Move functionality from make.sh to Makefile (#1142)
simplifies builds, prevents overriding of options
This commit is contained in:
parent
b0733cd36c
commit
c27f326dcc
9
Makefile
9
Makefile
|
@ -8,6 +8,12 @@ include functions.mk
|
|||
# Verbose output?
|
||||
V ?= 0
|
||||
|
||||
OS := $(shell uname)
|
||||
ifeq ($(OS),Darwin)
|
||||
LIBARCHS = i386 x86_64
|
||||
PREFIX ?= /usr/local
|
||||
endif
|
||||
|
||||
ifeq ($(PKG_EXTRA),)
|
||||
PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR)
|
||||
else
|
||||
|
@ -15,10 +21,7 @@ PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA)
|
|||
endif
|
||||
|
||||
ifeq ($(CROSS),)
|
||||
CC ?= cc
|
||||
AR ?= ar
|
||||
RANLIB ?= ranlib
|
||||
STRIP ?= strip
|
||||
else
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
|
|
51
make.sh
51
make.sh
|
@ -57,16 +57,9 @@ build_iOS() {
|
|||
else
|
||||
IOS_ARCHS="$1"
|
||||
fi
|
||||
CC="$IOS_CC" \
|
||||
CFLAGS="$IOS_CFLAGS" \
|
||||
LDFLAGS="$IOS_LDFLAGS" \
|
||||
LIBARCHS="$IOS_ARCHS" \
|
||||
${MAKE}
|
||||
}
|
||||
|
||||
build() {
|
||||
[ "$UNAME" = Darwin ] && LIBARCHS="i386 x86_64"
|
||||
${MAKE} $*
|
||||
export CC="$IOS_CC"
|
||||
export LIBARCHS="$IOS_ARCHS"
|
||||
CFLAGS="$IOS_CFLAGS" LDFLAGS="$IOS_LDFLAGS" ${MAKE}
|
||||
}
|
||||
|
||||
install() {
|
||||
|
@ -75,11 +68,9 @@ install() {
|
|||
# we are going to install into /usr/local, so remove old installs under /usr
|
||||
rm -rf /usr/lib/libcapstone.*
|
||||
rm -rf /usr/include/capstone
|
||||
# install into /usr/local
|
||||
PREFIX=/usr/local
|
||||
if [ "${HOMEBREW_CAPSTONE}" != 1 ]; then
|
||||
# find the directory automatically, so we can support both Macport & Brew
|
||||
PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
|
||||
export PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
|
||||
fi
|
||||
${MAKE} install
|
||||
else # not OSX
|
||||
|
@ -92,8 +83,7 @@ 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)"
|
||||
PREFIX=/usr/local
|
||||
export PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cut -d ':' -f 1)"
|
||||
${MAKE} uninstall
|
||||
else # not OSX
|
||||
test -d /usr/lib64 && LIBDIRARCH=lib64
|
||||
|
@ -103,43 +93,42 @@ uninstall() {
|
|||
|
||||
if [ "$UNAME" = SunOS ]; then
|
||||
[ -z "${MAKE}" ] && MAKE=gmake
|
||||
INSTALL_BIN=ginstall
|
||||
CC=gcc
|
||||
export INSTALL_BIN=ginstall
|
||||
export CC=gcc
|
||||
fi
|
||||
|
||||
if [ -n "`echo "$UNAME" | grep BSD`" ]; then
|
||||
MAKE=gmake
|
||||
PREFIX=/usr/local
|
||||
export PREFIX=/usr/local
|
||||
fi
|
||||
|
||||
[ -z "${UNAME}" ] && UNAME=$(uname)
|
||||
[ -z "${MAKE}" ] && MAKE=make
|
||||
[ -n "${MAKE_JOBS}" ] && MAKE="$MAKE -j${MAKE_JOBS}"
|
||||
export CC INSTALL_BIN PREFIX PKGCFGDIR LIBDIRARCH LIBARCHS CFLAGS LDFLAGS
|
||||
|
||||
TARGET="$1"
|
||||
[ -n "$TARGET" ] && shift
|
||||
|
||||
case "$TARGET" in
|
||||
"" ) build $*;;
|
||||
"default" ) build $*;;
|
||||
"debug" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_STATIC=yes CFLAGS='-O0 -g -fsanitize=address' LDFLAGS='-fsanitize=address' build $*;;
|
||||
"" ) ${MAKE} $*;;
|
||||
"default" ) ${MAKE} $*;;
|
||||
"debug" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_STATIC=yes CFLAGS='-O0 -g -fsanitize=address' LDFLAGS='-fsanitize=address' ${MAKE} $*;;
|
||||
"install" ) install;;
|
||||
"uninstall" ) uninstall;;
|
||||
"nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build $*;;
|
||||
"cross-win32" ) CROSS=i686-w64-mingw32- build $*;;
|
||||
"cross-win64" ) CROSS=x86_64-w64-mingw32- build $*;;
|
||||
"cygwin-mingw32" ) CROSS=i686-pc-mingw32- build $*;;
|
||||
"cygwin-mingw64" ) CROSS=x86_64-w64-mingw32- build $*;;
|
||||
"nix32" ) CFLAGS=-m32 LDFLAGS=-m32 ${MAKE} $*;;
|
||||
"cross-win32" ) CROSS=i686-w64-mingw32- ${MAKE} $*;;
|
||||
"cross-win64" ) CROSS=x86_64-w64-mingw32- ${MAKE} $*;;
|
||||
"cygwin-mingw32" ) CROSS=i686-pc-mingw32- ${MAKE} $*;;
|
||||
"cygwin-mingw64" ) CROSS=x86_64-w64-mingw32- ${MAKE} $*;;
|
||||
"cross-android" ) build_android $*;;
|
||||
"cross-android64" ) CROSS=aarch64-linux-gnu- build $*;; # Linux cross build
|
||||
"clang" ) CC=clang build $*;;
|
||||
"gcc" ) CC=gcc build $*;;
|
||||
"cross-android64" ) CROSS=aarch64-linux-gnu- ${MAKE} $*;; # Linux cross build
|
||||
"clang" ) CC=clang ${MAKE} $*;;
|
||||
"gcc" ) CC=gcc ${MAKE} $*;;
|
||||
"ios" ) build_iOS $*;;
|
||||
"ios_armv7" ) build_iOS armv7 $*;;
|
||||
"ios_armv7s" ) build_iOS armv7s $*;;
|
||||
"ios_arm64" ) build_iOS arm64 $*;;
|
||||
"osx-kernel" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_HAS_OSXKERNEL=yes CAPSTONE_ARCHS=x86 CAPSTONE_SHARED=no CAPSTONE_BUILD_CORE_ONLY=yes build $*;;
|
||||
"osx-kernel" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_HAS_OSXKERNEL=yes CAPSTONE_ARCHS=x86 CAPSTONE_SHARED=no CAPSTONE_BUILD_CORE_ONLY=yes ${MAKE} $*;;
|
||||
"mac-universal-no" ) MACOS_UNIVERSAL=no ${MAKE} $*;;
|
||||
* )
|
||||
echo "Usage: $0 ["`grep '^ "' $0 | cut -d '"' -f 2 | tr "\\n" "|"`"]"
|
||||
|
|
Loading…
Reference in New Issue