Implement replace and replace_sub to allow for keyword/value/replacement
[openresolv] / configure
index fdfd87fc0e68c68795c7c1e08dbf670857146a14..a32cc1c653ee7d893be2d36875cbadb869756c2a 100755 (executable)
--- a/configure
+++ b/configure
@@ -80,49 +80,37 @@ 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
+       # autoconf target triplet: cpu-vendor-os
+       BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
 fi
+: ${HOST:=$BUILD}
 
 if [ -z "$OS" ]; then
-       # Derive OS from cpu-manufacturer-os-kernel
-       CPU=${TARGET%%-*}
-       REST=${TARGET#*-}
+       echo "Deriving operating system from ... $HOST"
+       # Derive OS from cpu-vendor-[kernel-]os
+       CPU=${HOST%%-*}
+       REST=${HOST#*-}
        if [ "$CPU" != "$REST" ]; then
-               MANU=${REST%%-*}
+               VENDOR=${REST%%-*}
                REST=${REST#*-}
-               if [ "$MANU" != "$REST" ]; then
+               if [ "$VENDOR" != "$REST" ]; then
+                       # Use kernel if given, otherwise os
                        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=
+                       OS=$VENDOR
+                       VENDOR=
                fi
        fi
+
+        # Work with cpu-kernel-os, ie Debian
+       case "$VENDOR" in
+       linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;;
+       esac
+       # Special case
+       case "$OS" in
+       gnu*) OS=hurd;; # No HURD support as yet
+       esac
 fi
 
 echo "Configuring openresolv for ... $OS"
@@ -138,11 +126,30 @@ for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR; do
        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"
+if [ -z "$RESTARTCMD" ]; then
+       printf "Checking for systemd ... "
+       if [ -x /bin/systemctl ]; then
+               RESTARTCMD="/bin/systemctl try-restart \1"
+               echo "yes"
+       elif [ -x /usr/bin/systemctl ]; then
+               RESTARTCMD="/usr/bin/systemctl try-restart \1"
+               echo "yes"
+       else
+               echo "no"
+       fi
+fi
+
+# Arch upgraded to systemd, so this check has to be just after systemd
+# but higher than the others
+if [ -z "$RESTARTCMD" ]; then
+       printf "Checking for Arch ... "
+       if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
+               RCDIR=/etc/rc.d
+               RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
+               echo "yes"
+       else
+               echo "no"
+       fi
 fi
 
 if [ -z "$RESTARTCMD" ]; then