All of lore.kernel.org
 help / color / mirror / Atom feed
* kbuild: shorthand ym2y, ym2m etc
@ 2005-01-30 19:37 Sam Ravnborg
  2005-01-30 19:48 ` Muli Ben-Yehuda
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Sam Ravnborg @ 2005-01-30 19:37 UTC (permalink / raw)
  To: linux-kernel

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


y2y takes one parameter and return y unly if parameter is y, otherwise
return nothing.


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

Altetnative syntax:
obj-$(call yx2x,CONFIG_FB,CONFIG_PPC) += mcmodes.o

yx2x return second parameter (x) if first parameter is y. Otherwise
nothing is returned.

To be complete the full set would be:

ym2y
ym2m
empty2y
empty2m
y2y
m2y
y2m
m2m
yx2x
mx2x

Would that be considered usefull?

	Sam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 19:37 kbuild: shorthand ym2y, ym2m etc Sam Ravnborg
@ 2005-01-30 19:48 ` Muli Ben-Yehuda
  2005-01-30 19:52 ` Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Muli Ben-Yehuda @ 2005-01-30 19:48 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

On Sun, Jan 30, 2005 at 08:37:33PM +0100, Sam Ravnborg wrote:

> Would that be considered usefull?

IMHO, no. Small languages are only useful when they are more
descriptive than the alternative. In this case, you are replacing two
obvious lines with one entirely not obvious line, causing the Makefile
to become less readable.

Cheers, 
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 19:37 kbuild: shorthand ym2y, ym2m etc Sam Ravnborg
  2005-01-30 19:48 ` Muli Ben-Yehuda
@ 2005-01-30 19:52 ` Christoph Hellwig
  2005-01-30 22:39   ` Sam Ravnborg
  2005-01-30 22:41 ` Arnd Bergmann
  2005-01-31  1:57 ` Andreas Gruenbacher
  3 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2005-01-30 19:52 UTC (permalink / raw)
  To: linux-kernel

> 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

This should go away with either syntax, and I don't think yours is much
cleaner..

> ifeq ($(CONFIG_FB),y)
>   obj-$(CONFIG_PPC)                 += macmodes.o
> endif
> 
> Altetnative syntax:
> obj-$(call yx2x,CONFIG_FB,CONFIG_PPC) += mcmodes.o

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

would be a lot more obvious, but I'm not sure how to handle
it for the case where one of them evaluates to m


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 19:52 ` Christoph Hellwig
@ 2005-01-30 22:39   ` Sam Ravnborg
  2005-01-30 22:44     ` Russell King
  0 siblings, 1 reply; 9+ messages in thread
From: Sam Ravnborg @ 2005-01-30 22:39 UTC (permalink / raw)
  To: Christoph Hellwig, linux-kernel

On Sun, Jan 30, 2005 at 07:52:30PM +0000, Christoph Hellwig wrote:
> 
> obj-$(CONFIG_FB)$(CONFIG_PPC)		+= macmodes.o
> 
> would be a lot more obvious, but I'm not sure how to handle
> it for the case where one of them evaluates to m

The real problem is when say CONFIG_FB are empty. Then kbuild will see:
obj-$(CONFIG_PPC) which I doubt was what you wanted.

This can be fixed by changing Kconfig to evaluate all known symbols to
either y,m,n - in contradiction to today where symbols that evaluate
to n is left empty.

	Sam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 19:37 kbuild: shorthand ym2y, ym2m etc Sam Ravnborg
  2005-01-30 19:48 ` Muli Ben-Yehuda
  2005-01-30 19:52 ` Christoph Hellwig
@ 2005-01-30 22:41 ` Arnd Bergmann
  2005-01-30 22:59   ` Sam Ravnborg
  2005-01-31  1:57 ` Andreas Gruenbacher
  3 siblings, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2005-01-30 22:41 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

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 #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 22:39   ` Sam Ravnborg
@ 2005-01-30 22:44     ` Russell King
  2005-01-30 22:51       ` Sam Ravnborg
  0 siblings, 1 reply; 9+ messages in thread
