Makefile.kconfig 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # ===========================================================================
  2. # Kernel configuration targets
  3. # These targets are used from top-level makefile
  4. PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
  5. Kconfig := arch/$(SRCARCH)/Kconfig
  6. xconfig: $(obj)/qconf
  7. $< $(Kconfig)
  8. gconfig: $(obj)/gconf
  9. $< $(Kconfig)
  10. menuconfig: $(obj)/mconf
  11. $< $(Kconfig)
  12. config: $(obj)/conf
  13. $< $(Kconfig)
  14. oldconfig: $(obj)/conf
  15. $< -o $(Kconfig)
  16. silentoldconfig: $(obj)/conf
  17. $< -s $(Kconfig)
  18. # Create new linux.pot file
  19. # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
  20. # The symlink is used to repair a deficiency in arch/um
  21. update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
  22. $(Q)echo " GEN config"
  23. $(Q)xgettext --default-domain=linux \
  24. --add-comments --keyword=_ --keyword=N_ \
  25. --from-code=UTF-8 \
  26. --files-from=scripts/kconfig/POTFILES.in \
  27. --output $(obj)/config.pot
  28. $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
  29. $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
  30. $(Q)(for i in `ls arch/*/Kconfig`; \
  31. do \
  32. echo " GEN $$i"; \
  33. $(obj)/kxgettext $$i \
  34. >> $(obj)/config.pot; \
  35. done )
  36. $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
  37. --output $(obj)/linux.pot
  38. $(Q)rm -f arch/um/Kconfig.arch
  39. $(Q)rm -f $(obj)/config.pot
  40. PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
  41. randconfig: $(obj)/conf
  42. $< -r $(Kconfig)
  43. allyesconfig: $(obj)/conf
  44. $< -y $(Kconfig)
  45. allnoconfig: $(obj)/conf
  46. $< -n $(Kconfig)
  47. allmodconfig: $(obj)/conf
  48. $< -m $(Kconfig)
  49. defconfig: $(obj)/conf
  50. ifeq ($(KBUILD_DEFCONFIG),)
  51. $< -d $(Kconfig)
  52. else
  53. @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  54. $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  55. endif
  56. %_defconfig: $(obj)/conf
  57. $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
  58. # Help text used by make help
  59. help:
  60. @echo ' config - Update current config utilising a line-oriented program'
  61. @echo ' menuconfig - Update current config utilising a menu based program'
  62. @echo ' xconfig - Update current config utilising a QT based front-end'
  63. @echo ' gconfig - Update current config utilising a GTK based front-end'
  64. @echo ' oldconfig - Update current config utilising a provided .config as base'
  65. @echo ' silentoldconfig - Same as oldconfig, but quietly'
  66. @echo ' randconfig - New config with random answer to all options'
  67. @echo ' defconfig - New config with default answer to all options'
  68. @echo ' allmodconfig - New config selecting modules when possible'
  69. @echo ' allyesconfig - New config where all options are accepted with yes'
  70. @echo ' allnoconfig - New config where all options are answered with no'
  71. # lxdialog stuff
  72. check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  73. # Use recursively expanded variables so we do not call gcc unless
  74. # we really need to do so. (Do not call gcc as part of make mrproper)
  75. HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
  76. HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  77. HOST_EXTRACFLAGS += -DLOCALE
  78. # ===========================================================================
  79. # Shared Makefile for the various kconfig executables:
  80. # conf: Used for defconfig, oldconfig and related targets
  81. # mconf: Used for the mconfig target.
  82. # Utilizes the lxdialog package
  83. # qconf: Used for the xconfig target
  84. # Based on QT which needs to be installed to compile it
  85. # gconf: Used for the gconfig target
  86. # Based on GTK which needs to be installed to compile it
  87. # object files used by all kconfig flavours
  88. lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
  89. lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  90. conf-objs := conf.o zconf.tab.o
  91. mconf-objs := mconf.o zconf.tab.o $(lxdialog)
  92. kxgettext-objs := kxgettext.o zconf.tab.o
  93. hostprogs-y := conf qconf gconf kxgettext
  94. ifeq ($(MAKECMDGOALS),menuconfig)
  95. hostprogs-y += mconf
  96. endif
  97. ifeq ($(MAKECMDGOALS),xconfig)
  98. qconf-target := 1
  99. endif
  100. ifeq ($(MAKECMDGOALS),gconfig)
  101. gconf-target := 1
  102. endif
  103. ifeq ($(qconf-target),1)
  104. qconf-cxxobjs := qconf.o
  105. qconf-objs := kconfig_load.o zconf.tab.o
  106. endif
  107. ifeq ($(gconf-target),1)
  108. gconf-objs := gconf.o kconfig_load.o zconf.tab.o
  109. endif
  110. clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
  111. .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
  112. clean-files += mconf qconf gconf
  113. clean-files += config.pot linux.pot
  114. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  115. PHONY += $(obj)/dochecklxdialog
  116. $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
  117. $(obj)/dochecklxdialog:
  118. $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
  119. always := dochecklxdialog
  120. # Add environment specific flags
  121. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  122. # generated files seem to need this to find local include files
  123. HOSTCFLAGS_lex.zconf.o := -I$(src)
  124. HOSTCFLAGS_zconf.tab.o := -I$(src)
  125. HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
  126. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
  127. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
  128. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  129. -D LKC_DIRECT_LINK
  130. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  131. ifeq ($(qconf-target),1)
  132. $(obj)/.tmp_qtcheck: $(src)/Makefile
  133. -include $(obj)/.tmp_qtcheck
  134. # QT needs some extra effort...
  135. $(obj)/.tmp_qtcheck:
  136. @set -e; echo " CHECK qt"; dir=""; pkg=""; \
  137. pkg-config --exists qt 2> /dev/null && pkg=qt; \
  138. pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
  139. if [ -n "$$pkg" ]; then \
  140. cflags="\$$(shell pkg-config $$pkg --cflags)"; \
  141. libs="\$$(shell pkg-config $$pkg --libs)"; \
  142. moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
  143. dir="$$(pkg-config $$pkg --variable=prefix)"; \
  144. else \
  145. for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
  146. if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
  147. done; \
  148. if [ -z "$$dir" ]; then \
  149. echo "*"; \
  150. echo "* Unable to find the QT3 installation. Please make sure that"; \
  151. echo "* the QT3 development package is correctly installed and"; \
  152. echo "* either install pkg-config or set the QTDIR environment"; \
  153. echo "* variable to the correct location."; \
  154. echo "*"; \
  155. false; \
  156. fi; \
  157. libpath=$$dir/lib; lib=qt; osdir=""; \
  158. $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
  159. osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
  160. test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
  161. test -f $$libpath/libqt-mt.so && lib=qt-mt; \
  162. cflags="-I$$dir/include"; \
  163. libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
  164. moc="$$dir/bin/moc"; \
  165. fi; \
  166. if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
  167. echo "*"; \
  168. echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
  169. echo "*"; \
  170. moc="/usr/bin/moc"; \
  171. fi; \
  172. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  173. echo "KC_QT_LIBS=$$libs" >> $@; \
  174. echo "KC_QT_MOC=$$moc" >> $@
  175. endif
  176. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  177. ifeq ($(gconf-target),1)
  178. -include $(obj)/.tmp_gtkcheck
  179. # GTK needs some extra effort, too...
  180. $(obj)/.tmp_gtkcheck:
  181. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  182. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  183. touch $@; \
  184. else \
  185. echo "*"; \
  186. echo "* GTK+ is present but version >= 2.0.0 is required."; \
  187. echo "*"; \
  188. false; \
  189. fi \
  190. else \
  191. echo "*"; \
  192. echo "* Unable to find the GTK+ installation. Please make sure that"; \
  193. echo "* the GTK+ 2.0 development package is correctly installed..."; \
  194. echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  195. echo "*"; \
  196. false; \
  197. fi
  198. endif
  199. $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
  200. $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
  201. $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
  202. $(obj)/gconf.o: $(obj)/lkc_defs.h
  203. $(obj)/%.moc: $(src)/%.h
  204. $(KC_QT_MOC) -i $< -o $@
  205. $(obj)/lkc_defs.h: $(src)/lkc_proto.h
  206. sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
  207. # Extract gconf menu items for I18N support
  208. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  209. intltool-extract --type=gettext/glade $(obj)/gconf.glade
  210. ###
  211. # The following requires flex/bison/gperf
  212. # By default we use the _shipped versions, uncomment the following line if
  213. # you are modifying the flex/bison src.
  214. # LKC_GENPARSER := 1
  215. ifdef LKC_GENPARSER
  216. $(obj)/zconf.tab.c: $(src)/zconf.y
  217. $(obj)/lex.zconf.c: $(src)/zconf.l
  218. $(obj)/zconf.hash.c: $(src)/zconf.gperf
  219. %.tab.c: %.y
  220. bison -l -b $* -p $(notdir $*) $<
  221. cp $@ $@_shipped
  222. lex.%.c: %.l
  223. flex -L -P$(notdir $*) -o$@ $<
  224. cp $@ $@_shipped
  225. %.hash.c: %.gperf
  226. gperf < $< > $@
  227. cp $@ $@_shipped
  228. endif