Makefile.kconfig 8.9 KB

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