From: Russell King @ 2005-01-30 22:44 UTC (permalink / raw)
  To: Christoph Hellwig, linux-kernel

On Sun, Jan 30, 2005 at 11:39:26PM +0100, Sam Ravnborg wrote:
> On Sun, Jan 30, 2005 at 07:52:30PM +0000, Christoph Hellwig wrote:
> > 
> > obj-$(CONFIG_FB)$(CONFIG_PPC)		+= macmodes.o
> > 
> > would be a lot more obvious, but I'm not sure how to handle
> > it for the case where one of them evaluates to m
> 
> The real problem is when say CONFIG_FB are empty. Then kbuild will see:
> obj-$(CONFIG_PPC) which I doubt was what you wanted.
> 
> This can be fixed by changing Kconfig to evaluate all known symbols to
> either y,m,n - in contradiction to today where symbols that evaluate
> to n is left empty.

Isn't that rather hard to achieve, unless all Kconfig files (including
all architecture specific ones) are read?  Eg, CONFIG_PPC wouldn't
exist on ARM.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 22:44     ` Russell King
@ 2005-01-30 22:51       ` Sam Ravnborg
  0 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2005-01-30 22:51 UTC (permalink / raw)
  To: Christoph Hellwig, linux-kernel

On Sun, Jan 30, 2005 at 10:44:52PM +0000, Russell King wrote:
 > This can be fixed by changing Kconfig to evaluate all known symbols to
> > either y,m,n - in contradiction to today where symbols that evaluate
> > to n is left empty.
> 
> Isn't that rather hard to achieve, unless all Kconfig files (including
> all architecture specific ones) are read?  Eg, CONFIG_PPC wouldn't
> exist on ARM.

Exactly - thats why I wrote "all known".
I do not see this as the solution that solve more than it breaks.
So I have not even tried it out.

	Sam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 22:41 ` Arnd Bergmann
@ 2005-01-30 22:59   ` Sam Ravnborg
  0 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2005-01-30 22:59 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Sam Ravnborg, linux-kernel

On Sun, Jan 30, 2005 at 11:41:34PM +0100, Arnd Bergmann wrote:
> 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.

Thanks for input

I will try to do something. But their home will be
Documentation/kbuild/makefiles.txt

	Sam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: shorthand ym2y, ym2m etc
  2005-01-30 19:37 kbuild: shorthand ym2y, ym2m etc Sam Ravnborg
                   ` (2 preceding siblings ...)
  2005-01-30 22:41 ` Arnd Bergmann
@ 2005-01-31  1:57 ` Andreas Gruenbacher
  3 siblings, 0 replies; 9+ messages in thread
From: Andreas Gruenbacher @ 2005-01-31  1:57 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

On Sunday 30 January 2005 20:37, Sam Ravnborg wrote:
> We have in several cases the need to transpose a i'm' to 'y' in the Kbuild
> files.

I assume you mean what you write in the text rather than what the example 
shows. If so, why not use this:

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

> One example is the following snippet from sound/Makefile:
> ifeq ($(CONFIG_SND),y)
>   obj-y += last.o
> endif
>
> [...]
>
> To be complete the full set would be:
>
> ym2y
> ym2m
> empty2y
> empty2m
> y2y
> m2y
> y2m
> m2m
> yx2x
> mx2x
>
>
> Would that be considered usefull?

That would take the kbuild makefile obfuscation contest to the next level. Who 
should understand that stuff?

Cheers,
-- 
Andreas Gruenbacher <agruen@suse.de>
SUSE Labs, SUSE LINUX PRODUCTS GMBH

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-01-31  1:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-30 19:37 kbuild: shorthand ym2y, ym2m etc Sam Ravnborg
2005-01-30 19:48 ` Muli Ben-Yehuda
2005-01-30 19:52 ` Christoph Hellwig
2005-01-30 22:39   ` Sam Ravnborg
2005-01-30 22:44     ` Russell King
2005-01-30 22:51       ` Sam Ravnborg
2005-01-30 22:41 ` Arnd Bergmann
2005-01-30 22:59   ` Sam Ravnborg
2005-01-31  1:57 ` Andreas Gruenbacher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.