2011-09-10 08:19:06 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-07-03 05:15:40 +08:00
|
|
|
MAKE=make
|
|
|
|
gmake --help >/dev/null 2>&1
|
|
|
|
[ $? = 0 ] && MAKE=gmake
|
|
|
|
|
2018-10-24 04:22:38 +08:00
|
|
|
# if owner of sys/install.sh != uid && uid == 0 { exec sudo -u id -A $SUDO_UID sys/install.sh $* }
|
2019-11-20 23:40:02 +08:00
|
|
|
ARGS=""
|
2019-05-14 23:53:34 +08:00
|
|
|
while : ; do
|
2019-11-20 23:40:02 +08:00
|
|
|
[ -z "$1" ] && break
|
2019-05-14 23:53:34 +08:00
|
|
|
case "$1" in
|
|
|
|
--help)
|
|
|
|
./configure --help
|
|
|
|
echo
|
|
|
|
echo "NOTE: Use sys/install.sh --install to use 'cp' instead of 'ln'."
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"--with-capstone5")
|
|
|
|
export USE_CS5=1
|
|
|
|
rm -rf shlr/capstone
|
|
|
|
shift
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
"--install")
|
|
|
|
export INSTALL_TARGET="install"
|
|
|
|
shift
|
|
|
|
continue
|
|
|
|
;;
|
2019-11-20 23:40:02 +08:00
|
|
|
*)
|
|
|
|
ARGS="${ARGS} $1"
|
|
|
|
;;
|
2019-05-14 23:53:34 +08:00
|
|
|
esac
|
2019-11-20 23:40:02 +08:00
|
|
|
shift
|
2019-05-14 23:53:34 +08:00
|
|
|
done
|
|
|
|
|
2018-10-24 04:22:38 +08:00
|
|
|
if [ "${UID}" = 0 ]; then
|
|
|
|
echo "[XX] Do not run this script as root!"
|
|
|
|
if [ -n "${SUDO_USER}" ]; then
|
|
|
|
echo "[--] Downgrading credentials to ${SUDO_USER}"
|
|
|
|
exec sudo -u "${SUDO_USER}" sys/install.sh $*
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-04 20:18:07 +08:00
|
|
|
${MAKE} --help 2>&1 | grep -q gnu
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "You need GNU Make to build me"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-05-04 04:29:56 +08:00
|
|
|
export MAKE="$MAKE"
|
|
|
|
|
2015-05-01 05:18:56 +08:00
|
|
|
[ -z "${INSTALL_TARGET}" ] && INSTALL_TARGET=symstall
|
|
|
|
|
2011-09-10 08:19:06 +08:00
|
|
|
# find root
|
2015-06-17 11:47:36 +08:00
|
|
|
cd "$(dirname "$0")" ; cd ..
|
2011-09-10 08:19:06 +08:00
|
|
|
|
|
|
|
# update
|
2014-12-14 09:36:57 +08:00
|
|
|
if [ "$1" != "--without-pull" ]; then
|
|
|
|
if [ -d .git ]; then
|
|
|
|
git branch | grep "^\* master" > /dev/null
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "WARNING: Updating from remote repository"
|
|
|
|
git pull
|
|
|
|
fi
|
2014-11-24 05:11:41 +08:00
|
|
|
fi
|
2014-12-14 09:36:57 +08:00
|
|
|
else
|
2017-10-20 09:19:55 +08:00
|
|
|
export WITHOUT_PULL=1
|
2014-12-14 09:36:57 +08:00
|
|
|
shift
|
2011-09-10 08:19:06 +08:00
|
|
|
fi
|
|
|
|
|
2018-03-07 07:53:05 +08:00
|
|
|
umask 0002
|
|
|
|
|
2017-05-15 21:36:37 +08:00
|
|
|
export NOSUDO
|
|
|
|
if [ -n "${NOSUDO}" ]; then
|
|
|
|
SUDO=""
|
|
|
|
else
|
|
|
|
type sudo > /dev/null 2>&1 || NOSUDO=1
|
|
|
|
SUDO=sudo
|
|
|
|
[ -n "${NOSUDO}" ] && SUDO=
|
|
|
|
fi
|
2017-05-15 21:32:03 +08:00
|
|
|
|
2017-04-18 07:09:30 +08:00
|
|
|
if [ "$(id -u)" = 0 ]; then
|
|
|
|
SUDO=""
|
|
|
|
else
|
|
|
|
[ -n "${NOSUDO}" ] && SUDO="echo NOTE: sudo not found. Please run as root: "
|
|
|
|
fi
|
2012-08-27 23:02:58 +08:00
|
|
|
|
2018-09-16 06:08:46 +08:00
|
|
|
if [ "${USE_SU}" = 1 ]; then
|
|
|
|
SUDO="/bin/su -m root -c"
|
|
|
|
fi
|
|
|
|
|
2015-09-15 01:21:57 +08:00
|
|
|
if [ "${M32}" = 1 ]; then
|
2019-11-20 23:40:02 +08:00
|
|
|
./sys/build-m32.sh ${ARGS} && ${SUDO} ${MAKE} ${INSTALL_TARGET}
|
2015-09-15 01:21:57 +08:00
|
|
|
elif [ "${HARDEN}" = 1 ]; then
|
2015-06-17 11:47:36 +08:00
|
|
|
# shellcheck disable=SC2048
|
|
|
|
# shellcheck disable=SC2086
|
2019-11-20 23:40:02 +08:00
|
|
|
./sys/build-harden.sh ${ARGS} && ${SUDO} ${MAKE} ${INSTALL_TARGET}
|
2013-09-28 01:50:48 +08:00
|
|
|
else
|
2015-06-17 11:47:36 +08:00
|
|
|
# shellcheck disable=SC2048
|
|
|
|
# shellcheck disable=SC2086
|
2019-11-20 23:40:02 +08:00
|
|
|
./sys/build.sh ${ARGS} && ${SUDO} ${MAKE} ${INSTALL_TARGET}
|
2013-09-28 01:50:48 +08:00
|
|
|
fi
|