Makefile 11 KB

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