Add command line parsing function which allows to compile tools (trafgen, 
netsniff-ng)
without libnl-xxx libraries.

Option --no-libnl sets CONFIG_NO_LIBNL=1.

Signed-off-by: Vadim Kochan <vadi...@gmail.com>
---
 configure | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 105b1ec..85f2178 100755
--- a/configure
+++ b/configure
@@ -18,8 +18,36 @@ HAVE_LIBGEOIP=0
 HAVE_LIBZ=0
 HAVE_TPACKET3=0
 
+CONFIG_NO_LIBNL=0
+
 # use "CROSS_COMPILE=<prefix> SYSROOT=<path> ./configure && make" for cross 
compilation
 
+usage()
+{
+       echo "Usage: ./configure [OPTIONS]"
+       echo -e  "\t-h, --help - print usage"
+        echo -ne "\t--no-libnl - compile without libnl"
+       echo "Some features (rfraw, nlmsg dissect) will not work in trafgen, 
netsniff-ng."
+
+       exit 0
+}
+
+while [ $# -gt 0 ]
+do
+       case "$1" in
+               -h|--help)
+                       usage
+                       ;;
+               --no-libnl)
+                       CONFIG_NO_LIBNL=1
+                       ;;
+               *)
+                       usage
+                       ;;
+       esac
+       shift
+done
+
 [ -z "$CC" ] && CC="${CROSS_COMPILE}gcc"
 [ -z "$LD" ] && LD="${CROSS_COMPILE}gcc"
 if [ "x$SYSROOT" != "x" ] ; then
@@ -194,8 +222,10 @@ EOF
        if [ ! -x $TMPDIR/libnltest ] ; then
                echo "[NO]"
                MISSING_DEFS=1
-               tools_remove "trafgen"
-               tools_remove "netsniff-ng"
+               if [ "$CONFIG_NO_LIBNL" == "0" ]; then
+                       tools_remove "trafgen"
+                       tools_remove "netsniff-ng"
+               fi
        else
                echo "[YES]"
        fi
@@ -230,7 +260,9 @@ EOF
        if [ ! -x $TMPDIR/libnlroutetest ] ; then
                echo "[NO]"
                MISSING_DEFS=1
-               tools_remove "netsniff-ng"
+               if [ "$CONFIG_NO_LIBNL" == "0" ]; then
+                       tools_remove "netsniff-ng"
+               fi
        else
                echo "[YES]"
        fi
@@ -600,6 +632,7 @@ gen_config_hdr()
        local _have_libz=""
        local _have_hwts=""
        local _have_tp3=""
+       local _config_no_libnl=""
 
        echo "[*] Generating config.h ..."
 
@@ -640,6 +673,12 @@ gen_config_hdr()
                _have_tp3="/* HAVE_TPACKET3 is not defined */"
        fi
 
+       if [ "$CONFIG_NO_LIBNL" == "1" ] ; then
+               _config_no_libnl="#define CONFIG_NO_LIBNL 1"
+       else
+               _config_no_libnl="/* CONFIG_NO_LIBNL is not defined */"
+       fi
+
        cat > config.h << EOF
 #ifndef CONFIG_H
 #define CONFIG_H
@@ -654,6 +693,7 @@ $_have_libgeoip
 $_have_libz
 $_have_hwts
 $_have_tp3
+$_config_no_libnl
 #endif /* CONFIG_H */
 EOF
 }
@@ -721,6 +761,12 @@ else
        echo "CONFIG_GEOIP=0" >> Config
 fi
 
+if [ "$CONFIG_NO_LIBNL" == "1" ] ; then
+       echo "CONFIG_NO_LIBNL=1" >> Config
+else
+       echo "CONFIG_NO_LIBNL=0" >> Config
+fi
+
 echo "CONFIG_TOOLS=$TOOLS" >> Config
 echo "CONFIG_OK=1" >> Config
 
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to