]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
configure: check for zlib and liblzma
authorGiuseppe Longo <glongo@stamus-networks.com>
Thu, 13 Jul 2017 19:09:38 +0000 (21:09 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 31 Jan 2018 13:27:26 +0000 (14:27 +0100)
This checks if zlib and libzma are installed on the system
in order to decompress swf files.

configure.ac

index 3c94f9a006a8fdc4ccfc0be00df5b3196a6d626c..bdfe927e40ce1133102f8d67f1594b69b7195432 100644 (file)
 
 # libraries
 
+  # zlib
+    AC_ARG_WITH(zlib_includes,
+            [  --with-zlib-includes=DIR  zlib include directory],
+            [with_zlib_includes="$withval"],[with_zlib_includes=no])
+    AC_ARG_WITH(zlib_libraries,
+            [  --with-zlib-libraries=DIR    zlib library directory],
+            [with_zlib_libraries="$withval"],[with_zlib_libraries="no"])
+
+    if test "$with_zlib_includes" != "no"; then
+        CPPFLAGS="${CPPFLAGS} -I${with_zlib_includes}"
+    fi
+
+    AC_CHECK_HEADER(zlib.h, ZLIB="yes",ZLIB="no")
+    if test "$ZLIB" = "yes"; then
+        if test "$with_zlib_libraries" != "no"; then
+            LDFLAGS="${LDFLAGS}  -L${with_zlib_libraries}"
+        fi
+
+        # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
+        # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
+        ZLIB=""
+        TMPLIBS="${LIBS}"
+        AC_CHECK_LIB(z,inflate,,ZLIB="no")
+
+        if test "$ZLIB" = "no"; then
+            echo
+            echo "   ERROR!  zlib library not found, go get it"
+            echo
+            exit 1
+        fi
+        LIBS="${TMPLIBS} -lz"
+    fi
+
+  # liblzma
+    enable_liblzma=no
+
+    AC_ARG_WITH(liblzma_includes,
+            [  --with-liblzma-includes=DIR  liblzma include directory],
+            [with_liblzma_includes="$withval"],[with_liblzma_includes=no])
+    AC_ARG_WITH(liblzma_libraries,
+            [  --with-liblzma-libraries=DIR    liblzma library directory],
+            [with_liblzma_libraries="$withval"],[with_liblzma_libraries="no"])
+
+    if test "$with_liblzma_includes" != "no"; then
+        CPPFLAGS="${CPPFLAGS} -I${with_liblzma_includes}"
+    fi
+
+    AC_CHECK_HEADER(lzma.h,LIBLZMA="yes",LIBLZMA="no")
+    if test "$LIBLZMA" = "yes"; then
+        if test "$with_liblzma_libraries" != "no"; then
+            LDFLAGS="${LDFLAGS}  -L${with_liblzma_libraries}"
+        fi
+
+        # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
+        # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
+        LIBLZMA=""
+        TMPLIBS="${LIBS}"
+        AC_CHECK_LIB(lzma,lzma_code,,LIBLZMA="no")
+
+        if test "$LIBLZMA" = "no"; then
+            echo
+            echo "   Warning! liblzma library not found, you will not be"
+            echo "   able to decompress flash file compressed with lzma."
+            echo
+            enable_liblzma=no
+        else
+            enable_liblzma=yes
+            AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma available])
+            LIBS="${TMPLIBS} -llzma"
+        fi
+    fi
+
     AC_MSG_CHECKING([for Mpipe])
     AC_COMPILE_IFELSE(
         [AC_LANG_PROGRAM([[#include <gxio/mpipe.h>]])],
@@ -2144,6 +2216,7 @@ SURICATA_BUILD_CONF="Suricata Configuration:
   libnss support:                          ${enable_nss}
   libnspr support:                         ${enable_nspr}
   libjansson support:                      ${enable_jansson}
+  liblzma support:                         ${enable_liblzma}
   hiredis support:                         ${enable_hiredis}
   hiredis async with libevent:             ${enable_hiredis_async}
   Prelude support:                         ${enable_prelude}