Allow ROUTERADVERT to be an up reason.
[dhcpcd-ui] / configure
index 315e68a3c35510a3fc16f7ec6c3d8daa9695fdf2..ba6a7b1eb2595f755696c4afa933517f46be168b 100755 (executable)
--- a/configure
+++ b/configure
@@ -6,17 +6,19 @@ DEBUG=
 LIBDHCPCD=no
 WITH_GTK=
 NOTIFY=yes
 LIBDHCPCD=no
 WITH_GTK=
 NOTIFY=yes
+INCLUDEDIR=
 
 for x; do
        opt=${x%%=*}
        var=${x#*=}
 
 for x; do
        opt=${x%%=*}
        var=${x#*=}
+       [ "$var" = "$opt" ] && var=
        case "$opt" in
        --os|OS) OS=$var;;
        --with-cc|CC) CC=$var;;
        --debug) DEBUG=$var;;
        --disable-debug) DEBUG=no;;
        --enable-debug) DEBUG=yes;;
        case "$opt" in
        --os|OS) OS=$var;;
        --with-cc|CC) CC=$var;;
        --debug) DEBUG=$var;;
        --disable-debug) DEBUG=no;;
        --enable-debug) DEBUG=yes;;
-       --prefix) PREFIX=$var;;
+       --prefix) prefix=$var;;
        --sysconfdir) SYSCONFDIR=$var;;
        --bindir) BINDIR=$var;;
        --libexecdir) LIBEXECDIR=$var;;
        --sysconfdir) SYSCONFDIR=$var;;
        --bindir) BINDIR=$var;;
        --libexecdir) LIBEXECDIR=$var;;
@@ -29,7 +31,9 @@ for x; do
        --host) HOST=$var;;
        --target) TARGET=$var;;
        --libdir) LIBDIR=$var;;
        --host) HOST=$var;;
        --target) TARGET=$var;;
        --libdir) LIBDIR=$var;;
+       --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
        --datadir|--infodir) ;; # ignore autotools
        --datadir|--infodir) ;; # ignore autotools
+       --disable-maintainer-mode|--disable-dependency-tracking) ;;
        --icondir) ICONDIR=$var;;
        --with-gtk|--with-gtk+) WITH_GTK=${var:-yes};;
        --without-gtk|--without-gtk+) WITH_GTK=no;;
        --icondir) ICONDIR=$var;;
        --with-gtk|--with-gtk+) WITH_GTK=${var:-yes};;
        --without-gtk|--without-gtk+) WITH_GTK=no;;
@@ -43,7 +47,7 @@ done
 : ${INSTALL:=install}
 : ${SED:=sed}
 
 : ${INSTALL:=install}
 : ${SED:=sed}
 
-: ${PREFIX:=/usr/local}
+: ${PREFIX:=${prefix:=/usr/local}}
 : ${SYSCONFDIR:=$PREFIX/etc}
 : ${BINDIR:=$PREFIX/bin}
 : ${LIBEXECDIR:=$PREFIX/libexec}
 : ${SYSCONFDIR:=$PREFIX/etc}
 : ${BINDIR:=$PREFIX/bin}
 : ${LIBEXECDIR:=$PREFIX/libexec}
@@ -52,6 +56,14 @@ done
 
 : ${ICONDIR:=$PREFIX/share/dhcpcd/icons}
 
 
 : ${ICONDIR:=$PREFIX/share/dhcpcd/icons}
 
