From 295be612584183232c221f4f28ebc103de5dba85 Mon Sep 17 00:00:00 2001
From: William Metcalf <william.metcalf@gmail.com>
Date: Wed, 9 Jun 2010 17:04:59 -0500
Subject: [PATCH 2/2] Updates to allow for disabling options based on  Pierre Chifflier's patch

---
 configure.in |  222 ++++++++++++++++++++++++++--------------------------------
 1 files changed, 100 insertions(+), 122 deletions(-)

diff --git a/configure.in b/configure.in
index 8dbbd02..bd95bc7 100644
--- a/configure.in
+++ b/configure.in
@@ -120,11 +120,9 @@ AC_INIT(configure.in)
 #These flags seem to be supported on CentOS 5+, Ubuntu 8.04+, and FedoreCore 11+
 #Options are taken from https://wiki.ubuntu.com/CompilerFlags
     AC_ARG_ENABLE(gccprotect,
-            [  --enable-gccprotect  Detect and use gcc hardening options],
-            [ enable_gccprotect=yes
-            ])
+           AS_HELP_STRING([--enable-gccprotect], [Detect and use gcc hardening options]),,[enable_gccprotect=no])
 
-    if test "$enable_gccprotect" = "yes"; then
+    AS_IF([test "x$enable_gccprotect" = "xyes"], [
         #buffer overflow protection
         AC_MSG_CHECKING(for -fstack-protector)
         TMPCFLAGS="${CFLAGS}"
@@ -172,25 +170,19 @@ AC_INIT(configure.in)
 
         CFLAGS="${CFLAGS} ${SECCFLAGS}"
         LDFLAGS="${LDFLAGS} ${SECLDFLAGS}"
-    fi
+    ])
 
 #enable profile generation
     AC_ARG_ENABLE(gccprofile,
-            [  --enable-gccprofile Enable gcc profile info i.e -pg flag is set],
-            [ enable_gccprofile=yes
-            ])
-
-    if test "$enable_gccprofile" = "yes"; then
-    CFLAGS="${CFLAGS} -pg"
-    fi
+           AS_HELP_STRING([--enable-gccprofile], [Enable gcc profile info i.e -pg flag is set]),,[enable_gccprofile=no])
+    AS_IF([test "x$enable_gccprofile" = "xyes"], [
+        CFLAGS="${CFLAGS} -pg"
+    ])
 
 #enable gcc march=native gcc 4.2 or later
     AC_ARG_ENABLE(gccmarch_native,
-            [  --enable-gccmarch-native Enable gcc march=native gcc 4.2 and later only],
-            [ enable_gccmarch_native=yes
-            ])
-
-    if test "$enable_gccmarch_native" = "yes"; then
+           AS_HELP_STRING([--enable-gccmarch-native], [Enable gcc march=native gcc 4.2 and later only]),,[enable_gccmarch_native=no])
+    AS_IF([test "x$enable_gccmarch_native" = "xyes"], [
         if test "$gccvernum" -ge "402"; then
                 dnl gcc 4.2 or later
                 CFLAGS="$CFLAGS -march=native"
@@ -201,7 +193,7 @@ AC_INIT(configure.in)
                 echo
                 exit 1
         fi
-    fi
+    ])
 
 #libpcre
     AC_ARG_WITH(libpcre_includes,
@@ -321,12 +313,10 @@ AC_INIT(configure.in)
 
 #enable support for NFQUEUE
     AC_ARG_ENABLE(nfqueue,
-            [  --enable-nfqueue  Enable NFQUEUE support for inline IDP],
-            [ enable_nfqueue=yes ],
-            [ enable_nfqueue=no ])
-    if test "$enable_nfqueue" = "yes"; then
-    CFLAGS="$CFLAGS -DNFQ"
-
+           AS_HELP_STRING([--enable-nfqueue], [Enable NFQUEUE support for inline IDP]),,[enable_nfqueue=no])
+    AS_IF([test "x$enable_nfqueue" = "xyes"], [
+        CFLAGS="$CFLAGS -DNFQ"
+  
 #libnfnetlink
 case $host in
 *-*-mingw32*)
@@ -416,21 +406,17 @@ esac
     echo
     exit 1 
     fi
-    fi
-
+])
 #enable support for IPFW
     AC_ARG_ENABLE(ipfw,
-            [  --enable-ipfw  Enable FreeBSD IPFW support for inline IDP],
-            [ enable_ipfw=yes ],
-            [ enable_ipfw=no ])
-    if test "$enable_ipfw" = "yes"; then
+            AS_HELP_STRING([--enable-ipfw], [Enable FreeBSD IPFW support for inline IDP]),,[enable_ipfw=no])
+    AS_IF([test "x$enable_ipfw" = "xyes"], [
         CFLAGS="$CFLAGS -DIPFW"
-    fi
+    ])
 
 #prelude
