Makefile 8.6 KB

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