Makefile 11 KB

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