Re: kbuild: shorthand ym2y, ym2m etc

From: Arnd Bergmann
Date: Sun Jan 30 2005 - 17:54:47 EST


On Sünndag 30 Januar 2005 20:37, Sam Ravnborg wrote:
> We have in several cases the need to transpose a i'm' to 'y' in the Kbuild
> files.
> One example is the following snippet from sound/Makefile:
> ifeq ($(CONFIG_SND),y)
> obj-y += last.o
> endif
>
> Alternative syntax could be:
> obj-$(call y2y,CONFIG_SND) += last.o

You can already write this as

last-$(CONFIG_SND) := last.o
obj-y += $(last-y)

I'm not sure if this is better than the current version, but I'd
prefer it to using the extra function.

> From drivers/vidoe/Makfile:
> ifeq ($(CONFIG_FB),y)
> obj-$(CONFIG_PPC) += macmodes.o
> endif

macmodes-$(CONFIG_FB) := macmodes.o
obj-$(CONFIG_PPC) += $(macmodes-y)

> ym2y
> ym2m

tmp-$(CONFIG_FOO) := foo.o
tmp-$(CONFIG_BAR) := $(tmp-y)
obj-m += $(tmp-m)

> empty2y
> empty2m

tmp-$(CONFIG_FOO) := foo.o
obj-m += $(tmp-) $(tmp-n)

> y2y
> m2y
> y2m
> m2m
> yx2x
> mx2x
>
> Would that be considered usefull?

I don't fully understand what all those examples should do, so they
are probably not that intuitive. I'm pretty sure that we can already
express them all with either ifeq() or two assignments, though.
Both are already used in the kernel (see ipc/Makefile for an
example of yx2x), so maybe the preferred style should be documented
in CodingStyle.

Arnd <><

Attachment: pgp00000.pgp
Description: signature