Makefile 10 KB

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