Add --with-qt and --without-qk options.
[dhcpcd-ui] / configure
index 6be180d62798ac25087a8c30e78ebd790c7dffcf..8da4f077ed7ae320f9a21c7057e742566d5afd3e 100755 (executable)
--- a/configure
+++ b/configure
@@ -37,6 +37,8 @@ for x; do
        --icondir) ICONDIR=$var;;
        --with-gtk|--with-gtk+) WITH_GTK=${var:-yes};;
        --without-gtk|--without-gtk+) WITH_GTK=no;;
+       --with-qt) WITH_QT=${var:-yes};;
+       --without-qt) WITH_QT=no;;
        --enable-notification) NOTIFY=yes;;
        --disable-notification) NOTIFY=no;;
        --help) echo "See the README file for available options"; exit 0;;
@@ -170,8 +172,18 @@ if ! type "$CC" >/dev/null 2>&1; then
 fi
 
 echo "Using compiler .. $CC"
-if ! type "$CC" >/dev/null 2>&1; then
-       echo "$CC is not an executable"
+cat <<EOF >_test.c
+int main(void) {
+       return 0;
+}
+EOF
+_CC=false
+if $CC _test.c -o _test >/dev/null 2>&1; then
+       [ -x _test ] && _CC=true
+fi
+rm -f _test.c _test
+if ! $_CC; then
+       echo "$CC does not create executables"
        exit 1
 fi
 [ "$CC" != cc ] && echo "CC=   $CC" >>$CONFIG_MK
@@ -218,12 +230,41 @@ EOF
        mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers
        *)              echo "CFLAGS+=  -Wredundant-decls" >>$CONFIG_MK;;
        esac
+else
+       # Disable assertations
+       echo "CFLAGS+=  -DNDEBUG" >>$CONFIG_MK
 fi
 
 # Add CPPFLAGS and CFLAGS to CC for testing features
 XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
 XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
 
+if [ -z "$GETTEXT" ]; then
+       printf "Testing for gettext ... "
+       cat <<EOF >_gettext.c
+#include <libintl.h>
+int main(void) {
+       gettext("foo");
+       return 0;
+}
+EOF
+       LIB_INTL=
+       if $XCC _gettext.c -o _gettext 2>/dev/null; then
+               GETTEXT=yes
+       elif $XCC _gettext.c -o _gettext -lintl 2>/dev/null; then
+               GETTEXT="yes (-lintl)"
+               LIB_INTL=-lintl
+       else
+               GETTEXT=no
+       fi
+       echo "$GETTEXT"
+       rm -f _gettext.c _gettext
+fi
+if [ "$GETTEXT" != no ]; then
+       echo "#define HAS_GETTEXT" >>$CONFIG_H
+       echo "LIB_INTL= $LIB_INTL" >>$CONFIG_MK
+fi
+
 if [ -z "$STRLCPY" ]; then
        printf "Testing for strlcpy ... "
        cat <<EOF >_strlcpy.c
@@ -244,8 +285,9 @@ EOF
        rm -f _strlcpy.c _strlcpy
 fi
 if [ "$STRLCPY" = no ]; then
-       echo "#define strlcpy(dst, src, n) snprintf(dst, n, \"%s\", src)" \
-       >>$CONFIG_H
+       echo "#define strlcpy(dst, src, n) " \
+           "((size_t)snprintf(dst, n, \"%s\", src))" \
+           >>$CONFIG_H
 fi
 
 if [ -z "$LIBDIR" ]; then
@@ -273,22 +315,14 @@ 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
-echo "DBus CFLAGS=$DBUS_CFLAGS"
-echo "DBus LIBS=$DBUS_LIBS"
-echo "DBUS_CFLAGS=     $DBUS_CFLAGS" >>$CONFIG_MK
-echo "DBUS_LIBS=       $DBUS_LIBS" >>$CONFIG_MK
+echo "LDADD+=          -Wl,--as-needed" >>$CONFIG_MK
 
 UI=
 if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
-       if pkg-config --cflags gtk+-3.0 >/dev/null 2>&1; then
-               WITH_GTK="gtk+-3.0"
-       elif pkg-config --cflags gtk+-2.0 >/dev/null 2>&1; then
+       if pkg-config --cflags gtk+-2.0 >/dev/null 2>&1; then
                WITH_GTK="gtk+-2.0"
+       elif pkg-config --cflags gtk+-3.0 >/dev/null 2>&1; then
+               WITH_GTK="gtk+-3.0"
        fi
 elif [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
        if ! pkg-config --cflags $WITH_GTK >/dev/null; then
@@ -296,9 +330,9 @@ elif [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
                exit 1
        fi
 fi
-
-if [ -n "$WITH_GTK" ]; then
-       PKG="dbus-1 $WITH_GTK"
+       
+if [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
+       PKG="$WITH_GTK"
        if [ "$NOTIFY" = yes ]; then
                PKG="$PKG${PKG:+ }libnotify"
                echo "NOTIFY=           -DNOTIFY" >>$CONFIG_MK
@@ -314,6 +348,22 @@ if [ -n "$WITH_GTK" ]; then
        UI="$UI${UI:+ }dhcpcd-gtk"
 fi
 
+DHCPCD_QT=false
+if [ "WITH_QT" = yes -o -z "$WITH_QT" ]; then
+       if type qmake >/dev/null 2>&1; then
+               UI="$UI${UI+ }dhcpcd-qt"
+               DHCPCD_QT=true
+       fi
+elif [ -n "$WITH_QT" -a "$WITH_QT" != no ]; then
+       if type qmake >/dev/null 2>&1; then
+               UI="$UI${UI+ }dhcpcd-qt"
+               DHCPCD_QT=true
+       else
+               echo "$0: no suitable QT library has been found" >&2
+               exit 1
+       fi
+fi
+
 if [ -z "$UI" ]; then
        echo "$0: no UI is available, not building." >&2
        exit 1
@@ -330,3 +380,10 @@ echo "   UI =                      $UI"
 echo
 
 echo "MKDIR=           \${TOPDIR}/mk" >>$CONFIG_MK
+
+if $DHCPCD_QT; then
+       if ! (cd src/dhcpcd-qt; qmake dhcpcd-qt.pro); then
+               echo "$0: failed to configure dhcpcd-qt" >&2
+               exit 1
+       fi
+fi