@@ -27,7 +27,7 @@ m4_define([msc_version_with_patchlevel],
2727 [ msc_version_major.msc_version_minor.msc_version_patchlevel] )
2828
2929m4_define ( [ msc_version_git] ,
30- [ m4_esyscmd_s ( git describe ) ] )
30+ [ m4_esyscmd_s ( git describe -- tags -- always 2>/dev/null || echo unknown ) ] )
3131
3232m4_define ( [ msc_version_info] ,
3333 [ msc_version_c_plus_a:msc_version_patchlevel:msc_version_minor] )
@@ -62,6 +62,23 @@ PKG_PROG_PKG_CONFIG
6262# Set C++ standard version and check if compiler supports it.
6363AX_CXX_COMPILE_STDCXX ( 17 , noext , mandatory )
6464
65+ AC_ARG_WITH ( [ json-backend] ,
66+ [ AS_HELP_STRING ( [ --with-json-backend=BACKEND] ,
67+ [ Select internal JSON backend: simdjson or jsoncons [ default=simdjson] ] ) ] ,
68+ [ json_backend="$withval"] ,
69+ [ json_backend="simdjson"] )
70+
71+ case "$json_backend" in
72+ simdjson|jsoncons)
73+ ;;
74+ *)
75+ AC_MSG_ERROR ( [ Unsupported JSON backend '$json_backend'. Use simdjson or jsoncons.] )
76+ ;;
77+ esac
78+
79+ JSON_BACKEND="$json_backend"
80+ AC_SUBST ( [ JSON_BACKEND] )
81+
6582# Check for libinjection
6683if ! test -f "${srcdir}/others/libinjection/src/libinjection_html5.c"; then
6784AC_MSG_ERROR ( [ \
@@ -80,7 +97,7 @@ AC_MSG_ERROR([\
8097 ] )
8198fi
8299# Libinjection version
83- AC_DEFUN ( [ LIBINJECTION_VERSION] , m4_esyscmd_s ( cd "others/libinjection" && git describe && cd ../.. ) )
100+ AC_DEFUN ( [ LIBINJECTION_VERSION] , m4_esyscmd_s ( cd "others/libinjection" && ( git describe -- tags -- always 2>/dev/null || echo unknown ) && cd ../.. ) )
84101AC_SUBST ( [ LIBINJECTION_VERSION] )
85102
86103# Check for Mbed TLS
@@ -101,16 +118,56 @@ AC_MSG_ERROR([\
101118 ] )
102119fi
103120# Mbed TLS version
104- AC_DEFUN ( [ MBEDTLS_VERSION] , m4_esyscmd_s ( cd "others/mbedtls" && git describe && cd ../.. ) )
121+ AC_DEFUN ( [ MBEDTLS_VERSION] , m4_esyscmd_s ( cd "others/mbedtls" && ( git describe -- tags -- always 2>/dev/null || echo unknown ) && cd ../.. ) )
105122
106- # SecLang test version
107- AC_DEFUN ( [ SECLANG_TEST_VERSION] , m4_esyscmd_s ( cd "test/test-cases/secrules-language-tests" && git log - 1 -- format="%h" -- abbrev-commit && cd ../../.. ) )
123+ # Check for selected JSON backend
124+ if test "x$json_backend" = "xsimdjson"; then
125+ if ! test -f "${srcdir}/others/simdjson/singleheader/simdjson.h" || \
126+ ! test -f "${srcdir}/others/simdjson/singleheader/simdjson.cpp"; then
127+ AC_MSG_ERROR ( [ \
128+
129+
130+ simdjson was not found within ModSecurity source directory.
131+
132+ simdjson code is available as part of ModSecurity source code in a format
133+ of a git-submodule. git-submodule allow us to specify the correct version of
134+ simdjson and still uses the simdjson repository to download it.
135+
136+ You can download simdjson using git:
137+
138+ $ git submodule update --init --recursive
139+
140+ ] )
141+ fi
142+ JSON_BACKEND_VERSION=`cd "${srcdir}/others/simdjson" && git describe --tags --always 2>/dev/null || echo unknown`
143+ AC_DEFINE ( [ MSC_JSON_BACKEND_SIMDJSON] , [ 1] ,
144+ [ Define if simdjson is the selected internal JSON backend] )
145+ elif test "x$json_backend" = "xjsoncons"; then
146+ if ! test -d "${srcdir}/others/jsoncons/include" || \
147+ ! test -f "${srcdir}/others/jsoncons/include/jsoncons/json.hpp"; then
148+ AC_MSG_ERROR ( [ \
149+
150+
151+ jsoncons was not found within ModSecurity source directory.
108152
153+ jsoncons code is available as part of ModSecurity source code in a format
154+ of a git-submodule. git-submodule allow us to specify the correct version of
155+ jsoncons and still uses the jsoncons repository to download it.
109156
110- # Check for yajl
111- PROG_YAJL
157+ You can download jsoncons using git:
112158
113- AM_CONDITIONAL([ YAJL_VERSION] , [ test "$YAJL_VERSION" != ""] )
159+ $ git submodule update --init --recursive
160+
161+ ] )
162+ fi
163+ JSON_BACKEND_VERSION=`cd "${srcdir}/others/jsoncons" && git describe --tags --always 2>/dev/null || echo unknown`
164+ AC_DEFINE ( [ MSC_JSON_BACKEND_JSONCONS] , [ 1] ,
165+ [ Define if jsoncons is the selected internal JSON backend] )
166+ fi
167+ AC_SUBST ( [ JSON_BACKEND_VERSION] )
168+
169+ # SecLang test version
170+ AC_DEFUN ( [ SECLANG_TEST_VERSION] , m4_esyscmd_s ( cd "test/test-cases/secrules-language-tests" && git log - 1 -- format="%h" -- abbrev-commit && cd ../../.. ) )
114171
115172# Check for LibGeoIP
116173PROG_GEOIP
306363
307364
308365# Decide if we want to build the tests or not.
309- buildTestUtilities=false
310- if test "x$YAJL_FOUND" = "x1"; then
311- # Regression tests will not be able to run without the logging support.
312- # But we still have the unit tests.
313- # if test "$debugLogs" = "true"; then
314- buildTestUtilities=true
315- # fi
316- fi
366+ buildTestUtilities=true
317367
318368
319369AM_CONDITIONAL([ TEST_UTILITIES] , [ test $buildTestUtilities = true] )
328378AM_CONDITIONAL([ EXAMPLES] , [ test $buildExamples = true] )
329379AM_CONDITIONAL([ BUILD_PARSER] , [ test $buildParser = true] )
330380AM_CONDITIONAL([ USE_MUTEX_ON_PM] , [ test $mutexPm = true] )
381+ AM_CONDITIONAL([ JSON_BACKEND_SIMDJSON] , [ test "x$json_backend" = "xsimdjson"] )
382+ AM_CONDITIONAL([ JSON_BACKEND_JSONCONS] , [ test "x$json_backend" = "xjsoncons"] )
331383
332384
333385# General link options
@@ -422,6 +474,8 @@ AS_ECHO_N(" + libInjection ....")
422474echo LIBINJECTION_VERSION
423475AS_ECHO_N ( " + Mbed TLS ...." )
424476echo MBEDTLS_VERSION
477+ AS_ECHO_N ( " + JSON backend ...." )
478+ echo "$JSON_BACKEND ($JSON_BACKEND_VERSION)"
425479AS_ECHO_N ( " + SecLang tests ...." )
426480echo SECLANG_TEST_VERSION
427481
@@ -451,7 +505,6 @@ if test "x$GEOIP_FOUND" = "x2" && test "x$MAXMIND_FOUND" = "x2"; then
451505fi
452506
453507MSC_STATUS_LIB([ LibCURL ] , [ CURL] )
454- MSC_STATUS_LIB([ YAJL ] , [ YAJL] )
455508MSC_STATUS_LIB([ LMDB ] , [ LMDB] )
456509MSC_STATUS_LIB([ LibXML2 ] , [ LIBXML2] )
457510MSC_STATUS_LIB([ SSDEEP ] , [ SSDEEP] )
@@ -532,4 +585,3 @@ if test "$aflFuzzer" = "true"; then
532585 echo " $ export CC=afl-clang-fast "
533586 echo " "
534587fi
535-
0 commit comments