[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Conditional compiler flags based on the compiler (version) used



Hi,

I want to add "EXTRA_CFLAGS += -Werror=date-time" to the Makefile of my kernel 
module project (https://github.com/diederikdehaas/rtl8812AU) to support 
Reproducible Builds. But this makes the build fail when using Jessie (or 
older) since that flag isn't supported on GCC < 4.9. 
While gcc-4.9 is the default on Jessie, it looks like gcc-4.8 is used by 
default, which matches the value from /proc/version. There's a similar 
mismatch on Sid (and probably Stretch).

I thought to be able to handle my situation by doing "$(CC) -dumpversion" and 
this seems to work when make is invoked like "make CC=/usr/bin/gcc-4.9".
But when it's invoked with just "make" then $(CC) is reported back as "cc" and 
"cc -dumpversion" reports back the version of the _default_ compiler version, 
but as I described above that's not the same as the one actually used to 
compile my module.

How can I make my Makefile work across different Debian versions and also when 
make is invoked as just "make" and "make CC=/usr/bin/gcc-<version>" ?
(Preferably across distributions, but my main concern is Debian/Raspbian)

TIA,
  Diederik

PS: I also want to add other compiler flags conditionally, but I guess the 
principle would be the same for all.

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: