xref: /linux/scripts/kconfig/Makefile (revision 281c9dadc31ffd9f3cf637553134fefe75e849da)
11da177e4SLinus Torvalds# ===========================================================================
21da177e4SLinus Torvalds# Kernel configuration targets
31da177e4SLinus Torvalds# These targets are used from top-level makefile
41da177e4SLinus Torvalds
503fa25daSSteven RostedtPHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
6*281c9dadSSteven Rostedt	localmodconfig localyesconfig
71da177e4SLinus Torvalds
861bee204SAl Viroifdef KBUILD_KCONFIG
961bee204SAl ViroKconfig := $(KBUILD_KCONFIG)
1061bee204SAl Viroelse
1147572387SSam RavnborgKconfig := arch/$(SRCARCH)/Kconfig
1261bee204SAl Viroendif
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
3203fa25daSSteven Rostedtlocalmodconfig: $(obj)/streamline_config.pl $(obj)/conf
3303fa25daSSteven Rostedt	$(Q)perl $< $(Kconfig) > .tmp.config
3403fa25daSSteven Rostedt	$(Q)cmp -s .tmp.config .config ||		\
3503fa25daSSteven Rostedt		(mv -f .config .config.old.1;		\
3603fa25daSSteven Rostedt		 mv -f .tmp.config .config;		\
3703fa25daSSteven Rostedt		 $(obj)/conf -s $(Kconfig);		\
3803fa25daSSteven Rostedt		 mv -f .config.old.1 .config.old)
3903fa25daSSteven Rostedt	$(Q)rm -f .tmp.config
4003fa25daSSteven Rostedt
41*281c9dadSSteven Rostedtlocalyesconfig: $(obj)/streamline_config.pl
42*281c9dadSSteven Rostedt	$(Q)perl $< $(Kconfig) > .tmp.config
43*281c9dadSSteven Rostedt	$(Q)sed -i s/=m/=y/ .tmp.config
44*281c9dadSSteven Rostedt	$(Q)cmp -s .tmp.config .config ||		\
45*281c9dadSSteven Rostedt		(mv -f .config .config.old.1;		\
46*281c9dadSSteven Rostedt		 mv -f .tmp.config .config;		\
47*281c9dadSSteven Rostedt		 $(obj)/conf -s $(Kconfig);		\
48*281c9dadSSteven Rostedt		 mv -f .config.old.1 .config.old)
49*281c9dadSSteven Rostedt	$(Q)rm -f .tmp.config
50*281c9dadSSteven Rostedt
511020026fSEGRY Gabor# Create new linux.pot file
52b70e325cSSam Ravnborg# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
53b70e325cSSam Ravnborg# The symlink is used to repair a deficiency in arch/um
5446d26319SEGRY Gaborupdate-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
551020026fSEGRY Gabor	$(Q)echo "  GEN config"
561020026fSEGRY Gabor	$(Q)xgettext --default-domain=linux              \
573b9fa093SArnaldo Carvalho de Melo	    --add-comments --keyword=_ --keyword=N_      \
58b70e325cSSam Ravnborg	    --from-code=UTF-8                            \
593b9fa093SArnaldo Carvalho de Melo	    --files-from=scripts/kconfig/POTFILES.in     \
60b70e325cSSam Ravnborg	    --output $(obj)/config.pot
61b70e325cSSam Ravnborg	$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
62b70e325cSSam Ravnborg	$(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
634217516eSSam Ravnborg	$(Q)(for i in `ls arch/*/Kconfig`;               \
64720d6c29SEgry Gabor	    do                                           \
651020026fSEGRY Gabor		echo "  GEN $$i";                        \
664217516eSSam Ravnborg		$(obj)/kxgettext $$i                     \
671020026fSEGRY Gabor		     >> $(obj)/config.pot;               \
681020026fSEGRY Gabor	    done )
691020026fSEGRY Gabor	$(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
70b70e325cSSam Ravnborg	    --output $(obj)/linux.pot
71b70e325cSSam Ravnborg	$(Q)rm -f arch/um/Kconfig.arch
72b70e325cSSam Ravnborg	$(Q)rm -f $(obj)/config.pot
733b9fa093SArnaldo Carvalho de Melo
744f193362SPaul SmithPHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
751da177e4SLinus Torvalds
761da177e4SLinus Torvaldsrandconfig: $(obj)/conf
77e703f75dSSam Ravnborg	$< -r $(Kconfig)
781da177e4SLinus Torvalds
791da177e4SLinus Torvaldsallyesconfig: $(obj)/conf
80e703f75dSSam Ravnborg	$< -y $(Kconfig)
811da177e4SLinus Torvalds
821da177e4SLinus Torvaldsallnoconfig: $(obj)/conf
83e703f75dSSam Ravnborg	$< -n $(Kconfig)
841da177e4SLinus Torvalds
851da177e4SLinus Torvaldsallmodconfig: $(obj)/conf
86e703f75dSSam Ravnborg	$< -m $(Kconfig)
871da177e4SLinus Torvalds
881da177e4SLinus Torvaldsdefconfig: $(obj)/conf
891da177e4SLinus Torvaldsifeq ($(KBUILD_DEFCONFIG),)
90e703f75dSSam Ravnborg	$< -d $(Kconfig)
911da177e4SLinus Torvaldselse
922266cfd5SSam Ravnborg	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
93e703f75dSSam Ravnborg	$(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
941da177e4SLinus Torvaldsendif
951da177e4SLinus Torvalds
961da177e4SLinus Torvalds%_defconfig: $(obj)/conf
97e703f75dSSam Ravnborg	$(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
981da177e4SLinus Torvalds
991da177e4SLinus Torvalds# Help text used by make help
1001da177e4SLinus Torvaldshelp:
1011da177e4SLinus Torvalds	@echo  '  config	  - Update current config utilising a line-oriented program'
1021da177e4SLinus Torvalds	@echo  '  menuconfig	  - Update current config utilising a menu based program'
1031da177e4SLinus Torvalds	@echo  '  xconfig	  - Update current config utilising a QT based front-end'
1041da177e4SLinus Torvalds	@echo  '  gconfig	  - Update current config utilising a GTK based front-end'
1051da177e4SLinus Torvalds	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
10603fa25daSSteven Rostedt	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
107*281c9dadSSteven Rostedt	@echo  '  localyesconfig  - Update current config converting local mods to core'
108590a5857SMarkus Heidelberg	@echo  '  silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
1091da177e4SLinus Torvalds	@echo  '  randconfig	  - New config with random answer to all options'
1101da177e4SLinus Torvalds	@echo  '  defconfig	  - New config with default answer to all options'
1111da177e4SLinus Torvalds	@echo  '  allmodconfig	  - New config selecting modules when possible'
1121da177e4SLinus Torvalds	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
113e11f0496SJesper Juhl	@echo  '  allnoconfig	  - New config where all options are answered with no'
1141da177e4SLinus Torvalds
1152982de69SSam Ravnborg# lxdialog stuff
1162982de69SSam Ravnborgcheck-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
1172982de69SSam Ravnborg
118e9e40e14SRob Landley# Use recursively expanded variables so we do not call gcc unless
1192982de69SSam Ravnborg# we really need to do so. (Do not call gcc as part of make mrproper)
1202982de69SSam RavnborgHOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
1212982de69SSam RavnborgHOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
1222982de69SSam Ravnborg
1232982de69SSam RavnborgHOST_EXTRACFLAGS += -DLOCALE
1242982de69SSam Ravnborg
1252982de69SSam Ravnborg
1261da177e4SLinus Torvalds# ===========================================================================
1271da177e4SLinus Torvalds# Shared Makefile for the various kconfig executables:
1281da177e4SLinus Torvalds# conf:	  Used for defconfig, oldconfig and related targets
1296f26e5e4SMarkus Heidelberg# mconf:  Used for the menuconfig target
1301da177e4SLinus Torvalds#         Utilizes the lxdialog package
1311da177e4SLinus Torvalds# qconf:  Used for the xconfig target
1321da177e4SLinus Torvalds#         Based on QT which needs to be installed to compile it
1331da177e4SLinus Torvalds# gconf:  Used for the gconfig target
1341da177e4SLinus Torvalds#         Based on GTK which needs to be installed to compile it
1351da177e4SLinus Torvalds# object files used by all kconfig flavours
1361da177e4SLinus Torvalds
1372982de69SSam Ravnborglxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
1382982de69SSam Ravnborglxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
1392982de69SSam Ravnborg
1401da177e4SLinus Torvaldsconf-objs	:= conf.o  zconf.tab.o
1412982de69SSam Ravnborgmconf-objs	:= mconf.o zconf.tab.o $(lxdialog)
1423b9fa093SArnaldo Carvalho de Melokxgettext-objs	:= kxgettext.o zconf.tab.o
1431da177e4SLinus Torvalds
144c29121b7SSam Ravnborghostprogs-y := conf qconf gconf kxgettext
145c29121b7SSam Ravnborg
146c29121b7SSam Ravnborgifeq ($(MAKECMDGOALS),menuconfig)
147c29121b7SSam Ravnborg	hostprogs-y += mconf
148c29121b7SSam Ravnborgendif
149c29121b7SSam Ravnborg
1501da177e4SLinus Torvaldsifeq ($(MAKECMDGOALS),xconfig)
1511da177e4SLinus Torvalds	qconf-target := 1
1521da177e4SLinus Torvaldsendif
1531da177e4SLinus Torvaldsifeq ($(MAKECMDGOALS),gconfig)
1541da177e4SLinus Torvalds	gconf-target := 1
1551da177e4SLinus Torvaldsendif
1561da177e4SLinus Torvalds
1571da177e4SLinus Torvalds
1581da177e4SLinus Torvaldsifeq ($(qconf-target),1)
1591da177e4SLinus Torvaldsqconf-cxxobjs	:= qconf.o
1601da177e4SLinus Torvaldsqconf-objs	:= kconfig_load.o zconf.tab.o
1611da177e4SLinus Torvaldsendif
1621da177e4SLinus Torvalds
1631da177e4SLinus Torvaldsifeq ($(gconf-target),1)
1641da177e4SLinus Torvaldsgconf-objs	:= gconf.o kconfig_load.o zconf.tab.o
1651da177e4SLinus Torvaldsendif
1661da177e4SLinus Torvalds
1671da177e4SLinus Torvaldsclean-files	:= lkc_defs.h qconf.moc .tmp_qtcheck \
16846d26319SEGRY Gabor		   .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
169145c9047SSam Ravnborgclean-files     += mconf qconf gconf
1701020026fSEGRY Gaborclean-files     += config.pot linux.pot
1711da177e4SLinus Torvalds
1726e588f6dSSam Ravnborg# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
1736e588f6dSSam RavnborgPHONY += $(obj)/dochecklxdialog
1746e588f6dSSam Ravnborg$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
1756e588f6dSSam Ravnborg$(obj)/dochecklxdialog:
1766e588f6dSSam Ravnborg	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
1776e588f6dSSam Ravnborg
1786e588f6dSSam Ravnborgalways := dochecklxdialog
1796e588f6dSSam Ravnborg
180aa1e5ef5SSam Ravnborg# Add environment specific flags
181aa1e5ef5SSam RavnborgHOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
18270a6a0cbSYuri Vasilevski
1831da177e4SLinus Torvalds# generated files seem to need this to find local include files
1841da177e4SLinus TorvaldsHOSTCFLAGS_lex.zconf.o	:= -I$(src)
1851da177e4SLinus TorvaldsHOSTCFLAGS_zconf.tab.o	:= -I$(src)
1861da177e4SLinus Torvalds
187b3a5225fSRoman ZippelHOSTLOADLIBES_qconf	= $(KC_QT_LIBS) -ldl
188b3a5225fSRoman ZippelHOSTCXXFLAGS_qconf.o	= $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
1891da177e4SLinus Torvalds
19037193147SAdrian BunkHOSTLOADLIBES_gconf	= `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
19137193147SAdrian BunkHOSTCFLAGS_gconf.o	= `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
1921da177e4SLinus Torvalds                          -D LKC_DIRECT_LINK
1931da177e4SLinus Torvalds
1941da177e4SLinus Torvalds$(obj)/qconf.o: $(obj)/.tmp_qtcheck
1951da177e4SLinus Torvalds
1961da177e4SLinus Torvaldsifeq ($(qconf-target),1)
197b3a5225fSRoman Zippel$(obj)/.tmp_qtcheck: $(src)/Makefile
1981da177e4SLinus Torvalds-include $(obj)/.tmp_qtcheck
1991da177e4SLinus Torvalds
2001da177e4SLinus Torvalds# QT needs some extra effort...
2011da177e4SLinus Torvalds$(obj)/.tmp_qtcheck:
202b3a5225fSRoman Zippel	@set -e; echo "  CHECK   qt"; dir=""; pkg=""; \
203b3a5225fSRoman Zippel	pkg-config --exists qt 2> /dev/null && pkg=qt; \
204b3a5225fSRoman Zippel	pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
205b3a5225fSRoman Zippel	if [ -n "$$pkg" ]; then \
206b3a5225fSRoman Zippel	  cflags="\$$(shell pkg-config $$pkg --cflags)"; \
207b3a5225fSRoman Zippel	  libs="\$$(shell pkg-config $$pkg --libs)"; \
208b3a5225fSRoman Zippel	  moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
209b3a5225fSRoman Zippel	  dir="$$(pkg-config $$pkg --variable=prefix)"; \
210b3a5225fSRoman Zippel	else \
211b3a5225fSRoman Zippel	  for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
212b3a5225fSRoman Zippel	    if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
2131da177e4SLinus Torvalds	  done; \
214b3a5225fSRoman Zippel	  if [ -z "$$dir" ]; then \
2151da177e4SLinus Torvalds	    echo "*"; \
2169ae57004SSam Ravnborg	    echo "* Unable to find the QT3 installation. Please make sure that"; \
2179ae57004SSam Ravnborg	    echo "* the QT3 development package is correctly installed and"; \
218b3a5225fSRoman Zippel	    echo "* either install pkg-config or set the QTDIR environment"; \
219b3a5225fSRoman Zippel	    echo "* variable to the correct location."; \
2201da177e4SLinus Torvalds	    echo "*"; \
2211da177e4SLinus Torvalds	    false; \
2221da177e4SLinus Torvalds	  fi; \
223b3a5225fSRoman Zippel	  libpath=$$dir/lib; lib=qt; osdir=""; \
2241da177e4SLinus Torvalds	  $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
225b3a5225fSRoman Zippel	    osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
226b3a5225fSRoman Zippel	  test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
227b3a5225fSRoman Zippel	  test -f $$libpath/libqt-mt.so && lib=qt-mt; \
228b3a5225fSRoman Zippel	  cflags="-I$$dir/include"; \
229b3a5225fSRoman Zippel	  libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
230b3a5225fSRoman Zippel	  moc="$$dir/bin/moc"; \
231ab919c06SSam Ravnborg	fi; \
232b3a5225fSRoman Zippel	if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
2331da177e4SLinus Torvalds	  echo "*"; \
234b3a5225fSRoman Zippel	  echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
2351da177e4SLinus Torvalds	  echo "*"; \
236b3a5225fSRoman Zippel	  moc="/usr/bin/moc"; \
237b3a5225fSRoman Zippel	fi; \
238b3a5225fSRoman Zippel	echo "KC_QT_CFLAGS=$$cflags" > $@; \
239b3a5225fSRoman Zippel	echo "KC_QT_LIBS=$$libs" >> $@; \
240b3a5225fSRoman Zippel	echo "KC_QT_MOC=$$moc" >> $@
2411da177e4SLinus Torvaldsendif
2421da177e4SLinus Torvalds
2431da177e4SLinus Torvalds$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
2441da177e4SLinus Torvalds
2451da177e4SLinus Torvaldsifeq ($(gconf-target),1)
2461da177e4SLinus Torvalds-include $(obj)/.tmp_gtkcheck
2471da177e4SLinus Torvalds
2481da177e4SLinus Torvalds# GTK needs some extra effort, too...
2491da177e4SLinus Torvalds$(obj)/.tmp_gtkcheck:
25037193147SAdrian Bunk	@if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then		\
25137193147SAdrian Bunk		if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then			\
2521da177e4SLinus Torvalds			touch $@;								\
2531da177e4SLinus Torvalds		else									\
2541da177e4SLinus Torvalds			echo "*"; 							\
2551da177e4SLinus Torvalds			echo "* GTK+ is present but version >= 2.0.0 is required.";	\
2561da177e4SLinus Torvalds			echo "*";							\
2571da177e4SLinus Torvalds			false;								\
2581da177e4SLinus Torvalds		fi									\
2591da177e4SLinus Torvalds	else										\
2601da177e4SLinus Torvalds		echo "*"; 								\
2611da177e4SLinus Torvalds		echo "* Unable to find the GTK+ installation. Please make sure that"; 	\
2621da177e4SLinus Torvalds		echo "* the GTK+ 2.0 development package is correctly installed..."; 	\
2631da177e4SLinus Torvalds		echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; 		\
2641da177e4SLinus Torvalds		echo "*"; 								\
2651da177e4SLinus Torvalds		false;									\
2661da177e4SLinus Torvalds	fi
2671da177e4SLinus Torvaldsendif
2681da177e4SLinus Torvalds
2697a88488bSRoman Zippel$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
2701da177e4SLinus Torvalds
2711da177e4SLinus Torvalds$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
2721da177e4SLinus Torvalds
2731da177e4SLinus Torvalds$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
2741da177e4SLinus Torvalds
2751da177e4SLinus Torvalds$(obj)/gconf.o: $(obj)/lkc_defs.h
2761da177e4SLinus Torvalds
2771da177e4SLinus Torvalds$(obj)/%.moc: $(src)/%.h
278b3a5225fSRoman Zippel	$(KC_QT_MOC) -i $< -o $@
2791da177e4SLinus Torvalds
2801da177e4SLinus Torvalds$(obj)/lkc_defs.h: $(src)/lkc_proto.h
2811da177e4SLinus Torvalds	sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
2821da177e4SLinus Torvalds
28346d26319SEGRY Gabor# Extract gconf menu items for I18N support
28446d26319SEGRY Gabor$(obj)/gconf.glade.h: $(obj)/gconf.glade
28546d26319SEGRY Gabor	intltool-extract --type=gettext/glade $(obj)/gconf.glade
2861da177e4SLinus Torvalds
2871da177e4SLinus Torvalds###
2887a88488bSRoman Zippel# The following requires flex/bison/gperf
2891da177e4SLinus Torvalds# By default we use the _shipped versions, uncomment the following line if
2901da177e4SLinus Torvalds# you are modifying the flex/bison src.
2911da177e4SLinus Torvalds# LKC_GENPARSER := 1
2921da177e4SLinus Torvalds
2931da177e4SLinus Torvaldsifdef LKC_GENPARSER
2941da177e4SLinus Torvalds
295491d7110SRoman Zippel$(obj)/zconf.tab.c: $(src)/zconf.y
296491d7110SRoman Zippel$(obj)/lex.zconf.c: $(src)/zconf.l
2977a88488bSRoman Zippel$(obj)/zconf.hash.c: $(src)/zconf.gperf
2981da177e4SLinus Torvalds
2991da177e4SLinus Torvalds%.tab.c: %.y
300491d7110SRoman Zippel	bison -l -b $* -p $(notdir $*) $<
301491d7110SRoman Zippel	cp $@ $@_shipped
3021da177e4SLinus Torvalds
3031da177e4SLinus Torvaldslex.%.c: %.l
304491d7110SRoman Zippel	flex -L -P$(notdir $*) -o$@ $<
305491d7110SRoman Zippel	cp $@ $@_shipped
3061da177e4SLinus Torvalds
3077a88488bSRoman Zippel%.hash.c: %.gperf
3087a88488bSRoman Zippel	gperf < $< > $@
3097a88488bSRoman Zippel	cp $@ $@_shipped
3107a88488bSRoman Zippel
3111da177e4SLinus Torvaldsendif
312