Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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 := 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. # if no path is given, then use src directory to find file
  27. ifdef LSMOD
  28. LSMOD_F := $(LSMOD)
  29. ifeq ($(findstring /,$(LSMOD)),)
  30. LSMOD_F := $(objtree)/$(LSMOD)
  31. endif
  32. endif
  33. localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
  34. $(Q)mkdir -p include/generated
  35. $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
  36. $(Q)if [ -f .config ]; then \
  37. cmp -s .tmp.config .config || \
  38. (mv -f .config .config.old.1; \
  39. mv -f .tmp.config .config; \
  40. $(obj)/conf --silentoldconfig $(Kconfig); \
  41. mv -f .config.old.1 .config.old) \
  42. else \
  43. mv -f .tmp.config .config; \
  44. $(obj)/conf --silentoldconfig $(Kconfig); \
  45. fi
  46. $(Q)rm -f .tmp.config
  47. localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
  48. $(Q)mkdir -p include/generated
  49. $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
  50. $(Q)sed -i s/=m/=y/ .tmp.config
  51. $(Q)if [ -f .config ]; then \
  52. cmp -s .tmp.config .config || \
  53. (mv -f .config .config.old.1; \
  54. mv -f .tmp.config .config; \
  55. $(obj)/conf --silentoldconfig $(Kconfig); \
  56. mv -f .config.old.1 .config.old) \
  57. else \
  58. mv -f .tmp.config .config; \
  59. $(obj)/conf --silentoldconfig $(Kconfig); \
  60. fi
  61. $(Q)rm -f .tmp.config
  62. # Create new linux.pot file
  63. # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
  64. # The symlink is used to repair a deficiency in arch/um
  65. update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
  66. $(Q)echo " GEN config"
  67. $(Q)xgettext --default-domain=linux \
  68. --add-comments --keyword=_ --keyword=N_ \
  69. --from-code=UTF-8 \
  70. --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
  71. --directory=$(srctree) --directory=$(objtree) \
  72. --output $(obj)/config.pot
  73. $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
  74. $(Q)ln -fs Kconfig.x86 arch/um/Kconfig
  75. $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \
  76. do \
  77. echo " GEN $$i"; \
  78. $(obj)/kxgettext $$i \
  79. >> $(obj)/config.pot; \
  80. done )
  81. $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
  82. --output $(obj)/linux.pot
  83. $(Q)rm -f $(srctree)/arch/um/Kconfig
  84. $(Q)rm -f $(obj)/config.pot
  85. PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
  86. allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
  87. $< --$@ $(Kconfig)
  88. PHONY += listnewconfig oldnoconfig savedefconfig defconfig
  89. listnewconfig oldnoconfig: $(obj)/conf
  90. $< --$@ $(Kconfig)
  91. savedefconfig: $(obj)/conf
  92. $< --$@=defconfig $(Kconfig)
  93. defconfig: $(obj)/conf
  94. ifeq ($(KBUILD_DEFCONFIG),)
  95. $< --defconfig $(Kconfig)
  96. else
  97. @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
  98. $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
  99. endif
  100. %_defconfig: $(obj)/conf
  101. $(Q)$< --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 ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)'
  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 := kconfig_load.o zconf.tab.o
  148. gconf-objs := gconf.o kconfig_load.o zconf.tab.o
  149. hostprogs-y := conf
  150. ifeq ($(MAKECMDGOALS),nconfig)
  151. hostprogs-y += nconf
  152. endif
  153. ifeq ($(MAKECMDGOALS),menuconfig)
  154. hostprogs-y += mconf
  155. endif
  156. ifeq ($(MAKECMDGOALS),update-po-config)
  157. hostprogs-y += kxgettext
  158. endif
  159. ifeq ($(MAKECMDGOALS),xconfig)
  160. qconf-target := 1
  161. endif
  162. ifeq ($(MAKECMDGOALS),gconfig)
  163. gconf-target := 1
  164. endif
  165. ifeq ($(qconf-target),1)
  166. hostprogs-y += qconf
  167. endif
  168. ifeq ($(gconf-target),1)
  169. hostprogs-y += gconf
  170. endif
  171. clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck
  172. clean-files += zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
  173. clean-files += mconf qconf gconf nconf
  174. clean-files += config.pot linux.pot
  175. # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
  176. PHONY += $(obj)/dochecklxdialog
  177. $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
  178. $(obj)/dochecklxdialog:
  179. $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
  180. always := dochecklxdialog
  181. # Add environment specific flags
  182. HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
  183. # generated files seem to need this to find local include files
  184. HOSTCFLAGS_lex.zconf.o := -I$(src)
  185. HOSTCFLAGS_zconf.tab.o := -I$(src)
  186. HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
  187. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
  188. HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl
  189. HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
  190. -D LKC_DIRECT_LINK
  191. HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  192. HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
  193. $(obj)/qconf.o: $(obj)/.tmp_qtcheck
  194. ifeq ($(qconf-target),1)
  195. $(obj)/.tmp_qtcheck: $(src)/Makefile
  196. -include $(obj)/.tmp_qtcheck
  197. # QT needs some extra effort...
  198. $(obj)/.tmp_qtcheck:
  199. @set -e; echo " CHECK qt"; dir=""; pkg=""; \
  200. if ! pkg-config --exists QtCore 2> /dev/null; then \
  201. echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
  202. pkg-config --exists qt 2> /dev/null && pkg=qt; \
  203. pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
  204. if [ -n "$$pkg" ]; then \
  205. cflags="\$$(shell pkg-config $$pkg --cflags)"; \
  206. libs="\$$(shell pkg-config $$pkg --libs)"; \
  207. moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
  208. dir="$$(pkg-config $$pkg --variable=prefix)"; \
  209. else \
  210. for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
  211. if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
  212. done; \
  213. if [ -z "$$dir" ]; then \
  214. echo "*"; \
  215. echo "* Unable to find any QT installation. Please make sure that"; \
  216. echo "* the QT4 or QT3 development package is correctly installed and"; \
  217. echo "* either qmake can be found or install pkg-config or set"; \
  218. echo "* the QTDIR environment variable to the correct location."; \
  219. echo "*"; \
  220. false; \
  221. fi; \
  222. libpath=$$dir/lib; lib=qt; osdir=""; \
  223. $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
  224. osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
  225. test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
  226. test -f $$libpath/libqt-mt.so && lib=qt-mt; \
  227. cflags="-I$$dir/include"; \
  228. libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
  229. moc="$$dir/bin/moc"; \
  230. fi; \
  231. if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
  232. echo "*"; \
  233. echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
  234. echo "*"; \
  235. moc="/usr/bin/moc"; \
  236. fi; \
  237. else \
  238. cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
  239. libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
  240. binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \
  241. moc="$$binpath/bin/moc"; \
  242. fi; \
  243. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  244. echo "KC_QT_LIBS=$$libs" >> $@; \
  245. echo "KC_QT_MOC=$$moc" >> $@
  246. endif
  247. $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
  248. ifeq ($(gconf-target),1)
  249. -include $(obj)/.tmp_gtkcheck
  250. # GTK needs some extra effort, too...
  251. $(obj)/.tmp_gtkcheck:
  252. @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
  253. if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
  254. touch $@; \
  255. else \
  256. echo "*"; \
  257. echo "* GTK+ is present but version >= 2.0.0 is required."; \
  258. echo "*"; \
  259. false; \
  260. fi \
  261. else \
  262. echo "*"; \
  263. echo "* Unable to find the GTK+ installation. Please make sure that"; \
  264. echo "* the GTK+ 2.0 development package is correctly installed..."; \
  265. echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
  266. echo "*"; \
  267. false; \
  268. fi
  269. endif
  270. $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
  271. $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
  272. $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
  273. $(obj)/gconf.o: $(obj)/lkc_defs.h
  274. $(obj)/%.moc: $(src)/%.h
  275. $(KC_QT_MOC) -i $< -o $@
  276. $(obj)/lkc_defs.h: $(src)/lkc_proto.h
  277. $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
  278. # Extract gconf menu items for I18N support
  279. $(obj)/gconf.glade.h: $(obj)/gconf.glade
  280. $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
  281. $(obj)/gconf.glade
  282. ###
  283. # The following requires flex/bison/gperf
  284. # By default we use the _shipped versions, uncomment the following line if
  285. # you are modifying the flex/bison src.
  286. # LKC_GENPARSER := 1
  287. ifdef LKC_GENPARSER
  288. $(obj)/zconf.tab.c: $(src)/zconf.y
  289. $(obj)/lex.zconf.c: $(src)/zconf.l
  290. $(obj)/zconf.hash.c: $(src)/zconf.gperf
  291. %.tab.c: %.y
  292. bison -l -b $* -p $(notdir $*) $<
  293. cp $@ $@_shipped
  294. lex.%.c: %.l
  295. flex -L -P$(notdir $*) -o$@ $<
  296. cp $@ $@_shipped
  297. %.hash.c: %.gperf
  298. gperf < $< > $@
  299. cp $@ $@_shipped
  300. endif