Improve qt diagnostics.
[dhcpcd-ui] / configure
index 73a761f4b4ba582c629ea27443aad3b404368ad2..cc3a561bef05119c2f666292ae8e2ee04037d29f 100755 (executable)
--- a/configure
+++ b/configure
@@ -10,7 +10,8 @@ LIBDHCPCD=no
 HOST=
 HOSTCC=
 BUILD=
-WITH_TOOLS=yes
+WITH_DHCPCD_ONLINE=yes
+WITH_CURSES=
 WITH_GTK=
 WITH_QT=
 WITH_ICONS=
@@ -44,12 +45,15 @@ for x; do
        --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
        --datadir|--infodir) ;; # ignore autotools
        --disable-maintainer-mode|--disable-dependency-tracking) ;;
-       --with-tools) WITH_TOOLS=${var:-yes};;
-       --without-tools) WITH_TOOLS=no;;
+       --with-dhcpcd-online) WITH_DHCPCD_ONLINE=${var:-yes};;
+       --without-dhcpcd-online) WITH_DHCPCD_ONLINE=no;;
+       --with-curses) WITH_CURSES=${var:-yes};;
+       --without-curses) WITH_CURSES=${var:-no};;
        --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;;
+       QTDIR) QTDIR=$var;;
        --with-icons) WITH_ICONS=${var:-yes};;
        --without-icons) WITH_ICONS=no;;
        --enable-notification) NOTIFY=yes;;
@@ -134,7 +138,7 @@ if [ -z "$OS" ]; then
        esac
 fi
 
-echo "Configuring dhcpcd for ... $OS"
+echo "Configuring dhcpcd-ui for ... $OS"
 rm -f $CONFIG_H $CONFIG_MK
 echo "# $OS" >$CONFIG_MK
 echo "/* $OS */" >$CONFIG_H
@@ -215,6 +219,7 @@ if [ -n "$LDFLAGS" ]; then
        echo "LDFLAGS=" >>$CONFIG_MK
        echo "LDFLAGS+= $LDFLAGS" >>$CONFIG_MK
 fi
+QMAKE_CONFIG=
 
 for x in $INCLUDEDIR; do
        echo "CPPFLAGS+=        -I$x" >>$CONFIG_MK
@@ -229,14 +234,15 @@ fi
 if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
        echo "Adding debugging CFLAGS"
        cat <<EOF >>$CONFIG_MK
-CFLAGS+=       -g -Wall -Wextra -Wshadow -Wformat=2
+CFLAGS+=       -g -Wall -Wextra
 CFLAGS+=       -Wmissing-prototypes -Wmissing-declarations
-CFLAGS+=       -Wmissing-noreturn -Wmissing-format-attribute
-CFLAGS+=       -Wnested-externs
-CFLAGS+=       -Winline -Wwrite-strings -Wcast-align -Wcast-qual
-CFLAGS+=       -Wpointer-arith -Wstrict-overflow
-CFLAGS+=       -Wdeclaration-after-statement
+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+=       -Wconversion
+CFLAGS+=       -Wformat=2
+CFLAGS+=       -Wpointer-sign -Wmissing-noreturn
 EOF
        case "$OS" in
        mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers
@@ -266,7 +272,7 @@ EOF
        elif $XCC _gettext.c -o _gettext -lintl 2>&3; then
                GETTEXT="yes (-lintl)"
                LIB_INTL=-lintl
-               QMAKE_CONFIG="CONFIG+=has_libintl"
+               QMAKE_CONFIG="$QMAKE_CONFIG CONFIG+=has_libintl"
        else
                GETTEXT=no
        fi
@@ -303,66 +309,6 @@ if [ "$STRLCPY" = no ]; then
            >>$CONFIG_H
 fi
 
-if [ -z "$VIS" ]; then
-       printf "Testing for vis ... "
-       cat <<EOF >_vis.c
-#include <vis.h>
-
-int main(void) {
-       char s[10];
-       xxvis(s, 0, 0, 0);
-       return 0;
-}
-EOF
-       if $XCC _vis.c -o _vis 2>&3; then
-               VIS=yes
-       else
-               VIS=no
-       fi
-       echo "$VIS"
-       rm -f _vis.c _vis
-fi
-if [ "$VIS" = no ]; then
-       echo "VIS_SRC=          vis.c" >>$CONFIG_MK
-       echo "#define vis       dhcpcd_vis" >>$CONFIG_H
-else
-       echo "#define HAVE_VIS_H" >>$CONFIG_H
-fi
-
-if [ -z "$STRNUNVIS" ]; then
-       printf "Testing for strnunvis ... "
-       cat <<EOF >_strnunvis.c
-#include <vis.h>
-#ifdef __FreeBSD__
-#error FreeBSD has broken strnunvis support
-#endif
-#ifdef __NetBSD_Version__
-#  if __NetBSD_Version__ <799000200
-#  error Upgrade NetBSD to 7.99.2 to get a working strnunvis
-#  endif
-#endif
-
-int main(void) {
-       char s[10];
-       strunvis(s, 0, s);
-       return 0;
-}
-EOF
-       if $XCC _strnunvis.c -o _strnunvis 2>&3; then
-               STRNUNVIS=yes
-       else
-               STRNUNVIS=no
-       fi
-       echo "$STRNUNVIS"
-       rm -f _strnunvis.c _strnunvis
-fi
-if [ "$STRNUNVIS" = no ]; then
-       echo "UNVIS_SRC=        unvis.c" >>$CONFIG_MK
-       echo "#define strnunvis dhcpcd_strnunvis" >>$CONFIG_H
-else
-       echo "#define HAVE_STRNUNVIS" >>$CONFIG_H
-fi
-
 if [ -z "$STRVERSCMP" ]; then
        printf "Testing for strverscmp ... "
        cat <<EOF >_strverscmp.c
@@ -412,15 +358,19 @@ echo "LIB_DHCPCD= $x" >>$CONFIG_MK
 # what we actually need.
 echo "LDADD+=          -Wl,--as-needed" >>$CONFIG_MK
 
+_NOTIFY="$NOTIFY"
+_WITH_GTK="$WITH_GTK"
 if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
        if pkg-config --cflags gtk+-2.0 >/dev/null 2>&3; then
                WITH_GTK="gtk+-2.0"
        elif pkg-config --cflags gtk+-3.0 >/dev/null 2>&3; then
                WITH_GTK="gtk+-3.0"
