diff --git a/.gitignore b/.gitignore index cb8812c6..f1f12990 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,9 @@ reconfigure.sh */Depend*.tmp .deps/ database/database.h +# autoconf config header, generated by ./configure (in-tree location; out-of-tree +# it lives under the build dir's include/ and is covered by the build-dir rules). +magic/autoconf/config.h # Editor / OS cruft .*.swp diff --git a/scripts/configure b/scripts/configure index 7dfa7d2a..5f93d65c 100755 --- a/scripts/configure +++ b/scripts/configure @@ -9398,6 +9398,24 @@ ac_config_files="$ac_config_files scripts/makedbh:scripts/makedbh.in" ac_config_files="$ac_config_files rules.mak:rules.mak" + +if test "`cd $srcdir && pwd`" = "`pwd`" ; then + magic_config_header=magic/autoconf/config.h +else + magic_config_header=include/magic/autoconf/config.h +fi +mkdir -p "`dirname $magic_config_header`" +{ + echo "/* $magic_config_header -- generated by configure; DO NOT EDIT. */" + echo "/* Every autoconf define (>= all -D options on the compiler lines). */" + echo "#ifndef _MAGIC_AUTOCONF_CONFIG_H" + echo "#define _MAGIC_AUTOCONF_CONFIG_H 1" + grep '^#define ' confdefs.h | sort -u + echo "#endif /* _MAGIC_AUTOCONF_CONFIG_H */" +} > "$magic_config_header" +{ $as_echo "$as_me:${as_lineno-$LINENO}: created config header $magic_config_header" >&5 +$as_echo "$as_me: created config header $magic_config_header" >&6;} + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure diff --git a/scripts/configure.in b/scripts/configure.in index a703cdc1..c928c238 100644 --- a/scripts/configure.in +++ b/scripts/configure.in @@ -2002,6 +2002,38 @@ dnl Copy rules.mak into the build top (it has no @...@ substitutions; this just dnl places it next to the generated defs.mak so a single ${MAGICDIR} resolves dnl both `include`s in every subdir Makefile out-of-tree). AC_CONFIG_FILES([rules.mak:rules.mak]) + +dnl Emit an autoconf config header, available to the tree as +dnl #include +dnl It carries every autoconf define (i.e. at least all the -D options that +dnl appear on the compiler command lines, plus anything else configure knows). +dnl We build it here, from confdefs.h, rather than via AC_CONFIG_HEADERS on +dnl purpose: that keeps @DEFS@ (hence the command lines and the whole build) +dnl exactly as-is, so the header is a pure additional artifact with no consumers +dnl yet. confdefs.h holds every AC_DEFINE and is still present at this point +dnl (AC_OUTPUT removes it), so it must run before AC_OUTPUT. +dnl +dnl Location mirrors the generated database.h (see defs.mak GENINC): at the +dnl build top when in-tree (build dir == source dir), else under a clean +dnl include/ subdir so the -I include/ rule finds and +dnl the raw build dir is never on the search path. Regenerated on every +dnl ./configure; the directory is created on demand. +if test "`cd $srcdir && pwd`" = "`pwd`" ; then + magic_config_header=magic/autoconf/config.h +else + magic_config_header=include/magic/autoconf/config.h +fi +mkdir -p "`dirname $magic_config_header`" +{ + echo "/* $magic_config_header -- generated by configure; DO NOT EDIT. */" + echo "/* Every autoconf define (>= all -D options on the compiler lines). */" + echo "#ifndef _MAGIC_AUTOCONF_CONFIG_H" + echo "#define _MAGIC_AUTOCONF_CONFIG_H 1" + grep '^#define ' confdefs.h | sort -u + echo "#endif /* _MAGIC_AUTOCONF_CONFIG_H */" +} > "$magic_config_header" +AC_MSG_NOTICE([created config header $magic_config_header]) + AC_OUTPUT dnl