From patchwork Sun Mar 2 16:52:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 325601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 6BCCB2C00C5 for ; Mon, 3 Mar 2014 03:53:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1537610694; Sun, 2 Mar 2014 16:53:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vak7dKYEnah8; Sun, 2 Mar 2014 16:53:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1EA5C10659; Sun, 2 Mar 2014 16:53:17 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 822931BF836 for ; Sun, 2 Mar 2014 16:53:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7EEF291CD5 for ; Sun, 2 Mar 2014 16:53:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8uqsloZCloa2 for ; Sun, 2 Mar 2014 16:53:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by whitealder.osuosl.org (Postfix) with ESMTPS id 81FFF91CC2 for ; Sun, 2 Mar 2014 16:53:15 +0000 (UTC) Received: by mail-wg0-f41.google.com with SMTP id l18so2156301wgh.0 for ; Sun, 02 Mar 2014 08:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=nEDItMQ/273sKXrN7qyH8OiHpxe7nCJ1vPhaqU5U+is=; b=axYT7Pshemo9aPa/G3C3v1axpx8zVw5nC9d/u1BWNKU77RpsLwxDlYwJDx3PWZTT5f 8spU6BHUMDVIw41vq2QPGMPKPXtICMOB3Sro5eYH4j5JF4zvpNRiXeH0UezTE0ANgS0F a15sBU/JyEyxC8yCLeNlHH4RLjBcdPBGDOySGb4rP/NPj8gEd4605XXiTtGmlzYViNNS rJrP5/S6p6Ry7+5IQgRtuxh+OOfeuFx4nPz8p7J5Mw8cvd9lcZPVvJZySY70U4d5vAF1 ilTVAsmNdZZTCzqo11/nsBjzJpWmB4TyTmW3l+2Xlal9VhrSt+8CG4CXVAYT5E2H/xKB FFmw== X-Received: by 10.194.57.239 with SMTP id l15mr11403332wjq.40.1393779194104; Sun, 02 Mar 2014 08:53:14 -0800 (PST) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id h13sm21964648wjr.22.2014.03.02.08.53.12 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 08:53:13 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 2 Mar 2014 17:52:49 +0100 Message-Id: X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: MIME-Version: 1.0 Cc: Thomas Petazzoni , "Yann E. MORIN" Subject: [Buildroot] [PATCH 08/19] packages: add infrastructure for virtual packages X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: "Yann E. MORIN" The virtual-package infrastructure allows to easily define a virtual package in a single line: $ package/some-virtual-package/some-virtual-package.mk: $(eval $(virtual-package)) And that's all. :-) Thanks to Éric for his work on the manual, that prompted the idea for this virtual-package infrastructure! ;-) Signed-off-by: "Yann E. MORIN" Cc: Eric Le Bihan Cc: Thomas Petazzoni Cc: Thomas De Schampheleire Cc: Mike Zick Reviewed-by: Samuel Martin --- package/Makefile.in | 1 + package/pkg-virtual.mk | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 package/pkg-virtual.mk diff --git a/package/Makefile.in b/package/Makefile.in index 454f614..c5cdf5a 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -362,4 +362,5 @@ include package/pkg-cmake.mk include package/pkg-luarocks.mk include package/pkg-perl.mk include package/pkg-python.mk +include package/pkg-virtual.mk include package/pkg-generic.mk diff --git a/package/pkg-virtual.mk b/package/pkg-virtual.mk new file mode 100644 index 0000000..9b206ea --- /dev/null +++ b/package/pkg-virtual.mk @@ -0,0 +1,66 @@ +################################################################################ +# 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 +# argument 2 is the uppercase package name, including an HOST_ prefix +# 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. +ifeq ($(BR2_PACKAGE_HAS_$(2)),y) +ifeq ($(call qstrip,$(BR2_PACKAGE_PROVIDES_$(2))),) +$$(error No implementation selected for virtual package $(1). Configuration error) +endif +endif + +# A virtual package does not have any source associated +$(2)_SOURCE = + +# This must be repeated from inner-generic-package, otherwise we get an empty +# _DEPENDENCIES +$(2)_DEPENDENCIES ?= $(filter-out host-toolchain $(1),\ + $(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES)))) + +# Add dependency against the provider +$(2)_DEPENDENCIES += $(call qstrip,$(BR2_PACKAGE_PROVIDES_$(2))) + +# 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)