Autoconf allows multiple config files in AC_CONFIG_HEADERS
. From the Autoconf manual:
— Macro: AC_CONFIG_HEADERS (header ..., [cmds], [init-cmds])
This macro is one of the instantiating macros; see Configuration Actions. Make AC_OUTPUT create the file(s) in the blank-or-newline-separated list header containing C preprocessor #define statements, and replace ‘@DEFS@’ in generated files with -DHAVE_CONFIG_H instead of the value of DEFS. The usual name for header is config.h.
...
We use two config headers. The first one is called config_asm.h
, and includes defines for ISA availability, like SSE2, SSSE3, SSE4.1, AES, CLMUL, SHA, etc. The second one is called config_cxx.h
, and includes defines for C++ features, like atomics, alignof, alignas, synchronization, etc. Users include a top level config.h
which includes the subordinate config files, like config_asm.h
and config_cxx.h
.
I need to switch between the config files depending on the test being run. The manual does not discuss how to use multiple config files, and it does not provide an example of using multiple config files.
How do I switch between the config files when using Autoconf?
Here is what I have so far. I believe I need to change to something like AC_CONFIG_HEADERS([config_asm.h config_cxx.h])
. But it is not clear to me how to tell Autoconf to write results to a particular config file.
AC_INIT([Crypto++], [8.3], [http://cryptopp.com/bugs], [cryptopp], [http://cryptopp.com/])
AM_INIT_AUTOMAKE
AC_PROG_CXX
AC_LANG([C++])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config_asm.h])
AC_CONFIG_FILES([Makefile] [libray.pc])
AC_CONFIG_SRCDIR([configure.ac])
When I tell Autoconf there is a second config file it results in an error. I suspect I am missing something simple, but I'm not sure what it is since the manual does not discuss it.
AC_CONFIG_HEADERS([config_asm.h config_cxx.h])
results in:
autoreconf -f -i
...
configure.ac:105: installing './compile'
configure.ac:95: installing './missing'
configure.ac:101: error: required file 'config_cxx.h.in' not found
Makefile.am: installing './depcomp'