+       else
+               echo "No suitable GTK+ library has been found"
        fi
 elif [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
        if ! pkg-config --cflags $WITH_GTK >/dev/null 2>&3; then
-               echo "$0: no suitable GTK+ library has been found" >&2
+               echo "No suitable GTK+ library has been found" >&2
                exit 1
        fi
 fi
@@ -430,8 +380,7 @@ if [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
        if [ "$NOTIFY" = yes -o -z "$NOTIFY" ]; then
                if ! pkg-config --cflags libnotify >/dev/null 2>&3; then
                        echo "libnotify not found" >&2
-                       [ "$NOTIFY" = yes ] && exit 1
-                       NOTIFY=no
+                       [ "$NOTIFY" = yes -a -n "$_WITH_GTK" ] && exit 1
                fi
                NOTIFY=yes
        fi
@@ -444,25 +393,41 @@ if [ -n "$WITH_GTK" -a "$WITH_GTK" != no ]; then
        [ $? != 0 -a "$WITH_GTK" = yes ] && exit 1
        GTK_LIBS=$(pkg-config --libs $PKG)
        [ $? != 0 -a "$WITH_GTK" = yes ] && exit 1
-       echo "GTK+ CFLAGS=$GTK_CFLAGS"
-       echo "GTK+ LIBS=$GTK_LIBS"
        echo "GTK_CFLAGS=       $GTK_CFLAGS" >>$CONFIG_MK
        echo "GTK_LIBS= $GTK_LIBS" >>$CONFIG_MK
        UI="$UI${UI:+ }dhcpcd-gtk"
 fi
 
 DHCPCD_QT=false
-if [ "WITH_QT" = yes -o -z "$WITH_QT" ]; then
-       if type qmake >/dev/null 2>&3; then
-               UI="$UI${UI+ }dhcpcd-qt"
-               DHCPCD_QT=true
+if [ -z "$WITH_QT" -o "$WITH_QT" != no ]; then
+       printf "Looking for qmake ... "
+       if [ -z "$QMAKE" ]; then
+               if [ -x "$QTDIR"/bin/qmake ]; then
+                       QMAKE="$QTDIR"/bin/qmake
+               else
+                       QMAKE=$(_which qmake)
+               fi
        fi
-elif [ -n "$WITH_QT" -a "$WITH_QT" != no ]; then
-       if type qmake >/dev/null 2>&3; then
+       if [ -x "$QMAKE" ]; then
                UI="$UI${UI+ }dhcpcd-qt"
                DHCPCD_QT=true
+               echo "$QMAKE"
        else
-               echo "$0: no suitable QT library has been found" >&2
+               echo "no"
+               if [ -n "$WITH_QT" ]; then
+                       echo "No suitable Qt library has been found" >&2
+                       exit 1
+               fi
+       fi
+fi
+
+NOTIFY="$_NOTIFY"
+if $DHCPCD_QT && [ -z "$NOTFY" -o "$NOTIFY" = yes ]; then
+       if kde4-config --path lib --locate libkdeui.so >/dev/null 2>&3; then
+               QMAKE_CONFIG="$QMAKE_CONFIG CONFIG+=has_libkdeui"
+               echo "Building dhcpcd-qt with notification support"
+       elif [ "$NOTIFY" = yes ]; then
+               echo "$0: knotify4 not found" >&2
                exit 1
        fi
 fi
@@ -474,9 +439,51 @@ if [ "$WITH_ICONS" = yes ]; then
        echo "MKICONS=  icons" >>$CONFIG_MK
 fi
 
-if [ -n "$WITH_TOOLS" -a "$WITH_TOOLS" != no ]; then
-       UI="dhcpcd-decode dhcpcd-online${UI:+ }$UI"
+LIB_CURSES=
+if [ "$WITH_CURSES" = yes -o -z "$WITH_CURSES" ]; then
+       printf "Looking for libcurses ... "
+       cat <<EOF >_curses.c
+#include <curses.h>
+int main(void) {
+       initscr();
+       return 0;
+}
+EOF
+       if $XCC _curses.c -o _curses -lcurses 2>&3; then
+               LIB_CURSES=-lcurses
+       fi
+       rm -f _curses.c _curses
 fi
+if [ -n "$LIB_CURSES" ]; then
+       echo "$LIB_CURSES"
+       echo "LIB_CURSES=       $LIB_CURSES" >>$CONFIG_MK
+       UI="dhcpcd-curses${UI:+ }$UI"
+
+       if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
+               printf "Testing for _nc_free_and_exit() in $LIB_CURSES ... "
+               cat <<EOF >_curses.c
+#include <curses.h>
+int main(void) {
+       _nc_free_and_exit();
+       return 0;
+}
+EOF
+               if $XCC _curses.c -o _curses "$LIB_CURSES" 2>&3; then
+                       echo "yes"
+                       echo "CURSES_CPPFLAGS=  -DHAVE_NC_FREE_AND_EXIT" >>$CONFIG_MK
+               else
+                       echo "no"
+               fi
+               rm -f _curses.c _curses
+       fi
+elif [ ! "$WITH_CURSES" = no ]; then
+       echo "no"
+fi
+
+if [ -n "$WITH_DHCPCD_ONLINE" -a "$WITH_DHCPCD_ONLINE" != no ]; then
+       UI="dhcpcd-online${UI:+ }$UI"
+fi
+
 echo "UI=              ${UI:+libdhcpcd }$UI" >>$CONFIG_MK
 
 echo
@@ -493,7 +500,7 @@ echo "MKDIR=                \${TOPDIR}/mk" >>$CONFIG_MK
 if $DHCPCD_QT; then
        QMAKE_CONFIG="$QMAKE_CONFIG PREFIX=$PREFIX SYSCONFDIR=$SYSCONFDIR"
        QMAKE_CONFIG="$QMAKE_CONFIG MANDIR=$MANDIR"
-       if ! (cd src/dhcpcd-qt; qmake $QMAKE_CONFIG dhcpcd-qt.pro); then
+       if ! (cd src/dhcpcd-qt; $QMAKE $QMAKE_CONFIG dhcpcd-qt.pro); then
                echo "$0: failed to configure dhcpcd-qt" >&2
                exit 1
        fi