2011-09-22 22:16:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-07-15 09:58:11 +00:00
|
|
|
MAKE_JOBS=12
|
2013-05-02 21:49:58 +00:00
|
|
|
[ -z "${PREFIX}" ] && PREFIX=/usr
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-h)
|
|
|
|
echo "Usage: sys/build.sh [/usr]"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
'')
|
|
|
|
:
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PREFIX="$1"
|
|
|
|
;;
|
|
|
|
esac
|
2012-08-27 15:02:58 +00:00
|
|
|
|
|
|
|
[ ! "${PREFIX}" = /usr ] && \
|
2014-09-24 22:47:43 +00:00
|
|
|
CFGARG="${CFGARG} --with-rpath"
|
2012-08-10 09:35:38 +00:00
|
|
|
|
2011-07-02 21:15:40 +00:00
|
|
|
MAKE=make
|
|
|
|
gmake --help >/dev/null 2>&1
|
|
|
|
[ $? = 0 ] && MAKE=gmake
|
|
|
|
|
2011-09-22 22:16:29 +00:00
|
|
|
# find root
|
|
|
|
cd `dirname $PWD/$0` ; cd ..
|
|
|
|
|
|
|
|
ccache --help > /dev/null 2>&1
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
[ -z "${CC}" ] && CC=gcc
|
|
|
|
CC="ccache ${CC}"
|
|
|
|
export CC
|
|
|
|
fi
|
|
|
|
|
2015-05-14 01:46:09 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "export USE_R2_CAPSTONE=$USE_R2_CAPSTONE"
|
|
|
|
echo
|
2015-03-11 11:10:31 +00:00
|
|
|
# Set USE_R2_CAPSTONE env var to ignore syscapstone check
|
|
|
|
if [ -z "${USE_R2_CAPSTONE}" ]; then
|
2014-11-23 22:25:14 +00:00
|
|
|
pkg-config --atleast-version=3.0 capstone 2>/dev/null
|
|
|
|
if [ $? = 0 ]; then
|
2015-02-20 20:25:03 +00:00
|
|
|
echo '#include <capstone.h>' > .a.c
|
|
|
|
echo 'int main() {return 0;}' >> .a.c
|
|
|
|
gcc `pkg-config --cflags --libs capstone` -o .a.out .a.c
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
CFGARG="${CFGARG} --with-syscapstone"
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "** WARNING ** capstone pkg-config is wrongly installed."
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
rm -f .a.c .a.out
|
2014-11-23 22:25:14 +00:00
|
|
|
fi
|
2015-03-11 11:10:31 +00:00
|
|
|
fi
|
2014-11-23 22:25:14 +00:00
|
|
|
|
2011-09-22 22:16:29 +00:00
|
|
|
# build
|
2012-08-10 09:35:38 +00:00
|
|
|
${MAKE} mrproper > /dev/null 2>&1
|
2014-07-02 15:28:23 +00:00
|
|
|
if [ -d shlr/capstone/.git ]; then
|
|
|
|
( cd shlr/capstone ; git clean -xdf )
|
|
|
|
fi
|
2014-11-04 09:58:40 +00:00
|
|
|
[ "`uname`" = Linux ] && export LDFLAGS="-Wl,--as-needed ${LDFLAGS}"
|
2012-08-14 23:32:02 +00:00
|
|
|
rm -f plugins.cfg
|
2012-08-27 15:02:58 +00:00
|
|
|
./configure ${CFGARG} --prefix=${PREFIX} || exit 1
|
2014-05-03 00:17:30 +00:00
|
|
|
exec ${MAKE} -s -j${MAKE_JOBS} MAKE_JOBS=${MAKE_JOBS}
|