Makefile 10 KB

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