From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 917C2A04AA; Tue, 8 Sep 2020 00:08:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EC4521C1A2; Tue, 8 Sep 2020 00:07:35 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 698951C18E for ; Tue, 8 Sep 2020 00:07:31 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1BFB45C002F; Mon, 7 Sep 2020 18:07:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 07 Sep 2020 18:07:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=QVhAdAaE1DXUU g8NaEc6t+F7927DbzTHmuvwSrf4AYs=; b=VxeTu/7z5nq1QQyVMyUWjr/dXkit9 2vAEuhyn1PClbJYPrTrI5a9af8srJZFUQoIDZptfrGdtP3KUsGkSb3ejrKEhFrmX XtJmI/H0S+jwFKenJBR21kmHcMfqPcGZx7AGlZK2fibH5fAp9eILC49lszTCry0n lJkUdUNxVrMqzMXMNyKBOov7CoNr9i5bBU1YvBVcGj4txwCVH0VUapGlCArRUlLF Mcd0P0OqAHU4H5XojLNnSrDVs5uP63cpxKjhFhrY8OXC90pzQJTq3HRfsNWDeYKT kXVMgHbUW0Dx2Lkw0vFu0jJTYAw6kvfNWrw6XnuvWnOJEXPrxY0UNpdYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=QVhAdAaE1DXUUg8NaEc6t+F7927DbzTHmuvwSrf4AYs=; b=rfRrRcoF +vOz4bmQS2m636J9v3pujhOOyP2PZn56OLhMC9ilSA14/qlV+IIg8aAJtOiIIXnA DgjGet9/zVvdWthT0Dr8uk0DRgkMFL//TMORynXTuhhW/w7RV3Wz8pBIK7Q++L++ Byxq1LtsLLMc6LYSr1w5vr7Rt6Ja38N+YJLOkJQ0g1y3WMKRuRmjqJpWvLSS0MQW R3VXKE4eUr1vTPyG0yM8/fAiZoG46weIvpv02pGPPkggdSimALtn6goFsEA6Qxq3 iPdMmKu2CZ39UJXXePkP0k7247wuqN0VOWYJgUe/E9eUi+FrAIHJXZIOWeMmJUiv hZtelxvjPIwqJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehuddgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpeegfedttdeikeekvedttd dvueetgffhjeejudetveffkeeihffglefgtdeivdeuteenucffohhmrghinhepvhgrrhhs rdhmkhdpvgigthhsuhgsughirhdrmhhkpdgvgihtrghpphdrmhhkpdgvgihtlhhisgdrmh hknecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvg ht X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 63F4D3280059; Mon, 7 Sep 2020 18:07:30 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, bruce.richardson@intel.com, ciara.power@intel.com Date: Tue, 8 Sep 2020 00:06:48 +0200 Message-Id: <20200907220711.437405-9-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907220711.437405-1-thomas@monjalon.net> References: <20200903152717.42095-1-ciara.power@intel.com> <20200907220711.437405-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 08/31] examples/ethtool: convert to pkg-config-based build X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Bruce Richardson Remove references to the old DPDK build system from the makefiles, and use pkg-config provided flags instead. Signed-off-by: Bruce Richardson --- examples/ethtool/Makefile | 26 +++-------- examples/ethtool/ethtool-app/Makefile | 56 +++++++++++++++--------- examples/ethtool/lib/Makefile | 62 ++++++++++++++++----------- 3 files changed, 79 insertions(+), 65 deletions(-) diff --git a/examples/ethtool/Makefile b/examples/ethtool/Makefile index d3b97bb50b..a1a80c44e6 100644 --- a/examples/ethtool/Makefile +++ b/examples/ethtool/Makefile @@ -1,23 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2015 Intel Corporation +# Copyright(c) 2015-2020 Intel Corporation -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif +subdirs := lib ethtool-app -# Default target, detect a build directory, by looking for a path with a .config -RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) +.PHONY: all static shared clean $(subdirs) +all static shared clean: $(subdirs) -include $(RTE_SDK)/mk/rte.vars.mk - -ifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) -$(info This application can only operate in a linux environment, \ -please change the definition of the RTE_TARGET environment variable) -else - -DIRS-y += lib ethtool-app -endif - -DEPDIRS-ethtool-app := lib - -include $(RTE_SDK)/mk/rte.extsubdir.mk +ethtool-app: lib +$(subdirs): + $(MAKE) -C $@ $(MAKECMDGOALS) diff --git a/examples/ethtool/ethtool-app/Makefile b/examples/ethtool/ethtool-app/Makefile index 20ac0d3240..5ebeb200a8 100644 --- a/examples/ethtool/ethtool-app/Makefile +++ b/examples/ethtool/ethtool-app/Makefile @@ -1,14 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, detect a build directory, by looking for a path with a .config -RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) - -include $(RTE_SDK)/mk/rte.vars.mk +# Copyright(c) 2010-2020 Intel Corporation # binary name APP = ethtool @@ -16,17 +7,40 @@ APP = ethtool # all source are stored in SRCS-y SRCS-y := main.c ethapp.c -CFLAGS += -O3 -pthread -I$(SRCDIR)/../lib -CFLAGS += $(WERROR_FLAGS) -CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I../lib +LDFLAGS += -L../lib/build +LDFLAGS_STATIC = -l:librte_ethtool.a +LDFLAGS_SHARED = -lrte_ethtool -LDLIBS += -L$(subst ethtool-app,lib,$(RTE_OUTPUT))/lib -LDLIBS += -lrte_ethtool - -ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) -ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y) -LDLIBS += -lrte_pmd_ixgbe -endif +# Build using pkg-config variables if possible +ifneq ($(shell pkg-config --exists libdpdk && echo 0),0) +$(error "no installation of DPDK found") endif -include $(RTE_SDK)/mk/rte.extapp.mk +all: shared +.PHONY: shared static +shared: build/$(APP)-shared + ln -sf $(APP)-shared build/$(APP) +static: build/$(APP)-static + ln -sf $(APP)-static build/$(APP) + +PKGCONF ?= pkg-config + +PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) +CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) +LDFLAGS_SHARED += $(shell $(PKGCONF) --libs libdpdk) +LDFLAGS_STATIC += $(shell $(PKGCONF) --static --libs libdpdk) + +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) + +build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) + +build: + @mkdir -p $@ + +.PHONY: clean +clean: + rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared + test -d build && rmdir -p build || true diff --git a/examples/ethtool/lib/Makefile b/examples/ethtool/lib/Makefile index 6494741270..3bc2b9d8ba 100644 --- a/examples/ethtool/lib/Makefile +++ b/examples/ethtool/lib/Makefile @@ -1,37 +1,49 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2015 Intel Corporation +# Copyright(c) 2015-2020 Intel Corporation -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, detect a build directory, by looking for a path with a .config -RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) - -include $(RTE_SDK)/mk/rte.vars.mk -ifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) -$(error This application can only operate in a linux environment, \ -please change the definition of the RTE_TARGET environment variable) +ifneq ($(shell pkg-config --exists libdpdk && echo 0),0) +$(error "no installation of DPDK found") endif +ifneq ($(shell uname),Linux) +$(error This application can only operate in a linux environment) +endif + +PKGCONF ?= pkg-config # library name -LIB = librte_ethtool.a - -LIBABIVER := 0.1 - -# all source are stored in SRC-Y -SRCS-y := rte_ethtool.c +LIB = librte_ethtool.so +LIB_STATIC = librte_ethtool.a +SRCS = rte_ethtool.c CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) +CFLAGS += -fPIC CFLAGS += -DALLOW_EXPERIMENTAL_API -ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) -ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y) -LDLIBS += -lrte_pmd_ixgbe -endif +PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) +CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) +LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) +LDFLAGS += -Wl,--no-undefined $(LDFLAGS_SHARED) + +# check for ixgbe by grepping pre-processor output +ifneq ($(shell $(CC) $(CFLAGS) -dM -E - < /dev/null | grep IXGBE),) +LDFLAGS += -lrte_pmd_ixgbe endif -LDLIBS += -lrte_eal -lrte_ethdev -include $(RTE_SDK)/mk/rte.extlib.mk +.PHONY: all clean static shared +all shared: build/$(LIB) +static: build/$(LIB_STATIC) + +clean: + rm -f build/$(LIB) + test -d build && rmdir -p build || true + +build: + @mkdir -p $@ + +build/%.so: $(SRCS) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) -o $@ -shared $(SRCS) $(LDFLAGS) + +build/%.a: $(SRCS) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) -c $(SRCS) -o build/$(SRCS).o + $(AR) -cr $@ build/*.o -- 2.28.0