summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-04-01 21:14:28 +0000
committerRoy Marples <roy@marples.name>2016-04-01 21:14:28 +0000
commit61f6ce0e11946bd7a2f485f7f1d24bc122b7ba9f (patch)
tree4711d9c040d901e8a18fc314b0f58c639a713a0a /configure
parenta6162a7534b0f5f644da5d9f7b91e39207c7902b (diff)
downloaddhcpcd-61f6ce0e11946bd7a2f485f7f1d24bc122b7ba9f.tar.xz
Remove pidfile handling from dhcpcd and use pidfile_lock(3) from libutil
instead. pidfile_lock(3) should be found in NetBSD 8. Provide a compat shim, from an earlier implementation I wrote still based around flock if not available on host OS.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure38
1 files changed, 38 insertions, 0 deletions
diff --git a/configure b/configure
index d046ac60..215a9c5a 100755
--- a/configure
+++ b/configure
@@ -67,6 +67,7 @@ for x do
--without-closefrom) CLOSEFROM=no;;
--without-getline) GETLINE=no;;
--without-strlcpy) STRLCPY=no;;
+ --without-pidfile_lock) PIDFILE_LOCK=no;;
--with-printf_m) HAVE_PRINTF_M=yes;;
--without-printf_m) HAVE_PRINTF_M=no;;
--without-posix_spawn) POSIX_SPAWN=no;;
@@ -687,6 +688,43 @@ if [ "$STRLCPY" = no ]; then
echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H
fi
+if [ -z "$PIDFILE_LOCK" ]; then
+ printf "Testing for pidfile_lock ... "
+ cat <<EOF >_pidfile.c
+#include <stdlib.h>
+#include <util.h>
+int main(void) {
+ pidfile_lock(NULL);
+ return 0;
+}
+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
+ echo "#include \"compat/pidfile.h\"" >>$CONFIG_H
+else
+ echo "#define HAVE_UTIL_H" >>$CONFIG_H
+ if [ -n "$LIBUTIL" ]; then
+ echo "LDADD+= $LIBUTIL" >>$CONFIG_MK
+ fi
+fi
+
if [ -z "$STRTOI" ]; then
printf "Testing for strtoi ... "
cat <<EOF >_strtoi.c