Debian Codegraph @

make.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Capstone Disassembly Engine
4 # By Nguyen Anh Quynh <[email protected]>, 2013-2019
5
6 # Note: to cross-compile "nix32" on Linux, package gcc-multilib is required.
7
8 MAKE_JOBS=${MAKE_JOBS:-4}
9
10 # build Android lib for only one supported architecture
11 build_androidscip-shell shell shell-project 0.0.0 build_android().() {
12 if [scip-shell system . . `[`. -z "$NDK" ]; then
13 echoscip-shell system . . echo. "ERROR! Please set \$NDK to point at your Android NDK directory."
14 exit 1
15 fi
16
17 HOSTOS=$(unamescip-shell system . . uname. -s | trscip-shell system . . tr. 'LD' 'ld')
18 HOSTARCH=$(unamescip-shell system . . uname. -m)
19
20 TARGARCH="$1"
21 shift
22
23 case "$TARGARCH" in
24 arm)
25 [scip-shell system . . `[`. -n "$APILEVEL" ] || APILEVEL="android-14" # default to ICS
26 CROSS=arm-linux-androideabi
27 ;;
28 arm64)
29 [scip-shell system . . `[`. -n "$APILEVEL" ] || APILEVEL="android-21" # first with arm64
30 CROSS=aarch64-linux-android
31 ;;
32
33 *)
34 echoscip-shell system . . echo. "ERROR! Building for Android on $1 is not currently supported."
35 exit 1
36 ;;
37 esac
38
39 STANDALONE=`realpathscip-shell system . . realpath. android-ndk-${TARGARCH}-${APILEVEL}`
40
41 [scip-shell system . . `[`. -d $STANDALONE ] || {
42 python ${NDK}/build/tools/make_standalone_toolchain.py \
43 --arch ${TARGARCH} \
44 --api ${APILEVEL##*-} \
45 --install-dir ${STANDALONE}
46 }
47
48 ANDROID=1 CROSS="${STANDALONE}/${CROSS}/bin" CFLAGS="--sysroot=${STANDALONE}/sysroot" ${MAKE} $*
49 }
50
51 # build iOS lib for all iDevices, or only specific device
52 build_iOSscip-shell shell shell-project 0.0.0 build_iOS().() {
53 IOS_SDK=`xcrun --sdk iphoneos --show-sdk-path`
54 IOS_CC=`xcrun --sdk iphoneos -f clang`
55 IOS_CFLAGS="-Os -Wimplicit -isysroot $IOS_SDK"
56 IOS_LDFLAGS="-isysroot $IOS_SDK"
57 if [scip-shell system . . `[`. -z "$1" ]; then
58 # build for all iDevices
59 IOS_ARCHS="armv7 armv7s arm64"
60 else
61 IOS_ARCHS="$1"
62 fi
63 export CC="$IOS_CC"
64 export LIBARCHS="$IOS_ARCHS"
65 CFLAGS="$IOS_CFLAGS" LDFLAGS="$IOS_LDFLAGS" MACOS_UNIVERSAL=yes ${MAKE}
66 }
67
68 installscip-shell shell shell-project 0.0.0 install().() {
69 # Mac OSX needs to find the right directory for pkgconfig
70 if [scip-shell system . . `[`. "$UNAME" = Darwin ]; then
71 # we are going to install into /usr/local, so remove old installs under /usr
72 rmscip-shell system . . rm. -rf /usr/lib/libcapstone.*
73 rmscip-shell system . . rm. -rf /usr/include/capstonescip-shell filesystem . . `/usr/include/capstone`.
74 if [scip-shell system . . `[`. "${HOMEBREW_CAPSTONE}" != 1 ]; then
75 # find the directory automatically, so we can support both Macport & Brew
76 export PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cutscip-shell system . . cut. -d ':' -f 1)"
77 fi
78 ${MAKE} install
79 else # not OSX
80 testscip-shell system . . test. -d /usr/lib64scip-shell filesystem . . `/usr/lib64`. && ${MAKE} LIBDIRARCH=lib64
81 ${MAKE} install
82 fi
83 }
84
85 uninstallscip-shell shell shell-project 0.0.0 uninstall().() {
86 # Mac OSX needs to find the right directory for pkgconfig
87 if [scip-shell system . . `[`. "$UNAME" = "Darwin" ]; then
88 # find the directory automatically, so we can support both Macport & Brew
89 export PKGCFGDIR="$(pkg-config --variable pc_path pkg-config | cutscip-shell system . . cut. -d ':' -f 1)"
90 ${MAKE} uninstall
91 else # not OSX
92 testscip-shell system . . test. -d /usr/lib64scip-shell filesystem . . `/usr/lib64`. && LIBDIRARCH=lib64
93 ${MAKE} uninstall
94 fi
95 }
96
97 UNAME="${UNAME:-$(unamescip-shell system . . uname.)}"
98
99 if [scip-shell system . . `[`. "$UNAME" = SunOS ]; then
100 MAKE="${MAKE:-gmake}"
101 export INSTALL_BIN=ginstall
102 export CC=gcc
103 fi
104
105 MAKE="${MAKE:-make}"
106
107 if echoscip-shell system . . echo. "$UNAME" | grepscip-shell system . . grep. -q BSD; then
108 MAKE=gmake
109 export PREFIX=/usr/localscip-shell filesystem . . `/usr/local`.
110 fi
111
112 MAKE="$MAKE -j${MAKE_JOBS}"
113
114 TARGET="$1"
115 [scip-shell system . . `[`. $# -gt 0 ] && shift
116
117 case "$TARGET" in
118 "" | "default" ) ${MAKE} "$@";;
119 "debug" ) \
120 CAPSTONE_USE_SYS_DYN_MEM=yes \
121 CAPSTONE_STATIC=yes \
122 CFLAGS='-DCAPSTONE_DEBUG -O0 -g -fsanitize=address' \
123 LDFLAGS='-fsanitize=address' \
124 ${MAKE} "$@";;
125 "install" ) installscip-shell shell shell-project 0.0.0 install().;;
126 "uninstall" ) uninstallscip-shell shell shell-project 0.0.0 uninstall().;;
127 "nix32" ) CFLAGS=-m32 LDFLAGS=-m32 ${MAKE} "$@";;
128 "cross-win32" ) CROSS=i686-w64-mingw32- ${MAKE} "$@";;
129 "cross-win64" ) CROSS=x86_64-w64-mingw32- ${MAKE} "$@";;
130 "cygwin-mingw32" ) CROSS=i686-pc-mingw32- ${MAKE} "$@";;
131 "cygwin-mingw64" ) CROSS=x86_64-w64-mingw32- ${MAKE} "$@";;
132 "cross-android" ) build_androidscip-shell shell shell-project 0.0.0 build_android(). "$@";;
133 "cross-android64" ) CROSS=aarch64-linux-gnu- ${MAKE} "$@";; # Linux cross build
134 "clang" ) CC=clang ${MAKE} "$@";;
135 "gcc" ) CC=gcc ${MAKE} "$@";;
136 "ios" ) build_iOSscip-shell shell shell-project 0.0.0 build_iOS(). "$@";;
137 "ios_armv7" ) build_iOSscip-shell shell shell-project 0.0.0 build_iOS(). armv7 "$@";;
138 "ios_armv7s" ) build_iOSscip-shell shell shell-project 0.0.0 build_iOS(). armv7s "$@";;
139 "ios_arm64" ) build_iOSscip-shell shell shell-project 0.0.0 build_iOS(). arm64 "$@";;
140 "osx-kernel" ) CAPSTONE_USE_SYS_DYN_MEM=yes \
141 CAPSTONE_HAS_OSXKERNEL=yes \
142 CAPSTONE_ARCHS=x86 \
143 CAPSTONE_SHARED=no \
144 CAPSTONE_BUILD_CORE_ONLY=yes \
145 ${MAKE} "$@";;
146 "mac-universal" ) MACOS_UNIVERSAL=yes ${MAKE} "$@";;
147 "mac-universal-no" ) MACOS_UNIVERSAL=no ${MAKE} "$@";;
148 "xlc31" ) CC=xlc CFLAGS=-q31 LDFLAGS=-q31 ${MAKE} "$@";;
149 "xlc32" ) CC=xlc CFLAGS=-q32 LDFLAGS=-q32 ${MAKE} "$@";;
150 "xlc64" ) CC=xlc CFLAGS=-q64 LDFLAGS=-q64 ${MAKE} "$@";;
151 * )
152 echoscip-shell system . . echo. "Usage: $0 ["$(grepscip-shell system . . grep. '^ "' $0 | cutscip-shell system . . cut. -d '"' -f 2 | trscip-shell system . . tr. "\\n" "|")"]"
153 exit 1;;
154 esac