xref: /linux/scripts/kconfig/Makefile (revision 47572387d58a9584c60ebbbdee56fc92c627f16f)
11da177e4SLinus Torvalds# ===========================================================================
21da177e4SLinus Torvalds# Kernel configuration targets
31da177e4SLinus Torvalds# These targets are used from top-level makefile
41da177e4SLinus Torvalds
54f193362SPaul SmithPHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
61da177e4SLinus Torvalds
7*47572387SSam Ravnborg# If a arch/$(SRCARCH)/Kconfig.$(ARCH) file exist use it
8*47572387SSam Ravnborgifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/Kconfig.$(ARCH)),)
9*47572387SSam Ravnborg        Kconfig := arch/$(SRCARCH)/Kconfig.$(ARCH)
10*47572387SSam Ravnborgelse
11*47572387SSam Ravnborg        Kconfig := arch/$(SRCARCH)/Kconfig
12*47572387SSam Ravnborgendif
13e703f75dSSam Ravnborg
141da177e4SLinus Torvaldsxconfig: $(obj)/qconf
15e703f75dSSam Ravnborg	$< $(Kconfig)
161da177e4SLinus Torvalds
171da177e4SLinus Torvaldsgconfig: $(obj)/gconf
18e703f75dSSam Ravnborg	$< $(Kconfig)
191da177e4SLinus Torvalds
201da177e4SLinus Torvaldsmenuconfig: $(obj)/mconf
21e703f75dSSam Ravnborg	$< $(Kconfig)
221da177e4SLinus Torvalds
231da177e4SLinus Torvaldsconfig: $(obj)/conf
24e703f75dSSam Ravnborg	$< $(Kconfig)
251da177e4SLinus Torvalds
261da177e4SLinus Torvaldsoldconfig: $(obj)/conf
27e703f75dSSam Ravnborg	$< -o $(Kconfig)
281da177e4SLinus Torvalds
291da177e4SLinus Torvaldssilentoldconfig: $(obj)/conf
30e703f75dSSam Ravnborg	$< -s $(Kconfig)
311da177e4SLinus Torvalds
32b70e325cSSam Ravnborg# Create new linux.po file
33b70e325cSSam Ravnborg# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
34b70e325cSSam Ravnborg# The symlink is used to repair a deficiency in arch/um
353b9fa093SArnaldo Carvalho de Meloupdate-po-config: $(obj)/kxgettext
363b9fa093SArnaldo Carvalho de Melo	xgettext --default-domain=linux                  \
373b9fa093SArnaldo Carvalho de Melo	    --add-comments --keyword=_ --keyword=N_      \
38b70e325cSSam Ravnborg	    --from-code=UTF-8                            \
393b9fa093SArnaldo Carvalho de Melo	    --files-from=scripts/kconfig/POTFILES.in     \
40b70e325cSSam Ravnborg	    --output $(obj)/config.pot
41b70e325cSSam Ravnborg	$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
42b70e325cSSam Ravnborg	$(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
43b70e325cSSam Ravnborg	(for i in `ls arch/`;                            \
44720d6c29SEgry Gabor	do                                               \
45b70e325cSSam Ravnborg	    $(obj)/kxgettext arch/$$i/Kconfig;           \
46b70e325cSSam Ravnborg	done ) >> $(obj)/config.pot
47b70e325cSSam Ravnborg	msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
48b70e325cSSam Ravnborg	    --output $(obj)/linux.pot
49b70e325cSSam Ravnborg	$(Q)rm -f arch/um/Kconfig.arch
50b70e325cSSam Ravnborg	$(Q)rm -f $(obj)/config.pot
513b9fa093SArnaldo Carvalho de Melo
524f193362SPaul SmithPHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
531da177e4SLinus Torvalds
541da177e4SLinus Torvaldsrandconfig: $(obj)/conf
55e703f75dSSam Ravnborg	$< -r $(Kconfig)
561da177e4SLinus Torvalds
571da177e4SLinus Torvaldsallyesconfig: $(obj)/conf
58e703f75dSSam Ravnborg	$< -y $(Kconfig)
591da177e4SLinus Torvalds
601da177e4SLinus Torvaldsallnoconfig: $(obj)/conf
61e703f75dSSam Ravnborg	$< -n $(Kconfig)
621da177e4SLinus Torvalds
631da177e4SLinus Torvaldsallmodconfig: $(obj)/conf
64e703f75dSSam Ravnborg	$< -m $(Kconfig)
651da177e4SLinus Torvalds
661da177e4SLinus Torvaldsdefconfig: $(obj)/conf
671da177e4SLinus Torvaldsifeq ($(KBUILD_DEFCONFIG),)
68e703f75dSSam Ravnborg	$< -d $(Kconfig)
691da177e4SLinus Torvaldselse
702266cfd5SSam Ravnborg	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
71e703f75dSSam Ravnborg	$(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
721da177e4SLinus Torvaldsendif
731da177e4SLinus Torvalds
741da177e4SLinus Torvalds%_defconfig: $(obj)/conf
75e703f75dSSam Ravnborg	$(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
761da177e4SLinus Torvalds
771da177e4SLinus Torvalds# Help text used by make help
781da177e4SLinus Torvaldshelp:
791da177e4SLinus Torvalds	@echo  '  config	  - Update current config utilising a line-oriented program'
801da177e4SLinus Torvalds	@echo  '  menuconfig	  - Update current config utilising a menu based program'
811da177e4SLinus Torvalds	@echo  '  xconfig	  - Update current config utilising a QT based front-end'
821da177e4SLinus Torvalds	@echo  '  gconfig	  - Update current config utilising a GTK based front-end'
831da177e4SLinus Torvalds	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
84b32c8268SRobert P. J. Day	@echo  '  silentoldconfig - Same as oldconfig, but quietly'
851da177e4SLinus Torvalds	@echo  '  randconfig	  - New config with random answer to all options'
861da177e4SLinus Torvalds	@echo  '  defconfig	  - New config with default answer to all options'
871da177e4SLinus Torvalds	@echo  '  allmodconfig	  - New config selecting modules when possible'
881da177e4SLinus Torvalds	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
89e11f0496SJesper Juhl	@echo  '  allnoconfig	  - New config where all options are answered with no'
901da177e4SLinus Torvalds
912982de69SSam Ravnborg# lxdialog stuff
922982de69SSam Ravnborgcheck-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
932982de69SSam Ravnborg
94e9e40e14SRob Landley# Use recursively expanded variables so we do not call gcc unless
952982de69SSam Ravnborg# we really need to do so. (Do not call gcc as part of make mrproper)
962982de69SSam RavnborgHOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
972982de69SSam RavnborgHOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
982982de69SSam Ravnborg
992982de69SSam RavnborgHOST_EXTRACFLAGS += -DLOCALE
1002982de69SSam Ravnborg
1012982de69SSam RavnborgPHONY += $(obj)/dochecklxdialog
1022982de69SSam Ravnborg$(obj)/dochecklxdialog:
1032982de69SSam Ravnborg	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
1042982de69SSam Ravnborg
1052982de69SSam Ravnborgalways := dochecklxdialog
1062982de69SSam Ravnborg
1072982de69SSam Ravnborg
1081da177e4SLinus Torvalds# ===========================================================================
1091da177e4SLinus Torvalds# Shared Makefile for the various kconfig executables:
1101da177e4SLinus Torvalds# conf:	  Used for defconfig, oldconfig and related targets
1111da177e4SLinus Torvalds# mconf:  Used for the mconfig target.
1121da177e4SLinus Torvalds#         Utilizes the lxdialog package
1131da177e4SLinus Torvalds# qconf:  Used for the xconfig target
1141da177e4SLinus Torvalds#         Based on QT which needs to be installed to compile it
1151da177e4SLinus Torvalds# gconf:  Used for the gconfig target
1161da177e4SLinus Torvalds#         Based on GTK which needs to be installed to compile it
1171da177e4SLinus Torvalds# object files used by all kconfig flavours
1181da177e4SLinus Torvalds
1192982de69SSam Ravnborglxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
1202982de69SSam Ravnborglxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
1212982de69SSam Ravnborg
1221da177e4SLinus Torvaldsconf-objs	:= conf.o  zconf.tab.o
1232982de69SSam Ravnborgmconf-objs	:= mconf.o zconf.tab.o $(lxdialog)
1243b9fa093SArnaldo Carvalho de Melokxgettext-objs	:= kxgettext.o zconf.tab.o
1251da177e4SLinus Torvalds
126c29121b7SSam Ravnborghostprogs-y := conf qconf gconf kxgettext
127c29121b7SSam Ravnborg
128c29121b7SSam Ravnborgifeq ($(MAKECMDGOALS),menuconfig)
129c29121b7SSam Ravnborg	hostprogs-y += mconf
130c29121b7SSam Ravnborgendif
131c29121b7SSam Ravnborg
1321da177e4SLinus Torvaldsifeq ($(MAKECMDGOALS),xconfig)
1331da177e4SLinus Torvalds	qconf-target := 1
1341da177e4SLinus Torvaldsendif
1351da177e4SLinus Torvaldsifeq ($(MAKECMDGOALS),gconfig)
1361da177e4SLinus Torvalds	gconf-target := 1
1371da177e4SLinus Torvaldsendif
1381da177e4SLinus Torvalds
1391da177e4SLinus Torvalds
1401da177e4SLinus Torvaldsifeq ($(qconf-target),1)
1411da177e4SLinus Torvaldsqconf-cxxobjs	:= qconf.o
1421da177e4SLinus Torvaldsqconf-objs	:= kconfig_load.o zconf.tab.o
1431da177e4SLinus Torvaldsendif
1441da177e4SLinus Torvalds
1451da177e4SLinus Torvaldsifeq ($(gconf-target),1)
1461da177e4SLinus Torvaldsgconf-objs	:= gconf.o kconfig_load.o zconf.tab.o
1471da177e4SLinus Torvaldsendif
1481da177e4SLinus Torvalds
1491da177e4SLinus Torvaldsclean-files	:= lkc_defs.h qconf.moc .tmp_qtcheck \
1507a88488bSRoman Zippel		   .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
151145c9047SSam Ravnborgclean-files     += mconf qconf gconf
1521da177e4SLinus Torvalds
153aa1e5ef5SSam Ravnborg# Add environment specific flags
154aa1e5ef5SSam RavnborgHOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
15570a6a0cbSYuri Vasilevski
1561da177e4SLinus Torvalds# generated files seem to need this to find local include files
1571da177e4SLinus TorvaldsHOSTCFLAGS_lex.zconf.o	:= -I$(src)
1581da177e4SLinus TorvaldsHOSTCFLAGS_zconf.tab.o	:= -I$(src)
1591da177e4SLinus Torvalds
160b3a5225fSRoman ZippelHOSTLOADLIBES_qconf	= $(KC_QT_LIBS) -ldl
161b3a5225fSRoman ZippelHOSTCXXFLAGS_qconf.o	= $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
1621da177e4SLinus Torvalds
16337193147SAdrian BunkHOSTLOADLIBES_gconf	= `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
16437193147SAdrian BunkHOSTCFLAGS_gconf.o	= `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
1651da177e4SLinus Torvalds                          -D LKC_DIRECT_LINK
1661da177e4SLinus Torvalds
1671da177e4SLinus Torvalds$(obj)/qconf.o: $(obj)/.tmp_qtcheck
1681da177e4SLinus Torvalds
1691da177e4SLinus Torvaldsifeq ($(qconf-target),1)
170b3a5225fSRoman Zippel$(obj)/.tmp_qtcheck: $(src)/Makefile
1711da177e4SLinus Torvalds-include $(obj)/.tmp_qtcheck
1721da177e4SLinus Torvalds
1731da177e4SLinus Torvalds# QT needs some extra effort...
1741da177e4SLinus Torvalds$(obj)/.tmp_qtcheck:
175b3a5225fSRoman Zippel	@set -e; echo "  CHECK   qt"; dir=""; pkg=""; \
176b3a5225fSRoman Zippel	pkg-config --exists qt 2> /dev/null && pkg=qt; \
177b3a5225fSRoman Zippel	pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
178b3a5225fSRoman Zippel	if [ -n "$$pkg" ]; then \
179b3a5225fSRoman Zippel	  cflags="\$$(shell pkg-config $$pkg --cflags)"; \
180b3a5225fSRoman Zippel	  libs="\$$(shell pkg-config $$pkg --libs)"; \
181b3a5225fSRoman Zippel	  moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
182b3a5225fSRoman Zippel	  dir="$$(pkg-config $$pkg --variable=prefix)"; \
183b3a5225fSRoman Zippel	else \
184b3a5225fSRoman Zippel	  for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
185b3a5225fSRoman Zippel	    if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
1861da177e4SLinus Torvalds	  done; \
187b3a5225fSRoman Zippel	  if [ -z "$$dir" ]; then \
1881da177e4SLinus Torvalds	    echo "*"; \
1899ae57004SSam Ravnborg	    echo "* Unable to find the QT3 installation. Please make sure that"; \
1909ae57004SSam Ravnborg	    echo "* the QT3 development package is correctly installed and"; \
191b3a5225fSRoman Zippel	    echo "* either install pkg-config or set the QTDIR environment"; \
192b3a5225fSRoman Zippel	    echo "* variable to the correct location."; \
1931da177e4SLinus Torvalds	    echo "*"; \
1941da177e4SLinus Torvalds	    false; \
1951da177e4SLinus Torvalds	  fi; \
196b3a5225fSRoman Zippel	  libpath=$$dir/lib; lib=qt; osdir=""; \
1971da177e4SLinus Torvalds	  $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
198b3a5225fSRoman Zippel	    osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
199b3a5225fSRoman Zippel	  test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
200b3a5225fSRoman Zippel	  test -f $$libpath/libqt-mt.so && lib=qt-mt; \
201b3a5225fSRoman Zippel	  cflags="-I$$dir/include"; \
202b3a5225fSRoman Zippel	  libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
203b3a5225fSRoman Zippel	  moc="$$dir/bin/moc"; \
204ab919c06SSam Ravnborg	fi; \
205b3a5225fSRoman Zippel	if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
2061da177e4SLinus Torvalds	  echo "*"; \
207b3a5225fSRoman Zippel	  echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
2081da177e4SLinus Torvalds	  echo "*"; \
209b3a5225fSRoman Zippel	  moc="/usr/bin/moc"; \
210b3a5225fSRoman Zippel	fi; \
211b3a5225fSRoman Zippel	echo "KC_QT_CFLAGS=$$cflags" > $@; \
212b3a5225fSRoman Zippel	echo "KC_QT_LIBS=$$libs" >> $@; \
213b3a5225fSRoman Zippel	echo "KC_QT_MOC=$$moc" >> $@
2141da177e4SLinus Torvaldsendif
2151da177e4SLinus Torvalds
2161da177e4SLinus Torvalds$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
2171da177e4SLinus Torvalds
2181da177e4SLinus Torvaldsifeq ($(gconf-target),1)
2191da177e4SLinus Torvalds-include $(obj)/.tmp_gtkcheck
2201da177e4SLinus Torvalds
2211da177e4SLinus Torvalds# GTK needs some extra effort, too...
2221da177e4SLinus Torvalds$(obj)/.tmp_gtkcheck:
22337193147SAdrian Bunk	@if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then		\
22437193147SAdrian Bunk		if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then			\
2251da177e4SLinus Torvalds			touch $@;								\
2261da177e4SLinus Torvalds		else									\
2271da177e4SLinus Torvalds			echo "*"; 							\
2281da177e4SLinus Torvalds			echo "* GTK+ is present but version >= 2.0.0 is required.";	\
2291da177e4SLinus Torvalds			echo "*";							\
2301da177e4SLinus Torvalds			false;								\
2311da177e4SLinus Torvalds		fi									\
2321da177e4SLinus Torvalds	else										\
2331da177e4SLinus Torvalds		echo "*"; 								\
2341da177e4SLinus Torvalds		echo "* Unable to find the GTK+ installation. Please make sure that"; 	\
2351da177e4SLinus Torvalds		echo "* the GTK+ 2.0 development package is correctly installed..."; 	\
2361da177e4SLinus Torvalds		echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; 		\
2371da177e4SLinus Torvalds		echo "*"; 								\
2381da177e4SLinus Torvalds		false;									\
2391da177e4SLinus Torvalds	fi
2401da177e4SLinus Torvaldsendif
2411da177e4SLinus Torvalds
2427a88488bSRoman Zippel$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
2431da177e4SLinus Torvalds
2441da177e4SLinus Torvalds$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
2451da177e4SLinus Torvalds
2461da177e4SLinus Torvalds$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
2471da177e4SLinus Torvalds
2481da177e4SLinus Torvalds$(obj)/gconf.o: $(obj)/lkc_defs.h
2491da177e4SLinus Torvalds
2501da177e4SLinus Torvalds$(obj)/%.moc: $(src)/%.h
251b3a5225fSRoman Zippel	$(KC_QT_MOC) -i $< -o $@
2521da177e4SLinus Torvalds
2531da177e4SLinus Torvalds$(obj)/lkc_defs.h: $(src)/lkc_proto.h
2541da177e4SLinus Torvalds	sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
2551da177e4SLinus Torvalds
2561da177e4SLinus Torvalds
2571da177e4SLinus Torvalds###
2587a88488bSRoman Zippel# The following requires flex/bison/gperf
2591da177e4SLinus Torvalds# By default we use the _shipped versions, uncomment the following line if
2601da177e4SLinus Torvalds# you are modifying the flex/bison src.
2611da177e4SLinus Torvalds# LKC_GENPARSER := 1
2621da177e4SLinus Torvalds
2631da177e4SLinus Torvaldsifdef LKC_GENPARSER
2641da177e4SLinus Torvalds
265491d7110SRoman Zippel$(obj)/zconf.tab.c: $(src)/zconf.y
266491d7110SRoman Zippel$(obj)/lex.zconf.c: $(src)/zconf.l
2677a88488bSRoman Zippel$(obj)/zconf.hash.c: $(src)/zconf.gperf
2681da177e4SLinus Torvalds
2691da177e4SLinus Torvalds%.tab.c: %.y
270491d7110SRoman Zippel	bison -l -b $* -p $(notdir $*) $<
271491d7110SRoman Zippel	cp $@ $@_shipped
2721da177e4SLinus Torvalds
2731da177e4SLinus Torvaldslex.%.c: %.l
274491d7110SRoman Zippel	flex -L -P$(notdir $*) -o$@ $<
275491d7110SRoman Zippel	cp $@ $@_shipped
2761da177e4SLinus Torvalds
2777a88488bSRoman Zippel%.hash.c: %.gperf
2787a88488bSRoman Zippel	gperf < $< > $@
2797a88488bSRoman Zippel	cp $@ $@_shipped
2807a88488bSRoman Zippel
2811da177e4SLinus Torvaldsendif
282