Makefile 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. # ===========================================================================
  2. # Kernel configuration targets
  3. # These targets are used from top-level makefile
  4. PHONY += xconfig gconfig menuconfig config
  5. # We need this, in case the user has it in its environment
  6. unexport CONFIG_
  7. ifneq ($(Q),)
  8. # $(call kconfig_action,<action>,<target>)
  9. define kconfig_action
  10. @printf " %-7s %s\n" $(1) $(2)
  11. @
  12. endef
  13. endif
  14. srctree := $(SRCDIR)
  15. obj := $(KCONFIG_PATH)
  16. src := $(obj)
  17. kecho := echo
  18. # This environment variable is used by the conf tools to locate Kconfig files.
  19. export srctree
  20. Kconfig := $(srctree)/Kconfig
  21. xconfig: $(obj)/qconf
  22. $< $(Kconfig)
  23. gconfig: $(obj)/gconf
  24. $< $(Kconfig)
  25. menuconfig: $(obj)/mconf
  26. $< $(Kconfig)
  27. config: $(obj)/conf
  28. $< --oldaskconfig $(Kconfig)
  29. nconfig: $(obj)/nconf
  30. $< $(Kconfig)
  31. # These targets map 1:1 to the commandline options of 'conf'
  32. simple-targets := oldconfig allnoconfig allyesconfig \
  33. alldefconfig randconfig listnewconfig olddefconfig
  34. PHONY += $(simple-targets)
  35. $(simple-targets): $(obj)/conf
  36. $< --$@ $(Kconfig)
  37. PHONY += savedefconfig defconfig
  38. savedefconfig: $(obj)/conf
  39. $< --$@=defconfig $(Kconfig)
  40. defconfig: $(obj)/conf
  41. @$(kecho) "*** Default configuration is based on '$(KCONFIG_DEFCONFIG)'"
  42. $(Q)$< --defconfig=arch/$(ARCH)/configs/$(KCONFIG_DEFCONFIG) $(Kconfig)
  43. %_defconfig: $(obj)/conf
  44. $(Q)$< --defconfig=arch/$(ARCH)/configs/$@ $(Kconfig)
  45. # Help text used by make help
  46. help:
  47. @echo ' config - Set configuration - line-oriented program'
  48. @echo ' nconfig - Set configuration - ncurses menu based program'
  49. @echo ' menuconfig - Set configuration - menu based program'
  50. @echo ' xconfig - Set configuration - Qt based front-end'
  51. @echo ' gconfig - Set configuration - GTK+ based front-end'
  52. @echo ' allnoconfig - New configuration - all options disabled'
  53. @echo ' allyesconfig - New configuration - all options enabled'
  54. @echo ' alldefconfig - New configuration - default values'
  55. @echo ' randconfig - New configuration - random values'
  56. @echo ' oldconfig - Reuse existing .config for configuration'
  57. @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
  58. @echo ' default value'
  59. @echo ' defconfig - Default architecture-specific configuration'
  60. @echo ' savedefconfig - Save configuration as ./defconfig (minimal config)'
  61. @echo ' listnewconfig - List new options'
  62. # lxdialog stuff
  63. check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  64. # Use recursively expanded variables so we do not call gcc unless
  65. # we really need to do so. (Do not call gcc as part of make mrproper)
  66. HOST_EXTRACFLAGS += $(shell $(CONFIG_HOST_SHELL) $(check-lxdialog) -ccflags) \
  67. -DLOCALE
  68. # ===========================================================================
  69. # Shared Makefile for the various kconfig executables:
  70. # conf: Used for defconfig, oldconfig and related targets
  71. # nconf: Used for the nconfig target.
  72. # Utilizes ncurses
  73. # mconf: Used for the menuconfig target
  74. # Utilizes the lxdialog package
  75. # qconf: Used for the xconfig target
  76. # Based on Qt which needs to be installed to compile it
  77. # gconf: Used for the gconfig target
  78. # Based on GTK+ which needs to be installed to compile it
  79. # object files used by all kconfig flavours
  80. lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
  81. lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  82. conf-objs := conf.o zconf.tab.o
  83. mconf-objs := mconf.o zconf.tab.o $(lxdialog)
  84. nconf-objs := nconf.o zconf.tab.o nconf.gui.o
  85. qconf-cxxobjs := qconf.o
  86. qconf-objs := zconf.tab.o
  87. gconf-objs := gconf.o zconf.tab.o
  88. hostprogs-y := conf
  89. ifeq ($(MAKECMDGOALS),nconfig)
  90. hostprogs-y += nconf
  91. endif
  92. ifeq ($(MAKECMDGOALS),menuconfig)
  93. hostprogs-y += mconf
  94. endif
  95. ifeq ($(MAKECMDGOALS),xconfig)
  96. qconf-target := 1
  97. endif
  98. ifeq ($(MAKECMDGOALS),gconfig)
  99. gconf-target := 1
  100. endif
  101. ifeq ($(qconf-target),1)
  102. hostprogs-y += qconf
  103. endif
  104. ifeq ($(gconf-target),1)
  105. hostprogs-y += gconf
  106. endif
  107. clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
  108. clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
  109. clean-files += config.pot linux.pot
  110. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  111. $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.dochecklxdialog
  112. $(obj)/.dochecklxdialog:
  113. $(Q)$(CONFIG_HOST_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
  114. $(Q)touch $@
  115. # Add environment specific flags
  116. HOST_EXTRACFLAGS += $(shell $(CONFIG_HOST_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  117. # generated files seem to need this to find local include files
  118. HOSTCFLAGS_zconf.lex.o := -I$(srctree)/$(src)
  119. HOSTCFLAGS_zconf.tab.o := -I$(srctree)/$(src)
  120. LEX_PREFIX_zconf := zconf
  121. YACC_PREFIX_zconf := zconf
  122. HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
  123. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
  124. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
  125. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  126. -Wno-missing-prototypes
  127. HOSTLOADLIBES_mconf = $(shell $(CONFIG_HOST_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  128. HOSTLOADLIBES_nconf = $(shell \
  129. pkg-config --libs menuw panelw ncursesw 2>/dev/null \
  130. || pkg-config --libs menu panel ncurses 2>/dev/null \
  131. || echo "-lmenu -lpanel -lncurses" )
  132. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  133. ifeq ($(MAKECMDGOALS),xconfig)
  134. $(obj)/.tmp_qtcheck: $(src)/Makefile
  135. -include $(obj)/.tmp_qtcheck
  136. # Qt needs some extra effort...
  137. $(obj)/.tmp_qtcheck:
  138. @set -e; $(kecho) " CHECK qt"; \
  139. if pkg-config --exists Qt5Core; then \
  140. cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
  141. libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
  142. moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
  143. elif pkg-config --exists QtCore; then \
  144. cflags=`pkg-config --cflags QtCore QtGui`; \
  145. libs=`pkg-config --libs QtCore QtGui`; \
  146. moc=`pkg-config --variable=moc_location QtCore`; \
  147. else \
  148. echo >&2 "*"; \
  149. echo >&2 "* Could not find Qt via pkg-config."; \
  150. echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
  151. echo >&2 "*"; \
  152. exit 1; \
  153. fi; \
  154. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  155. echo "KC_QT_LIBS=$$libs" >> $@; \
  156. echo "KC_QT_MOC=$$moc" >> $@
  157. endif
  158. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  159. ifeq ($(MAKECMDGOALS),gconfig)
  160. -include $(obj)/.tmp_gtkcheck
  161. # GTK+ needs some extra effort, too...
  162. $(obj)/.tmp_gtkcheck:
  163. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  164. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  165. touch $@; \
  166. else \
  167. echo >&2 "*"; \
  168. echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
  169. echo >&2 "*"; \
  170. false; \
  171. fi \
  172. else \
  173. echo >&2 "*"; \
  174. echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
  175. echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
  176. echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  177. echo >&2 "*"; \
  178. false; \
  179. fi
  180. endif
  181. $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
  182. $(obj)/qconf.o: $(obj)/qconf.moc
  183. $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
  184. $(call kconfig_action,MOC,$@,)$(KC_QT_MOC) -i $< -o $@
  185. # Extract gconf menu items for i18n support
  186. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  187. $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
  188. $(obj)/gconf.glade
  189. -include $(obj)/.depend
  190. $(obj)/.depend: $(wildcard *.h *.c)
  191. $(Q)mkdir -p $(@D)
  192. $(Q)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || :
  193. __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
  194. host-csingle := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))))
  195. host-cmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\
  196. $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))))
  197. host-cxxmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\
  198. $(if $($(m)-cxxobjs),$(m),$(if $($(m)-objs),))))
  199. host-cobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-objs))))
  200. host-cxxobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-cxxobjs))))
  201. HOST_EXTRACFLAGS += -I$(obj)
  202. $(host-csingle): %: %.c
  203. $(Q)mkdir -p $(@D)
  204. $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $< -o $@
  205. $(host-cmulti): %: $(host-cobjs) $(host-cshlib)
  206. $(Q)mkdir -p $(@D)
  207. $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) -o $@
  208. $(host-cxxmulti): %: $(host-cxxobjs) $(host-cobjs) $(host-cshlib)
  209. $(Q)mkdir -p $(@D)
  210. $(call kconfig_action,CXX,$@)$(HOSTCXX) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs) $($(@F)-cxxobjs)) $(HOSTLOADLIBES_$(@F)) -o $@
  211. $(obj)/%.o: $(obj)/%.c
  212. $(Q)mkdir -p $(@D)
  213. $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@
  214. $(obj)/%.o: $(obj)/%.cc
  215. $(Q)mkdir -p $(@D)
  216. $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) -c $< -o $@
  217. $(obj)/%:: $(src)/%_shipped
  218. $(Q)mkdir -p $(@D)
  219. $(Q)cat $< > $@
  220. clean:
  221. $(Q)rm -f $(addprefix $(obj)/,$(clean-files))
  222. distclean: clean
  223. $(Q)rm -f $(addprefix $(obj)/,$(lxdialog) $(conf-objs) $(mconf-objs) \
  224. $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
  225. conf nconf mconf qconf gconf .depend .dochecklxdialog)
  226. .PHONY: clean distclean $(PHONY)