Simplest way to wrap an "AC_DEFINE_UNQUOTED" output around #ifndef and #endif?
0
votes
0
answers
29
views
This line for example
AC_DEFINE_UNQUOTED([SOME_MACRO_NAME], "$SOME_VALUE", [some comment])
generates
printf "%s\n" "#define SOME_MACRO_NAME \"$SOME_VALUE\"" >>confdefs.h
as a line in
configure
.
And something like the following in config.h
after configure
is run:
/* some comment */
#define SOME_MACRO_NAME ""
How would I make it produce the following instead?
/* some comment */
#ifndef SOME_MACRO_NAME
#define SOME_MACRO_NAME ""
#endif
Surely I can add some printf
lines manually or create a custom function but shouldn't there be an idiomatic way to do this already? Either methods I mentioned are hackish either way as I'm asserting confdefs.h
is the file being temporarily produced.
I'm already seeing people would be suggesting testing $SOME_VALUE
maybe through AS_IF
or m4_if
(or any of their applicable variants) instead but that's a varying use case. I might want to have the variable overridable through autoreconf
, through ./configure
or through CFLAGS
with the -D
option. It depends. But right now I just want the answer for this.
Also somebody might suggest using a template. Please, please no.
Asked by konsolebox
(1107 rep)
Dec 2, 2024, 04:20 PM
Last activity: Dec 2, 2024, 04:25 PM
Last activity: Dec 2, 2024, 04:25 PM