Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 savedefconfig defconfig
  79. listnewconfig oldnoconfig: $(obj)/conf
  80. $< --$@ $(Kconfig)
  81. savedefconfig: $(obj)/conf
  82. $< --$@=defconfig $(Kconfig)
  83. defconfig: $(obj)/conf
  84. ifeq ($(KBUILD_DEFCONFIG),)
  85. $< --defconfig $(Kconfig)
  86. else
  87. @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  88. $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  89. endif
  90. %_defconfig: $(obj)/conf
  91. $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
  92. # Help text used by make help
  93. help:
  94. @echo ' config - Update current config utilising a line-oriented program'
  95. @echo ' nconfig - Update current config utilising a ncurses menu based program'
  96. @echo ' menuconfig - Update current config utilising a menu based program'
  97. @echo ' xconfig - Update current config utilising a QT based front-end'
  98. @echo ' gconfig - Update current config utilising a GTK based front-end'
  99. @echo ' oldconfig - Update current config utilising a provided .config as base'
  100. @echo ' localmodconfig - Update current config disabling modules not loaded'
  101. @echo ' localyesconfig - Update current config converting local mods to core'
  102. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  103. @echo ' defconfig - New config with default from ARCH supplied defconfig'
  104. @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
  105. @echo ' allnoconfig - New config where all options are answered with no'
  106. @echo ' allyesconfig - New config where all options are accepted with yes'
  107. @echo ' allmodconfig - New config selecting modules when possible'
  108. @echo ' alldefconfig - New config with all symbols set to default'
  109. @echo ' randconfig - New config with random answer to all options'
  110. @echo ' listnewconfig - List new options'
  111. @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)'
  112. # lxdialog stuff
  113. check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  114. # Use recursively expanded variables so we do not call gcc unless
  115. # we really need to do so. (Do not call gcc as part of make mrproper)
  116. HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
  117. HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  118. HOST_EXTRACFLAGS += -DLOCALE
  119. # ===========================================================================
  120. # Shared Makefile for the various kconfig executables:
  121. # conf: Used for defconfig, oldconfig and related targets
  122. # nconf: Used for the nconfig target.
  123. # Utilizes ncurses
  124. # mconf: Used for the menuconfig target
  125. # Utilizes the lxdialog package
  126. # qconf: Used for the xconfig target
  127. # Based on QT which needs to be installed to compile it
  128. # gconf: Used for the gconfig target
  129. # Based on GTK which needs to be installed to compile it
  130. # object files used by all kconfig flavours
  131. lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
  132. lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  133. conf-objs := conf.o zconf.tab.o
  134. mconf-objs := mconf.o zconf.tab.o $(lxdialog)
  135. nconf-objs := nconf.o zconf.tab.o nconf.gui.o
  136. kxgettext-objs := kxgettext.o zconf.tab.o
  137. hostprogs-y := conf qconf gconf kxgettext
  138. ifeq ($(MAKECMDGOALS),nconfig)
  139. hostprogs-y += nconf
  140. endif
  141. ifeq ($(MAKECMDGOALS),menuconfig)
  142. hostprogs-y += mconf
  143. endif
  144. ifeq ($(MAKECMDGOALS),xconfig)
  145. qconf-target := 1
  146. endif
  147. ifeq ($(MAKECMDGOALS),gconfig)
  148. gconf-target := 1
  149. endif
  150. ifeq ($(qconf-target),1)
  151. qconf-cxxobjs := qconf.o
  152. qconf-objs := kconfig_load.o zconf.tab.o
  153. endif
  154. ifeq ($(gconf-target),1)
  155. gconf-objs := gconf.o kconfig_load.o zconf.tab.o
  156. endif
  157. clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
  158. .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
  159. clean-files += mconf qconf gconf nconf
  160. clean-files += config.pot linux.pot
  161. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  162. PHONY += $(obj)/dochecklxdialog
  163. $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
  164. $(obj)/dochecklxdialog:
  165. $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
  166. always := dochecklxdialog
  167. # Add environment specific flags
  168. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  169. # generated files seem to need this to find local include files
  170. HOSTCFLAGS_lex.zconf.o := -I$(src)
  171. HOSTCFLAGS_zconf.tab.o := -I$(src)
  172. HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
  173. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
  174. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
  175. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  176. -D LKC_DIRECT_LINK
  177. HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
  178. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  179. ifeq ($(qconf-target),1)
  180. $(obj)/.tmp_qtcheck: $(src)/Makefile
  181. -include $(obj)/.tmp_qtcheck
  182. # QT needs some extra effort...
  183. $(obj)/.tmp_qtcheck:
  184. @set -e; echo " CHECK qt"; dir=""; pkg=""; \
  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 the QT3 installation. Please make sure that"; \
  199. echo "* the QT3 development package is correctly installed and"; \
  200. echo "* either install pkg-config or set the QTDIR environment"; \
  201. echo "* 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. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  221. echo "KC_QT_LIBS=$$libs" >> $@; \
  222. echo "KC_QT_MOC=$$moc" >> $@
  223. endif
  224. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  225. ifeq ($(gconf-target),1)
  226. -include $(obj)/.tmp_gtkcheck
  227. # GTK needs some extra effort, too...
  228. $(obj)/.tmp_gtkcheck:
  229. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  230. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  231. touch $@; \
  232. else \
  233. echo "*"; \
  234. echo "* GTK+ is present but version >= 2.0.0 is required."; \
  235. echo "*"; \
  236. false; \
  237. fi \
  238. else \
  239. echo "*"; \
  240. echo "* Unable to find the GTK+ installation. Please make sure that"; \
  241. echo "* the GTK+ 2.0 development package is correctly installed..."; \
  242. echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  243. echo "*"; \
  244. false; \
  245. fi
  246. endif
  247. $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
  248. $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
  249. $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
  250. $(obj)/gconf.o: $(obj)/lkc_defs.h
  251. $(obj)/%.moc: $(src)/%.h
  252. $(KC_QT_MOC) -i $< -o $@
  253. $(obj)/lkc_defs.h: $(src)/lkc_proto.h
  254. sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
  255. # Extract gconf menu items for I18N support
  256. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  257. intltool-extract --type=gettext/glade $(obj)/gconf.glade
  258. ###
  259. # The following requires flex/bison/gperf
  260. # By default we use the _shipped versions, uncomment the following line if
  261. # you are modifying the flex/bison src.
  262. # LKC_GENPARSER := 1
  263. ifdef LKC_GENPARSER
  264. $(obj)/zconf.tab.c: $(src)/zconf.y
  265. $(obj)/lex.zconf.c: $(src)/zconf.l
  266. $(obj)/zconf.hash.c: $(src)/zconf.gperf
  267. %.tab.c: %.y
  268. bison -l -b $* -p $(notdir $*) $<
  269. cp $@ $@_shipped
  270. lex.%.c: %.l
  271. flex -L -P$(notdir $*) -o$@ $<
  272. cp $@ $@_shipped
  273. %.hash.c: %.gperf
  274. gperf < $< > $@
  275. cp $@ $@_shipped
  276. endif