Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
272 changes: 271 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ PKGPATH=$($PKG_CONFIG --variable pc_path pkg-config)
AC_PROG_CXX
AC_PROG_CC

JSONC_CFLAGS=""
JSONC_LDADD=""
JSONC_LDFLAGS=""
JANSSON_CFLAGS=""
JANSSON_LDADD=""
JANSSON_LDFLAGS=""
CJSON_CFLAGS=""
CJSON_LDADD=""
CJSON_LDFLAGS=""
JSONCPP_CFLAGS=""
JSONCPP_LDADD=""
JSONCPP_LDFLAGS=""
SIMDJSON_CFLAGS=""
SIMDJSON_LDADD=""
SIMDJSON_LDFLAGS=""
YYJSON_CFLAGS=""
YYJSON_LDADD=""
YYJSON_LDFLAGS=""
GLAZE_CFLAGS=""

# Verbose output
AC_ARG_ENABLE(verbose-output,
AS_HELP_STRING([--enable-verbose-output],
Expand Down Expand Up @@ -158,12 +178,262 @@ if test "$wannlohmannjson" != "no"; then
[AC_MSG_ERROR([NlohmannJSON headers not found. Install nlohmannjson or use --disable-nlohmannjson])]
)
AC_DEFINE([HAVE_NLOHMANNJSON], [1], [Mark that user wants NlohmannJSON])
have_nlohmannjson=yes
AC_LANG_POP([C++])
else
have_nlohmannjson=no
fi

AM_CONDITIONAL([HAVE_NLOHMANNJSON], [test "x$enable_nlohmannjson" = "xyes"])
AM_CONDITIONAL([HAVE_NLOHMANNJSON], [test "x$have_nlohmannjson" = "xyes"])
#dnl End check for nlohmannjson

dnl Check if we want to use json-c or not
AC_MSG_CHECKING([whether to use json-c])
AC_ARG_WITH(
[jsonc],
[AS_HELP_STRING([--with-jsonc], [Enable json-c (default is enabled if exists)])],
[case "$withval" in
yes) wantjsonc=yes ;;
no) wantjsonc=no; AC_DEFINE([HAVE_JSONC], [0], [Mark that user does not want json-c]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantjsonc="notset"]
)

if test "$wantjsonc" != "no"; then
PKG_CHECK_MODULES([JSONC], [json-c], [
JSONC_CFLAGS="$JSONC_CFLAGS"
JSONC_LDADD="$JSONC_LIBS"
AC_DEFINE([HAVE_JSONC], [1], [Mark that system has json-c])
], [
AC_MSG_ERROR([json-c was requested but not found via pkg-config. Install json-c or disable with --with-jsonc=no])
])
fi

dnl Check if we want to use jansson or not
AC_MSG_CHECKING([whether to use jansson])
AC_ARG_WITH(
[jansson],
[AS_HELP_STRING([--with-jansson], [Enable jansson (default is enabled if exists)])],
[case "$withval" in
yes) wantjansson=yes ;;
no) wantjansson=no; AC_DEFINE([HAVE_JANSSON], [0], [Mark that user does not want jansson]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantjansson="notset"]
)

if test "$wantjansson" != "no"; then
PKG_CHECK_MODULES([JANSSON], [jansson], [
JANSSON_CFLAGS="$JANSSON_CFLAGS"
JANSSON_LDADD="$JANSSON_LIBS"
AC_DEFINE([HAVE_JANSSON], [1], [Mark that system has jansson])
], [
AC_MSG_ERROR([jansson was requested but not found via pkg-config. Install jansson or disable with --with-jansson=no])
])
fi

dnl Check if we want to use cJSON or not
AC_MSG_CHECKING([whether to use cJSON])
AC_ARG_WITH(
[cjson],
[AS_HELP_STRING([--with-cjson], [Enable cJSON (default is enabled if exists)])],
[case "$withval" in
yes) wantcjson=yes ;;
no) wantcjson=no; AC_DEFINE([HAVE_CJSON], [0], [Mark that user does not want cJSON]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantcjson="notset"]
)

if test "$wantcjson" != "no"; then
PKG_CHECK_MODULES([CJSON], [libcjson], [
CJSON_CFLAGS="$CJSON_CFLAGS"
CJSON_LDADD="$CJSON_LIBS"
AC_DEFINE([HAVE_CJSON], [1], [Mark that system has cJSON])
], [
AC_MSG_ERROR([cJSON was requested but not found via pkg-config as libcjson. Install libcjson or disable with --with-cjson=no])
])
fi

