2889ef9beae551a45a28e81662544524634bd279
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / pkg-virtual.mk
1 ################################################################################
2 # Virtual package infrastructure
3 #
4 # This file implements an infrastructure that eases development of
5 # package .mk files for virtual packages. It should be used for all
6 # virtual packages.
7 #
8 # See the Buildroot documentation for details on the usage of this
9 # infrastructure
10 #
11 # In terms of implementation, this virtual infrastructure requires
12 # the .mk file to only call the 'virtual-package' macro.
13 #
14 ################################################################################
15
16
17 ################################################################################
18 # inner-virtual-package -- defines the dependency rules of the virtual
19 # package against its provider.
20 #
21 #  argument 1 is the lowercase package name
22 #  argument 2 is the uppercase package name, including a HOST_ prefix
23 #             for host packages
24 #  argument 3 is the uppercase package name, without the HOST_ prefix
25 #             for host packages
26 #  argument 4 is the type (target or host)
27 ################################################################################
28
29 # Note: putting this comment here rather than in the define block, otherwise
30 # make would try to expand the $(error ...) in the comment, which is not
31 # really what we want.
32 # We need to use second-expansion for the $(error ...) call, below,
33 # so it is not evaluated now, but as part of the generated make code.
34
35 define inner-virtual-package
36
37 # Ensure the virtual package has an implementation defined.
38 ifeq ($$(BR2_PACKAGE_HAS_$(2)),y)
39 ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
40 $$(error No implementation selected for virtual package $(1). Configuration error)
41 endif
42 endif
43
44 # A virtual package does not have any source associated
45 $(2)_SOURCE =
46
47 # Fake a version string, so it looks nicer in the build log
48 $(2)_VERSION = virtual
49
50 # This must be repeated from inner-generic-package, otherwise we get an empty
51 # _DEPENDENCIES
52 ifeq ($(4),host)
53 $(2)_DEPENDENCIES ?= $$(filter-out host-toolchain $(1),\
54         $$(patsubst host-host-%,host-%,$$(addprefix host-,$$($(3)_DEPENDENCIES))))
55 endif
56
57 # Add dependency against the provider
58 $(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
59
60 # Call the generic package infrastructure to generate the necessary
61 # make targets
62 $(call inner-generic-package,$(1),$(2),$(3),$(4))
63
64 endef
65
66 ################################################################################
67 # virtual-package -- the target generator macro for virtual packages
68 ################################################################################
69
70 virtual-package = $(call inner-virtual-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
71 host-virtual-package = $(call inner-virtual-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)