2014-04-05 09:21:45 -06:00
|
|
|
################################################################################
|
|
|
|
# Virtual package infrastructure
|
|
|
|
#
|
|
|
|
# This file implements an infrastructure that eases development of
|
|
|
|
# package .mk files for virtual packages. It should be used for all
|
|
|
|
# virtual packages.
|
|
|
|
#
|
|
|
|
# See the Buildroot documentation for details on the usage of this
|
|
|
|
# infrastructure
|
|
|
|
#
|
|
|
|
# In terms of implementation, this virtual infrastructure requires
|
|
|
|
# the .mk file to only call the 'virtual-package' macro.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# inner-virtual-package -- defines the dependency rules of the virtual
|
|
|
|
# package against its provider.
|
|
|
|
#
|
|
|
|
# argument 1 is the lowercase package name
|
2014-07-24 12:57:41 -06:00
|
|
|
# argument 2 is the uppercase package name, including a HOST_ prefix
|
2014-04-05 09:21:45 -06:00
|
|
|
# for host packages
|
|
|
|
# argument 3 is the uppercase package name, without the HOST_ prefix
|
|
|
|
# for host packages
|
|
|
|
# argument 4 is the type (target or host)
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Note: putting this comment here rather than in the define block, otherwise
|
|
|
|
# make would try to expand the $(error ...) in the comment, which is not
|
|
|
|
# really what we want.
|
|
|
|
# We need to use second-expansion for the $(error ...) call, below,
|
|
|
|
# so it is not evaluated now, but as part of the generated make code.
|
|
|
|
|
|
|
|
define inner-virtual-package
|
|
|
|
|
|
|
|
# Ensure the virtual package has an implementation defined.
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 13:12:24 -06:00
|
|
|
ifeq ($$(BR2_PACKAGE_HAS_$(2)),y)
|
|
|
|
ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
|
2014-04-05 09:21:45 -06:00
|
|
|
$$(error No implementation selected for virtual package $(1). Configuration error)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-12-29 16:10:40 -07:00
|
|
|
$(2)_IS_VIRTUAL = YES
|
|
|
|
|
2014-04-05 09:21:45 -06:00
|
|
|
# Add dependency against the provider
|
2016-07-03 04:44:43 -06:00
|
|
|
# For a host package, there is no corresponding BR2_PACKAGE_PROVIDES_HOST_FOO,
|
|
|
|
# so we need to compute it from the target variant.
|
|
|
|
ifeq ($(4),target)
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 13:12:24 -06:00
|
|
|
$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
|
2016-07-03 04:44:43 -06:00
|
|
|
else
|
|
|
|
$(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3)))
|
|
|
|
endif
|
2014-04-05 09:21:45 -06:00
|
|
|
|
|
|
|
# Call the generic package infrastructure to generate the necessary
|
|
|
|
# make targets
|
|
|
|
$(call inner-generic-package,$(1),$(2),$(3),$(4))
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# virtual-package -- the target generator macro for virtual packages
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
virtual-package = $(call inner-virtual-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
|
|
|
|
host-virtual-package = $(call inner-virtual-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
|