Makefile 7.9 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
L
Linus Torvalds 已提交
2 3 4 5
# ===========================================================================
# Kernel configuration targets
# These targets are used from top-level makefile

6 7
PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
	build_menuconfig build_nconfig build_gconfig build_xconfig
L
Linus Torvalds 已提交
8

A
Al Viro 已提交
9 10 11
ifdef KBUILD_KCONFIG
Kconfig := $(KBUILD_KCONFIG)
else
12
Kconfig := Kconfig
A
Al Viro 已提交
13
endif
14

15 16 17 18
ifeq ($(quiet),silent_)
silent := -s
endif

19 20 21
# We need this, in case the user has it in its environment
unexport CONFIG_

L
Linus Torvalds 已提交
22
xconfig: $(obj)/qconf
23
	$< $(silent) $(Kconfig)
L
Linus Torvalds 已提交
24 25

gconfig: $(obj)/gconf
26
	$< $(silent) $(Kconfig)
L
Linus Torvalds 已提交
27 28

menuconfig: $(obj)/mconf
29
	$< $(silent) $(Kconfig)
L
Linus Torvalds 已提交
30 31

config: $(obj)/conf
32
	$< $(silent) --oldaskconfig $(Kconfig)
L
Linus Torvalds 已提交
33

34
nconfig: $(obj)/nconf
35
	$< $(silent) $(Kconfig)
36

37 38 39 40 41 42 43 44
build_menuconfig: $(obj)/mconf

build_nconfig: $(obj)/nconf

build_gconfig: $(obj)/gconf

build_xconfig: $(obj)/qconf

45 46
localyesconfig localmodconfig: $(obj)/conf
	$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
47
	$(Q)if [ -f .config ]; then 					\
S
Sam Ravnborg 已提交
48 49 50
			cmp -s .tmp.config .config ||			\
			(mv -f .config .config.old.1;			\
			 mv -f .tmp.config .config;			\
51
			 $< $(silent) --oldconfig $(Kconfig);		\
S
Sam Ravnborg 已提交
52 53 54
			 mv -f .config.old.1 .config.old)		\
	else								\
			mv -f .tmp.config .config;			\
55
			$< $(silent) --oldconfig $(Kconfig);		\
56
	fi
57 58
	$(Q)rm -f .tmp.config

M
Michal Marek 已提交
59
# These targets map 1:1 to the commandline options of 'conf'
60 61 62 63
#
# Note:
#  syncconfig has become an internal implementation detail and is now
#  deprecated for external use
M
Michal Marek 已提交
64
simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
65
	alldefconfig randconfig listnewconfig olddefconfig syncconfig
M
Michal Marek 已提交
66
PHONY += $(simple-targets)
L
Linus Torvalds 已提交
67

M
Michal Marek 已提交
68
$(simple-targets): $(obj)/conf
69
	$< $(silent) --$@ $(Kconfig)
L
Linus Torvalds 已提交
70

71
PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
L
Linus Torvalds 已提交
72

73
# oldnoconfig is an alias of olddefconfig, because people already are dependent
74
# on its behavior (sets new symbols to their default value but not 'n') with the
75
# counter-intuitive name.
M
Michal Marek 已提交
76
oldnoconfig: olddefconfig
77 78
	@echo "  WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
	@echo "            Please use \"olddefconfig\" instead, which is an alias."
79

80 81 82 83 84 85 86
# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
silentoldconfig: syncconfig
	@echo "  WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
	@echo "            and is now an internal implementation detail."
	@echo "            What you want is probably \"oldconfig\"."
	@echo "            \"silentoldconfig\" will be removed after Linux 4.19"

S
Sam Ravnborg 已提交
87
savedefconfig: $(obj)/conf
88
	$< $(silent) --$@=defconfig $(Kconfig)
S
Sam Ravnborg 已提交
89

L
Linus Torvalds 已提交
90 91
defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),)
92
	$< $(silent) --defconfig $(Kconfig)
93 94
else
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
95 96
	@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