dnl Check if we want to use jsoncpp or not
AC_MSG_CHECKING([whether to use jsoncpp])
AC_ARG_WITH(
[jsoncpp],
[AS_HELP_STRING([--with-jsoncpp], [Enable jsoncpp (default is enabled if exists)])],
[case "$withval" in
yes) wantjsoncpp=yes ;;
no) wantjsoncpp=no; AC_DEFINE([HAVE_JSONCPP], [0], [Mark that user does not want JsonCpp]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantjsoncpp="notset"]
)

if test "$wantjsoncpp" != "no"; then
PKG_CHECK_MODULES([JSONCPP], [jsoncpp], [
JSONCPP_CFLAGS="$JSONCPP_CFLAGS"
JSONCPP_LDADD="$JSONCPP_LIBS"
AC_DEFINE([HAVE_JSONCPP], [1], [Mark that system has JsonCpp])
], [
AC_LANG_PUSH([C++])
jsoncpp_header="no"
AC_CHECK_HEADERS([json/json.h], [jsoncpp_header="json/json.h"])
if test "$jsoncpp_header" = "no"; then
AC_CHECK_HEADERS([jsoncpp/json/json.h], [
jsoncpp_header="jsoncpp/json/json.h"
JSONCPP_CFLAGS="-I/usr/include/jsoncpp"
])
fi
if test "$jsoncpp_header" = "no"; then
AC_MSG_ERROR([JsonCpp header not found (tried json/json.h and jsoncpp/json/json.h). Install jsoncpp development headers or disable with --with-jsoncpp=no])
fi
old_LIBS="$LIBS"
LIBS="$LIBS -ljsoncpp"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <$jsoncpp_header>]], [[Json::Value root; return root.isNull() ? 0 : 1;]])],
[
JSONCPP_LDADD="-ljsoncpp"
AC_DEFINE([HAVE_JSONCPP], [1], [Mark that system has JsonCpp])
],
[AC_MSG_ERROR([JsonCpp library not found. Install libjsoncpp or disable with --with-jsoncpp=no])]
)
LIBS="$old_LIBS"
AC_LANG_POP([C++])
])
fi



dnl Check if we want to use simdjson or not
AC_MSG_CHECKING([whether to use simdjson])
AC_ARG_WITH(
[simdjson],
[AS_HELP_STRING([--with-simdjson], [Enable simdjson (default is enabled if exists)])],
[case "$withval" in
yes) wantsimdjson=yes ;;
no) wantsimdjson=no; AC_DEFINE([HAVE_SIMDJSON], [0], [Mark that user does not want simdjson]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantsimdjson="notset"]
)

if test "$wantsimdjson" != "no"; then
PKG_CHECK_MODULES([SIMDJSON], [simdjson], [
SIMDJSON_CFLAGS="$SIMDJSON_CFLAGS"
SIMDJSON_LDADD="$SIMDJSON_LIBS"
AC_DEFINE([HAVE_SIMDJSON], [1], [Mark that system has simdjson])
], [
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([simdjson.h], [],
[AC_MSG_ERROR([simdjson.h not found. Install simdjson headers or disable with --with-simdjson=no])]
)
old_LIBS="$LIBS"
LIBS="$LIBS -lsimdjson"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <simdjson.h>]], [[simdjson::ondemand::parser parser; return 0;]])],
[
SIMDJSON_LDADD="-lsimdjson"
AC_DEFINE([HAVE_SIMDJSON], [1], [Mark that system has simdjson])
],
[AC_MSG_ERROR([simdjson library not found. Install libsimdjson or disable with --with-simdjson=no])]
)
LIBS="$old_LIBS"
AC_LANG_POP([C++])
])
fi

dnl Check if we want to use yyjson or not
AC_MSG_CHECKING([whether to use yyjson])
AC_ARG_WITH(
[yyjson],
[AS_HELP_STRING([--with-yyjson], [Enable yyjson (default is enabled if exists)])],
[case "$withval" in
yes) wantyyjson=yes ;;
no) wantyyjson=no; AC_DEFINE([HAVE_YYJSON], [0], [Mark that user does not want yyjson]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantyyjson="notset"]
)

