2009-07-14 21:59:30 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# Try and be like autotools configure, but without autotools
|
|
|
|
|
2014-03-07 21:35:10 +08:00
|
|
|
echo "configure args: $*"
|
2014-09-21 19:39:02 +08:00
|
|
|
exec 3>config.log
|
2014-03-07 21:35:10 +08:00
|
|
|
|
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
|
2013-02-04 21:30:35 +08:00
|
|
|
INET=
|
2016-10-14 16:55:04 +08:00
|
|
|
ARP=
|
|
|
|
ARPING=
|
2016-09-20 17:29:39 +08:00
|
|
|
IPV4LL=
|
2013-02-04 21:30:35 +08:00
|
|
|
INET6=
|
2019-11-29 00:41:15 +08:00
|
|
|
PRIVSEP=
|
2019-12-18 22:37:01 +08:00
|
|
|
PRIVSEP_USER=
|
2023-07-20 17:32:26 +08:00
|
|
|
SECCOMP=
|
2009-11-20 20:20:10 +08:00
|
|
|
ARC4RANDOM=
|
|
|
|
CLOSEFROM=
|
2019-03-04 06:59:13 +08:00
|
|
|
RBTREE=
|
2019-04-20 04:42:07 +08:00
|
|
|
CONSTTIME_MEMEQUAL=
|
2019-06-18 18:33:53 +08:00
|
|
|
OPEN_MEMSTREAM=
|
2009-11-20 20:20:10 +08:00
|
|
|
STRLCPY=
|
2013-09-10 00:14:06 +08:00
|
|
|
UDEV=
|
2010-01-26 04:06:15 +08:00
|
|
|
OS=
|
2014-03-25 02:41:34 +08:00
|
|
|
BUILD=
|
2010-01-26 04:06:15 +08:00
|
|
|
HOST=
|
2014-09-22 04:09:25 +08:00
|
|
|
HOSTCC=
|
2010-01-26 04:06:15 +08:00
|
|
|
TARGET=
|
2018-01-07 21:24:21 +08:00
|
|
|
INCLUDEDIR=
|
2010-01-26 04:06:15 +08:00
|
|
|
DEBUG=
|
|
|
|
FORK=
|
2012-07-06 00:37:41 +08:00
|
|
|
STATIC=
|
2013-09-12 23:43:20 +08:00
|
|
|
DEVS=
|
2013-11-29 19:15:03 +08:00
|
|
|
EMBEDDED=
|
2016-09-19 17:08:11 +08:00
|
|
|
AUTH=
|
2015-03-04 19:51:55 +08:00
|
|
|
POLL=
|
2016-09-09 17:56:26 +08:00
|
|
|
SMALL=
|
2020-04-01 03:21:58 +08:00
|
|
|
SANITIZE=no
|
2016-03-12 18:52:41 +08:00
|
|
|
STATUSARG=
|
2023-09-25 16:49:00 +08:00
|
|
|
OPENSSL=
|
2009-10-17 05:36:51 +08:00
|
|
|
|
2016-09-09 17:56:26 +08:00
|
|
|
DHCPCD_DEFS=dhcpcd-definitions.conf
|
|
|
|
|
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
|
|
|
--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;;
|
2016-10-14 16:55:04 +08:00
|
|
|
--disable-ipv4|--disable-inet) INET=no; ARP=no; ARPING=no; IPV4LL=no;;
|
2016-09-27 18:21:31 +08:00
|
|
|
--enable-ipv4|--enable-inet) INET=yes;;
|
2016-10-14 16:55:04 +08:00
|
|
|
--disable-arp) ARP=no; ARPING=no; IPV4LL=no;;
|
|
|
|
--enable-arp) ARP=yes; INET=yes;;
|
|
|
|
--disable-arping) ARPING=no;;
|
|
|
|
--enable-arping) ARPING=yes; ARP=yes; INET=yes;;
|
2016-09-20 17:29:39 +08:00
|
|
|
--disable-ipv4ll) IPV4LL=no;;
|
2016-10-14 16:55:04 +08:00
|
|
|
--enable-ipv4ll) IPV4LL=yes; ARP=yes; INET=yes;;
|
|
|
|
--disable-ipv6|--disable-inet6) INET6=no; DHCP6=no;;
|
2016-09-27 18:21:31 +08:00
|
|
|
--enable-ipv6|--enable-inet6) INET6=yes;;
|
2016-09-27 18:17:39 +08:00
|
|
|
--disable-dhcp6) DHCP6=no;;
|
|
|
|
--enable-dhcp6) DHCP6=yes;;
|
2013-11-29 19:15:03 +08:00
|
|
|
--disable-embedded) EMBEDDED=no;;
|
2014-04-25 16:16:02 +08:00
|
|
|
--enable-embedded) EMBEDDED=yes;;
|
2016-09-19 17:08:11 +08:00
|
|
|
--disable-auth) AUTH=no;;
|
|
|
|
--enable-auth) AUTH=yes;;
|
2019-11-29 00:41:15 +08:00
|
|
|
--disable-privsep) PRIVSEP=no;;
|
|
|
|
--enable-privsep) PRIVSEP=yes;;
|
2023-07-20 17:32:26 +08:00
|
|
|
--disable-seccomp) SECCOMP=no;;
|
|
|
|
--enable-seccomp) SECCOMP=yes;;
|
2019-12-02 08:43:07 +08:00
|
|
|
--privsepuser) PRIVSEP_USER=$var;;
|
2022-10-17 21:30:03 +08:00
|
|
|
--prefix) PREFIX=$var;prefix=$var;; # prefix is set for autotools compat
|
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;;
|
2019-11-28 19:47:29 +08:00
|
|
|
--rundir) RUNDIR=$var;;
|
|
|
|
--runstatedir) RUNSTATEDIR=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--mandir) MANDIR=$var;;
|
2015-12-23 06:26:09 +08:00
|
|
|
--datadir) DATADIR=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
--with-ccopts|CFLAGS) CFLAGS=$var;;
|
2018-01-07 21:24:21 +08:00
|
|
|
-I|--includedir) INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }-I$var";;
|
2014-03-24 19:07:19 +08:00
|
|
|
CC) CC=$var;;
|
2009-07-14 21:59:30 +08:00
|
|
|
CPPFLAGS) CPPFLAGS=$var;;
|
2016-06-21 16:39:19 +08:00
|
|
|
PKG_CONFIG) PKG_CONFIG=$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;;
|
2020-06-17 22:12:13 +08:00
|
|
|
--with-eghook) EGHOOKSCRIPTS="$EGHOOKSCRIPTS${EGHOOKSCRIPTS+ }$var";;
|
2020-06-17 22:17:58 +08:00
|
|
|
--with-eghooks|EGHOOKSCRIPTS) EGHOOKSCRIPTS=$var; EGHOOKSET=true;;
|
2020-04-01 02:45:17 +08:00
|
|
|
--with-default-hostname) _DEFAULT_HOSTNAME=$var;;
|
2009-07-27 03:29:37 +08:00
|
|
|
--build) BUILD=$var;;
|
2014-03-25 02:40:45 +08:00
|
|
|
--host) HOST=$var; HOSTCC=$var-;;
|
2009-07-27 03:29:37 +08:00
|
|
|
--target) TARGET=$var;;
|
|
|
|
--libdir) LIBDIR=$var;;
|
2009-11-20 20:20:10 +08:00
|
|
|
--without-arc4random) ARC4RANDOM=no;;
|
|
|
|
--without-strlcpy) STRLCPY=no;;
|
2016-04-02 05:14:28 +08:00
|
|
|
--without-pidfile_lock) PIDFILE_LOCK=no;;
|
2016-05-03 19:54:25 +08:00
|
|
|
--without-reallocarrray) REALLOCARRAY=no;;
|
2014-01-25 09:35:53 +08:00
|
|
|
--without-md5) MD5=no;;
|
2014-06-02 22:48:33 +08:00
|
|
|
--without-sha2) SHA2=no;;
|
|
|
|
--without-sha256) SHA2=no;;
|
2017-10-05 21:13:02 +08:00
|
|
|
--without-hmac) HMAC=no;;
|
2013-09-12 23:43:20 +08:00
|
|
|
--without-dev) DEV=no;;
|
2019-01-11 20:39:33 +08:00
|
|
|
--with-udev) DEV=yes; UDEV=yes;;
|
2013-09-10 00:14:06 +08:00
|
|
|
--without-udev) UDEV=no;;
|
2015-03-04 19:51:55 +08:00
|
|
|
--with-poll) POLL="$var";;
|
2023-09-25 16:49:00 +08:00
|
|
|
--with-openssl) OPENSSL=yes;;
|
|
|
|
--without-openssl) OPENSSL=no;;
|
2021-01-27 21:31:51 +08:00
|
|
|
--sanitise|--sanitize) SANITIZEADDRESS="yes";;
|
2010-09-09 22:40:27 +08:00
|
|
|
--serviceexists) SERVICEEXISTS=$var;;
|
|
|
|
--servicecmd) SERVICECMD=$var;;
|
|
|
|
--servicestatus) SERVICESTATUS=$var;;
|
2016-09-09 17:56:26 +08:00
|
|
|
--small) SMALL=yes;;
|
2016-03-12 18:52:41 +08:00
|
|
|
--statusarg) STATUSARG=$var;;
|
2019-01-11 20:30:46 +08:00
|
|
|
--infodir) ;; # ignore autotools
|
2010-06-09 23:32:03 +08:00
|
|
|
--disable-maintainer-mode|--disable-dependency-tracking) ;;
|
2023-05-18 18:40:19 +08:00
|
|
|
--disable-option-checking|--disable-silent-rules) ;;
|
2013-02-16 04:07:26 +08:00
|
|
|
-V|--version)
|
|
|
|
v=$(sed -ne 's/.*VERSION[[:space:]]*"\([^"]*\).*/\1/p' defs.h);
|
|
|
|
c=$(sed -ne 's/^.*copyright\[\] = "\([^"]*\).*/\1/p' dhcpcd.c);
|
|
|
|
echo "dhcpcd-$v $c";
|
|
|
|
exit 0;;
|
|
|
|
-h|--help) cat <<EOF
|
|
|
|
\`configure' configures this package to adapt to many kinds of systems.
|
|
|
|
|
|
|
|
Usage: configure [OPTION]... [VAR=VALUE]...
|
|
|
|
|
|
|
|
To assign environment variables (e.g., CC, CFLAGS...), specify them as
|
|
|
|
VAR=VALUE. See below for descriptions of some of the useful variables.
|
|
|
|
|
|
|
|
Defaults for the options are specified in brackets.
|
|
|
|
|
|
|
|
Configuration:
|
|
|
|
-h, --help display this help and exit
|
|
|
|
--help=short display options specific to this package
|
|
|
|
-V, --version display version information and exit
|
|
|
|
|
|
|
|
Installation directories:
|
|
|
|
--prefix=PREFIX install architecture-independent files in PREFIX [/]
|
|
|
|
|
|
|
|
By default, \`make install' will install all the files in \'/sbin',
|
|
|
|
\`/libexec', etc. You can specify
|
|
|
|
an installation prefix other than \`/' using \`--prefix',
|
|
|
|
for instance \`--prefix=$HOME'.
|
|
|
|
|
|
|
|
For better control, use the options below.
|
|
|
|
|
|
|
|
Fine tuning of the installation directories:
|
|
|
|
--bindir=DIR user executables [PREFIX/bin]
|
|
|
|
--sbindir=DIR system admin executables [PREFIX/sbin]
|
|
|
|
--libexecdir=DIR program executables [PREFIX/libexec]
|
2019-10-17 05:31:20 +08:00
|
|
|
--dbdir=DIR database [STATEDIR/db/dhcpcd]
|
2013-02-16 04:07:26 +08:00
|
|
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
2016-03-04 03:59:45 +08:00
|
|
|
--localstatedir=DIR modifiable single-machine data [/var]
|
2013-02-16 04:07:26 +08:00
|
|
|
--libdir=DIR object code libraries [PREFIX/lib]
|
|
|
|
--includedir=DIR C header files [PREFIX/include]
|
|
|
|
--mandir=DIR man documentation [PREFIX/man]
|
|
|
|
|
|
|
|
System types:
|
|
|
|
--build=BUILD configure for building on BUILD [guessed]
|
2021-01-27 21:31:51 +08:00
|
|
|
--host=HOST build programs to run on HOST [BUILD]
|
|
|
|
--target=TARGET configure for building compilers for TARGET [HOST]
|
2013-02-16 04:07:26 +08:00
|
|
|
|
|
|
|
Optional Features:
|
|
|
|
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
|
|
|
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
|
|
|
|
|
|
|
Some influential environment variables:
|
|
|
|
CC C compiler command
|
|
|
|
CFLAGS C compiler flags
|
|
|
|
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
|
2021-01-27 21:31:51 +08:00
|
|
|
nonstandard directory <lib dir>
|
2013-02-16 04:07:26 +08:00
|
|
|
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
|
2021-01-27 21:31:51 +08:00
|
|
|
headers in a nonstandard directory <include dir>
|
2013-02-16 04:07:26 +08:00
|
|
|
CPP C preprocessor
|
2016-06-21 16:39:19 +08:00
|
|
|
PKG_CONFIG pkg-config executable
|
2013-02-16 04:07:26 +08:00
|
|
|
|
|
|
|
Use these variables to override the choices made by \`configure' or to help
|
|
|
|
it to find libraries and programs with nonstandard names/locations.
|
|
|
|
EOF
|
|
|
|
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}
|
2013-11-29 19:15:03 +08:00
|
|
|
: ${GREP:=grep}
|
2016-06-21 16:39:19 +08:00
|
|
|
: ${PKG_CONFIG:=pkg-config}
|
2013-11-29 19:15:03 +08:00
|
|
|
: ${WC:=wc}
|
2009-09-03 18:10:51 +08:00
|
|
|
|
2009-07-14 21:59:30 +08:00
|
|
|
: ${FORK:=yes}
|
2009-10-09 21:12:20 +08:00
|
|
|
_which()
|
|
|
|
{
|
|
|
|
x="$(which "$1" 2>/dev/null)"
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ $? = 0 ] && [ -n "$x" ]; then
|
2009-10-09 21:12:20 +08:00
|
|
|
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
|
2014-03-02 16:36:19 +08:00
|
|
|
# autoconf target triplet: cpu-vendor-os
|
|
|
|
BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
|
2009-07-27 03:29:37 +08:00
|
|
|
fi
|
2014-03-25 02:40:45 +08:00
|
|
|
: ${HOST:=$BUILD}
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
if [ -z "$OS" ]; then
|
2014-03-25 02:40:45 +08:00
|
|
|
echo "Deriving operating system from ... $HOST"
|
2014-03-03 23:48:07 +08:00
|
|
|
# Derive OS from cpu-vendor-[kernel-]os
|
2014-03-25 02:40:45 +08:00
|
|
|
CPU=${HOST%%-*}
|
|
|
|
REST=${HOST#*-}
|
2010-06-09 23:32:03 +08:00
|
|
|
if [ "$CPU" != "$REST" ]; then
|
2014-03-02 16:36:19 +08:00
|
|
|
VENDOR=${REST%%-*}
|
2010-06-09 23:32:03 +08:00
|
|
|
REST=${REST#*-}
|
2014-03-02 16:36:19 +08:00
|
|
|
if [ "$VENDOR" != "$REST" ]; then
|
2014-03-04 01:25:28 +08:00
|
|
|
# Use kernel if given, otherwise os
|
|
|
|
OS=${REST%%-*}
|
2010-06-09 23:32:03 +08:00
|
|
|
else
|
|
|
|
# 2 tupple
|
2014-03-02 16:36:19 +08:00
|
|
|
OS=$VENDOR
|
|
|
|
VENDOR=
|
2010-06-09 23:32:03 +08:00
|
|
|
fi
|
|
|
|
fi
|
2014-03-03 23:48:07 +08:00
|
|
|
|
2021-01-27 21:31:51 +08:00
|
|
|
# Work with cpu-kernel-os, ie Debian
|
2014-03-04 01:25:28 +08:00
|
|
|
case "$VENDOR" in
|
2014-03-07 03:11:55 +08:00
|
|
|
linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;;
|
2014-03-04 01:25:28 +08:00
|
|
|
esac
|
2016-01-01 01:46:05 +08:00
|
|
|
case "$REST" in
|
|
|
|
gnu/kfreebsd*) OS="kfreebsd"; VENDOR= ;;
|
|
|
|
esac
|
2014-03-04 01:25:28 +08:00
|
|
|
# Special case
|
|
|
|
case "$OS" in
|
2019-08-28 20:50:06 +08:00
|
|
|
dragonfly*)
|
|
|
|
# This means /usr HAS to be mounted not via dhcpcd
|
|
|
|
: ${LIBEXECDIR:=${PREFIX:-/usr}/libexec}
|
|
|
|
;;
|
2014-03-07 03:11:55 +08:00
|
|
|
gnu*) OS=hurd;; # No HURD support as yet
|
2014-03-04 01:25:28 +08:00
|
|
|
esac
|
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
|
|
|
|
2019-08-28 20:50:06 +08:00
|
|
|
: ${SYSCONFDIR:=$PREFIX/etc}
|
|
|
|
: ${SBINDIR:=$PREFIX/sbin}
|
|
|
|
: ${LIBDIR:=$PREFIX/lib}
|
|
|
|
: ${LIBEXECDIR:=$PREFIX/libexec}
|
|
|
|
: ${STATEDIR:=/var}
|
|
|
|
: ${DBDIR:=$STATEDIR/db/dhcpcd}
|
2019-11-28 19:47:29 +08:00
|
|
|
: ${RUNSTATEDIR:=$STATEDIR/run}
|
|
|
|
: ${RUNDIR:=$RUNSTATEDIR/dhcpcd}
|
2019-08-28 20:50:06 +08:00
|
|
|
: ${MANDIR:=${PREFIX:-/usr}/share/man}
|
|
|
|
: ${DATADIR:=${PREFIX:-/usr}/share}
|
|
|
|
|
|
|
|
eval SYSCONFDIR="$SYSCONFDIR"
|
|
|
|
eval LIBDIR="$LIBDIR"
|
|
|
|
eval LIBEXECDIR="$LIBEXECDIR"
|
|
|
|
eval STATEDIR="$STATEDIR"
|
|
|
|
eval DBDIR="$DBDIR"
|
|
|
|
eval RUNDIR="$RUNDIR"
|
|
|
|
eval MANDIR="$MANDIR"
|
|
|
|
eval DATADIR="$DATADIR"
|
|
|
|
|
|
|
|
echo "#ifndef SYSCONFDIR" >>$CONFIG_H
|
2013-09-12 23:43:20 +08:00
|
|
|
for x in SYSCONFDIR SBINDIR LIBDIR 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=" "
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define $x$t \"$v\"" >>$CONFIG_H
|
2009-07-14 21:59:30 +08:00
|
|
|
done
|
2019-08-28 20:50:06 +08:00
|
|
|
echo "#endif" >>$CONFIG_H
|
|
|
|
|
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
|
2016-01-08 03:53:50 +08:00
|
|
|
echo "DATADIR= $DATADIR" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2014-03-24 19:07:19 +08:00
|
|
|
# Always obey CC.
|
|
|
|
if [ -n "$CC" ]; then
|
2014-03-25 02:40:45 +08:00
|
|
|
HOSTCC=
|
2014-03-24 19:07:19 +08:00
|
|
|
else
|
|
|
|
CC=cc
|
|
|
|
_COMPILERS="cc clang gcc pcc icc"
|
|
|
|
fi
|
2014-09-22 04:09:25 +08:00
|
|
|
# Only look for a cross compiler if --host and --build are not the same
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -n "$HOSTCC" ] && [ "$BUILD" != "$HOST" ]; then
|
2014-03-24 19:07:19 +08:00
|
|
|
for _CC in $_COMPILERS; do
|
2014-03-25 02:40:45 +08:00
|
|
|
_CC=$(_which "$HOSTCC$_CC")
|
2014-03-24 19:07:19 +08:00
|
|
|
if [ -x "$_CC" ]; then
|
|
|
|
CC=$_CC
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2014-03-13 08:42:16 +08:00
|
|
|
if ! type "$CC" >/dev/null 2>&1; then
|
2014-03-24 19:07:19 +08:00
|
|
|
for _CC in $_COMPILERS; do
|
2014-03-13 08:42:16 +08:00
|
|
|
_CC=$(_which "$_CC")
|
|
|
|
if [ -x "$_CC" ]; then
|
|
|
|
CC=$_CC
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-11-10 19:17:40 +08:00
|
|
|
# Set to blank, then append user config
|
|
|
|
# We do this so our SED call to append to XCC remains portable
|
2009-07-14 21:59:30 +08:00
|
|
|
if [ -n "$CFLAGS" ]; then
|
2013-11-28 05:14:19 +08:00
|
|
|
echo "CFLAGS=" >>$CONFIG_MK
|
2013-11-10 19:17:40 +08:00
|
|
|
echo "CFLAGS+= $CFLAGS" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
fi
|
2013-06-25 17:04:10 +08:00
|
|
|
if [ -n "$CPPFLAGS" ]; then
|
2013-11-28 05:14:19 +08:00
|
|
|
echo "CPPFLAGS=" >>$CONFIG_MK
|
2013-11-10 19:17:40 +08:00
|
|
|
echo "CPPFLAGS+= $CPPFLAGS" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
fi
|
2018-01-07 21:24:21 +08:00
|
|
|
if [ -n "$INCLUDEDIR" ]; then
|
|
|
|
echo "CPPFLAGS+= $INCLUDEDIR" >>$CONFIG_MK
|
|
|
|
fi
|
2012-07-06 00:37:41 +08:00
|
|
|
if [ -n "$LDFLAGS" ]; then
|
2013-11-28 05:14:19 +08:00
|
|
|
echo "LDFLAGS=" >>$CONFIG_MK
|
2013-11-10 19:17:40 +08:00
|
|
|
echo "LDFLAGS+= $LDFLAGS" >>$CONFIG_MK
|
2012-07-06 00:37:41 +08:00
|
|
|
fi
|
2013-11-10 19:17:40 +08:00
|
|
|
|
2016-04-14 00:45:52 +08:00
|
|
|
echo "CPPFLAGS+= -DHAVE_CONFIG_H" >>$CONFIG_MK
|
|
|
|
|
2014-03-26 19:16:02 +08:00
|
|
|
# NetBSD: Even if we build for $PREFIX, the clueless user might move us to /
|
|
|
|
LDELF=/libexec/ld.elf_so
|
|
|
|
if [ -e "$LDELF" ]; then
|
|
|
|
echo "Linking against $LDELF"
|
|
|
|
echo "LDFLAGS+= -Wl,-dynamic-linker=$LDELF" >>$CONFIG_MK
|
|
|
|
echo "LDFLAGS+= -Wl,-rpath=${LIBDIR}" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$PREFIX" ] || [ "$PREFIX" = / ]; then
|
2014-06-06 01:42:21 +08:00
|
|
|
ALLOW_USR_LIBS=false
|
|
|
|
else
|
|
|
|
ALLOW_USR_LIBS=true
|
|
|
|
fi
|
2014-03-08 00:03:52 +08:00
|
|
|
case "$OS" in
|
2023-04-12 02:25:03 +08:00
|
|
|
linux*|solaris*|sunos*|kfreebsd*|dragonfly*|freebsd*) ;;
|
2014-03-26 19:16:02 +08:00
|
|
|
*)
|
2016-03-12 04:46:54 +08:00
|
|
|
# There might be more than one ...
|
|
|
|
for LDELFN in /libexec/ld-elf.so.[0-9]*; do
|
|
|
|
[ -x "$LDELFN" ] && break
|
|
|
|
done
|
2021-05-05 00:33:02 +08:00
|
|
|
if ! [ -x "$LDELF" ] || [ -x "$LDELFN" ]; then
|
|
|
|
if [ -z "$PREFIX" ] || [ "$PREFIX" = "/" ]; then
|
|
|
|
echo "Forcing a static build for $OS and \$PREFIX of /"
|
|
|
|
STATIC=yes
|
|
|
|
ALLOW_USR_LIBS=true
|
|
|
|
fi
|
2014-03-08 00:03:52 +08:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2012-07-06 00:37:41 +08:00
|
|
|
if [ "$STATIC" = yes ]; then
|
|
|
|
echo "LDFLAGS+= -static" >>$CONFIG_MK
|
|
|
|
fi
|
2009-07-14 21:59:30 +08:00
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$DEBUG" ] && [ -d .git ]; then
|
2017-02-23 09:03:08 +08:00
|
|
|
printf "Found git checkout ... "
|
|
|
|
DEBUG=yes
|
|
|
|
fi
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -n "$DEBUG" ] && [ "$DEBUG" != no ] && [ "$DEBUG" != false ]; then
|
2019-11-05 03:56:32 +08:00
|
|
|
echo "Adding debugging CFLAGS"
|
2019-11-05 03:56:51 +08:00
|
|
|
|
2009-07-14 21:59:30 +08:00
|
|
|
cat <<EOF >>$CONFIG_MK
|
2019-11-28 20:22:28 +08:00
|
|
|
CFLAGS+= -g -Wall -Wextra -Wundef
|
2009-07-14 21:59:30 +08:00
|
|
|
CFLAGS+= -Wmissing-prototypes -Wmissing-declarations
|
2015-03-14 19:04:36 +08:00
|
|
|
CFLAGS+= -Wmissing-format-attribute -Wnested-externs
|
|
|
|
CFLAGS+= -Winline -Wcast-align -Wcast-qual -Wpointer-arith
|
|
|
|
CFLAGS+= -Wreturn-type -Wswitch -Wshadow
|
|
|
|
CFLAGS+= -Wcast-qual -Wwrite-strings
|
|
|
|
CFLAGS+= -Wformat=2
|
|
|
|
CFLAGS+= -Wpointer-sign -Wmissing-noreturn
|
2009-07-14 21:59:30 +08:00
|
|
|
EOF
|
2020-04-01 03:21:58 +08:00
|
|
|
|
2014-03-06 02:11:22 +08:00
|
|
|
case "$OS" in
|
2014-03-28 06:14:52 +08:00
|
|
|
mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers
|
2019-09-14 01:33:25 +08:00
|
|
|
bitrig*|solaris*|sunos*)
|
|
|
|
echo "CFLAGS+= -Wredundant-decls" >>$CONFIG_MK
|
2015-09-12 21:14:27 +08:00
|
|
|
;; # Bitrig spouts many conversion errors with htons
|
2016-05-01 22:51:10 +08:00
|
|
|
# sunos has many as well
|
2015-05-16 03:41:33 +08:00
|
|
|
*) echo "CFLAGS+= -Wredundant-decls" >>$CONFIG_MK
|
|
|
|
echo "CFLAGS+= -Wconversion" >>$CONFIG_MK
|
|
|
|
;;
|
2014-03-06 02:11:22 +08:00
|
|
|
esac
|
2014-05-22 07:07:52 +08:00
|
|
|
|
|
|
|
case "$OS" in
|
2019-09-14 01:33:25 +08:00
|
|
|
solaris*|sunos*);;
|
2014-05-31 06:02:16 +08:00
|
|
|
*) echo "CFLAGS+= -Wstrict-overflow" >>$CONFIG_MK;;
|
2014-05-22 07:07:52 +08:00
|
|
|
esac
|
2017-05-04 15:54:52 +08:00
|
|
|
|
|
|
|
# Turn on extra per compiler debugging
|
|
|
|
case "$CC" in
|
|
|
|
*gcc*) echo "CFLAGS+= -Wlogical-op" >>$CONFIG_MK;;
|
|
|
|
esac
|
2020-04-01 03:21:58 +08:00
|
|
|
|
|
|
|
if [ "$SANITIZEADDRESS" = yes ]; then
|
|
|
|
printf "Testing compiler supports address sanitisation ..."
|
|
|
|
cat <<EOF >_test.c
|
|
|
|
int main(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $CC -fsanitize=address _test.c -o _test 2>&3; then
|
|
|
|
echo "yes"
|
|
|
|
echo "CFLAGS+= -fsanitize=address" >>$CONFIG_MK
|
2021-01-27 21:31:51 +08:00
|
|
|
echo "CFLAGS+= -fno-omit-frame-pointer" >>$CONFIG_MK
|
2020-04-01 03:21:58 +08:00
|
|
|
echo "LDFLAGS+= -fsanitize=address" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -rf _test.c _test
|
|
|
|
fi
|
2015-05-13 09:22:58 +08:00
|
|
|
else
|
|
|
|
echo "CPPFLAGS+= -DNDEBUG" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
fi
|
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -n "$FORK" ] && [ "$FORK" != yes ] && [ "$FORK" != true ]; then
|
2009-07-14 21:59:30 +08:00
|
|
|
echo "There is no fork"
|
|
|
|
echo "CPPFLAGS+= -DTHERE_IS_NO_FORK" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2016-09-09 17:56:26 +08:00
|
|
|
if [ "$SMALL" = yes ]; then
|
|
|
|
echo "Building with -DSMALL"
|
|
|
|
echo "CPPFLAGS+= -DSMALL" >>$CONFIG_MK
|
|
|
|
DHCPCD_DEFS=dhcpcd-definitions-small.conf
|
|
|
|
echo "DHCPCD_DEFS= $DHCPCD_DEFS" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2009-07-27 03:29:37 +08:00
|
|
|
case "$OS" in
|
2015-04-20 17:02:58 +08:00
|
|
|
freebsd*|kfreebsd*)
|
2016-01-01 00:27:44 +08:00
|
|
|
# FreeBSD hide some newer POSIX APIs behind _GNU_SOURCE ...
|
2014-12-23 17:46:02 +08:00
|
|
|
echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
|
2016-01-01 00:27:44 +08:00
|
|
|
case "$OS" in
|
|
|
|
kfreebsd*) echo "CPPFLAGS+= -DBSD" >>$CONFIG_MK;;
|
|
|
|
esac
|
2014-12-23 17:46:02 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
|
2016-01-01 00:27:44 +08:00
|
|
|
# Whacky includes needed to buck the trend
|
2016-01-01 01:46:05 +08:00
|
|
|
case "$OS" in
|
|
|
|
kfreebsd*) echo "#include <inttypes.h>" >>$CONFIG_H;
|
|
|
|
esac
|
2019-03-04 07:44:51 +08:00
|
|
|
echo "#include <net/if.h>" >>$CONFIG_H
|
|
|
|
echo "#include <net/if_var.h>" >>$CONFIG_H
|
2014-12-23 17:46:02 +08:00
|
|
|
;;
|
2016-05-03 19:54:25 +08:00
|
|
|
netbsd*)
|
|
|
|
# reallocarray(3) is guarded by _OPENBSD_SOURCE
|
|
|
|
echo "CPPFLAGS+= -D_OPENBSD_SOURCE" >>$CONFIG_MK
|
|
|
|
echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
|
|
|
|
;;
|
2014-03-07 03:11:55 +08:00
|
|
|
linux*)
|
2015-04-20 17:02:58 +08:00
|
|
|
echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
|
2015-03-12 23:57:42 +08:00
|
|
|
# Large File Support, should be fine for 32-bit systems.
|
|
|
|
# But if this is the case, why is it not set by default?
|
|
|
|
echo "CPPFLAGS+= -D_FILE_OFFSET_BITS=64" >>$CONFIG_MK
|
|
|
|
echo "CPPFLAGS+= -D_LARGEFILE_SOURCE" >>$CONFIG_MK
|
|
|
|
echo "CPPFLAGS+= -D_LARGEFILE64_SOURCE" >>$CONFIG_MK
|
2014-09-10 09:46:58 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-linux.c" >>$CONFIG_MK
|
2014-12-11 06:42:12 +08:00
|
|
|
# for RTM_NEWADDR and friends
|
2015-04-20 17:02:58 +08:00
|
|
|
echo "#include <asm/types.h> /* fix broken headers */" >>$CONFIG_H
|
2015-07-18 18:31:19 +08:00
|
|
|
echo "#include <sys/socket.h> /* fix broken headers */" >>$CONFIG_H
|
2015-04-20 17:02:58 +08:00
|
|
|
echo "#include <linux/rtnetlink.h>" >>$CONFIG_H
|
2016-11-04 23:37:43 +08:00
|
|
|
# cksum does't support -a and netpgp is rare
|
|
|
|
echo "CKSUM= sha256sum --tag" >>$CONFIG_MK
|
|
|
|
echo "PGP= gpg2" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
;;
|
2014-12-23 17:46:02 +08:00
|
|
|
qnx*)
|
|
|
|
echo "CPPFLAGS+= -D__EXT" >>$CONFIG_MK
|
2014-04-24 04:09:20 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
|
2010-10-20 19:27:32 +08:00
|
|
|
;;
|
2019-09-14 01:33:25 +08:00
|
|
|
solaris*|sunos*)
|
2014-05-22 07:07:52 +08:00
|
|
|
echo "CPPFLAGS+= -D_XPG4_2 -D__EXTENSIONS__ -DBSD_COMP" \
|
|
|
|
>>$CONFIG_MK
|
2014-05-24 21:08:29 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-sun.c" >>$CONFIG_MK
|
2019-04-14 17:54:16 +08:00
|
|
|
echo "LDADD+= -ldlpi -lkstat" >>$CONFIG_MK
|
2014-05-22 07:07:52 +08:00
|
|
|
;;
|
2009-07-14 21:59:30 +08:00
|
|
|
*)
|
2014-04-24 04:09:20 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
|
2009-07-14 21:59:30 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-04-01 02:45:17 +08:00
|
|
|
if [ -n "${_DEFAULT_HOSTNAME+x}" ]; then
|
|
|
|
DEFAULT_HOSTNAME="${_DEFAULT_HOSTNAME}"
|
|
|
|
else
|
|
|
|
case "$OS" in
|
2020-04-17 06:26:49 +08:00
|
|
|
linux*) DEFAULT_HOSTNAME="(none)";;
|
2020-04-01 02:45:17 +08:00
|
|
|
*) DEFAULT_HOSTNAME="";;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
echo "DEFAULT_HOSTNAME= $DEFAULT_HOSTNAME" >>$CONFIG_MK
|
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$INET" ] || [ "$INET" = yes ]; then
|
2016-09-27 18:17:39 +08:00
|
|
|
echo "Enabling INET support"
|
2013-02-04 21:30:35 +08:00
|
|
|
echo "CPPFLAGS+= -DINET" >>$CONFIG_MK
|
2017-03-06 05:05:24 +08:00
|
|
|
echo "DHCPCD_SRCS+= dhcp.c ipv4.c bpf.c" >>$CONFIG_MK
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$ARP" ] || [ "$ARP" = yes ]; then
|
2016-10-14 16:55:04 +08:00
|
|
|
echo "Enabling ARP support"
|
|
|
|
echo "CPPFLAGS+= -DARP" >>$CONFIG_MK
|
|
|
|
echo "DHCPCD_SRCS+= arp.c" >>$CONFIG_MK
|
|
|
|
fi
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$ARPING" ] || [ "$ARPING" = yes ]; then
|
2016-10-14 16:55:04 +08:00
|
|
|
echo "Enabling ARPing support"
|
|
|
|
echo "CPPFLAGS+= -DARPING" >>$CONFIG_MK
|
|
|
|
fi
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$IPV4LL" ] || [ "$IPV4LL" = yes ]; then
|
2016-09-27 18:21:31 +08:00
|
|
|
echo "Enabling IPv4LL support"
|
|
|
|
echo "CPPFLAGS+= -DIPV4LL" >>$CONFIG_MK
|
|
|
|
echo "DHCPCD_SRCS+= ipv4ll.c" >>$CONFIG_MK
|
|
|
|
fi
|
2013-02-04 21:30:35 +08:00
|
|
|
fi
|
2019-11-28 19:47:29 +08:00
|
|
|
if [ -z "$INET6" ] || [ "$INET6" = yes ]; then
|
2016-09-27 18:17:39 +08:00
|
|
|
echo "Enabling INET6 support"
|
2013-02-04 21:30:35 +08:00
|
|
|
echo "CPPFLAGS+= -DINET6" >>$CONFIG_MK
|
2016-09-27 18:17:39 +08:00
|
|
|
echo "DHCPCD_SRCS+= ipv6.c ipv6nd.c" >>$CONFIG_MK
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$DHCP6" ] || [ "$DHCP6" = yes ]; then
|
2016-09-27 18:21:31 +08:00
|
|
|
echo "Enabling DHCPv6 support"
|
|
|
|
echo "CPPFLAGS+= -DDHCP6" >>$CONFIG_MK
|
|
|
|
echo "DHCPCD_SRCS+= dhcp6.c" >>$CONFIG_MK
|
|
|
|
fi
|
2016-09-27 18:17:39 +08:00
|
|
|
fi
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$AUTH" ] || [ "$AUTH" = yes ]; then
|
2016-10-07 17:42:38 +08:00
|
|
|
echo "Enabling Authentication"
|
2016-09-27 18:17:39 +08:00
|
|
|
echo "CPPFLAGS+= -DAUTH" >>$CONFIG_MK
|
2016-10-07 17:42:38 +08:00
|
|
|
echo "SRCS+= auth.c" >>$CONFIG_MK
|
2013-02-04 21:30:35 +08:00
|
|
|
fi
|
|
|
|
|
2019-12-02 06:09:18 +08:00
|
|
|
if [ -z "$PRIVSEP" ]; then
|
2020-02-10 21:26:30 +08:00
|
|
|
# privilege separation works fine .... except on Solaris
|
2019-12-02 06:09:18 +08:00
|
|
|
case "$OS" in
|
|
|
|
solaris*|sunos*) PRIVSEP=no;;
|
|
|
|
*) PRIVSEP=yes;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2019-11-29 00:41:15 +08:00
|
|
|
if [ "$PRIVSEP" = yes ]; then
|
2020-02-10 22:35:08 +08:00
|
|
|
echo "Enabling Privilege Separation"
|
2020-04-05 22:52:50 +08:00
|
|
|
|
2020-04-05 23:44:32 +08:00
|
|
|
# Try and work out system user
|
2020-04-05 22:52:50 +08:00
|
|
|
if [ -z "$PRIVSEP_USER" ]; then
|
2020-04-05 23:44:32 +08:00
|
|
|
printf "Detecting a suitable user for dhcpcd ... "
|
|
|
|
for x in _dhcpcd _dhcp dhcpcd; do
|
|
|
|
home=$(getent passwd $x 2>/dev/null | cut -d: -f6)
|
2020-05-12 18:32:22 +08:00
|
|
|
if [ -d "$home" ]; then
|
2020-04-05 22:52:50 +08:00
|
|
|
PRIVSEP_USER="$x"
|
2020-05-12 18:32:22 +08:00
|
|
|
break
|
|
|
|
fi
|
2020-04-05 22:52:50 +08:00
|
|
|
done
|
|
|
|
fi
|
2020-04-05 23:44:32 +08:00
|
|
|
if [ -n "$PRIVSEP_USER" ]; then
|
|
|
|
echo "$PRIVSEP_USER"
|
|
|
|
else
|
|
|
|
PRIVSEP_USER=dhcpcd
|
|
|
|
echo
|
|
|
|
echo "No suitable user found for Priviledge Separation!"
|
|
|
|
fi
|
2020-04-05 22:52:50 +08:00
|
|
|
|
2019-11-29 00:41:15 +08:00
|
|
|
echo "CPPFLAGS+= -DPRIVSEP" >>$CONFIG_MK
|
2020-05-01 04:13:45 +08:00
|
|
|
echo "PRIVSEP_USER?= $PRIVSEP_USER" >>$CONFIG_MK
|
2019-12-02 08:43:07 +08:00
|
|
|
echo "#ifndef PRIVSEP_USER" >>$CONFIG_H
|
|
|
|
echo "#define PRIVSEP_USER \"$PRIVSEP_USER\"" >>$CONFIG_H
|
|
|
|
echo "#endif" >>$CONFIG_H
|
2020-06-10 11:57:02 +08:00
|
|
|
echo "PRIVSEP_SRCS= privsep.c privsep-root.c" >>$CONFIG_MK
|
|
|
|
echo "PRIVSEP_SRCS+= privsep-control.c privsep-inet.c" >>$CONFIG_MK
|
2019-11-29 00:41:15 +08:00
|
|
|
if [ -z "$INET" ] || [ "$INET" = yes ]; then
|
2020-06-10 01:25:18 +08:00
|
|
|
echo "PRIVSEP_SRCS+= privsep-bpf.c" >>$CONFIG_MK
|
2019-11-29 00:41:15 +08:00
|
|
|
fi
|
|
|
|
case "$OS" in
|
2023-07-20 17:32:26 +08:00
|
|
|
linux*)
|
|
|
|
echo "PRIVSEP_SRCS+= privsep-linux.c" >>$CONFIG_MK
|
2023-07-20 17:48:37 +08:00
|
|
|
if [ -n "$SECCOMP" ] && [ "$SECCOMP" = no ]; then
|
2023-07-20 17:32:26 +08:00
|
|
|
echo "#define DISABLE_SECCOMP" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
;;
|
2020-06-10 01:25:18 +08:00
|
|
|
solaris*|sunos*) echo "PRIVSEP_SRCS+= privsep-sun.c" >>$CONFIG_MK;;
|
|
|
|
*) echo "PRIVSEP_SRCS+= privsep-bsd.c" >>$CONFIG_MK;;
|
2019-11-29 00:41:15 +08:00
|
|
|
esac
|
2020-06-10 01:25:18 +08:00
|
|
|
else
|
|
|
|
echo "PRIVSEP_SRCS=" >>$CONFIG_MK
|
2019-11-29 00:41:15 +08:00
|
|
|
fi
|
|
|
|
|
2014-09-21 18:28:54 +08:00
|
|
|
echo "Using compiler .. $CC"
|
2009-09-03 18:10:51 +08:00
|
|
|
# Add CPPFLAGS and CFLAGS to CC for testing features
|
2013-11-10 18:32:01 +08:00
|
|
|
XCC="$CC `$SED -n -e 's/CPPFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
|
2009-09-03 18:10:51 +08:00
|
|
|
XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
|
|
|
|
|
2016-03-12 00:35:29 +08:00
|
|
|
# When running tests, treat all warnings as errors.
|
|
|
|
# This avoids the situation where we link to a libc symbol
|
|
|
|
# without the correct header because it might be hidden behind
|
|
|
|
# a _*_SOURCE #define guard.
|
|
|
|
XCC="$XCC -Wall -Werror"
|
|
|
|
|
2014-09-21 18:28:54 +08:00
|
|
|
# Now test we can use the compiler with our CFLAGS
|
|
|
|
cat <<EOF >_test.c
|
|
|
|
int main(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
_CC=false
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _test.c -o _test >/dev/null 2>&3; then
|
2014-09-21 18:28:54 +08:00
|
|
|
[ -x _test ] && _CC=true
|
|
|
|
fi
|
|
|
|
rm -f _test.c _test
|
|
|
|
if ! $_CC; then
|
2019-12-02 08:43:07 +08:00
|
|
|
echo $XCC
|
2015-05-13 04:03:36 +08:00
|
|
|
echo "$CC does not create executables" >&2
|
2014-09-21 18:28:54 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-04-22 06:33:46 +08:00
|
|
|
[ "$CC" != cc ] && echo "CC= $CC" >>$CONFIG_MK
|
2014-09-21 18:28:54 +08:00
|
|
|
$CC --version | $SED -e '1!d'
|
|
|
|
|
2020-05-08 03:57:22 +08:00
|
|
|
if [ "$PRIVSEP" = yes ]; then
|
|
|
|
printf "Testing for capsicum ... "
|
|
|
|
cat <<EOF >_capsicum.c
|
|
|
|
#include <sys/capsicum.h>
|
|
|
|
int main(void) {
|
|
|
|
return cap_enter();
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _capsicum.c -o _capsicum 2>&3; then
|
|
|
|
echo "yes"
|
|
|
|
echo "#define HAVE_CAPSICUM" >>$CONFIG_H
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _capsicum.c _capsicum
|
2020-05-10 23:09:54 +08:00
|
|
|
|
|
|
|
printf "Testing for pledge ... "
|
2021-01-27 21:31:51 +08:00
|
|
|
cat <<EOF >_pledge.c
|
2020-05-10 23:09:54 +08:00
|
|
|
#include <unistd.h>
|
|
|
|
int main(void) {
|
2021-01-27 21:31:51 +08:00
|
|
|
return pledge("stdio", NULL);
|
2020-05-10 23:09:54 +08:00
|
|
|
}
|
|
|
|
EOF
|
2021-01-27 21:31:51 +08:00
|
|
|
if $XCC _pledge.c -o _pledge 2>&3; then
|
|
|
|
echo "yes"
|
|
|
|
echo "#define HAVE_PLEDGE" >>$CONFIG_H
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _pledge.c _pledge
|
2020-05-08 03:57:22 +08:00
|
|
|
fi
|
|
|
|
|
2020-06-16 05:04:37 +08:00
|
|
|
# This block needs to be after the compiler test due to embedded quotes.
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$EMBEDDED" ] || [ "$EMBEDDED" = yes ]; then
|
2020-06-16 05:04:37 +08:00
|
|
|
echo "$DHCPCD_DEFS will be embedded in dhcpcd itself"
|
|
|
|
echo "DHCPCD_SRCS+= dhcpcd-embedded.c" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "$DHCPCD_DEFS will be installed to $LIBEXECDIR"
|
|
|
|
echo "CPPFLAGS+= -DEMBEDDED_CONFIG=\\\"$LIBEXECDIR/dhcpcd-definitions.conf\\\"" >>$CONFIG_MK
|
|
|
|
echo "EMBEDDEDINSTALL= _embeddedinstall" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2014-09-10 10:22:18 +08:00
|
|
|
if [ "$OS" = linux ]; then
|
|
|
|
printf "Testing for nl80211 ... "
|
|
|
|
cat <<EOF >_nl80211.c
|
2014-09-10 16:40:06 +08:00
|
|
|
#include <linux/nl80211.h>
|
2014-09-10 10:22:18 +08:00
|
|
|
int main(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _nl80211.c -o _nl80211 2>&3; then
|
2014-09-10 10:22:18 +08:00
|
|
|
echo "yes"
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_NL80211_H" >>$CONFIG_H
|
2014-09-10 10:22:18 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
2016-11-17 20:10:18 +08:00
|
|
|
echo "DHCPCD_SRCS+= if-linux-wext.c" >>$CONFIG_MK
|
2014-09-10 10:22:18 +08:00
|
|
|
fi
|
|
|
|
rm -f _nl80211.c _nl80211
|
2014-09-16 07:05:20 +08:00
|
|
|
|
2015-10-15 07:04:21 +08:00
|
|
|
printf "Testing for IN6_ADDR_GEN_MODE_NONE ... "
|
|
|
|
cat <<EOF >_IN6_ADDR_GEN_MODE_NONE.c
|
2015-09-08 00:12:57 +08:00
|
|
|
#include <linux/if_link.h>
|
|
|
|
int main(void) {
|
2015-10-15 07:04:21 +08:00
|
|
|
int x = IN6_ADDR_GEN_MODE_NONE;
|
2015-09-08 00:12:57 +08:00
|
|
|
return x;
|
|
|
|
}
|
|
|
|
EOF
|
2015-10-15 07:04:21 +08:00
|
|
|
if $XCC _IN6_ADDR_GEN_MODE_NONE.c -o _IN6_ADDR_GEN_MODE_NONE 2>&3; then
|
2015-09-08 00:12:57 +08:00
|
|
|
echo "yes"
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_IN6_ADDR_GEN_MODE_NONE" >>$CONFIG_H
|
2015-09-08 00:12:57 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
2015-10-15 07:04:21 +08:00
|
|
|
rm -f _IN6_ADDR_GEN_MODE_NONE.c _IN6_ADDR_GEN_MODE_NONE
|
2016-09-02 16:09:47 +08:00
|
|
|
else
|
|
|
|
printf "Testing for ifam_pid ... "
|
|
|
|
cat <<EOF >_ifam_pid.c
|
|
|
|
#include <net/if.h>
|
|
|
|
int main(void) {
|
|
|
|
struct ifa_msghdr ifam = { };
|
|
|
|
return (int)ifam.ifam_pid;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _ifam_pid.c -o _ifam_pid 2>&3; then
|
|
|
|
echo "yes"
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_IFAM_PID" >>$CONFIG_H
|
2016-09-02 16:09:47 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _ifam_pid.c _ifam_pid
|
2016-09-16 23:49:01 +08:00
|
|
|
|
|
|
|
printf "Testing for ifam_addrflags ... "
|
|
|
|
cat <<EOF >_ifam_addrflags.c
|
|
|
|
#include <net/if.h>
|
|
|
|
int main(void) {
|
|
|
|
struct ifa_msghdr ifam = { };
|
|
|
|
return (int)ifam.ifam_addrflags;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _ifam_addrflags.c -o _ifam_addrflags 2>&3; then
|
|
|
|
echo "yes"
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_IFAM_ADDRFLAGS" >>$CONFIG_H
|
2016-09-16 23:49:01 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _ifam_addrflags.c _ifam_addrflags
|
2014-09-10 10:22:18 +08:00
|
|
|
fi
|
|
|
|
|
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
|
2016-09-16 23:49:01 +08:00
|
|
|
LIBSOCKET=
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _getifaddrs.c -o _getifaddrs 2>&3; then
|
2009-07-18 19:31:56 +08:00
|
|
|
echo "yes"
|
2014-09-21 19:39:02 +08:00
|
|
|
elif $XCC _getifaddrs.c -o _getifaddrs -lsocket 2>&3; then
|
2016-09-16 23:49:01 +08:00
|
|
|
LIBSOCKET=-lsocket
|
2014-05-22 07:07:52 +08:00
|
|
|
echo "yes (-lsocket)"
|
|
|
|
echo "LDADD+= -lsocket" >>$CONFIG_MK
|
2009-07-18 19:31:56 +08:00
|
|
|
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
|
|
|
|
2016-09-16 23:49:01 +08:00
|
|
|
printf "Testing for ifaddrs.ifa_addrflags ... "
|
|
|
|
cat <<EOF >_getifaddrs_addrflags.c
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
int main(void) {
|
|
|
|
struct ifaddrs *ifap;
|
|
|
|
getifaddrs(&ifap);
|
|
|
|
return (int)ifap->ifa_addrflags;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _getifaddrs_addrflags.c -o _getifaddrs_addrflags $LIBSOCKET 2>&3; then
|
|
|
|
echo "yes"
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_IFADDRS_ADDRFLAGS" >>$CONFIG_H
|
2016-09-16 23:49:01 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _getifaddrs_addrflags.c _getifaddrs_addrflags
|
|
|
|
|
2014-03-23 21:38:09 +08:00
|
|
|
printf "Testing for clock_gettime ... "
|
|
|
|
cat <<EOF >_clock_gettime.c
|
|
|
|
#include <time.h>
|
|
|
|
int main(void) {
|
|
|
|
struct timespec ts;
|
|
|
|
return clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _clock_gettime.c -o _clock_gettime 2>&3; then
|
2014-03-23 21:38:09 +08:00
|
|
|
echo "yes"
|
2014-09-21 19:39:02 +08:00
|
|
|
elif $XCC _clock_gettime.c -lrt -o _clock_gettime 2>&3; then
|
2014-03-23 21:38:09 +08:00
|
|
|
echo "yes (-lrt)"
|
|
|
|
echo "LDADD+= -lrt" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
echo "libc support for clock_getttime is required - aborting" >&2
|
|
|
|
abort=true
|
|
|
|
fi
|
2014-03-24 19:07:19 +08:00
|
|
|
rm -f _clock_gettime.c _clock_gettime
|
2014-03-23 21:38:09 +08:00
|
|
|
$abort && exit 1
|
|
|
|
|
2020-01-09 04:13:20 +08:00
|
|
|
printf "Testing ioctl request type ... "
|
|
|
|
cat <<EOF >_ioctl.c
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
int main(void) {
|
|
|
|
unsigned long req = 0;
|
|
|
|
return ioctl(3, req, &req);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _ioctl.c -o _ioctl 2>&3; then
|
|
|
|
IOCTL_REQ="unsigned long"
|
|
|
|
else
|
|
|
|
IOCTL_REQ="int"
|
|
|
|
fi
|
|
|
|
echo "$IOCTL_REQ"
|
|
|
|
# Our default is unsigned long
|
|
|
|
# We can still define it, but it makes the code path slightly bigger
|
|
|
|
if [ "$IOCTL_REQ" != "unsigned long" ]; then
|
|
|
|
echo "#define IOCTL_REQUEST_TYPE $IOCTL_REQ" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
rm -f _ioctl.c _ioctl
|
|
|
|
|
2014-05-22 07:07:52 +08:00
|
|
|
printf "Testing for inet_ntoa ... "
|
|
|
|
cat <<EOF >_inet_ntoa.c
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
int main(void) {
|
2016-03-12 04:37:17 +08:00
|
|
|
struct in_addr in = { .s_addr = 0 };
|
2014-05-22 07:07:52 +08:00
|
|
|
inet_ntoa(in);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _inet_ntoa.c -o _inet_ntoa 2>&3; then
|
2014-05-22 07:07:52 +08:00
|
|
|
echo "yes"
|
2014-09-21 19:39:02 +08:00
|
|
|
elif $XCC _inet_ntoa.c -lnsl -o _inet_ntoa 2>&3; then
|
2014-05-22 07:07:52 +08:00
|
|
|
echo "yes (-lnsl)"
|
|
|
|
echo "LDADD+= -lnsl" >>$CONFIG_MK
|
2014-12-20 22:11:38 +08:00
|
|
|
elif $XCC _inet_ntoa.c -lsocket -o _inet_ntoa 2>&3; then
|
|
|
|
echo "yes (-lsocket)"
|
2021-01-27 21:31:51 +08:00
|
|
|
echo "LDADD+= -lsocket" >>$CONFIG_MK
|
2014-05-22 07:07:52 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
echo "libc support for inet_ntoa is required - aborting" >&2
|
|
|
|
abort=true
|
|
|
|
fi
|
|
|
|
rm -f _inet_ntoa.c _inet_ntoa
|
|
|
|
$abort && exit 1
|
|
|
|
|
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) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)arc4random();
|
2009-07-14 21:59:30 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _arc4random.c -o _arc4random 2>&3; then
|
2009-11-20 20:20:10 +08:00
|
|
|
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
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/arc4random.h\"" >>$CONFIG_H
|
2009-07-14 21:59:30 +08:00
|
|
|
fi
|
|
|
|
|
2014-09-08 01:24:07 +08:00
|
|
|
if [ -z "$ARC4RANDOM_UNIFORM" ]; then
|
|
|
|
printf "Testing for arc4random_uniform ... "
|
|
|
|
cat <<EOF >_arc4random_uniform.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)arc4random_uniform(100);
|
2014-09-08 01:24:07 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _arc4random_uniform.c -o _arc4random_uniform 2>&3; then
|
2014-09-08 01:24:07 +08:00
|
|
|
ARC4RANDOM_UNIFORM=yes
|
|
|
|
else
|
|
|
|
ARC4RANDOM_UNIFORM=no
|
|
|
|
fi
|
2017-03-22 19:27:59 +08:00
|
|
|
echo "$ARC4RANDOM_UNIFORM"
|
2014-09-10 10:22:18 +08:00
|
|
|
rm -f _arc4random_uniform.c _arc4random_uniform
|
2014-09-08 01:24:07 +08:00
|
|
|
fi
|
|
|
|
if [ "$ARC4RANDOM_UNIFORM" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/arc4random_uniform.c" >>$CONFIG_MK
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/arc4random_uniform.h\"" >>$CONFIG_H
|
2014-09-08 01:24:07 +08:00
|
|
|
fi
|
|
|
|
|
2019-06-18 18:33:53 +08:00
|
|
|
if [ -z "$OPEN_MEMSTREAM" ]; then
|
|
|
|
printf "Testing for open_memstream ... "
|
|
|
|
cat <<EOF >_open_memstream.c
|
|
|
|
#include <stdio.h>
|
2009-07-14 21:59:30 +08:00
|
|
|
int main(void) {
|
2019-07-28 19:53:03 +08:00
|
|
|
return open_memstream(NULL, NULL) != NULL ? 0 : 1;
|
2009-07-14 21:59:30 +08:00
|
|
|
}
|
|
|
|
EOF
|
2019-06-18 18:33:53 +08:00
|
|
|
if $XCC _open_memstream.c -o _open_memstream 2>&3; then
|
|
|
|
OPEN_MEMSTREAM=yes
|
2009-11-20 20:20:10 +08:00
|
|
|
else
|
2019-06-18 18:33:53 +08:00
|
|
|
OPEN_MEMSTREAM=no
|
2009-11-20 20:20:10 +08:00
|
|
|
fi
|
2019-06-18 18:33:53 +08:00
|
|
|
echo "$OPEN_MEMSTREAM"
|
|
|
|
rm -f _open_memstream.c _open_memstream
|
2009-11-20 20:20:10 +08:00
|
|
|
fi
|
2019-06-18 18:33:53 +08:00
|
|
|
if [ "$OPEN_MEMSTREAM" = yes ]; then
|
|
|
|
echo "#define HAVE_OPEN_MEMSTREAM" >>$CONFIG_H
|
2020-05-27 23:52:01 +08:00
|
|
|
elif [ "$PRIVSEP" = yes ]; then
|
|
|
|
echo "WARNING: Ensure that /tmp exists in the privsep users chroot"
|
2009-07-14 21:59:30 +08:00
|
|
|
fi
|
2009-07-15 05:01:59 +08:00
|
|
|
|
2016-04-02 05:14:28 +08:00
|
|
|
if [ -z "$PIDFILE_LOCK" ]; then
|
|
|
|
printf "Testing for pidfile_lock ... "
|
|
|
|
cat <<EOF >_pidfile.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <util.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)pidfile_lock(NULL);
|
2016-04-02 05:14:28 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# We only want to link to libutil if it exists in /lib
|
|
|
|
if $ALLOW_USR_LIBS; then
|
|
|
|
set -- /
|
|
|
|
else
|
|
|
|
set -- $(ls /lib/libutil.so.* 2>/dev/null)
|
|
|
|
fi
|
|
|
|
if $XCC _pidfile.c -o _pidfile 2>&3; then
|
|
|
|
PIDFILE_LOCK=yes
|
|
|
|
elif [ -e "$1" ] && $XCC _pidfile.c -o _pidfile -lutil 2>&3; then
|
|
|
|
PIDFILE_LOCK="yes (-lutil)"
|
|
|
|
LIBUTIL="-lutil"
|
|
|
|
else
|
|
|
|
PIDFILE_LOCK=no
|
|
|
|
fi
|
|
|
|
echo "$PIDFILE_LOCK"
|
|
|
|
rm -f _pidfile.c _pidfile
|
|
|
|
fi
|
|
|
|
if [ "$PIDFILE_LOCK" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/pidfile.c" >>$CONFIG_MK
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/pidfile.h\"" >>$CONFIG_H
|
2016-04-02 05:14:28 +08:00
|
|
|
else
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_UTIL_H" >>$CONFIG_H
|
2016-04-02 05:14:28 +08:00
|
|
|
if [ -n "$LIBUTIL" ]; then
|
|
|
|
echo "LDADD+= $LIBUTIL" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-02-13 18:22:31 +08:00
|
|
|
if [ -z "$SETPROCTITLE" ]; then
|
|
|
|
printf "Testing for setproctitle ... "
|
|
|
|
cat << EOF >_setproctitle.c
|
|
|
|
#include <stdlib.h>
|
2019-10-16 22:19:58 +08:00
|
|
|
#include <unistd.h>
|
2018-02-13 18:22:31 +08:00
|
|
|
int main(void) {
|
|
|
|
setproctitle("foo");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _setproctitle.c -o _setproctitle 2>&3; then
|
|
|
|
SETPROCTITLE=yes
|
|
|
|
else
|
|
|
|
SETPROCTITLE=no
|
|
|
|
fi
|
|
|
|
echo "$SETPROCTITLE"
|
|
|
|
rm -f _setproctitle.c _setproctitle
|
|
|
|
fi
|
2019-10-15 04:49:31 +08:00
|
|
|
if [ "$SETPROCTITLE" = no ]; then
|
2020-10-10 18:32:23 +08:00
|
|
|
case "$OS" in
|
|
|
|
solaris*|sunos*)
|
|
|
|
echo "$OS has no support for setting process title"
|
|
|
|
echo "#define setproctitle(...)" >>$CONFIG_H
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "COMPAT_SRCS+= compat/setproctitle.c" >>$CONFIG_MK
|
|
|
|
echo "#include \"compat/setproctitle.h\"" \
|
|
|
|
>>$CONFIG_H
|
|
|
|
;;
|
|
|
|
esac
|
2018-02-13 18:22:31 +08:00
|
|
|
fi
|
|
|
|
|
2019-06-18 18:33:53 +08:00
|
|
|
if [ -z "$STRLCPY" ]; then
|
|
|
|
printf "Testing for strlcpy ... "
|
|
|
|
cat <<EOF >_strlcpy.c
|
|
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
|
|
const char s1[] = "foo";
|
|
|
|
char s2[10];
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)strlcpy(s2, s1, sizeof(s2));
|
2019-06-18 18:33:53 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _strlcpy.c -o _strlcpy 2>&3; then
|
|
|
|
STRLCPY=yes
|
|
|
|
else
|
|
|
|
STRLCPY=no
|
|
|
|
fi
|
|
|
|
echo "$STRLCPY"
|
|
|
|
rm -f _strlcpy.c _strlcpy
|
|
|
|
fi
|
|
|
|
if [ "$STRLCPY" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/strlcpy.c" >>$CONFIG_MK
|
|
|
|
echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2015-01-31 09:02:07 +08:00
|
|
|
if [ -z "$STRTOI" ]; then
|
|
|
|
printf "Testing for strtoi ... "
|
|
|
|
cat <<EOF >_strtoi.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
int main(void) {
|
|
|
|
int e;
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)strtoi("1234", NULL, 0, 0, INT32_MAX, &e);
|
2015-01-31 09:02:07 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _strtoi.c -o _strtoi 2>&3; then
|
|
|
|
STRTOI=yes
|
|
|
|
else
|
|
|
|
STRTOI=no
|
|
|
|
fi
|
|
|
|
echo "$STRTOI"
|
|
|
|
rm -f _strtoi.c _strtoi
|
|
|
|
fi
|
|
|
|
if [ "$STRTOI" = no ]; then
|
2017-03-22 23:27:45 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/strtoi.c compat/strtou.c" >>$CONFIG_MK
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/strtoi.h\"" >>$CONFIG_H
|
2015-01-31 09:02:07 +08:00
|
|
|
fi
|
|
|
|
|
2019-04-20 04:42:07 +08:00
|
|
|
if [ -z "$CONSTTIME_MEMEQUAL" ]; then
|
|
|
|
printf "Testing for consttime_memequal ... "
|
|
|
|
cat <<EOF >_consttime_memequal.c
|
|
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
|
|
return consttime_memequal("deadbeef", "deadbeef", 8);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _consttime_memequal.c -o _consttime_memequal 2>&3; then
|
|
|
|
CONSTTIME_MEMEQUAL=yes
|
|
|
|
else
|
|
|
|
CONSTTIME_MEMEQUAL=no
|
|
|
|
fi
|
|
|
|
echo "$CONSTTIME_MEMEQUAL"
|
|
|
|
rm -f _consttime_memequal.c _consttime_memequal
|
|
|
|
fi
|
|
|
|
if [ "$CONSTTIME_MEMEQUAL" = no ]; then
|
|
|
|
echo "#include \"compat/consttime_memequal.h\"" \
|
|
|
|
>>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2014-05-22 07:07:52 +08:00
|
|
|
if [ -z "$DPRINTF" ]; then
|
|
|
|
printf "Testing for dprintf ... "
|
|
|
|
cat <<EOF >_dprintf.c
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
|
|
return dprintf(0, "%d", 0);
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _dprintf.c -o _dprintf 2>&3; then
|
2014-05-22 07:07:52 +08:00
|
|
|
DPRINTF=yes
|
|
|
|
else
|
|
|
|
DPRINTF=no
|
|
|
|
fi
|
|
|
|
echo "$DPRINTF"
|
|
|
|
rm -f _dprintf.c _dprintf
|
|
|
|
fi
|
|
|
|
if [ "$DPRINTF" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/dprintf.c" >>$CONFIG_MK
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/dprintf.h\"" >>$CONFIG_H
|
2014-05-22 07:07:52 +08:00
|
|
|
fi
|
|
|
|
|
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
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _queue.c -o _queue 2>&3; then
|
2012-07-06 00:37:41 +08:00
|
|
|
TAILQ_FOREACH_SAFE=yes
|
2014-11-11 18:33:28 +08:00
|
|
|
TAILQ_FOREACH=yes
|
2012-07-06 00:37:41 +08:00
|
|
|
else
|
|
|
|
TAILQ_FOREACH_SAFE=no
|
|
|
|
fi
|
|
|
|
echo "$TAILQ_FOREACH_SAFE"
|
|
|
|
rm -f _queue.c _queue
|
|
|
|
fi
|
2019-08-28 20:52:38 +08:00
|
|
|
if [ "$TAILQ_FOREACH_SAFE" = no ] && [ -z "$TAILQ_FOREACH_MUTABLE" ]; then
|
|
|
|
printf "Testing for TAILQ_FOREACH_MUTABLE ... "
|
|
|
|
cat <<EOF >_queue.c
|
|
|
|
#include <sys/queue.h>
|
|
|
|
int main(void) {
|
|
|
|
#ifndef TAILQ_FOREACH_MUTABLE
|
|
|
|
#error TAILQ_FOREACH_MUTABLE
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _queue.c -o _queue 2>&3; then
|
|
|
|
TAILQ_FOREACH_MUTABLE=yes
|
|
|
|
TAILQ_FOREACH_SAFE=yes
|
|
|
|
TAILQ_FOREACH=yes
|
|
|
|
echo "#define TAILQ_FOREACH_SAFE TAILQ_FOREACH_MUTABLE" \
|
|
|
|
>> $CONFIG_H
|
|
|
|
else
|
|
|
|
TAILQ_FOREACH_MUTABLE=no
|
|
|
|
fi
|
|
|
|
echo "$TAILQ_FOREACH_MUTABLE"
|
|
|
|
rm -f _queue.c _queue
|
|
|
|
fi
|
|
|
|
|
2014-11-11 18:33:28 +08:00
|
|
|
|
2014-03-06 02:11:22 +08:00
|
|
|
if [ -z "$TAILQ_CONCAT" ]; then
|
|
|
|
printf "Testing for TAILQ_CONCAT ..."
|
|
|
|
cat <<EOF >_queue.c
|
|
|
|
#include <sys/queue.h>
|
|
|
|
int main(void) {
|
|
|
|
#ifndef TAILQ_CONCAT
|
|
|
|
#error TAILQ_CONCAT
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _queue.c -o _queue 2>&3; then
|
2014-03-06 02:11:22 +08:00
|
|
|
TAILQ_CONCAT=yes
|
2014-11-11 18:33:28 +08:00
|
|
|
TAILQ_FOREACH=yes
|
2014-03-06 02:11:22 +08:00
|
|
|
else
|
|
|
|
TAILQ_CONCAT=no
|
|
|
|
fi
|
|
|
|
echo "$TAILQ_CONCAT"
|
|
|
|
rm -f _queue.c _queue
|
|
|
|
fi
|
2014-11-11 18:33:28 +08:00
|
|
|
|
|
|
|
if [ -z "$TAILQ_FOREACH" ]; then
|
|
|
|
printf "Testing for TAILQ_FOREACH ... "
|
|
|
|
cat <<EOF >_queue.c
|
|
|
|
#include <sys/queue.h>
|
|
|
|
int main(void) {
|
|
|
|
#ifndef TAILQ_FOREACH
|
|
|
|
#error TAILQ_FOREACH
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _queue.c -o _queue 2>&3; then
|
|
|
|
TAILQ_FOREACH=yes
|
|
|
|
else
|
|
|
|
TAILQ_FOREACH=no
|
|
|
|
fi
|
|
|
|
echo "$TAILQ_FOREACH"
|
|
|
|
rm -f _queue.c _queue
|
|
|
|
fi
|
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ "$TAILQ_FOREACH_SAFE" = no ] || [ "$TAILQ_CONCAT" = no ]; then
|
2014-11-11 18:33:28 +08:00
|
|
|
# If we don't include sys/queue.h then clang analyser finds
|
|
|
|
# too many false positives.
|
|
|
|
# See http://llvm.org/bugs/show_bug.cgi?id=18222
|
|
|
|
# Strictly speaking this isn't needed, but I like it to help
|
|
|
|
# catch any nasties.
|
|
|
|
if [ "$TAILQ_FOREACH" = yes ]; then
|
2019-03-04 06:59:13 +08:00
|
|
|
echo "#include <sys/queue.h>">>$CONFIG_H
|
2014-11-11 18:33:28 +08:00
|
|
|
fi
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/queue.h\"">>$CONFIG_H
|
2014-11-11 00:56:32 +08:00
|
|
|
else
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_SYS_QUEUE_H" >>$CONFIG_H
|
2014-03-06 02:11:22 +08:00
|
|
|
fi
|
|
|
|
|
2019-03-04 06:59:13 +08:00
|
|
|
if [ -z "$RBTREE" ]; then
|
|
|
|
printf "Testing for rb_tree_init ... "
|
|
|
|
cat <<EOF >_rbtree.c
|
|
|
|
#include <sys/rbtree.h>
|
|
|
|
static rb_tree_ops_t ops;
|
|
|
|
int main(void) {
|
|
|
|
rb_tree_t tree;
|
|
|
|
rb_tree_init(&tree, &ops);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _rbtree.c -o _rbtree 2>&3; then
|
|
|
|
RBTREE=yes
|
|
|
|
else
|
|
|
|
RBTREE=no
|
|
|
|
fi
|
2019-03-04 07:39:20 +08:00
|
|
|
echo "$RBTREE"
|
2019-03-04 06:59:13 +08:00
|
|
|
rm -f _rbtree.c _rbtree
|
|
|
|
fi
|
|
|
|
if [ "$RBTREE" = no ]; then
|
2023-07-19 20:46:08 +08:00
|
|
|
echo "#define HAVE_NBTOOL_CONFIG_H 0" >>$CONFIG_H
|
2019-08-28 20:55:02 +08:00
|
|
|
echo "#define RBTEST" >>$CONFIG_H
|
2019-03-04 06:59:13 +08:00
|
|
|
echo "COMPAT_SRCS+= compat/rb.c" >>$CONFIG_MK
|
|
|
|
echo "#include \"compat/rbtree.h\"" >>$CONFIG_H
|
|
|
|
else
|
|
|
|
echo "#define HAVE_SYS_RBTREE_H" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
2016-05-03 19:54:25 +08:00
|
|
|
if [ -z "$REALLOCARRAY" ]; then
|
|
|
|
printf "Testing for reallocarray ... "
|
|
|
|
cat <<EOF >_reallocarray.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int main(void) {
|
2016-05-04 19:39:37 +08:00
|
|
|
void *foo = reallocarray(NULL, 0, 0);
|
|
|
|
return foo == NULL ? 1 : 0;
|
2016-05-03 19:54:25 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _reallocarray.c -o _reallocarray 2>&3; then
|
|
|
|
REALLOCARRAY=yes
|
|
|
|
else
|
|
|
|
REALLOCARRAY=no
|
|
|
|
fi
|
|
|
|
echo "$REALLOCARRAY"
|
|
|
|
rm -f _reallocarray.c _reallocarray
|
|
|
|
fi
|
|
|
|
if [ "$REALLOCARRAY" = no ]; then
|
|
|
|
echo "COMPAT_SRCS+= compat/reallocarray.c" >>$CONFIG_MK
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/reallocarray.h\"">>$CONFIG_H
|
2016-05-03 19:54:25 +08:00
|
|
|
fi
|
2016-05-07 20:20:36 +08:00
|
|
|
# Set this for eloop
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_REALLOCARRAY" >>$CONFIG_H
|
2016-05-03 19:54:25 +08:00
|
|
|
|
2021-01-30 09:37:15 +08:00
|
|
|
# Detect a polling mechanism.
|
|
|
|
# See src/eloop.c as to why we only detect ppoll, pollts and pselect and
|
|
|
|
# not others like epoll or kqueue.
|
2015-03-05 00:40:21 +08:00
|
|
|
if [ -z "$POLL" ]; then
|
2020-06-04 06:30:08 +08:00
|
|
|
printf "Testing for ppoll ... "
|
|
|
|
cat <<EOF >_ppoll.c
|
|
|
|
#include <poll.h>
|
|
|
|
#include <stddef.h>
|
2015-03-05 00:40:21 +08:00
|
|
|
int main(void) {
|
2020-06-04 06:30:08 +08:00
|
|
|
struct pollfd fds;
|
|
|
|
return ppoll(&fds, 1, NULL, NULL);
|
2015-03-05 00:40:21 +08:00
|
|
|
}
|
|
|
|
EOF
|
2020-06-04 06:30:08 +08:00
|
|
|
if $XCC _ppoll.c -o _ppoll 2>&3; then
|
|
|
|
POLL=ppoll
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _ppoll.c _ppoll
|
2015-03-05 00:40:21 +08:00
|
|
|
fi
|
2015-03-04 23:47:04 +08:00
|
|
|
if [ -z "$POLL" ]; then
|
2020-06-04 06:30:08 +08:00
|
|
|
printf "Testing for pollts ... "
|
|
|
|
cat <<EOF >_pollts.c
|
|
|
|
#include <poll.h>
|
|
|
|
#include <stddef.h>
|
2015-03-04 23:47:04 +08:00
|
|
|
int main(void) {
|
2020-06-04 06:30:08 +08:00
|
|
|
struct pollfd fds;
|
|
|
|
return pollts(&fds, 1, NULL, NULL);
|
2015-03-04 23:47:04 +08:00
|
|
|
}
|
|
|
|
EOF
|
2020-06-04 06:30:08 +08:00
|
|
|
if $XCC _pollts.c -o _pollts 2>&3; then
|
|
|
|
POLL=pollts
|
2015-03-04 19:51:55 +08:00
|
|
|
echo "yes"
|
2013-02-19 04:56:55 +08:00
|
|
|
else
|
2015-03-04 19:51:55 +08:00
|
|
|
echo "no"
|
2013-02-19 04:56:55 +08:00
|
|
|
fi
|
2020-06-04 06:30:08 +08:00
|
|
|
rm -f _pollts.c _pollts
|
2013-02-19 04:56:55 +08:00
|
|
|
fi
|
2015-03-04 19:51:55 +08:00
|
|
|
if [ -z "$POLL" ]; then
|
2012-11-11 00:38:53 +08:00
|
|
|
printf "Testing for pselect ... "
|
|
|
|
cat <<EOF >_pselect.c
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return pselect(0, NULL, NULL, NULL, NULL, NULL);
|
2012-11-11 00:38:53 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _pselect.c -o _pselect 2>&3; then
|
2015-03-04 19:51:55 +08:00
|
|
|
POLL=pselect
|
2013-02-19 04:56:55 +08:00
|
|
|
echo "yes"
|
2012-11-11 00:38:53 +08:00
|
|
|
else
|
2013-02-19 04:56:55 +08:00
|
|
|
echo "no"
|
2012-11-11 00:38:53 +08:00
|
|
|
fi
|
|
|
|
rm -f _pselect.c _pselect
|
|
|
|
fi
|
2015-03-04 19:51:55 +08:00
|
|
|
case "$POLL" in
|
2021-01-28 19:54:05 +08:00
|
|
|
kqueue1)
|
|
|
|
echo "#define HAVE_KQUEUE" >>$CONFIG_H
|
|
|
|
echo "#define HAVE_KQUEUE1" >>$CONFIG_H
|
|
|
|
POLL=kqueue
|
|
|
|
;;
|
|
|
|
kqueue)
|
|
|
|
echo "#define HAVE_KQUEUE" >>$CONFIG_H
|
|
|
|
;;
|
2021-01-29 01:26:20 +08:00
|
|
|
epoll)
|
|
|
|
echo "#define HAVE_EPOLL" >>$CONFIG_H
|
|
|
|
;;
|
2020-06-04 06:30:08 +08:00
|
|
|
ppoll)
|
|
|
|
echo "#define HAVE_PPOLL" >>$CONFIG_H
|
2013-02-19 05:25:07 +08:00
|
|
|
;;
|
2016-01-22 21:42:13 +08:00
|
|
|
pollts)
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_POLLTS" >>$CONFIG_H
|
2016-01-22 21:42:13 +08:00
|
|
|
;;
|
2013-02-19 04:56:55 +08:00
|
|
|
pselect)
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_PSELECT" >>$CONFIG_H
|
2013-02-19 04:56:55 +08:00
|
|
|
;;
|
|
|
|
*)
|
2015-05-13 04:03:36 +08:00
|
|
|
echo "No suitable polling function is available, not even pselect" >&2
|
|
|
|
exit 1
|
2013-02-19 04:56:55 +08:00
|
|
|
;;
|
|
|
|
esac
|
2012-11-11 00:38:53 +08:00
|
|
|
|
2014-06-05 21:53:20 +08:00
|
|
|
if [ -z "$BE64ENC" ]; then
|
|
|
|
printf "Testing for be64enc ... "
|
|
|
|
cat <<EOF >_be64enc.c
|
|
|
|
#include <sys/endian.h>
|
2014-06-05 21:56:16 +08:00
|
|
|
#include <stdlib.h>
|
2014-06-05 21:53:20 +08:00
|
|
|
int main(void) {
|
|
|
|
be64enc(NULL, 0);
|
2016-03-12 00:44:59 +08:00
|
|
|
return 0;
|
2014-06-05 21:53:20 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _be64enc.c -o _be64enc 2>&3; then
|
2014-06-05 21:53:20 +08:00
|
|
|
BE64ENC=yes
|
|
|
|
else
|
|
|
|
BE64ENC=no
|
|
|
|
fi
|
|
|
|
echo "$BE64ENC"
|
2014-06-05 22:21:27 +08:00
|
|
|
rm -f _be64enc.c _be64enc
|
2014-06-05 21:53:20 +08:00
|
|
|
fi
|
2014-06-05 21:54:38 +08:00
|
|
|
if [ "$BE64ENC" = no ]; then
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/endian.h\"" >>$CONFIG_H
|
2014-06-05 21:53:20 +08:00
|
|
|
fi
|
|
|
|
|
2016-02-03 06:52:40 +08:00
|
|
|
if [ -z "$FLS64" ]; then
|
|
|
|
printf "Testing for fls64 ... "
|
|
|
|
cat <<EOF >_fls64.c
|
2016-01-29 18:18:02 +08:00
|
|
|
#include <sys/bitops.h>
|
|
|
|
int main(void) {
|
2016-02-03 06:52:40 +08:00
|
|
|
return (int)fls64(1337);
|
2016-01-29 18:18:02 +08:00
|
|
|
}
|
|
|
|
EOF
|
2016-02-03 06:52:40 +08:00
|
|
|
if $XCC _fls64.c -o _fls64 2>&3; then
|
|
|
|
FLS64=yes
|
2016-01-29 18:18:02 +08:00
|
|
|
else
|
2016-02-03 06:52:40 +08:00
|
|
|
FLS64=no
|
2016-01-29 18:18:02 +08:00
|
|
|
fi
|
2016-02-03 06:52:40 +08:00
|
|
|
echo "$FLS64"
|
|
|
|
rm -f _fls64.c _fls64
|
2016-01-29 18:18:02 +08:00
|
|
|
fi
|
2016-02-03 06:52:40 +08:00
|
|
|
if [ "$FLS64" = yes ]; then
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_SYS_BITOPS_H" >>$CONFIG_H
|
2016-01-29 18:18:02 +08:00
|
|
|
fi
|
|
|
|
|
2014-01-25 09:35:53 +08:00
|
|
|
if [ -z "$MD5" ]; then
|
2014-02-03 21:09:13 +08:00
|
|
|
MD5_LIB=
|
2014-01-25 09:35:53 +08:00
|
|
|
printf "Testing for MD5Init ... "
|
|
|
|
cat <<EOF >_md5.c
|
2014-02-03 21:09:13 +08:00
|
|
|
#include <sys/types.h>
|
2014-01-25 09:35:53 +08:00
|
|
|
#include <md5.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
|
|
MD5_CTX context;
|
|
|
|
MD5Init(&context);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-02-03 21:24:04 +08:00
|
|
|
# We only want to link to libmd if it exists in /lib
|
2014-06-06 01:42:21 +08:00
|
|
|
if $ALLOW_USR_LIBS; then
|
|
|
|
set -- /
|
|
|
|
else
|
|
|
|
set -- $(ls /lib/libmd.so.* 2>/dev/null)
|
|
|
|
fi
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _md5.c -o _md5 2>&3; then
|
2014-01-25 09:35:53 +08:00
|
|
|
MD5=yes
|
2014-09-21 19:39:02 +08:00
|
|
|
elif [ -e "$1" ] && $XCC _md5.c -lmd -o _md5 2>&3; then
|
2014-02-03 21:09:13 +08:00
|
|
|
MD5="yes (-lmd)"
|
|
|
|
MD5_LIB=-lmd
|
2014-01-25 09:35:53 +08:00
|
|
|
else
|
|
|
|
MD5=no
|
|
|
|
fi
|
|
|
|
echo "$MD5"
|
|
|
|
rm -f _md5.c _md5
|
|
|
|
fi
|
|
|
|
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -z "$SHA2_H" ]; then
|
|
|
|
if [ -z "$SHA2" ] || [ "$SHA2" != no ]; then
|
|
|
|
printf "Testing for sha2.h ... "
|
|
|
|
if [ -e /usr/include/sha2.h ]; then
|
|
|
|
SHA2_H=sha2.h
|
|
|
|
elif [ -e /usr/include/sha256.h ]; then
|
|
|
|
SHA2_H=sha256.h
|
|
|
|
fi
|
|
|
|
if [ -n "$SHA2_H" ]; then
|
|
|
|
echo "$SHA2_H"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
2014-06-02 22:48:33 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$SHA2" ]; then
|
|
|
|
SHA2_LIB=
|
2014-06-03 00:31:37 +08:00
|
|
|
SHA2_RENAMED=
|
2014-06-02 22:48:33 +08:00
|
|
|
printf "Testing for SHA256_Init ... "
|
|
|
|
cat <<EOF >_sha256.c
|
|
|
|
#include <sys/types.h>
|
|
|
|
EOF
|
|
|
|
[ -n "$SHA2_H" ] && echo "#include <$SHA2_H>">>_sha256.c
|
|
|
|
cat <<EOF >>_sha256.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
|
|
SHA256_CTX context;
|
|
|
|
SHA256_Init(&context);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# We only want to link to libmd if it exists in /lib
|
2014-06-06 01:42:21 +08:00
|
|
|
if $ALLOW_USR_LIBS; then
|
|
|
|
set -- /
|
|
|
|
else
|
|
|
|
set -- $(ls /lib/libmd.so.* 2>/dev/null)
|
|
|
|
fi
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _sha256.c -o _sha256 2>&3; then
|
2014-06-02 22:48:33 +08:00
|
|
|
SHA2=yes
|
2014-09-21 19:39:02 +08:00
|
|
|
elif [ -e "$1" ] && $XCC _sha256.c -lmd -o _sha256 2>&3; then
|
2014-06-02 22:48:33 +08:00
|
|
|
SHA2="yes (-lmd)"
|
|
|
|
SHA2_LIB=-lmd
|
|
|
|
else
|
2014-06-02 23:00:24 +08:00
|
|
|
SHA2=no
|
2014-06-02 22:48:33 +08:00
|
|
|
fi
|
|
|
|
echo "$SHA2"
|
|
|
|
rm -f _sha256.c _sha256
|
2014-06-03 00:31:37 +08:00
|
|
|
if [ "$SHA2" = no ]; then
|
|
|
|
# Did OpenBSD really change this? grrrr
|
|
|
|
printf "Testing for SHA256Init ... "
|
|
|
|
cat <<EOF >_sha256.c
|
|
|
|
#include <sys/types.h>
|
|
|
|
EOF
|
|
|
|
[ -n "$SHA2_H" ] && echo "#include <$SHA2_H>">>_sha256.c
|
|
|
|
cat <<EOF >>_sha256.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
|
|
SHA2_CTX context;
|
|
|
|
SHA256Init(&context);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# We only want to link to libmd if it exists in /lib
|
2014-06-06 01:42:21 +08:00
|
|
|
if $ALLOW_USR_LIBS; then
|
|
|
|
set -- /
|
|
|
|
else
|
|
|
|
set -- $(ls /lib/libmd.so.* 2>/dev/null)
|
|
|
|
fi
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _sha256.c -o _sha256 2>&3; then
|
2014-06-03 00:31:37 +08:00
|
|
|
SHA2=yes
|
|
|
|
SHA2_RENAMED=yes
|
2014-09-21 19:39:02 +08:00
|
|
|
elif [ -e "$1" ] && $XCC _sha256.c -lmd -o _sha256 2>&3
|
2014-06-03 00:31:37 +08:00
|
|
|
then
|
|
|
|
SHA2="yes (-lmd)"
|
|
|
|
SHA2_LIB=-lmd
|
|
|
|
SHA2_RENAMED=yes
|
|
|
|
else
|
|
|
|
SHA2=no
|
|
|
|
fi
|
|
|
|
echo "$SHA2"
|
|
|
|
rm -f _sha256.c _sha256
|
|
|
|
fi
|
2014-06-02 22:48:33 +08:00
|
|
|
fi
|
2019-08-28 23:15:04 +08:00
|
|
|
|
2017-10-05 21:13:02 +08:00
|
|
|
if [ -z "$HMAC" ]; then
|
|
|
|
HMAC_LIB=
|
|
|
|
printf "Testing for hmac ... "
|
|
|
|
cat <<EOF >_hmac.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <hmac.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)hmac(NULL, NULL, 0, NULL, 0, NULL, 0);
|
2017-10-05 21:13:02 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _hmac.c $MD5_LIB -o _hmac 2>&3; then
|
|
|
|
HMAC=yes
|
2018-03-27 14:23:31 +08:00
|
|
|
echo "#define HAVE_HMAC_H" >>$CONFIG_H
|
2017-10-05 21:13:02 +08:00
|
|
|
else
|
|
|
|
# Remove this test if NetBSD-8 ships with
|
|
|
|
# hmac in it's own header and not stdlib.h
|
|
|
|
cat <<EOF >_hmac.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return (int)hmac(NULL, NULL, 0, NULL, 0, NULL, 0);
|
2017-10-05 21:13:02 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC _hmac.c $MD5_LIB -o _hmac 2>&3; then
|
|
|
|
HMAC=yes
|
|
|
|
else
|
|
|
|
HMAC=no
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "$HMAC"
|
|
|
|
rm -f _hmac.c _hmac
|
|
|
|
fi
|
2023-09-25 16:49:00 +08:00
|
|
|
|
|
|
|
if [ "$OPENSSL" = yes ] ||
|
|
|
|
{ [ -z "$OPENSSL" ] && [ "$ALLOW_USR_LIBS" = true ] &&
|
|
|
|
[ "$SHA2" = no ] && [ "$HMAC" = no ];
|
|
|
|
}; then
|
|
|
|
printf "Testing for openssl ... "
|
|
|
|
if type "$PKG_CONFIG" >/dev/null 2>&1; then
|
|
|
|
LIBCRYPTO_CFLAGS=$("$PKG_CONFIG" --cflags libcrypto 2>&3)
|
|
|
|
LIBCRYPTO_LIBS=$("$PKG_CONFIG" --libs libcrypto 2>&3)
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat <<EOF >_openssl.c
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/crypto.h>
|
|
|
|
int main(void) {
|
|
|
|
return OPENSSL_init_crypto(0, NULL) == 1;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC $LIBCRYPTO_CFLAGS _openssl.c -o _openssl $LIBCRYPTO_LIBS 2>&3;
|
|
|
|
then
|
|
|
|
OPENSSL=yes
|
|
|
|
MD5=yes
|
|
|
|
MD5_LIB=
|
|
|
|
if [ -n "$LIBCRYPTO_CFLAGS" ]; then
|
|
|
|
echo "CFLAGS+= $LIBCRYPTO_CFLAGS" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
echo "LDADD+= $LIBCRYPTO_LIBS" >>$CONFIG_MK
|
|
|
|
echo "#define HAVE_OPENSSL" >>$CONFIG_H
|
|
|
|
else
|
|
|
|
OPENSSL=no
|
|
|
|
fi
|
|
|
|
echo "$OPENSSL"
|
|
|
|
rm -f _openssl.c _openssl
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$OPENSSL" = yes ]; then
|
|
|
|
printf "Testing for openssl/sha.h ... "
|
|
|
|
cat <<EOF >_openssl_sha.c
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
SHA256_CTX ctx;
|
|
|
|
SHA256_Init(&ctx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $XCC $LIBCRYPTO_CFLAGS _openssl_sha.c -o _openssl_sha \
|
|
|
|
$LIBCRYPTO_LIBS 2>&3; then
|
|
|
|
SHA2_H=openssl/sha.h
|
|
|
|
SHA2="yes (-lcrypto)"
|
|
|
|
else
|
|
|
|
SHA2=no
|
|
|
|
fi
|
|
|
|
SHA2_LIB=
|
|
|
|
SHA2_RENAMED=
|
|
|
|
echo "$SHA2"
|
|
|
|
rm -f _openssl_sha.c _openssl_sha
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Workaround for DragonFlyBSD import
|
|
|
|
if [ "$OS" = dragonfly ]; then
|
|
|
|
echo "#ifdef USE_PRIVATECRYPTO" >>$CONFIG_H
|
|
|
|
echo "#define HAVE_MD5_H" >>$CONFIG_H
|
|
|
|
echo "#define SHA2_H <openssl/sha.h>" >>$CONFIG_H
|
|
|
|
echo "#else" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MD5" = no ]; then
|
|
|
|
echo "#include \"compat/crypt/md5.h\"" >>$CONFIG_H
|
|
|
|
echo "MD5_SRC= compat/crypt/md5.c" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "MD5_SRC=" >>$CONFIG_MK
|
|
|
|
[ "$OPENSSL" != yes ] && echo "#define HAVE_MD5_H" >>$CONFIG_H
|
|
|
|
[ -n "$MD5_LIB" ] && echo "LDADD+= $MD5_LIB" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$OPENSSL" = yes ] && [ "$SHA2" = no ]; then
|
|
|
|
echo "#include \"compat/crypt_openssl/sha256.h\"" >>$CONFIG_H
|
|
|
|
echo "SHA256_SRC= compat/crypt_openssl/sha256.c" >>$CONFIG_MK
|
|
|
|
elif [ "$SHA2" = no ]; then
|
|
|
|
echo "#include \"compat/crypt/sha256.h\"" >>$CONFIG_H
|
|
|
|
echo "SHA256_SRC= compat/crypt/sha256.c" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "SHA256_SRC=" >>$CONFIG_MK
|
|
|
|
echo "#define SHA2_H <$SHA2_H>" >>$CONFIG_H
|
|
|
|
if [ "$SHA2_RENAMED" = yes ]; then
|
|
|
|
echo "#define SHA256_CTX SHA2_CTX" >>$CONFIG_H
|
|
|
|
echo "#define SHA256_Init SHA256Init" >>$CONFIG_H
|
|
|
|
echo "#define SHA256_Update SHA256Update" >>$CONFIG_H
|
|
|
|
echo "#define SHA256_Final SHA256Final" >>$CONFIG_H
|
|
|
|
fi
|
|
|
|
[ -n "$SHA2_LIB" ] && echo "LDADD+= $SHA2_LIB" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Workarond for DragonFlyBSD import
|
|
|
|
[ "$OS" = dragonfly ] && echo "#endif" >>$CONFIG_H
|
|
|
|
|
|
|
|
if [ "$OPENSSL" = yes ]; then
|
|
|
|
echo "#include \"compat/crypt_openssl/hmac.h\"" >>$CONFIG_H
|
|
|
|
echo "HMAC_SRC= compat/crypt_openssl/hmac.c" >>$CONFIG_MK
|
|
|
|
elif [ "$HMAC" = no ]; then
|
2018-07-24 15:44:17 +08:00
|
|
|
echo "#include \"compat/crypt/hmac.h\"" >>$CONFIG_H
|
2018-03-27 15:52:25 +08:00
|
|
|
echo "HMAC_SRC= compat/crypt/hmac.c" >>$CONFIG_MK
|
2017-10-05 21:13:02 +08:00
|
|
|
else
|
2018-03-27 14:23:31 +08:00
|
|
|
# echo "#define HAVE_HMAC_H" >>$CONFIG_H
|
2017-10-05 21:13:02 +08:00
|
|
|
echo "HMAC_SRC=" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
|
2019-08-29 05:57:11 +08:00
|
|
|
if [ -z "$AUTH" ] || [ "$AUTH" = yes ]; then
|
|
|
|
if [ "$HMAC" = no ]; then
|
|
|
|
echo "CRYPT_SRCS+= \${HMAC_SRC}" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$INET6" ] || [ "$INET6" = yes ] || \
|
|
|
|
[ -z "$AUTH" ] || [ "$AUTH" = yes ]; then
|
|
|
|
if [ "$MD5" = no ]; then
|
|
|
|
echo "CRYPT_SRCS+= \${MD5_SRC}" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
if [ "$SHA2" = no ]; then
|
|
|
|
echo "CRYPT_SRCS+= \${SHA256_SRC}" >>$CONFIG_MK
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-06-11 18:35:20 +08:00
|
|
|
if [ "$DEV" != no ] && [ "$UDEV" != no ]; then
|
2013-09-10 00:14:06 +08:00
|
|
|
printf "Checking for libudev ... "
|
2016-06-21 16:39:19 +08:00
|
|
|
if type "$PKG_CONFIG" >/dev/null 2>&1; then
|
|
|
|
LIBUDEV_CFLAGS=$("$PKG_CONFIG" --cflags libudev 2>&3)
|
|
|
|
LIBUDEV_LIBS=$("$PKG_CONFIG" --libs libudev 2>&3)
|
2014-09-22 21:57:58 +08:00
|
|
|
fi
|
2020-06-11 18:35:20 +08:00
|
|
|
if [ -n "$LIBUDEV_LIBS" ] && [ "$UDEV" = yes ]; then
|
|
|
|
echo "yes"
|
|
|
|
elif [ -n "$LIBUDEV_LIBS" ]; then
|
|
|
|
case "$OS" in
|
|
|
|
linux*) echo "yes";;
|
|
|
|
*) echo "yes (disabled)"
|
|
|
|
# FreeBSD libudev fails to return a udev device
|
|
|
|
# with udev_device_new_from_subsystem_sysname
|
|
|
|
# which breaks our test for device initialisation
|
|
|
|
LIBUDEV_CFLAGS=
|
|
|
|
LIBUDEV_LIBS=
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
2013-09-10 00:14:06 +08:00
|
|
|
fi
|
2020-06-11 18:35:20 +08:00
|
|
|
|
|
|
|
if [ "$DEV" != no ] && [ "$UDEV" != no ] && [ -n "$LIBUDEV_LIBS" ]; then
|
2013-09-13 01:08:34 +08:00
|
|
|
[ -z "$DEV" ] && DEV=yes
|
2013-09-12 23:43:20 +08:00
|
|
|
echo "DEV_PLUGINS+= udev" >>$CONFIG_MK
|
2013-09-10 00:14:06 +08:00
|
|
|
if [ -n "$LIBUDEV_CFLAGS" ]; then
|
2013-09-12 23:43:20 +08:00
|
|
|
echo "LIBUDEV_CFLAGS= $LIBUDEV_CFLAGS" >>$CONFIG_MK
|
2013-09-10 00:14:06 +08:00
|
|
|
fi
|
2013-11-30 02:41:02 +08:00
|
|
|
echo "LIBUDEV_LIBS= $LIBUDEV_LIBS" >>$CONFIG_MK
|
2013-09-10 00:14:06 +08:00
|
|
|
|
2013-09-13 00:46:41 +08:00
|
|
|
printf "Checking udev_monitor_filter_add_match_subsystem_devtype ... "
|
2013-09-10 00:14:06 +08:00
|
|
|
cat <<EOF >_udev.c
|
|
|
|
#include <libudev.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return udev_monitor_filter_add_match_subsystem_devtype(NULL, NULL, NULL);
|
2013-09-10 00:14:06 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC $LIBUDEV_CFLAGS _udev.c -o _udev $LIBUDEV_LIBS 2>&3
|
2013-09-10 00:14:06 +08:00
|
|
|
then
|
2013-09-13 00:46:41 +08:00
|
|
|
echo "yes"
|
2013-09-10 00:14:06 +08:00
|
|
|
else
|
2013-09-13 00:46:41 +08:00
|
|
|
echo "LIBUDEV_CPPFLAGS+= -DLIBUDEV_NOFILTER" >>$CONFIG_MK
|
|
|
|
echo "no"
|
2013-09-10 00:14:06 +08:00
|
|
|
fi
|
|
|
|
rm -f _udev.c _udev
|
2013-09-13 05:43:17 +08:00
|
|
|
|
|
|
|
printf "Checking udev_device_get_is_initialized ... "
|
|
|
|
cat <<EOF >_udev.c
|
|
|
|
#include <libudev.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2023-01-09 06:10:21 +08:00
|
|
|
return udev_device_get_is_initialized(NULL);
|
2013-09-13 05:43:17 +08:00
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC $LIBUDEV_CFLAGS _udev.c -o _udev $LIBUDEV_LIBS 2>&3
|
2013-09-13 05:43:17 +08:00
|
|
|
then
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "LIBUDEV_CPPFLAGS+= -DLIBUDEV_NOINIT" >>$CONFIG_MK
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f _udev.c _udev
|
2020-06-11 18:35:20 +08:00
|
|
|
elif [ "$DEV" != no ] && [ "$UDEV" != no ] && [ -n "$UDEV" ]; then
|
|
|
|
echo "udev has been explicitly requested ... aborting" >&2
|
|
|
|
exit 1
|
2013-09-10 00:14:06 +08:00
|
|
|
fi
|
|
|
|
|
2013-09-12 23:43:20 +08:00
|
|
|
if [ "$DEV" = yes ]; then
|
2014-01-25 09:35:53 +08:00
|
|
|
echo "DHCPCD_SRCS+= dev.c" >>$CONFIG_MK
|
2013-09-12 23:43:20 +08:00
|
|
|
echo "CPPFLAGS+= -DPLUGIN_DEV" >>$CONFIG_MK
|
2013-11-30 02:41:02 +08:00
|
|
|
echo "MKDIRS+= dev" >>$CONFIG_MK
|
2014-03-23 21:38:09 +08:00
|
|
|
|
2018-03-27 15:52:25 +08:00
|
|
|
# So the plugins have access to logerr
|
|
|
|
echo "LDFLAGS+= -Wl,-export-dynamic" >>$CONFIG_MK
|
|
|
|
|
2014-03-23 21:38:09 +08:00
|
|
|
printf "Testing for dlopen ... "
|
|
|
|
cat <<EOF >_dlopen.c
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
2019-11-06 00:23:02 +08:00
|
|
|
void *h = dlopen("/foo/bar", 0);
|
|
|
|
void (*s)(char *) = dlsym(h, "deadbeef");
|
|
|
|
s(dlerror());
|
|
|
|
dlclose(h);
|
2014-03-23 21:38:09 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-21 19:39:02 +08:00
|
|
|
if $XCC _dlopen.c -o _dlopen 2>&3; then
|
2014-03-23 21:38:09 +08:00
|
|
|
echo "yes"
|
2014-09-21 19:39:02 +08:00
|
|
|
elif $XCC _dlopen.c -ldl -o _dlopen 2>&3; then
|
2014-03-23 21:38:09 +08:00
|
|
|
echo "yes (-ldl)"
|
|
|
|
echo "LDADD+= -ldl" >>$CONFIG_MK
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
echo "libc for dlopen is required - aborting"
|
|
|
|
fi
|
|
|
|
rm -f _dlopen.c _dlopen
|
|
|
|
$abort && exit 1
|
2013-09-12 23:43:20 +08:00
|
|
|
fi
|
|
|
|
|
2010-09-09 22:40:27 +08:00
|
|
|
# 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' \
|
2014-01-08 19:34:51 +08:00
|
|
|
-e 's:\$:\\\\\$\$:g' \
|
2010-09-09 22:40:27 +08:00
|
|
|
)
|
|
|
|
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' \
|
2014-01-08 19:34:51 +08:00
|
|
|
-e 's:\$:\\\\\$\$:g' \
|
2010-09-09 22:40:27 +08:00
|
|
|
)
|
|
|
|
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' \
|
2014-01-08 19:34:51 +08:00
|
|
|
-e 's:\$:\\\\\$\$:g' \
|
2010-09-09 22:40:27 +08:00
|
|
|
)
|
|
|
|
echo "SERVICESTATUS= $SERVICESTATUS" >>config.mk
|
2016-03-12 18:52:41 +08:00
|
|
|
if [ -z "$STATUSARG" ]; then
|
|
|
|
case "$OS" in
|
2019-09-19 15:54:08 +08:00
|
|
|
dragonfly*|freebsd*) STATUSARG="onestatus";;
|
2016-03-12 18:52:41 +08:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
echo "STATUSARG= $STATUSARG" >>config.mk
|
2010-09-09 22:40:27 +08:00
|
|
|
|
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)"
|
|
|
|
else
|
|
|
|
echo "not found"
|
|
|
|
fi
|
2015-09-07 18:58:04 +08:00
|
|
|
printf "Checking for chronyd ... "
|
|
|
|
CHRONYD=$(_which chronyd)
|
|
|
|
if [ -n "$CHRONYD" ]; then
|
|
|
|
echo "$CHRONYD (50-ntp.conf)"
|
|
|
|
else
|
|
|
|
echo "not found"
|
|
|
|
fi
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -n "$NTPD" ] || [ -n "$CHRONYD" ]; then
|
2015-09-07 18:58:04 +08:00
|
|
|
HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf"
|
|
|
|
fi
|
|
|
|
# Warn if both are detected
|
2021-05-05 00:33:02 +08:00
|
|
|
if [ -n "$NTPD" ] && [ -n "$CHRONYD" ]; then
|
2015-09-07 18:58:04 +08:00
|
|
|
echo "NTP will default to $NTPD"
|
|
|
|
fi
|
2009-10-09 21:12:20 +08:00
|
|
|
|
2022-08-10 00:26:37 +08:00
|
|
|
printf "Checking for timesyncd ... "
|
|
|
|
TIMESYNCD=
|
|
|
|
for x in /usr/lib/systemd/systemd-timesyncd; do
|
|
|
|
if [ -x "$x" ]; then
|
|
|
|
TIMESYNCD=$x
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$TIMESYNCD" ]; then
|
|
|
|
echo "$TIMESYNCD"
|
|
|
|
HOOKS="$HOOKS${HOOKS:+ }50-timesyncd.conf"
|
|
|
|
else
|
|
|
|
echo "not found"
|
|
|
|
fi
|
|
|
|
|
2014-03-20 00:51:57 +08:00
|
|
|
printf "Checking for ypbind ... "
|
2009-10-17 05:36:51 +08:00
|
|
|
YPBIND=$(_which ypbind)
|
|
|
|
if [ -n "$YPBIND" ]; then
|
2014-03-20 00:51:57 +08:00
|
|
|
YPHOOK="50-ypbind"
|
2014-03-19 23:02:30 +08:00
|
|
|
if strings "$YPBIND" | $GREP -q yp\\.conf; then
|
2009-10-17 05:36:51 +08:00
|
|
|
YPHOOK="50-yp.conf"
|
2014-03-20 00:51:57 +08:00
|
|
|
YPOS="Linux"
|
2014-03-19 23:02:30 +08:00
|
|
|
elif strings "$YPBIND" | $GREP -q \\.ypservers; then
|
2014-03-20 00:51:57 +08:00
|
|
|
YPOS="NetBSD"
|
2014-03-19 23:02:30 +08:00
|
|
|
echo "YPDOMAIN_DIR= /var/yp" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=.ypservers" >>$CONFIG_MK
|
|
|
|
elif strings "$YPBIND" | $GREP -q /etc/yp; then
|
2014-03-20 00:51:57 +08:00
|
|
|
YPOS="OpenBSD"
|
2014-03-19 23:02:30 +08:00
|
|
|
echo "YPDOMAIN_DIR= /etc/yp" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK
|
|
|
|
else
|
2014-03-20 00:51:57 +08:00
|
|
|
YPOS="FreeBSD"
|
|
|
|
echo "YPDOMAIN_DIR=" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK
|
2009-10-17 05:36:51 +08:00
|
|
|
fi
|
2014-03-20 00:51:57 +08:00
|
|
|
echo "$YPBIND ($YPHOOK${YPOS:+ }$YPOS)"
|
2015-12-23 08:39:56 +08:00
|
|
|
EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK"
|
2009-10-09 21:12:20 +08:00
|
|
|
else
|
2009-10-17 05:36:51 +08:00
|
|
|
echo "not found"
|
2021-01-30 19:46:06 +08:00
|
|
|
YPHOOK="50-ypbind"
|
|
|
|
case "$OS" in
|
|
|
|
linux*)
|
|
|
|
YPHOOK="50-yp.conf"
|
|
|
|
YPOS="Linux"
|
|
|
|
;;
|
|
|
|
freebsd*|dragonfly*)
|
|
|
|
YPOS="FreeBSD"
|
|
|
|
echo "YPDOMAIN_DIR=" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK
|
|
|
|
;;
|
|
|
|
netbsd*)
|
|
|
|
YPOS="NetBSD"
|
|
|
|
echo "YPDOMAIN_DIR= /var/yp" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=.ypservers" >>$CONFIG_MK
|
|
|
|
;;
|
|
|
|
openbsd*)
|
|
|
|
YPOS="OpenBSD"
|
|
|
|
echo "YPDOMAIN_DIR= /etc/yp" >>$CONFIG_MK
|
|
|
|
echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
YPHOOK=
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ -n "$YPHOOK" ]; then
|
|
|
|
echo "Assuming ypbind is $YPOS"
|
|
|
|
EGHOOKS="$EGHOOKS${EGHOOKS:+ }$YPHOOK"
|
|
|
|
fi
|
2009-10-09 21:12:20 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-06-17 22:12:13 +08:00
|
|
|
find_hook()
|
|
|
|
{
|
|
|
|
for h in [0-9][0-9]"-$x" [0-9][0-9]"-$x.in" \
|
|
|
|
[0-9][0-9]"-$x.sh" [0-9][0-9]"-$x.sh.in" \
|
|
|
|
[0-9][0-9]"-$x.conf" [0-9][0-9]"-$x.conf.in"
|
|
|
|
do
|
|
|
|
[ -e "$h" ] && break
|
|
|
|
done
|
|
|
|
[ -e "$h" ] || return 1
|
|
|
|
echo "${h%%.in}"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-03-20 08:44:57 +08:00
|
|
|
if cd hooks; then
|
2014-03-20 00:51:57 +08:00
|
|
|
for x in $HOOKSCRIPTS; do
|
|
|
|
printf "Finding hook $x ... "
|
2020-06-17 22:12:13 +08:00
|
|
|
h=$(find_hook "$x")
|
|
|
|
if [ -z "$h" ]; then
|
2014-03-20 00:51:57 +08:00
|
|
|
echo "no"
|
|
|
|
else
|
|
|
|
echo "$h"
|
|
|
|
case " $HOOKS " in
|
|
|
|
*" $h "*) ;;
|
|
|
|
*) HOOKS="$HOOKS${HOOKS:+ }$h";;
|
|
|
|
esac
|
|
|
|
fi
|
2009-07-15 05:01:59 +08:00
|
|
|
done
|
2015-12-23 08:39:56 +08:00
|
|
|
for x in $EGHOOKSCRIPTS; do
|
|
|
|
printf "Finding example hook $x ... "
|
2020-06-17 22:12:13 +08:00
|
|
|
h=$(find_hook "$x")
|
|
|
|
if [ -z "$h" ]; then
|
2015-12-23 08:39:56 +08:00
|
|
|
echo "no"
|
|
|
|
else
|
|
|
|
echo "$h"
|
|
|
|
case " $EGHOOKS " in
|
|
|
|
*" $h "*) ;;
|
|
|
|
*) EGHOOKS="$EGHOOKS${EGHOOKS:+ }$h";;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
2014-03-20 00:51:57 +08:00
|
|
|
cd ..
|
|
|
|
fi
|
2009-07-15 05:01:59 +08:00
|
|
|
echo "HOOKSCRIPTS= $HOOKS" >>$CONFIG_MK
|
2015-12-23 08:39:56 +08:00
|
|
|
echo "EGHOOKSCRIPTS= $EGHOOKS" >>$CONFIG_MK
|
2009-07-15 05:01:59 +08:00
|
|
|
|
|
|
|
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"
|
2021-01-27 21:31:51 +08:00
|
|
|
echo " RUNDIR = $RUNDIR"
|
2009-07-15 05:01:59 +08:00
|
|
|
echo " MANDIR = $MANDIR"
|
2015-12-23 06:26:09 +08:00
|
|
|
echo " DATADIR = $DATADIR"
|
2009-10-09 21:12:20 +08:00
|
|
|
echo " HOOKSCRIPTS = $HOOKS"
|
2015-12-23 08:39:56 +08:00
|
|
|
echo " EGHOOKSCRIPTS = $EGHOOKS"
|
2021-01-27 21:31:51 +08:00
|
|
|
echo " STATUSARG = $STATUSARG"
|
2019-12-02 08:43:07 +08:00
|
|
|
if [ "$PRIVSEP" = yes ]; then
|
|
|
|
echo " PRIVSEPUSER = $PRIVSEP_USER"
|
|
|
|
fi
|
2009-07-15 05:01:59 +08:00
|
|
|
echo
|
2014-01-25 09:35:53 +08:00
|
|
|
|
|
|
|
rm -f dhcpcd tests/test
|