-
     AC_ARG_ENABLE(prelude,
-            AS_HELP_STRING([--enable-prelude], [Enable Prelude support for alerts]))
+            AS_HELP_STRING([--enable-prelude], [Enable Prelude support for alerts]),,[enable_prelude=no])
     AS_IF([test "x$enable_prelude" = "xyes"], [
         CFLAGS="$CFLAGS -DPRELUDE"
         AM_PATH_LIBPRELUDE(0.9.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no)
@@ -447,7 +433,6 @@ esac
         fi
     ])
 
-
 #libnet
     AC_ARG_WITH(libnet_includes,
             [  --with-libnet-includes=DIR     libnet include directory],
@@ -524,12 +509,10 @@ esac
 # libpfring (currently only supported for libpcap enabled pfring)
 # Error on the side of caution. If libpfring enabled pcap is being used and we don't link against -lpfring compilation will fail.
     AC_ARG_ENABLE(pfring,
-            [  --enable-pfring  Enable Native PF_RING support],
-            [ enable_pfring=yes
-            ])
-    if test "$enable_pfring" = "yes"; then
-    CFLAGS="$CFLAGS -DHAVE_PFRING"
-    fi
+           AS_HELP_STRING([--enable-pfring], [Enable Native PF_RING support]),,[enable_pfring=no])
+    AS_IF([test "x$enable_pfring" = "xyes"], [
+        CFLAGS="$CFLAGS -DHAVE_PFRING"
+    ])
 
 #We have to set CFLAGS for AC_TRY_COMPILE as it doesn't pay attention to CPPFLAGS
     AC_ARG_WITH(libpfring_includes,
@@ -550,7 +533,7 @@ esac
     LIBPFRING=""
     AC_CHECK_LIB(pfring, pfring_set_cluster,, LIBPFRING="no")
     if test "$LIBPFRING" = "no"; then
-        if test "enable_pfring" = "yes"; then
+        if test "x$enable_pfring" = "xyes"; then
         echo
         echo "   ERROR! --enable-pfring was passed but the library was not found or version is >4, go get it"
         echo "   from http://www.ntop.org/PF_RING.html"
@@ -622,88 +605,79 @@ AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
 
 # enable the running of unit tests
     AC_ARG_ENABLE(unittests,
-            [  --enable-unittests  Enable compilation of the unit tests],
-            [ enable_unittests=yes ],
-            [ enable_unittests=no ])
-    if test "$enable_unittests" = "yes"; then
-    CFLAGS="${CFLAGS} -DUNITTESTS"
-    fi
+           AS_HELP_STRING([--enable-unittests], [Enable compilation of the unit tests]),,[enable_unittests=no])
+    AS_IF([test "x$enable_unittests" = "xyes"], [
+        UT_ENABLED="yes"
+        CFLAGS="${CFLAGS} -DUNITTESTS"
+    ])
 
 # enable native timeval for unified alert output
     AC_ARG_ENABLE(unified-native-timeval,
-            [  --enable-unified-native-timeval  Use native timeval for unified outputs],
-            [ enable_unified_native_timeval=yes
-            ])
-    if test "$enable_unified_native_timeval" = "yes"; then
-    CFLAGS="${CFLAGS} -DUNIFIED_NATIVE_TIMEVAL"
-    fi
+           AS_HELP_STRING([--enable-unified-native-timeval], [Use native timeval for unified outputs]),,[enable_unified_native_timeval=no])
+    AS_IF([test "x$enable_unified_native_timeval" = "xyes"], [
+        CFLAGS="${CFLAGS} -DUNIFIED_NATIVE_TIMEVAL"
+    ])
 
 # enable debug output
     AC_ARG_ENABLE(debug,
-            [  --enable-debug  Enable debug output],
-            [ enable_debug=yes ],
-            [ enable_debug=no ])
-    if test "$enable_debug" = "yes"; then
-    CFLAGS="${CFLAGS} -DDEBUG"
-    fi
+           AS_HELP_STRING([--enable-debug], [Enable debug output]),,[enable_debug=no])
+    AS_IF([test "x$enable_debug" = "xyes"], [
+        CFLAGS="${CFLAGS} -DDEBUG"
+    ])
 
 #libhtp