if test "$wantyyjson" != "no"; then
PKG_CHECK_MODULES([YYJSON], [yyjson], [
YYJSON_CFLAGS="$YYJSON_CFLAGS"
YYJSON_LDADD="$YYJSON_LIBS"
AC_DEFINE([HAVE_YYJSON], [1], [Mark that system has yyjson])
], [
AC_MSG_ERROR([yyjson was requested but not found via pkg-config. Install yyjson or disable with --with-yyjson=no])
])
fi

dnl Check if we want to use glaze or not
AC_MSG_CHECKING([whether to use glaze])
AC_ARG_WITH(
[glaze],
[AS_HELP_STRING([--with-glaze], [Enable glaze (default is enabled if exists)])],
[case "$withval" in
yes) wantglaze=yes ;;
no) wantglaze=no; AC_DEFINE([HAVE_GLAZE], [0], [Mark that user does not want glaze]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantglaze="notset"]
)

if test "$wantglaze" != "no"; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't if it's a package error or something else, but after I installed libglaze-dev on my Debian SID test environment, I got this message:

configure: error: glaze/glaze.hpp not found or not compilable with C++. Install glaze headers or disable with --with-glaze=no

Here is what I have:

│││ Name           Version
├┼┼─═══════════════════════
ii  libglaze-dev   7.3.3-1

and the verbose log:

configure:5674: checking for usable glaze/glaze.hpp with C++ compiler
configure:5687: g++ -c -g -O2  conftest.cpp >&5
In file included from /usr/include/glaze/glaze.hpp:35,
                 from conftest.cpp:30:
/usr/include/glaze/base64/base64.hpp: In function 'std::string glz::read_base64(std::string_view)':
/usr/include/glaze/base64/base64.hpp:28:8: error: 'glz::read_base64(std::string_view)::<lambda()>' called in a constant expression
   21 |       static constexpr std::array<int, 256> decode_table = [] {
      |                                                            ~~~~
   22 |          std::array<int, 256> t;
      |          ~~~~~~~~~~~~~~~~~~~~~~~
   23 |          t.fill(-1);
      |          ~~~~~~~~~~~
   24 |          for (int i = 0; i < 64; ++i) {
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   25 |             t[base64_chars[i]] = i;
      |             ~~~~~~~~~~~~~~~~~~~~~~~
   26 |          }
      |          ~
   27 |          return t;
      |          ~~~~~~~~~
   28 |       }();
      |       ~^~
/usr/include/glaze/base64/base64.hpp:21:60: note: 'glz::read_base64(std::string_view)::<lambda()>' is not usable as a 'constexpr' function because:
   21 |       static constexpr std::array<int, 256> decode_table = [] {
      |                                                            ^
/usr/include/glaze/base64/base64.hpp:23:16: error: call to non-'constexpr' function 'void std::array<_Tp, _Nm>::fill(const value_type&) [with _Tp = int; long unsigned int _Nm = 256; value_type = int]'
   23 |          t.fill(-1);
      |          ~~~~~~^~~~
In file included from /usr/include/glaze/base64/base64.hpp:6:
/usr/include/c++/15/array:123:7: note: 'void std::array<_Tp, _Nm>::fill(const value_type&) [with _Tp = int; long unsigned int _Nm = 256; value_type = int]' declared here
  123 |       fill(const value_type& __u)
      |       ^~~~
In file included from /usr/include/glaze/beve/header.hpp:13,
                 from /usr/include/glaze/beve.hpp:6,
                 from /usr/include/glaze/glaze.hpp:36:
/usr/include/glaze/core/context.hpp: At global scope:
/usr/include/glaze/core/context.hpp:130:4: error: 'concept' does not name a type; did you mean 'context'?
  130 |    concept is_context = requires(T& ctx) {
      |    ^~~~~~~
      |    context
/usr/include/glaze/core/context.hpp:130:4: note: 'concept' only available with '-std=c++20' or '-fconcepts'
/usr/include/glaze/core/context.hpp:147:4: error: 'concept' does not name a type; did you mean 'context'?
  147 |    concept has_runtime_max_string_length = requires(Ctx& ctx) {
      |    ^~~~~~~
      |    context
/usr/include/glaze/core/context.hpp:147:4: note: 'concept' only available with '-std=c++20' or '-fconcepts'
/usr/include/glaze/core/context.hpp:152:4: error: 'concept' does not name a type; did you mean 'context'?
  152 |    concept has_runtime_max_array_size = requires(Ctx& ctx) {
      |    ^~~~~~~
...

plus so-so much messages.

AC_LANG_PUSH([C++])
AC_MSG_CHECKING([for usable glaze/glaze.hpp with C++ compiler])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <glaze/glaze.hpp>]], [[return 0;]])],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([glaze/glaze.hpp not found or not compilable with C++. Install glaze headers or disable with --with-glaze=no])
]
)
AC_LANG_POP([C++])
AC_DEFINE([HAVE_GLAZE], [1], [Mark that system has glaze])
fi

