kbuild and CPPFLAGS (out-of-tree modules)
A message that is not in the archive (sent off-list or not yet received): [email protected]
[Included [email protected] - this is today
the kbuild mailing list.
I have in the past tried to close down the sourceforge list, alas without luck]
Quoted 9 lines · Paul Smith
Hi all. I'm trying to build an out-of-tree module, which actually has configuration associated with it (it has a
Kconfigfile and everything--although that doesn't help me for out-of-tree builds of course).I have my own makefile which invokes the appropriate kbuild-based make (setting O= etc. on the command line). I know what configure options I want to set as well.
Quoted 7 lines
So, I wanted to figure out how just pass a couple of -DCONFIG_...=... on the kbuild make command line such that they would be added to the compile line of my out-of-tree modules. Unfortunately I can't use
EXTRA_CFLAGS(easily) because the out-of-tree moduleMakefilesets some flags inEXTRA_CFLAGSitself. All things being equal I'd prefer not to change the module code, or have to duplicate those flags on my invocation line.
In kbuild all the EXTRA_* variables are for internal use in the individual kbuild files (named Makefiles for historical reasons).
We actually try to clear them before we include the kbuild files, to avoid any previous value and most users use ":=" to assign them. So in short - EXTRA_* is not to be used on the command line.
We invented a set of K{A,C,CPP}FLAGS to be used on the commandline. This was done to avoid picling up peoples random stuff they have assigned to for example CFLAGS.
A warning is issued to tell the user that we have picked up some flags on the commandline - this could hacve been an info.
So passing your options using KCFLAGS is the correct thing to do.
Quoted 6 lines
In normal make, the CPPFLAGS variable contains C preprocessor options and is included in each compile line automatically. I can see that kbuild supports
EXTRA_CPPFLAGSand cppflags-y etc. but these seem to have a different purpose; anyway they don't appear on any normal compile line. Is this an oversight? What are these cppflags variables intended for? I'm having a hard time finding where they are used.
Hmmm...
We use cppflags-y / EXTRA_CPPFLAGS for a single rule which preprocess linker scripts.
I cannot remember why we did it this way and it looks rather inconsistent. The right solution would have been to introduce another set of variables to deal with this special case and let cppflags-y / EXTRA_CPPFLAGS have effect on both as and cc invocations.
So I understand why you find it hard - since it is inconsistent.
From a quick grep we have ~20 linker script related assignments to CPPFLAGS_*
This would be easy to fix up - I will consider this.
Feel free to ask agoin if I fail to cover what you really wanted to know!
Sam