97 98 99
else
	@$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
	$(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
L
Linus Torvalds 已提交
100
endif
101
endif
L
Linus Torvalds 已提交
102 103

%_defconfig: $(obj)/conf
104
	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
L
Linus Torvalds 已提交
105

106
configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
107

108 109 110 111
%.config: $(obj)/conf
	$(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
	+$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
112 113

PHONY += kvmconfig
114 115
kvmconfig: kvm_guest.config
	@:
116

117 118 119 120
PHONY += xenconfig
xenconfig: xen.config
	@:

121
PHONY += tinyconfig
122 123
tinyconfig:
	$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
124

125 126 127 128 129 130 131 132
# CHECK: -o cache_dir=<path> working?
PHONY += testconfig
testconfig: $(obj)/conf
	$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
	-o cache_dir=$(abspath $(obj)/tests/.cache) \
	$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
clean-dirs += tests/.cache

L
Linus Torvalds 已提交
133 134 135
# Help text used by make help
help:
	@echo  '  config	  - Update current config utilising a line-oriented program'
136
	@echo  '  nconfig         - Update current config utilising a ncurses menu based program'
L
Linus Torvalds 已提交
137
	@echo  '  menuconfig	  - Update current config utilising a menu based program'
138
	@echo  '  xconfig	  - Update current config utilising a Qt based front-end'
139
	@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
L
Linus Torvalds 已提交
140
	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
141
	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
142
	@echo  '  localyesconfig  - Update current config converting local mods to core'
S
Sam Ravnborg 已提交
143
	@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
S
Sam Ravnborg 已提交
144
	@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
145
	@echo  '  allnoconfig	  - New config where all options are answered with no'
S
Sam Ravnborg 已提交
146 147 148 149
	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
	@echo  '  allmodconfig	  - New config selecting modules when possible'
	@echo  '  alldefconfig    - New config with all symbols set to default'
	@echo  '  randconfig	  - New config with random answer to all options'
150
	@echo  '  listnewconfig   - List new options'
151 152
	@echo  '  olddefconfig	  - Same as oldconfig but sets new symbols to their'
	@echo  '                    default value without prompting'
153
	@echo  '  kvmconfig	  - Enable additional options for kvm guest kernel support'
154
	@echo  '  xenconfig       - Enable additional options for xen dom0 and guest kernel support'
155
	@echo  '  tinyconfig	  - Configure the tiniest possible kernel'
156
	@echo  '  testconfig	  - Run Kconfig unit tests (requires python3 and pytest)'
L
Linus Torvalds 已提交
157 158 159 160 161 162 163 164

# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf:	  Used for defconfig, oldconfig and related targets
# object files used by all kconfig flavours

conf-objs	:= conf.o  zconf.tab.o

165
hostprogs-y := conf
L
Linus Torvalds 已提交
166

167
targets		+= zconf.lex.c
168

L
Linus Torvalds 已提交
169
# generated files seem to need this to find local include files
A
Arnaud Lacombe 已提交
170
HOSTCFLAGS_zconf.lex.o	:= -I$(src)
L
Linus Torvalds 已提交
171 172
HOSTCFLAGS_zconf.tab.o	:= -I$(src)

173 174 175 176
# nconf: Used for the nconfig target based on ncurses
hostprogs-y	+= nconf
nconf-objs	:= nconf.o zconf.tab.o nconf.gui.o

177
HOSTLDLIBS_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
178 179 180
HOSTCFLAGS_nconf.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
HOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)

181
$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
182 183 184 185 186 187

# mconf: Used for the menuconfig target based on lxdialog
hostprogs-y	+= mconf
lxdialog	:= checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
mconf-objs	:= mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))

188
HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
189 190
$(foreach f, mconf.o $(lxdialog), \
  $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
191

192 193
$(obj)/mconf.o: $(obj)/.mconf-cfg
$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
194 195 196 197 198 199

# qconf: Used for the xconfig target based on Qt
hostprogs-y	+= qconf
qconf-cxxobjs	:= qconf.o
qconf-objs	:= zconf.tab.o

200
HOSTLDLIBS_qconf	= $(shell . $(obj)/.qconf-cfg && echo $$libs)
201 202 203 204 205 206 207 208 209
HOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/.qconf-cfg && echo $$cflags)

$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc

quiet_cmd_moc = MOC     $@
      cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@

$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
	$(call cmd,moc)
L
Linus Torvalds 已提交
210

211 212 213 214
# gconf: Used for the gconfig target based on GTK+
hostprogs-y	+= gconf
gconf-objs	:= gconf.o zconf.tab.o

215
HOSTLDLIBS_gconf    = $(shell . $(obj)/.gconf-cfg && echo $$libs)
216 217 218
HOSTCFLAGS_gconf.o  = $(shell . $(obj)/.gconf-cfg && echo $$cflags)

$(obj)/gconf.o: $(obj)/.gconf-cfg
L
Linus Torvalds 已提交
219

220
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
L
Linus Torvalds 已提交
221

222 223 224 225 226 227 228 229 230
# check if necessary packages are available, and configure build flags
define filechk_conf_cfg
	$(CONFIG_SHELL) $<
endef

$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
	$(call filechk,conf_cfg)

clean-files += .*conf-cfg