Makefile 10 KB

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