From 41162c08f275e2a8cf429aa66081255d2dbd459e Mon Sep 17 00:00:00 2001 From: Abdoulaye Walsimou Gaye Date: Sat, 8 Mar 2014 22:36:38 +0100 Subject: Build system: internal macros: rework __embtk_pkg_installed-y for correctness and performance improvement Signed-off-by: Abdoulaye Walsimou Gaye --- mk/bmake.mk | 3 ++- mk/eglibc.mk | 6 +++--- mk/glibc.mk | 4 ++-- mk/linux.mk | 7 ++++--- mk/macros.mk | 6 +++--- mk/musl.mk | 5 +++-- mk/pkg-macros/incl.mk | 12 ++++++++---- mk/pkg-macros/install.mk | 43 ++++++++++++------------------------------- mk/pkg-macros/vars.mk | 4 ++++ mk/toolchain.mk | 18 +++++++----------- mk/uclibc.mk | 6 +++--- 11 files changed, 51 insertions(+), 63 deletions(-) (limited to 'mk') diff --git a/mk/bmake.mk b/mk/bmake.mk index 6a370ea..4dccf83 100644 --- a/mk/bmake.mk +++ b/mk/bmake.mk @@ -39,10 +39,11 @@ define __embtk_install_bmake --prefix=$(embtk_htools)/usr --install $(call __embtk_setinstalled_pkg,bmake) $(call __embtk_pkg_gen_dotkconfig_f,bmake) + $(eval __embtk_bmake_installed := y) endef define embtk_install_bmake - $(if $(call __embtk_pkg_installed-y,bmake),,$(__embtk_install_bmake)) + $(if $(call __embtk_pkg_runrecipe-y,bmake),$(__embtk_install_bmake)) endef define embtk_cleanup_bmake diff --git a/mk/eglibc.mk b/mk/eglibc.mk index 836c4a8..d23a057 100644 --- a/mk/eglibc.mk +++ b/mk/eglibc.mk @@ -1,6 +1,6 @@ ################################################################################ # Embtoolkit -# Copyright(C) 2009-2013 Abdoulaye Walsimou GAYE. +# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -98,11 +98,11 @@ define __embtk_install_eglibc install_root=$(embtk_sysroot) install $(call __embtk_setinstalled_pkg,eglibc) $(call __embtk_pkg_gen_dotkconfig_f,eglibc) + $(eval __embtk_eglibc_installed := y) endef define embtk_install_eglibc - $(if $(call __embtk_pkg_installed-y,eglibc),true, \ - $(__embtk_install_eglibc)) + $(if $(call __embtk_pkg_runrecipe-y,eglibc),$(__embtk_install_eglibc)) endef # diff --git a/mk/glibc.mk b/mk/glibc.mk index 0add5cb..ad72875 100644 --- a/mk/glibc.mk +++ b/mk/glibc.mk @@ -91,11 +91,11 @@ define __embtk_install_glibc install_root=$(embtk_sysroot) install $(call __embtk_setinstalled_pkg,glibc) $(call __embtk_pkg_gen_dotkconfig_f,glibc) + $(eval __embtk_glibc_installed := y) endef define embtk_install_glibc - $(if $(call __embtk_pkg_installed-y,glibc),true, \ - $(__embtk_install_glibc)) + $(if $(call __embtk_pkg_runrecipe-y,glibc),$(__embtk_install_glibc)) endef # diff --git a/mk/linux.mk b/mk/linux.mk index 704c65c..b9a08ff 100644 --- a/mk/linux.mk +++ b/mk/linux.mk @@ -62,10 +62,10 @@ define __embtk_install_linux_headers INSTALL_HDR_PATH=$(embtk_sysroot)/usr headers_install $(call __embtk_setinstalled_pkg,linux_headers) $(call __embtk_pkg_gen_dotkconfig_f,linux_headers) + $(eval __embtk_linux_headers_installed := y) endef define embtk_install_linux_headers - $(if $(call __embtk_pkg_installed-y,linux_headers),, - $(__embtk_install_linux_headers)) + $(if $(call __embtk_pkg_runrecipe-y,linux_headers),$(__embtk_install_linux_headers)) endef # @@ -112,10 +112,11 @@ define __embtk_install_linux $(MAKE) -C $(__embtk_linux_srcdir) $(LINUX_MAKE_OPTS) $(J) $(call __embtk_setinstalled_pkg,linux) $(call __embtk_pkg_gen_dotkconfig_f,linux) + $(eval __embtk_linux_installed := y) endef define embtk_install_linux - $(if $(call __embtk_pkg_installed-y,linux),true,$(__embtk_install_linux)) + $(if $(call __embtk_pkg_runrecipe-y,linux),$(__embtk_install_linux)) $(if $(__embtk_linux_support_modules),$(embtk_postinstall_linux)) endef diff --git a/mk/macros.mk b/mk/macros.mk index 571346b..a6c8e5f 100644 --- a/mk/macros.mk +++ b/mk/macros.mk @@ -1,6 +1,6 @@ ################################################################################ # Embtoolkit -# Copyright(C) 2009-2012 Abdoulaye Walsimou GAYE. +# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ __embtk_msg_h = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Usage: # $(call __embtk_streq,str1,str2) # -__embtk_streq = $(if $(subst x$(1),,x$(2)),,y) +__embtk_streq = $(if $(subst $(1),,$(2)),,y) # # __embtk_strneq: @@ -59,7 +59,7 @@ __embtk_streq = $(if $(subst x$(1),,x$(2)),,y) # Usage: # $(call __embtk_strneq,str1,str2) # -__embtk_strneq = $(if $(subst x$(1),,x$(2)),y) +__embtk_strneq = $(subst $(1),,$(2)) # # __embtk_mk_pathexist diff --git a/mk/musl.mk b/mk/musl.mk index 0ea6b7d..bde8aba 100644 --- a/mk/musl.mk +++ b/mk/musl.mk @@ -1,6 +1,6 @@ ################################################################################ # Embtoolkit -# Copyright(C) 2012-2013 Abdoulaye Walsimou GAYE. +# Copyright(C) 2012-2014 Abdoulaye Walsimou GAYE. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -61,10 +61,11 @@ define __embtk_install_musl ln -sf $(embtk_musl_dlinker).so.1 ld-musl.so.1 $(call __embtk_setinstalled_pkg,musl) $(call __embtk_pkg_gen_dotkconfig_f,musl) + $(eval __embtk_musl_installed := y) endef define embtk_install_musl - $(if $(call __embtk_pkg_installed-y,musl),true,$(__embtk_install_musl)) + $(if $(call __embtk_pkg_runrecipe-y,musl),$(__embtk_install_musl)) endef define embtk_cleanup_musl diff --git a/mk/pkg-macros/incl.mk b/mk/pkg-macros/incl.mk index 7641c15..bcd8402 100644 --- a/mk/pkg-macros/incl.mk +++ b/mk/pkg-macros/incl.mk @@ -32,10 +32,10 @@ define embtk_include_pkg $(eval $(call __embtk_include_pkg,$(1),$(2))) endef define __embtk_include_pkg - $(eval __embtk_inckconfig := $(or $(2),$(PKGV))) + $(eval __embtk_inc_pkgname := $(or $(2),$(PKGV))) $(eval __embtk_incmk := $(embtk_pkgincdir)/$(pkgv)/$(pkgv).mk) $(eval __embtk_incinstalled-y := $(if $(wildcard $(__embtk_pkg_dotinstalled_f)),y)) - $(eval __embtk_incenabled-y := $(CONFIG_EMBTK_HAVE_$(__embtk_inckconfig))) + $(eval __embtk_incenabled-y := $(CONFIG_EMBTK_HAVE_$(__embtk_inc_pkgname))) $(eval __embtk_incmk-y := $(if $(__embtk_incenabled-y)$(__embtk_incinstalled-y),y)) # Is it necessary to include the .mk file? $(eval __embtk_incmk-y := $(if $(findstring $(__embtk_incmk),$(MAKEFILE_LIST)),,$(__embtk_incmk-y))) @@ -47,19 +47,21 @@ define __embtk_include_pkg else ifeq (x$(__embtk_incinstalled-y),xy) ROOTFS_COMPONENTS- += $(pkgv)_install endif + # also include old package kconfig entries if any + -include $(__embtk_pkg_dotkconfig_f) endef define embtk_include_hostpkg $(eval $(call __embtk_include_hostpkg,$(1),$(2))) endef define __embtk_include_hostpkg - $(eval __embtk_inckconfig := $(or $(2),$(PKGV))) + $(eval __embtk_inc_pkgname := $(or $(2),$(PKGV))) # Case where foo and foo_host are in the same .mk file $(eval __embtk_incmk0 := $(embtk_pkgincdir)/$(pkgv)/$(pkgv).mk) $(eval __embtk_incmk1 := $(embtk_pkgincdir)/$(patsubst %_host,%,$(pkgv))/$(patsubst %_host,%,$(pkgv)).mk) $(eval __embtk_incmk := $(or $(wildcard $(__embtk_incmk0)),$(wildcard $(__embtk_incmk1)),$(wildcard $(__embtk_incmk0)))) $(eval __embtk_incinstalled-y := $(if $(wildcard $(__embtk_pkg_dotinstalled_f)),y)) - $(eval __embtk_incenabled-y := $(CONFIG_EMBTK_HOST_HAVE_$(patsubst %_HOST,%,$(__embtk_inckconfig)))) + $(eval __embtk_incenabled-y := $(CONFIG_EMBTK_HOST_HAVE_$(patsubst %_HOST,%,$(__embtk_inc_pkgname)))) $(eval __embtk_incmk-y := $(if $(__embtk_incenabled-y)$(__embtk_incinstalled-y),y)) # Is it necessary to include the .mk file? $(eval __embtk_incmk-y := $(if $(findstring $(__embtk_incmk),$(MAKEFILE_LIST)),,$(__embtk_incmk-y))) @@ -71,4 +73,6 @@ define __embtk_include_hostpkg else ifeq (x$(__embtk_incinstalled-y),xy) HOSTTOOLS_COMPONENTS- += $(pkgv)_install endif + # also include old package kconfig entries if any + -include $(__embtk_pkg_dotkconfig_f) endef diff --git a/mk/pkg-macros/install.mk b/mk/pkg-macros/install.mk index 8938f69..07d1f32 100644 --- a/mk/pkg-macros/install.mk +++ b/mk/pkg-macros/install.mk @@ -104,41 +104,20 @@ __embtk_pkg_notpatched-y = $(call __embtk_mk_pathnotexist,$(__embtk_pkg_dotpatch __embtk_pkg_configured-y = $(call __embtk_mk_pathexist,$(__embtk_pkg_dotconfigured_f)) __embtk_pkg_notconfigured-y = $(call __embtk_mk_pathnotexist,$(__embtk_pkg_dotconfigured_f)) -# -# A macro to print kconfig entries of a package -# -__embtk_pkg_printkconfigs = \ - grep 'CONFIG_K*EMBTK_.*$(__embtk_pkg_kconfigsname)_.*' \ - $(EMBTK_DOTCONFIG) - # # A macro to generate a package __embtk_pkg_dotkconfig_f file. # define __embtk_pkg_gen_dotkconfig_f - $(call __embtk_pkg_printkconfigs,$(1)) \ - > $(__embtk_pkg_dotkconfig_f) 2>/dev/null \ - $(if $(__embtk_pkg_deps), \ - $(foreach dep,$(call __embtk_pkg_depspkgv,$(1)),; \ - $(call __embtk_pkg_printkconfigs,$(dep)) \ - >> $(__embtk_pkg_dotkconfig_f))) + echo '__embtk_$(pkgv)_okconfigs := $(__embtk_pkg_kconfigs_all_v)' > $(__embtk_pkg_dotkconfig_f) endef # -# A macro to test if a package is already installed. -# It returns y if installed and nothing if not. +# A macro to test if a package build recipe needs to be run or not. # -__installed_f = $(__embtk_pkg_dotinstalled_f) -__pkgkconfig_f = $(__embtk_pkg_dotkconfig_f) -__pkgkconfig_f_old = $(__embtk_pkg_dotkconfig_f).old -__embtk_pkg_installed-y = $(shell \ - if [ -e $(__installed_f) ] && [ -e $(__pkgkconfig_f) ]; then \ - cp $(__pkgkconfig_f) $(__pkgkconfig_f_old); \ - $(call __embtk_pkg_gen_dotkconfig_f,$(1)); \ - cmp -s $(__pkgkconfig_f) $(__pkgkconfig_f_old); \ - if [ "x$$?" = "x0" ]; then \ - echo y; \ - fi; \ - fi;) +__embtk_pkg_runrecipe-y = $(or $(__embtk_pkg_ninstalled-y),$(__embtk_pkg_confchanged-y)) +__embtk_pkg_installed-y = $(or $(__embtk_$(pkgv)_installed),$(wildcard $(__embtk_pkg_dotinstalled_f))) +__embtk_pkg_ninstalled-y = $(if $(__embtk_pkg_installed-y),,y) +__embtk_pkg_confchanged-y = $(call __embtk_strneq,$(__embtk_pkg_kconfigs_all_v),$(__embtk_$(pkgv)_okconfigs)) # # Various helpers macros for different steps while installing packages. @@ -197,6 +176,7 @@ define __embtk_install_pkg_make $(call __embtk_fix_pkgconfig_files)) $(call __embtk_setinstalled_pkg,$(1)) $(call __embtk_pkg_gen_dotkconfig_f,$(1)) + $(eval __embtk_$(pkgv)_installed := y) endef define __embtk_install_hostpkg_make $(Q)$(if $(__embtk_pkg_deps),$(MAKE) $(__embtk_pkg_deps)) @@ -213,6 +193,7 @@ define __embtk_install_hostpkg_make $(__embtk_single_make_hostinstall)) $(call __embtk_setinstalled_pkg,$(1)) $(call __embtk_pkg_gen_dotkconfig_f,$(1)) + $(eval __embtk_$(pkgv)_installed := y) endef # @@ -267,7 +248,7 @@ __embtk_xinstall_xpkg_allvarset-y = $(and $(__embtk_pkg_name), \ # $(call embtk_install_pkg,package) # define __embtk_install_pkg - $(if $(__embtk_pkg_installed-y),, + $(if $(__embtk_pkg_runrecipe-y), $(Q)mkdir -p $(__embtk_pkg_builddir) $(Q)$(call __embtk_install_pkg_make,$(1),autotools) $(embtk_postinstallonce_$(pkgv)) @@ -290,7 +271,7 @@ endef # define embtk_makeinstall_pkg $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),, + $(if $(__embtk_pkg_runrecipe-y), $(Q)mkdir -p $(__embtk_pkg_builddir) $(Q)$(call __embtk_install_pkg_make,$(1)) $(embtk_postinstallonce_$(pkgv)) @@ -307,7 +288,7 @@ endef # define __embtk_install_hostpkg - $(if $(__embtk_pkg_installed-y),, + $(if $(__embtk_pkg_runrecipe-y), $(Q)mkdir -p $(__embtk_pkg_builddir) $(Q)$(call __embtk_install_hostpkg_make,$(1),autotools) $(embtk_postinstallonce_$(pkgv)) @@ -328,7 +309,7 @@ endef # define embtk_makeinstall_hostpkg $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),, + $(if $(__embtk_pkg_runrecipe-y), $(Q)mkdir -p $(__embtk_pkg_builddir) $(Q)$(call __embtk_install_hostpkg_make,$(1)) $(embtk_postinstallonce_$(pkgv)) diff --git a/mk/pkg-macros/vars.mk b/mk/pkg-macros/vars.mk index b360d64..d9a478b 100644 --- a/mk/pkg-macros/vars.mk +++ b/mk/pkg-macros/vars.mk @@ -106,6 +106,10 @@ __embtk_pkg_deps = $(strip $($(PKGV)_DEPS)) __embtk_pkg_depspkgv = $(sort $(patsubst %_install,%,$(__embtk_pkg_deps))) ___embtk_pkg_kconfigsname = $(strip $(or $($(PKGV)_KCONFIGS_NAME),$(PKGV))) __embtk_pkg_kconfigsname = $(patsubst %_HOST,%,$(___embtk_pkg_kconfigsname)) +__embtk_pkg_kconfigs = $(sort $(filter CONFIG_EMBTK_$(__embtk_pkg_kconfigsname)_%,$(.VARIABLES))) +__embtk_pkg_kconfigs_v = $(foreach k,$(__embtk_pkg_kconfigs),$(k)=$($(k))) +__embtk_pkg_deps_kconfigs_v = $(foreach d,$(__embtk_pkg_depspkgv),$(call __embtk_pkg_kconfigs_v,$(d))) +__embtk_pkg_kconfigs_all_v = $(strip $(__embtk_pkg_kconfigs_v) $(__embtk_pkg_deps_kconfigs_v)) __embtk_pkg_cflags = $(strip $($(PKGV)_CFLAGS)) __embtk_pkg_cppflags = $(strip $($(PKGV)_CPPFLAGS)) __embtk_pkg_cxxflags = $(strip $($(PKGV)_CXXFLAGS)) diff --git a/mk/toolchain.mk b/mk/toolchain.mk index 2d2dcd5..9e28abd 100644 --- a/mk/toolchain.mk +++ b/mk/toolchain.mk @@ -1,5 +1,5 @@ ################################################################################ -# Copyright(C) 2009-2013 Abdoulaye Walsimou GAYE . +# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE . # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -324,20 +324,16 @@ define __embtk_toolchain_build $(__embtk_toolchain_decompress)) endef -define __embtk_toolchain_core_inst-y - $(and $(call __embtk_pkg_installed-y,toolchain), - $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE))) +define __embtk_toolchain_runrecipe-y + $(or $(call __embtk_pkg_runrecipe-y,toolchain),$(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y)) endef -__embtk_toolchain_core_inst = $(if $(strip $(__embtk_toolchain_core_inst-y)),,core) -define __embtk_toolchain_addons_inst-y - $(and $(call __embtk_pkg_installed-y,toolchain_addons), - $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE))) +define __embtk_toolchain_addons_runrecipe-y + $(or $(call __embtk_pkg_runrecipe-y,toolchain_addons),$(if $(wildcard $(TOOLCHAIN_DIR)/$(TOOLCHAIN_PACKAGE)),,y)) endef -__embtk_toolchain_addons_inst = $(if $(strip $(__embtk_toolchain_addons_inst-y)),,addons) -__embtk_toolchain_buildargs = $(if $(__embtk_toolchain_core_inst),core-addons) -__embtk_toolchain_buildargs += $(__embtk_toolchain_addons_inst) +__embtk_toolchain_buildargs := $(if $(strip $(__embtk_toolchain_runrecipe-y)),core-addons) +__embtk_toolchain_buildargs +=$(if $(strip $(__embtk_toolchain_addons_runrecipe-y)),addons) toolchain_install: $(Q)$(call __embtk_toolchain_build,$(__embtk_toolchain_buildargs)) diff --git a/mk/uclibc.mk b/mk/uclibc.mk index 8dd7a75..2aa63ab 100755 --- a/mk/uclibc.mk +++ b/mk/uclibc.mk @@ -1,6 +1,6 @@ ################################################################################ # Embtoolkit -# Copyright(C) 2009-2011 Abdoulaye Walsimou GAYE. +# Copyright(C) 2009-2014 Abdoulaye Walsimou GAYE. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -105,11 +105,11 @@ define __embtk_install_uclibc_headers $(MAKE) -C $(UCLIBC_BUILD_DIR) $(UCLIBC_MAKE_OPTS) install_startfiles $(__embtk_install_uclibc_dummy) $(call __embtk_setinstalled_pkg,uclibc_headers) + $(eval __embtk_uclibc_headers_installed := y) endef define embtk_install_uclibc_headers - $(if $(call __embtk_pkg_installed-y,uclubc_headers),, - $(__embtk_install_uclibc_headers)) + $(if $(call __embtk_pkg_runrecipe-y,uclubc_headers),$(__embtk_install_uclibc_headers)) endef # -- cgit v1.2.3