Makefile 9.3 KB

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