Makefile 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. # SPDX-License-Identifier: GPL-2.0
  2. # ===========================================================================
  3. # Kernel configuration targets
  4. # These targets are used from top-level makefile
  5. PHONY += xconfig gconfig menuconfig config syncconfig \
  6. localmodconfig localyesconfig
  7. ifdef KBUILD_KCONFIG
  8. Kconfig := $(KBUILD_KCONFIG)
  9. else
  10. Kconfig := Kconfig
  11. endif
  12. ifeq ($(quiet),silent_)
  13. silent := -s
  14. endif
  15. # We need this, in case the user has it in its environment
  16. unexport CONFIG_
  17. xconfig: $(obj)/qconf
  18. $< $(silent) $(Kconfig)
  19. gconfig: $(obj)/gconf
  20. $< $(silent) $(Kconfig)
  21. menuconfig: $(obj)/mconf
  22. $< $(silent) $(Kconfig)
  23. config: $(obj)/conf
  24. $< $(silent) --oldaskconfig $(Kconfig)
  25. nconfig: $(obj)/nconf
  26. $< $(silent) $(Kconfig)
  27. # This has become an internal implementation detail and is now deprecated
  28. # for external use.
  29. syncconfig: $(obj)/conf
  30. $(Q)mkdir -p include/config include/generated
  31. $< $(silent) --$@ $(Kconfig)
  32. localyesconfig localmodconfig: $(obj)/conf
  33. $(Q)mkdir -p include/config include/generated
  34. $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
  35. $(Q)if [ -f .config ]; then \
  36. cmp -s .tmp.config .config || \
  37. (mv -f .config .config.old.1; \
  38. mv -f .tmp.config .config; \
  39. $< $(silent) --oldconfig $(Kconfig); \
  40. mv -f .config.old.1 .config.old) \
  41. else \
  42. mv -f .tmp.config .config; \
  43. $< $(silent) --oldconfig $(Kconfig); \
  44. fi
  45. $(Q)rm -f .tmp.config
  46. # These targets map 1:1 to the commandline options of 'conf'
  47. simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
  48. alldefconfig randconfig listnewconfig olddefconfig
  49. PHONY += $(simple-targets)
  50. $(simple-targets): $(obj)/conf
  51. $< $(silent) --$@ $(Kconfig)
  52. PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
  53. # oldnoconfig is an alias of olddefconfig, because people already are dependent
  54. # on its behavior (sets new symbols to their default value but not 'n') with the
  55. # counter-intuitive name.
  56. oldnoconfig: olddefconfig
  57. @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
  58. @echo " Please use \"olddefconfig\" instead, which is an alias."
  59. # We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
  60. silentoldconfig: syncconfig
  61. @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
  62. @echo " and is now an internal implementation detail."
  63. @echo " What you want is probably \"oldconfig\"."
  64. @echo " \"silentoldconfig\" will be removed after Linux 4.19"
  65. savedefconfig: $(obj)/conf
  66. $< $(silent) --$@=defconfig $(Kconfig)
  67. defconfig: $(obj)/conf
  68. ifeq ($(KBUILD_DEFCONFIG),)
  69. $< $(silent) --defconfig $(Kconfig)
  70. else
  71. ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
  72. @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  73. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  74. else
  75. @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
  76. $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
  77. endif
  78. endif
  79. %_defconfig: $(obj)/conf
  80. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
  81. configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
  82. %.config: $(obj)/conf
  83. $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
  84. $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
  85. +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
  86. PHONY += kvmconfig
  87. kvmconfig: kvm_guest.config
  88. @:
  89. PHONY += xenconfig
  90. xenconfig: xen.config
  91. @:
  92. PHONY += tinyconfig
  93. tinyconfig:
  94. $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
  95. # CHECK: -o cache_dir=<path> working?
  96. PHONY += testconfig
  97. testconfig: $(obj)/conf
  98. $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
  99. -o cache_dir=$(abspath $(obj)/tests/.cache) \
  100. $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
  101. clean-dirs += tests/.cache
  102. # Help text used by make help
  103. help:
  104. @echo ' config - Update current config utilising a line-oriented program'
  105. @echo ' nconfig - Update current config utilising a ncurses menu based program'
  106. @echo ' menuconfig - Update current config utilising a menu based program'
  107. @echo ' xconfig - Update current config utilising a Qt based front-end'
  108. @echo ' gconfig - Update current config utilising a GTK+ based front-end'
  109. @echo ' oldconfig - Update current config utilising a provided .config as base'
  110. @echo ' localmodconfig - Update current config disabling modules not loaded'
  111. @echo ' localyesconfig - Update current config converting local mods to core'
  112. @echo ' defconfig - New config with default from ARCH supplied defconfig'
  113. @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
  114. @echo ' allnoconfig - New config where all options are answered with no'
  115. @echo ' allyesconfig - New config where all options are accepted with yes'
  116. @echo ' allmodconfig - New config selecting modules when possible'
  117. @echo ' alldefconfig - New config with all symbols set to default'
  118. @echo ' randconfig - New config with random answer to all options'
  119. @echo ' listnewconfig - List new options'
  120. @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
  121. @echo ' default value without prompting'
  122. @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
  123. @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
  124. @echo ' tinyconfig - Configure the tiniest possible kernel'
  125. @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
  126. # ===========================================================================
  127. # Shared Makefile for the various kconfig executables:
  128. # conf: Used for defconfig, oldconfig and related targets
  129. # object files used by all kconfig flavours
  130. conf-objs := conf.o zconf.tab.o
  131. hostprogs-y := conf
  132. targets += zconf.lex.c
  133. # generated files seem to need this to find local include files
  134. HOSTCFLAGS_zconf.lex.o := -I$(src)
  135. HOSTCFLAGS_zconf.tab.o := -I$(src)
  136. # nconf: Used for the nconfig target based on ncurses
  137. hostprogs-y += nconf
  138. nconf-objs := nconf.o zconf.tab.o nconf.gui.o
  139. HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
  140. HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
  141. HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
  142. $(obj)/nconf.o: $(obj)/.nconf-cfg
  143. # mconf: Used for the menuconfig target based on lxdialog
  144. hostprogs-y += mconf
  145. lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
  146. mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
  147. HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
  148. $(foreach f, mconf.o $(lxdialog), \
  149. $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
  150. $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg
  151. # qconf: Used for the xconfig target based on Qt
  152. hostprogs-y += qconf
  153. qconf-cxxobjs := qconf.o
  154. qconf-objs := zconf.tab.o
  155. HOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
  156. HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
  157. $(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
  158. quiet_cmd_moc = MOC $@
  159. cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
  160. $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
  161. $(call cmd,moc)
  162. # gconf: Used for the gconfig target based on GTK+
  163. hostprogs-y += gconf
  164. gconf-objs := gconf.o zconf.tab.o
  165. HOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
  166. HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
  167. $(obj)/gconf.o: $(obj)/.gconf-cfg
  168. $(obj)/zconf.tab.o: $(obj)/zconf.lex.c
  169. # check if necessary packages are available, and configure build flags
  170. define filechk_conf_cfg
  171. $(CONFIG_SHELL) $<
  172. endef
  173. $(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
  174. $(call filechk,conf_cfg)
  175. clean-files += .*conf-cfg