diff --git a/Makefile b/Makefile index 4e09a71..d1bee89 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,14 @@ em_flags = -std=c++17 \ -Wno-switch-enum \ -Wno-weak-vtables \ -Wno-missing-prototypes \ + -Wno-unsafe-buffer-usage \ --bind \ ./wrapper/hext-emscripten.cpp \ - -I./build-dep/include \ - ./build-dep/lib/libhext.a \ - ./build-dep/lib/libgumbo.a \ + -I./build-dep/boost/include \ + -I./build-dep/gumbo/include \ + -I./build-dep/libhext/include \ + ./build-dep/libhext/lib/libhext.a \ + ./build-dep/gumbo/lib/libgumbo.a \ -s MODULARIZE=1 \ -s EXPORT_NAME="loadHext" \ -s SINGLE_FILE=1 \ diff --git a/Makefile.boost b/Makefile.boost index a6a80c5..d48bd90 100644 --- a/Makefile.boost +++ b/Makefile.boost @@ -7,7 +7,7 @@ BOOST_SHA256=2575e74ffc3ef1cd0babac2c1ee8bdb5782a0ee672b1912da40e5b4b591ca01f boost: build/boost_${BOOST_VERSION}.tar.gz \ build/boost_${BOOST_VERSION} \ - build-dep/include/boost + build-dep/boost/include build/boost_${BOOST_VERSION}.tar.gz: cd build && \ @@ -18,11 +18,17 @@ build/boost_${BOOST_VERSION}: echo '${BOOST_SHA256} boost_${BOOST_VERSION}.tar.gz' | sha256sum -c && \ tar xf boost_${BOOST_VERSION}.tar.gz -build-dep/include/boost: - mkdir -p build-dep/include - cp -rf build/boost_${BOOST_VERSION}/boost build-dep/include/ +# Install Boost with its installer. This also creates the CMake config files, which are needed because newer +# versions of CMake no longer ship their own FindBoost module. +# Boost.System isn't actually needed. Boost.System is installed here, because Boost doesn't have an option to +# only install the header-only libraries. +build-dep/boost/include: + mkdir -p "${BASE}/build-dep/boost" && \ + cd "build/boost_${BOOST_VERSION}" && \ + ./bootstrap.sh --prefix="${BASE}/build-dep/boost" --with-libraries=system && \ + ./b2 install clean: - rm -rf build-dep/include/boost + rm -rf build-dep/boost rm -rf build/boost_* diff --git a/Makefile.gumbo b/Makefile.gumbo index a7e417b..273f4da 100644 --- a/Makefile.gumbo +++ b/Makefile.gumbo @@ -5,7 +5,7 @@ BASE=${PWD} all: build/v0.10.1.tar.gz build/gumbo-parser-0.10.1 \ build/gumbo-parser-0.10.1/configure \ build/gumbo-parser-0.10.1/Makefile \ - build-dep/lib/libgumbo.a + build-dep/gumbo/lib/libgumbo.a build/v0.10.1.tar.gz: cd build && wget https://github.com/google/gumbo-parser/archive/v0.10.1.tar.gz @@ -21,15 +21,15 @@ build/gumbo-parser-0.10.1/configure: build/gumbo-parser-0.10.1/Makefile: cd build/gumbo-parser-0.10.1 && \ emconfigure ./configure \ - --prefix=${BASE}/build-dep \ + --prefix=${BASE}/build-dep/gumbo \ --enable-static --disable-shared -build-dep/lib/libgumbo.a: +build-dep/gumbo/lib/libgumbo.a: cd build/gumbo-parser-0.10.1 && \ emmake make install clean: - rm -f build-dep/lib/libgumbo.a + rm -rf build-dep/gumbo rm -rf build/v0.10.1.tar.gz rm -rf build/gumbo-parser-0.10.1 diff --git a/Makefile.libhext b/Makefile.libhext index c95cc53..4e033ca 100644 --- a/Makefile.libhext +++ b/Makefile.libhext @@ -5,7 +5,7 @@ BASE=${PWD} all: build/v${VERSION}.tar.gz \ build/hext-${VERSION} \ - build-dep/lib/libhext.a + build-dep/libhext/lib/libhext.a build/v${VERSION}.tar.gz: cd build && \ @@ -16,25 +16,27 @@ build/hext-${VERSION}: echo '${SHA256} v${VERSION}.tar.gz' | sha256sum -c && \ tar xf v${VERSION}.tar.gz -build-dep/lib/libhext.a: +# CMAKE_PREFIX_PATH is ignored, unless CMAKE_FIND_ROOT_PATH_MODE_{LIBRARY,INCLUDE,PACKAGE} +# are set to "BOTH". If unset, the emscripten toolchain module sets them to "ONLY", breaking +# CMAKE_PREFIX_PATH. +build-dep/libhext/lib/libhext.a: cd build/hext-${VERSION}/libhext/build && \ - emcmake cmake \ + CMAKE_PREFIX_PATH="${BASE}/build-dep/boost:${BASE}/build-dep/gumbo" emcmake cmake \ -DCMAKE_AR=$(shell which emar) \ -DCMAKE_RANLIB=$(shell which emranlib) \ -DCMAKE_MAKE_PROGRAM=$(shell which emmake) \ -DCMAKE_C_COMPILER=$(shell which emcc) \ -DCMAKE_CXX_COMPILER=$(shell which em++) \ - -DGumbo_LIBRARY=${BASE}/build-dep/lib/libgumbo.a \ - -DGumbo_INCLUDE_DIR=${BASE}/build-dep/include \ - -DBoost_INCLUDE_DIR=${BASE}/build-dep/include \ - -DBoost_LIBRARY_DIR=${BASE}/build-dep/lib \ - -DCMAKE_FIND_ROOT_PATH=${BASE}/build-dep/lib/cmake \ - -DCMAKE_INSTALL_PREFIX=${BASE}/build-dep \ + -DCMAKE_INSTALL_PREFIX="${BASE}/build-dep/libhext" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \ .. && \ emmake make install VERBOSE=1 clean: - rm -f build-dep/lib/libhext.a + rm -rf build-dep/libhext rm -rf build/v${VERSION}.tar.gz rm -rf build/hext-${VERSION}