Makefile 11 KB

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