[v2,4/5] examples/vdpa: support building from pkg-config info

Message ID 20190517114734.7072-5-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series improve building examples |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson May 17, 2019, 11:47 a.m. UTC
  The vdpa example app did not check for a libdpdk pkg-config file and
attempt to build using that. Add support for that method of compile to
align the app with the other examples.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/vdpa/Makefile | 52 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 44 insertions(+), 8 deletions(-)
  

Comments

Thomas Monjalon July 2, 2019, 7:57 a.m. UTC | #1
17/05/2019 13:47, Bruce Richardson:
> The vdpa example app did not check for a libdpdk pkg-config file and
> attempt to build using that. Add support for that method of compile to
> align the app with the other examples.

I see an issue with the experimental tag:

clang -Wp,-MD,./.main.o.d.tmp  -m64 -pthread -fPIC -Ilib/librte_eal/linux/eal/include  -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_RDRAND -DRTE_MACHINE_CPUFLAG_RDSEED -DRTE_MACHINE_CPUFLAG_FSGSBASE -DRTE_MACHINE_CPUFLAG_F16C -DRTE_MACHINE_CPUFLAG_AVX2  -Ix86_64-native-linux-clang+shared+next+debug+ASSERT/examples/vdpa/x86_64-native-linux-clang+shared+next+debug+ASSERT/include -Ix86_64-native-linux-clang+shared+next+debug+ASSERT/include -include x86_64-native-linux-clang+shared+next+debug+ASSERT/include/rte_config.h -D_GNU_SOURCE -O2 -D_FILE_OFFSET_BITS=64 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Werror -Wno-missing-field-initializers -Wno-address-of-packed-member -D_GNU_SOURCE    -o main.o -c examples/vdpa/main.c 
examples/vdpa/main.c:172:8: error: 'rte_vhost_driver_attach_vdpa_device' is deprecated: Symbol is not yet part of stable ABI [-Werror,-Wdeprecated-declarations]

It seems "CFLAGS += -DALLOW_EXPERIMENTAL_API"
is reset by the call to pkg-config.

> +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build

Better to use the real directory name as prerequisite,
instead of "build".
  
Bruce Richardson July 2, 2019, 2:35 p.m. UTC | #2
On Tue, Jul 02, 2019 at 09:57:48AM +0200, Thomas Monjalon wrote:
> 17/05/2019 13:47, Bruce Richardson:
> > The vdpa example app did not check for a libdpdk pkg-config file and
> > attempt to build using that. Add support for that method of compile to
> > align the app with the other examples.
> 
> I see an issue with the experimental tag:
> 
> clang -Wp,-MD,./.main.o.d.tmp  -m64 -pthread -fPIC -Ilib/librte_eal/linux/eal/include  -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_RDRAND -DRTE_MACHINE_CPUFLAG_RDSEED -DRTE_MACHINE_CPUFLAG_FSGSBASE -DRTE_MACHINE_CPUFLAG_F16C -DRTE_MACHINE_CPUFLAG_AVX2  -Ix86_64-native-linux-clang+shared+next+debug+ASSERT/examples/vdpa/x86_64-native-linux-clang+shared+next+debug+ASSERT/include -Ix86_64-native-linux-clang+shared+next+debug+ASSERT/include -include x86_64-native-linux-clang+shared+next+debug+ASSERT/include/rte_config.h -D_GNU_SOURCE -O2 -D_FILE_OFFSET_BITS=64 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Werror -Wno-missing-field-initializers -Wno-address-of-packed-member -D_GNU_SOURCE    -o main.o -c examples/vdpa/main.c 
> examples/vdpa/main.c:172:8: error: 'rte_vhost_driver_attach_vdpa_device' is deprecated: Symbol is not yet part of stable ABI [-Werror,-Wdeprecated-declarations]
> 
> It seems "CFLAGS += -DALLOW_EXPERIMENTAL_API"
> is reset by the call to pkg-config.
>

No, it's not, it's reset by the call to the DPDK make build system in
the other leg of the code. I'll fix this in the Makefile in v3.
 
> > +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
> 
> Better to use the real directory name as prerequisite,
> instead of "build".
> 
Not sure what you mean here, build is the name of the directory. [This is
also consistent with what is done in all the other example makefiles. If it
needs updating, then it should be done as a general patch to all examples
in 19.11 release timeframe.]

/Bruce
  
Thomas Monjalon July 2, 2019, 3 p.m. UTC | #3
02/07/2019 16:35, Bruce Richardson:
> On Tue, Jul 02, 2019 at 09:57:48AM +0200, Thomas Monjalon wrote:
> > It seems "CFLAGS += -DALLOW_EXPERIMENTAL_API"
> > is reset by the call to pkg-config.
> >
> 
> No, it's not, it's reset by the call to the DPDK make build system in
> the other leg of the code. I'll fix this in the Makefile in v3.

OK
 
> > > +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
> > 
> > Better to use the real directory name as prerequisite,
> > instead of "build".
> > 
> Not sure what you mean here, build is the name of the directory. [This is
> also consistent with what is done in all the other example makefiles. If it
> needs updating, then it should be done as a general patch to all examples
> in 19.11 release timeframe.]

Ah my bad, I overlooked it :)
  

Patch

diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile
index 9d16d8eb5..05a9b9029 100644
--- a/examples/vdpa/Makefile
+++ b/examples/vdpa/Makefile
@@ -1,6 +1,47 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
+# binary name
+APP = vdpa
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+# Build using pkg-config variables if possible
+$(shell pkg-config --exists libdpdk)
+ifeq ($(.SHELLSTATUS),0)
+
+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 --define-prefix
+
+PC_FILE := $(shell $(PKGCONF) --path libdpdk)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(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
+
+else
+
 ifeq ($(RTE_SDK),)
 $(error "Please define RTE_SDK environment variable")
 endif
@@ -16,17 +57,12 @@  please change the definition of the RTE_TARGET environment variable)
 all:
 else
 
-# binary name
-APP = vdpa
-
-# all source are stored in SRCS-y
-SRCS-y := main.c
-
 CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -D_GNU_SOURCE
-CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
-endif
+endif # linuxapp
+
+endif # pkg-config