How to specify a value for a #define with autoconf?
Asked Answered
W

1

6

I'm trying to build Gnu binutils with behaviour unlocked by defining the macro SYSV386_COMPAT 0 to vary the way in which it generates some FPU opcodes.

I can easily go into the header file and set the value manually, but how would I invoke the configure script in order to specify the equivalent of #define SYSV386_COMPAT 0 on the command line? I would prefer to specify something on the command line if at all possible (just because the feature is transitive and I don't think I should be hacking the source). Having said that, I have tried to read at least some of the FM but have had no luck with inserting an AC_DEFINE(SYSV386_COMPAT, 0) in either binutils/configure.in or gas/configure.in.

Wicketkeeper answered 9/3, 2012 at 13:22 Comment(3)
I don't have sufficient credit here to answer my own question yet, I need to wait another few hours, permitting helpful souls like yourselves to slave away at answering a question to which I have found the answer. I'll post when I can, till then it lies in using ./configure CFLAGS=-DSYSV386_COMPAT=0...Wicketkeeper
You should use CPPFLAGS instead of CFLAGS. This will allow the default CFLAGS to be set, so you'll get optimizations. Also, the convention is for preprocessor flags to be in CPPFLAGSMeltwater
Thanks William, that's very welcome advice.Wicketkeeper
W
4

OK, so continued searching through other autoconf-tagged answers took me to the second comment for this answer.

I was able to use a similar syntax to invoke configure to get the result I was after:

./configure CPPFLAGS=-DSYSV386_COMPAT=0 --prefix=/path/to/my/deploy/dir

Thanks to William Pursell for his comment above pointing out the benefits of using CPPFLAGS instead of CFLAGS, and to anyone who was preparing to answer this question. If you have any further comments about the "best" way of solving this problem then please add to this thread for those coming to it later.

Best wishes,

Michael

Wicketkeeper answered 9/3, 2012 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.