Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/aquynh/capstone into next
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Apr 14, 2014
2 parents 91af6b2 + 360bf1e commit 1d03727
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 32 deletions.
33 changes: 11 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ PREFIX ?= /usr
DESTDIR ?=
INCDIR = $(DESTDIR)$(PREFIX)/include

UNAME_M := $(shell uname -m)
UNAME_S := $(shell uname -s)

LIBDIR = $(DESTDIR)$(PREFIX)/lib
# on x86_64, we might have /usr/lib64 directory instead of /usr/lib
ifeq ($(UNAME_M), x86_64)
# ignore Mac OSX
ifneq ($(UNAME_S), Darwin)
ifneq (,$(wildcard $(DESTDIR)$(PREFIX)/lib64))
LIBDIR = $(DESTDIR)$(PREFIX)/lib64
endif
endif
endif
LIBDIRARCH ?= lib
# Uncomment the below line to installs x86_64 libs to lib64/ directory.
# Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'.
#LIBDIRARCH ?= lib64
LIBDIR = $(DESTDIR)$(PREFIX)/$(LIBDIRARCH)

ifneq ($(UNAME_S),Darwin)
LDFLAGS += -shared
Expand Down Expand Up @@ -197,7 +191,7 @@ LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SP
LIBOBJ += MCInst.o


PKGCFCGDIR = $(LIBDATADIR)/pkgconfig
PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
VERSION_EXT =

Expand All @@ -207,18 +201,13 @@ EXT = dylib
VERSION_EXT = $(API_MAJOR).$(EXT)
LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
AR_EXT = a
# Homebrew wants to make sure its formula does not disable FORTIFY_SOURCE
# However, this is not really necessary because 'USE_SYS_DYN_MEM=yes' by default
ifneq ($(HOMEBREW_CAPSTONE),1)
ifneq ($(USE_SYS_DYN_MEM),yes)
# remove string check because OSX kernel complains about missing symbols
CFLAGS += -D_FORTIFY_SOURCE=0
endif
# By default, suppose that Brew is installed & use Brew path for pkgconfig file
PKGCFCGDIR = /usr/local/lib/pkgconfig
# is Macport installed instead?
ifneq (,$(wildcard /opt/local/bin/port))
# then correct the path for pkgconfig file
PKGCFCGDIR = /opt/local/lib/pkgconfig
endif
endif
else
# Cygwin?
Expand Down Expand Up @@ -303,13 +292,13 @@ endif
$(INSTALL_DATA) lib$(LIBNAME).$(AR_EXT) $(LIBDIR)
mkdir -p $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME)
mkdir -p $(PKGCFCGDIR)
$(INSTALL_DATA) $(PKGCFGF) $(PKGCFCGDIR)/
mkdir -p $(PKGCFGDIR)
$(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)/

uninstall:
rm -rf $(INCDIR)/$(LIBNAME)
rm -f $(LIBDIR)/lib$(LIBNAME).*
rm -f $(PKGCFCGDIR)/$(LIBNAME).pc
rm -f $(PKGCFGDIR)/$(LIBNAME).pc

clean:
rm -f $(LIBOBJ) lib$(LIBNAME).*
Expand Down
66 changes: 56 additions & 10 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,76 @@ function build {
}

function install {
if [ ${CC}x != x ]; then
${MAKE} CC=$CC install
else
${MAKE} install
# Mac OSX needs to find the right directory for pkgconfig
if [ "$(uname)" == "Darwin" ]; then
# find the directory automatically, so we can support both Macport & Brew
PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
if [ ${PKGCFGDIR}x != x ]; then
if [ ${CC}x != x ]; then
${MAKE} CC=$CC PKGCFGDIR=$PKGCFGDIR install
else
${MAKE} PKGCFGDIR=$PKGCFGDIR install
fi
else
if [ ${CC}x != x ]; then
${MAKE} CC=$CC install
else
${MAKE} install
fi
fi
else # not OSX
if test -d /usr/lib64; then
if [ ${CC}x != x ]; then
${MAKE} LIBDIRARCH=lib64 CC=$CC install
else
${MAKE} LIBDIRARCH=lib64 install
fi
else
if [ ${CC}x != x ]; then
${MAKE} CC=$CC install
else
${MAKE} install
fi
fi
fi
}

function uninstall {
# Mac OSX needs to find the right directory for pkgconfig
if [ "$(uname)" == "Darwin" ]; then
# find the directory automatically, so we can support both Macport & Brew
PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
if [ ${PKGCFGDIR}x != x ]; then
${MAKE} PKGCFGDIR=$PKGCFGDIR uninstall
else
${MAKE} uninstall
fi
else # not OSX
if test -d /usr/lib64; then
${MAKE} LIBDIRARCH=lib64 uninstall
else
${MAKE} uninstall
fi
fi
}

MAKE=make
if [ "$(uname)" == "SunOS" ]; then
export MAKE=gmake
export INSTALL_BIN=ginstall
export CC=gcc
export MAKE=gmake
export INSTALL_BIN=ginstall
export CC=gcc
fi

if [[ "$(uname)" == *BSD* ]]; then
export MAKE=gmake
export PREFIX=/usr/local
export MAKE=gmake
export PREFIX=/usr/local
fi

case "$1" in
"" ) build;;
"default" ) build;;
"install" ) install;;
"uninstall" ) ${MAKE} uninstall;;
"uninstall" ) uninstall;;
"nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build;;
"cross-win32" ) CROSS=i686-w64-mingw32- build;;
"cross-win64" ) CROSS=x86_64-w64-mingw32- build;;
Expand Down

0 comments on commit 1d03727

Please sign in to comment.