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
|
|
|
|
|
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
|
|
|
|
shift
|
2011-09-10 08:19:06 +08:00
|
|
|
fi
|
|
|
|
|
2017-04-18 07:09:30 +08:00
|
|
|
NOSUDO=""
|
|
|
|
type sudo > /dev/null 2>&1 || NOSUDO=1
|
|
|
|
SUDO=sudo
|
|
|
|
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
|
|
|
|
2015-09-15 01:21:57 +08:00
|
|
|
if [ "${M32}" = 1 ]; then
|
|
|
|
./sys/build-m32.sh $* && ${SUDO} ${MAKE} ${INSTALL_TARGET}
|
|
|
|
elif [ "${HARDEN}" = 1 ]; then
|
2015-06-17 11:47:36 +08:00
|
|
|
# shellcheck disable=SC2048
|
|
|
|
# shellcheck disable=SC2086
|
2015-05-01 05:18:56 +08:00
|
|
|
./sys/build-harden.sh $* && ${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
|
2015-05-01 05:18:56 +08:00
|
|
|
./sys/build.sh $* && ${SUDO} ${MAKE} ${INSTALL_TARGET}
|
2013-09-28 01:50:48 +08:00
|
|
|
fi
|