dnl Check if we want to use jsoncons or not
AC_MSG_CHECKING([whether to use jsoncons])
AC_ARG_WITH(
[jsoncons],
[AS_HELP_STRING([--with-jsoncons], [Enable jsoncons (default is enabled if exists)])],
[case "$withval" in
yes) wantjsoncons=yes ;;
no) wantjsoncons=no; AC_DEFINE([HAVE_JSONCONS], [0], [Mark that user does not want jsoncons]) ;;
*) AC_MSG_ERROR([Invalid value for --with-feature: $withval]) ;;
esac],
[wantjsoncons="notset"]
)

if test "$wantjsoncons" != "no"; then
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([jsoncons/json.hpp], [],
[AC_MSG_ERROR([jsoncons/json.hpp not found. Install jsoncons headers or disable with --with-jsoncons=no])]
)
AC_LANG_POP([C++])
AC_DEFINE([HAVE_JSONCONS], [1], [Mark that system has jsoncons])
fi

AC_SUBST(JSONC_CFLAGS)
AC_SUBST(JSONC_LDADD)
AC_SUBST(JSONC_LDFLAGS)
AC_SUBST(JANSSON_CFLAGS)
AC_SUBST(JANSSON_LDADD)
AC_SUBST(JANSSON_LDFLAGS)
AC_SUBST(CJSON_CFLAGS)
AC_SUBST(CJSON_LDADD)
AC_SUBST(CJSON_LDFLAGS)
AC_SUBST(JSONCPP_CFLAGS)
AC_SUBST(JSONCPP_LDADD)
AC_SUBST(JSONCPP_LDFLAGS)
AC_SUBST(SIMDJSON_CFLAGS)
AC_SUBST(SIMDJSON_LDADD)
AC_SUBST(SIMDJSON_LDFLAGS)
AC_SUBST(YYJSON_CFLAGS)
AC_SUBST(YYJSON_LDADD)
AC_SUBST(YYJSON_LDFLAGS)
AC_SUBST(GLAZE_CFLAGS)

AC_ARG_WITH(
[file-buffer-size],
Expand Down
10 changes: 6 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
AM_CXXFLAGS = -Wall -g -O0 -std=c++17 -fPIC
AM_CFLAGS = -Wall -g -O0
AM_LDFLAGS= $(YAJL_LDFLAGS)
AM_LDFLAGS= $(YAJL_LDFLAGS) $(JSONC_LDFLAGS) $(JANSSON_LDFLAGS) $(CJSON_LDFLAGS) $(JSONCPP_LDFLAGS) $(SIMDJSON_LDFLAGS) $(YYJSON_LDFLAGS)

bin_PROGRAMS = jsonbench

jsonbench_SOURCES = yajlparser.c rjparser.cpp nlparser.cpp jsonbench.c
jsonbench_CFLAGS = $(AM_CFLAGS) $(YAJL_CFLAGS)
jsonbench_LDADD = $(YAJL_LDADD)
jsonbench_SOURCES = yajlparser.c rjparser.cpp nlparser.cpp jsoncparser.c janssonparser.c cjsonparser.c jsoncppparser.cpp jsonconsparser.cpp simdjsonparser.cpp yyjsonparser.c glazeparser.cpp jsonbench.c
jsonbench_CPPFLAGS = $(YAJL_CFLAGS) $(JSONC_CFLAGS) $(JANSSON_CFLAGS) $(CJSON_CFLAGS) $(JSONCPP_CFLAGS) $(SIMDJSON_CFLAGS) $(YYJSON_CFLAGS) $(GLAZE_CFLAGS)
jsonbench_CFLAGS = $(AM_CFLAGS)
jsonbench_CXXFLAGS = $(AM_CXXFLAGS)
jsonbench_LDADD = $(YAJL_LDADD) $(JSONC_LDADD) $(JANSSON_LDADD) $(CJSON_LDADD) $(JSONCPP_LDADD) $(SIMDJSON_LDADD) $(YYJSON_LDADD)
Loading