4

I am trying to compile the code for one of the projects and the source file uses autoreconf for generating the makefiles.

" autoreconf --verbose --force --make "

The problem is that this somehow generates the makefiles that uses the compiler as GCC. I want it to generate the configuration files with a different compiler. How can I do it?

I can issue the command as make CC= but this throws an error in the libtool that is used later on.

Thank You

1 Answers1

7

Typically autoreconf just regenerates the configure script and the autoconf makefile templates, it doesn't create any actual makefiles.

Makefiles get created when configure is run, and that's when you want to override the compiler:

configure CC=clang CXX=clang++

that should create makefiles that use CC=clang and CXX=clang++

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
  • For what `autoreconf` and the auto-tools do see [the Goat book](https://www.sourceware.org/autobook/), but overriding makefile variables when running `configure` is just longstanding convention that has been standard practice for decades. – Jonathan Wakely Sep 02 '15 at 17:21
  • 1
    @Jason that means the configure script you're using has checks added for the compiler version, and those checks are not compatible with clang. Not every configure script does that. My answer can't be expected to cover the specifics of every configure script in the world. (Also the latest clang is not 4.x, but clang pretends to be GCC 4.2.1 which is probably the problem). – Jonathan Wakely May 09 '19 at 21:52
  • I hear you @Jonathan. I agree that your answer cannot be expected to cover every configure script. But given that I used your answer and it didn't work, I suggest a simple one line clue: "Configure scripts can override these arguments, thought they probably shouldn't." After looking into the problem I had more closely, I did indeed find the author had overridden default checks. I think it was a poor design choice on his part given there are standard ways to do these things. – Jason May 20 '19 at 16:40
  • I also notice my message was deleted... I think that should not have happened. Others may have the same problem I had, and reading my message may help them. This is one of the purposes of comments on answers. – Jason May 20 '19 at 16:41
  • Autoconf is designed to allow customisation, so it would be entirely wrong to say authors of configure scripts should not change the defaults. – Jonathan Wakely May 20 '19 at 17:14
  • I hear you hold the opinion that authors should take the liberty to override defaults in configure scripts. Let me be clear what I mean and where the confusion may be. I do not think authors should override variables like `CC` with their own custom ones. If the user compiling the code specifies `CC` and `CXX` then those should be accepted. If they are not valid to compile the software then a suitable error message should be displayed. What the author of the code I was using did was re-implement a compiler check included with autoconf. I believe that is not the purpose of autoconf. – Jason May 31 '19 at 18:36
  • I think we're getting a bit off topic here... but for readers the take away should be that specifying `CC` and `CXX` on the command line may not work if the author chose to discard them or override them. Nothing in autoconf prevents this. – Jason May 31 '19 at 18:36