1*4882a593Smuzhiyun################################################################################ 2*4882a593Smuzhiyun# Kconfig package infrastructure 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# This file implements an infrastructure that eases development of 5*4882a593Smuzhiyun# package .mk files for packages that use kconfig for configuration files. 6*4882a593Smuzhiyun# It is based on the generic-package infrastructure, and inherits all of its 7*4882a593Smuzhiyun# features. 8*4882a593Smuzhiyun# 9*4882a593Smuzhiyun# See the Buildroot documentation for details on the usage of this 10*4882a593Smuzhiyun# infrastructure. 11*4882a593Smuzhiyun# 12*4882a593Smuzhiyun################################################################################ 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun# Macro to update back the custom (def)config file 15*4882a593Smuzhiyun# Must only be called if $(PKG)_KCONFIG_FILE is set and $(PKG)_KCONFIG_DEFCONFIG) 16*4882a593Smuzhiyun# is not set. 17*4882a593Smuzhiyun# $(1): file to copy from 18*4882a593Smuzhiyundefine kconfig-package-update-config 19*4882a593Smuzhiyun @$(if $($(PKG)_KCONFIG_FRAGMENT_FILES), \ 20*4882a593Smuzhiyun echo "Unable to perform $(@) when fragment files are set"; exit 1) 21*4882a593Smuzhiyun $(Q)if [ -d $($(PKG)_KCONFIG_FILE) ]; then \ 22*4882a593Smuzhiyun echo "Unable to perform $(@) when $($(PKG)_KCONFIG_FILE) is a directory"; \ 23*4882a593Smuzhiyun exit 1; \ 24*4882a593Smuzhiyun fi 25*4882a593Smuzhiyun $(Q)mkdir -p $(dir $($(PKG)_KCONFIG_FILE)) 26*4882a593Smuzhiyun cp -f $($(PKG)_DIR)/$(1) $($(PKG)_KCONFIG_FILE) 27*4882a593Smuzhiyun $(Q)touch --reference $($(PKG)_DIR)/$($(PKG)_KCONFIG_STAMP_DOTCONFIG) $($(PKG)_KCONFIG_FILE) 28*4882a593Smuzhiyunendef 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunPKG_KCONFIG_COMMON_OPTS = \ 31*4882a593Smuzhiyun HOSTCC="$(HOSTCC_NOCCACHE)" 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun# Macro to save the defconfig file 34*4882a593Smuzhiyun# $(1): the name of the package in upper-case letters 35*4882a593Smuzhiyundefine kconfig-package-savedefconfig 36*4882a593Smuzhiyun $($(1)_MAKE_ENV) $($(1)_MAKE) -C $($(1)_DIR) \ 37*4882a593Smuzhiyun $(PKG_KCONFIG_COMMON_OPTS) $($(1)_KCONFIG_OPTS) savedefconfig 38*4882a593Smuzhiyunendef 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun# The correct way to regenerate a .config file is to use 'make olddefconfig'. 41*4882a593Smuzhiyun# For historical reasons, the target name is 'oldnoconfig' between Linux kernel 42*4882a593Smuzhiyun# versions 2.6.36 and 3.6, and remains as an alias in later versions. 43*4882a593Smuzhiyun# In older versions, and in some other projects that use kconfig, the target is 44*4882a593Smuzhiyun# not supported at all, and we use 'yes "" | make oldconfig' as a fallback 45*4882a593Smuzhiyun# only, as this can fail in complex cases. 46*4882a593Smuzhiyun# $(1): the name of the package in upper-case letters 47*4882a593Smuzhiyundefine kconfig-package-regen-dot-config 48*4882a593Smuzhiyun $(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)), 49*4882a593Smuzhiyun $(Q)$($(1)_KCONFIG_MAKE) olddefconfig, 50*4882a593Smuzhiyun $(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)), 51*4882a593Smuzhiyun $(Q)$($(1)_KCONFIG_MAKE) oldnoconfig, 52*4882a593Smuzhiyun $(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig))) 53*4882a593Smuzhiyunendef 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun# Macro to create a .config file where all given fragments are merged into. 56*4882a593Smuzhiyun# $(1): the name of the package in upper-case letters 57*4882a593Smuzhiyun# $(2): name of the .config file 58*4882a593Smuzhiyun# $(3): fragment files to merge 59*4882a593Smuzhiyundefine kconfig-package-merge-config 60*4882a593Smuzhiyun $(Q)$(if $($(1)_KCONFIG_DEFCONFIG),\ 61*4882a593Smuzhiyun $($(1)_KCONFIG_MAKE) $($(1)_KCONFIG_DEFCONFIG),\ 62*4882a593Smuzhiyun $(INSTALL) -m 0644 -D $($(1)_KCONFIG_FILE) $(2)) 63*4882a593Smuzhiyun $(Q)support/kconfig/merge_config.sh -m -O $(dir $(2)) $(2) $(3) 64*4882a593Smuzhiyun $(call kconfig-package-regen-dot-config,$(1)) 65*4882a593Smuzhiyunendef 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun################################################################################ 68*4882a593Smuzhiyun# inner-kconfig-package -- generates the make targets needed to support a 69*4882a593Smuzhiyun# kconfig package 70*4882a593Smuzhiyun# 71*4882a593Smuzhiyun# argument 1 is the lowercase package name 72*4882a593Smuzhiyun# argument 2 is the uppercase package name, including a HOST_ prefix 73*4882a593Smuzhiyun# for host packages 74*4882a593Smuzhiyun# argument 3 is the uppercase package name, without the HOST_ prefix 75*4882a593Smuzhiyun# for host packages 76*4882a593Smuzhiyun# argument 4 is the type (target or host) 77*4882a593Smuzhiyun################################################################################ 78*4882a593Smuzhiyun 79*4882a593Smuzhiyundefine inner-kconfig-package 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun# Default values 82*4882a593Smuzhiyun$(2)_MAKE ?= $$(MAKE) 83*4882a593Smuzhiyun$(2)_KCONFIG_EDITORS ?= menuconfig 84*4882a593Smuzhiyun$(2)_KCONFIG_OPTS ?= 85*4882a593Smuzhiyun$(2)_KCONFIG_FIXUP_CMDS ?= 86*4882a593Smuzhiyun$(2)_KCONFIG_FRAGMENT_FILES ?= 87*4882a593Smuzhiyun$(2)_KCONFIG_DOTCONFIG ?= .config 88*4882a593Smuzhiyun$(2)_KCONFIG_SUPPORTS_DEFCONFIG ?= YES 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun# Register the kconfig dependencies as regular dependencies, so that 91*4882a593Smuzhiyun# they are also accounted for in the generated graphs. 92*4882a593Smuzhiyun$(2)_DEPENDENCIES += $$($(2)_KCONFIG_DEPENDENCIES) 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun# Generate the kconfig-related help: one entry for each editor. 95*4882a593Smuzhiyun# Additionally, if the package is *not* using an in-tree defconfig 96*4882a593Smuzhiyun# name, an entry for updating the package configuration file. 97*4882a593Smuzhiyunifndef $(2)_HELP_CMDS 98*4882a593Smuzhiyundefine $(2)_HELP_CMDS 99*4882a593Smuzhiyun $$(foreach editor, $$($(2)_KCONFIG_EDITORS), \ 100*4882a593Smuzhiyun @printf ' %-22s - Run %s %s\n' $(1)-$$(editor) $(1) $$(editor) 101*4882a593Smuzhiyun ) 102*4882a593Smuzhiyun $$(if $$($(2)_KCONFIG_DEFCONFIG),,\ 103*4882a593Smuzhiyun $$(if $$(filter YES,$$($(2)_KCONFIG_SUPPORTS_DEFCONFIG)),\ 104*4882a593Smuzhiyun @printf ' %-22s - Save the %s configuration as a defconfig file\n' \ 105*4882a593Smuzhiyun $(1)-update-defconfig $(1) 106*4882a593Smuzhiyun @printf ' %-22s to %s\n' '' $$($(2)_KCONFIG_FILE) 107*4882a593Smuzhiyun @printf ' %-22s (or override with %s_KCONFIG_FILE)\n' '' $(2) 108*4882a593Smuzhiyun ) 109*4882a593Smuzhiyun @printf ' %-22s - Save the %s configuration as a full .config file\n' \ 110*4882a593Smuzhiyun $(1)-update-config $(1) 111*4882a593Smuzhiyun @printf ' %-22s to %s\n' '' $$($(2)_KCONFIG_FILE) 112*4882a593Smuzhiyun @printf ' %-22s (or override with %s_KCONFIG_FILE)\n' '' $(2) 113*4882a593Smuzhiyun ) 114*4882a593Smuzhiyunendef 115*4882a593Smuzhiyunendif 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun# Call the generic package infrastructure to generate the necessary 118*4882a593Smuzhiyun# make targets. 119*4882a593Smuzhiyun# Note: this must be done _before_ attempting to use $$($(2)_DIR) in a 120*4882a593Smuzhiyun# dependency expression 121*4882a593Smuzhiyun$(call inner-generic-package,$(1),$(2),$(3),$(4)) 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun# Do not use $(2)_KCONFIG_DOTCONFIG as stamp file, because the package 124*4882a593Smuzhiyun# buildsystem (e.g. linux >= 4.19) may touch it, thus rendering our 125*4882a593Smuzhiyun# timestamps out of date, thus re-trigerring the build of the package. 126*4882a593Smuzhiyun# Instead, use a specific file of our own as timestamp. 127*4882a593Smuzhiyun$(2)_KCONFIG_STAMP_DOTCONFIG = .stamp_dotconfig 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun# The config file as well as the fragments could be in-tree, so before 130*4882a593Smuzhiyun# depending on them the package should be extracted (and patched) first. 131*4882a593Smuzhiyun# 132*4882a593Smuzhiyun# Since those files only have a order-only dependency, make would treat 133*4882a593Smuzhiyun# any missing one as a "force" target: 134*4882a593Smuzhiyun# https://www.gnu.org/software/make/manual/make.html#Force-Targets 135*4882a593Smuzhiyun# and would forcibly any rule that depend on those files, causing a 136*4882a593Smuzhiyun# rebuild of the kernel each time make is called. 137*4882a593Smuzhiyun# 138*4882a593Smuzhiyun# So, we provide a recipe that checks all of those files exist, to 139*4882a593Smuzhiyun# overcome that standard make behaviour. 140*4882a593Smuzhiyun# 141*4882a593Smuzhiyun$$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch 142*4882a593Smuzhiyun for f in $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES); do \ 143*4882a593Smuzhiyun if [ ! -f "$$$${f}" ]; then \ 144*4882a593Smuzhiyun printf "Kconfig file or fragment '%s' for '%s' does not exist\n" "$$$${f}" "$(1)"; \ 145*4882a593Smuzhiyun exit 1; \ 146*4882a593Smuzhiyun fi; \ 147*4882a593Smuzhiyun done 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun$(2)_KCONFIG_MAKE = \ 150*4882a593Smuzhiyun $$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \ 151*4882a593Smuzhiyun $$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS) 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun# $(2)_KCONFIG_MAKE may already rely on shell expansion. As the $() syntax 154*4882a593Smuzhiyun# of the shell conflicts with Make's own syntax, this means that backticks 155*4882a593Smuzhiyun# are used with those shell constructs. Unfortunately, the backtick syntax 156*4882a593Smuzhiyun# does not nest, and we need to use Make instead of the shell to handle 157*4882a593Smuzhiyun# conditions. 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun# A recursively expanded variable is necessary, to be sure that the shell 160*4882a593Smuzhiyun# command is called when the rule is processed during the build and not 161*4882a593Smuzhiyun# when the rule is created when parsing all packages. 162*4882a593Smuzhiyun$(2)_KCONFIG_RULES = \ 163*4882a593Smuzhiyun $$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \ 164*4882a593Smuzhiyun sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d') 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun# The specified source configuration file and any additional configuration file 167*4882a593Smuzhiyun# fragments are merged together to .config, after the package has been patched. 168*4882a593Smuzhiyun# Since the file could be a defconfig file it needs to be expanded to a 169*4882a593Smuzhiyun# full .config first. 170*4882a593Smuzhiyun$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES) 171*4882a593Smuzhiyun $$(call prepare-per-package-directory,$$($(2)_KCONFIG_DEPENDENCIES)) 172*4882a593Smuzhiyun $$(call kconfig-package-merge-config,$(2),$$(@D)/$$($(2)_KCONFIG_DOTCONFIG),\ 173*4882a593Smuzhiyun $$($(2)_KCONFIG_FRAGMENT_FILES)) 174*4882a593Smuzhiyun $$(Q)touch $$(@D)/$$($(2)_KCONFIG_STAMP_DOTCONFIG) 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun# If _KCONFIG_FILE or _KCONFIG_FRAGMENT_FILES exists, this dependency is 177*4882a593Smuzhiyun# already implied, but if we only have a _KCONFIG_DEFCONFIG we have to add 178*4882a593Smuzhiyun# it explicitly. It doesn't hurt to always have it though. 179*4882a593Smuzhiyun$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): | $(1)-patch 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun# Some packages may need additional tools to be present by the time their 182*4882a593Smuzhiyun# kconfig structure is parsed (e.g. the linux kernel may need to call to 183*4882a593Smuzhiyun# the compiler to test its features). 184*4882a593Smuzhiyun$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): | $$($(2)_KCONFIG_DEPENDENCIES) 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun# In order to get a usable, consistent configuration, some fixup may be needed. 187*4882a593Smuzhiyun# The exact rules are specified by the package .mk file. 188*4882a593Smuzhiyundefine $(2)_FIXUP_DOT_CONFIG 189*4882a593Smuzhiyun $$($(2)_KCONFIG_FIXUP_CMDS) 190*4882a593Smuzhiyun $$(call kconfig-package-regen-dot-config,$(2)) 191*4882a593Smuzhiyun $$(Q)touch $$($(2)_DIR)/.stamp_kconfig_fixup_done 192*4882a593Smuzhiyunendef 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun$$($(2)_DIR)/.stamp_kconfig_fixup_done: PKG=$(2) 195*4882a593Smuzhiyun$$($(2)_DIR)/.stamp_kconfig_fixup_done: $$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG) 196*4882a593Smuzhiyun $$($(2)_FIXUP_DOT_CONFIG) 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun# Before running configure, the configuration file should be present and fixed 199*4882a593Smuzhiyun$$($(2)_TARGET_CONFIGURE): $$($(2)_DIR)/.stamp_kconfig_fixup_done 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun# Force olddefconfig again on -reconfigure 202*4882a593Smuzhiyun$(1)-clean-for-reconfigure: $(1)-clean-kconfig-for-reconfigure 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun$(1)-clean-kconfig-for-reconfigure: 205*4882a593Smuzhiyun rm -f $$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG) 206*4882a593Smuzhiyun 207*4882a593Smuzhiyun# Only enable the foo-*config targets when the package is actually enabled. 208*4882a593Smuzhiyun# Note: the variable $(2)_KCONFIG_VAR is not related to the kconfig 209*4882a593Smuzhiyun# infrastructure, but defined by pkg-generic.mk. The generic infrastructure is 210*4882a593Smuzhiyun# already called above, so we can effectively use this variable. 211*4882a593Smuzhiyunifeq ($$($$($(2)_KCONFIG_VAR)),y) 212*4882a593Smuzhiyun 213*4882a593Smuzhiyunifeq ($$(BR_BUILDING),y) 214*4882a593Smuzhiyun# Either FOO_KCONFIG_FILE or FOO_KCONFIG_DEFCONFIG is required... 215*4882a593Smuzhiyunifeq ($$(or $$($(2)_KCONFIG_FILE),$$($(2)_KCONFIG_DEFCONFIG)),) 216*4882a593Smuzhiyun$$(error Internal error: no value specified for $(2)_KCONFIG_FILE or $(2)_KCONFIG_DEFCONFIG) 217*4882a593Smuzhiyunendif 218*4882a593Smuzhiyun# ... but not both: 219*4882a593Smuzhiyunifneq ($$(and $$($(2)_KCONFIG_FILE),$$($(2)_KCONFIG_DEFCONFIG)),) 220*4882a593Smuzhiyun$$(error Internal error: $(2)_KCONFIG_FILE and $(2)_KCONFIG_DEFCONFIG are mutually exclusive but both are defined) 221*4882a593Smuzhiyunendif 222*4882a593Smuzhiyunendif 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun# For the configurators, we do want to use the system-provided host 225*4882a593Smuzhiyun# tools, not the ones we build. This is particularly true for 226*4882a593Smuzhiyun# pkg-config; if we use our pkg-config (from host-pkgconf), then it 227*4882a593Smuzhiyun# would not look for the .pc from the host, but we do need them, 228*4882a593Smuzhiyun# especially to find ncurses, GTK+, Qt (resp. for menuconfig and 229*4882a593Smuzhiyun# nconfig, gconfig, xconfig). 230*4882a593Smuzhiyun# So we simply remove our PATH and PKG_CONFIG_* variables. 231*4882a593Smuzhiyun$(2)_CONFIGURATOR_MAKE_ENV = \ 232*4882a593Smuzhiyun $$(filter-out PATH=% PKG_CONFIG=% PKG_CONFIG_SYSROOT_DIR=% \ 233*4882a593Smuzhiyun PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=% PKG_CONFIG_ALLOW_SYSTEM_LIBS=% \ 234*4882a593Smuzhiyun PKG_CONFIG_LIBDIR=%,$$($(2)_MAKE_ENV)) \ 235*4882a593Smuzhiyun PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" 236*4882a593Smuzhiyun 237*4882a593Smuzhiyun# Configuration editors (menuconfig, ...) 238*4882a593Smuzhiyun# 239*4882a593Smuzhiyun# We need to apply the configuration fixups right after a configuration 240*4882a593Smuzhiyun# editor exits, so that it is possible to save the configuration right 241*4882a593Smuzhiyun# after exiting an editor, and so the user always sees a .config file 242*4882a593Smuzhiyun# that is clean wrt. our requirements. 243*4882a593Smuzhiyun# 244*4882a593Smuzhiyun# Because commands in $(1)_FIXUP_KCONFIG are probably using $(@D), we 245*4882a593Smuzhiyun# need to have a valid @D set. But, because the configurators rules are 246*4882a593Smuzhiyun# not real files and do not contain the path to the package build dir, 247*4882a593Smuzhiyun# @D would be just '.' in this case. So, we use an intermediate rule 248*4882a593Smuzhiyun# with a stamp-like file which path is in the package build dir, so we 249*4882a593Smuzhiyun# end up having a valid @D. 250*4882a593Smuzhiyun# 251*4882a593Smuzhiyun$$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $(1)-%: $$($(2)_DIR)/.kconfig_editor_% 252*4882a593Smuzhiyun$$($(2)_DIR)/.kconfig_editor_%: PKG=$(2) 253*4882a593Smuzhiyun$$($(2)_DIR)/.kconfig_editor_%: $$($(2)_DIR)/.stamp_kconfig_fixup_done 254*4882a593Smuzhiyun $$($(2)_CONFIGURATOR_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \ 255*4882a593Smuzhiyun $$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS) $$(*) 256*4882a593Smuzhiyun rm -f $$($(2)_DIR)/.stamp_{kconfig_fixup_done,configured,built} 257*4882a593Smuzhiyun rm -f $$($(2)_DIR)/.stamp_{target,staging,images}_installed 258*4882a593Smuzhiyun $$($(2)_FIXUP_DOT_CONFIG) 259*4882a593Smuzhiyun 260*4882a593Smuzhiyun# Saving back the configuration 261*4882a593Smuzhiyun# 262*4882a593Smuzhiyun# Ideally, that should directly depend on $$($(2)_DIR)/.stamp_kconfig_fixup_done, 263*4882a593Smuzhiyun# but that breaks the use-case in PR-8156 (from a clean tree): 264*4882a593Smuzhiyun# make menuconfig <- enable kernel, use an in-tree defconfig, save and exit 265*4882a593Smuzhiyun# make linux-menuconfig <- enable/disable whatever option, save and exit 266*4882a593Smuzhiyun# make menuconfig <- change to use a custom defconfig file, set a path, save and exit 267*4882a593Smuzhiyun# make linux-update-config <- should save to the new custom defconfig file 268*4882a593Smuzhiyun# 269*4882a593Smuzhiyun# Because of that use-case, saving the configuration can *not* directly 270*4882a593Smuzhiyun# depend on the stamp file, because it itself depends on the .config, 271*4882a593Smuzhiyun# which in turn depends on the (newly-set an non-existent) custom 272*4882a593Smuzhiyun# defconfig file. 273*4882a593Smuzhiyun# 274*4882a593Smuzhiyun# Instead, we use a PHONY rule that will catch that situation. 275*4882a593Smuzhiyun# 276*4882a593Smuzhiyun$(1)-check-configuration-done: 277*4882a593Smuzhiyun @if [ ! -f $$($(2)_DIR)/.stamp_kconfig_fixup_done ]; then \ 278*4882a593Smuzhiyun echo "$(1) is not yet configured"; \ 279*4882a593Smuzhiyun exit 1; \ 280*4882a593Smuzhiyun fi 281*4882a593Smuzhiyun 282*4882a593Smuzhiyunifeq ($$($(2)_KCONFIG_SUPPORTS_DEFCONFIG),YES) 283*4882a593Smuzhiyun.PHONY: $(1)-savedefconfig 284*4882a593Smuzhiyun$(1)-savedefconfig: $(1)-check-configuration-done 285*4882a593Smuzhiyun $$(call kconfig-package-savedefconfig,$(2)) 286*4882a593Smuzhiyunendif 287*4882a593Smuzhiyun 288*4882a593Smuzhiyunifeq ($$($(2)_KCONFIG_DEFCONFIG),) 289*4882a593Smuzhiyun# Target to copy back the configuration to the source configuration file 290*4882a593Smuzhiyun# Even though we could use 'cp --preserve-timestamps' here, the separate 291*4882a593Smuzhiyun# cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig. 292*4882a593Smuzhiyun.PHONY: $(1)-update-config 293*4882a593Smuzhiyun$(1)-update-config: PKG=$(2) 294*4882a593Smuzhiyun$(1)-update-config: $(1)-check-configuration-done 295*4882a593Smuzhiyun $$(call kconfig-package-update-config,$$($(2)_KCONFIG_DOTCONFIG)) 296*4882a593Smuzhiyun 297*4882a593Smuzhiyunifeq ($$($(2)_KCONFIG_SUPPORTS_DEFCONFIG),YES) 298*4882a593Smuzhiyun# Note: make sure the timestamp of the stored configuration is not newer than 299*4882a593Smuzhiyun# the .config to avoid a useless rebuild. Note that, contrary to 300*4882a593Smuzhiyun# $(1)-update-config, the reference for 'touch' is _not_ the file from which 301*4882a593Smuzhiyun# we copy. 302*4882a593Smuzhiyun.PHONY: $(1)-update-defconfig 303*4882a593Smuzhiyun$(1)-update-defconfig: PKG=$(2) 304*4882a593Smuzhiyun$(1)-update-defconfig: $(1)-savedefconfig 305*4882a593Smuzhiyun $$(call kconfig-package-update-config,defconfig) 306*4882a593Smuzhiyunendif 307*4882a593Smuzhiyun 308*4882a593Smuzhiyunendif 309*4882a593Smuzhiyun 310*4882a593Smuzhiyun# Target to output differences between the configuration obtained via the 311*4882a593Smuzhiyun# defconfig + fragments (if any) and the current configuration. 312*4882a593Smuzhiyun# Note: it preserves the timestamp of the current configuration when moving it 313*4882a593Smuzhiyun# around. 314*4882a593Smuzhiyun$(1)-diff-config: $(1)-check-configuration-done 315*4882a593Smuzhiyun $$(Q)cp -a $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG) $$($(2)_DIR)/.config.dc.bak 316*4882a593Smuzhiyun $$(call kconfig-package-merge-config,$(2),$$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG),\ 317*4882a593Smuzhiyun $$($(2)_KCONFIG_FRAGMENT_FILES)) 318*4882a593Smuzhiyun $$(Q)utils/diffconfig $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG) \ 319*4882a593Smuzhiyun $$($(2)_DIR)/.config.dc.bak 320*4882a593Smuzhiyun $$(Q)cp -a $$($(2)_DIR)/.config.dc.bak $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG) 321*4882a593Smuzhiyun $$(Q)rm -f $$($(2)_DIR)/.config.dc.bak 322*4882a593Smuzhiyun 323*4882a593Smuzhiyun 324*4882a593Smuzhiyunendif # package enabled 325*4882a593Smuzhiyun 326*4882a593Smuzhiyun.PHONY: \ 327*4882a593Smuzhiyun $(1)-diff-config \ 328*4882a593Smuzhiyun $(1)-check-configuration-done \ 329*4882a593Smuzhiyun $$($(2)_DIR)/.kconfig_editor_% \ 330*4882a593Smuzhiyun $$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)) 331*4882a593Smuzhiyun 332*4882a593Smuzhiyunendef # inner-kconfig-package 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun################################################################################ 335*4882a593Smuzhiyun# kconfig-package -- the target generator macro for kconfig packages 336*4882a593Smuzhiyun################################################################################ 337*4882a593Smuzhiyun 338*4882a593Smuzhiyunkconfig-package = $(call inner-kconfig-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) 339