Move closer to the standard autotools idiom. (#3187)

* Create `src/config.h` instead of passing everything on the compiler
  command line.

* To reduce the magnitude of this change, add `--include src/config.h`
  to CFLAGS instead of adding `#include "src/config.h"` at the top of
  each source file.  Not all compilers support this, but I don't think
  we care about anything other than gcc and clang at this point.

* Rather than generate `src/config_opts.inc`, emit `JQ_CONFIG` directly
  into `src/config.h`.

* Rather than generate `src/version.h`, define `JQ_VERSION` as an alias
  for the standard `PACKAGE_VERSION`.
This commit is contained in:
Dag-Erling Smørgrav authored and GitHub committed 2025-01-25 17:10:05 +09:00
1 parent 71ed7b3412
commit d8463c2549
7 files changed
+20 -36

No files matched your search

+7 -2
View File
@@ -111,7 +111,7 @@ AC_ARG_ENABLE([decnum],
AS_HELP_STRING([--disable-decnum],[disable decnum support]))
AS_IF([test "x$enable_decnum" != "xno"],[
AC_DEFINE([USE_DECNUM],1)
AC_DEFINE([USE_DECNUM], 1, [Define to enable decnum support.])
])
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno])
@@ -125,7 +125,7 @@ AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes])
dnl Find pthread, if we have it. We do this first because we may set -pthread on CFLAGS
dnl which can cause various macros to be defined (__REENTRANT on Darwin, for example)
AX_PTHREAD([
AC_DEFINE([HAVE_PTHREAD], [1])
AC_DEFINE([HAVE_PTHREAD], [1], [Define to enable POSIX threads support.])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
@@ -242,6 +242,9 @@ AC_C_BIGENDIAN(
AC_MSG_ERROR(universal endianness not supported)
)
AC_DEFINE_UNQUOTED([JQ_CONFIG], ["$ac_cs_config"], [The options jq was configured with.])
AH_BOTTOM([#define JQ_VERSION PACKAGE_VERSION])
dnl Oniguruma
AC_ARG_WITH([oniguruma],
[AS_HELP_STRING([--with-oniguruma=prefix],
@@ -291,6 +294,8 @@ AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno])
AC_SUBST([BUNDLER], ["$bundle_cmd"])
AC_CONFIG_MACRO_DIRS([config/m4 m4])
AC_CONFIG_HEADERS([src/config.h])
CFLAGS="$CFLAGS --include src/config.h"
AC_CONFIG_FILES([Makefile libjq.pc])
AC_OUTPUT