Makefile 11 KB

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