source: rtems-libbsd/dhcpcd/configure @ 1378632

55-freebsd-126-freebsd-12
Last change on this file since 1378632 was f2ed769, checked in by Sebastian Huber <sebastian.huber@…>, on 01/30/14 at 12:29:46

DHCPCD(8): Import

Import DHCPCD(8) from:

http://roy.marples.name/projects/dhcpcd/

The upstream sources can be obtained via:

fossil clone http://roy.marples.name/projects/dhcpcd

The imported version is 2014-01-29 19:46:44 [6b209507bb].

  • Property mode set to 100755
File size: 19.0 KB
Line 
1#!/bin/sh
2# Try and be like autotools configure, but without autotools
3
4# Ensure that we do not inherit these from env
5HOOKSET=false
6INET=
7INET6=
8ARC4RANDOM=
9CLOSEFROM=
10GETLINE=
11STRLCPY=
12UDEV=
13OS=
14BUILD=
15HOST=
16TARGET=
17DEBUG=
18FORK=
19STATIC=
20INCLUDEDIR=
21DEVS=
22EMBEDDED=
23
24for x do
25        opt=${x%%=*}
26        var=${x#*=}
27        case "$opt" in
28        --os|OS) OS=$var;;
29        --with-cc|CC) CC=$var;;
30        --debug) DEBUG=$var;;
31        --disable-debug) DEBUG=no;;
32        --enable-debug) DEBUG=yes;;
33        --fork) FORK=$var;;
34        --disable-fork) FORK=no;;
35        --enable-fork) FORK=yes;;
36        --disable-static) STATIC=no;;
37        --enable-static) STATIC=yes;;
38        --disable-ipv4) INET=no;;
39        --enable-ipv4) INET=yes;;
40        --disable-ipv6) INET6=no;;
41        --enable-ipv6) INET6=yes;;
42        --disable-embedded) EMBEDDED=no;;
43        --enable-embedded) EMBEDDED=no;;
44        --prefix) PREFIX=$var;;
45        --sysconfdir) SYSCONFDIR=$var;;
46        --bindir|--sbindir) SBINDIR=$var;;
47        --libexecdir) LIBEXECDIR=$var;;
48        --statedir|--localstatedir) STATEDIR=$var;;
49        --dbdir) DBDIR=$var;;
50        --rundir) RUNDIR=$var;;
51        --mandir) MANDIR=$var;;
52        --with-ccopts|CFLAGS) CFLAGS=$var;;
53        CPPFLAGS) CPPFLAGS=$var;;
54        --with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";;
55        --with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;;
56        --build) BUILD=$var;;
57        --host) HOST=$var;;
58        --target) TARGET=$var;;
59        --libdir) LIBDIR=$var;;
60        --without-arc4random) ARC4RANDOM=no;;
61        --without-closefrom) CLOSEFROM=no;;
62        --without-getline) GETLINE=no;;
63        --without-strlcpy) STRLCPY=no;;
64        --without-posix_spawn) POSIX_SPAWN=no;;
65        --without-pollts) POLLTS=no;;
66        --with-pollts) POLLTS=$var;;
67        --without-md5) MD5=no;;
68        --without-dev) DEV=no;;
69        --without-udev) UDEV=no;;
70        --serviceexists) SERVICEEXISTS=$var;;
71        --servicecmd) SERVICECMD=$var;;
72        --servicestatus) SERVICESTATUS=$var;;
73        --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
74        --datadir|--infodir) ;; # ignore autotools
75        --disable-maintainer-mode|--disable-dependency-tracking) ;;
76        -V|--version)
77                v=$(sed -ne 's/.*VERSION[[:space:]]*"\([^"]*\).*/\1/p' defs.h);
78                c=$(sed -ne 's/^.*copyright\[\] = "\([^"]*\).*/\1/p' dhcpcd.c);
79                echo "dhcpcd-$v $c";
80                exit 0;;
81        -h|--help) cat <<EOF
82\`configure' configures this package to adapt to many kinds of systems.
83
84Usage: configure [OPTION]... [VAR=VALUE]...
85
86To assign environment variables (e.g., CC, CFLAGS...), specify them as
87VAR=VALUE.  See below for descriptions of some of the useful variables.
88
89Defaults for the options are specified in brackets.
90
91Configuration:
92  -h, --help              display this help and exit
93      --help=short        display options specific to this package
94  -V, --version           display version information and exit
95
96Installation directories:
97  --prefix=PREFIX         install architecture-independent files in PREFIX [/]
98
99By default, \`make install' will install all the files in \'/sbin',
100\`/libexec', etc. You can specify
101an installation prefix other than \`/' using \`--prefix',
102for instance \`--prefix=$HOME'.
103
104For better control, use the options below.
105
106Fine tuning of the installation directories:
107  --bindir=DIR            user executables [PREFIX/bin]
108  --sbindir=DIR           system admin executables [PREFIX/sbin]
109  --libexecdir=DIR        program executables [PREFIX/libexec]
110  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
111  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
112  --libdir=DIR            object code libraries [PREFIX/lib]
113  --includedir=DIR        C header files [PREFIX/include]
114  --mandir=DIR            man documentation [PREFIX/man]
115
116System types:
117  --build=BUILD           configure for building on BUILD [guessed]
118  --host=HOST       build programs to run on HOST [BUILD]
119  --target=TARGET   configure for building compilers for TARGET [HOST]
120
121Optional Features:
122  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
123  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
124
125Some influential environment variables:
126  CC          C compiler command
127  CFLAGS      C compiler flags
128  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
129              nonstandard directory <lib dir>
130  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
131              headers in a nonstandard directory <include dir>
132  CPP         C preprocessor
133
134Use these variables to override the choices made by \`configure' or to help
135it to find libraries and programs with nonstandard names/locations.
136EOF
137exit 0
138;;
139        *) echo "$0: WARNING: unknown option $opt" >&2;;
140        esac
141done
142
143: ${SED:=sed}
144: ${GREP:=grep}
145: ${WC:=wc}
146
147: ${FORK:=yes}
148: ${SYSCONFDIR:=$PREFIX/etc}
149: ${SBINDIR:=$PREFIX/sbin}
150: ${LIBDIR:=$PREFIX/lib}
151: ${LIBEXECDIR:=$PREFIX/libexec}
152: ${STATEDIR:=/var}
153: ${DBDIR:=$STATEDIR/db}
154: ${RUNDIR:=$STATEDIR/run}
155: ${MANDIR:=${PREFIX:-/usr}/share/man}
156
157eval SYSCONFDIR="$SYSCONFDIR"
158eval LIBDIR="$LIBDIR"
159eval LIBEXECDIR="$LIBEXECDIR"
160eval STATEDIR="$STATEDIR"
161eval DBDIR="$DBDIR"
162eval RUNDIR="$RUNDIR"
163eval MANDIR="$MANDIR"
164
165_which()
166{
167        x="$(which "$1" 2>/dev/null)"
168        if [ -n "$x" ]; then
169                echo "$x"
170                return 0
171        fi
172        for x in /sbin/"$1" /usr/sbin/"$1" \
173                /usr/pkg/sbin/"$1" /usr/local/sbin/"$1"
174        do
175                if [ -e "$x" ]; then
176                        echo "$x"
177                        return 0
178                fi
179        done
180        return 1
181}
182
183CONFIG_H=config.h
184CONFIG_MK=config.mk
185
186if [ -z "$BUILD" ]; then
187        BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'`
188fi
189if [ -z "$HOST" ]; then
190        [ -z "$TARGET" ] && TARGET=$BUILD
191        HOST=$TARGET
192fi
193if [ -z "$TARGET" ]; then
194        [ -z "$HOST" ] && HOST=$BUILD
195        TARGET=$HOST
196fi
197
198# Debian and Slackware have linux in different places when dealing with
199# autoconf, so we deal with that here.
200if [ -z "$OS" ]; then
201        case "$TARGET" in
202        *-linux-*|linux-*|*-linux|linux) OS=linux;;
203        esac
204fi
205
206if [ -z "$OS" ]; then
207        # Derive OS from cpu-manufacturer-os-kernel
208        CPU=${TARGET%%-*}
209        REST=${TARGET#*-}
210        if [ "$CPU" != "$REST" ]; then
211                MANU=${REST%%-*}
212                REST=${REST#*-}
213                if [ "$MANU" != "$REST" ]; then
214                        OS=${REST%%-*}
215                        REST=${REST#*-}
216                        if [ "$OS" != "$REST" ]; then
217                                KERNEL=${REST%%-*}
218                        else
219                                # 3 tupple
220                                KERNEL=$OS
221                                OS=$MANU
222                                MANU=
223                        fi
224                else
225                        # 2 tupple
226                        OS=$MANU
227                        MANU=
228                fi
229        fi
230fi
231
232echo "Configuring dhcpcd for ... $OS"
233rm -f $CONFIG_H $CONFIG_MK
234echo "# $OS" >$CONFIG_MK
235echo "/* $OS */" >$CONFIG_H
236
237for x in SYSCONFDIR SBINDIR LIBDIR LIBEXECDIR DBDIR RUNDIR; do
238        eval v=\$$x
239        # Make files look nice for import
240        l=$((10 - ${#x}))
241        unset t
242        [ $l -gt 3 ] && t="     "
243        echo "$x=$t     $v" >>$CONFIG_MK
244        unset t
245        [ $l -gt 2 ] && t="     "
246        echo "#define $x$t      \"$v\"" >>$CONFIG_H
247done
248echo "LIBDIR=           $LIBDIR" >>$CONFIG_MK
249echo "MANDIR=           $MANDIR" >>$CONFIG_MK
250
251if [ -z "$CC" ]; then
252        printf "Looking for compiler ... "
253        for b in $TARGET- ""; do
254                for cc in gcc clang pcc icc cc; do
255                        if type $b$cc >/dev/null 2>&1; then
256                                CC=$b$cc
257                                echo "$CC"
258                                break
259                        fi
260                done
261                [ -n "$CC" ] && break
262        done
263        if [ -z "$CC" ]; then
264                echo
265                echo "no suitable compiler found - aborting" >&2
266                exit 1
267        fi
268else
269        echo "Using compiler $CC"
270fi
271$CC --version | $SED -e '1!d'
272echo "CC=               $CC" >>$CONFIG_MK
273
274# Set to blank, then append user config
275# We do this so our SED call to append to XCC remains portable
276if [ -n "$CFLAGS" ]; then
277        echo "CFLAGS=" >>$CONFIG_MK
278        echo "CFLAGS+=  $CFLAGS" >>$CONFIG_MK
279fi
280if [ -n "$CPPFLAGS" ]; then
281        echo "CPPFLAGS=" >>$CONFIG_MK
282        echo "CPPFLAGS+=        $CPPFLAGS" >>$CONFIG_MK
283fi
284if [ -n "$LDFLAGS" ]; then
285        echo "LDFLAGS=" >>$CONFIG_MK
286        echo "LDFLAGS+= $LDFLAGS" >>$CONFIG_MK
287fi
288
289if [ "$STATIC" = yes ]; then
290        echo "LDFLAGS+= -static" >>$CONFIG_MK
291fi
292for x in $INCLUDEDIR; do
293        echo "CPPFLAGS+=        -I$x" >>$CONFIG_MK
294done
295
296if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
297        echo "Enabling memory debugging"
298        echo "CPPFLAGS+=        -DDEBUG_MEMORY" >>$CONFIG_MK
299        echo "CFLAGS+=  -g" >>$CONFIG_MK
300elif [ -z "$DEBUG" -a -f .fslckout ]; then
301        printf "Found fossil checkout ... "
302        DEBUG=yes
303        echo "CFLAGS+=  -g" >>$CONFIG_MK
304else
305        DEBUG=no
306fi
307if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
308        echo "Adding debugging CFLAGS"
309        cat <<EOF >>$CONFIG_MK
310CFLAGS+=        -Wall -Wextra -Wimplicit -Wshadow -Wformat=2
311CFLAGS+=        -Wmissing-prototypes -Wmissing-declarations
312CFLAGS+=        -Wmissing-noreturn -Wmissing-format-attribute
313CFLAGS+=        -Wredundant-decls  -Wnested-externs
314CFLAGS+=        -Winline -Wwrite-strings -Wcast-align -Wcast-qual
315CFLAGS+=        -Wpointer-arith -Wstrict-overflow
316CFLAGS+=        -Wdeclaration-after-statement -Wsequence-point
317CFLAGS+=        -fno-common
318EOF
319fi
320
321if [ -z "$EMBEDDED" -o "$EMBEDDED" = yes ]; then
322        echo "dhcpcd-definitions.conf will be embedded in dhcpcd itself"
323        echo "DHCPCD_SRCS+=     dhcpcd-embedded.c" >>$CONFIG_MK
324else
325        echo "dhcpcd-definitions.conf will be installed to $LIBEXECDIR"
326        echo "CFLAGS+= -DEMBEDDED_CONFIG=\\\"$LIBEXECDIR/dhcpcd-definitions.conf\\\"" >>$CONFIG_MK
327        echo "EMBEDDEDINSTALL=  _embeddedinstall" >>$CONFIG_MK
328fi
329
330if [ -n "$FORK" -a "$FORK" != yes -a "$FORK" != true ]; then
331        echo "There is no fork"
332        echo "CPPFLAGS+=        -DTHERE_IS_NO_FORK" >>$CONFIG_MK
333fi
334
335case "$OS" in
336linux)
337        echo "CPPFLAGS+=        -D_BSD_SOURCE -D_XOPEN_SOURCE=700" >>$CONFIG_MK
338        if [ -z "$INET" -o "$INET" = yes ]; then
339                echo "DHCPCD_SRCS+=     lpf.c" >>$CONFIG_MK
340        fi
341        echo "DHCPCD_SRCS+=     if-linux.c if-linux-wireless.c" >>$CONFIG_MK
342        echo "DHCPCD_SRCS+=     platform-linux.c" >>$CONFIG_MK
343        echo "LDADD+=           -lrt -ldl" >>$CONFIG_MK
344        ;;
345kfreebsd)
346        echo "CPPFLAGS+=        -D_GNU_SOURCE" >>$CONFIG_MK
347        if [ -z "$INET" -o "$INET" = yes ]; then
348                echo "DHCPCD_SRCS+=             bpf.c" >>$CONFIG_MK
349        fi
350        echo "DHCPCD_SRCS+=     if-bsd.c platform-bsd.c" >>$CONFIG_MK
351        echo "COMPAT_SRCS+=     compat/linkaddr.c" >>$CONFIG_MK
352        echo "LDADD+=           -lrt -ldl" >>$CONFIG_MK
353        ;;
354*)
355        if [ -z "$INET" -o "$INET" = yes ]; then
356                echo "DHCPCD_SRCS+=             bpf.c" >>$CONFIG_MK
357        fi
358        echo "DHCPCD_SRCS+=     if-bsd.c platform-bsd.c" >>$CONFIG_MK
359        ;;
360esac
361
362if [ -z "$INET" -o "$INET" = yes ]; then
363        echo "CPPFLAGS+=        -DINET" >>$CONFIG_MK
364        echo "DHCPCD_SRCS+=     arp.c dhcp.c ipv4.c ipv4ll.c" >>$CONFIG_MK
365fi
366if [ -z "$INET6" -o "$INET6" = yes ]; then
367        echo "CPPFLAGS+=        -DINET6" >>$CONFIG_MK
368        echo "DHCPCD_SRCS+=     ipv6.c ipv6nd.c dhcp6.c" >>$CONFIG_MK
369fi
370
371# NetBSD: Even if we build for $PREFIX, the clueless user might move us to /
372LDELF=/libexec/ld.elf_so
373if [ -e "$LDELF" ]; then
374        echo "Linking against $LDELF"
375        echo "LDFLAGS+= -Wl,-dynamic-linker=$LDELF" >>$CONFIG_MK
376        echo "LDFLAGS+= -Wl,-rpath=${LIBDIR}" >>$CONFIG_MK
377fi
378
379# Add CPPFLAGS and CFLAGS to CC for testing features
380XCC="$CC `$SED -n -e 's/CPPFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
381XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
382
383abort=false
384# We require the libc to support non standard functions, like getifaddrs
385printf "Testing for getifaddrs ... "
386cat <<EOF >_getifaddrs.c
387#include <sys/types.h>
388#include <ifaddrs.h>
389int main(void) {
390        struct ifaddrs *ifap;
391        return getifaddrs(&ifap);
392}
393EOF
394if $XCC _getifaddrs.c -o _getifaddrs 2>/dev/null; then
395        echo "yes"
396else
397        echo "no"
398        echo "libc support for getifaddrs is required - aborting" >&2
399        abort=true
400fi
401rm -f _getifaddrs.c _getifaddrs
402$abort && exit 1
403
404if [ -z "$ARC4RANDOM" ]; then
405        printf "Testing for arc4random ... "
406        cat <<EOF >_arc4random.c
407#include <stdlib.h>
408int main(void) {
409        arc4random();
410        return 0;
411}
412EOF
413        if $XCC _arc4random.c -o _arc4random 2>/dev/null; then
414                ARC4RANDOM=yes
415        else
416                ARC4RANDOM=no
417        fi
418        echo "$ARC4RANDOM"
419        rm -f _arc4random.c _arc4random
420fi
421if [ "$ARC4RANDOM" = no ]; then
422        echo "COMPAT_SRCS+=     compat/arc4random.c" >>$CONFIG_MK
423        echo "#include \"compat/arc4random.h\"" >>$CONFIG_H
424fi
425
426if [ -z "$CLOSEFROM" ]; then
427        printf "Testing for closefrom ... "
428        cat <<EOF >_closefrom.c
429#include <unistd.h>
430int main(void) {
431        closefrom(3);
432        return 0;
433}
434EOF
435        if $XCC _closefrom.c -o _closefrom 2>/dev/null; then
436                CLOSEFROM=yes
437        else
438                CLOSEFROM=no
439        fi
440        echo "$CLOSEFROM"
441        rm -f _closefrom.c _closefrom
442fi
443if [ "$CLOSEFROM" = no ]; then
444        echo "COMPAT_SRCS+=     compat/closefrom.c" >>$CONFIG_MK
445        echo "#include \"compat/closefrom.h\"" >>$CONFIG_H
446fi
447
448if [ -z "$GETLINE" ]; then
449        printf "Testing for getline ... "
450        cat <<EOF >_getline.c
451#define _GNU_SOURCE
452#include <stdio.h>
453int main(void) {
454        char *buf = NULL;
455        size_t n = 0;
456        getline(&buf, &n, stdin);
457        return 0;
458}
459EOF
460        if $XCC _getline.c -o _getline 2>/dev/null; then
461                GETLINE=yes
462        else
463                GETLINE=no
464        fi
465        echo "$GETLINE"
466        rm -f _getline.c _getline
467fi
468if [ "$GETLINE" = no ]; then
469        echo "COMPAT_SRCS+=     compat/getline.c" >>$CONFIG_MK
470        echo "#include \"compat/getline.h\"" >>$CONFIG_H
471fi
472
473if [ -z "$STRLCPY" ]; then
474        printf "Testing for strlcpy ... "
475        cat <<EOF >_strlcpy.c
476#include <string.h>
477int main(void) {
478        const char s1[] = "foo";
479        char s2[10];
480        strlcpy(s2, s1, sizeof(s2));
481        return 0;
482}
483EOF
484        if $XCC _strlcpy.c -o _strlcpy 2>/dev/null; then
485                STRLCPY=yes
486        else
487                STRLCPY=no
488        fi
489        echo "$STRLCPY"
490        rm -f _strlcpy.c _strlcpy
491fi
492if [ "$STRLCPY" = no ]; then
493        echo "COMPAT_SRCS+=     compat/strlcpy.c" >>$CONFIG_MK
494        echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H
495fi
496
497if [ -z "$TAILQ_FOREACH_SAFE" ]; then
498        printf "Testing for TAILQ_FOREACH_SAFE ... "
499        cat <<EOF >_queue.c
500#include <sys/queue.h>
501int main(void) {
502#ifndef TAILQ_FOREACH_SAFE
503#error TAILQ_FOREACH_SAFE
504#endif
505        return 0;
506}
507EOF
508        if $XCC _queue.c -o _queue 2>/dev/null; then
509                TAILQ_FOREACH_SAFE=yes
510        else
511                TAILQ_FOREACH_SAFE=no
512        fi
513        echo "$TAILQ_FOREACH_SAFE"
514        rm -f _queue.c _queue
515fi
516if [ "$TAILQ_FOREACH_SAFE" = no ]; then
517        cat <<EOF >>$CONFIG_H
518#define TAILQ_FOREACH_SAFE(var, head, field, next)                      \\
519        for ((var) = TAILQ_FIRST((head));                               \\
520            (var) && ((next) = TAILQ_NEXT((var), field), 1);            \\
521            (var) = (next))
522#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev)    \\
523        for ((var) = TAILQ_LAST((head), headname);                      \\
524            (var) && ((prev) = TAILQ_PREV((var), headname, field), 1);  \\
525            (var) = (prev))
526EOF
527fi
528
529if [ -z "$POSIX_SPAWN" ]; then
530        printf "Testing for posix_spawn ... "
531        cat <<EOF >_posix_spawn.c
532#include <spawn.h>
533#include <stdlib.h>
534int main(void) {
535        posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL);
536        return 0;
537}
538EOF
539        if $XCC _posix_spawn.c -o _posix_spawn 2>/dev/null; then
540                POSIX_SPAWN=yes
541        else
542                POSIX_SPAWN=no
543        fi
544        echo "$POSIX_SPAWN"
545        rm -f _posix_spawn.c _posix_spawn
546fi
547if [ "$POSIX_SPAWN" = no ]; then
548        echo "COMPAT_SRCS+=     compat/posix_spawn.c" >>$CONFIG_MK
549        echo "#include \"compat/posix_spawn.h\"" >>$CONFIG_H
550else
551        echo "#include <spawn.h>" >>$CONFIG_H
552fi
553
554if [ -z "$POLLTS" ]; then
555        printf "Testing for pollts ... "
556        cat <<EOF >_pollts.c
557#include <poll.h>
558#include <signal.h>
559#include <stdlib.h>
560#include <time.h>
561int main(void) {
562        pollts(NULL, 0, NULL, NULL);
563        return 0;
564}
565EOF
566        if $XCC _pollts.c -o _pollts 2>/dev/null; then
567                POLLTS=yes
568        else
569                POLLTS=no
570        fi
571        echo "$POLLTS"
572        rm -f _pollts.c _pollts
573fi
574if [ "$POLLTS" = no ]; then
575        printf "Testing for ppoll ... "
576        cat <<EOF >_ppoll.c
577#include <poll.h>
578#include <stdlib.h>
579int main(void) {
580        ppoll(NULL, 0, NULL, NULL);
581        return 0;
582}
583EOF
584        if $XCC _ppoll.c -o _ppoll 2>/dev/null; then
585                POLLTS=ppoll
586                echo "yes"
587        else
588                POLLTS=no
589                echo "no"
590        fi
591        rm -f _ppoll.c _ppoll
592fi
593if [ "$POLLTS" = no ]; then
594        printf "Testing for pselect ... "
595        cat <<EOF >_pselect.c
596#include <sys/select.h>
597#include <stdlib.h>
598int main(void) {
599        pselect(0, NULL, NULL, NULL, NULL, NULL);
600        return 0;
601}
602EOF
603        if $XCC _pselect.c -o _pselect 2>/dev/null; then
604                POLLTS=pselect
605                echo "yes"
606        else
607                POLLTS=no
608                echo "no"
609        fi
610        rm -f _pselect.c _pselect
611fi
612case "$POLLTS" in
613yes)
614        ;;
615ppoll)
616        echo "#define pollts ppoll" >>$CONFIG_H
617        ;;
618pselect)
619        echo "COMPAT_SRCS+=     compat/pselect.c" >>$CONFIG_MK
620        echo "#include \"compat/pollts.h\"" >>$CONFIG_H
621        ;;
622*)
623        echo "COMPAT_SRCS+=     compat/pollts.c" >>$CONFIG_MK
624        echo "#include \"compat/pollts.h\"" >>$CONFIG_H
625        ;;
626esac
627
628if [ -z "$MD5" ]; then
629        printf "Testing for MD5Init ... "
630        cat <<EOF >_md5.c
631#include <md5.h>
632#include <stdlib.h>
633int main(void) {
634        MD5_CTX context;
635        MD5Init(&context);
636        return 0;
637}
638EOF
639        if $XCC _md5.c -o _md5 2>/dev/null; then
640                MD5=yes
641        else
642                MD5=no
643        fi
644        echo "$MD5"
645        rm -f _md5.c _md5
646fi
647if [ "$MD5" = no ]; then
648        echo "MD5_SRC=  md5.c" >>$CONFIG_MK
649else
650        echo "MD5_SRC=" >>$CONFIG_MK
651        echo "#define HAVE_MD5H" >>$CONFIG_H
652fi
653
654if [ "$DEV" != no -a "$UDEV" != no ]; then
655        printf "Checking for libudev ... "
656        LIBUDEV_CFLAGS=$(pkg-config --cflags libudev 2>/dev/null)
657        LIBUDEV_LIBS=$(pkg-config --libs libudev 2>/dev/null)
658fi
659if [ "$DEV" != no -a "$UDEV" != no -a -n "$LIBUDEV_LIBS" ]; then
660        echo "yes"
661        [ -z "$DEV" ] && DEV=yes
662        echo "DEV_PLUGINS+=     udev" >>$CONFIG_MK
663        if [ -n "$LIBUDEV_CFLAGS" ]; then
664                echo "LIBUDEV_CFLAGS=           $LIBUDEV_CFLAGS" >>$CONFIG_MK
665        fi
666        echo "LIBUDEV_LIBS=     $LIBUDEV_LIBS" >>$CONFIG_MK
667
668        printf "Checking udev_monitor_filter_add_match_subsystem_devtype ... "
669        cat <<EOF >_udev.c
670#include <libudev.h>
671#include <stdlib.h>
672int main(void) {
673        udev_monitor_filter_add_match_subsystem_devtype(NULL, NULL, NULL);
674        return 0;
675}
676EOF
677        if $XCC $LIBUDEV_CFLAGS _udev.c -o _udev $LIBUDEV_LIBS 2>/dev/null
678        then
679                echo "yes"
680        else
681                echo "LIBUDEV_CPPFLAGS+=        -DLIBUDEV_NOFILTER" >>$CONFIG_MK
682                echo "no"
683        fi
684        rm -f _udev.c _udev
685
686        printf "Checking udev_device_get_is_initialized ... "
687        cat <<EOF >_udev.c
688#include <libudev.h>
689#include <stdlib.h>
690int main(void) {
691        udev_device_get_is_initialized(NULL);
692        return 0;
693}
694EOF
695        if $XCC $LIBUDEV_CFLAGS _udev.c -o _udev $LIBUDEV_LIBS 2>/dev/null
696        then
697                echo "yes"
698        else
699                echo "LIBUDEV_CPPFLAGS+=        -DLIBUDEV_NOINIT" >>$CONFIG_MK
700                echo "no"
701        fi
702        rm -f _udev.c _udev
703elif [ "$DEV" != no -a "$UDEV" != no ]; then
704        echo "no"
705fi
706
707if [ "$DEV" = yes ]; then
708        echo "DHCPCD_SRCS+=     dev.c" >>$CONFIG_MK
709        echo "CPPFLAGS+=        -DPLUGIN_DEV" >>$CONFIG_MK
710        echo "MKDIRS+=  dev" >>$CONFIG_MK
711fi
712
713# Transform for a make file
714SERVICEEXISTS=$(echo "$SERVICEEXISTS" | $SED \
715        -e 's:\\:\\\\:g' \
716        -e 's:\&:\\\&:g' \
717        -e 's:\$:\\\\\$\$:g' \
718)
719echo "SERVICEEXISTS=    $SERVICEEXISTS" >>config.mk
720SERVICECMD=$(echo "$SERVICECMD" | $SED \
721        -e 's:\\:\\\\:g' \
722        -e 's:\&:\\\&:g' \
723        -e 's:\$:\\\\\$\$:g' \
724)
725echo "SERVICECMD=       $SERVICECMD" >>config.mk
726SERVICESTATUS=$(echo "$SERVICESTATUS" | $SED \
727        -e 's:\\:\\\\:g' \
728        -e 's:\&:\\\&:g' \
729        -e 's:\$:\\\\\$\$:g' \
730)
731echo "SERVICESTATUS=    $SERVICESTATUS" >>config.mk
732
733HOOKS=
734if ! $HOOKSET; then
735        printf "Checking for ntpd ... "
736        NTPD=$(_which ntpd)
737        if [ -n "$NTPD" ]; then
738                echo "$NTPD (50-ntp.conf)"
739                HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf"
740        else
741                echo "not found"
742        fi
743
744        printf "Checking for ypind ... "
745        YPBIND=$(_which ypbind)
746        if [ -n "$YPBIND" ]; then
747                if strings "$YPBIND" | $GREP -q yp.conf; then
748                        YPHOOK="50-yp.conf"
749                else
750                        YPHOOK="50-ypbind"
751                fi
752                echo "$YPBIND ($YPHOOK)"
753                HOOKS="$HOOKS${HOOKS:+ }$YPHOOK"
754        else
755                echo "not found"
756        fi
757fi
758
759cd dhcpcd-hooks
760for x in $HOOKSCRIPTS; do
761        printf "Finding hook $x ... "
762        for h in [0-9][0-9]"-$x" [0-9][0-9]"-$x.sh" [0-9][0-9]"-$x.conf"; do
763                [ -e "$h" ] && break
764        done
765        if [ ! -e "$h" ]; then
766                echo "no"
767        else
768                echo "$h"
769                case " $HOOKS " in
770                *" $h "*)       ;;
771                *)              HOOKS="$HOOKS${HOOKS:+ }$h";;
772                esac
773        fi
774done
775cd ..
776echo "HOOKSCRIPTS=      $HOOKS" >>$CONFIG_MK
777
778# Define any RCSIDs for import into 3rd party systems
779case "$OS" in
780netbsd)
781        echo "IMPORT_RCSID=     \#include <sys/cdefs.h>\\n" >>$CONFIG_MK
782        echo "IMPORT_RCSID+=    __RCSID(\\\"\\\$\$NetBSD: \\\$\$\\\");" >> \
783            $CONFIG_MK
784        echo "IMPORT_HID+=      /* \\\$\$NetBSD: \\\$\$ */" >> \
785            $CONFIG_MK
786        echo "IMPORT_MANID=     .\\\\\\\\\\\"     \\\$\$NetBSD: \$\$ " >> \
787            $CONFIG_MK
788        echo "IMPORT_SHID=      \# \\\$\$NetBSD: \$\$ " >>$CONFIG_MK
789        ;;
790esac
791
792echo
793echo "   SYSCONFDIR =           $SYSCONFDIR"
794echo "   SBINDIR =              $SBINDIR"
795echo "   LIBDIR =               $LIBDIR"
796echo "   LIBEXECDIR =           $LIBEXECDIR"
797echo "   DBDIR =                $DBDIR"
798echo "   RUNDIR =               $RUNDIR"
799echo "   MANDIR =               $MANDIR"
800echo "   HOOKSCRIPTS =  $HOOKS"
801echo
802
803rm -f dhcpcd tests/test
Note: See TracBrowser for help on using the repository browser.