Re: autoconf.h #defines different names for modules/non-modules

David Woodhouse (David.Woodhouse@mvhi.com)
Wed, 09 Sep 1998 09:57:58 +0100


> ... in drivers/char/Makefile:
>
> ifeq ($(CONFIG_DFS_TRACE),y)
> LX_OBJS += dfs_trace_buffer.o
> else
> ifeq ($(CONFIG_DFS_TRACE),m)
> MX_OBJS += dfs_trace_buffer.o
> endif
> endif
>
> ... in include/linux/autoconf.h:
>
> #undef CONFIG_DFS_TRACE
> #define CONFIG_DFS_TRACE_MODULE 1
>
> Yipes. This certainly isn't apparent from the Makefile!

I think the Makefile gets its defines from .config . So CONFIG_DFS_TRACE
is defined as either 'y' or 'm' in the Makefile, or is undefined.

In the C code, the defines are taken from autoconf.h, and they're different.

> In any case, I hope the proper way to #ifdef out code that needs to go
> into the kernel proper (i.e. not a driver) whether or not something is
> compiled in as a module is:
>
> #ifdef CONFIG_DFS_TRACE || CONFIG_DFS_TRACE_MODULE
> ...
> #endif
>
> but that looks awfully silly. Why is this necessary?

Because in general it's a silly thing to do. If something is compiled as a
module, it should be usable in a standard kernel¹. The kernel itself shouldn't
change according to which modules are compiled with it.

It's extremely useful to be able to compile new modules for new hardware or
features without having to recompile the whole kernel. If every modular driver
did this kind of thing, it'd be impossible.

( Take a look at the PC speaker driver for a prime example of this bad
behaviour - you can only load the pcsnd.o module into a kernel which
was compiled with CONFIG_PCSP=m :)

¹ - Ideally. I'm not telling you that you shouldn't do this at all. But that's
why nobody's bothered to make it look nice when you do it.

---- ---- ----
David Woodhouse David.Woodhouse@mvhi.com Office: (+44) 1223 810302
Project Leader, Process Information Systems Mobile: (+44) 976 658355
Axiom (Cambridge) Ltd., Swaffham Bulbeck, Cambridge, CB5 0NA, UK.
finger dwmw2@ferret.lmh.ox.ac.uk for PGP key.

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