Update copyright.
[openresolv] / configure
index 28f43a75dd583bc0d1fd2a0a4c6d90004e6c00d8..fdfd87fc0e68c68795c7c1e08dbf670857146a14 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,8 +7,9 @@ BUILD=
 HOST=
 TARGET=
 RESTARTCMD=
+RCDIR=
 
-for x; do
+for x do
        opt=${x%%=*}
        var=${x#*=}
        case "$opt" in
@@ -17,7 +18,7 @@ for x; do
        --debug) DEBUG=$var;;
        --disable-debug) DEBUG=no;;
        --enable-debug) DEBUG=yes;;
-       --prefix) prefix=$var;;
+       --prefix) PREFIX=$var;;
        --sysconfdir) SYSCONFDIR=$var;;
        --bindir|--sbindir) SBINDIR=$var;;
        --libexecdir) LIBEXECDIR=$var;;
@@ -40,19 +41,39 @@ for x; do
        esac
 done
 
+if [ -z "$LIBEXECDIR" ]; then
+       printf "Checking for directory /libexec ... "
+       if [ -d /libexec ]; then
+               echo "yes"
+               LIBEXECDIR=$PREFIX/libexec/resolvconf
+       else
+               echo "no"
+               LIBEXECDIR=$PREFIX/lib/resolvconf
+       fi
+fi
+if [ -z "$RUNDIR" ]; then
+       printf "Checking for directory /run ... "
+       if [ -d /run ]; then
+               echo "yes"
+               RUNDIR=/run
+       else
+               echo "no"
+               RUNDIR=/var/run
+       fi
+fi     
+
 : ${SED:=sed}
 
-: ${PREFIX:=$prefix}
 : ${SYSCONFDIR:=$PREFIX/etc}
 : ${SBINDIR:=$PREFIX/sbin}
-: ${LIBEXECDIR:=$PREFIX/libexec}
+: ${LIBEXECDIR:=$PREFIX/libexec/resolvconf}
 : ${STATEDIR:=/var}
 : ${RUNDIR:=$STATEDIR/run}
 : ${MANDIR:=${PREFIX:-/usr}/share/man}
 
 eval SYSCONFDIR="$SYSCONFDIR"
 eval SBINDIR="$SBINDIR"
-eval LIBEXECDIR="$LIBEXECDIR/resolvconf"
+eval LIBEXECDIR="$LIBEXECDIR"
 eval VARDIR="$RUNDIR/resolvconf"
 eval MANDIR="$MANDIR"
 
@@ -119,6 +140,7 @@ 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
@@ -126,7 +148,7 @@ 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"
+               RESTARTCMD="if /sbin/rc-service -e \1; then /sbin/rc-service \1 -- -Ds restart; fi"
                echo "yes"
        else
                echo "no"
@@ -135,7 +157,8 @@ fi
 if [ -z "$RESTARTCMD" ]; then
        printf "Checking for invoke-rc.d ... "
        if [ -x /usr/sbin/invoke-rc.d ]; then
-               RESTARTCMD="/usr/sbin/invoke-rc.d --query --quiet \1 restart || [ \$\$\? = 104 ] \&\& /usr/sbin/invoke-rc.d \1 restart"
+               RCDIR=/etc/init.d
+               RESTARTCMD="if /usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1; then /usr/sbin/invoke-rc.d \1 restart; fi"
                echo "yes"
        else
                echo "no"
@@ -144,7 +167,8 @@ fi
 if [ -z "$RESTARTCMD" ]; then
        printf "Checking for service ... "
        if [ -x /sbin/service ]; then
-               RESTARTCMD="/sbin/service \1 \&\& /sbin/service \1 restart"
+               RCDIR=/etc/init.d
+               RESTARTCMD="if /sbin/service \1; then /sbin/service \1 restart; fi"
                echo "yes"
        else
                echo "no"
@@ -154,7 +178,8 @@ 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
-                       RESTARTCMD="$x/\1 status >/dev/null 2>\&1 \&\& $x/\1 restart"
+                       RCDIR=$x
+                       RESTARTCMD="if $x/\1 status >/dev/null 2>\&1; then $x/\1 restart; fi"
                        echo "yes"
                        break
                else
@@ -164,12 +189,13 @@ if [ -z "$RESTARTCMD" ]; then
 fi
 
 if [ -z "$RESTARTCMD" ]; then
-       echo "WARNING! No means of interacting with system services detected!"
+       echo "$0: 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
+printf "%s\n" "RESTARTCMD=     $RESTARTCMD" >>$CONFIG_MK
 
 echo
 echo "   SYSCONFDIR =          $SYSCONFDIR"