2009-07-14 21:59:30 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# Try and be like autotools configure, but without autotools
|
|
|
|
|
2010-01-26 04:06:15 +08:00
|
|
|
# Ensure that we do not inherit these from env
|
2009-10-17 05:36:51 +08:00
|
|
|
HOOKSET=false
|
2009-11-20 20:20:10 +08:00
|
|
|
ARC4RANDOM=
|
|
|
|
CLOSEFROM=
|
|
|
|
GETLINE=
|
|
|
|
STRLCPY=
|
2010-01-26 04:06:15 +08:00
|
|
|
OS=
|
|
|
|
BUILD=
|
|
|
|
HOST=
|
|
|
|
TARGET=
|
|
|
|
DEBUG=
|
|
|
|
FORK=
|
2012-07-06 00:37:41 +08:00
|
|
|
STATIC=
|
2010-06-09 23:32:03 +08:00
|
|
|
INCLUDEDIR=
|
2009-10-17 05:36:51 +08:00
|
|
|
|
2011-06-01 14:28:41 +08:00
|
|
|
for x do
|
2009-07-14 21:59:30 +08:00
|
|
|
opt=${x%%=*}
|
|
|
|
var=${x#*=}
|
|
|
|
case "$opt" in
|
2009-07-27 03:29:37 +08:00
|
|
|
--os|OS) OS=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--with-cc|CC) CC=$var;;
|
|
|
|
--debug) DEBUG=$var;;
|
|
|
|
--disable-debug) DEBUG=no;;
|
|
|
|
--enable-debug) DEBUG=yes;;
|
|
|
|
--fork) FORK=$var;;
|
|
|
|
--disable-fork) FORK=no;;
|
|
|
|
--enable-fork) FORK=yes;;
|
2012-07-06 00:37:41 +08:00
|
|
|
--disable-static) STATIC=no;;
|
|
|
|
--enable-static) STATIC=yes;;
|
2010-06-09 23:32:03 +08:00
|
|
|
--prefix) prefix=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--sysconfdir) SYSCONFDIR=$var;;
|
2009-09-03 20:18:03 +08:00
|
|
|
--bindir|--sbindir) SBINDIR=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--libexecdir) LIBEXECDIR=$var;;
|
2009-07-27 01:26:18 +08:00
|
|
|
--statedir|--localstatedir) STATEDIR=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--dbdir) DBDIR=$var;;
|
|
|
|
--rundir) RUNDIR=$var;;
|
|
|
|
--mandir) MANDIR=$var;;
|
|
|
|
--with-ccopts|CFLAGS) CFLAGS=$var;;
|
|
|
|
CPPFLAGS) CPPFLAGS=$var;;
|
2009-07-27 03:37:46 +08:00
|
|
|
--with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";;
|
2009-10-17 05:36:51 +08:00
|
|
|
--with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;;
|
2009-07-27 03:29:37 +08:00
|
|
|
--build) BUILD=$var;;
|
|
|
|
--host) HOST=$var;;
|
|
|
|
--target) TARGET=$var;;
|
|
|
|
--libdir) LIBDIR=$var;;
|
2009-11-20 20:20:10 +08:00
|
|
|
--without-arc4random) ARC4RANDOM=no;;
|
|
|
|
--without-closefrom) CLOSEFROM=no;;
|
|
|
|
--without-getline) GETLINE=no;;
|
|
|
|
--without-strlcpy) STRLCPY=no;;
|
2010-09-09 22:40:27 +08:00
|
|
|
--serviceexists) SERVICEEXISTS=$var;;
|
|
|
|
--servicecmd) SERVICECMD=$var;;
|
|
|
|
--servicestatus) SERVICESTATUS=$var;;
|
2010-06-09 23:32:03 +08:00
|
|
|
--includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
|
2009-07-27 03:29:37 +08:00
|
|
|
--datadir|--infodir) ;; # ignore autotools
|
2010-06-09 23:32:03 +08:00
|
|
|
--disable-maintainer-mode|--disable-dependency-tracking) ;;
|
2009-09-03 20:18:03 +08:00
|
|
|
--help) echo "See the README file for available options"; exit 0;;
|
2009-07-27 00:40:47 +08:00
|
|
|
*) echo "$0: WARNING: unknown option $opt" >&2;;
|
2009-07-14 21:59:30 +08:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2009-09-03 18:10:51 +08:00
|
|
|
: ${SED:=sed}
|
|
|
|
|
2009-07-14 21:59:30 +08:00
|
|
|
: ${FORK:=yes}
|
2010-06-09 23:32:03 +08:00
|
|
|
: ${PREFIX:=$prefix}
|
2009-07-14 21:59:30 +08:00
|
|
|
: ${SYSCONFDIR:=$PREFIX/etc}
|
|
|
|
: ${SBINDIR:=$PREFIX/sbin}
|
2009-07-27 03:29:37 +08:00
|
|
|
: ${LIBDIR:=$PREFIX/lib}
|
2009-07-14 21:59:30 +08:00
|
|
|
: ${LIBEXECDIR:=$PREFIX/libexec}
|
|
|
|
: ${STATEDIR:=/var}
|
|
|
|
: ${DBDIR:=$STATEDIR/db}
|
|
|
|
: ${RUNDIR:=$STATEDIR/run}
|
|
|
|
: ${MANDIR:=${PREFIX:-/usr}/share/man}
|
|
|
|
|
2010-06-09 23:32:03 +08:00
|
|
|
eval SYSCONFDIR="$SYSCONFDIR"
|
|
|
|
eval LIBDIR="$LIBDIR"
|
|
|
|
eval LIBEXECDIR="$LIBEXECDIR"
|
|
|
|
eval STATEDIR="$STATEDIR"
|
|
|
|
eval DBDIR="$DBDIR"
|
|
|
|
eval RUNDIR="$RUNDIR"
|
|
|
|
eval MANDIR="$MANDIR"
|
|
|
|
|
2009-10-09 21:12:20 +08:00
|
|
|
_which()
|
|
|
|
{
|
|
|
|
x="$(which "$1" 2>/dev/null)"
|
|
|
|
if [ -n "$x" ]; then
|
|
|
|
echo "$x"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
for x in /sbin/"$1" /usr/sbin/"$1" \
|
|
|
|
/usr/pkg/sbin/"$1" /usr/local/sbin/"$1"
|
|
|
|
do
|
|
|
|
if [ -e "$x" ]; then
|
|
|
|
echo "$x"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-07-14 21:59:30 +08:00
|
|
|
CONFIG_H=config.h
|
|
|
|
CONFIG_MK=config.mk
|
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
if [ -z "$BUILD" ]; then
|
2010-06-09 23:32:03 +08:00
|
|
|
BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'`
|
2009-07-27 03:29:37 +08:00
|
|
|
fi
|
|
|
|
if [ -z "$HOST" ]; then
|
|
|
|
[ -z "$TARGET" ] && TARGET=$BUILD
|
|
|
|
HOST=$TARGET
|
|
|
|
fi
|
|
|
|
if [ -z "$TARGET" ]; then
|
|
|
|
[ -z "$HOST" ] && HOST=$BUILD
|
|
|
|
TARGET=$HOST
|
|
|
|
fi
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2010-07-11 21:33:25 +08:00
|
|
|
# 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
|
|
|
|
fi
|
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
if [ -z "$OS" ]; then
|
|
|
|
# Derive OS from cpu-manufacturer-os-kernel
|
|
|
|
CPU=${TARGET%%-*}
|
|
|
|
REST=${TARGET#*-}
|
2010-06-09 23:32:03 +08:00
|
|
|
if [ "$CPU" != "$REST" ]; then
|
|
|
|
MANU=${REST%%-*}
|
|
|
|
REST=${REST#*-}
|
|
|
|
if [ "$MANU" != "$REST" ]; then
|
|
|
|
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=
|
|
|
|
fi
|
|
|
|
fi
|
2009-07-27 03:29:37 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Configuring dhcpcd for ... $OS"
|
|
|
|
rm -f $CONFIG_H $CONFIG_MK
|
|
|
|
echo "# $OS" >$CONFIG_MK
|
|
|
|
echo "/* $OS */" >$CONFIG_H
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2009-07-15 17:36:43 +08:00
|
|
|
for x in SYSCONFDIR SBINDIR LIBEXECDIR DBDIR RUNDIR; do
|
2009-10-03 03:08:59 +08:00
|
|
|
eval v=\$$x
|
2009-07-15 17:36:43 +08:00
|
|
|
# Make files look nice for import
|
|
|
|
l=$((10 - ${#x}))
|
2009-10-03 03:08:59 +08:00
|
|
|
unset t
|
|
|
|
[ $l -gt 3 ] && t=" "
|
2009-07-15 17:36:43 +08:00
|
|
|
echo "$x=$t $v" >>$CONFIG_MK
|
2009-10-03 03:08:59 +08:00
|
|
|
unset t
|
|
|
|
[ $l -gt 2 ] && t=" "
|
2009-07-15 17:36:43 +08:00
|
|
|
echo "#define $x$t \"$v\"" >>$CONFIG_H
|
2009-07-14 21:59:30 +08:00
|
|
|
done
|
2009-07-27 03:29:37 +08:00
|
|
|
echo "LIBDIR= $LIBDIR" >>$CONFIG_MK
|
2009-07-15 17:36:43 +08:00
|
|
|
echo "MANDIR= $MANDIR" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
if [ -z "$CC" ]; then
|
|
|
|
printf "Looking for compiler ... "
|
|
|
|
for b in $TARGET- ""; do
|
2012-02-03 07:30:13 +08:00
|
|
|
for cc in gcc clang pcc icc cc; do
|
2009-07-27 03:29:37 +08:00
|
|
|
if type $b$cc >/dev/null 2>&1; then
|
|
|
|
CC=$b$cc
|
|
|
|
echo "$CC"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[ -n "$CC" ] && break
|
|
|
|
done
|
2009-07-27 03:37:46 +08:00
|
|
|
if [ -z "$CC" ]; then
|
|
|
|
echo
|
|
|
|
echo "no suitable compiler found - aborting" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-07-27 03:29:37 +08:00
|
|
|
else
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "Using compiler $CC"
|
|
|
|
fi
|
2012-01-24 19:26:20 +08:00
|
|
|
$CC --version | $SED -e '1!d'
|
2009-07-27 03:29:37 +08:00
|
|
|
echo "CC= $CC" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
|
|
|
|
if [ -n "$CFLAGS" ]; then
|
|
|
|
echo "CFLAGS= $CFLAGS" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
if [ -n "$CPPLAGS" ]; then
|
|
|
|
echo "CPPLAGS= $CPPLAGS" >>$CONFIG_MK
|
|
|
|
fi
|
2012-07-06 00:37:41 +08:00
|
|
|
if [ -n "$LDFLAGS" ]; then
|
|
|
|
echo "LDFLAGS= $LDFLAGS" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
if [ "$STATIC" = yes ]; then
|
|
|
|
echo "LDFLAGS+= -static" >>$CONFIG_MK
|
|
|
|
fi
|
2010-06-09 23:32:03 +08:00
|
|
|
for x in $INCLUDEDIR; do
|
|
|
|
echo "CPPFLAGS+= -I$x" >>$CONFIG_MK
|
|
|
|
done
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2009-09-05 07:27:53 +08:00
|
|
|
if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
|
2009-09-05 07:15:18 +08:00
|
|
|
echo "Enabling memory debugging"
|
|
|
|
echo "CPPFLAGS+= -DDEBUG_MEMORY" >>$CONFIG_MK
|
2009-09-05 07:27:53 +08:00
|
|
|
elif [ -z "$DEBUG" -a -d .git ]; then
|
|
|
|
printf "Found git ... "
|
|
|
|
DEBUG=yes
|
2012-11-01 04:14:08 +08:00
|
|
|
echo "CFLAGS+= -ggdb" >>$CONFIG_MK
|
2009-08-06 04:36:31 +08:00
|
|
|
else
|
|
|
|
DEBUG=no
|
2009-07-15 05:01:59 +08:00
|
|
|
fi
|
2009-08-06 04:36:31 +08:00
|
|
|
if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "Adding debugging CFLAGS"
|
|
|
|
cat <<EOF >>$CONFIG_MK
|
|
|
|
CFLAGS+= -Wall -Wextra -Wimplicit -Wshadow -Wformat=2
|
|
|
|
CFLAGS+= -Wmissing-prototypes -Wmissing-declarations
|
|
|
|
CFLAGS+= -Wmissing-noreturn -Wmissing-format-attribute
|
|
|
|
CFLAGS+= -Wredundant-decls -Wnested-externs
|
|
|
|
CFLAGS+= -Winline -Wwrite-strings -Wcast-align -Wcast-qual
|
2012-10-12 19:26:20 +08:00
|
|
|
CFLAGS+= -Wpointer-arith -Wstrict-overflow
|
2009-07-14 21:59:30 +08:00
|
|
|
CFLAGS+= -Wdeclaration-after-statement -Wsequence-point
|
2009-09-25 05:29:18 +08:00
|
|
|
CFLAGS+= -fno-common
|
2009-07-14 21:59:30 +08:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$FORK" -a "$FORK" != yes -a "$FORK" != true ]; then
|
|
|
|
echo "There is no fork"
|
|
|
|
echo "CPPFLAGS+= -DTHERE_IS_NO_FORK" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
case "$OS" in
|
|
|
|
linux)
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600" >>$CONFIG_MK
|
|
|
|
echo "SRCS+= if-linux.c if-linux-wireless.c lpf.c" >>$CONFIG_MK
|
2010-02-17 21:26:45 +08:00
|
|
|
echo "SRCS+= platform-linux.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "LDADD+= -lrt" >>$CONFIG_MK
|
|
|
|
;;
|
2010-10-20 19:27:32 +08:00
|
|
|
kfreebsd)
|
2010-10-27 22:17:21 +08:00
|
|
|
echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
|
2010-10-20 19:27:32 +08:00
|
|
|
echo "SRCS+= bpf.c if-bsd.c platform-bsd.c" >>$CONFIG_MK
|
|
|
|
echo "COMPAT_SRCS+= compat/linkaddr.c" >>$CONFIG_MK
|
|
|
|
echo "LDADD+= -lrt" >>$CONFIG_MK
|
|
|
|
;;
|
2009-07-14 21:59:30 +08:00
|
|
|
*)
|
2010-02-17 21:26:45 +08:00
|
|
|
echo "SRCS+= bpf.c if-bsd.c platform-bsd.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-06-09 23:32:03 +08:00
|
|
|
# NetBSD: Even if we build for $PREFIX, the clueless user might move us to /
|
2009-07-14 23:10:09 +08:00
|
|
|
LDELF=/libexec/ld.elf_so
|
|
|
|
if [ -e "$LDELF" ]; then
|
|
|
|
echo "Linking against $LDELF"
|
2009-07-15 17:36:43 +08:00
|
|
|
echo "LDFLAGS+= -Wl,-dynamic-linker=$LDELF" >>$CONFIG_MK
|
2010-06-09 23:32:03 +08:00
|
|
|
echo "LDFLAGS+= -Wl,-rpath=${LIBDIR}" >>$CONFIG_MK
|
2009-07-14 23:10:09 +08:00
|
|
|
fi
|
|
|
|
|
2009-09-03 18:10:51 +08:00
|
|
|
# Add CPPFLAGS and CFLAGS to CC for testing features
|
|
|
|
XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
|
|
|
|
XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
|
|
|
|
|
2009-07-22 04:07:13 +08:00
|
|
|
abort=false
|
2009-07-18 19:31:56 +08:00
|
|
|
# We require the libc to support non standard functions, like getifaddrs
|
2009-07-27 05:56:43 +08:00
|
|
|
printf "Testing for getifaddrs ... "
|
2009-07-18 19:31:56 +08:00
|
|
|
cat <<EOF >_getifaddrs.c
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
int main(void) {
|
|
|
|
struct ifaddrs *ifap;
|
|
|
|
return getifaddrs(&ifap);
|
|
|
|
}
|
|
|
|
EOF
|
2009-09-03 18:10:51 +08:00
|
|
|
if $XCC _getifaddrs.c -o _getifaddrs 2>/dev/null; then
|
2009-07-18 19:31:56 +08:00
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
echo "libc support for getifaddrs is required - aborting" >&2
|
2009-07-22 04:07:13 +08:00
|
|
|
abort=true
|
2009-07-18 19:31:56 +08:00
|
|
|
fi
|
2009-07-22 04:07:13 +08:00
|
|
|
rm -f _getifaddrs.c _getifaddrs
|
|
|
|
$abort && exit 1
|
2009-07-18 19:31:56 +08:00
|
|
|
|
2009-11-20 20:20:10 +08:00
|
|
|
if [ -z "$ARC4RANDOM" ]; then
|
|
|
|
printf "Testing for arc4random ... "
|
|
|
|
cat <<EOF >_arc4random.c
|
2009-07-14 21:59:30 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2012-02-04 22:25:11 +08:00
|
|
|
arc4random();
|
2009-07-14 21:59:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2009-11-20 20:20:10 +08:00
|
|
|
if $XCC _arc4random.c -o _arc4random 2>/dev/null; then
|
|
|
|
ARC4RANDOM=yes
|
|
|
|
else
|
|
|
|
ARC4RANDOM=no
|
|
|
|
fi
|
|
|
|
echo "$ARC4RANDOM"
|
|
|
|
rm -f _arc4random.c _arc4random
|
|
|
|
fi
|
|
|
|
if [ "$ARC4RANDOM" = no ]; then
|
2009-10-09 04:21:23 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/arc4random.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "#include \"compat/arc4random.h\"" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2009-11-20 20:20:10 +08:00
|
|
|
if [ -z "$CLOSEFROM" ]; then
|
|
|
|
printf "Testing for closefrom ... "
|
|
|
|
cat <<EOF >_closefrom.c
|
2009-07-14 21:59:30 +08:00
|
|
|
#include <unistd.h>
|
|
|
|
int main(void) {
|
2010-04-13 20:10:16 +08:00
|
|
|
closefrom(3);
|
2009-07-14 21:59:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2009-11-20 20:20:10 +08:00
|
|
|
if $XCC _closefrom.c -o _closefrom 2>/dev/null; then
|
|
|
|
CLOSEFROM=yes
|
|
|
|
else
|
|
|
|
CLOSEFROM=no
|
|
|
|
fi
|
|
|
|
echo "$CLOSEFROM"
|
|
|
|
rm -f _closefrom.c _closefrom
|
|
|
|
fi
|
|
|
|
if [ "$CLOSEFROM" = no ]; then
|
2009-10-09 04:21:23 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/closefrom.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "#include \"compat/closefrom.h\"" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2009-11-20 20:20:10 +08:00
|
|
|
if [ -z "$GETLINE" ]; then
|
|
|
|
printf "Testing for getline ... "
|
|
|
|
cat <<EOF >_getline.c
|
2009-07-14 21:59:30 +08:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
|
|
char *buf = NULL;
|
|
|
|
size_t n = 0;
|
|
|
|
getline(&buf, &n, stdin);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2009-11-20 20:20:10 +08:00
|
|
|
if $XCC _getline.c -o _getline 2>/dev/null; then
|
|
|
|
GETLINE=yes
|
|
|
|
else
|
|
|
|
GETLINE=no
|
|
|
|
fi
|
|
|
|
echo "$GETLINE"
|
|
|
|
rm -f _getline.c _getline
|
|
|
|
fi
|
|
|
|
if [ "$GETLINE" = no ]; then
|
2009-10-09 04:21:23 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/getline.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "#include \"compat/getline.h\"" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2009-11-20 20:20:10 +08:00
|
|
|
if [ -z "$STRLCPY" ]; then
|
|
|
|
printf "Testing for strlcpy ... "
|
|
|
|
cat <<EOF >_strlcpy.c
|
2009-07-14 21:59:30 +08:00
|
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
|
|
const char s1[] = "foo";
|
|
|
|
char s2[10];
|
|
|
|
strlcpy(s2, s1, sizeof(s2));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2009-11-20 20:20:10 +08:00
|
|
|
if $XCC _strlcpy.c -o _strlcpy 2>/dev/null; then
|
|
|
|
STRLCPY=yes
|
|
|
|
else
|
|
|
|
STRLCPY=no
|
|
|
|
fi
|
|
|
|
echo "$STRLCPY"
|
|
|
|
rm -f _strlcpy.c _strlcpy
|
|
|
|
fi
|
|
|
|
if [ "$STRLCPY" = no ]; then
|
2009-10-09 04:21:23 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/strlcpy.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H
|
|
|
|
fi
|
2009-07-15 05:01:59 +08:00
|
|
|
|
2012-07-06 00:37:41 +08:00
|
|
|
if [ -z "$TAILQ_FOREACH_SAFE" ]; then
|
|
|
|
printf "Testing for TAILQ_FOREACH_SAFE ... "
|
|
|
|
cat <<EOF >_queue.c
|
|
|
|
#include <sys/queue.h>
|
|
|
|
int main(void) {
|
|
|
|
#ifndef TAILQ_FOREACH_SAFE
|
|
|
|
#error TAILQ_FOREACH_SAFE
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _queue.c -o _queue 2>/dev/null; then
|
|
|
|
TAILQ_FOREACH_SAFE=yes
|
|
|
|
else
|
|
|
|
TAILQ_FOREACH_SAFE=no
|
|
|
|
fi
|
|
|
|
echo "$TAILQ_FOREACH_SAFE"
|
|
|
|
rm -f _queue.c _queue
|
|
|
|
fi
|
|
|
|
if [ "$TAILQ_FOREACH_SAFE" = no ]; then
|
|
|
|
cat <<EOF >>$CONFIG_H
|
2012-11-01 04:17:59 +08:00
|
|
|
#define TAILQ_FOREACH_SAFE(var, head, field, next) \\
|
|
|
|
for ((var) = TAILQ_FIRST((head)); \\
|
|
|
|
(var) && ((next) = TAILQ_NEXT((var), field), 1); \\
|
2012-07-06 00:37:41 +08:00
|
|
|
(var) = (next))
|
2012-11-01 04:17:59 +08:00
|
|
|
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \\
|
|
|
|
for ((var) = TAILQ_LAST((head), headname); \\
|
|
|
|
(var) && ((prev) = TAILQ_PREV((var), headname, field), 1); \\
|
|
|
|
(var) = (prev))
|
2012-07-06 00:37:41 +08:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
2012-11-11 00:38:52 +08:00
|
|
|
if [ -z "$POSIX_SPAWN" ]; then
|
|
|
|
printf "Testing for posix_spawn ... "
|
|
|
|
cat <<EOF >_posix_spawn.c
|
|
|
|
#include <spawn.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
|
|
posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _posix_spawn.c -o _posix_spawn 2>/dev/null; then
|
|
|
|
POSIX_SPAWN=yes
|
|
|
|
else
|
|
|
|
POSIX_SPAWN=no
|
|
|
|
fi
|
|
|
|
echo "$POSIX_SPAWN"
|
|
|
|
rm -f _posix_spawn.c _posix_spawn
|
|
|
|
fi
|
|
|
|
if [ "$POSIX_SPAWN" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/posix_spawn.c" >>$CONFIG_MK
|
|
|
|
echo "#include \"compat/posix_spawn.h\"" >>$CONFIG_H
|
|
|
|
else
|
|
|
|
echo "#include <spawn.h>" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2010-09-09 22:40:27 +08:00
|
|
|
if [ -z "$SERVICECMD" ]; then
|
|
|
|
printf "Checking for OpenRC ... "
|
|
|
|
if [ -x /sbin/rc-service ]; then
|
|
|
|
SERVICEEXISTS="/sbin/rc-service -e \$1"
|
|
|
|
SERVICECMD="/sbin/rc-service \$1 -- -D \$2"
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
fi
|
2010-10-23 08:15:42 +08:00
|
|
|
if [ -z "$SERVICECMD" ]; then
|
2010-09-09 22:40:27 +08:00
|
|
|
printf "Checking for invoke-rc.d ... "
|
|
|
|
if [ -x /usr/sbin/invoke-rc.d ]; then
|
|
|
|
SERVICEEXISTS="/usr/sbin/invoke-rc.d --query --quiet \$1 start >/dev/null 2>&1 || [ \$? = 104 ]"
|
|
|
|
SERVICECMD="/usr/sbin/invoke-rc.d \$1 \$2"
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$SERVICECMD" ]; then
|
|
|
|
printf "Checking for service ... "
|
|
|
|
if [ -x /sbin/service ]; then
|
|
|
|
SERVICEEXISTS="/sbin/service \$1 >/dev/null 2>&1"
|
|
|
|
SERVICECMD="/sbin/service \$1 \$2"
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$SERVICECMD" ]; then
|
|
|
|
for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
|
|
|
|
printf "Checking for $x ... "
|
|
|
|
if [ -d $x ]; then
|
|
|
|
SERVICEEXISTS="[ -x $x/\$1 ]"
|
|
|
|
SERVICECMD="$x/\$1 \$2"
|
|
|
|
echo "yes"
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -e /etc/arch-release ]; then
|
|
|
|
echo "Overriding service status check for Arch Linux"
|
2011-05-22 14:19:33 +08:00
|
|
|
SERVICESTATUS="[ -e /var/run/daemons/\$1 ]"
|
2010-09-09 22:40:27 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$SERVICEEXISTS" -o -z "$SERVICECMD" ]; then
|
2012-04-22 01:18:14 +08:00
|
|
|
echo "$0: WARNING: No means of interacting with system services detected!"
|
2010-09-09 22:40:27 +08:00
|
|
|
SERVICEEXISTS="return 1"
|
|
|
|
SERVICECMD="return 1"
|
|
|
|
fi
|
|
|
|
if [ -z "$SERVICESTATUS" ]; then
|
|
|
|
SERVICESTATUS="service_command \$1 status >/dev/null 2>&1"
|
|
|
|
fi
|
|
|
|
# Transform for a make file
|
2010-11-04 17:12:14 +08:00
|
|
|
SERVICEEXISTS=$(echo "$SERVICEEXISTS" | $SED \
|
2010-09-09 22:40:27 +08:00
|
|
|
-e 's:\\:\\\\:g' \
|
|
|
|
-e 's:\&:\\\&:g' \
|
|
|
|
-e 's:\$:\$\$:g' \
|
|
|
|
)
|
|
|
|
echo "SERVICEEXISTS= $SERVICEEXISTS" >>config.mk
|
2010-11-04 17:12:14 +08:00
|
|
|
SERVICECMD=$(echo "$SERVICECMD" | $SED \
|
2010-09-09 22:40:27 +08:00
|
|
|
-e 's:\\:\\\\:g' \
|
|
|
|
-e 's:\&:\\\&:g' \
|
|
|
|
-e 's:\$:\$\$:g' \
|
|
|
|
)
|
|
|
|
echo "SERVICECMD= $SERVICECMD" >>config.mk
|
2010-11-04 17:12:14 +08:00
|
|
|
SERVICESTATUS=$(echo "$SERVICESTATUS" | $SED \
|
2010-09-09 22:40:27 +08:00
|
|
|
-e 's:\\:\\\\:g' \
|
|
|
|
-e 's:\&:\\\&:g' \
|
|
|
|
-e 's:\$:\$\$:g' \
|
|
|
|
)
|
|
|
|
echo "SERVICESTATUS= $SERVICESTATUS" >>config.mk
|
|
|
|
|
2009-07-15 05:01:59 +08:00
|
|
|
HOOKS=
|
2009-10-17 05:36:51 +08:00
|
|
|
if ! $HOOKSET; then
|
|
|
|
printf "Checking for ntpd ... "
|
|
|
|
NTPD=$(_which ntpd)
|
|
|
|
if [ -n "$NTPD" ]; then
|
|
|
|
echo "$NTPD (50-ntp.conf)"
|
|
|
|
HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf"
|
|
|
|
else
|
|
|
|
echo "not found"
|
|
|
|
fi
|
2009-10-09 21:12:20 +08:00
|
|
|
|
2009-10-17 05:36:51 +08:00
|
|
|
printf "Checking for ypind ... "
|
|
|
|
YPBIND=$(_which ypbind)
|
|
|
|
if [ -n "$YPBIND" ]; then
|
|
|
|
if strings "$YPBIND" | grep -q yp.conf; then
|
|
|
|
YPHOOK="50-yp.conf"
|
|
|
|
else
|
|
|
|
YPHOOK="50-ypbind"
|
|
|
|
fi
|
|
|
|
echo "$YPBIND ($YPHOOK)"
|
|
|
|
HOOKS="$HOOKS${HOOKS:+ }$YPHOOK"
|
2009-10-09 21:12:20 +08:00
|
|
|
else
|
2009-10-17 05:36:51 +08:00
|
|
|
echo "not found"
|
2009-10-09 21:12:20 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd dhcpcd-hooks
|
2009-07-15 05:01:59 +08:00
|
|
|
for x in $HOOKSCRIPTS; do
|
|
|
|
printf "Finding hook $x ... "
|
|
|
|
for h in [0-9][0-9]"-$x" [0-9][0-9]"-$x.sh" [0-9][0-9]"-$x.conf"; do
|
|
|
|
[ -e "$h" ] && break
|
|
|
|
done
|
|
|
|
if [ ! -e "$h" ]; then
|
|
|
|
echo "no"
|
|
|
|
else
|
|
|
|
echo "$h"
|
2009-10-17 14:58:42 +08:00
|
|
|
case " $HOOKS " in
|
|
|
|
*" $h "*) ;;
|
|
|
|
*) HOOKS="$HOOKS${HOOKS:+ }$h";;
|
|
|
|
esac
|
2009-07-15 05:01:59 +08:00
|
|
|
fi
|
|
|
|
done
|
2009-07-22 04:51:00 +08:00
|
|
|
cd ..
|
2009-07-15 05:01:59 +08:00
|
|
|
echo "HOOKSCRIPTS= $HOOKS" >>$CONFIG_MK
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo " SYSCONFDIR = $SYSCONFDIR"
|
|
|
|
echo " SBINDIR = $SBINDIR"
|
2009-07-27 03:29:37 +08:00
|
|
|
echo " LIBDIR = $LIBDIR"
|
2009-07-15 05:01:59 +08:00
|
|
|
echo " LIBEXECDIR = $LIBEXECDIR"
|
|
|
|
echo " DBDIR = $DBDIR"
|
|
|
|
echo " RUNDIR = $RUNDIR"
|
|
|
|
echo " MANDIR = $MANDIR"
|
2009-10-09 21:12:20 +08:00
|
|
|
echo " HOOKSCRIPTS = $HOOKS"
|
2009-07-15 05:01:59 +08:00
|
|
|
echo
|