2011-11-22 14:12:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-03-02 15:38:42 +00:00
|
|
|
if [ "$(uname)" = Linux ]; then
|
2018-03-11 22:35:40 +00:00
|
|
|
LDFLAGS="${LDFLAGS} -lpthread -ldl -lutil -lm"
|
2018-03-02 15:38:42 +00:00
|
|
|
fi
|
2011-11-22 14:12:29 +00:00
|
|
|
MAKE=make
|
|
|
|
gmake --help >/dev/null 2>&1
|
|
|
|
[ $? = 0 ] && MAKE=gmake
|
|
|
|
|
2017-02-02 11:00:02 +00:00
|
|
|
if [ `uname` = Darwin ]; then
|
|
|
|
STRIP="strip"
|
|
|
|
else
|
|
|
|
STRIP="strip -s"
|
|
|
|
fi
|
|
|
|
|
2011-11-22 14:12:29 +00:00
|
|
|
# find root
|
2015-06-17 02:39:19 +00:00
|
|
|
cd "$(dirname "$PWD/$0")" ; cd ..
|
2011-11-22 14:12:29 +00:00
|
|
|
|
|
|
|
ccache --help > /dev/null 2>&1
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
[ -z "${CC}" ] && CC=gcc
|
|
|
|
CC="ccache ${CC}"
|
|
|
|
export CC
|
|
|
|
fi
|
2015-01-24 02:30:07 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
PREFIX="$1"
|
2018-02-19 12:17:21 +00:00
|
|
|
else
|
|
|
|
PREFIX=/usr
|
2015-01-24 02:30:07 +00:00
|
|
|
fi
|
2018-02-19 12:17:21 +00:00
|
|
|
DOCFG=1
|
|
|
|
if [ 1 = "${DOCFG}" ]; then
|
2015-01-24 20:18:26 +00:00
|
|
|
# build
|
|
|
|
if [ -f config-user.mk ]; then
|
|
|
|
${MAKE} mrproper > /dev/null 2>&1
|
|
|
|
fi
|
2018-03-11 22:35:40 +00:00
|
|
|
export CFLAGS="${CFLAGS} -fPIC"
|
2018-02-19 12:17:21 +00:00
|
|
|
cp -f plugins.static.cfg plugins.cfg
|
2015-04-08 14:07:57 +00:00
|
|
|
#-D__ANDROID__=1"
|
2015-11-01 18:31:07 +00:00
|
|
|
./configure-plugins || exit 1
|
2018-05-28 15:14:49 +00:00
|
|
|
./configure --prefix="$PREFIX" --with-libr --disable-loadlibs || exit 1
|
2011-11-22 14:12:29 +00:00
|
|
|
fi
|
2015-11-01 09:26:38 +00:00
|
|
|
${MAKE} -j 8 || exit 1
|
2015-04-09 21:36:18 +00:00
|
|
|
BINS="rarun2 rasm2 radare2 ragg2 rabin2 rax2 rahash2 rafind2 rasign2 r2agent radiff2"
|
2015-06-17 02:39:19 +00:00
|
|
|
# shellcheck disable=SC2086
|
2015-04-09 21:36:18 +00:00
|
|
|
for a in ${BINS} ; do
|
|
|
|
(
|
2015-07-22 23:19:10 +00:00
|
|
|
cd binr/$a
|
|
|
|
${MAKE} clean
|
2015-11-01 18:31:07 +00:00
|
|
|
#LDFLAGS=-static ${MAKE} -j2
|
2018-02-19 12:17:21 +00:00
|
|
|
${MAKE} -j4 || exit 1
|
2017-02-02 11:00:02 +00:00
|
|
|
${STRIP} $a
|
2015-04-09 21:36:18 +00:00
|
|
|
)
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -rf r2-static
|
2015-11-01 18:31:07 +00:00
|
|
|
mkdir r2-static || exit 1
|
2018-02-19 12:17:21 +00:00
|
|
|
${MAKE} install DESTDIR="${PWD}/r2-static" || exit 1
|
|
|
|
|
|
|
|
# testing installation
|
|
|
|
cat > .test.c <<EOF
|
|
|
|
#include <r_core.h>
|
|
|
|
int main() {
|
|
|
|
RCore *core = r_core_new ();
|
|
|
|
r_core_free (core);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
cat .test.c
|
|
|
|
if [ -z "${CC}" ]; then
|
|
|
|
CC=gcc
|
|
|
|
fi
|
|
|
|
${CC} .test.c \
|
2018-03-13 02:38:38 +00:00
|
|
|
${CFLAGS} \
|
2018-02-19 12:17:21 +00:00
|
|
|
-I r2-static/usr/include/libr \
|
2018-03-03 21:28:21 +00:00
|
|
|
r2-static/usr/lib/libr.a ${LDFLAGS}
|
2018-02-19 12:17:21 +00:00
|
|
|
res=$?
|
2018-03-02 00:06:50 +00:00
|
|
|
if [ $res = 0 ]; then
|
2018-02-19 12:17:21 +00:00
|
|
|
echo SUCCESS
|
|
|
|
else
|
|
|
|
echo FAILURE
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $res
|