Makefile 11 KB

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