-    AC_ARG_ENABLE(nonbundled-htp,
-            [  --enable-nonbundled-htp Enable the use of an already installed version of htp],
-            [enable_non_bundled_htp=yes],[enable_non_bundled_htp=no]
-            )
-    if test "$enable_non_bundled_htp" = "yes"; then
-    AC_ARG_WITH(libhtp_includes,
-            [  --with-libhtp-includes=DIR  libhtp include directory],
-            [with_libhtp_includes="$withval"],[with_libhtp_includes=no])
-    AC_ARG_WITH(libhtp_libraries,
-            [  --with-libhtp-libraries=DIR    libhtp library directory],
-            [with_libhtp_libraries="$withval"],[with_libhtp_libraries="no"])
-
-    if test "$with_libhtp_includes" != "no"; then
-    CPPFLAGS="${CPPFLAGS} -I${with_libhtp_includes}"
-    fi
+    AC_ARG_ENABLE(non-bundled-htp,
+           AS_HELP_STRING([--enable-non-bundled-htp], [Enable the use of an already installed version of htp]),,[enable_non_bundled_htp=no])
+    AS_IF([test "x$enable_non_bundled_htp" = "xyes"], [
+        AC_ARG_WITH(libhtp_includes,
+                [  --with-libhtp-includes=DIR  libhtp include directory],
+                [with_libhtp_includes="$withval"],[with_libhtp_includes=no])
+        AC_ARG_WITH(libhtp_libraries,
+                [  --with-libhtp-libraries=DIR    libhtp library directory],
+                [with_libhtp_libraries="$withval"],[with_libhtp_libraries="no"])
+
+        if test "$with_libhtp_includes" != "no"; then
+        CPPFLAGS="${CPPFLAGS} -I${with_libhtp_includes}"
+        fi
 
-    if test "$with_libhtp_libraries" != "no"; then
-    LDFLAGS="${LDFLAGS} -L${with_libhtp_libraries}"
-    fi
+        if test "$with_libhtp_libraries" != "no"; then
+        LDFLAGS="${LDFLAGS} -L${with_libhtp_libraries}"
+        fi
 
-    AC_CHECK_HEADER(htp/htp.h,,[AC_ERROR(htp/htp.h not found ...)])
+        AC_CHECK_HEADER(htp/htp.h,,[AC_ERROR(htp/htp.h not found ...)])
 
-    LIBHTP=""
-    AC_CHECK_LIB(htp, htp_conn_create,, LIBHTP="no")
-    if test "$LIBHTP" = "no"; then
-    echo
-    echo "   ERROR! libhtp library not found"
-    echo
-    exit 1
-    fi
-    PKG_CHECK_MODULES(LIBHTPMINVERSION, htp >= 0.2.3,[libhtp_minver_found="yes"],[libhtp_minver_found="no"])
-    if test "$libhtp_minver_found" = "no"; then
-    echo
-    echo "   ERROR! libhtp was found but is not the minimum version required >=0.2.3"
-    echo
-    exit 1
-    fi
-    fi
+        LIBHTP=""
+        AC_CHECK_LIB(htp, htp_conn_create,, LIBHTP="no")
+        if test "$LIBHTP" = "no"; then
+        echo
+        echo "   ERROR! libhtp library not found"
+        echo
+        exit 1
+        fi
+        PKG_CHECK_MODULES(LIBHTPMINVERSION, htp >= 0.2.3,[libhtp_minver_found="yes"],[libhtp_minver_found="no"])
+        if test "$libhtp_minver_found" = "no"; then
+        echo
+        echo "   ERROR! libhtp was found but is not the minimum version required >=0.2.3"
+        echo
+        exit 1
+        fi
+    ]) 
 
    #even if we are using an installed htp lib we still need to gen Makefiles inside of htp
    AC_CONFIG_SUBDIRS([libhtp])
