Skip to content

Commit

Permalink
fix for make.sh for android (capstone-engine#1523)
Browse files Browse the repository at this point in the history
* fix for make.sh for android

* remove commented line
  • Loading branch information
occia authored and aquynh committed Jul 29, 2019
1 parent 1065ce7 commit b8c7a9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ capstone_get_setup
*.s

cstool/cstool

# android
android-ndk-*
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ endif

ifeq ($(CROSS),)
RANLIB ?= ranlib
else ifeq ($(ANDROID), 1)
CC = $(CROSS)/../../bin/clang
AR = $(CROSS)/ar
RANLIB = $(CROSS)/ranlib
STRIP = $(CROSS)/strip
else
CC = $(CROSS)gcc
AR = $(CROSS)ar
Expand Down Expand Up @@ -467,6 +472,7 @@ clean:
rm -f $(LIBOBJ)
rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).pc
rm -f $(PKGCFGF)
[ ${ANDROID} -eq 1 ] && rm -rf android-ndk-*
$(MAKE) -C cstool clean

ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
Expand Down
19 changes: 12 additions & 7 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build_android() {
echo "ERROR! Please set \$NDK to point at your Android NDK directory."
exit 1
fi

HOSTOS=$(uname -s | tr 'LD' 'ld')
HOSTARCH=$(uname -m)

Expand All @@ -22,13 +23,11 @@ build_android() {
case "$TARGARCH" in
arm)
[ -n "$APILEVEL" ] || APILEVEL="android-14" # default to ICS
[ -n "$GCCVER" ] || GCCVER="4.8"
CROSS=arm-linux-androideabi-
CROSS=arm-linux-androideabi
;;
arm64)
[ -n "$APILEVEL" ] || APILEVEL="android-21" # first with arm64
[ -n "$GCCVER" ] || GCCVER="4.9"
CROSS=aarch64-linux-android-
CROSS=aarch64-linux-android
;;

*)
Expand All @@ -37,10 +36,16 @@ build_android() {
;;
esac

TOOLCHAIN="$NDK/toolchains/$CROSS$GCCVER/prebuilt/$HOSTOS-$HOSTARCH"
PLATFORM="$NDK/platforms/$APILEVEL/arch-$TARGARCH"
STANDALONE=`realpath android-ndk-${TARGARCH}-${APILEVEL}`

[ -d $STANDALONE ] || {
python ${NDK}/build/tools/make_standalone_toolchain.py \
--arch ${TARGARCH} \
--api ${APILEVEL##*-} \
--install-dir ${STANDALONE}
}

CROSS="$TOOLCHAIN/bin/$CROSS" CFLAGS="--sysroot=$PLATFORM" LDFLAGS="--sysroot=$PLATFORM" ${MAKE} $*
ANDROID=1 CROSS="${STANDALONE}/${CROSS}/bin" CFLAGS="--sysroot=${STANDALONE}/sysroot" ${MAKE} $*
}

# build iOS lib for all iDevices, or only specific device
Expand Down

0 comments on commit b8c7a9f

Please sign in to comment.