From f38b5b7296d87e7b1744ef6b5f3dca11fe7cf886 Mon Sep 17 00:00:00 2001 From: Felipe Zipitria Date: Thu, 12 Feb 2026 18:42:32 -0300 Subject: [PATCH 1/2] refactor: autotools files Signed-off-by: Felipe Zipitria --- build/curl.m4 | 135 +++--------------- build/libgeoip.m4 | 182 +----------------------- build/libmaxmind.m4 | 183 +----------------------- build/libxml.m4 | 137 +----------------- build/lmdb.m4 | 195 +++---------------------- build/lua.m4 | 321 +++++++++++------------------------------- build/msc_find_lib.m4 | 266 ++++++++++++++++++++++++++++++++++ build/pcre.m4 | 143 +++++-------------- build/pcre2.m4 | 192 ++----------------------- build/ssdeep.m4 | 151 ++------------------ build/yajl.m4 | 197 +++----------------------- configure.ac | 254 ++++++++------------------------- modsecurity.pc.in | 2 +- 13 files changed, 538 insertions(+), 1820 deletions(-) create mode 100644 build/msc_find_lib.m4 diff --git a/build/curl.m4 b/build/curl.m4 index 747d21fe64..f5e1bff5c6 100644 --- a/build/curl.m4 +++ b/build/curl.m4 @@ -1,131 +1,36 @@ dnl Check for CURL Libraries -dnl CHECK_CURL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) dnl Sets: dnl CURL_CFLAGS -dnl CURL_LIBS - -CURL_CONFIG="" -CURL_VERSION="" -CURL_CPPFLAGS="" -CURL_CFLAGS="" -CURL_LDFLAGS="" -CURL_LDADD="" -CURL_MIN_VERSION="7.15.1" +dnl CURL_LDADD +dnl CURL_LDFLAGS +dnl CURL_VERSION +dnl CURL_DISPLAY +dnl CURL_FOUND AC_DEFUN([CHECK_CURL], [ - - -AC_ARG_WITH( - curl, - [AS_HELP_STRING([--with-curl=PATH],[Path to curl prefix or config script])], - [test_paths="${with_curl}"], - [test_paths="/usr/local/libcurl /usr/local/curl /usr/local /opt/libcurl /opt/curl /opt /usr"]) - -AC_MSG_CHECKING([for libcurl config script]) - -for x in ${test_paths}; do - dnl # Determine if the script was specified and use it directly - if test ! -d "$x" -a -e "$x"; then - CURL_CONFIG=$x - curl_path="no" - break - fi - - dnl # Try known config script names/locations - for CURL_CONFIG in curl-config; do - if test -e "${x}/bin/${CURL_CONFIG}"; then - curl_path="${x}/bin" - break - elif test -e "${x}/${CURL_CONFIG}"; then - curl_path="${x}" - break - else - curl_path="" - fi - done - if test -n "$curl_path"; then - break - fi -done - -if test -n "${curl_path}"; then - if test "${curl_path}" != "no"; then - CURL_CONFIG="${curl_path}/${CURL_CONFIG}" - fi - AC_MSG_RESULT([${CURL_CONFIG}]) - CURL_VERSION=`${CURL_CONFIG} --version | sed 's/^[[^0-9]][[^[:space:]]][[^[:space:]]]*[[[:space:]]]*//' | tr '\r\n' ' '` - if test ! -z "${CURL_VERSION}"; then AC_MSG_NOTICE(curl VERSION: $CURL_VERSION); fi - CURL_CFLAGS="`${CURL_CONFIG} --cflags`" - if test ! -z "${CURL_CFLAGS}"; then AC_MSG_NOTICE(curl CFLAGS: $CURL_CFLAGS); fi - CURL_LDADD="`${CURL_CONFIG} --libs`" - if test ! -z "${CURL_CONFIG}"; then AC_MSG_NOTICE(curl LDADD: $CURL_LIBS); fi - - dnl # Check version is ok - AC_MSG_CHECKING([if libcurl is at least v${CURL_MIN_VERSION}]) - curl_min_ver=`echo ${CURL_MIN_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` - curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` - if test "$curl_min_ver" -le "$curl_ver"; then - AC_MSG_RESULT([yes, $CURL_VERSION]) - curl_tlsv2_ver=`echo 7.34.0 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` - if test "$curl_tlsv2_ver" -le "$curl_ver"; then - CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL_SSLVERSION_TLSv1_2" - fi - CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL" +MSC_CHECK_LIB([CURL], [libcurl], [curl/curl.h], [curl], [-DWITH_CURL], [7.15.1]) + +# Post-processing: TLSv1.2 version check +if test "x${CURL_FOUND}" = "x1" && test -n "${CURL_VERSION}"; then + AC_MSG_CHECKING([if libcurl supports TLSv1.2]) + _msc_curl_tlsv2_ver=`echo 7.34.0 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` + _msc_curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` + if test "${_msc_curl_tlsv2_ver}" -le "${_msc_curl_ver}" 2>/dev/null; then + AC_MSG_RESULT([yes]) + CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL_SSLVERSION_TLSv1_2" else - AC_MSG_RESULT([no, $CURL_VERSION]) - AC_MSG_NOTICE([NOTE: curl library may be too old]) + AC_MSG_RESULT([no]) fi - dnl # Check/warn if GnuTLS is used + # Check/warn if GnuTLS is used AC_MSG_CHECKING([if libcurl is linked with gnutls]) - curl_uses_gnutls=`echo ${CURL_LIBS} | grep gnutls | wc -l` - if test "$curl_uses_gnutls" -ne 0; then + _msc_curl_uses_gnutls=`echo ${CURL_LDADD} | grep gnutls | wc -l` + if test "$_msc_curl_uses_gnutls" -ne 0; then AC_MSG_RESULT([yes]) AC_MSG_NOTICE([NOTE: curl linked with gnutls may be buggy, openssl recommended]) - CURL_USES_GNUTLS=yes else AC_MSG_RESULT([no]) - CURL_USES_GNUTLS=no - fi - -else - AC_MSG_RESULT([no]) -fi - -AC_SUBST(CURL_CONFIG) -AC_SUBST(CURL_VERSION) -AC_SUBST(CURL_CPPFLAGS) -AC_SUBST(CURL_CFLAGS) -AC_SUBST(CURL_LDFLAGS) -AC_SUBST(CURL_LDADD) -AC_SUBST(CURL_USES_GNUTLS) - -if test "x${with_curl}" == "xno"; then - CURL_DISABLED=yes -else - if test "x${with_curl}" != "x"; then - CURL_MANDATORY=yes - fi -fi - -if test -z "${CURL_VERSION}"; then - AC_MSG_NOTICE([*** curl library not found.]) - if test -z "${CURL_MANDATORY}"; then - if test -z "${CURL_DISABLED}"; then - CURL_FOUND=0 - else - CURL_FOUND=2 - fi - else - AC_MSG_ERROR([Curl was explicitly referenced but it was not found]) - CURL_FOUND=-1 fi -else - CURL_FOUND=1 - AC_MSG_NOTICE([using curl v${CURL_VERSION}]) - CURL_DISPLAY="${CURL_LDADD}, ${CURL_CFLAGS}" fi -AC_SUBST(CURL_FOUND) -AC_SUBST(CURL_DISPLAY) -]) +]) # AC_DEFUN [CHECK_CURL] diff --git a/build/libgeoip.m4 b/build/libgeoip.m4 index c382d241df..3aa74b3b9c 100644 --- a/build/libgeoip.m4 +++ b/build/libgeoip.m4 @@ -1,186 +1,12 @@ -dnl Check for GEOIP Libraries -dnl CHECK_GEOIP(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +dnl Check for GeoIP Libraries dnl Sets: dnl GEOIP_CFLAGS dnl GEOIP_LDADD dnl GEOIP_LDFLAGS -dnl GEOIP_LIBS dnl GEOIP_VERSION +dnl GEOIP_DISPLAY +dnl GEOIP_FOUND AC_DEFUN([PROG_GEOIP], [ - -# Possible names for the geoip library/package (pkg-config) -GEOIP_POSSIBLE_LIB_NAMES="geoip2 geoip GeoIP" - -# Possible extensions for the library -GEOIP_POSSIBLE_EXTENSIONS="so la sl dll dylib" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -GEOIP_POSSIBLE_PATHS="/usr/local/libgeoip /usr/local/geoip /usr/local /opt/libgeoip /opt/geoip /opt /usr /opt/local/include /opt/local /usr/lib /usr/local/lib /usr/lib64 /usr" - -# Variables to be set by this very own script. -GEOIP_VERSION="" -GEOIP_CFLAGS="" -GEOIP_CPPFLAGS="" -GEOIP_LDADD="" -GEOIP_LDFLAGS="" - -AC_ARG_WITH( - geoip, - AS_HELP_STRING( - [--with-geoip=PATH], - [Path to GeoIP (including headers). Use 'no' to disable GeoIP support.] - ) -) - -# AS_HELP_STRING( -# [--without-geoip], -# [Complete dsiables GeoIP support] -# ) - - -if test "x${with_geoip}" == "xno"; then - AC_DEFINE(HAVE_GEOIP, 0, [Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no]) - AC_MSG_NOTICE([Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no]) - GEOIP_DISABLED=yes -else - if test "x${with_geoip}" == "xyes"; then - GEOIP_MANDATORY=yes - AC_MSG_NOTICE([GeoIP support was marked as mandatory by the utilization of --with-geoip=yes]) - fi -# for x in ${GEOIP_POSSIBLE_LIB_NAMES}; do -# CHECK_FOR_GEOIP_AT(${x}) -# if test -n "${GEOIP_VERSION}"; then -# break -# fi -# done - -# if test "x${with_geoip}" != "xyes" or test "x${with_geoip}" == "xyes"; then - if test "x${with_geoip}" == "x" || test "x${with_geoip}" == "xyes"; then - # Nothing about GeoIP was informed, using the pkg-config to figure things out. - if test -n "${PKG_CONFIG}"; then - GEOIP_PKG_NAME="" - for x in ${GEOIP_POSSIBLE_LIB_NAMES}; do - if ${PKG_CONFIG} --exists ${x}; then - GEOIP_PKG_NAME="$x" - break - fi - done - fi - AC_MSG_NOTICE([Nothing about GeoIP was informed during the configure phase. Trying to detect it on the platform...]) - if test -n "${GEOIP_PKG_NAME}"; then - # Package was found using the pkg-config scripts - GEOIP_VERSION="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --modversion`" - GEOIP_CFLAGS="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --cflags`" - GEOIP_LDADD="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --libs-only-l`" - GEOIP_LDFLAGS="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --libs-only-L --libs-only-other`" - GEOIP_DISPLAY="${GEOIP_LDADD}, ${GEOIP_CFLAGS}" - else - # If pkg-config did not find anything useful, go over file lookup. - for x in ${GEOIP_POSSIBLE_PATHS}; do - CHECK_FOR_GEOIP_AT(${x}) - if test -n "${GEOIP_VERSION}"; then - break - fi - done - fi - fi - if test "x${with_geoip}" != "x"; then - # An specific path was informed, lets check. - GEOIP_MANDATORY=yes - CHECK_FOR_GEOIP_AT(${with_geoip}) - fi -# fi -fi - -if test -z "${GEOIP_CFLAGS}"; then - if test -z "${GEOIP_MANDATORY}"; then - if test -z "${GEOIP_DISABLED}"; then - AC_MSG_NOTICE([GeoIP library was not found]) - GEOIP_FOUND=0 - else - GEOIP_FOUND=2 - fi - else - AC_MSG_ERROR([GeoIP was explicit requested but it was not found]) - GEOIP_FOUND=-1 - fi -else - GEOIP_FOUND=1 - AC_MSG_NOTICE([using GeoIP v${GEOIP_VERSION}]) - GEOIP_CFLAGS="-DWITH_GEOIP ${GEOIP_CFLAGS}" - AC_SUBST(GEOIP_VERSION) - AC_SUBST(GEOIP_LDADD) - AC_SUBST(GEOIP_LIBS) - AC_SUBST(GEOIP_LDFLAGS) - AC_SUBST(GEOIP_CFLAGS) - AC_SUBST(GEOIP_DISPLAY) -fi - - - -AC_SUBST(GEOIP_FOUND) - +MSC_CHECK_LIB([GEOIP], [geoip2 geoip GeoIP], [GeoIPCity.h], [GeoIP], [-DWITH_GEOIP]) ]) # AC_DEFUN [PROG_GEOIP] - - -AC_DEFUN([CHECK_FOR_GEOIP_AT], [ - path=$1 - for y in ${GEOIP_POSSIBLE_EXTENSIONS}; do - for z in ${GEOIP_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - geoip_lib_path="${path}/" - geoip_lib_name="${z}" - geoip_lib_file="${geoip_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - geoip_lib_path="${path}/" - geoip_lib_name="${z}" - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - geoip_lib_path="${path}/lib/" - geoip_lib_name="${z}" - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib64/lib${z}.${y}"; then - geoip_lib_path="${path}/lib64/" - geoip_lib_name="${z}" - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - geoip_lib_path="${path}/lib/x86_64-linux-gnu/" - geoip_lib_name="${z}" - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$geoip_lib_path"; then - break - fi - done - if test -e "${path}/include/GeoIPCity.h"; then - geoip_inc_path="${path}/include" - elif test -e "${path}/GeoIPCity.h"; then - geoip_inc_path="${path}" - fi - - - if test -n "${geoip_inc_path}" -a -n "${geoip_lib_path}"; then - - AC_MSG_NOTICE([GeoIP headers found at: ${geoip_inc_path}]) - AC_MSG_NOTICE([GeoIP library found at: ${geoip_lib_file}]) - fi - - if test -n "${geoip_lib_path}" -a -n "${geoip_inc_path}"; then - # TODO: Compile a piece of code to check the version. - GEOIP_CFLAGS="-I${geoip_inc_path}" - GEOIP_LDADD="-l${geoip_lib_name}" - GEOIP_LDFLAGS="-L${geoip_lib_path}" - GEOIP_DISPLAY="${geoip_lib_file}, ${geoip_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_GEOIP_AT] diff --git a/build/libmaxmind.m4 b/build/libmaxmind.m4 index 7eafc4d58d..074227daa2 100644 --- a/build/libmaxmind.m4 +++ b/build/libmaxmind.m4 @@ -1,187 +1,12 @@ -dnl Check for MAXMIND Libraries -dnl CHECK_MAXMIND(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +dnl Check for MaxMind Libraries dnl Sets: dnl MAXMIND_CFLAGS dnl MAXMIND_LDADD dnl MAXMIND_LDFLAGS -dnl MAXMIND_LIBS dnl MAXMIND_VERSION +dnl MAXMIND_DISPLAY +dnl MAXMIND_FOUND AC_DEFUN([PROG_MAXMIND], [ - -# Possible names for the maxmind library/package (pkg-config) -MAXMIND_POSSIBLE_LIB_NAMES="maxminddb maxmind" - -# Possible extensions for the library -MAXMIND_POSSIBLE_EXTENSIONS="so la sl dll dylib" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -MAXMIND_POSSIBLE_PATHS="/usr/local/libmaxmind /usr/local/maxmind /usr/local /opt/libmaxmind /opt/maxmind /opt /usr /opt/local/include /opt/local /usr/lib /usr/local/lib /usr/lib64 /usr /usr/include/x86_64-linux-gnu/" - -# Variables to be set by this very own script. -MAXMIND_VERSION="" -MAXMIND_CFLAGS="" -MAXMIND_CPPFLAGS="" -MAXMIND_LDADD="" -MAXMIND_LDFLAGS="" - -AC_ARG_WITH( - maxmind, - AS_HELP_STRING( - [--with-maxmind=PATH], - [Path to MaxMind (including headers). Use 'no' to disable MaxMind support.] - ) -) - -# AS_HELP_STRING( -# [--without-maxmind], -# [Complete dsiables MaxMind support] -# ) - - -if test "x${with_maxmind}" == "xno"; then - AC_DEFINE(HAVE_MAXMIND, 0, [Support for MaxMind was disabled by the utilization of --without-maxmind or --with-maxmind=no]) - AC_MSG_NOTICE([Support for MaxMind was disabled by the utilization of --without-maxmind or --with-maxmind=no]) - MAXMIND_DISABLED=yes -else - if test "x${with_maxmind}" == "xyes"; then - MAXMIND_MANDATORY=yes - AC_MSG_NOTICE([MaxMind support was marked as mandatory by the utilization of --with-maxmind=yes]) - fi -# for x in ${MAXMIND_POSSIBLE_LIB_NAMES}; do -# CHECK_FOR_MAXMIND_AT(${x}) -# if test -n "${MAXMIND_VERSION}"; then -# break -# fi -# done - -# if test "x${with_maxmind}" != "xyes" or test "x${with_maxmind}" == "xyes"; then - if test "x${with_maxmind}" == "x" || test "x${with_maxmind}" == "xyes"; then - # Nothing about MaxMind was informed, using the pkg-config to figure things out. - if test -n "${PKG_CONFIG}"; then - MAXMIND_PKG_NAME="" - if ${PKG_CONFIG} --exists libmaxminddb; then - MAXMIND_PKG_NAME="libmaxminddb" - break - fi - fi - AC_MSG_NOTICE([Nothing about MaxMind was informed during the configure phase. Trying to detect it on the platform...]) - if test -n "${MAXMIND_PKG_NAME}"; then - # Package was found using the pkg-config scripts - MAXMIND_VERSION="`${PKG_CONFIG} ${MAXMIND_PKG_NAME} --modversion`" - MAXMIND_CFLAGS="`${PKG_CONFIG} ${MAXMIND_PKG_NAME} --cflags`" - MAXMIND_LDADD="`${PKG_CONFIG} ${MAXMIND_PKG_NAME} --libs-only-l`" - MAXMIND_LDFLAGS="`${PKG_CONFIG} ${MAXMIND_PKG_NAME} --libs-only-L --libs-only-other`" - MAXMIND_DISPLAY="${MAXMIND_LDADD}" - else - # If pkg-config did not find anything useful, go over file lookup. - for x in ${MAXMIND_POSSIBLE_PATHS}; do - CHECK_FOR_MAXMIND_AT(${x}) - if test -n "${MAXMIND_VERSION}"; then - break - fi - done - fi - fi - if test "x${with_maxmind}" != "x"; then - # An specific path was informed, lets check. - MAXMIND_MANDATORY=yes - CHECK_FOR_MAXMIND_AT(${with_maxmind}) - fi -# fi -fi - -if test -z "${MAXMIND_DISPLAY}"; then - if test -z "${MAXMIND_MANDATORY}"; then - if test -z "${MAXMIND_DISABLED}"; then - AC_MSG_NOTICE([MaxMind library was not found]) - MAXMIND_FOUND=0 - else - MAXMIND_FOUND=2 - fi - else - AC_MSG_ERROR([MaxMind was explicit requested but it was not found]) - MAXMIND_FOUND=-1 - fi -else - MAXMIND_FOUND=1 - AC_MSG_NOTICE([using MaxMind v${MAXMIND_VERSION}]) - MAXMIND_CFLAGS="-DWITH_MAXMIND ${MAXMIND_CFLAGS}" - if ! test "x$MAXMIND_CFLAGS" = "x"; then - MAXMIND_DISPLAY="${MAXMIND_DISPLAY}, ${MAXMIND_CFLAGS}" - fi - AC_SUBST(MAXMIND_VERSION) - AC_SUBST(MAXMIND_LDADD) - AC_SUBST(MAXMIND_LIBS) - AC_SUBST(MAXMIND_LDFLAGS) - AC_SUBST(MAXMIND_CFLAGS) - AC_SUBST(MAXMIND_DISPLAY) -fi - - - -AC_SUBST(MAXMIND_FOUND) - +MSC_CHECK_LIB([MAXMIND], [libmaxminddb], [maxminddb.h], [maxminddb], [-DWITH_MAXMIND]) ]) # AC_DEFUN [PROG_MAXMIND] - - -AC_DEFUN([CHECK_FOR_MAXMIND_AT], [ - path=$1 - for y in ${MAXMIND_POSSIBLE_EXTENSIONS}; do - for z in ${MAXMIND_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - maxmind_lib_path="${path}/" - maxmind_lib_name="${z}" - maxmind_lib_file="${maxmind_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - maxmind_lib_path="${path}/" - maxmind_lib_name="${z}" - maxmind_lib_file="${maxmind_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - maxmind_lib_path="${path}/lib/" - maxmind_lib_name="${z}" - maxmind_lib_file="${maxmind_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib64/lib${z}.${y}"; then - maxmind_lib_path="${path}/lib64/" - maxmind_lib_name="${z}" - maxmind_lib_file="${maxmind_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - maxmind_lib_path="${path}/lib/x86_64-linux-gnu/" - maxmind_lib_name="${z}" - maxmind_lib_file="${maxmind_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$maxmind_lib_path"; then - break - fi - done - if test -e "${path}/include/maxminddb.h"; then - maxmind_inc_path="${path}/include" - elif test -e "${path}/maxminddb.h"; then - maxmind_inc_path="${path}" - fi - - - if test -n "${maxmind_inc_path}" -a -n "${maxmind_lib_path}"; then - - AC_MSG_NOTICE([MaxMind headers found at: ${maxmind_inc_path}]) - AC_MSG_NOTICE([MaxMind library found at: ${maxmind_lib_file}]) - fi - - if test -n "${maxmind_lib_path}" -a -n "${maxmind_inc_path}"; then - # TODO: Compile a piece of code to check the version. - MAXMIND_CFLAGS="-I${maxmind_inc_path}" - MAXMIND_LDADD="-l${maxmind_lib_name}" - MAXMIND_LDFLAGS="-L${maxmind_lib_path}" - MAXMIND_DISPLAY="${maxmind_lib_file}, ${maxmind_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_MAXMIND_AT] diff --git a/build/libxml.m4 b/build/libxml.m4 index f10fd1f8d3..035b639d6f 100644 --- a/build/libxml.m4 +++ b/build/libxml.m4 @@ -1,135 +1,12 @@ dnl Check for LIBXML2 Libraries -dnl CHECK_LIBXML2(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) dnl Sets: dnl LIBXML2_CFLAGS -dnl LIBXML2_LIBS - -AC_DEFUN([CHECK_XML2CONFIG], [ - -AC_MSG_CHECKING([for libxml2 config script]) - -for x in ${test_paths}; do - dnl # Determine if the script was specified and use it directly - if test ! -d "$x" -a -e "$x"; then - LIBXML2_CONFIG=$x - libxml2_path="no" - break - fi - - dnl # Try known config script names/locations - for LIBXML2_CONFIG in xml2-config xml-2-config xml-config; do - if test -e "${x}/bin/${LIBXML2_CONFIG}"; then - libxml2_path="${x}/bin" - break - elif test -e "${x}/${LIBXML2_CONFIG}"; then - libxml2_path="${x}" - break - else - libxml2_path="" - fi - done - if test -n "$libxml2_path"; then - break - fi -done - -if test -n "${libxml2_path}"; then - if test "${libxml2_path}" != "no"; then - LIBXML2_CONFIG="${libxml2_path}/${LIBXML2_CONFIG}" - fi - AC_MSG_RESULT([${LIBXML2_CONFIG}]) - LIBXML2_VERSION=`${LIBXML2_CONFIG} --version | sed 's/^[[^0-9]][[^[:space:]]][[^[:space:]]]*[[[:space:]]]*//'` - if test ! -z "${LIBXML2_VERSION}"; then AC_MSG_NOTICE(xml VERSION: $LIBXML2_VERSION); fi - LIBXML2_CFLAGS="`${LIBXML2_CONFIG} --cflags` -DWITH_LIBXML2" - if test ! -z "${LIBXML2_CFLAGS}"; then AC_MSG_NOTICE(xml CFLAGS: $LIBXML2_CFLAGS); fi - LIBXML2_LDADD="`${LIBXML2_CONFIG} --libs`" - if test ! -z "${LIBXML2_LDADD}"; then AC_MSG_NOTICE(xml LDADD: $LIBXML2_LDADD); fi - - AC_MSG_CHECKING([if libxml2 is at least v${LIBXML2_MIN_VERSION}]) - libxml2_min_ver=`echo ${LIBXML2_MIN_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` - libxml2_ver=`echo ${LIBXML2_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'` - if test "$libxml2_ver" -ge "$libxml2_min_ver"; then - AC_MSG_RESULT([yes, $LIBXML2_VERSION]) - else - AC_MSG_RESULT([no, $LIBXML2_VERSION]) - AC_MSG_ERROR([NOTE: libxml2 library must be at least ${LIBXML2_MIN_VERSION}]) - fi - -else - AC_MSG_RESULT([no]) -fi -]) +dnl LIBXML2_LDADD +dnl LIBXML2_LDFLAGS +dnl LIBXML2_VERSION +dnl LIBXML2_DISPLAY +dnl LIBXML2_FOUND AC_DEFUN([CHECK_LIBXML2], [ - -AC_ARG_WITH( - libxml, - [AS_HELP_STRING([--with-libxml=PATH],[Path to libxml2 prefix or config script])], - [test_paths="${with_libxml}"], - [test_paths="/usr/local/libxml2 /usr/local/xml2 /usr/local/xml /usr/local /opt/libxml2 /opt/libxml /opt/xml2 /opt/xml /opt /usr"]) - -LIBXML2_MIN_VERSION="2.6.29" -LIBXML2_PKG_NAME="libxml-2.0" -LIBXML2_CONFIG="" -LIBXML2_VERSION="" -LIBXML2_CFLAGS="" -LIBXML2_CPPFLAGS="" -LIBXML2_LDADD="" -LIBXML2_LDFLAGS="" - -if test "x${with_libxml}" != "xno"; then - if test -n "${PKG_CONFIG}"; then - AC_MSG_CHECKING([for libxml2 >= ${LIBXML2_MIN_VERSION} via pkg-config]) - if `${PKG_CONFIG} --exists "${LIBXML2_PKG_NAME} >= ${LIBXML2_MIN_VERSION}"`; then - LIBXML2_VERSION="`${PKG_CONFIG} --modversion ${LIBXML2_PKG_NAME}`" - LIBXML2_CFLAGS="`${PKG_CONFIG} --cflags ${LIBXML2_PKG_NAME}` -DWITH_LIBXML2" - LIBXML2_LDADD="`${PKG_CONFIG} --libs-only-l ${LIBXML2_PKG_NAME}`" - LIBXML2_LDFLAGS="`${PKG_CONFIG} --libs-only-L --libs-only-other ${LIBXML2_PKG_NAME}`" - AC_MSG_RESULT([found version ${LIBXML2_VERSION}]) - else - AC_MSG_RESULT([not found]) - fi - fi - - if test -z "${LIBXML2_VERSION}"; then - CHECK_XML2CONFIG - fi -fi - -AC_SUBST(LIBXML2_CONFIG) -AC_SUBST(LIBXML2_VERSION) -AC_SUBST(LIBXML2_CFLAGS) -AC_SUBST(LIBXML2_CPPFLAGS) -AC_SUBST(LIBXML2_LDADD) -AC_SUBST(LIBXML2_LDFLAGS) - - -if test "x${with_libxml}" == "xno"; then - LIBXML2_DISABLED=yes -else - if test "x${with_libxml}" != "x"; then - LIBXML2_MANDATORY=yes - fi -fi - -if test -z "${LIBXML2_VERSION}"; then - AC_MSG_NOTICE([*** libxml2 library not found.]) - if test -z "${LIBXML2_MANDATORY}"; then - if test -z "${LIBXML2_DISABLED}"; then - LIBXML2_FOUND=0 - else - LIBXML2_FOUND=2 - fi - else - AC_MSG_ERROR([Libxml2 was explicitly referenced but it was not found]) - LIBXML2_FOUND=-1 - fi -else - LIBXML2_FOUND=1 - AC_MSG_NOTICE([using libxml2 v${LIBXML2_VERSION}]) - LIBXML2_DISPLAY="${LIBXML2_LDADD}, ${LIBXML2_CFLAGS}" -fi - -AC_SUBST(LIBXML2_FOUND) -AC_SUBST(LIBXML2_DISPLAY) -]) +MSC_CHECK_LIB([LIBXML2], [libxml-2.0], [libxml/parser.h], [xml2], [-DWITH_LIBXML2], [2.6.29], [libxml]) +]) # AC_DEFUN [CHECK_LIBXML2] diff --git a/build/lmdb.m4 b/build/lmdb.m4 index 1488617e3f..3b834074a1 100644 --- a/build/lmdb.m4 +++ b/build/lmdb.m4 @@ -1,180 +1,29 @@ dnl Check for LMDB Libraries -dnl CHECK_LMDB(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +dnl LMDB is disabled by default; only enabled when --with-lmdb is given. +dnl Sets: +dnl LMDB_CFLAGS +dnl LMDB_LDADD +dnl LMDB_LDFLAGS +dnl LMDB_VERSION +dnl LMDB_DISPLAY +dnl LMDB_FOUND AC_DEFUN([PROG_LMDB], [ -# Possible names for the lmdb library/package (pkg-config) -LMDB_POSSIBLE_LIB_NAMES="lmdb" - -# Possible extensions for the library -LMDB_POSSIBLE_EXTENSIONS="so so0 la sl dll dylib so.0.0.0" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -LMDB_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/liblmdb /usr/local/lmdb /usr/local /opt/liblmdb /opt/lmdb /opt /usr /usr/lib64 /opt/local" - -# Variables to be set by this very own script. -LMDB_VERSION="" -LMDB_CFLAGS="" -LMDB_CPPFLAGS="" -LMDB_LDADD="" -LMDB_LDFLAGS="" - -AC_ARG_WITH( - lmdb, - [AS_HELP_STRING([--with-lmdb=PATH],[Path to lmdb prefix or config script])] -) - -if test "x${with_lmdb}" == "xno"; then - AC_DEFINE(HAVE_LMDB, 0, [Support for LMDB was disabled by the utilization of --without-lmdb or --with-lmdb=no]) - AC_MSG_NOTICE([Support for LMDB was disabled by the utilization of --without-lmdb or --with-lmdb=no]) - LMDB_DISABLED=yes -else - if test "x${with_lmdb}" == "xyes"; then - LMDB_MANDATORY=yes - AC_MSG_NOTICE([LMDB support was marked as mandatory by the utilization of --with-lmdb=yes]) - fi -# for x in ${LMDB_POSSIBLE_LIB_NAMES}; do -# CHECK_FOR_LMDB_AT(${x}) -# if test -n "${LMDB_VERSION}"; then -# break -# fi -# done - -# if test "x${with_lmdb}" != "xyes" or test "x${with_lmdb}" == "xyes"; then - if test "x${with_lmdb}" == "x" || test "x${with_lmdb}" == "xyes"; then - # Nothing about LMDB was informed, using the pkg-config to figure things out. - if test -n "${PKG_CONFIG}"; then - LMDB_PKG_NAME="" - for x in ${LMDB_POSSIBLE_LIB_NAMES}; do - if ${PKG_CONFIG} --exists ${x}; then - LMDB_PKG_NAME="$x" - break - fi - done - fi - AC_MSG_NOTICE([Nothing about LMDB was informed during the configure phase. Trying to detect it on the platform...]) - if test -n "${LMDB_PKG_NAME}"; then - # Package was found using the pkg-config scripts - LMDB_VERSION="`${PKG_CONFIG} ${LMDB_PKG_NAME} --modversion`" - LMDB_CFLAGS="`${PKG_CONFIG} ${LMDB_PKG_NAME} --cflags`" - LMDB_LDADD="`${PKG_CONFIG} ${LMDB_PKG_NAME} --libs-only-l`" - LMDB_LDFLAGS="`${PKG_CONFIG} ${LMDB_PKG_NAME} --libs-only-L --libs-only-other`" - LMDB_DISPLAY="${LMDB_LDADD}, ${LMDB_CFLAGS}" - else - # If pkg-config did not find anything useful, go over file lookup. - for x in ${LMDB_POSSIBLE_PATHS}; do - CHECK_FOR_LMDB_AT(${x}) - if test -n "${LMDB_VERSION}"; then - break - fi - done - fi - fi - if test "x${with_lmdb}" != "x"; then - # An specific path was informed, lets check. - LMDB_MANDATORY=yes - CHECK_FOR_LMDB_AT(${with_lmdb}) - fi -# fi -fi - -if test -z "${LMDB_LDADD}"; then - if test -z "${LMDB_MANDATORY}"; then - if test -z "${LMDB_DISABLED}"; then - AC_MSG_NOTICE([LMDB library was not found]) - LMDB_FOUND=0 - else - LMDB_FOUND=2 - fi - else - AC_MSG_ERROR([LMDB was explicitly referenced but it was not found]) - LMDB_FOUND=-1 - fi -else - if test -z "${LMDB_MANDATORY}"; then - LMDB_FOUND=2 - AC_MSG_NOTICE([LMDB is disabled by default.]) - else - LMDB_FOUND=1 - AC_MSG_NOTICE([using LMDB v${LMDB_VERSION}]) - LMDB_CFLAGS="-DWITH_LMDB ${LMDB_CFLAGS}" - LMDB_DISPLAY="${LMDB_LDADD}, ${LMDB_CFLAGS}" - AC_SUBST(LMDB_VERSION) - AC_SUBST(LMDB_LDADD) - AC_SUBST(LMDB_LIBS) - AC_SUBST(LMDB_LDFLAGS) - AC_SUBST(LMDB_CFLAGS) - AC_SUBST(LMDB_DISPLAY) - fi +# LMDB is opt-in: auto-detect finds it but we only activate when +# --with-lmdb or --with-lmdb=PATH is given explicitly. +MSC_CHECK_LIB([LMDB], [lmdb], [lmdb.h], [lmdb], [-DWITH_LMDB]) + +# If LMDB was found by auto-detection (no explicit --with-lmdb) treat it +# as disabled since LMDB is opt-in. +_msc_lmdb_with_val="$with_lmdb" +if test "x${_msc_lmdb_with_val}" = "x" && test "x${LMDB_FOUND}" = "x1"; then + LMDB_FOUND=2 + LMDB_CFLAGS="" + LMDB_LDADD="" + LMDB_LDFLAGS="" + LMDB_DISPLAY="" + AC_MSG_NOTICE([LMDB is disabled by default. Use --with-lmdb to enable.]) fi - -AC_SUBST(LMDB_FOUND) - ]) # AC_DEFUN [PROG_LMDB] - - -AC_DEFUN([CHECK_FOR_LMDB_AT], [ - path=$1 - echo "*** LOOKING AT PATH: " ${path} - for y in ${LMDB_POSSIBLE_EXTENSIONS}; do - for z in ${LMDB_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - lmdb_lib_path="${path}/" - lmdb_lib_name="${z}" - lmdb_lib_file="${lmdb_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - lmdb_lib_path="${path}/" - lmdb_lib_name="${z}" - lmdb_lib_file="${lmdb_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - lmdb_lib_path="${path}/lib/" - lmdb_lib_name="${z}" - lmdb_lib_file="${lmdb_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - lmdb_lib_path="${path}/lib/x86_64-linux-gnu/" - lmdb_lib_name="${z}" - lmdb_lib_file="${lmdb_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/i386-linux-gnu/lib${z}.${y}"; then - lmdb_lib_path="${path}/lib/i386-linux-gnu/" - lmdb_lib_name="${z}" - lmdb_lib_file="${lmdb_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$lmdb_lib_path"; then - break - fi - done - if test -e "${path}/include/lmdb.h"; then - lmdb_inc_path="${path}/include" - elif test -e "${path}/lmdb.h"; then - lmdb_inc_path="${path}" - elif test -e "${path}/include/lmdb/lmdb.h"; then - lmdb_inc_path="${path}/include" - fi - - if test -n "${lmdb_lib_path}"; then - AC_MSG_NOTICE([LMDB library found at: ${lmdb_lib_file}]) - fi - - if test -n "${lmdb_inc_path}"; then - AC_MSG_NOTICE([LMDB headers found at: ${lmdb_inc_path}]) - fi - - if test -n "${lmdb_lib_path}" -a -n "${lmdb_inc_path}"; then - # TODO: Compile a piece of code to check the version. - LMDB_CFLAGS="-I${lmdb_inc_path}" - LMDB_LDADD="-l${lmdb_lib_name}" - LMDB_LDFLAGS="-L${lmdb_lib_path}" - LMDB_DISPLAY="${lmdb_lib_file}, ${lmdb_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_LMDB_AT] diff --git a/build/lua.m4 b/build/lua.m4 index c644ff8af3..a5c2c7782b 100644 --- a/build/lua.m4 +++ b/build/lua.m4 @@ -1,249 +1,98 @@ dnl Check for LUA Libraries -dnl CHECK_LUA(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) - - -AC_DEFUN([CHECK_LUA], -[dnl - -# Possible names for the lua library/package (pkg-config) -LUA_POSSIBLE_LIB_NAMES="lua54 lua5.4 lua-5.4 lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua" - -# Possible extensions for the library -LUA_POSSIBLE_EXTENSIONS="so la sl dll dylib" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -LUA_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/lib64 /usr/local/lua /usr/local/liblua /usr/local /opt /usr /usr/lib64 /opt/local /usr/lib/lua5.3/liblua /usr/lib/lua5.2/liblua" - -# Variables to be set by this very own script. -LUA_CFLAGS="" -LUA_LDFLAGS="" -LUA_LDADD="" -LUA_DISPLAY="" - -AC_ARG_WITH( - lua, - [AS_HELP_STRING([--with-lua=PATH],[Path to lua prefix])] -) - - -if test "x${with_lua}" == "xno"; then - AC_DEFINE(HAVE_LUA, 0, [Support for LUA was disabled by the utilization of --without-lua or --with-lua=no]) - AC_MSG_NOTICE([Support for LUA was disabled by the utilization of --without-lua or --with-lua=no]) - LUA_DISABLED=yes -else - if test "x${with_lua}" == "xyes"; then - LUA_MANDATORY=yes - AC_MSG_NOTICE([LUA support was marked as mandatory by the utilization of --with-lua=yes]) - else - LUA_MANDATORY=no - fi - for x in ${LUA_POSSIBLE_PATHS}; do - CHECK_FOR_LUA_AT(${x}) - if test -n "${LUA_CFLAGS}"; then - break - fi - done - if test -z "${LUA_CFLAGS}"; then - #Trying to figure out the version using pkg-config... - if test -n "${PKG_CONFIG}"; then - LUA_PKG_NAME="" - for x in ${LUA_POSSIBLE_LIB_NAMES}; do - if ${PKG_CONFIG} --exists ${x}; then - LUA_PKG_NAME="$x" - LUA_PKG_VERSION="`${PKG_CONFIG} ${LUA_PKG_NAME} --modversion`" - break - fi - done - fi - if test -n "${LUA_PKG_NAME}"; then - # Package was found using the pkg-config scripts - LUA_PKG_VERSION="`${PKG_CONFIG} ${LUA_PKG_NAME} --modversion`" - LUA_CFLAGS="`${PKG_CONFIG} ${LUA_PKG_NAME} --cflags`" - LUA_LDADD="`${PKG_CONFIG} ${LUA_PKG_NAME} --libs-only-l`" - LUA_LDFLAGS="`${PKG_CONFIG} ${LUA_PKG_NAME} --libs-only-L --libs-only-other`" - LUA_DISPLAY="${LUA_LDADD}, ${LUA_CFLAGS}" - case $LUA_PKG_VERSION in - (5.1*) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ; lua_5_1=1 ;; - (5.2*) LUA_CFLAGS="-DWITH_LUA_5_2 ${LUA_CFLAGS}" ; lua_5_2=1 ;; - (5.3*) LUA_CFLAGS="-DWITH_LUA_5_3 ${LUA_CFLAGS}" ; lua_5_3=1 ;; - (5.4*) LUA_CFLAGS="-DWITH_LUA_5_4 ${LUA_CFLAGS}" ; lua_5_4=1 ;; - (2.0*) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ; lua_5_1=1 ;; - (2.1*) LUA_CFLAGS="-DWITH_LUA_5_1 -DWITH_LUA_JIT_2_1 ${LUA_CFLAGS}" ; lua_5_1=1 ;; - esac - AC_MSG_NOTICE([LUA pkg-config version: ${LUA_PKG_VERSION}]) +dnl Sets: +dnl LUA_CFLAGS +dnl LUA_LDADD +dnl LUA_LDFLAGS +dnl LUA_DISPLAY +dnl LUA_FOUND + +AC_DEFUN([CHECK_LUA], [ +MSC_CHECK_LIB([LUA], [lua54 lua5.4 lua-5.4 lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 luajit lua], [lua.h], [lua5.4 lua5.3 lua5.2 lua5.1 luajit-5.1 lua], [-DWITH_LUA]) + +# Post-processing: detect Lua version and add version-specific defines +if test "x${LUA_FOUND}" = "x1"; then + LUA_VERSION="" + + # First, try to get version from pkg-config modversion + if test -n "${PKG_CONFIG}"; then + _msc_lua_pkg_name="" + for _msc_lua_p in lua54 lua5.4 lua-5.4 lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 luajit lua; do + if ${PKG_CONFIG} --exists ${_msc_lua_p} 2>/dev/null; then + _msc_lua_pkg_name="${_msc_lua_p}" + break + fi + done + if test -n "${_msc_lua_pkg_name}"; then + _msc_lua_pkg_version="`${PKG_CONFIG} ${_msc_lua_pkg_name} --modversion`" + case $_msc_lua_pkg_version in + 5.1*) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + 5.2*) LUA_CFLAGS="-DWITH_LUA_5_2 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + 5.3*) LUA_CFLAGS="-DWITH_LUA_5_3 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + 5.4*) LUA_CFLAGS="-DWITH_LUA_5_4 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + 2.0*) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + 2.1*) LUA_CFLAGS="-DWITH_LUA_5_1 -DWITH_LUA_JIT_2_1 ${LUA_CFLAGS}" ; LUA_VERSION="${_msc_lua_pkg_version}" ;; + esac + AC_MSG_NOTICE([LUA pkg-config version: ${_msc_lua_pkg_version}]) fi fi -fi - -if test -z "${LUA_CFLAGS}"; then - if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" == "xno"; then - if test -z "${LUA_DISABLED}"; then - AC_MSG_NOTICE([LUA library was not found]) - LUA_FOUND=0 - else - LUA_FOUND=2 + # If no version detected via pkg-config, try compile tests + if test -z "${LUA_VERSION}"; then + _msc_save_CFLAGS=$CFLAGS + CFLAGS="${LUA_CFLAGS} ${CFLAGS}" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], + [[ #if (LUA_VERSION_NUM == 504) + return 0; + #else + #error not 5.4 + #endif ]])], + [ _msc_lua_ver=504 ], [ _msc_lua_ver="" ]) + + if test -z "$_msc_lua_ver"; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], + [[ #if (LUA_VERSION_NUM == 503) + return 0; + #else + #error not 5.3 + #endif ]])], + [ _msc_lua_ver=503 ], [ _msc_lua_ver="" ]) fi - else - AC_MSG_ERROR([LUA was explicitly referenced but it was not found]) - LUA_FOUND=-1 - fi -else - if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" == "xno"; then - LUA_FOUND=1 - AC_MSG_NOTICE([using LUA ${LUA_LDADD}]) - LUA_CFLAGS="-DWITH_LUA ${LUA_CFLAGS}" - LUA_DISPLAY="${LUA_LDADD} ${LUA_LDFLAGS}, ${LUA_CFLAGS}" - AC_SUBST(LUA_LDFLAGS) - AC_SUBST(LUA_LDADD) - AC_SUBST(LUA_CFLAGS) - AC_SUBST(LUA_DISPLAY) - else - LUA_FOUND=1 - AC_MSG_NOTICE([using LUA ${LUA_LDADD}]) - LUA_CFLAGS="-DWITH_LUA ${LUA_CFLAGS}" - LUA_DISPLAY="${LUA_LDADD} ${LUA_LDFLAGS}, ${LUA_CFLAGS}" - AC_SUBST(LUA_LDFLAGS) - AC_SUBST(LUA_LDADD) - AC_SUBST(LUA_CFLAGS) - AC_SUBST(LUA_DISPLAY) - fi -fi - -AC_SUBST(LUA_FOUND) -]) # AC_DEFUN [CHECK_LUA] - - -AC_DEFUN([CHECK_FOR_LUA_AT], [ - path=$1 - echo "*** LOOKING AT PATH: " ${path} - for y in ${LUA_POSSIBLE_EXTENSIONS}; do - for z in ${LUA_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - lua_lib_path="${path}/" - lua_lib_name="${z}" - lua_lib_file="${lua_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - lua_lib_path="${path}/" - lua_lib_name="${z}" - lua_lib_file="${lua_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - lua_lib_path="${path}/lib/" - lua_lib_name="${z}" - lua_lib_file="${lua_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - lua_lib_path="${path}/lib/x86_64-linux-gnu/" - lua_lib_name="${z}" - lua_lib_file="${lua_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/i386-linux-gnu/lib${z}.${y}"; then - lua_lib_path="${path}/lib/i386-linux-gnu/" - lua_lib_name="${z}" - lua_lib_file="${lua_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$lua_lib_path"; then - break - fi - done - if test -e "${path}/include/lua.h"; then - lua_inc_path="${path}/include" - elif test -e "${path}/lua.h"; then - lua_inc_path="${path}" - elif test -e "${path}/include/lua/lua.h"; then - lua_inc_path="${path}/include/lua" - elif test -e "${path}/include/lua5.4/lua.h"; then - lua_inc_path="${path}/include/lua5.4" - LUA_VERSION=504 - elif test -e "${path}/include/lua5.3/lua.h"; then - lua_inc_path="${path}/include/lua5.3" - LUA_VERSION=503 - elif test -e "${path}/include/lua5.2/lua.h"; then - lua_inc_path="${path}/include/lua5.2" - LUA_VERSION=502 - elif test -e "${path}/include/lua5.1/lua.h"; then - lua_inc_path="${path}/include/lua5.1" - LUA_VERSION=501 - elif test -e "${path}/include/luajit-2.0/lua.h"; then - lua_inc_path="${path}/include/luajit-2.0" - LUA_VERSION=501 - fi - - if test -n "${lua_lib_path}"; then - AC_MSG_NOTICE([LUA library found at: ${lua_lib_file}]) - fi - - if test -n "${lua_inc_path}"; then - AC_MSG_NOTICE([LUA headers found at: ${lua_inc_path}]) - fi - if test -n "${lua_lib_path}" -a -n "${lua_inc_path}"; then - LUA_CFLAGS="-I${lua_inc_path}" - LUA_LDADD="-l${lua_lib_name}" - LUA_LDFLAGS="-L${lua_lib_path}" - LUA_DISPLAY="${lua_lib_file}, ${lua_inc_path}" - - # Double checking version from lua.h... - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ], - [ #if (LUA_VERSION_NUM == 502) - return 0; - #else - #error Lua 5.2 not detected - #endif ]])], - [ LUA_VERSION=502 ], [ lua_5_2=0 ] - ) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ], - [ #if (LUA_VERSION_NUM == 502) - return 0; - #else - #error Lua 5.2 not detected - #endif ]])], - [ LUA_VERSION=502 ], [ lua_5_2=0 ] - ) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ], - [ #if (LUA_VERSION_NUM == 504) - return 0; - #else - #error Lua 5.4 not detected - #endif ]])], - [ LUA_VERSION=504 ], [ lua_5_4=0 ] - ) + if test -z "$_msc_lua_ver"; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], + [[ #if (LUA_VERSION_NUM == 502) + return 0; + #else + #error not 5.2 + #endif ]])], + [ _msc_lua_ver=502 ], [ _msc_lua_ver="" ]) + fi - if test -z "${LUA_VERSION}" ; then - # As a last resort, try to find LUA version from $lua_inc_path - while read -r line - do - case "$line" in - (\#define\ LUA_VERSION_NUM*501*) LUA_VERSION=501 ;; - (\#define\ LUA_VERSION_NUM*502*) LUA_VERSION=502 ;; - (\#define\ LUA_VERSION_NUM*503*) LUA_VERSION=503 ;; - (\#define\ LUA_VERSION_NUM*504*) LUA_VERSION=504 - esac - done <"${lua_inc_path}/lua.h" - AC_MSG_NOTICE([LUA_VERSION is ${LUA_VERSION} found at: ${lua_inc_path}]) - else - AC_MSG_NOTICE([LUA version from includes: ${LUA_VERSION}]) + if test -z "$_msc_lua_ver"; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], + [[ #if (LUA_VERSION_NUM == 501) + return 0; + #else + #error not 5.1 + #endif ]])], + [ _msc_lua_ver=501 ], [ _msc_lua_ver="" ]) fi - case $LUA_VERSION in - (501) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ; lua_5_1=1 ;; - (502) LUA_CFLAGS="-DWITH_LUA_5_2 ${LUA_CFLAGS}" ; lua_5_2=1 ;; - (503) LUA_CFLAGS="-DWITH_LUA_5_3 ${LUA_CFLAGS}" ; lua_5_3=1 ;; - (504) LUA_CFLAGS="-DWITH_LUA_5_4 ${LUA_CFLAGS}" ; lua_5_4=1 ;; + CFLAGS=$_msc_save_CFLAGS + + case $_msc_lua_ver in + 501) LUA_CFLAGS="-DWITH_LUA_5_1 ${LUA_CFLAGS}" ;; + 502) LUA_CFLAGS="-DWITH_LUA_5_2 ${LUA_CFLAGS}" ;; + 503) LUA_CFLAGS="-DWITH_LUA_5_3 ${LUA_CFLAGS}" ;; + 504) LUA_CFLAGS="-DWITH_LUA_5_4 ${LUA_CFLAGS}" ;; esac + if test -n "$_msc_lua_ver"; then + AC_MSG_NOTICE([LUA version from compile test: $_msc_lua_ver]) + fi fi -]) # AC_DEFUN [CHECK_FOR_LUA_AT] - - + LUA_DISPLAY="${LUA_LDADD} ${LUA_LDFLAGS}, ${LUA_CFLAGS}" +fi +]) # AC_DEFUN [CHECK_LUA] diff --git a/build/msc_find_lib.m4 b/build/msc_find_lib.m4 new file mode 100644 index 0000000000..77fdb38d38 --- /dev/null +++ b/build/msc_find_lib.m4 @@ -0,0 +1,266 @@ +dnl MSC_CHECK_LIB: Generic library detection macro +dnl +dnl MSC_CHECK_LIB(NAME, PKG_NAMES, HEADER, LIB_NAMES, EXTRA_CFLAGS, +dnl [MIN_VERSION], [WITH_NAME]) +dnl +dnl Detects a library via pkg-config first, then falls back to manual +dnl file-system scanning. Preserves the --with-LIB=PATH|yes|no interface. +dnl +dnl Sets and AC_SUBSTs: +dnl ${NAME}_CFLAGS, ${NAME}_LDADD, ${NAME}_LDFLAGS, +dnl ${NAME}_VERSION, ${NAME}_DISPLAY, ${NAME}_FOUND (0/1/2) +dnl +dnl NAME - Variable prefix (e.g., YAJL, CURL, LIBXML2) +dnl PKG_NAMES - Space-separated pkg-config names to try +dnl HEADER - Header file to look for (e.g., yajl/yajl_parse.h) +dnl LIB_NAMES - Space-separated library names for -l flags +dnl EXTRA_CFLAGS - Additional CFLAGS when found (e.g., -DWITH_YAJL) +dnl MIN_VERSION - Optional minimum version for pkg-config check +dnl WITH_NAME - Optional --with-X name if different from lowercased NAME + +AC_DEFUN([MSC_CHECK_LIB], [ +m4_pushdef([_MSC_NAME], [$1])dnl +m4_pushdef([_MSC_PKG_NAMES], [$2])dnl +m4_pushdef([_MSC_HEADER], [$3])dnl +m4_pushdef([_MSC_LIB_NAMES], [$4])dnl +m4_pushdef([_MSC_EXTRA_CFLAGS], [$5])dnl +m4_pushdef([_MSC_MIN_VERSION], [$6])dnl +m4_pushdef([_MSC_WITH_NAME], [m4_default([$7], m4_tolower([$1]))])dnl +m4_pushdef([_MSC_POSSIBLE_PATHS], [/usr/local /usr /opt /opt/local /usr/lib /usr/local/lib /usr/lib64])dnl +m4_pushdef([_MSC_POSSIBLE_EXTENSIONS], [so la sl dll dylib])dnl + +# Initialize variables +$1_VERSION="" +$1_CFLAGS="" +$1_LDADD="" +$1_LDFLAGS="" +$1_DISPLAY="" +$1_FOUND=0 +_msc_[]m4_tolower($1)[]_mandatory="" +_msc_[]m4_tolower($1)[]_disabled="" + +AC_ARG_WITH( + _MSC_WITH_NAME, + [AS_HELP_STRING([--with-]_MSC_WITH_NAME[=PATH], + [Path to ]_MSC_NAME[ prefix. Use 'no' to disable.])]) + +# Get the value of the --with flag +_msc_with_val="$with_[]m4_translit(_MSC_WITH_NAME, [-], [_])" + +if test "x${_msc_with_val}" = "xno"; then + AC_MSG_NOTICE([$1 support disabled via --without-]_MSC_WITH_NAME) + _msc_[]m4_tolower($1)[]_disabled=yes +elif test "x${_msc_with_val}" = "xyes"; then + _msc_[]m4_tolower($1)[]_mandatory=yes + AC_MSG_NOTICE([$1 support marked as mandatory]) + # Try pkg-config + _MSC_TRY_PKG_CONFIG([$1], [_MSC_PKG_NAMES], [_MSC_MIN_VERSION]) + if test -z "${$1_VERSION}"; then + _MSC_TRY_MANUAL([$1], [_MSC_HEADER], [_MSC_LIB_NAMES]) + fi +elif test "x${_msc_with_val}" = "x"; then + # Auto-detect + AC_MSG_NOTICE([Auto-detecting $1...]) + _MSC_TRY_PKG_CONFIG([$1], [_MSC_PKG_NAMES], [_MSC_MIN_VERSION]) + if test -z "${$1_VERSION}"; then + _MSC_TRY_MANUAL([$1], [_MSC_HEADER], [_MSC_LIB_NAMES]) + fi +else + # Specific path provided + _msc_[]m4_tolower($1)[]_mandatory=yes + _MSC_TRY_PKG_CONFIG_AT([$1], [_MSC_PKG_NAMES], [_MSC_MIN_VERSION], [${_msc_with_val}]) + if test -z "${$1_VERSION}"; then + _MSC_CHECK_AT([$1], [_MSC_HEADER], [_MSC_LIB_NAMES], [${_msc_with_val}]) + fi +fi + +# Evaluate results +if test -n "${$1_LDADD}" || test -n "${$1_VERSION}"; then + $1_FOUND=1 + AC_MSG_NOTICE([using $1 v${$1_VERSION}]) + $1_CFLAGS="_MSC_EXTRA_CFLAGS ${$1_CFLAGS}" + if test -z "${$1_DISPLAY}"; then + $1_DISPLAY="${$1_LDADD}, ${$1_CFLAGS}" + fi + AC_SUBST($1_VERSION) + AC_SUBST($1_LDADD) + AC_SUBST($1_LDFLAGS) + AC_SUBST($1_CFLAGS) + AC_SUBST($1_DISPLAY) +elif test -n "${_msc_[]m4_tolower($1)[]_disabled}"; then + $1_FOUND=2 +elif test -n "${_msc_[]m4_tolower($1)[]_mandatory}"; then + AC_MSG_ERROR([$1 was explicitly requested but not found]) +else + AC_MSG_NOTICE([$1 library not found]) + $1_FOUND=0 +fi + +AC_SUBST($1_FOUND) + +m4_popdef([_MSC_POSSIBLE_EXTENSIONS])dnl +m4_popdef([_MSC_POSSIBLE_PATHS])dnl +m4_popdef([_MSC_WITH_NAME])dnl +m4_popdef([_MSC_MIN_VERSION])dnl +m4_popdef([_MSC_EXTRA_CFLAGS])dnl +m4_popdef([_MSC_LIB_NAMES])dnl +m4_popdef([_MSC_HEADER])dnl +m4_popdef([_MSC_PKG_NAMES])dnl +m4_popdef([_MSC_NAME])dnl +]) # MSC_CHECK_LIB + + +dnl _MSC_TRY_PKG_CONFIG(NAME, PKG_NAMES, MIN_VERSION) +dnl Try to find the library via pkg-config +AC_DEFUN([_MSC_TRY_PKG_CONFIG], [ +if test -n "${PKG_CONFIG}"; then + _msc_pkg_name="" + for _msc_p in $2; do + if test -n "$3"; then + if ${PKG_CONFIG} --exists "${_msc_p} >= $3" 2>/dev/null; then + _msc_pkg_name="${_msc_p}" + break + fi + else + if ${PKG_CONFIG} --exists "${_msc_p}" 2>/dev/null; then + _msc_pkg_name="${_msc_p}" + break + fi + fi + done + if test -n "${_msc_pkg_name}"; then + $1_VERSION="`${PKG_CONFIG} ${_msc_pkg_name} --modversion`" + $1_CFLAGS="`${PKG_CONFIG} ${_msc_pkg_name} --cflags`" + $1_LDADD="`${PKG_CONFIG} ${_msc_pkg_name} --libs-only-l`" + $1_LDFLAGS="`${PKG_CONFIG} ${_msc_pkg_name} --libs-only-L --libs-only-other`" + $1_DISPLAY="${$1_LDADD}, ${$1_CFLAGS}" + AC_MSG_NOTICE([$1 found via pkg-config: ${_msc_pkg_name} v${$1_VERSION}]) + fi +fi +]) # _MSC_TRY_PKG_CONFIG + + +dnl _MSC_TRY_PKG_CONFIG_AT(NAME, PKG_NAMES, MIN_VERSION, PATH) +dnl Try pkg-config with PKG_CONFIG_PATH set to a specific location +AC_DEFUN([_MSC_TRY_PKG_CONFIG_AT], [ +if test -n "${PKG_CONFIG}"; then + _msc_save_pkg_config_path="${PKG_CONFIG_PATH}" + PKG_CONFIG_PATH="$4/lib/pkgconfig:$4/lib64/pkgconfig:$4/share/pkgconfig:${PKG_CONFIG_PATH}" + export PKG_CONFIG_PATH + _MSC_TRY_PKG_CONFIG([$1], [$2], [$3]) + PKG_CONFIG_PATH="${_msc_save_pkg_config_path}" + export PKG_CONFIG_PATH +fi +]) # _MSC_TRY_PKG_CONFIG_AT + + +dnl _MSC_TRY_MANUAL(NAME, HEADER, LIB_NAMES) +dnl Try to find the library by scanning common paths +AC_DEFUN([_MSC_TRY_MANUAL], [ +for _msc_search_path in /usr/local /usr /opt /opt/local /usr/lib /usr/local/lib /usr/lib64; do + _MSC_CHECK_AT([$1], [$2], [$3], [${_msc_search_path}]) + if test -n "${$1_VERSION}"; then + break + fi + # Also check if LDADD was set (version may not always be detected manually) + if test -n "${$1_LDADD}"; then + break + fi +done +]) # _MSC_TRY_MANUAL + + +dnl _MSC_CHECK_AT(NAME, HEADER, LIB_NAMES, PATH) +dnl Check for a library at a specific path +AC_DEFUN([_MSC_CHECK_AT], [ +_msc_check_lib_path="" +_msc_check_lib_name="" +_msc_check_lib_file="" +_msc_check_inc_path="" + +# Search for library files +for _msc_ext in so la sl dll dylib; do + for _msc_ln in $3; do + for _msc_try_path in \ + "$4/lib${_msc_ln}.${_msc_ext}" \ + "$4/lib/lib${_msc_ln}.${_msc_ext}" \ + "$4/lib64/lib${_msc_ln}.${_msc_ext}" \ + "$4/lib/x86_64-linux-gnu/lib${_msc_ln}.${_msc_ext}" \ + "$4/lib/i386-linux-gnu/lib${_msc_ln}.${_msc_ext}"; do + if test -e "${_msc_try_path}"; then + _msc_check_lib_path="`dirname ${_msc_try_path}`" + _msc_check_lib_name="${_msc_ln}" + _msc_check_lib_file="${_msc_try_path}" + break 3 + fi + done + done +done + +# Search for header file +_msc_header_base="`basename $2`" +_msc_header_dir="`dirname $2`" +if test "${_msc_header_dir}" = "."; then + # Simple header name (e.g., "lmdb.h") + if test -e "$4/include/$2"; then + _msc_check_inc_path="$4/include" + elif test -e "$4/$2"; then + _msc_check_inc_path="$4" + fi +else + # Header with subdirectory (e.g., "yajl/yajl_parse.h") + if test -e "$4/include/$2"; then + _msc_check_inc_path="$4/include" + elif test -e "$4/$2"; then + _msc_check_inc_path="$4" + fi +fi + +if test -n "${_msc_check_lib_path}" && test -n "${_msc_check_inc_path}"; then + AC_MSG_NOTICE([$1 headers found at: ${_msc_check_inc_path}]) + AC_MSG_NOTICE([$1 library found at: ${_msc_check_lib_file}]) + $1_CFLAGS="-I${_msc_check_inc_path}" + $1_LDADD="-l${_msc_check_lib_name}" + $1_LDFLAGS="-L${_msc_check_lib_path}" + $1_DISPLAY="${_msc_check_lib_file}, ${_msc_check_inc_path}" + # Version is unknown from manual detection + if test -z "${$1_VERSION}"; then + $1_VERSION="unknown" + fi +fi +]) # _MSC_CHECK_AT + + +dnl MSC_STATUS_LIB(DISPLAY_NAME, VAR_PREFIX) +dnl Print a status line for the configure summary +AC_DEFUN([MSC_STATUS_LIB], [ +if test "x${$2_FOUND}" = "x0"; then + echo " + $1 ....not found" +fi +if test "x${$2_FOUND}" = "x1"; then + AS_ECHO_N([" + $1 ....found "]) + if ! test "x${$2_VERSION}" = "x"; then + echo "v${$2_VERSION}" + else + echo "" + fi + echo " ${$2_DISPLAY}" +fi +if test "x${$2_FOUND}" = "x2"; then + echo " + $1 ....disabled" +fi +]) # MSC_STATUS_LIB + + +dnl MSC_ARG_ENABLE_BOOL(NAME, HELP_TEXT, DEFAULT, VARIABLE) +dnl Wrapper for boolean AC_ARG_ENABLE options +AC_DEFUN([MSC_ARG_ENABLE_BOOL], [ +AC_ARG_ENABLE($1, + [AS_HELP_STRING([--enable-$1],[$2])], + [case "${enableval}" in + yes) $4=true ;; + no) $4=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-$1]) ;; + esac], + [$4=$3]) +]) # MSC_ARG_ENABLE_BOOL diff --git a/build/pcre.m4 b/build/pcre.m4 index de28e8b889..90454a5edc 100644 --- a/build/pcre.m4 +++ b/build/pcre.m4 @@ -1,8 +1,10 @@ dnl Check for PCRE Libraries -dnl CHECK_PCRE(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) dnl Sets: dnl PCRE_CFLAGS -dnl PCRE_LIBS +dnl PCRE_LDADD +dnl PCRE_LDFLAGS +dnl PCRE_VERSION +dnl PCRE_FOUND PCRE_CONFIG="" PCRE_VERSION="" @@ -12,116 +14,39 @@ PCRE_LDFLAGS="" PCRE_LDADD="" PCRE_LD_PATH="" -AC_DEFUN([CHECK_PCRE], -[dnl - -AC_ARG_WITH( - pcre, - [AS_HELP_STRING([--with-pcre=PATH],[Path to pcre prefix or config script])], - [test_paths="${with_pcre}"], - [test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr /opt/local"]) - -if test "x${with_pcre}" == "x" && test "x${with_pcre}" != "xno"; then - AC_MSG_NOTICE([Support for pcre not requested; omitting check for pcre]) -else - - AC_MSG_CHECKING([for libpcre config script]) - - AC_CHECK_PROG([PCRE_CONFIG_IN_ENV], [pcre-config], [yes], [no]) - - if test "$PCRE_CONFIG_IN_ENV" = "yes"; then - AC_MSG_NOTICE([pcre-config found in envinronment]) - - PCRE_CONFIG=pcre-config - pcre_path="no" - else - AC_MSG_NOTICE([pcre-config not found in environment. checking known paths]) - - for x in ${test_paths}; do - dnl # Determine if the script was specified and use it directly - if test ! -d "$x" -a -e "$x"; then - PCRE_CONFIG=$x - pcre_path="no" - break - fi - - dnl # Try known config script names/locations - for PCRE_CONFIG in pcre-config; do - if test -e "${x}/bin/${PCRE_CONFIG}"; then - pcre_path="${x}/bin" - break - elif test -e "${x}/${PCRE_CONFIG}"; then - pcre_path="${x}" - break - else - pcre_path="" - fi - done - if test -n "$pcre_path"; then - break - fi - done - fi - - if test -n "${pcre_path}"; then - if test "${pcre_path}" != "no"; then - PCRE_CONFIG="${pcre_path}/${PCRE_CONFIG}" - fi - AC_MSG_RESULT([${PCRE_CONFIG}]) - PCRE_VERSION="`${PCRE_CONFIG} --version`" - if test ! -z "${PCRE_VERSION}"; then AC_MSG_NOTICE(pcre VERSION: $PCRE_VERSION); fi - PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" - if test ! -z "${PCRE_CFLAGS}"; then AC_MSG_NOTICE(pcre CFLAGS: $PCRE_CFLAGS); fi - PCRE_LDADD="`${PCRE_CONFIG} --libs`" - if test ! -z "${PCRE_LDADD}"; then AC_MSG_NOTICE(pcre LDADD: $PCRE_LDADD); fi - PCRE_LD_PATH="/`${PCRE_CONFIG} --libs | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`" - if test ! -z "${PCRE_LD_PATH}"; then AC_MSG_NOTICE(pcre PCRE_LD_PATH: $PCRE_LD_PATH); fi +AC_DEFUN([CHECK_PCRE], [ +MSC_CHECK_LIB([PCRE], [libpcre], [pcre.h], [pcre], [-DWITH_PCRE]) + +# Post-processing: JIT detection +if test "x${PCRE_FOUND}" = "x1" && test -n "${PCRE_VERSION}"; then + AC_MSG_CHECKING([for PCRE JIT]) + _msc_save_CFLAGS=$CFLAGS + _msc_save_LDFLAGS=$LDFLAGS + _msc_save_LIBS=$LIBS + CFLAGS="${PCRE_CFLAGS} ${CFLAGS}" + LDFLAGS="${PCRE_LDADD} ${LDFLAGS}" + LIBS="${PCRE_LDADD} ${LIBS}" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ #include ]], + [[ pcre_jit_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL); ]])], + [ _msc_pcre_jit_available=yes ], + [:] + ) + if test "x$_msc_pcre_jit_available" = "xyes"; then + AC_MSG_RESULT([yes]) + PCRE_CFLAGS="${PCRE_CFLAGS} -DPCRE_HAVE_JIT" else AC_MSG_RESULT([no]) fi + CFLAGS=$_msc_save_CFLAGS + LDFLAGS=$_msc_save_LDFLAGS + LIBS=$_msc_save_LIBS - if test -n "${PCRE_VERSION}"; then - AC_MSG_CHECKING(for PCRE JIT) - save_CFLAGS=$CFLAGS - save_LDFLAGS=$LDFLAGS - save_LIBS=$LIBS - CFLAGS="${PCRE_CFLAGS} ${CFLAGS}" - LDFLAGS="${PCRE_LDADD} ${LDFLAGS}" - LIBS="${PCRE_LDADD} ${LIBS}" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ #include ]], - [[ pcre_jit_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL); ]])], - [ pcre_jit_available=yes ], - [:] - ) - - if test "x$pcre_jit_available" = "xyes"; then - AC_MSG_RESULT(yes) - PCRE_CFLAGS="${PCRE_CFLAGS} -DPCRE_HAVE_JIT" - else - AC_MSG_RESULT(no) - fi - CFLAGS=$save_CFLAGS - LDFLAGS=$save_LDFLAGS - LIBS=$save_LIBS - fi + PCRE_LDADD="${PCRE_LDADD} -lpcre" +fi - PCRE_CFLAGS="-DWITH_PCRE ${PCRE_CFLAGS}" - AC_SUBST(PCRE_CONFIG) - AC_SUBST(PCRE_VERSION) - AC_SUBST(PCRE_CPPFLAGS) - AC_SUBST(PCRE_CFLAGS) - AC_SUBST(PCRE_LDFLAGS) - AC_SUBST(PCRE_LDADD) - AC_SUBST(PCRE_LD_PATH) +AC_SUBST(PCRE_CONFIG) +AC_SUBST(PCRE_CPPFLAGS) +AC_SUBST(PCRE_LD_PATH) - if test -z "${PCRE_VERSION}"; then - AC_MSG_NOTICE([*** pcre library not found.]) - ifelse([$2], , AC_MSG_ERROR([pcre library is required]), $2) - else - AC_MSG_NOTICE([using pcre v${PCRE_VERSION}]) - ifelse([$1], , , $1) - PCRE_LDADD="${PCRE_LDADD} -lpcre" - fi -fi -]) +]) # AC_DEFUN [CHECK_PCRE] diff --git a/build/pcre2.m4 b/build/pcre2.m4 index aaa4f8a1d2..c441a61155 100644 --- a/build/pcre2.m4 +++ b/build/pcre2.m4 @@ -1,187 +1,13 @@ dnl Check for PCRE2 Libraries -dnl CHECK_PCRE2(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +dnl PCRE2 is enabled by default (mandatory unless --with-pcre is used). +dnl Sets: +dnl PCRE2_CFLAGS +dnl PCRE2_LDADD +dnl PCRE2_LDFLAGS +dnl PCRE2_VERSION +dnl PCRE2_DISPLAY +dnl PCRE2_FOUND AC_DEFUN([PROG_PCRE2], [ - -# Possible names for the pcre2 library/package (pkg-config) -PCRE2_POSSIBLE_LIB_NAMES="pcre2 pcre2-8 libpcre2-8" - -# Possible extensions for the library -PCRE2_POSSIBLE_EXTENSIONS="so so0 la sl dll dylib so.0.0.0" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -PCRE2_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/libpcre2-8 /usr/local/pcre2 /usr/local /opt/libpcre2-8 /opt/pcre2 /opt /usr /usr/lib64 /opt/local" - -# Variables to be set by this very own script. -PCRE2_VERSION="" -PCRE2_CFLAGS="" -PCRE2_CPPFLAGS="" -PCRE2_LDADD="" -PCRE2_LDFLAGS="" - -AC_ARG_WITH( - pcre2, - [AS_HELP_STRING([--with-pcre2=PATH],[Path to pcre2 prefix or config script])] -) - -if test "x${with_pcre2}" == "xno"; then - AC_DEFINE(HAVE_PCRE2, 0, [Support for PCRE2 was disabled by the utilization of --without-pcre2 or --with-pcre2=no]) - AC_MSG_NOTICE([Support for PCRE2 was disabled by the utilization of --without-pcre2 or --with-pcre2=no]) - PCRE2_DISABLED=yes -else - PCRE2_MANDATORY=yes - AC_MSG_NOTICE([PCRE2 is enabled by default.]) -# if test "x${with_pcre2}" == "xyes"; then -# PCRE2_MANDATORY=yes -# AC_MSG_NOTICE([PCRE2 support was marked as mandatory by the utilization of --with-pcre2=yes]) -# fi -# for x in ${PCRE2_POSSIBLE_LIB_NAMES}; do -# CHECK_FOR_PCRE2_AT(${x}) -# if test -n "${PCRE2_VERSION}"; then -# break -# fi -# done - -# if test "x${with_pcre2}" != "xyes" or test "x${with_pcre2}" == "xyes"; then - if test "x${with_pcre2}" == "x" || test "x${with_pcre2}" == "xyes"; then - # Nothing about PCRE2 was informed, using the pkg-config to figure things out. - if test -n "${PKG_CONFIG}"; then - PCRE2_PKG_NAME="" - for x in ${PCRE2_POSSIBLE_LIB_NAMES}; do - if ${PKG_CONFIG} --exists ${x}; then - PCRE2_PKG_NAME="$x" - break - fi - done - fi - AC_MSG_NOTICE([Nothing about PCRE2 was informed during the configure phase. Trying to detect it on the platform...]) - if test -n "${PCRE2_PKG_NAME}"; then - # Package was found using the pkg-config scripts - PCRE2_VERSION="`${PKG_CONFIG} ${PCRE2_PKG_NAME} --modversion`" - PCRE2_CFLAGS="`${PKG_CONFIG} ${PCRE2_PKG_NAME} --cflags`" - PCRE2_LDADD="`${PKG_CONFIG} ${PCRE2_PKG_NAME} --libs-only-l`" - PCRE2_LDFLAGS="`${PKG_CONFIG} ${PCRE2_PKG_NAME} --libs-only-L --libs-only-other`" - PCRE2_DISPLAY="${PCRE2_LDADD}, ${PCRE2_CFLAGS}" - else - # If pkg-config did not find anything useful, go over file lookup. - for x in ${PCRE2_POSSIBLE_PATHS}; do - CHECK_FOR_PCRE2_AT(${x}) - if test -n "${PCRE2_VERSION}"; then - break - fi - done - fi - fi - if test "x${with_pcre2}" != "x"; then - # An specific path was informed, lets check. - PCRE2_MANDATORY=yes - CHECK_FOR_PCRE2_AT(${with_pcre2}) - fi -# fi -fi - -if test -z "${PCRE2_LDADD}"; then - if test -z "${PCRE2_MANDATORY}"; then - if test -z "${PCRE2_DISABLED}"; then - AC_MSG_NOTICE([PCRE2 library was not found]) - PCRE2_FOUND=0 - else - PCRE2_FOUND=2 - fi - else - AC_MSG_ERROR([PCRE2 was explicitly referenced but it was not found]) - PCRE2_FOUND=-1 - fi -else - if test -z "${PCRE2_MANDATORY}"; then - PCRE2_FOUND=2 - AC_MSG_NOTICE([PCRE2 is disabled by default.]) - else - PCRE2_FOUND=1 - PCRE2_CFLAGS="${PCRE2_CFLAGS}" - PCRE2_DISPLAY="${PCRE2_LDADD}, ${PCRE2_CFLAGS}" - AC_MSG_NOTICE([using PCRE2_VERSION ${PCRE2_VERSION}]) - AC_MSG_NOTICE([using PCRE2_LDADD ${PCRE2_LDADD}]) - AC_MSG_NOTICE([using PCRE2_LIBS ${PCRE2_LIBS}]) - AC_MSG_NOTICE([using PCRE2_LDFLAGS ${PCRE2_LDFLAGS}]) - AC_MSG_NOTICE([using PCRE2_CFLAGS ${PCRE2_CFLAGS}]) - AC_MSG_NOTICE([using PCRE2_DISPLAY ${PCRE2_DISPLAY}]) - AC_SUBST(PCRE2_VERSION) - AC_SUBST(PCRE2_LDADD) - AC_SUBST(PCRE2_LIBS) - AC_SUBST(PCRE2_LDFLAGS) - AC_SUBST(PCRE2_CFLAGS) - AC_SUBST(PCRE2_DISPLAY) - fi -fi - - -AC_SUBST(PCRE2_FOUND) - +MSC_CHECK_LIB([PCRE2], [libpcre2-8 pcre2-8 pcre2], [pcre2.h], [pcre2-8], []) ]) # AC_DEFUN [PROG_PCRE2] - - -AC_DEFUN([CHECK_FOR_PCRE2_AT], [ - path=$1 - echo "*** LOOKING AT PATH: " ${path} - for y in ${PCRE2_POSSIBLE_EXTENSIONS}; do - for z in ${PCRE2_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - pcre2_lib_path="${path}/" - pcre2_lib_name="${z}" - pcre2_lib_file="${pcre2_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - pcre2_lib_path="${path}/" - pcre2_lib_name="${z}" - pcre2_lib_file="${pcre2_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - pcre2_lib_path="${path}/lib/" - pcre2_lib_name="${z}" - pcre2_lib_file="${pcre2_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - pcre2_lib_path="${path}/lib/x86_64-linux-gnu/" - pcre2_lib_name="${z}" - pcre2_lib_file="${pcre2_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/i386-linux-gnu/lib${z}.${y}"; then - pcre2_lib_path="${path}/lib/i386-linux-gnu/" - pcre2_lib_name="${z}" - pcre2_lib_file="${pcre2_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$pcre2_lib_path"; then - break - fi - done - if test -e "${path}/include/pcre2.h"; then - pcre2_inc_path="${path}/include" - elif test -e "${path}/pcre2.h"; then - pcre2_inc_path="${path}" - elif test -e "${path}/include/pcre2/pcre2.h"; then - pcre2_inc_path="${path}/include" - fi - - if test -n "${pcre2_lib_path}"; then - AC_MSG_NOTICE([PCRE2 library found at: ${pcre2_lib_file}]) - fi - - if test -n "${pcre2_inc_path}"; then - AC_MSG_NOTICE([PCRE2 headers found at: ${pcre2_inc_path}]) - fi - - if test -n "${pcre2_lib_path}" -a -n "${pcre2_inc_path}"; then - # TODO: Compile a piece of code to check the version. - PCRE2_CFLAGS="-I${pcre2_inc_path}" - PCRE2_LDADD="-l${pcre2_lib_name}" - PCRE2_LDFLAGS="-L${pcre2_lib_path}" - PCRE2_DISPLAY="${pcre2_lib_file}, ${pcre2_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_PCRE2_AT] diff --git a/build/ssdeep.m4 b/build/ssdeep.m4 index 44e7832718..81168bc3f0 100644 --- a/build/ssdeep.m4 +++ b/build/ssdeep.m4 @@ -1,144 +1,11 @@ dnl Check for SSDEEP Libraries -dnl CHECK_SSDEEP(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) - - -AC_DEFUN([CHECK_SSDEEP], -[dnl - -# Possible names for the ssdeep library/package (pkg-config) -SSDEEP_POSSIBLE_LIB_NAMES="fuzzy" - -# Possible extensions for the library -SSDEEP_POSSIBLE_EXTENSIONS="so so0 la sl dll dylib so.0.0.0" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -SSDEEP_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/fuzzy /usr/local/libfuzzy /usr/local /opt /usr /usr/lib64 /opt/local" - -# Variables to be set by this very own script. -SSDEEP_CFLAGS="" -SSDEEP_LDFLAGS="" -SSDEEP_LDADD="" -SSDEEP_DISPLAY="" - -AC_ARG_WITH( - ssdeep, - [AS_HELP_STRING([--with-ssdeep=PATH],[Path to ssdeep prefix])] -) - - -if test "x${with_ssdeep}" == "xno"; then - AC_DEFINE(HAVE_SSDEEP, 0, [Support for SSDEEP was disabled by the utilization of --without-ssdeep or --with-ssdeep=no]) - AC_MSG_NOTICE([Support for SSDEEP was disabled by the utilization of --without-ssdeep or --with-ssdeep=no]) - SSDEEP_DISABLED=yes -else - if test "x${with_ssdeep}" == "xyes"; then - SSDEEP_MANDATORY=yes - AC_MSG_NOTICE([SSDEEP support was marked as mandatory by the utilization of --with-ssdeep=yes]) - else - SSDEEP_MANDATORY=no - fi - for x in ${SSDEEP_POSSIBLE_PATHS}; do - CHECK_FOR_SSDEEP_AT(${x}) - if test -n "${SSDEEP_CFLAGS}"; then - break - fi - done -fi - - -if test -z "${SSDEEP_CFLAGS}"; then - if test -z "${SSDEEP_MANDATORY}" || test "x${SSDEEP_MANDATORY}" == "xno"; then - if test -z "${SSDEEP_DISABLED}"; then - AC_MSG_NOTICE([SSDEEP library was not found]) - SSDEEP_FOUND=0 - else - SSDEEP_FOUND=2 - fi - else - AC_MSG_ERROR([SSDEEP was explicitly referenced but it was not found]) - SSDEEP_FOUND=-1 - fi -else - SSDEEP_FOUND=1 - AC_MSG_NOTICE([using SSDEEP v${SSDEEP_VERSION}]) - SSDEEP_CFLAGS="-DWITH_SSDEEP ${SSDEEP_CFLAGS}" - SSDEEP_DISPLAY="${SSDEEP_LDADD} ${SSDEEP_LDFLAGS}, ${SSDEEP_CFLAGS}" - AC_SUBST(SSDEEP_LDFLAGS) - AC_SUBST(SSDEEP_LDADD) - AC_SUBST(SSDEEP_CFLAGS) - AC_SUBST(SSDEEP_DISPLAY) -fi - - -AC_SUBST(SSDEEP_FOUND) - +dnl Sets: +dnl SSDEEP_CFLAGS +dnl SSDEEP_LDADD +dnl SSDEEP_LDFLAGS +dnl SSDEEP_DISPLAY +dnl SSDEEP_FOUND + +AC_DEFUN([CHECK_SSDEEP], [ +MSC_CHECK_LIB([SSDEEP], [fuzzy], [fuzzy.h], [fuzzy], [-DWITH_SSDEEP]) ]) # AC_DEFUN [CHECK_SSDEEP] - - -AC_DEFUN([CHECK_FOR_SSDEEP_AT], [ - path=$1 - echo "*** LOOKING AT PATH: " ${path} - for y in ${SSDEEP_POSSIBLE_EXTENSIONS}; do - for z in ${SSDEEP_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - ssdeep_lib_path="${path}/" - ssdeep_lib_name="${z}" - ssdeep_lib_file="${ssdeep_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - ssdeep_lib_path="${path}/" - ssdeep_lib_name="${z}" - ssdeep_lib_file="${ssdeep_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - ssdeep_lib_path="${path}/lib/" - ssdeep_lib_name="${z}" - ssdeep_lib_file="${ssdeep_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - ssdeep_lib_path="${path}/lib/x86_64-linux-gnu/" - ssdeep_lib_name="${z}" - ssdeep_lib_file="${ssdeep_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/i386-linux-gnu/lib${z}.${y}"; then - ssdeep_lib_path="${path}/lib/i386-linux-gnu/" - ssdeep_lib_name="${z}" - ssdeep_lib_file="${ssdeep_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$ssdeep_lib_path"; then - break - fi - done - if test -e "${path}/include/fuzzy.h"; then - ssdeep_inc_path="${path}/include" - elif test -e "${path}/fuzzy.h"; then - ssdeep_inc_path="${path}" - elif test -e "${path}/include/fuzzy/fuzzy.h"; then - ssdeep_inc_path="${path}/include" - fi - - if test -n "${ssdeep_lib_path}"; then - AC_MSG_NOTICE([SSDEEP library found at: ${ssdeep_lib_file}]) - fi - - if test -n "${ssdeep_inc_path}"; then - AC_MSG_NOTICE([SSDEEP headers found at: ${ssdeep_inc_path}]) - fi - - if test -n "${ssdeep_lib_path}" -a -n "${ssdeep_inc_path}"; then - # TODO: Compile a piece of code to check the version. - SSDEEP_CFLAGS="-I${ssdeep_inc_path}" - SSDEEP_LDADD="-l${ssdeep_lib_name}" - SSDEEP_LDFLAGS="-L${ssdeep_lib_path}" - SSDEEP_DISPLAY="${ssdeep_lib_file}, ${ssdeep_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_SSDEEP_AT] - - - diff --git a/build/yajl.m4 b/build/yajl.m4 index 10d4e78a4c..06271e1fea 100644 --- a/build/yajl.m4 +++ b/build/yajl.m4 @@ -1,192 +1,33 @@ dnl Check for YAJL Libraries -dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +dnl Sets: +dnl YAJL_CFLAGS +dnl YAJL_LDADD +dnl YAJL_LDFLAGS +dnl YAJL_VERSION +dnl YAJL_DISPLAY +dnl YAJL_FOUND AC_DEFUN([PROG_YAJL], [ - -# Possible names for the yajl library/package (pkg-config) -YAJL_POSSIBLE_LIB_NAMES="yajl2 yajl" - -# Possible extensions for the library -YAJL_POSSIBLE_EXTENSIONS="so la sl dll dylib" - -# Possible paths (if pkg-config was not found, proceed with the file lookup) -YAJL_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/libyajl /usr/local/yajl /usr/local /opt/libyajl /opt/yajl /opt /usr /usr/lib64" - -# Variables to be set by this very own script. -YAJL_VERSION="" -YAJL_CFLAGS="" -YAJL_CPPFLAGS="" -YAJL_LDADD="" -YAJL_LDFLAGS="" - -AC_ARG_WITH( - yajl, - [AS_HELP_STRING([--with-yajl=PATH],[Path to yajl prefix or config script])] -) - -if test "x${with_yajl}" == "xno"; then - AC_DEFINE(HAVE_YAJL, 0, [Support for YAJL was disabled by the utilization of --without-yajl or --with-yajl=no]) - AC_MSG_NOTICE([Support for YAJL was disabled by the utilization of --without-yajl or --with-yajl=no]) - YAJL_DISABLED=yes -else - if test "x${with_yajl}" == "xyes"; then - YAJL_MANDATORY=yes - AC_MSG_NOTICE([YAJL support was marked as mandatory by the utilization of --with-yajl=yes]) - fi -# for x in ${YAJL_POSSIBLE_LIB_NAMES}; do -# CHECK_FOR_YAJL_AT(${x}) -# if test -n "${YAJL_VERSION}"; then -# break -# fi -# done - -# if test "x${with_yajl}" != "xyes" or test "x${with_yajl}" == "xyes"; then - if test "x${with_yajl}" == "x" || test "x${with_yajl}" == "xyes"; then - # Nothing about YAJL was informed, using the pkg-config to figure things out. - if test -n "${PKG_CONFIG}"; then - YAJL_PKG_NAME="" - for x in ${YAJL_POSSIBLE_LIB_NAMES}; do - if ${PKG_CONFIG} --exists ${x}; then - YAJL_PKG_NAME="$x" - break - fi - done - fi - AC_MSG_NOTICE([Nothing about YAJL was informed during the configure phase. Trying to detect it on the platform...]) - if test -n "${YAJL_PKG_NAME}"; then - # Package was found using the pkg-config scripts - YAJL_VERSION="`${PKG_CONFIG} ${YAJL_PKG_NAME} --modversion`" - YAJL_CFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --cflags`" - YAJL_LDADD="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-l`" - YAJL_LDFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-L --libs-only-other`" - YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}" - else - # If pkg-config did not find anything useful, go over file lookup. - for x in ${YAJL_POSSIBLE_PATHS}; do - CHECK_FOR_YAJL_AT(${x}) - if test -n "${YAJL_VERSION}"; then - break - fi - done - fi - fi - if test "x${with_yajl}" != "x"; then - # An specific path was informed, lets check. - YAJL_MANDATORY=yes - CHECK_FOR_YAJL_AT(${with_yajl}) - fi -# fi -fi +MSC_CHECK_LIB([YAJL], [yajl2 yajl], [yajl/yajl_parse.h], [yajl], [-DWITH_YAJL]) # FIX: if the include directory in CFLAGS ends with "include/yajl", -# remove the suffix "/yajl". the library header files are included -# using the prefix (for example, #include ), and -# this is even the case for the library itself (for example, +# remove the suffix "/yajl". The library header files are included +# using the prefix (e.g., #include ), and +# this is even the case for the library itself (e.g., # yajl_tree.h includes yajl/yajl_common.h). - -new_cflags="" - -for flag in $YAJL_CFLAGS; do - case "$flag" in +_msc_yajl_new_cflags="" +for _msc_yajl_flag in $YAJL_CFLAGS; do + case "$_msc_yajl_flag" in -I*/include/yajl) - new_flag="${flag%/yajl}" - new_cflags="$new_cflags $new_flag" + _msc_yajl_new_flag="${_msc_yajl_flag%/yajl}" + _msc_yajl_new_cflags="$_msc_yajl_new_cflags $_msc_yajl_new_flag" ;; *) - new_cflags="$new_cflags $flag" + _msc_yajl_new_cflags="$_msc_yajl_new_cflags $_msc_yajl_flag" ;; esac done - -YAJL_CFLAGS="$new_cflags" - - -if test -z "${YAJL_LDADD}"; then - if test -z "${YAJL_MANDATORY}"; then - if test -z "${YAJL_DISABLED}"; then - AC_MSG_NOTICE([YAJL library was not found]) - YAJL_FOUND=0 - else - YAJL_FOUND=2 - fi - else - AC_MSG_ERROR([YAJL was explicitly referenced but it was not found]) - YAJL_FOUND=-1 - fi -else - YAJL_FOUND=1 - AC_MSG_NOTICE([using YAJL v${YAJL_VERSION}]) - YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}" - YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}" - AC_SUBST(YAJL_VERSION) - AC_SUBST(YAJL_LDADD) - AC_SUBST(YAJL_LIBS) - AC_SUBST(YAJL_LDFLAGS) - AC_SUBST(YAJL_CFLAGS) - AC_SUBST(YAJL_DISPLAY) -fi - - - -AC_SUBST(YAJL_FOUND) +YAJL_CFLAGS="$_msc_yajl_new_cflags" +YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}" ]) # AC_DEFUN [PROG_YAJL] - - -AC_DEFUN([CHECK_FOR_YAJL_AT], [ - path=$1 - for y in ${YAJL_POSSIBLE_EXTENSIONS}; do - for z in ${YAJL_POSSIBLE_LIB_NAMES}; do - if test -e "${path}/${z}.${y}"; then - yajl_lib_path="${path}/" - yajl_lib_name="${z}" - yajl_lib_file="${yajl_lib_path}/${z}.${y}" - break - fi - if test -e "${path}/lib${z}.${y}"; then - yajl_lib_path="${path}/" - yajl_lib_name="${z}" - yajl_lib_file="${yajl_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/lib${z}.${y}"; then - yajl_lib_path="${path}/lib/" - yajl_lib_name="${z}" - yajl_lib_file="${yajl_lib_path}/lib${z}.${y}" - break - fi - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then - yajl_lib_path="${path}/lib/x86_64-linux-gnu/" - yajl_lib_name="${z}" - yajl_lib_file="${yajl_lib_path}/lib${z}.${y}" - break - fi - done - if test -n "$yajl_lib_path"; then - break - fi - done - if test -e "${path}/include/yajl_parse.h"; then - yajl_inc_path="${path}/include" - elif test -e "${path}/yajl_parse.h"; then - yajl_inc_path="${path}" - elif test -e "${path}/include/yajl/yajl_parse.h"; then - yajl_inc_path="${path}/include" - fi - - if test -n "${yajl_lib_path}"; then - AC_MSG_NOTICE([YAJL library found at: ${yajl_lib_file}]) - fi - - if test -n "${yajl_inc_path}"; then - AC_MSG_NOTICE([YAJL headers found at: ${yajl_inc_path}]) - fi - - if test -n "${yajl_lib_path}" -a -n "${yajl_inc_path}"; then - # TODO: Compile a piece of code to check the version. - YAJL_CFLAGS="-I${yajl_inc_path}" - YAJL_LDADD="-l${yajl_lib_name}" - YAJL_LDFLAGS="-L${yajl_lib_path}" - YAJL_DISPLAY="${yajl_lib_file}, ${yajl_inc_path}" - fi -]) # AC_DEFUN [CHECK_FOR_YAJL_AT] diff --git a/configure.ac b/configure.ac index 31097b02c5..b1612d95bc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ # ModSecurity configure.ac +AC_PREREQ([2.72]) # Get the hash of the last commit, to be used if it is not an # official release. @@ -48,7 +49,14 @@ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # Check for dependencies (C++, AR, Lex, Yacc and Make) AC_PROG_CXX AM_PROG_AR +AC_PROG_AWK +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S AC_PROG_MAKE_SET +AC_PROG_RANLIB +AC_PROG_MKDIR_P PKG_PROG_PKG_CONFIG @@ -111,7 +119,6 @@ PROG_GEOIP # Check for MaxMind PROG_MAXMIND - # Check for LMDB PROG_LMDB @@ -155,7 +162,34 @@ fi AC_CHECK_HEADERS([string]) AC_CHECK_HEADERS([iostream]) AC_CHECK_HEADERS([sys/utsname.h]) - +AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h malloc.h netdb.h netinet/in.h stdint.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h]) + + + +# Checks for typedefs, structures, and compiler characteristics. +AC_CHECK_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_INT16_T +AC_TYPE_INT32_T +AC_TYPE_INT64_T +AC_TYPE_INT8_T +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_UINT8_T +AC_CHECK_TYPES([ptrdiff_t]) +AC_CHECK_TYPES([time_t]) + +# Checks for library functions. +AC_FUNC_ERROR_AT_LINE +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([alarm clock_gettime gethostname gettimeofday inet_ntoa localtime_r memmove memset mkdir select setenv socket strcasecmp strchr strdup strerror strncasecmp strspn strstr strtol strtoul strtoull uname]) # Initialize libtool LT_INIT @@ -241,73 +275,17 @@ AC_SUBST([MSC_VERSION]) MSC_GIT_VERSION=msc_version_git AC_SUBST([MSC_GIT_VERSION]) -AC_ARG_ENABLE(assertions, - [AS_HELP_STRING([--enable-assertions],[Turn on assertions feature: undefine NDEBUG])], - - [case "${enableval}" in - yes) assertions=true ;; - no) assertions=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-assertions) ;; - esac], - - [assertions=false] - ) - -AC_ARG_ENABLE(debug-logs, - [AS_HELP_STRING([--disable-debug-logs],[Turn off the SecDebugLog feature])], - - [case "${enableval}" in - yes) debugLogs=true ;; - no) debugLogs=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-logs) ;; - esac], - - [debugLogs=true] - ) +MSC_ARG_ENABLE_BOOL([assertions], [Turn on assertions feature: undefine NDEBUG], [false], [assertions]) +MSC_ARG_ENABLE_BOOL([debug-logs], [Turn off the SecDebugLog feature], [true], [debugLogs]) if test "$debugLogs" != "true"; then MODSEC_NO_LOGS="-DNO_LOGS=1" AC_SUBST(MODSEC_NO_LOGS) fi - -# Fuzzer -AC_ARG_ENABLE(afl-fuzz, - [AS_HELP_STRING([--enable-afl-fuzz],[Turn on the afl fuzzer compilation utilities])], - - [case "${enableval}" in - yes) aflFuzzer=true ;; - no) aflFuzzer=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-afl-fuzz) ;; - esac], - - [aflFuzzer=false] - ) - -# Examples -AC_ARG_ENABLE(examples, - [AS_HELP_STRING([--enable-examples],[Turn on the examples compilation (default option)])], - - [case "${enableval}" in - yes) buildExamples=true ;; - no) buildExamples=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-examples) ;; - esac], - - [buildExamples=true] - ) - -# Parser -AC_ARG_ENABLE(parser-generation, - [AS_HELP_STRING([--enable-parser-generation],[Enables parser generation during the build])], - - [case "${enableval}" in - yes) buildParser=true ;; - no) buildParser=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-parser-generation) ;; - esac], - - [buildParser=false] - ) +MSC_ARG_ENABLE_BOOL([afl-fuzz], [Turn on the afl fuzzer compilation utilities], [false], [aflFuzzer]) +MSC_ARG_ENABLE_BOOL([examples], [Turn on the examples compilation (default option)], [true], [buildExamples]) +MSC_ARG_ENABLE_BOOL([parser-generation], [Enables parser generation during the build], [false], [buildParser]) +MSC_ARG_ENABLE_BOOL([mutex-on-pm], [Treat pm operations as critical section], [false], [mutexPm]) if test $buildParser = true; then @@ -453,12 +431,12 @@ echo " Optional dependencies" -## GeoIP - MaxMind +## GeoIP - MaxMind (combined display) if test "x$GEOIP_FOUND" = "x0" && test "x$MAXMIND_FOUND" = "x0"; then echo " + GeoIP/MaxMind ....not found" fi if test "x$GEOIP_FOUND" = "x1" || test "x$MAXMIND_FOUND" = "x1"; then - AS_ECHO_N(" + GeoIP/MaxMind ....found ") + AS_ECHO_N([" + GeoIP/MaxMind ....found "]) echo "" if test "x$MAXMIND_FOUND" = "x1"; then echo " * (MaxMind) v${MAXMIND_VERSION}" @@ -473,141 +451,25 @@ if test "x$GEOIP_FOUND" = "x2" && test "x$MAXMIND_FOUND" = "x2"; then echo " + GeoIP/MaxMind ....disabled" fi +MSC_STATUS_LIB([LibCURL ], [CURL]) +MSC_STATUS_LIB([YAJL ], [YAJL]) +MSC_STATUS_LIB([LMDB ], [LMDB]) +MSC_STATUS_LIB([LibXML2 ], [LIBXML2]) +MSC_STATUS_LIB([SSDEEP ], [SSDEEP]) +MSC_STATUS_LIB([LUA ], [LUA]) -## LibCurl -if test "x$CURL_FOUND" = "x0"; then - echo " + LibCURL ....not found" -fi -if test "x$CURL_FOUND" = "x1"; then - AS_ECHO_N(" + LibCURL ....found ") - if ! test "x$CURL_VERSION" = "x"; then - echo "v${CURL_VERSION}" - else - echo "" - fi - echo " ${CURL_DISPLAY}" -fi -if test "x$CURL_FOUND" = "x2"; then - echo " + LibCURL ....disabled" -fi - - -## YAJL -if test "x$YAJL_FOUND" = "x0"; then - echo " + YAJL ....not found" -fi -if test "x$YAJL_FOUND" = "x1"; then - AS_ECHO_N(" + YAJL ....found ") - if ! test "x$YAJL_VERSION" = "x"; then - echo "v${YAJL_VERSION}" - else - echo "" - fi - echo " ${YAJL_DISPLAY}" -fi -if test "x$YAJL_FOUND" = "x2"; then - echo " + YAJL ....disabled" -fi - - -## LMDB -if test "x$LMDB_FOUND" = "x0"; then - echo " + LMDB ....not found" -fi -if test "x$LMDB_FOUND" = "x1"; then - AS_ECHO_N(" + LMDB ....found ") - if ! test "x$LMDB_VERSION" = "x"; then - echo "v${LMDB_VERSION}" - else - echo "" - fi - echo " ${LMDB_DISPLAY}" -fi -if test "x$LMDB_FOUND" = "x2"; then - echo " + LMDB ....disabled" -fi - - -## libxml2 -if test "x$LIBXML2_FOUND" = "x0"; then - echo " + LibXML2 ....not found" -fi -if test "x$LIBXML2_FOUND" = "x1"; then - AS_ECHO_N(" + LibXML2 ....found ") - if ! test "x$LIBXML2_VERSION" = "x"; then - echo "v${LIBXML2_VERSION}" - else - echo "" - fi - echo " ${LIBXML2_DISPLAY}" -fi -if test "x$LIBXML2_FOUND" = "x2"; then - echo " + LibXML2 ....disabled" -fi - - -## SSDEEP -if test "x$SSDEEP_FOUND" = "x0"; then - echo " + SSDEEP ....not found" -fi -if test "x$SSDEEP_FOUND" = "x1"; then - AS_ECHO_N(" + SSDEEP ....found ") - if ! test "x$SSDEEP_VERSION" = "x"; then - echo "v${SSDEEP_VERSION}" - else - echo "" - fi - echo " ${SSDEEP_DISPLAY}" -fi -if test "x$SSDEEP_FOUND" = "x2"; then - echo " + SSDEEP ....disabled" -fi - -## LUA -if test "x$LUA_FOUND" = "x0"; then - echo " + LUA ....not found" -fi -if test "x$LUA_FOUND" = "x1"; then - AS_ECHO_N(" + LUA ....found ") - if ! test "x$LUA_VERSION" = "x"; then - echo "v${LUA_VERSION}" +## PCRE (only shown when explicitly requested) +if test "x${with_pcre}" != "x" && test "x${with_pcre}" != "xno"; then + if test -n "${PCRE_VERSION}"; then + echo " + PCRE ....found " + echo " using pcre v${PCRE_VERSION}" + echo " ${PCRE_LDADD}, ${PCRE_CFLAGS}" else - echo "" + AC_MSG_NOTICE([*** pcre library not found.]) fi - echo " ${LUA_DISPLAY}" -fi -if test "x$LUA_FOUND" = "x2"; then - echo " + LUA ....disabled" fi -##PCRE -if test "x${with_pcre}" != "x" \ - && test "x${with_pcre}" != "xno" \ - && test "x${PCRE_VERSION}" == "x"; then - AC_MSG_NOTICE([*** pcre library not found.]) -else - echo " + PCRE ....found " - echo " using pcre v${PCRE_VERSION}" - echo " ${PCRE_LDADD}, ${PCRE_CFLAGS}" -fi - - -## PCRE2 -if test "x$PCRE2_FOUND" = "x0"; then - echo " + PCRE2 ....not found" -fi -if test "x$PCRE2_FOUND" = "x1"; then - AS_ECHO_N(" + PCRE2 ....found ") - if ! test "x$PCRE2_VERSION" = "x"; then - echo "v${PCRE2_VERSION}" - else - echo "" - fi - echo " ${PCRE2_DISPLAY}" -fi -if test "x$PCRE2_FOUND" = "x2"; then - echo " + PCRE2 ....disabled" -fi +MSC_STATUS_LIB([PCRE2 ], [PCRE2]) echo " " echo " Other Options" diff --git a/modsecurity.pc.in b/modsecurity.pc.in index 96cdf5ca79..d00ad644fa 100644 --- a/modsecurity.pc.in +++ b/modsecurity.pc.in @@ -8,4 +8,4 @@ Description: ModSecurity API Version: @MSC_VERSION_WITH_PATCHLEVEL@ Cflags: -I@includedir@ Libs: -L@libdir@ -lmodsecurity -Libs.private: @CURL_LDADD@ @GEOIP_LDADD@ @MAXMIND_LDADD@ @GLOBAL_LDADD@ @LIBXML2_LDADD@ @LMDB_LDADD@ @LUA_LDADD@ @PCRE_LDADD@ @SSDEEP_LDADD@ @YAJL_LDADD@ +Libs.private: @CURL_LDADD@ @GEOIP_LDADD@ @MAXMIND_LDADD@ @GLOBAL_LDADD@ @LIBXML2_LDADD@ @LMDB_LDADD@ @LUA_LDADD@ @PCRE_LDADD@ @PCRE2_LDADD@ @SSDEEP_LDADD@ @YAJL_LDADD@ From 1fa8be216571c75ca413867c9645f3856260800c Mon Sep 17 00:00:00 2001 From: Felipe Zipitria Date: Fri, 13 Feb 2026 19:12:24 -0300 Subject: [PATCH 2/2] fix: use older autoconf Signed-off-by: Felipe Zipitria --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b1612d95bc..f816547f49 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # ModSecurity configure.ac -AC_PREREQ([2.72]) +AC_PREREQ([2.69]) # Get the hash of the last commit, to be used if it is not an # official release.