Skip to content

Commit

Permalink
Fix gmp cross-compile build on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestagg committed Dec 21, 2023
1 parent 3afd925 commit 0db331d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions libs/recipes/gmp/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ GMP_VERSION = 6.3.0
GMP_TARBALL = $(DOWNLOAD)/gmp-$(GMP_VERSION).tar.gz
GMP_URL = https://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VERSION).tar.xz

# Cross-compile fix for Emscripten-on-macOS
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
HOST_CFLAGS += "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
HOST_CFLAGS += "-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
endif

.PHONY: gmp
gmp: $(GMP_WASM_LIB)

Expand All @@ -13,13 +20,14 @@ $(GMP_WASM_LIB): $(GMP_TARBALL)
mkdir -p $(BUILD)/gmp-$(GMP_VERSION)/build
tar -C $(BUILD) -xf $(GMP_TARBALL)
cd $(BUILD)/gmp-$(GMP_VERSION)/build && \
emconfigure ../configure \
--build=x86_64-pc-linux-gnu \
--host=wasm32-unknown-emscripten \
--enable-shared=no \
--enable-static=yes \
--disable-assembly \
--enable-cxx \
--prefix=$(WASM) && \
emconfigure bash -c '\
HOST_CC="$${HOST_CC} $(HOST_CFLAGS)" ../configure \
--host=wasm32-unknown-emscripten \
--enable-shared=no \
--enable-static=yes \
--disable-assembly \
--enable-cxx \
--prefix=$(WASM) \
' && \
emmake make install

0 comments on commit 0db331d

Please sign in to comment.