From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6B931A0C58;
	Fri,  5 Nov 2021 18:22:19 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 255A240E5A;
	Fri,  5 Nov 2021 18:22:19 +0100 (CET)
Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com
 [209.85.214.174])
 by mails.dpdk.org (Postfix) with ESMTP id 3EA1340151
 for <dev@dpdk.org>; Fri,  5 Nov 2021 18:22:17 +0100 (CET)
Received: by mail-pl1-f174.google.com with SMTP id t11so11433216plq.11
 for <dev@dpdk.org>; Fri, 05 Nov 2021 10:22:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20210112.gappssmtp.com; s=20210112;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=zTKMGLeuwJpvVOQV0K7Aev/hmfPFiUuu4FXdiiyAPCo=;
 b=4NHZEnIcZQ7SmZRBL922qSdG+ZaUzcGJwVZ87vmMb1XPZ0X3kWoYFaEbMFzD9KDMig
 zCYynrXX9l3D3+XPLv+V5xMfKqPaEPSMVIieI0LFlDZ5WQTUVnB54zTwzZQW5YkYKPMg
 /NTI5VneklwBQwEaDsLKC+K+30HZBfxYNWyb8V1j4pZUuDbLTaN5cMLHDNlm70wnWeZS
 9ZMG2zq6V5JVqfnwxc3BKuG9Jpr/ag7yhTJjK7Fp+Or4yoBP7vZ0tmzIQPMiOQofY76S
 eZAKfQVgNQKuN7lJE0C5Wj6fxcrITIohDEPlk9JkHQP4tkmW5HoZD+Y0EkehNM3KUPtI
 qMRA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=zTKMGLeuwJpvVOQV0K7Aev/hmfPFiUuu4FXdiiyAPCo=;
 b=jXlSJgjejq4w0GSl9yJ7THeszxwLlf5WwJ6WQG0eCUpUslAlR82DIn9QNmpU6q66lD
 DYVS8jLPtG6CjWx1Ha7lYCiZSmS8U/n1TPF/4azlfdmtLnXL83SX8DYMZP1t3VMGMomP
 Cxz6YWdg4OzLtyuSMyUMA9MFYwHUdMpj+7mZ/33mPiPeQE3iR5hPiXaKFXt8gL0ElKq5
 4yBHHp7ZxsTHW623k2NmUqFnNi3WDQxoRlsVCgi4YQHL0jnKwV34jLP7prJ2G3XY3Emy
 uNjQ83YcKU4HtK/ySZJchn+mF0M5DFwiKoa8vWzfW3nBJbo03jISj+6tgd6/EhNTx5dn
 0QPg==
X-Gm-Message-State: AOAM531Y+WTwZbCxz8OVFG1eMNUSbxlx7wa+/k9isY0svqsVDzrdItM5
 MyqlgTJUkxijPrKd0QeekaYdXw==
X-Google-Smtp-Source: ABdhPJzXJqEsFpVjGy4O9reo4FHUzsFVlEb8i1NF1ApbCbUIj1V5apA6w/UJGZ0K/Djaodptb1A1eQ==
X-Received: by 2002:a17:90a:eb03:: with SMTP id
 j3mr31623548pjz.149.1636132936413; 
 Fri, 05 Nov 2021 10:22:16 -0700 (PDT)
Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123])
 by smtp.gmail.com with ESMTPSA id w5sm6338217pgp.79.2021.11.05.10.22.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 05 Nov 2021 10:22:15 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org,
	Stephen Hemminger <stephen@networkplumber.org>
Date: Fri,  5 Nov 2021 10:22:13 -0700
Message-Id: <20211105172213.103988-1-stephen@networkplumber.org>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20211103221205.63175-1-stephen@networkplumber.org>
References: <20211103221205.63175-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2] build: add definitions for use as meson
 subproject
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Some other projects using meson may not be able to use DPDK
using the standard distribution pkg-config mechanism.
Meson supports a way to handle this via the subproject
  https://mesonbuild.com/Subprojects.html

This patch adds the necessary dependency to follow the
"Naming convention for dependency variables" from the documentation.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---

v2 - add link libraries

 lib/meson.build |  5 +++++
 meson.build     | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/lib/meson.build b/lib/meson.build
index 499d26060fdd..e6df538bd6ef 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -241,6 +241,11 @@ foreach l:libraries
 
     dpdk_libraries = [shared_lib] + dpdk_libraries
     dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+    if get_option('default_library') == 'static'
+        dpdk_libs_deps += static_dep
+    else
+        dpdk_libs_deps += shared_dep
+    endif
 
     set_variable('shared_rte_' + name, shared_dep)
     set_variable('static_rte_' + name, static_dep)
diff --git a/meson.build b/meson.build
index 12cb6e0e83f3..3bf6bb794ce1 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,7 @@ dpdk_drivers = []
 dpdk_extra_ldflags = []
 dpdk_libs_disabled = []
 dpdk_drvs_disabled = []
+dpdk_libs_deps = []
 abi_version_file = files('ABI_VERSION')
 
 if host_machine.cpu_family().startswith('x86')
@@ -97,6 +98,18 @@ configure_file(output: build_cfg,
 # build pkg-config files for dpdk
 subdir('buildtools/pkg-config')
 
+# If DPDK is being built as subproject then define
+# variable with the dependency convention
+if meson.is_subproject()
+    libdpdk_dep = declare_dependency(
+        version: meson.project_version(),
+        compile_args : pkg_extra_cflags,
+        dependencies: dpdk_libs_deps,
+        link_args: dpdk_extra_ldflags,
+        link_with: dpdk_libraries
+    )
+endif
+
 # final output, list all the libs and drivers to be built
 # this does not affect any part of the build, for information only.
 output_message = '\n=================\nLibraries Enabled\n=================\n'
-- 
2.30.2