Import 2.1.81
[davej-history.git] / Documentation / smart-config.txt
blobeda5c3dfaa001f2650fcd1466196db83adaff7e2
1 Smart CONFIG_* Dependencies
2 Fri 2 Dec 1997
4 Michael Chastain   <mec@shout.net>
5 Werner Almesberger <almesber@lrc.di.epfl.ch>
6 Martin von Loewis  <martin@mira.isdn.cs.tu-berlin.de>
8 Here is the problem:
10     Suppose that drivers/net/foo.c has the following lines:
12         #include <linux/config.h>
14         ...
16         #ifdef CONFIG_FOO_AUTOFROB
17             /* Code for auto-frobbing */
18         #else
19             /* Manual frobbing only */
20         #endif
22         ...
24         #ifdef CONFIG_FOO_MODEL_TWO
25             /* Code for model two */
26         #endif
28     Now suppose the user (the person building kernels) reconfigures the
29     kernel to change some unrelated setting.  This will regenerate the
30     file include/linux/autoconf.h, which will cause include/linux/config.h
31     to be out of date, which will cause drivers/net/foo.c to be recompiled.
33     Most kernel sources, perhaps 80% of them, have at least one CONFIG_*
34     dependency somewhere.  So changing _any_ CONFIG_* setting requires
35     almost _all_ of the kernel to be recompiled.
37 Here is the solution:
39     We've made the dependency generator, mkdep.c, smarter.  Instead of
40     generating this dependency:
42         drivers/net/foo.c: include/linux/config.h
44     It now generates these dependencies:
46         drivers/net/foo.c: \
47             include/config/foo_autofrob.h \
48             include/config/foo_model_two.h
50     So drivers/net/foo.c depends only on the CONFIG_* lines that
51     it actually uses.
53     A new program, split-include.c, runs at the end of make config (also
54     make oldconfig, make menuconfig, and make xconfig).  split-include
55     reads include/linux/autoconf.h and updates the include/linux/*.h
56     directory, writing one file per option.  It updates only the files
57     that changed.
59     mkdep.c also generates much better warning messages for missing
60     or unneeded <linux/config.h> lines.  In fact, you can get these
61     messages without generating dependencies with the new top-level
62     target 'make checkconfig'.
64 Flag Dependencies
66     Martin Von Loewis contributed another feature to this patch:
67     'flag dependencies'.  The idea is that a .o file depends on
68     the compilation flags used to build it.  The file foo.o has
69     its flags stored in .flags.foo.o.
71     Suppose the user changes the foo driver from resident to
72     modular, 'make' will notice that the foo.o was not compiled
73     with -DMODULE and will recompile foo.c.
75     Flag dependencies also work with per-source-file flags such
76     as those in drivers/net/CONFIG.
78     All .a and .o files made from C source or with 'ld' or 'ar'
79     have flag dependencies.  .S files do not have flag dependencies.
81 Per-source-file Flags
83     You can specify compilation flags for individual source files
84     like this:
86         CFLAGS_foo.o = -DSPECIAL_FOO_DEFINE
88     This helps clean up drivers/net/Makefile, drivers/scsi/Makefile,
89     and several other Makefiles.
91 Credit
93     Werner Almesberger had the original idea and wrote the first
94     version of this patch.
95     
96     Michael Chastain picked it up and continued development.  He is
97     now the principal author and maintainer.  Report bugs to him,
98     or to all three people together.
100     Martin von Loewis wrote flag dependencies, with some modifications
101     by Michael Chastain.
103     Thanks to all of the beta testers.