Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. # ===========================================================================
  2. # Kernel configuration targets
  3. # These targets are used from top-level makefile
  4. PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \
  5. localmodconfig localyesconfig
  6. ifdef KBUILD_KCONFIG
  7. Kconfig := $(KBUILD_KCONFIG)
  8. else
  9. Kconfig := Kconfig
  10. endif
  11. ifeq ($(quiet),silent_)
  12. silent := -s
  13. endif
  14. # We need this, in case the user has it in its environment
  15. unexport CONFIG_
  16. xconfig: $(obj)/qconf
  17. $< $(silent) $(Kconfig)
  18. gconfig: $(obj)/gconf
  19. $< $(silent) $(Kconfig)
  20. menuconfig: $(obj)/mconf
  21. $< $(silent) $(Kconfig)
  22. config: $(obj)/conf
  23. $< $(silent) --oldaskconfig $(Kconfig)
  24. nconfig: $(obj)/nconf
  25. $< $(silent) $(Kconfig)
  26. silentoldconfig: $(obj)/conf
  27. $(Q)mkdir -p include/config include/generated
  28. $< $(silent) --$@ $(Kconfig)
  29. localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
  30. $(Q)mkdir -p include/config include/generated
  31. $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
  32. $(Q)if [ -f .config ]; then \
  33. cmp -s .tmp.config .config || \
  34. (mv -f .config .config.old.1; \
  35. mv -f .tmp.config .config; \
  36. $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
  37. mv -f .config.old.1 .config.old) \
  38. else \
  39. mv -f .tmp.config .config; \
  40. $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
  41. fi
  42. $(Q)rm -f .tmp.config
  43. # Create new linux.pot file
  44. # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
  45. update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
  46. $(Q)$(kecho) " GEN config.pot"
  47. $(Q)xgettext --default-domain=linux \
  48. --add-comments --keyword=_ --keyword=N_ \
  49. --from-code=UTF-8 \
  50. --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
  51. --directory=$(srctree) --directory=$(objtree) \
  52. --output $(obj)/config.pot
  53. $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
  54. $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
  55. $(srctree)/arch/*/um/Kconfig`; \
  56. do \
  57. $(kecho) " GEN $$i"; \
  58. $(obj)/kxgettext $$i \
  59. >> $(obj)/config.pot; \
  60. done )
  61. $(Q)$(kecho) " GEN linux.pot"
  62. $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
  63. --output $(obj)/linux.pot
  64. $(Q)rm -f $(obj)/config.pot
  65. # These targets map 1:1 to the commandline options of 'conf'
  66. simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
  67. alldefconfig randconfig listnewconfig olddefconfig
  68. PHONY += $(simple-targets)
  69. $(simple-targets): $(obj)/conf
  70. $< $(silent) --$@ $(Kconfig)
  71. PHONY += oldnoconfig savedefconfig defconfig
  72. ifneq ($(VARIANT_DEFCONFIG),)
  73. export KCONFIG_VARIANT := arch/$(SRCARCH)/configs/$(VARIANT_DEFCONFIG)
  74. endif
  75. ifneq ($(DEBUG_DEFCONFIG),)
  76. export KCONFIG_DEBUG := arch/$(SRCARCH)/configs/$(DEBUG_DEFCONFIG)
  77. endif
  78. ifneq ($(SELINUX_DEFCONFIG),)
  79. export KCONFIG_SELINUX := arch/$(SRCARCH)/configs/$(SELINUX_DEFCONFIG)
  80. endif
  81. ifneq ($(SELINUX_LOG_DEFCONFIG),)
  82. export KCONFIG_LOG_SELINUX := arch/$(SRCARCH)/configs/$(SELINUX_LOG_DEFCONFIG)
  83. endif
  84. ifneq ($(TIMA_DEFCONFIG),)
  85. export KCONFIG_TIMA := arch/$(SRCARCH)/configs/$(TIMA_DEFCONFIG)
  86. endif
  87. # oldnoconfig is an alias of olddefconfig, because people already are dependent
  88. # on its behavior(sets new symbols to their default value but not 'n') with the
  89. # counter-intuitive name.
  90. oldnoconfig: olddefconfig
  91. savedefconfig: $(obj)/conf
  92. $< $(silent) --$@=defconfig $(Kconfig)
  93. defconfig: $(obj)/conf
  94. ifeq ($(KBUILD_DEFCONFIG),)
  95. $< $(silent) --defconfig $(Kconfig)
  96. else
  97. @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  98. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  99. endif
  100. %_defconfig: $(obj)/conf
  101. $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
  102. # Help text used by make help
  103. help:
  104. @echo ' config - Update current config utilising a line-oriented program'
  105. @echo ' nconfig - Update current config utilising a ncurses menu based program'
  106. @echo ' menuconfig - Update current config utilising a menu based program'
  107. @echo ' xconfig - Update current config utilising a QT based front-end'
  108. @echo ' gconfig - Update current config utilising a GTK based front-end'
  109. @echo ' oldconfig - Update current config utilising a provided .config as base'
  110. @echo ' localmodconfig - Update current config disabling modules not loaded'
  111. @echo ' localyesconfig - Update current config converting local mods to core'
  112. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  113. @echo ' defconfig - New config with default from ARCH supplied defconfig'
  114. @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
  115. @echo ' allnoconfig - New config where all options are answered with no'
  116. @echo ' allyesconfig - New config where all options are accepted with yes'
  117. @echo ' allmodconfig - New config selecting modules when possible'
  118. @echo ' alldefconfig - New config with all symbols set to default'
  119. @echo ' randconfig - New config with random answer to all options'
  120. @echo ' listnewconfig - List new options'
  121. @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
  122. # lxdialog stuff
  123. check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  124. # Use recursively expanded variables so we do not call gcc unless
  125. # we really need to do so. (Do not call gcc as part of make mrproper)
  126. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
  127. -DLOCALE
  128. # ===========================================================================
  129. # Shared Makefile for the various kconfig executables:
  130. # conf: Used for defconfig, oldconfig and related targets
  131. # nconf: Used for the nconfig target.
  132. # Utilizes ncurses
  133. # mconf: Used for the menuconfig target
  134. # Utilizes the lxdialog package
  135. # qconf: Used for the xconfig target
  136. # Based on QT which needs to be installed to compile it
  137. # gconf: Used for the gconfig target
  138. # Based on GTK which needs to be installed to compile it
  139. # object files used by all kconfig flavours
  140. lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
  141. lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  142. conf-objs := conf.o zconf.tab.o
  143. mconf-objs := mconf.o zconf.tab.o $(lxdialog)
  144. nconf-objs := nconf.o zconf.tab.o nconf.gui.o
  145. kxgettext-objs := kxgettext.o zconf.tab.o
  146. qconf-cxxobjs := qconf.o
  147. qconf-objs := zconf.tab.o
  148. gconf-objs := gconf.o zconf.tab.o
  149. hostprogs-y := conf nconf mconf kxgettext qconf gconf
  150. clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
  151. clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
  152. clean-files += config.pot linux.pot
  153. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  154. PHONY += $(obj)/dochecklxdialog
  155. $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
  156. $(obj)/dochecklxdialog:
  157. $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
  158. always := dochecklxdialog
  159. # Add environment specific flags
  160. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  161. # generated files seem to need this to find local include files
  162. HOSTCFLAGS_zconf.lex.o := -I$(src)
  163. HOSTCFLAGS_zconf.tab.o := -I$(src)
  164. LEX_PREFIX_zconf := zconf
  165. YACC_PREFIX_zconf := zconf
  166. HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
  167. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
  168. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
  169. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  170. -Wno-missing-prototypes
  171. HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  172. HOSTLOADLIBES_nconf = $(shell \
  173. pkg-config --libs menuw panelw ncursesw 2>/dev/null \
  174. || pkg-config --libs menu panel ncurses 2>/dev/null \
  175. || echo "-lmenu -lpanel -lncurses" )
  176. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  177. ifeq ($(MAKECMDGOALS),xconfig)
  178. $(obj)/.tmp_qtcheck: $(src)/Makefile
  179. -include $(obj)/.tmp_qtcheck
  180. # QT needs some extra effort...
  181. $(obj)/.tmp_qtcheck:
  182. @set -e; $(kecho) " CHECK qt"; dir=""; pkg=""; \
  183. if ! pkg-config --exists QtCore 2> /dev/null; then \
  184. echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
  185. pkg-config --exists qt 2> /dev/null && pkg=qt; \
  186. pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
  187. if [ -n "$$pkg" ]; then \
  188. cflags="\$$(shell pkg-config $$pkg --cflags)"; \
  189. libs="\$$(shell pkg-config $$pkg --libs)"; \
  190. moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
  191. dir="$$(pkg-config $$pkg --variable=prefix)"; \
  192. else \
  193. for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
  194. if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
  195. done; \
  196. if [ -z "$$dir" ]; then \
  197. echo "*"; \
  198. echo "* Unable to find any QT installation. Please make sure that"; \
  199. echo "* the QT4 or QT3 development package is correctly installed and"; \
  200. echo "* either qmake can be found or install pkg-config or set"; \
  201. echo "* the QTDIR environment variable to the correct location."; \
  202. echo "*"; \
  203. false; \
  204. fi; \
  205. libpath=$$dir/lib; lib=qt; osdir=""; \
  206. $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
  207. osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
  208. test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
  209. test -f $$libpath/libqt-mt.so && lib=qt-mt; \
  210. cflags="-I$$dir/include"; \
  211. libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
  212. moc="$$dir/bin/moc"; \
  213. fi; \
  214. if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
  215. echo "*"; \
  216. echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
  217. echo "*"; \
  218. moc="/usr/bin/moc"; \
  219. fi; \
  220. else \
  221. cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
  222. libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
  223. binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \
  224. moc="$$binpath/bin/moc"; \
  225. fi; \
  226. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  227. echo "KC_QT_LIBS=$$libs" >> $@; \
  228. echo "KC_QT_MOC=$$moc" >> $@
  229. endif
  230. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  231. ifeq ($(MAKECMDGOALS),gconfig)
  232. -include $(obj)/.tmp_gtkcheck
  233. # GTK needs some extra effort, too...
  234. $(obj)/.tmp_gtkcheck:
  235. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  236. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  237. touch $@; \
  238. else \
  239. echo "*"; \
  240. echo "* GTK+ is present but version >= 2.0.0 is required."; \
  241. echo "*"; \
  242. false; \
  243. fi \
  244. else \
  245. echo "*"; \
  246. echo "* Unable to find the GTK+ installation. Please make sure that"; \
  247. echo "* the GTK+ 2.0 development package is correctly installed..."; \
  248. echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  249. echo "*"; \
  250. false; \
  251. fi
  252. endif
  253. $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
  254. $(obj)/qconf.o: $(obj)/qconf.moc
  255. $(obj)/%.moc: $(src)/%.h
  256. $(KC_QT_MOC) -i $< -o $@
  257. # Extract gconf menu items for I18N support
  258. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  259. $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
  260. $(obj)/gconf.glade