-   AM_CONDITIONAL([BUILD_LIBHTP], [test "$enable_non_bundled_htp" = "no"])
+   AM_CONDITIONAL([BUILD_LIBHTP], [test "x$enable_non_bundled_htp" = "xno"])
 
 # enable CUDA output
     AC_ARG_ENABLE(cuda,
-            [  --enable-cuda  Enable CUDA pattern matching],
-            [ enable_cuda=yes ],
-            [ enable_cuda=no ])
-    AC_ARG_WITH(cuda_includes,
-            [  --with-cuda-includes=DIR  cuda include directory],
-            [with_cuda_includes="$withval"],[with_cuda_includes=no])
-    AC_ARG_WITH(cuda_libraries,
-            [  --with-cuda-libraries=DIR    cuda library directory],
-            [with_cuda_libraries="$withval"],[with_cuda_libraries="no"])
-
-    if test "$enable_cuda" = "yes"; then
+           AS_HELP_STRING([--enable-cuda], [Enable CUDA pattern matching]),,[enable_cuda=no])
+    AS_IF([test "x$enable_cuda" = "xyes"], [
+        AC_ARG_WITH(cuda_includes,
+                [  --with-cuda-includes=DIR  cuda include directory],
+                [with_cuda_includes="$withval"],[with_cuda_includes=no])
+        AC_ARG_WITH(cuda_libraries,
+                [  --with-cuda-libraries=DIR    cuda library directory],
+                [with_cuda_libraries="$withval"],[with_cuda_libraries="no"])
+
         CFLAGS="${CFLAGS} -D__SC_CUDA_SUPPORT__"
 
         if test "$with_cuda_includes" != "no"; then
@@ -726,7 +700,8 @@ AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
             echo
             exit 1
         fi
-    fi
+    ])
+    
 
 # Check for libcap-ng
 
@@ -766,12 +741,10 @@ AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
     fi
 
     AC_ARG_ENABLE(profiling,
-            [  --enable-profiling  Enable performance profiling],
-            [ enable_profiling=yes ],
-            [ enable_profiling=no ])
-    if test "$enable_profiling" = "yes"; then
-    CFLAGS="${CFLAGS} -DPROFILING"
-    fi
+           AS_HELP_STRING([--enable-profiling], [Enable performance profiling]),,[enable_profiling=no])
+    AS_IF([test "x$enable_profiling" = "xyes"], [
+        CFLAGS="${CFLAGS} -DPROFILING"
+    ])
 
 AC_SUBST(CFLAGS)
 AC_SUBST(LDFLAGS)
@@ -781,12 +754,17 @@ AC_OUTPUT(Makefile src/Makefile)
 
 echo "
 Suricata Configuration:
-
-  NFQueue support:      ${enable_nfqueue}
-  IPFW support:         ${enable_ipfw}
-  Prelude support:      ${enable_prelude}
-  Unit tests enabled:   ${enable_unittests}
-  Debug output enabled: ${enable_debug}
-  CUDA enabled:         ${enable_cuda}
-  Profiling enabled:    ${enable_profiling}
-"
\ No newline at end of file
+  NFQueue support:          ${enable_nfqueue}
+  IPFW support:             ${enable_ipfw}
+  PF_RING support:          ${enable_pfring}
+  Prelude support:          ${enable_prelude}
+  Unit tests enabled:       ${enable_unittests}
+  Debug output enabled:     ${enable_debug}
+  CUDA enabled:             ${enable_cuda}
+  Profiling enabled:        ${enable_profiling}
+  GCC Protect enabled:      ${enable_gccprotect}
+  GCC march native enabled: ${enable_gccmarch_native}   
+  GCC Profile enabled:      ${enable_gccprofile}
+  Unified native time:      ${enable_unified_native_timeval}
+  Non-bundled htp:          ${enable_non_bundled_htp}
+"
-- 
1.7.0.4

