examples: warn about broken pkg-config
[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 CFLAGS += -DALLOW_EXPERIMENTAL_API
21
22 # Build using pkg-config variables if possible
23 ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
24 $(error "no installation of DPDK found")
25 endif
26
27 all: shared
28 .PHONY: shared static
29 shared: build/$(APP)-shared
30         ln -sf $(APP)-shared build/$(APP)
31 static: build/$(APP)-static
32         ln -sf $(APP)-static build/$(APP)
33
34 PKGCONF ?= pkg-config
35
36 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
37 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
38 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
39 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
40
41 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
42         $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
43
44 build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
45         $(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
46
47 build:
48         @mkdir -p $@
49
50 .PHONY: clean
51 clean:
52         rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
53         test -d build && rmdir -p build || true