I'm porting existing code to autotools. Previously, all defines were passed through the command line, e.g. -DOS_LINUX
.
There are many source files, some are generated.
In my configure.ac
I've added:
AC_CONFIG_HEADERS(config.h)
Now I want to be sure that if a source file does not include config.h
, compile fails.
My current solution is to redefine int
on command line and fix it back in config.h
:
CPPFLAGS="$CPPFLAGS -Dint=bad -I\$(top_srcdir)"
AH_BOTTOM([#include <custom.h>])
AC_OUTPUT
custom.h:
#undef int
I'm looking for a cleaner way. For example, is it correct to use the makefile variable $(top_srcdir)
the way I use it?
#include
d. Obviously the error messages will be syntax errors and the like (rather than something like "header file config.h needed" but it does cause the compilation unit to not compile. And, if there is no actual dependency, what does it matter if the header file is not#include
d? Redefining any keyword (includingint
) also causes undefined behaviour - even if later "fixed". – Peter