make.sh: add new option 'macos-universal' to build MacOS universal binaries

This commit is contained in:
Nguyen Anh Quynh 2016-07-15 16:34:16 +08:00
parent c61aff1dbe
commit 6f5e59be73
3 changed files with 16 additions and 0 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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;;