diff --git a/Makefile-rules b/Makefile-rules deleted file mode 100644 index 6c39f2d..0000000 --- a/Makefile-rules +++ /dev/null @@ -1,49 +0,0 @@ - -.PHONY: native -native: ${DIST_NATIVE}/.built - -.PHONY: wasm -wasm: ${DIST_WASM}/.built - -.PHONY: clean-wasm -clean-wasm:: - rm -rf ${BUILD_WASM} ${DIST_WASM} - -.PHONY: clean-native -clean-native:: - rm -rf ${BUILD_NATIVE} ${DIST_NATIVE} - -.PHONY: clean-build -clean-build:: - rm -rf ${BUILD} ${SRC}/zig-cache - -clean-node_modules:: - rm -rf node_modules - -.PHONY: clean -clean:: clean-wasm clean-native clean-node_modules - rm -rf ${BUILD} ${DIST} tsconfig.tsbuildinfo ${SRC}/zig-cache - -${TARBALL}: - mkdir -p ${UPSTREAM} - curl -L ${URL} -o ${TARBALL} - -# NOTE: these double colon rules can be nicely overridden, which is where additional patching goes. -# See https://stackoverflow.com/questions/1644920/override-target-in-makefile-to-add-more-commands -# -${BUILD_NATIVE}/.build:: ${TARBALL} - rm -rf ${BUILD_NATIVE} - mkdir -p ${BUILD_NATIVE} - tar xf ${TARBALL} -C ${BUILD_NATIVE} --strip-components=1 - touch ${BUILD_NATIVE}/.build - -${BUILD_WASM}/.build:: ${TARBALL} - rm -rf ${BUILD_WASM} - mkdir -p ${BUILD_WASM} - tar xf ${TARBALL} -C ${BUILD_WASM} --strip-components=1 - touch ${BUILD_WASM}/.build - -node_modules: - cd ../node && make - npm install - diff --git a/Makefile-vars b/Makefile-vars deleted file mode 100644 index 44a4b1b..0000000 --- a/Makefile-vars +++ /dev/null @@ -1,56 +0,0 @@ -# This is a Makefile of common definitions that is used by other packages that -# involve building upstream code from source. - -# The directory containing the package where the makefile is run, e.g., packages/bzip2 -CWD:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) - -# The directory containing all of the packages. -PACKAGES = ${CWD}/.. - -# Where the upstream sources are cached -UPSTREAM = ${CWD}/../../upstream/sources - -# Binaries useful for building, e.g., node, zig, cowasm -BIN = ${CWD}/../../bin - - - -# Include the BIN directory at front of path. -# See https://stackoverflow.com/questions/8941110/how-i-could-add-dir-to-path-in-makefile -export PATH := $(BIN):$(PATH) -export SHELL := env PATH='$(PATH)' /bin/bash - -# Where sources, e.g., patches, customizations, new code, etc., are stored for this build. -SRC = ${CWD}/src - -# Temporary path where we do the build. These files can always be deleted without impacting -# the artifact in dist. -BUILD = ${CWD}/build -BUILD_NATIVE = ${BUILD}/native -BUILD_WASM = ${BUILD}/wasm - -# Where we put the result of the build, e.g., --prefix=${DIST_WASM} -DIST = ${CWD}/dist -DIST_NATIVE = ${DIST}/native -DIST_WASM = ${DIST}/wasm - -UNAME_S := $(shell uname -s) -UNAME_M := $(shell uname -m) - - -# This target below also works around a zig bug -- the native build fails -# with "ld.lld: error: undefined symbol: fcntl64". -# See https://github.com/ziglang/zig/issues/5882 and https://github.com/ziglang/zig/issues/9485 -# NOTE: we use musl instead of gnu.2.31, since musl works on CoCalc (a massive messy huge Linux -# environment), wheras gnu.2.31 only worked on several minimal linux envs. Plus it's pretty cool -# that we can use musl and it works! - -ifeq ($(UNAME_S),Linux) - # On Linux we explicitly always build for musl - # See https://github.com/ziglang/zig/issues/12797 - ZIG_NATIVE_CFLAGS="--target=$(UNAME_M)-linux-musl" - ZIG_NATIVE_CFLAGS_GNU="--target=$(UNAME_M)-linux-gnu.2.31" -else - ZIG_NATIVE_CFLAGS="" - ZIG_NATIVE_CFLAGS_GNU="" -endif diff --git a/Makefile-vars-build b/Makefile-vars-build new file mode 100644 index 0000000..c3eb18e --- /dev/null +++ b/Makefile-vars-build @@ -0,0 +1,10 @@ +# This is a bootstrap version of Makefile-vars, just for installing some binaries. + +CWD:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +PACKAGES = ${CWD}/../../.. +UPSTREAM = ${PACKAGES}/../upstream/sources +BIN = ${PACKAGES}/../bin +BUILD = ${CWD}/build +BUILD_NATIVE = ${BUILD}/native +DIST = ${CWD}/dist +DIST_NATIVE = ${DIST}/native diff --git a/node/Makefile b/node/Makefile index 0eff1cd..1eafc17 100644 --- a/node/Makefile +++ b/node/Makefile @@ -2,7 +2,7 @@ # for your architecture here, so that we can use it for # building everything else. -include ../build/Makefile-vars +include ../Makefile-vars-build # Find the latest version at https://nodejs.org/dist/latest/ VERSION = 19.1.0 @@ -20,7 +20,7 @@ OS = $(shell uname -s | sed s/Darwin/darwin/ | sed s/Linux/linux/) TARBALL = ${UPSTREAM}/node-v${VERSION}-${OS}-${ARCH}.tar.xz URL = https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-${OS}-${ARCH}.tar.xz -include ../build/Makefile-rules +include ../../Makefile-rules ${DIST_NATIVE}/.${VERSION}: ${TARBALL} rm -rf ${DIST_NATIVE} diff --git a/zig/Makefile b/zig/Makefile index a70e29e..988419f 100644 --- a/zig/Makefile +++ b/zig/Makefile @@ -2,7 +2,7 @@ # for your architecture here, so that we can use it for # building everything else. -include ../build/Makefile-vars +include ../Makefile-vars-build # Find the latest version at https://ziglang.org/download/ @@ -41,7 +41,7 @@ TARBALL = ${UPSTREAM}/zig-${OS}-${ARCH}-${VERSION}.tar.xz all: ${DIST_NATIVE}/.${VERSION} ${BIN}/cowasm-cc ${BIN}/cowasm-c++ ${BIN}/cowasm-zig ${BIN}/zig -include ../build/Makefile-rules +include ../../Makefile-rules ${DIST_NATIVE}/.${VERSION}: ${TARBALL} rm -rf ${DIST_NATIVE}