2014-12-22 03:50:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
MAKE=make
|
2022-03-22 08:44:10 +00:00
|
|
|
export CFLAGS="${CFLAGS} -fPIC"
|
2014-12-22 03:50:08 +00:00
|
|
|
gmake --help >/dev/null 2>&1
|
|
|
|
[ $? = 0 ] && MAKE=gmake
|
|
|
|
|
2018-09-02 20:06:48 +00:00
|
|
|
${MAKE} --help 2>&1 | grep -q gnu
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "You need GNU Make to build me"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-12-22 03:50:08 +00:00
|
|
|
# find root
|
2018-09-01 23:40:25 +00:00
|
|
|
cd "$(dirname "$0")" ; cd ..
|
2014-12-22 03:50:08 +00:00
|
|
|
|
2018-12-05 11:30:36 +00:00
|
|
|
export WITHOUT_PULL=0
|
2024-05-13 10:27:51 +00:00
|
|
|
PREFIX="${HOME}/.local"
|
2018-12-05 11:30:36 +00:00
|
|
|
|
2021-02-28 17:46:45 +00:00
|
|
|
abspath() {
|
|
|
|
echo "$1" | grep -q ^/
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "$1"
|
|
|
|
else
|
|
|
|
echo "`pwd`/$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-19 16:10:19 +00:00
|
|
|
ARGS=""
|
2018-12-05 11:30:36 +00:00
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
"--without-pull")
|
|
|
|
WITHOUT_PULL=1
|
|
|
|
;;
|
|
|
|
"--install-path")
|
|
|
|
shift
|
|
|
|
if [ -n "$1" ]; then
|
2024-05-13 10:27:51 +00:00
|
|
|
PREFIX="`abspath $1`"
|
|
|
|
BINDIR="$PREFIX/bin"
|
2018-12-05 11:30:36 +00:00
|
|
|
else
|
|
|
|
echo "ERROR: install-path must not be empty"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
2023-02-19 16:10:19 +00:00
|
|
|
ARGS="${ARGS} $1"
|
2018-12-05 11:30:36 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2024-05-13 10:27:51 +00:00
|
|
|
ARGS="${ARGS} --with-rpath"
|
|
|
|
|
2014-12-22 03:50:08 +00:00
|
|
|
# update
|
2018-12-05 11:30:36 +00:00
|
|
|
if [ $WITHOUT_PULL -eq 0 ]; then
|
2023-05-16 13:52:36 +00:00
|
|
|
if [ -e .git ]; then
|
2014-12-22 03:50:08 +00:00
|
|
|
git branch | grep "^\* master" > /dev/null
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "WARNING: Updating from remote repository"
|
2021-12-15 09:12:43 +00:00
|
|
|
# Attempt to update from an existing remote
|
2022-03-11 12:16:53 +00:00
|
|
|
UPSTREAM_REMOTE=$(git remote -v | grep 'radareorg/radare2\(\.git\)\? (fetch)' | cut -f1 | head -n1)
|
2021-12-15 09:12:43 +00:00
|
|
|
if [ -n "$UPSTREAM_REMOTE" ]; then
|
|
|
|
git pull "$UPSTREAM_REMOTE" master
|
|
|
|
else
|
|
|
|
git pull https://github.com/radareorg/radare2 master
|
|
|
|
fi
|
2014-12-22 03:50:08 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-05-13 10:27:51 +00:00
|
|
|
if [ -z "${PREFIX}" ]; then
|
2018-12-05 11:30:36 +00:00
|
|
|
if [ -z "${HOME}" ]; then
|
|
|
|
echo "HOME not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-12-22 03:50:08 +00:00
|
|
|
|
2018-12-05 11:30:36 +00:00
|
|
|
if [ ! -d "${HOME}" ]; then
|
|
|
|
echo "HOME is not a directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-05-13 10:27:51 +00:00
|
|
|
PREFIX="${HOME}/.local"
|
|
|
|
# PREFIX="${PREFIX}/bin/prefix/radare2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${BINDIR}" ]; then
|
|
|
|
BINDIR="${PREFIX}/bin"
|
2014-12-22 03:50:08 +00:00
|
|
|
fi
|
|
|
|
|
2024-05-13 10:27:51 +00:00
|
|
|
mkdir -p "${PREFIX}/lib"
|
2014-12-22 03:50:08 +00:00
|
|
|
|
2015-09-14 17:21:57 +00:00
|
|
|
if [ "${M32}" = 1 ]; then
|
2024-05-13 10:27:51 +00:00
|
|
|
./sys/build-m32.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
|
2015-09-14 17:21:57 +00:00
|
|
|
elif [ "${HARDEN}" = 1 ]; then
|
2024-05-13 10:27:51 +00:00
|
|
|
./sys/build-harden.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
|
2014-12-22 03:50:08 +00:00
|
|
|
else
|
2024-05-13 10:27:51 +00:00
|
|
|
./sys/build.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
|
2014-12-22 03:50:08 +00:00
|
|
|
fi
|
2015-09-08 21:47:45 +00:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Oops"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-05-13 10:27:51 +00:00
|
|
|
${MAKE} symstall
|
|
|
|
S='$'
|
2014-12-22 03:50:08 +00:00
|
|
|
echo
|
2024-05-13 10:27:51 +00:00
|
|
|
echo "radare2 is now installed in ${PREFIX}"
|
2014-12-22 03:50:08 +00:00
|
|
|
echo
|
2024-05-13 10:27:51 +00:00
|
|
|
echo "export PATH=${BINDIR}:${S}PATH"
|
2014-12-22 03:50:08 +00:00
|
|
|
echo
|