Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 update-po-config \
  6. localmodconfig localyesconfig
  7. # Added for U-Boot
  8. # Linux has defconfig files in arch/$(SRCARCH)/configs/,
  9. # on the other hand, U-Boot does in configs/.
  10. # Set SRCARCH to .. fake this Makefile.
  11. SRCARCH := ..
  12. ifdef KBUILD_KCONFIG
  13. Kconfig := $(KBUILD_KCONFIG)
  14. else
  15. Kconfig := Kconfig
  16. endif
  17. ifeq ($(quiet),silent_)
  18. silent := -s
  19. endif
  20. # We need this, in case the user has it in its environment
  21. unexport CONFIG_
  22. xconfig: $(obj)/qconf
  23. $< $(silent) $(Kconfig)
  24. gconfig: $(obj)/gconf
  25. $< $(silent) $(Kconfig)
  26. menuconfig: $(obj)/mconf
  27. $< $(silent) $(Kconfig)
  28. config: $(obj)/conf
  29. $< $(silent) --oldaskconfig $(Kconfig)
  30. nconfig: $(obj)/nconf
  31. $< $(silent) $(Kconfig)
  32. # This has become an internal implementation detail and is now deprecated
  33. # for external use.
  34. syncconfig: $(obj)/conf
  35. $(Q)mkdir -p include/config include/generated
  36. $< $(silent) --$@ $(Kconfig)
  37. localyesconfig localmodconfig: $(obj)/conf
  38. $(Q)mkdir -p include/config include/generated
  39. $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
  40. $(Q)if [ -f .config ]; then \
  41. cmp -s .tmp.config .config || \
  42. (mv -f .config .config.old.1; \
  43. mv -f .tmp.config .config; \
  44. $< $(silent) --oldconfig $(Kconfig); \
  45. mv -f .config.old.1 .config.old) \
  46. else \
  47. mv -f .tmp.config .config; \
  48. $< $(silent) --oldconfig $(Kconfig); \
  49. fi
  50. $(Q)rm -f .tmp.config
  51. # Create new linux.pot file
  52. # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
  53. update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
  54. $(Q)$(kecho) " GEN config.pot"
  55. $(Q)xgettext --default-domain=linux \
  56. --add-comments --keyword=_ --keyword=N_ \
  57. --from-code=UTF-8 \
  58. --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
  59. --directory=$(srctree) --directory=$(objtree) \
  60. --output $(obj)/config.pot
  61. $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
  62. $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
  63. $(srctree)/arch/*/um/Kconfig`; \
  64. do \
  65. $(kecho) " GEN $$i"; \
  66. $(obj)/kxgettext $$i \
  67. >> $(obj)/config.pot; \
  68. done )
  69. $(Q)$(kecho) " GEN linux.pot"
  70. $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
  71. --output $(obj)/linux.pot
  72. $(Q)rm -f $(obj)/config.pot
  73. # These targets map 1:1 to the commandline options of 'conf'
  74. simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
  75. alldefconfig randconfig listnewconfig olddefconfig
  76. PHONY += $(simple-targets)
  77. $(simple-targets): $(obj)/conf
  78. $< $(silent) --$@ $(Kconfig)
  79. PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
  80. # oldnoconfig is an alias of olddefconfig, because people already are dependent
  81. # on its behavior (sets new symbols to their default value but not 'n') with the
  82. # counter-intuitive name.
  83. oldnoconfig: olddefconfig
  84. @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
  85. @echo " Please use \"olddefconfig\" instead, which is an alias."
  86. # We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
  87. silentoldconfig: syncconfig
  88. @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
  89. @echo " and is now an internal implementation detail."
  90. @echo " What you want is probably \"oldconfig\"."
  91. @echo " \"silentoldconfig\" will be removed after Linux 4.19"
  92. savedefconfig: $(obj)/conf
  93. $< $(silent) --$@=defconfig $(Kconfig)
  94. defconfig: $(obj)/conf
  95. ifeq ($(KBUILD_DEFCONFIG),)
  96. $< $(silent) --defconfig $(Kconfig)
  97. else
  98. ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
  99. @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  100. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  101. else
  102. @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
  103. $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
  104. endif
  105. endif
  106. %_defconfig: $(obj)/conf
  107. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
  108. # Added for U-Boot (backward compatibility)
  109. %_config: %_defconfig
  110. @:
  111. configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
  112. %.config: $(obj)/conf
  113. $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
  114. $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
  115. +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
  116. PHONY += kvmconfig
  117. kvmconfig: kvm_guest.config
  118. @:
  119. PHONY += xenconfig
  120. xenconfig: xen.config
  121. @:
  122. PHONY += tinyconfig
  123. tinyconfig:
  124. $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
  125. # CHECK: -o cache_dir=<path> working?
  126. PHONY += testconfig
  127. testconfig: $(obj)/conf
  128. $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
  129. -o cache_dir=$(abspath $(obj)/tests/.cache) \
  130. $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
  131. clean-dirs += tests/.cache
  132. # Help text used by make help
  133. help:
  134. @echo ' config - Update current config utilising a line-oriented program'
  135. @echo ' nconfig - Update current config utilising a ncurses menu based'
  136. @echo ' program'
  137. @echo ' menuconfig - Update current config utilising a menu based program'
  138. @echo ' xconfig - Update current config utilising a Qt based front-end'
  139. @echo ' gconfig - Update current config utilising a GTK+ based front-end'
  140. @echo ' oldconfig - Update current config utilising a provided .config as base'
  141. @echo ' localmodconfig - Update current config disabling modules not loaded'
  142. @echo ' localyesconfig - Update current config converting local mods to core'
  143. @echo ' defconfig - New config with default from ARCH supplied defconfig'
  144. @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
  145. @echo ' allnoconfig - New config where all options are answered with no'
  146. @echo ' allyesconfig - New config where all options are accepted with yes'
  147. @echo ' allmodconfig - New config selecting modules when possible'
  148. @echo ' alldefconfig - New config with all symbols set to default'
  149. @echo ' randconfig - New config with random answer to all options'
  150. @echo ' listnewconfig - List new options'
  151. @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
  152. @echo ' default value without prompting'
  153. # @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
  154. # @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
  155. # @echo ' tinyconfig - Configure the tiniest possible kernel'
  156. # lxdialog stuff
  157. check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  158. # Use recursively expanded variables so we do not call gcc unless
  159. # we really need to do so. (Do not call gcc as part of make mrproper)
  160. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
  161. -DLOCALE
  162. # ===========================================================================
  163. # Shared Makefile for the various kconfig executables:
  164. # conf: Used for defconfig, oldconfig and related targets
  165. # nconf: Used for the nconfig target.
  166. # Utilizes ncurses
  167. # mconf: Used for the menuconfig target
  168. # Utilizes the lxdialog package
  169. # qconf: Used for the xconfig target
  170. # Based on Qt which needs to be installed to compile it
  171. # gconf: Used for the gconfig target
  172. # Based on GTK+ which needs to be installed to compile it
  173. # object files used by all kconfig flavours
  174. lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
  175. lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  176. conf-objs := conf.o zconf.tab.o
  177. mconf-objs := mconf.o zconf.tab.o $(lxdialog)
  178. nconf-objs := nconf.o zconf.tab.o nconf.gui.o
  179. kxgettext-objs := kxgettext.o zconf.tab.o
  180. qconf-cxxobjs := qconf.o
  181. qconf-objs := zconf.tab.o
  182. gconf-objs := gconf.o zconf.tab.o
  183. hostprogs-y := conf nconf mconf kxgettext qconf gconf
  184. targets += zconf.lex.c
  185. clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
  186. clean-files += gconf.glade.h
  187. clean-files += config.pot linux.pot
  188. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  189. PHONY += $(obj)/dochecklxdialog
  190. $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
  191. $(obj)/dochecklxdialog:
  192. $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
  193. always := dochecklxdialog
  194. # Add environment specific flags
  195. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  196. HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS))
  197. # generated files seem to need this to find local include files
  198. HOSTCFLAGS_zconf.lex.o := -I$(src)
  199. HOSTCFLAGS_zconf.tab.o := -I$(src)
  200. HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
  201. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
  202. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
  203. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  204. -Wno-missing-prototypes
  205. HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  206. HOSTLOADLIBES_nconf = $(shell \
  207. pkg-config --libs menuw panelw ncursesw 2>/dev/null \
  208. || pkg-config --libs menu panel ncurses 2>/dev/null \
  209. || echo "-lmenu -lpanel -lncurses" )
  210. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  211. ifeq ($(MAKECMDGOALS),xconfig)
  212. $(obj)/.tmp_qtcheck: $(src)/Makefile
  213. -include $(obj)/.tmp_qtcheck
  214. # Qt needs some extra effort...
  215. $(obj)/.tmp_qtcheck:
  216. @set -e; $(kecho) " CHECK qt"; \
  217. if pkg-config --exists Qt5Core; then \
  218. cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
  219. libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
  220. moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
  221. elif pkg-config --exists QtCore; then \
  222. cflags=`pkg-config --cflags QtCore QtGui`; \
  223. libs=`pkg-config --libs QtCore QtGui`; \
  224. moc=`pkg-config --variable=moc_location QtCore`; \
  225. else \
  226. echo >&2 "*"; \
  227. echo >&2 "* Could not find Qt via pkg-config."; \
  228. echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
  229. echo >&2 "*"; \
  230. exit 1; \
  231. fi; \
  232. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  233. echo "KC_QT_LIBS=$$libs" >> $@; \
  234. echo "KC_QT_MOC=$$moc" >> $@
  235. endif
  236. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  237. ifeq ($(MAKECMDGOALS),gconfig)
  238. -include $(obj)/.tmp_gtkcheck
  239. # GTK+ needs some extra effort, too...
  240. $(obj)/.tmp_gtkcheck:
  241. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  242. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  243. touch $@; \
  244. else \
  245. echo >&2 "*"; \
  246. echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
  247. echo >&2 "*"; \
  248. false; \
  249. fi \
  250. else \
  251. echo >&2 "*"; \
  252. echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
  253. echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
  254. echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  255. echo >&2 "*"; \
  256. false; \
  257. fi
  258. endif
  259. $(obj)/zconf.tab.o: $(obj)/zconf.lex.c
  260. $(obj)/qconf.o: $(obj)/qconf.moc
  261. quiet_cmd_moc = MOC $@
  262. cmd_moc = $(KC_QT_MOC) -i $< -o $@
  263. $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
  264. $(call cmd,moc)
  265. # Extract gconf menu items for i18n support
  266. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  267. $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
  268. $(obj)/gconf.glade