examples: fix pkg-config override
[dpdk.git] / examples / performance-thread / l3fwd-thread / Makefile
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2020 Intel Corporation
3
4 # binary name
5 APP = l3fwd-thread
6
7 # all source are stored in SRCS-y
8 SRCS-y := main.c
9
10 include ../common/common.mk
11
12 ifeq ($(MAKECMDGOALS),static)
13 # check for broken pkg-config
14 ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
15 $(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
16 $(error "Cannot generate statically-linked binaries with this version of pkg-config")
17 endif
18 endif
19
20 PKGCONF ?= pkg-config
21
22 CFLAGS += -DALLOW_EXPERIMENTAL_API
23
24 # Build using pkg-config variables if possible
25 ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
26 $(error "no installation of DPDK found")
27 endif
28
29 all: shared
30 .PHONY: shared static
31 shared: build/$(APP)-shared
32         ln -sf $(APP)-shared build/$(APP)
33 static: build/$(APP)-static
34         ln -sf $(APP)-static build/$(APP)
35
36
37 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
38 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
39 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
40 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
41
42 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
43         $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
44
45 build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
46         $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
47
48 build:
49         @mkdir -p $@
50
51 .PHONY: clean
52 clean:
53         rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
54         test -d build && rmdir -p build || true