Makefile 10.0 KB

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