Re: Kconfig, Makefile and ifdef: mod as yes vs. no?

From: Pekka Paalanen
Date: Sun Jul 12 2009 - 05:07:50 EST


On Sat, 11 Jul 2009 17:53:43 -0400
Kyle McMartin <kyle@xxxxxxxxxxx> wrote:

> On Sun, Jul 12, 2009 at 12:06:25AM +0300, Pekka Paalanen wrote:
> > +#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
> >
>
> You need to test _MODULE for the symbol too... since it's necessary to
> be able to distinguish between symbols which exist in the vmlinux, and
> symbols which require a module to be loaded.
>
> #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) &&
> defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
>
> should work.

Just || instead of &&, and yes, this is a solution for half of the problem,
thanks.

But what about the Makefile?

nouveau-y := nouveau_drv.o ...
nouveau-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += nouveau_backlight.o
obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o

With this, nouveau_backlight.o is not built if
CONFIG_BACKLIGHT_CLASS_DEVICE=m. Should I write:

nouveau-$(if $(findstring m,$(CONFIG_BACKLIGHT_CLASS_DEVICE)),y,n) += \
nouveau_backlight.o

which to me looks ugly, or add a new Kconfig boolean option that is
selected 'if CONFIG_BACKLIGHT_CLASS_DEVICE' and use that in both Makefile
and code, or is there a canonical way to do this?

Other code seems to deal with a similar situation by #ifdef'ing the
whole c-file contents. That cannot be the preferred way, can it?


Thanks.

--
Pekka Paalanen
http://www.iki.fi/pq/
--
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/