Makefile 11 KB

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