blob: 2f1a59fa51694262e270a8228fe18fd835690af7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
Randy Dunlap4bf6a9a2018-08-14 17:36:49 -07006PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
7 build_menuconfig build_nconfig build_gconfig build_xconfig
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Al Viro61bee202008-08-25 04:51:27 -04009ifdef KBUILD_KCONFIG
10Kconfig := $(KBUILD_KCONFIG)
11else
Arnaud Lacombe838a2e52010-09-04 17:10:20 -040012Kconfig := Kconfig
Al Viro61bee202008-08-25 04:51:27 -040013endif
Sam Ravnborge703f752007-10-25 20:42:18 +020014
Masahiro Yamadabd305f22019-05-27 23:37:24 +090015ifndef KBUILD_DEFCONFIG
16KBUILD_DEFCONFIG := defconfig
17endif
18
Michal Marek0a1f00a2015-04-08 13:30:42 +020019ifeq ($(quiet),silent_)
20silent := -s
21endif
22
Yann E. MORINc2838e62012-11-22 01:06:04 +010023# We need this, in case the user has it in its environment
24unexport CONFIG_
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026xconfig: $(obj)/qconf
Michal Marek0a1f00a2015-04-08 13:30:42 +020027 $< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29gconfig: $(obj)/gconf
Michal Marek0a1f00a2015-04-08 13:30:42 +020030 $< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32menuconfig: $(obj)/mconf
Michal Marek0a1f00a2015-04-08 13:30:42 +020033 $< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35config: $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020036 $< $(silent) --oldaskconfig $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020038nconfig: $(obj)/nconf
Michal Marek0a1f00a2015-04-08 13:30:42 +020039 $< $(silent) $(Kconfig)
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020040
Randy Dunlap4bf6a9a2018-08-14 17:36:49 -070041build_menuconfig: $(obj)/mconf
42
43build_nconfig: $(obj)/nconf
44
45build_gconfig: $(obj)/gconf
46
47build_xconfig: $(obj)/qconf
48
Ulf Magnusson2a616252018-03-01 12:18:01 +010049localyesconfig localmodconfig: $(obj)/conf
Ulf Magnusson2a616252018-03-01 12:18:01 +010050 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
Michal Marek7a996d32010-08-04 14:05:07 +020051 $(Q)if [ -f .config ]; then \
Sam Ravnborg4062f1a2010-07-31 23:35:26 +020052 cmp -s .tmp.config .config || \
53 (mv -f .config .config.old.1; \
54 mv -f .tmp.config .config; \
Ulf Magnusson2a616252018-03-01 12:18:01 +010055 $< $(silent) --oldconfig $(Kconfig); \
Sam Ravnborg4062f1a2010-07-31 23:35:26 +020056 mv -f .config.old.1 .config.old) \
57 else \
58 mv -f .tmp.config .config; \
Ulf Magnusson2a616252018-03-01 12:18:01 +010059 $< $(silent) --oldconfig $(Kconfig); \
Steven Rostedta7c02602009-05-07 11:09:55 -040060 fi
Steven Rostedt03fa25d2009-04-29 22:52:22 -040061 $(Q)rm -f .tmp.config
62
Michal Marek1cba0c32015-04-08 11:11:57 +020063# These targets map 1:1 to the commandline options of 'conf'
Masahiro Yamada79123b12018-07-20 16:46:29 +090064#
65# Note:
66# syncconfig has become an internal implementation detail and is now
67# deprecated for external use
Michal Marek1cba0c32015-04-08 11:11:57 +020068simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
Laura Abbott5d8b42a2019-11-04 17:10:08 -050069 alldefconfig randconfig listnewconfig olddefconfig syncconfig \
70 helpnewconfig
71
Michal Marek1cba0c32015-04-08 11:11:57 +020072PHONY += $(simple-targets)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Michal Marek1cba0c32015-04-08 11:11:57 +020074$(simple-targets): $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020075 $< $(silent) --$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Masahiro Yamada0085b412018-10-30 00:41:28 +090077PHONY += savedefconfig defconfig
Masahiro Yamada911a91c2018-03-01 15:34:37 +090078
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020079savedefconfig: $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020080 $< $(silent) --$@=defconfig $(Kconfig)
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082defconfig: $(obj)/conf
Masahiro Yamadae0a26682019-05-27 23:37:21 +090083ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
Michal Marek0a1f00a2015-04-08 13:30:42 +020084 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
85 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
Michael Ellermand2036f32015-09-23 15:40:34 +100086else
87 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
88 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089endif
90
91%_defconfig: $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020092 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
Masahiro Yamada63a91032015-03-13 15:21:43 +090094configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
Josh Triplett3aaefce2014-08-06 15:21:00 -070095
Masahiro Yamada63a91032015-03-13 15:21:43 +090096%.config: $(obj)/conf
97 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
98 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
Masahiro Yamada3266c802019-06-05 03:14:53 +090099 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
Josh Triplett3aaefce2014-08-06 15:21:00 -0700100
101PHONY += kvmconfig
Masahiro Yamada63a91032015-03-13 15:21:43 +0900102kvmconfig: kvm_guest.config
103 @:
Josh Triplett3aaefce2014-08-06 15:21:00 -0700104
Luis R. Rodriguez6c668502015-05-20 11:53:39 -0700105PHONY += xenconfig
106xenconfig: xen.config
107 @:
108
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700109PHONY += tinyconfig
Masahiro Yamada63a91032015-03-13 15:21:43 +0900110tinyconfig:
111 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700112
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900113# CHECK: -o cache_dir=<path> working?
114PHONY += testconfig
115testconfig: $(obj)/conf
116 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
117 -o cache_dir=$(abspath $(obj)/tests/.cache) \
118 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
Masahiro Yamada1634f2b2019-08-25 10:31:27 +0900119clean-files += tests/.cache
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121# Help text used by make help
122help:
123 @echo ' config - Update current config utilising a line-oriented program'
Petr Vorelbb6d83d2018-06-02 11:08:03 +0200124 @echo ' nconfig - Update current config utilising a ncurses menu based program'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 @echo ' menuconfig - Update current config utilising a menu based program'
Diego Viola092373c2015-04-06 06:27:45 -0300126 @echo ' xconfig - Update current config utilising a Qt based front-end'
Diego Viola39c3f1b2015-05-31 14:35:51 -0300127 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 @echo ' oldconfig - Update current config utilising a provided .config as base'
Steven Rostedt03fa25d2009-04-29 22:52:22 -0400129 @echo ' localmodconfig - Update current config disabling modules not loaded'
Steven Rostedt281c9da2009-04-29 22:52:23 -0400130 @echo ' localyesconfig - Update current config converting local mods to core'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200131 @echo ' defconfig - New config with default from ARCH supplied defconfig'
Sam Ravnborg7cf3d732010-07-31 23:35:34 +0200132 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
Jesper Juhle11f0492006-02-25 21:52:50 +0100133 @echo ' allnoconfig - New config where all options are answered with no'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200134 @echo ' allyesconfig - New config where all options are accepted with yes'
135 @echo ' allmodconfig - New config selecting modules when possible'
136 @echo ' alldefconfig - New config with all symbols set to default'
137 @echo ' randconfig - New config with random answer to all options'
Sam Ravnborg861b4ea2010-07-31 23:35:28 +0200138 @echo ' listnewconfig - List new options'
Laura Abbott5d8b42a2019-11-04 17:10:08 -0500139 @echo ' helpnewconfig - List new options and help text'
Marc Herbertcedd55d2018-01-26 14:59:00 -0800140 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
141 @echo ' default value without prompting'
Luis R. Rodriguez9bcd7762015-05-20 11:53:38 -0700142 @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
Geert Uytterhoevena64c0442019-10-25 13:52:32 +0200143 @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel'
144 @echo ' support'
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700145 @echo ' tinyconfig - Configure the tiniest possible kernel'
Petr Voreld6a0c8a2018-06-02 11:08:02 +0200146 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148# ===========================================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149# object files used by all kconfig flavours
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900150common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
Masahiro Yamada521b29b2019-08-26 02:28:33 +0900151 symbol.o util.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900153$(obj)/lexer.lex.o: $(obj)/parser.tab.h
Masahiro Yamada9cc342f2019-05-13 15:22:16 +0900154HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
155HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900157# conf: Used for defconfig, oldconfig and related targets
158hostprogs-y += conf
159conf-objs := conf.o $(common-objs)
160
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900161# nconf: Used for the nconfig target based on ncurses
162hostprogs-y += nconf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900163nconf-objs := nconf.o nconf.gui.o $(common-objs)
Arnaud Lacombe7080e472010-08-16 00:19:04 -0400164
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900165HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
166HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
167HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900168
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900169$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900170
171# mconf: Used for the menuconfig target based on lxdialog
172hostprogs-y += mconf
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900173lxdialog := $(addprefix lxdialog/, \
174 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
175mconf-objs := mconf.o $(lxdialog) $(common-objs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900176
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900177HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900178$(foreach f, mconf.o $(lxdialog), \
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900179 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900180
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900181$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900183# qconf: Used for the xconfig target based on Qt
184hostprogs-y += qconf
185qconf-cxxobjs := qconf.o
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900186qconf-objs := images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900188HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
189HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900190
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900191$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900192
193quiet_cmd_moc = MOC $@
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900194 cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900195
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900196$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900197 $(call cmd,moc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Masahiro Yamadab464ef52018-05-22 16:22:20 +0900199# gconf: Used for the gconfig target based on GTK+
200hostprogs-y += gconf
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900201gconf-objs := gconf.o images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900203HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs)
204HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900206$(obj)/gconf.o: $(obj)/gconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900208# check if necessary packages are available, and configure build flags
Masahiro Yamadaba97df42019-01-03 10:16:54 +0900209filechk_conf_cfg = $(CONFIG_SHELL) $<
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900210
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900211$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900212 $(call filechk,conf_cfg)
213
Masahiro Yamada2648ca12019-01-11 11:51:48 +0900214clean-files += *conf-cfg