1587392a5SHajimu UMEMOTO#!/bin/sh 2587392a5SHajimu UMEMOTO# Try and be like autotools configure, but without autotools 3587392a5SHajimu UMEMOTO 4587392a5SHajimu UMEMOTO# Ensure that we do not inherit these from env 5587392a5SHajimu UMEMOTOOS= 6587392a5SHajimu UMEMOTOBUILD= 7587392a5SHajimu UMEMOTOHOST= 8587392a5SHajimu UMEMOTOTARGET= 9587392a5SHajimu UMEMOTORESTARTCMD= 10587392a5SHajimu UMEMOTORCDIR= 113f2a60a1SPedro F. GiffuniSTATUSARG= 12587392a5SHajimu UMEMOTO 13d7149f4eSGlen Barberfor x do 14587392a5SHajimu UMEMOTO opt=${x%%=*} 15587392a5SHajimu UMEMOTO var=${x#*=} 16587392a5SHajimu UMEMOTO case "$opt" in 17587392a5SHajimu UMEMOTO --os|OS) OS=$var;; 18587392a5SHajimu UMEMOTO --with-cc|CC) CC=$var;; 19587392a5SHajimu UMEMOTO --debug) DEBUG=$var;; 20587392a5SHajimu UMEMOTO --disable-debug) DEBUG=no;; 21587392a5SHajimu UMEMOTO --enable-debug) DEBUG=yes;; 22d7149f4eSGlen Barber --prefix) PREFIX=$var;; 23587392a5SHajimu UMEMOTO --sysconfdir) SYSCONFDIR=$var;; 24587392a5SHajimu UMEMOTO --bindir|--sbindir) SBINDIR=$var;; 25587392a5SHajimu UMEMOTO --libexecdir) LIBEXECDIR=$var;; 26587392a5SHajimu UMEMOTO --statedir|--localstatedir) STATEDIR=$var;; 27587392a5SHajimu UMEMOTO --dbdir) DBDIR=$var;; 28587392a5SHajimu UMEMOTO --rundir) RUNDIR=$var;; 29587392a5SHajimu UMEMOTO --mandir) MANDIR=$var;; 30587392a5SHajimu UMEMOTO --with-ccopts|CFLAGS) CFLAGS=$var;; 31587392a5SHajimu UMEMOTO CPPFLAGS) CPPFLAGS=$var;; 32587392a5SHajimu UMEMOTO --build) BUILD=$var;; 33587392a5SHajimu UMEMOTO --host) HOST=$var;; 34587392a5SHajimu UMEMOTO --target) TARGET=$var;; 35587392a5SHajimu UMEMOTO --libdir) LIBDIR=$var;; 36587392a5SHajimu UMEMOTO --restartcmd) RESTARTCMD=$var;; 373f2a60a1SPedro F. Giffuni --rcdir) RCDIR=$var;; 383f2a60a1SPedro F. Giffuni --statusarg) STATUSARG=$var;; 39587392a5SHajimu UMEMOTO --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";; 40587392a5SHajimu UMEMOTO --datadir|--infodir) ;; # ignore autotools 41587392a5SHajimu UMEMOTO --disable-maintainer-mode|--disable-dependency-tracking) ;; 42587392a5SHajimu UMEMOTO --help) echo "See the README file for available options"; exit 0;; 43587392a5SHajimu UMEMOTO *) echo "$0: WARNING: unknown option $opt" >&2;; 44587392a5SHajimu UMEMOTO esac 45587392a5SHajimu UMEMOTOdone 46587392a5SHajimu UMEMOTO 47587392a5SHajimu UMEMOTO: ${SED:=sed} 48587392a5SHajimu UMEMOTO 49587392a5SHajimu UMEMOTOCONFIG_MK=config.mk 50587392a5SHajimu UMEMOTO 51587392a5SHajimu UMEMOTOif [ -z "$BUILD" ]; then 52d7149f4eSGlen Barber # autoconf target triplet: cpu-vendor-os 53d7149f4eSGlen Barber BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]') 54587392a5SHajimu UMEMOTOfi 55d7149f4eSGlen Barber: ${HOST:=$BUILD} 56587392a5SHajimu UMEMOTO 57587392a5SHajimu UMEMOTOif [ -z "$OS" ]; then 58d7149f4eSGlen Barber echo "Deriving operating system from ... $HOST" 59d7149f4eSGlen Barber # Derive OS from cpu-vendor-[kernel-]os 60d7149f4eSGlen Barber CPU=${HOST%%-*} 61d7149f4eSGlen Barber REST=${HOST#*-} 62587392a5SHajimu UMEMOTO if [ "$CPU" != "$REST" ]; then 63d7149f4eSGlen Barber VENDOR=${REST%%-*} 64587392a5SHajimu UMEMOTO REST=${REST#*-} 65d7149f4eSGlen Barber if [ "$VENDOR" != "$REST" ]; then 66d7149f4eSGlen Barber # Use kernel if given, otherwise os 67587392a5SHajimu UMEMOTO OS=${REST%%-*} 68587392a5SHajimu UMEMOTO else 69587392a5SHajimu UMEMOTO # 2 tupple 70d7149f4eSGlen Barber OS=$VENDOR 71d7149f4eSGlen Barber VENDOR= 72587392a5SHajimu UMEMOTO fi 73587392a5SHajimu UMEMOTO fi 74d7149f4eSGlen Barber 75d7149f4eSGlen Barber # Work with cpu-kernel-os, ie Debian 76d7149f4eSGlen Barber case "$VENDOR" in 77d7149f4eSGlen Barber linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;; 78d7149f4eSGlen Barber esac 79d7149f4eSGlen Barber # Special case 80d7149f4eSGlen Barber case "$OS" in 81d7149f4eSGlen Barber gnu*) OS=hurd;; # No HURD support as yet 82d7149f4eSGlen Barber esac 83587392a5SHajimu UMEMOTOfi 84587392a5SHajimu UMEMOTO 85587392a5SHajimu UMEMOTOecho "Configuring openresolv for ... $OS" 86587392a5SHajimu UMEMOTOrm -rf $CONFIG_MK 87587392a5SHajimu UMEMOTOecho "# $OS" >$CONFIG_MK 88587392a5SHajimu UMEMOTO 8987b2cfceSPedro F. Giffunicase "$OS" in 90*9af6c78cSPedro F. Giffunidragonfly*) 91*9af6c78cSPedro F. Giffuni # This means /usr HAS to be mounted not via dhcpcd 92*9af6c78cSPedro F. Giffuni : ${LIBEXECDIR:=${PREFIX:-/usr}/libexec/resolvconf} 9387b2cfceSPedro F. Giffuni ;; 9487b2cfceSPedro F. Giffunilinux*) 9587b2cfceSPedro F. Giffuni # cksum does't support -a and netpgp is rare 9687b2cfceSPedro F. Giffuni echo "CKSUM= sha256sum --tag" >>$CONFIG_MK 9787b2cfceSPedro F. Giffuni echo "PGP= gpg2" >>$CONFIG_MK 9887b2cfceSPedro F. Giffuni ;; 9987b2cfceSPedro F. Giffuniesac 1003f2a60a1SPedro F. Giffuni 101*9af6c78cSPedro F. Giffunicase "$OS" in 102*9af6c78cSPedro F. Giffunidragonfly*|freebsd*) 103*9af6c78cSPedro F. Giffuni # On FreeBSD, /etc/init.d/foo status returns 0 if foo is not enabled 104*9af6c78cSPedro F. Giffuni # regardless of if it's not running. 105*9af6c78cSPedro F. Giffuni # So we force onestatus to work around this silly bug. 106*9af6c78cSPedro F. Giffuni if [ -z "$STATUSARG" ]; then 107*9af6c78cSPedro F. Giffuni STATUSARG="onestatus" 108*9af6c78cSPedro F. Giffuni fi 109*9af6c78cSPedro F. Giffuni ;; 110*9af6c78cSPedro F. Giffuniesac 111*9af6c78cSPedro F. Giffuni 112*9af6c78cSPedro F. Giffuni 113*9af6c78cSPedro F. Giffuniif [ -z "$LIBEXECDIR" ]; then 114*9af6c78cSPedro F. Giffuni printf "Checking for directory /libexec ... " 115*9af6c78cSPedro F. Giffuni if [ -d /libexec ]; then 116*9af6c78cSPedro F. Giffuni echo "yes" 117*9af6c78cSPedro F. Giffuni LIBEXECDIR=$PREFIX/libexec/resolvconf 118*9af6c78cSPedro F. Giffuni else 119*9af6c78cSPedro F. Giffuni echo "no" 120*9af6c78cSPedro F. Giffuni LIBEXECDIR=$PREFIX/lib/resolvconf 121*9af6c78cSPedro F. Giffuni fi 122*9af6c78cSPedro F. Giffunifi 123*9af6c78cSPedro F. Giffuniif [ -z "$RUNDIR" ]; then 124*9af6c78cSPedro F. Giffuni printf "Checking for directory /run ... " 125*9af6c78cSPedro F. Giffuni if [ -d /run ]; then 126*9af6c78cSPedro F. Giffuni echo "yes" 127*9af6c78cSPedro F. Giffuni RUNDIR=/run 128*9af6c78cSPedro F. Giffuni else 129*9af6c78cSPedro F. Giffuni echo "no" 130*9af6c78cSPedro F. Giffuni RUNDIR=/var/run 131*9af6c78cSPedro F. Giffuni fi 132*9af6c78cSPedro F. Giffunifi 133*9af6c78cSPedro F. Giffuni 134*9af6c78cSPedro F. Giffuni: ${SYSCONFDIR:=$PREFIX/etc} 135*9af6c78cSPedro F. Giffuni: ${SBINDIR:=$PREFIX/sbin} 136*9af6c78cSPedro F. Giffuni: ${LIBEXECDIR:=$PREFIX/libexec/resolvconf} 137*9af6c78cSPedro F. Giffuni: ${STATEDIR:=/var} 138*9af6c78cSPedro F. Giffuni: ${RUNDIR:=$STATEDIR/run} 139*9af6c78cSPedro F. Giffuni: ${MANDIR:=${PREFIX:-/usr}/share/man} 140*9af6c78cSPedro F. Giffuni 141*9af6c78cSPedro F. Giffunieval SYSCONFDIR="$SYSCONFDIR" 142*9af6c78cSPedro F. Giffunieval SBINDIR="$SBINDIR" 143*9af6c78cSPedro F. Giffunieval LIBEXECDIR="$LIBEXECDIR" 144*9af6c78cSPedro F. Giffunieval VARDIR="$RUNDIR/resolvconf" 145*9af6c78cSPedro F. Giffunieval MANDIR="$MANDIR" 146*9af6c78cSPedro F. Giffuni 1473f2a60a1SPedro F. Giffunifor x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR RESTARTCMD RCDIR STATUSARG 1483f2a60a1SPedro F. Giffunido 149587392a5SHajimu UMEMOTO eval v=\$$x 150587392a5SHajimu UMEMOTO # Make files look nice for import 151587392a5SHajimu UMEMOTO l=$((10 - ${#x})) 152587392a5SHajimu UMEMOTO unset t 153587392a5SHajimu UMEMOTO [ $l -gt 3 ] && t=" " 154587392a5SHajimu UMEMOTO echo "$x=$t $v" >>$CONFIG_MK 155587392a5SHajimu UMEMOTOdone 156587392a5SHajimu UMEMOTO 157587392a5SHajimu UMEMOTOecho 158587392a5SHajimu UMEMOTOecho " SYSCONFDIR = $SYSCONFDIR" 159587392a5SHajimu UMEMOTOecho " SBINDIR = $SBINDIR" 160587392a5SHajimu UMEMOTOecho " LIBEXECDIR = $LIBEXECDIR" 161587392a5SHajimu UMEMOTOecho " VARDIR = $RUNDIR" 162587392a5SHajimu UMEMOTOecho " MANDIR = $MANDIR" 163587392a5SHajimu UMEMOTOecho 1643f2a60a1SPedro F. Giffuniecho " RESTARTCMD = $RESTARTCMD" 1653f2a60a1SPedro F. Giffuniecho " RCDIR = $RCDIR" 1663f2a60a1SPedro F. Giffuniecho " STATUSARG = $STATUSARG" 1673f2a60a1SPedro F. Giffuniecho 168