smart-config.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. Smart CONFIG_* Dependencies
  2. 1 August 1999
  3. Michael Chastain <mec@shout.net>
  4. Werner Almesberger <almesber@lrc.di.epfl.ch>
  5. Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>
  6. Here is the problem:
  7. Suppose that drivers/net/foo.c has the following lines:
  8. #include <linux/config.h>
  9. ...
  10. #ifdef CONFIG_FOO_AUTOFROB
  11. /* Code for auto-frobbing */
  12. #else
  13. /* Manual frobbing only */
  14. #endif
  15. ...
  16. #ifdef CONFIG_FOO_MODEL_TWO
  17. /* Code for model two */
  18. #endif
  19. Now suppose the user (the person building kernels) reconfigures the
  20. kernel to change some unrelated setting. This will regenerate the
  21. file include/linux/autoconf.h, which will cause include/linux/config.h
  22. to be out of date, which will cause drivers/net/foo.c to be recompiled.
  23. Most kernel sources, perhaps 80% of them, have at least one CONFIG_*
  24. dependency somewhere. So changing _any_ CONFIG_* setting requires
  25. almost _all_ of the kernel to be recompiled.
  26. Here is the solution:
  27. We've made the dependency generator, mkdep.c, smarter. Instead of
  28. generating this dependency:
  29. drivers/net/foo.c: include/linux/config.h
  30. It now generates these dependencies:
  31. drivers/net/foo.c: \
  32. include/config/foo/autofrob.h \
  33. include/config/foo/model/two.h
  34. So drivers/net/foo.c depends only on the CONFIG_* lines that
  35. it actually uses.
  36. A new program, split-include.c, runs at the beginning of
  37. compilation (make bzImage or make zImage). split-include reads
  38. include/linux/autoconf.h and updates the include/config/ tree,
  39. writing one file per option. It updates only the files for options
  40. that have changed.
  41. Flag Dependencies
  42. Martin Von Loewis contributed another feature to this patch:
  43. 'flag dependencies'. The idea is that a .o file depends on
  44. the compilation flags used to build it. The file foo.o has
  45. its flags stored in .flags.foo.o.
  46. Suppose the user changes the foo driver from resident to modular.
  47. 'make' will notice that the current foo.o was not compiled with
  48. -DMODULE and will recompile foo.c.
  49. All .o files made from C source have flag dependencies. So do .o
  50. files made with ld, and .a files made with ar. However, .o files
  51. made from assembly source do not have flag dependencies (nobody
  52. needs this yet, but it would be good to fix).
  53. Per-source-file Flags
  54. Flag dependencies also work with per-source-file flags.
  55. You can specify compilation flags for individual source files
  56. like this:
  57. CFLAGS_foo.o = -DSPECIAL_FOO_DEFINE
  58. This helps clean up drivers/net/Makefile, drivers/scsi/Makefile,
  59. and several other Makefiles.
  60. Credit
  61. Werner Almesberger had the original idea and wrote the first
  62. version of this patch.
  63. Michael Chastain picked it up and continued development. He is
  64. now the principal author and maintainer. Please report any bugs
  65. to him.
  66. Martin von Loewis wrote flag dependencies, with some modifications
  67. by Michael Chastain.
  68. Thanks to all of the beta testers.