Browse Source

- add kconfig infrastructure

master
vanhofen 3 years ago
parent
commit
85d07b0db6
  1. 1
      package/Makefile.in
  2. 42
      package/pkg-kconfig.mk
  3. 38
      package/pkg-utils.mk

1
package/Makefile.in

@ -29,6 +29,7 @@ include package/pkg-autotools.mk
include package/pkg-cmake.mk
include package/pkg-generic.mk
include package/pkg-individual.mk
include package/pkg-kconfig.mk
include package/pkg-kernel-module.mk
include package/pkg-meson.mk
include package/pkg-python.mk

42
package/pkg-kconfig.mk

@ -0,0 +1,42 @@
################################################################################
#
# Kconfig packages
#
################################################################################
#
# Manipulation of .config files based on the Kconfig infrastructure.
# Used by the BusyBox package, the Linux kernel package, and more.
#
# KCONFIG_DOT_CONFIG ([file])
# Returns the path to the .config file that should be used, which will
# be $(1) if provided, or the current package .config file otherwise.
KCONFIG_DOT_CONFIG = $(strip \
$(if $(strip $(1)), $(1), \
$(PKG_BUILD_DIR)/$($(PKG)_KCONFIG_DOTCONFIG) \
) \
)
# KCONFIG_MUNGE_DOT_CONFIG (option, newline [, file])
define KCONFIG_MUNGE_DOT_CONFIG
$(SED) "/\\<$(strip $(1))\\>/d" $(call KCONFIG_DOT_CONFIG,$(3))
echo '$(strip $(2))' >> $(call KCONFIG_DOT_CONFIG,$(3))
endef
# KCONFIG_ENABLE_OPT (option [, file])
KCONFIG_ENABLE_OPT = $(call KCONFIG_MUNGE_DOT_CONFIG, $(1), $(1)=y, $(2))
# KCONFIG_SET_OPT (option, value [, file])
KCONFIG_SET_OPT = $(call KCONFIG_MUNGE_DOT_CONFIG, $(1), $(1)=$(2), $(3))
# KCONFIG_DISABLE_OPT (option [, file])
KCONFIG_DISABLE_OPT = $(call KCONFIG_MUNGE_DOT_CONFIG, $(1), $(SHARP_SIGN) $(1) is not set, $(2))
# -----------------------------------------------------------------------------
define kconfig-package
$(eval PKG_MODE = $(pkg-mode))
$(call PREPARE,$(1))
$(if $(filter $(1),$(PKG_NO_BUILD)),,$(call TARGET_MAKE_BUILD))
$(if $(filter $(1),$(PKG_NO_INSTALL)),,$(call TARGET_MAKE_INSTALL))
$(call TARGET_FOLLOWUP)
endef

38
package/pkg-utils.mk

@ -99,7 +99,7 @@ endif
# build commands
# TODO: python, kernel
ifndef $(PKG)_BUILD_CMDS
ifeq ($(PKG_MODE),$(filter $(PKG_MODE),AUTOTOOLS CMAKE GENERIC))
ifeq ($(PKG_MODE),$(filter $(PKG_MODE),AUTOTOOLS CMAKE GENERIC KCONFIG))
ifeq ($(PKG_HOST_PACKAGE),YES)
$(PKG)_BUILD_CMDS = $$(HOST_MAKE_BUILD_CMDS)
else
@ -111,6 +111,8 @@ ifndef $(PKG)_BUILD_CMDS
else
$(PKG)_BUILD_CMDS = $$(TARGET_NINJA_BUILD_CMDS)
endif
else
$(PKG)_BUILD_CMDS = echo "$(PKG_NO_BUILD)"
endif
endif
@ -131,7 +133,7 @@ endif
# install commands
# TODO: python, kernel
ifndef $(PKG)_INSTALL_CMDS
ifeq ($(PKG_MODE),$(filter $(PKG_MODE),AUTOTOOLS CMAKE GENERIC))
ifeq ($(PKG_MODE),$(filter $(PKG_MODE),AUTOTOOLS CMAKE GENERIC KCONFIG))
ifeq ($(PKG_HOST_PACKAGE),YES)
$(PKG)_INSTALL_CMDS = $$(HOST_MAKE_INSTALL_CMDS)
else
@ -143,6 +145,8 @@ ifndef $(PKG)_INSTALL_CMDS
else
$(PKG)_INSTALL_CMDS = $$(TARGET_NINJA_INSTALL_CMDS)
endif
else
$(PKG)_INSTALL_CMDS = echo "$(PKG_NO_INSTALL)"
endif
endif
@ -154,6 +158,14 @@ ifndef $(PKG)_NINJA_OPTS
$(PKG)_NINJA_OPTS =
endif
#kconfig
ifeq ($(PKG_MODE),KCONFIG)
ifndef $(PKG)_KCONFIG_FILE
$(PKG)_KCONFIG_FILE = .config
endif
$(PKG)_KCONFIG_DOTCONFIG = $$($(PKG)_KCONFIG_FILE)
endif
endef # PKG_CHECK_VARIABLES
pkg-check-variables = $(call PKG_CHECK_VARIABLES)
@ -409,25 +421,3 @@ define TARGET_FOLLOWUP
$(foreach hook,$($(PKG)_POST_FOLLOWUP_HOOKS),$(call $(hook))$(sep))
$(call TOUCH)
endef
# -----------------------------------------------------------------------------
#
# Manipulation of .config files based on the Kconfig infrastructure.
# Used by the BusyBox package, the Linux kernel package, and more.
#
define KCONFIG_ENABLE_OPT # (option, file)
$(SED) "/\\<$(1)\\>/d" $(2)
echo '$(1)=y' >> $(2)
endef
define KCONFIG_SET_OPT # (option, value, file)
$(SED) "/\\<$(1)\\>/d" $(3)
echo '$(1)=$(2)' >> $(3)
endef
define KCONFIG_DISABLE_OPT # (option, file)
$(SED) "/\\<$(1)\\>/d" $(2)
echo '# $(1) is not set' >> $(2)
endef

Loading…
Cancel
Save