587392a5a0
Helped by: jhb
187 lines
4.1 KiB
Bash
187 lines
4.1 KiB
Bash
#!/bin/sh
|
|
# Try and be like autotools configure, but without autotools
|
|
|
|
# Ensure that we do not inherit these from env
|
|
OS=
|
|
BUILD=
|
|
HOST=
|
|
TARGET=
|
|
RESTARTCMD=
|
|
RCDIR=
|
|
|
|
for x; do
|
|
opt=${x%%=*}
|
|
var=${x#*=}
|
|
case "$opt" in
|
|
--os|OS) OS=$var;;
|
|
--with-cc|CC) CC=$var;;
|
|
--debug) DEBUG=$var;;
|
|
--disable-debug) DEBUG=no;;
|
|
--enable-debug) DEBUG=yes;;
|
|
--prefix) prefix=$var;;
|
|
--sysconfdir) SYSCONFDIR=$var;;
|
|
--bindir|--sbindir) SBINDIR=$var;;
|
|
--libexecdir) LIBEXECDIR=$var;;
|
|
--statedir|--localstatedir) STATEDIR=$var;;
|
|
--dbdir) DBDIR=$var;;
|
|
--rundir) RUNDIR=$var;;
|
|
--mandir) MANDIR=$var;;
|
|
--with-ccopts|CFLAGS) CFLAGS=$var;;
|
|
CPPFLAGS) CPPFLAGS=$var;;
|
|
--build) BUILD=$var;;
|
|
--host) HOST=$var;;
|
|
--target) TARGET=$var;;
|
|
--libdir) LIBDIR=$var;;
|
|
--restartcmd) RESTARTCMD=$var;;
|
|
--includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
|
|
--datadir|--infodir) ;; # ignore autotools
|
|
--disable-maintainer-mode|--disable-dependency-tracking) ;;
|
|
--help) echo "See the README file for available options"; exit 0;;
|
|
*) echo "$0: WARNING: unknown option $opt" >&2;;
|
|
esac
|
|
done
|
|
|
|
: ${SED:=sed}
|
|
|
|
: ${PREFIX:=$prefix}
|
|
: ${SYSCONFDIR:=$PREFIX/etc}
|
|
: ${SBINDIR:=$PREFIX/sbin}
|
|
: ${LIBEXECDIR:=$PREFIX/libexec}
|
|
: ${STATEDIR:=/var}
|
|
: ${RUNDIR:=$STATEDIR/run}
|
|
: ${MANDIR:=${PREFIX:-/usr}/share/man}
|
|
|
|
eval SYSCONFDIR="$SYSCONFDIR"
|
|
eval SBINDIR="$SBINDIR"
|
|
eval LIBEXECDIR="$LIBEXECDIR/resolvconf"
|
|
eval VARDIR="$RUNDIR/resolvconf"
|
|
eval MANDIR="$MANDIR"
|
|
|
|
CONFIG_MK=config.mk
|
|
|
|
if [ -z "$BUILD" ]; then
|
|
BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'`
|
|
fi
|
|
if [ -z "$HOST" ]; then
|
|
[ -z "$TARGET" ] && TARGET=$BUILD
|
|
HOST=$TARGET
|
|
fi
|
|
if [ -z "$TARGET" ]; then
|
|
[ -z "$HOST" ] && HOST=$BUILD
|
|
TARGET=$HOST
|
|
fi
|
|
|
|
# Debian and Slackware have linux in different places when dealing with
|
|
# autoconf, so we deal with that here.
|
|
if [ -z "$OS" ]; then
|
|
case "$TARGET" in
|
|
*-linux-*|linux-*|*-linux|linux) OS=linux;;
|
|
esac
|
|
fi
|
|
|
|
if [ -z "$OS" ]; then
|
|
# Derive OS from cpu-manufacturer-os-kernel
|
|
CPU=${TARGET%%-*}
|
|
REST=${TARGET#*-}
|
|
if [ "$CPU" != "$REST" ]; then
|
|
MANU=${REST%%-*}
|
|
REST=${REST#*-}
|
|
if [ "$MANU" != "$REST" ]; then
|
|
OS=${REST%%-*}
|
|
REST=${REST#*-}
|
|
if [ "$OS" != "$REST" ]; then
|
|
KERNEL=${REST%%-*}
|
|
else
|
|
# 3 tupple
|
|
KERNEL=$OS
|
|
OS=$MANU
|
|
MANU=
|
|
fi
|
|
else
|
|
# 2 tupple
|
|
OS=$MANU
|
|
MANU=
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo "Configuring openresolv for ... $OS"
|
|
rm -rf $CONFIG_MK
|
|
echo "# $OS" >$CONFIG_MK
|
|
|
|
for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR; do
|
|
eval v=\$$x
|
|
# Make files look nice for import
|
|
l=$((10 - ${#x}))
|
|
unset t
|
|
[ $l -gt 3 ] && t=" "
|
|
echo "$x=$t $v" >>$CONFIG_MK
|
|
done
|
|
|
|
if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
|
|
echo "Overriding service status check for Arch Linux"
|
|
RCDIR=/etc/rc.d
|
|
RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
|
|
echo "yes"
|
|
fi
|
|
|
|
if [ -z "$RESTARTCMD" ]; then
|
|
printf "Checking for OpenRC ... "
|
|
if [ -x /sbin/rc-service ]; then
|
|
RESTARTCMD="/sbin/rc-service -e \1 \&\& /sbin/rc-service \1 -- -Ds restart"
|
|
echo "yes"
|
|
else
|
|
echo "no"
|
|
fi
|
|
fi
|
|
if [ -z "$RESTARTCMD" ]; then
|
|
printf "Checking for invoke-rc.d ... "
|
|
if [ -x /usr/sbin/invoke-rc.d ]; then
|
|
RCDIR=/etc/init.d
|
|
RESTARTCMD="/usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1 \&\& /usr/sbin/invoke-rc.d \1 restart"
|
|
echo "yes"
|
|
else
|
|
echo "no"
|
|
fi
|
|
fi
|
|
if [ -z "$RESTARTCMD" ]; then
|
|
printf "Checking for service ... "
|
|
if [ -x /sbin/service ]; then
|
|
RCDIR=/etc/init.d
|
|
RESTARTCMD="/sbin/service \1 \&\& /sbin/service \1 restart"
|
|
echo "yes"
|
|
else
|
|
echo "no"
|
|
fi
|
|
fi
|
|
if [ -z "$RESTARTCMD" ]; then
|
|
for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
|
|
printf "Checking for $x ... "
|
|
if [ -d $x ]; then
|
|
RCDIR=$x
|
|
RESTARTCMD="$x/\1 status >/dev/null 2>\&1 \&\& $x/\1 restart"
|
|
echo "yes"
|
|
break
|
|
else
|
|
echo "no"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ -z "$RESTARTCMD" ]; then
|
|
echo "WARNING! No means of interacting with system services detected!"
|
|
exit 1
|
|
fi
|
|
|
|
echo "RCDIR= $RCDIR" >>$CONFIG_MK
|
|
# Work around bug in the dash shell as "echo 'foo \1'" does bad things
|
|
printf "%s\n" "RESTARTCMD= $RESTARTCMD" >>$CONFIG_MK
|
|
|
|
echo
|
|
echo " SYSCONFDIR = $SYSCONFDIR"
|
|
echo " SBINDIR = $SBINDIR"
|
|
echo " LIBEXECDIR = $LIBEXECDIR"
|
|
echo " VARDIR = $RUNDIR"
|
|
echo " MANDIR = $MANDIR"
|
|
echo
|