From 6f5e59be73ac5f8940e51d63044abb18a1be3646 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Fri, 15 Jul 2016 16:34:16 +0800 Subject: [PATCH] make.sh: add new option 'macos-universal' to build MacOS universal binaries --- Makefile | 4 ++++ docs/COMPILE-NIX.md | 5 +++++ make.sh | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/Makefile b/Makefile index 1015d324..93448875 100644 --- a/Makefile +++ b/Makefile @@ -105,10 +105,14 @@ ifeq ($(IS_APPLE),1) EXT = dylib VERSION_EXT = $(API_MAJOR).$(EXT) $(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR) +ifeq ($(MACOS_UNIVERSAL),yes) $(LIBNAME)_LDFLAGS += -m32 -arch i386 -m64 -arch x86_64 +endif AR_EXT = a UNICORN_CFLAGS += -fvisibility=hidden +ifeq ($(MACOS_UNIVERSAL),yes) UNICORN_CFLAGS += -m32 -arch i386 -m64 -arch x86_64 +endif else # Cygwin? IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l) diff --git a/docs/COMPILE-NIX.md b/docs/COMPILE-NIX.md index 06341b19..bfc08e39 100644 --- a/docs/COMPILE-NIX.md +++ b/docs/COMPILE-NIX.md @@ -58,6 +58,11 @@ To build Unicorn on *nix (such as MacOSX, Linux, *BSD, Solaris): $ ./make.sh + On Mac OS, to build universal binaries including both 32-bit & 64-bit code, + replace above command with: + + $ ./make.sh macos-universal + - Unicorn requires Python 2.x to compile. If Python 2.x is not the default Python interpreter, ensure that the appropriate option is set: diff --git a/make.sh b/make.sh index bb234572..c512f6e6 100755 --- a/make.sh +++ b/make.sh @@ -41,6 +41,12 @@ build() { ${MAKE} } +build_macos_universal() { + [ "$UNAME" = Darwin ] && LIBARCHS="i386 x86_64" + MACOS_UNIVERSAL=yes \ + ${MAKE} +} + build_cross() { [ "$UNAME" = Darwin ] && LIBARCHS="i386 x86_64" CROSS=$1 @@ -97,6 +103,7 @@ export CC INSTALL_BIN PREFIX PKGCFGDIR LIBDIRARCH LIBARCHS CFLAGS LDFLAGS case "$1" in "" ) build;; + "macos-universal" ) build_macos_universal;; "asan" ) asan;; "default" ) build;; "install" ) install;;