# 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., core/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