1#!/bin/sh 2# Try and be like autotools configure, but without autotools 3 4# Ensure that we do not inherit these from env 5OS= 6BUILD= 7HOST= 8TARGET= 9RESTARTCMD= 10RCDIR= 11 12for x; do 13 opt=${x%%=*} 14 var=${x#*=} 15 case "$opt" in 16 --os|OS) OS=$var;; 17 --with-cc|CC) CC=$var;; 18 --debug) DEBUG=$var;; 19 --disable-debug) DEBUG=no;; 20 --enable-debug) DEBUG=yes;; 21 --prefix) prefix=$var;; 22 --sysconfdir) SYSCONFDIR=$var;; 23 --bindir|--sbindir) SBINDIR=$var;; 24 --libexecdir) LIBEXECDIR=$var;; 25 --statedir|--localstatedir) STATEDIR=$var;; 26 --dbdir) DBDIR=$var;; 27 --rundir) RUNDIR=$var;; 28 --mandir) MANDIR=$var;; 29 --with-ccopts|CFLAGS) CFLAGS=$var;; 30 CPPFLAGS) CPPFLAGS=$var;; 31 --build) BUILD=$var;; 32 --host) HOST=$var;; 33 --target) TARGET=$var;; 34 --libdir) LIBDIR=$var;; 35 --restartcmd) RESTARTCMD=$var;; 36 --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";; 37 --datadir|--infodir) ;; # ignore autotools 38 --disable-maintainer-mode|--disable-dependency-tracking) ;; 39 --help) echo "See the README file for available options"; exit 0;; 40 *) echo "$0: WARNING: unknown option $opt" >&2;; 41 esac 42done 43 44: ${SED:=sed} 45 46: ${PREFIX:=$prefix} 47: ${SYSCONFDIR:=$PREFIX/etc} 48: ${SBINDIR:=$PREFIX/sbin} 49: ${LIBEXECDIR:=$PREFIX/libexec} 50: ${STATEDIR:=/var} 51: ${RUNDIR:=$STATEDIR/run} 52: ${MANDIR:=${PREFIX:-/usr}/share/man} 53 54eval SYSCONFDIR="$SYSCONFDIR" 55eval SBINDIR="$SBINDIR" 56eval LIBEXECDIR="$LIBEXECDIR/resolvconf" 57eval VARDIR="$RUNDIR/resolvconf" 58eval MANDIR="$MANDIR" 59 60CONFIG_MK=config.mk 61 62if [ -z "$BUILD" ]; then 63 BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'` 64fi 65if [ -z "$HOST" ]; then 66 [ -z "$TARGET" ] && TARGET=$BUILD 67 HOST=$TARGET 68fi 69if [ -z "$TARGET" ]; then 70 [ -z "$HOST" ] && HOST=$BUILD 71 TARGET=$HOST 72fi 73 74# Debian and Slackware have linux in different places when dealing with 75# autoconf, so we deal with that here. 76if [ -z "$OS" ]; then 77 case "$TARGET" in 78 *-linux-*|linux-*|*-linux|linux) OS=linux;; 79 esac 80fi 81 82if [ -z "$OS" ]; then 83 # Derive OS from cpu-manufacturer-os-kernel 84 CPU=${TARGET%%-*} 85 REST=${TARGET#*-} 86 if [ "$CPU" != "$REST" ]; then 87 MANU=${REST%%-*} 88 REST=${REST#*-} 89 if [ "$MANU" != "$REST" ]; then 90 OS=${REST%%-*} 91 REST=${REST#*-} 92 if [ "$OS" != "$REST" ]; then 93 KERNEL=${REST%%-*} 94 else 95 # 3 tupple 96 KERNEL=$OS 97 OS=$MANU 98 MANU= 99 fi 100 else 101 # 2 tupple 102 OS=$MANU 103 MANU= 104 fi 105 fi 106fi 107 108echo "Configuring openresolv for ... $OS" 109rm -rf $CONFIG_MK 110echo "# $OS" >$CONFIG_MK 111 112for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR; do 113 eval v=\$$x 114 # Make files look nice for import 115 l=$((10 - ${#x})) 116 unset t 117 [ $l -gt 3 ] && t=" " 118 echo "$x=$t $v" >>$CONFIG_MK 119done 120 121if [ -e /etc/arch-release -a -d /etc/rc.d ]; then 122 echo "Overriding service status check for Arch Linux" 123 RCDIR=/etc/rc.d 124 RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart" 125 echo "yes" 126fi 127 128if [ -z "$RESTARTCMD" ]; then 129 printf "Checking for OpenRC ... " 130 if [ -x /sbin/rc-service ]; then 131 RESTARTCMD="/sbin/rc-service -e \1 \&\& /sbin/rc-service \1 -- -Ds restart" 132 echo "yes" 133 else 134 echo "no" 135 fi 136fi 137if [ -z "$RESTARTCMD" ]; then 138 printf "Checking for invoke-rc.d ... " 139 if [ -x /usr/sbin/invoke-rc.d ]; then 140 RCDIR=/etc/init.d 141 RESTARTCMD="/usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1 \&\& /usr/sbin/invoke-rc.d \1 restart" 142 echo "yes" 143 else 144 echo "no" 145 fi 146fi 147if [ -z "$RESTARTCMD" ]; then 148 printf "Checking for service ... " 149 if [ -x /sbin/service ]; then 150 RCDIR=/etc/init.d 151 RESTARTCMD="/sbin/service \1 \&\& /sbin/service \1 restart" 152 echo "yes" 153 else 154 echo "no" 155 fi 156fi 157if [ -z "$RESTARTCMD" ]; then 158 for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do 159 printf "Checking for $x ... " 160 if [ -d $x ]; then 161 RCDIR=$x 162 RESTARTCMD="$x/\1 status >/dev/null 2>\&1 \&\& $x/\1 restart" 163 echo "yes" 164 break 165 else 166 echo "no" 167 fi 168 done 169fi 170 171if [ -z "$RESTARTCMD" ]; then 172 echo "WARNING! No means of interacting with system services detected!" 173 exit 1 174fi 175 176echo "RCDIR= $RCDIR" >>$CONFIG_MK 177# Work around bug in the dash shell as "echo 'foo \1'" does bad things 178printf "%s\n" "RESTARTCMD= $RESTARTCMD" >>$CONFIG_MK 179 180echo 181echo " SYSCONFDIR = $SYSCONFDIR" 182echo " SBINDIR = $SBINDIR" 183echo " LIBEXECDIR = $LIBEXECDIR" 184echo " VARDIR = $RUNDIR" 185echo " MANDIR = $MANDIR" 186echo 187