xref: /OK3568_Linux_fs/buildroot/package/pkg-virtual.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun# Virtual package infrastructure
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# This file implements an infrastructure that eases development of
5*4882a593Smuzhiyun# package .mk files for virtual packages. It should be used for all
6*4882a593Smuzhiyun# virtual packages.
7*4882a593Smuzhiyun#
8*4882a593Smuzhiyun# See the Buildroot documentation for details on the usage of this
9*4882a593Smuzhiyun# infrastructure
10*4882a593Smuzhiyun#
11*4882a593Smuzhiyun# In terms of implementation, this virtual infrastructure requires
12*4882a593Smuzhiyun# the .mk file to only call the 'virtual-package' macro.
13*4882a593Smuzhiyun#
14*4882a593Smuzhiyun################################################################################
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun################################################################################
18*4882a593Smuzhiyun# inner-virtual-package -- defines the dependency rules of the virtual
19*4882a593Smuzhiyun# package against its provider.
20*4882a593Smuzhiyun#
21*4882a593Smuzhiyun#  argument 1 is the lowercase package name
22*4882a593Smuzhiyun#  argument 2 is the uppercase package name, including a HOST_ prefix
23*4882a593Smuzhiyun#             for host packages
24*4882a593Smuzhiyun#  argument 3 is the uppercase package name, without the HOST_ prefix
25*4882a593Smuzhiyun#             for host packages
26*4882a593Smuzhiyun#  argument 4 is the type (target or host)
27*4882a593Smuzhiyun################################################################################
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun# Note: putting this comment here rather than in the define block, otherwise
30*4882a593Smuzhiyun# make would try to expand the $(error ...) in the comment, which is not
31*4882a593Smuzhiyun# really what we want.
32*4882a593Smuzhiyun# We need to use second-expansion for the $(error ...) call, below,
33*4882a593Smuzhiyun# so it is not evaluated now, but as part of the generated make code.
34*4882a593Smuzhiyun
35*4882a593Smuzhiyundefine inner-virtual-package
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun# Ensure the virtual package has an implementation defined.
38*4882a593Smuzhiyunifeq ($$(BR2_PACKAGE_HAS_$(2)),y)
39*4882a593Smuzhiyunifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
40*4882a593Smuzhiyun$$(error No implementation selected for virtual package $(1). Configuration error)
41*4882a593Smuzhiyunendif
42*4882a593Smuzhiyunendif
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun# explicitly set these so we do not get confused by environment
45*4882a593Smuzhiyun# variables with the same names.
46*4882a593Smuzhiyun$(2)_VERSION =
47*4882a593Smuzhiyun$(2)_SOURCE =
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun$(2)_IS_VIRTUAL = YES
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun# Add dependency against the provider
52*4882a593Smuzhiyun# For a host package, there is no corresponding BR2_PACKAGE_PROVIDES_HOST_FOO,
53*4882a593Smuzhiyun# so we need to compute it from the target variant.
54*4882a593Smuzhiyunifeq ($(4),target)
55*4882a593Smuzhiyun$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
56*4882a593Smuzhiyunelse
57*4882a593Smuzhiyunifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
58*4882a593Smuzhiyun# Inherit from target package BR2_PACKAGE_PROVIDES_FOO
59*4882a593Smuzhiyun$(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3)))
60*4882a593Smuzhiyunelse
61*4882a593Smuzhiyun# BR2_PACKAGE_PROVIDES_HOST_<pkg> is explicitly defined
62*4882a593Smuzhiyun$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
63*4882a593Smuzhiyunendif
64*4882a593Smuzhiyunendif
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun# Call the generic package infrastructure to generate the necessary
67*4882a593Smuzhiyun# make targets
68*4882a593Smuzhiyun$(call inner-generic-package,$(1),$(2),$(3),$(4))
69*4882a593Smuzhiyun
70*4882a593Smuzhiyunendef
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun################################################################################
73*4882a593Smuzhiyun# virtual-package -- the target generator macro for virtual packages
74*4882a593Smuzhiyun################################################################################
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunvirtual-package = $(call inner-virtual-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
77*4882a593Smuzhiyunhost-virtual-package = $(call inner-virtual-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
78