Makefile 9.8 KB

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