+eval SYSCONFDIR="$SYSCONFDIR"
+eval LIBDIR="$LIBDIR"
+eval LIBEXECDIR="$LIBEXECDIR"
+eval STATEDIR="$STATEDIR"
+eval DBDIR="$DBDIR"
+eval RUNDIR="$RUNDIR"
+eval MANDIR="$MANDIR"
+
 _which()
 {
        x="$(which "$1" 2>/dev/null)"
 _which()
 {
        x="$(which "$1" 2>/dev/null)"
@@ -85,23 +97,49 @@ if [ -z "$TARGET" ]; then
        TARGET=$HOST
 fi
 
        TARGET=$HOST
 fi
 
+# Debian and Slackware have linux in different places when dealing with
+# autoconf, so we deal with that here.
+if [ -z "$OS" ]; then
+       case "$TARGET" in
+       *-linux-*|linux-*|*-linux|linux) OS=linux;;
+       esac
+fi
+
 if [ -z "$OS" ]; then
        # Derive OS from cpu-manufacturer-os-kernel
        CPU=${TARGET%%-*}
        REST=${TARGET#*-}
 if [ -z "$OS" ]; then
        # Derive OS from cpu-manufacturer-os-kernel
        CPU=${TARGET%%-*}
        REST=${TARGET#*-}
-       MANU=${REST%%-*}
-       REST=${REST#*-}
-       OS=${REST%%-*}
-       REST=${REST#*-}
-       KERNEL=${REST%%-*}
+       if [ "$CPU" != "$REST" ]; then
+               MANU=${REST%%-*}
+               REST=${REST#*-}
+               if [ "$MANU" != "$REST" ]; then
+                       OS=${REST%%-*}
+                       REST=${REST#*-}
+                       if [ "$OS" != "$REST" ]; then
+                               KERNEL=${REST%%-*}
+                       else
+                               # 3 tupple
+                               KERNEL=$OS
+                               OS=$MANU
+                               MANU=
+                       fi
+               else
+                       # 2 tupple
+                       OS=$MANU
+                       MANU=
+               fi
+       fi
 fi
 
 fi
 
-echo "Configuring dhcpcd-dbus for ... $OS"
+echo "Configuring dhcpcd-ui for ... $OS"
 rm -f $CONFIG_H $CONFIG_MK
 echo "# $OS" >$CONFIG_MK
 echo "/* $OS */" >$CONFIG_H
 
 rm -f $CONFIG_H $CONFIG_MK
 echo "# $OS" >$CONFIG_MK
 echo "/* $OS */" >$CONFIG_H
 
-for x in PREFIX SYSCONFDIR BINDIRi ICONDIR; do
+VERSION=$($SED -ne 's/VERSION= //p' Makefile)
+echo "#define VERSION \"$VERSION\"" >>$CONFIG_H
+
+for x in PREFIX SYSCONFDIR BINDIR ICONDIR; do
        eval v=\$$x
        # Make files look nice for import
        l=$((10 - ${#x}))
        eval v=\$$x
        # Make files look nice for import
        l=$((10 - ${#x}))
@@ -112,6 +150,7 @@ for x in PREFIX SYSCONFDIR BINDIRi ICONDIR; do
        [ $l -gt 2 ] && t="     "
        echo "#define $x$t      \"$v\"" >>$CONFIG_H
 done
        [ $l -gt 2 ] && t="     "
        echo "#define $x$t      \"$v\"" >>$CONFIG_H
 done
+echo "MANDIR=          ${MANDIR}" >>$CONFIG_MK
 
 if [ -z "$CC" ]; then
        printf "Looking for compiler ... "
 
 if [ -z "$CC" ]; then
        printf "Looking for compiler ... "
@@ -135,13 +174,16 @@ else
 fi
 echo "CC=              $CC" >>$CONFIG_MK
 
 fi
 echo "CC=              $CC" >>$CONFIG_MK
 
-if [ -z "$CFLAGS"]; then
+if [ -z "$CFLAGS" ]; then
        CFLAGS="-O2"
 fi
 echo "CFLAGS=          $CFLAGS" >>$CONFIG_MK
 if [ -n "$CPPLAGS" ]; then
        echo "CPPLAGS=          $CPPLAGS" >>$CONFIG_MK
 fi
        CFLAGS="-O2"
 fi
 echo "CFLAGS=          $CFLAGS" >>$CONFIG_MK
 if [ -n "$CPPLAGS" ]; then
        echo "CPPLAGS=          $CPPLAGS" >>$CONFIG_MK
 fi
+for x in $INCLUDEDIR; do
+       echo "CPPFLAGS+=        -I$x" >>$CONFIG_MK
+done
 
 if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
        echo "Enabling memory debugging"
 
 if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
        echo "Enabling memory debugging"
@@ -218,6 +260,10 @@ else
 fi
 echo "LIB_DHCPCD=      $x" >>$CONFIG_MK
 
 fi
 echo "LIB_DHCPCD=      $x" >>$CONFIG_MK
 
+# Due to our use of pkg-config, pass --as-needed to ld so we only link
+# what we actually need.
+echo "LDADD+=  -Wl,--as-needed" >>$CONFIG_MK
+
 # Get DBus CFLAGS
 DBUS_CFLAGS=$(pkg-config --cflags dbus-1) || exit 1
 DBUS_LIBS=$(pkg-config --libs dbus-1) || exit 1
 # Get DBus CFLAGS
 DBUS_CFLAGS=$(pkg-config --cflags dbus-1) || exit 1
 DBUS_LIBS=$(pkg-config --libs dbus-1) || exit 1
@@ -228,7 +274,7 @@ echo "DBUS_LIBS=    $DBUS_LIBS" >>$CONFIG_MK
 
 UI=
 if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
 
 UI=
 if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
-       PKG="gtk+-2.0"
+       PKG="dbus-1 gtk+-2.0"
        if [ "$NOTIFY" = yes ]; then
                PKG="$PKG${PKG:+ }libnotify"
                echo "NOTIFY=           -DNOTIFY" >>$CONFIG_MK
        if [ "$NOTIFY" = yes ]; then
                PKG="$PKG${PKG:+ }libnotify"
                echo "NOTIFY=           -DNOTIFY" >>$CONFIG_MK
@@ -254,6 +300,8 @@ echo
 echo "   SYSCONFDIR =          $SYSCONFDIR"
 echo "   BINDIR =              $BINDIR"
 echo "   LIBDIR =              $LIBDIR"
 echo "   SYSCONFDIR =          $SYSCONFDIR"
 echo "   BINDIR =              $BINDIR"
 echo "   LIBDIR =              $LIBDIR"
+echo "   ICONDIR =             $ICONDIR"
+echo "   MANDIR =              $MANDIR"
 echo "   UI =                  $UI"
 echo
 
 echo "   UI =                  $UI"
 echo