Makefile 7.9 KB

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