freebsd-skq/contrib/openresolv/configure
gjb 89cd18cd05 MFV r225523, r282431:
r225523 (hrs):
  Import openresolv-3.4.4.

 r282431:
  Import openresolv-3.7.0.

PR:		199854
Submitted by:	yuri@rawbw.com
MFC after:	1 week
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
2015-05-04 21:07:20 +00:00

226 lines
5.0 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
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}
: ${SYSCONFDIR:=$PREFIX/etc}
: ${SBINDIR:=$PREFIX/sbin}
: ${LIBEXECDIR:=$PREFIX/libexec/resolvconf}
: ${STATEDIR:=/var}
: ${RUNDIR:=$STATEDIR/run}
: ${MANDIR:=${PREFIX:-/usr}/share/man}
eval SYSCONFDIR="$SYSCONFDIR"
eval SBINDIR="$SBINDIR"
eval LIBEXECDIR="$LIBEXECDIR"
eval VARDIR="$RUNDIR/resolvconf"
eval MANDIR="$MANDIR"
CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
# autoconf target triplet: cpu-vendor-os
BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
fi
: ${HOST:=$BUILD}
if [ -z "$OS" ]; then
echo "Deriving operating system from ... $HOST"
# Derive OS from cpu-vendor-[kernel-]os
CPU=${HOST%%-*}
REST=${HOST#*-}
if [ "$CPU" != "$REST" ]; then
VENDOR=${REST%%-*}
REST=${REST#*-}
if [ "$VENDOR" != "$REST" ]; then
# Use kernel if given, otherwise os
OS=${REST%%-*}
else
# 2 tupple
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"
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 [ -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
printf "Checking for OpenRC ... "
if [ -x /sbin/rc-service ]; then
RESTARTCMD="if /sbin/rc-service -e \1; then /sbin/rc-service \1 -- -Ds restart; fi"
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="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"
fi
fi
if [ -z "$RESTARTCMD" ]; then
printf "Checking for service ... "
if [ -x /sbin/service ]; then
RCDIR=/etc/init.d
RESTARTCMD="if /sbin/service \1; then /sbin/service \1 restart; fi"
echo "yes"
else
echo "no"
fi
fi
if [ -z "$RESTARTCMD" ]; then
printf "Checking for runit... "
if [ -x /bin/sv ]; then
RESTARTCMD="/bin/sv try-restart \1"
echo "yes"
elif [ -x /usr/bin/sv ]; then
RESTARTCMD="/usr/bin/sv try-restart \1"
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="if $x/\1 status >/dev/null 2>\&1; then $x/\1 restart; fi"
echo "yes"
break
else
echo "no"
fi
done
fi
if [ -z "$RESTARTCMD" ]; then
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
echo
echo " SYSCONFDIR = $SYSCONFDIR"
echo " SBINDIR = $SBINDIR"
echo " LIBEXECDIR = $LIBEXECDIR"
echo " VARDIR = $RUNDIR"
echo " MANDIR = $MANDIR"
echo