From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 365292BD2 for ; Thu, 29 Mar 2018 16:05:04 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2018 07:05:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,376,1517904000"; d="scan'208";a="29924123" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.223]) by orsmga006.jf.intel.com with ESMTP; 29 Mar 2018 07:05:03 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Thu, 29 Mar 2018 15:04:57 +0100 Message-Id: <20180329140457.93034-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180329140457.93034-1-bruce.richardson@intel.com> References: <20180329140457.93034-1-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 2/2] examples/ethtool: enable build using pkg-config vars 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: , X-List-Received-Date: Thu, 29 Mar 2018 14:05:04 -0000 When provided as an example in a DPDK package, the build of the example app should use the pkg-config-supplied values from the package. As with other examples, set up makefile to allow compilation either using pkg-config or old $RTE_SDK/$RTE_TARGET values. Signed-off-by: Bruce Richardson --- examples/ethtool/Makefile | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/examples/ethtool/Makefile b/examples/ethtool/Makefile index 2b40b4b61..9ea7e0e07 100644 --- a/examples/ethtool/Makefile +++ b/examples/ethtool/Makefile @@ -1,6 +1,54 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2015 Intel Corporation +# Build using pkg-config variables if possible +$(shell pkg-config --exists libdpdk) +ifeq ($(.SHELLSTATUS),0) + +# sample app consists of two parts, an example library and app using it +APP := ethtool +SRCS-y := ethtool-app/main.c ethtool-app/ethapp.c + +LIB := rte_ethtool +LIB-SRC := rte_ethtool.c + +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) + +PC_FILE := $(shell pkg-config --path libdpdk) +CFLAGS += -O3 $(shell pkg-config --cflags libdpdk) +LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) -lrte_pmd_ixgbe +LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) + +LIB-OBJ := build/$(LIB-SRC:.c=.o) +AR_FILE := build/lib$(LIB).a + +$(LIB-OBJ): lib/$(LIB-SRC) Makefile $(PC_FILE) | build + $(CC) -c $(CFLAGS) lib/$(LIB-SRC) -o $@ + +$(AR_FILE): $(LIB-OBJ) + $(AR) r $@ $< + +build/$(APP)-shared: $(SRCS-y) $(AR_FILE) Makefile $(PC_FILE) | build + $(CC) -Ilib $(CFLAGS) $(SRCS-y) $(AR_FILE) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) + +build/$(APP)-static: $(SRCS-y) $(AR_FILE) Makefile $(PC_FILE) | build + $(CC) -Ilib $(CFLAGS) $(SRCS-y) $(AR_FILE) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) + +build: + @mkdir -p $@ + +.PHONY: clean +clean: + rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared + rmdir --ignore-fail-on-non-empty build + +else + ifeq ($(RTE_SDK),) $(error "Please define RTE_SDK environment variable") endif @@ -21,3 +69,5 @@ endif DEPDIRS-ethtool-app := lib include $(RTE_SDK)/mk/rte.extsubdir.mk + +endif # no pkg-config for DPDK -- 2.14.3