Re: [RFC] Extending kbuild syntax



On Sat, Sep 29, 2007 at 10:11:45PM +0200, Sam Ravnborg wrote:
...
The second is the more controversial suggestion.
In several Makefile we have simple if expression of the variants:
if ($(CONFIG_FOO),y)
obj-$(CONFIG_BAR) += fubar.o
endif

The pattern varies over this theme.
The suggestion here is to introduce a few helpers:

obj-y-if-$(CONFIG_FOO) += fubar.o
This one shall read:
if $(CONFIG_FOO) is y or m then set += to obj-y

IMHO for people who are not kbuild junkies the pattern is more clear
with the current syntax.

But you should better ask some guinea pigs who have not already seen as
many kernel Makefiles as I have...

In several cases we will need it to be more complicated like the this:
obj-y-ify-$(CONFIG_FOO) += fubar.o
This one shall read:
if $(CONFIG_FOO) is y (thats the ify thing) then += to obj-y

And we can mix it like the following:
obj-$(CONFIG_BAR)-ify-$(CONFIG_FOO) += fubar.o
This one shall read:
if $(CONFIG_FOO) equal y then += to obj-$(CONFIG_BAR)


The full list of new variables are (for obj-y):
obj-y-if-y
obj-y-if-m

obj-y-ify-y
obj-y-ifm-m

obj-y-ifn-

And similar for obj-m:
obj-m-if-y
obj-m-if-m

obj-m-ify-y
obj-m-ifm-m

obj-m-ifn-

The 'y' and 'm' can be replaced by $(CONFIG_FOO) but the one right
to the if are not supposed to be replaced.


To better express how to use it I have tried to update a few Makefiles
to use the new syntax. See below.

On MAJOR drawback is the linking order.
I have no way to keep the link order if the new syntax are sued. The
.o files will either be put before .o files specified with obj-y or obj-m or
after the same.

For some places this does not matter but for other places (fs/Makefile)
I will expect it to matter a lot.

Comments?
Is this just to magic for bare humans to grasp.
Or mabe the linking order is so important that we do not want it?
...

Some of the cases have the following pattern:

config X86_POWERNOW_K8_ACPI
bool
depends on X86_POWERNOW_K8 && ACPI_PROCESSOR
depends on !(X86_POWERNOW_K8 = y && ACPI_PROCESSOR = m)
default y

Your suggested syntax has to be enhanced with three additional
variables for handling such cases.


The complicated cases can be handled either in kconfig or in kbuild,
and I think kconfig is the better place for them:

Handling it in kconfig has the advantage that we also get a variable we
can use in C code.

For all the *-if-m and *-m-if{,n}-* cases this is a huge advantage over
having to express the whole dependency in each #if.

Compare
#if defined(CONFIG_ACPI_PROCESSOR) || (defined(CONFIG_ACPI_PROCESSOR_MODULE && defined(MODULE))
with
#ifdef CONFIG_X86_POWERNOW_K8_ACPI

Sam
...

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Per-target make rules.
    ... directory containing object files with a common set of CFLAGS. ... So I took your suggestion and did it that way, ... Makefiles that accomplish something similar, ... I could go back to using the solution of placing .o files in separate ...
    (comp.unix.programmer)
  • Re: How to improve performance of regular expression pattern matching
    ... did you try Ed's suggestion to create one regular ... > expression for all of the array elements? ... The reason I used an array of patterns rather than a single pattern ...
    (comp.unix.shell)
  • Re: Script to search an input file, insert a line and then update the file
    ... subject line, i.e. read in a file, search for specific string, if the ... Rainer's suggestion of ed is cool: ... the file foo, but I don't even know how to easily extend it to ... if the pattern doesn't appear in the file. ...
    (comp.unix.programmer)
  • Re: Script to search an input file, insert a line and then update the file
    ... Rainer's suggestion of ed is cool: ... if the pattern doesn't appear in the file. ... Here's a python snippet ... for line in buf: ...
    (comp.unix.programmer)
  • Re: Data conversion
    ... My next suggestion would be the same as Carsten's. ... If you can't spot any ... pattern by looking at the data, you may have to use whatever export ... Install a printer on your system which "prints" ...
    (microsoft.public.fox.helpwanted)