Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # ===========================================================================
0003 # Kernel configuration targets
0004 # These targets are used from top-level makefile
0005 
0006 ifdef KBUILD_KCONFIG
0007 Kconfig := $(KBUILD_KCONFIG)
0008 else
0009 Kconfig := Kconfig
0010 endif
0011 
0012 ifndef KBUILD_DEFCONFIG
0013 KBUILD_DEFCONFIG := defconfig
0014 endif
0015 
0016 ifeq ($(quiet),silent_)
0017 silent := -s
0018 endif
0019 
0020 export KCONFIG_DEFCONFIG_LIST :=
0021 ifndef cross_compiling
0022 kernel-release := $(shell uname -r)
0023 KCONFIG_DEFCONFIG_LIST += \
0024         /lib/modules/$(kernel-release)/.config \
0025         /etc/kernel-config \
0026         /boot/config-$(kernel-release)
0027 endif
0028 KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
0029 
0030 # We need this, in case the user has it in its environment
0031 unexport CONFIG_
0032 
0033 config-prog     := conf
0034 menuconfig-prog := mconf
0035 nconfig-prog    := nconf
0036 gconfig-prog    := gconf
0037 xconfig-prog    := qconf
0038 
0039 define config_rule
0040 PHONY += $(1)
0041 $(1): $(obj)/$($(1)-prog)
0042         $(Q)$$< $(silent) $(Kconfig)
0043 
0044 PHONY += build_$(1)
0045 build_$(1): $(obj)/$($(1)-prog)
0046 endef
0047 
0048 $(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
0049 
0050 PHONY += localmodconfig localyesconfig
0051 localyesconfig localmodconfig: $(obj)/conf
0052         $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
0053         $(Q)if [ -f .config ]; then                             \
0054                 cmp -s .tmp.config .config ||                   \
0055                 (mv -f .config .config.old.1;                   \
0056                  mv -f .tmp.config .config;                     \
0057                  $< $(silent) --oldconfig $(Kconfig);           \
0058                  mv -f .config.old.1 .config.old)               \
0059         else                                                    \
0060                 mv -f .tmp.config .config;                      \
0061                 $< $(silent) --oldconfig $(Kconfig);            \
0062         fi
0063         $(Q)rm -f .tmp.config
0064 
0065 # These targets map 1:1 to the commandline options of 'conf'
0066 #
0067 # Note:
0068 #  syncconfig has become an internal implementation detail and is now
0069 #  deprecated for external use
0070 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
0071         alldefconfig randconfig listnewconfig olddefconfig syncconfig \
0072         helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
0073 
0074 PHONY += $(simple-targets)
0075 
0076 $(simple-targets): $(obj)/conf
0077         $(Q)$< $(silent) --$@ $(Kconfig)
0078 
0079 PHONY += savedefconfig defconfig
0080 
0081 savedefconfig: $(obj)/conf
0082         $(Q)$< $(silent) --$@=defconfig $(Kconfig)
0083 
0084 defconfig: $(obj)/conf
0085 ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
0086         @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
0087         $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
0088 else
0089         @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
0090         $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
0091 endif
0092 
0093 %_defconfig: $(obj)/conf
0094         $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
0095 
0096 configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
0097 
0098 %.config: $(obj)/conf
0099         $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
0100         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
0101         $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
0102 
0103 PHONY += tinyconfig
0104 tinyconfig:
0105         $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
0106         $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
0107 
0108 # CHECK: -o cache_dir=<path> working?
0109 PHONY += testconfig
0110 testconfig: $(obj)/conf
0111         $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
0112         -o cache_dir=$(abspath $(obj)/tests/.cache) \
0113         $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
0114 clean-files += tests/.cache
0115 
0116 # Help text used by make help
0117 help:
0118         @echo  '  config          - Update current config utilising a line-oriented program'
0119         @echo  '  nconfig         - Update current config utilising a ncurses menu based program'
0120         @echo  '  menuconfig      - Update current config utilising a menu based program'
0121         @echo  '  xconfig         - Update current config utilising a Qt based front-end'
0122         @echo  '  gconfig         - Update current config utilising a GTK+ based front-end'
0123         @echo  '  oldconfig       - Update current config utilising a provided .config as base'
0124         @echo  '  localmodconfig  - Update current config disabling modules not loaded'
0125         @echo  '                    except those preserved by LMC_KEEP environment variable'
0126         @echo  '  localyesconfig  - Update current config converting local mods to core'
0127         @echo  '                    except those preserved by LMC_KEEP environment variable'
0128         @echo  '  defconfig       - New config with default from ARCH supplied defconfig'
0129         @echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
0130         @echo  '  allnoconfig     - New config where all options are answered with no'
0131         @echo  '  allyesconfig    - New config where all options are accepted with yes'
0132         @echo  '  allmodconfig    - New config selecting modules when possible'
0133         @echo  '  alldefconfig    - New config with all symbols set to default'
0134         @echo  '  randconfig      - New config with random answer to all options'
0135         @echo  '  yes2modconfig   - Change answers from yes to mod if possible'
0136         @echo  '  mod2yesconfig   - Change answers from mod to yes if possible'
0137         @echo  '  mod2noconfig    - Change answers from mod to no if possible'
0138         @echo  '  listnewconfig   - List new options'
0139         @echo  '  helpnewconfig   - List new options and help text'
0140         @echo  '  olddefconfig    - Same as oldconfig but sets new symbols to their'
0141         @echo  '                    default value without prompting'
0142         @echo  '  tinyconfig      - Configure the tiniest possible kernel'
0143         @echo  '  testconfig      - Run Kconfig unit tests (requires python3 and pytest)'
0144 
0145 # ===========================================================================
0146 # object files used by all kconfig flavours
0147 common-objs     := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
0148                    preprocess.o symbol.o util.o
0149 
0150 $(obj)/lexer.lex.o: $(obj)/parser.tab.h
0151 HOSTCFLAGS_lexer.lex.o  := -I $(srctree)/$(src)
0152 HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
0153 
0154 # conf: Used for defconfig, oldconfig and related targets
0155 hostprogs       += conf
0156 conf-objs       := conf.o $(common-objs)
0157 
0158 # nconf: Used for the nconfig target based on ncurses
0159 hostprogs       += nconf
0160 nconf-objs      := nconf.o nconf.gui.o $(common-objs)
0161 
0162 HOSTLDLIBS_nconf        = $(shell . $(obj)/nconf-cfg && echo $$libs)
0163 HOSTCFLAGS_nconf.o      = $(shell . $(obj)/nconf-cfg && echo $$cflags)
0164 HOSTCFLAGS_nconf.gui.o  = $(shell . $(obj)/nconf-cfg && echo $$cflags)
0165 
0166 $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
0167 
0168 # mconf: Used for the menuconfig target based on lxdialog
0169 hostprogs       += mconf
0170 lxdialog        := $(addprefix lxdialog/, \
0171                      checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
0172 mconf-objs      := mconf.o $(lxdialog) $(common-objs)
0173 
0174 HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
0175 $(foreach f, mconf.o $(lxdialog), \
0176   $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
0177 
0178 $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
0179 
0180 # qconf: Used for the xconfig target based on Qt
0181 hostprogs       += qconf
0182 qconf-cxxobjs   := qconf.o qconf-moc.o
0183 qconf-objs      := images.o $(common-objs)
0184 
0185 HOSTLDLIBS_qconf        = $(shell . $(obj)/qconf-cfg && echo $$libs)
0186 HOSTCXXFLAGS_qconf.o    = $(shell . $(obj)/qconf-cfg && echo $$cflags)
0187 HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
0188 
0189 $(obj)/qconf.o: $(obj)/qconf-cfg
0190 
0191 quiet_cmd_moc = MOC     $@
0192       cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
0193 
0194 $(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
0195         $(call if_changed,moc)
0196 
0197 targets += qconf-moc.cc
0198 
0199 # gconf: Used for the gconfig target based on GTK+
0200 hostprogs       += gconf
0201 gconf-objs      := gconf.o images.o $(common-objs)
0202 
0203 HOSTLDLIBS_gconf    = $(shell . $(obj)/gconf-cfg && echo $$libs)
0204 HOSTCFLAGS_gconf.o  = $(shell . $(obj)/gconf-cfg && echo $$cflags)
0205 
0206 $(obj)/gconf.o: $(obj)/gconf-cfg
0207 
0208 # check if necessary packages are available, and configure build flags
0209 filechk_conf_cfg = $(CONFIG_SHELL) $<
0210 
0211 $(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
0212         $(call filechk,conf_cfg)
0213 
0214 clean-files += *conf-cfg