examples: warn about broken pkg-config
[dpdk.git] / examples / ip_pipeline / Makefile
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2018 Intel Corporation
3
4 # binary name
5 APP = ip_pipeline
6
7 # all source are stored in SRCS-y
8 SRCS-y := action.c
9 SRCS-y += cli.c
10 SRCS-y += conn.c
11 SRCS-y += kni.c
12 SRCS-y += link.c
13 SRCS-y += main.c
14 SRCS-y += mempool.c
15 SRCS-y += parser.c
16 SRCS-y += pipeline.c
17 SRCS-y += swq.c
18 SRCS-y += tap.c
19 SRCS-y += thread.c
20 SRCS-y += tmgr.c
21 SRCS-y += cryptodev.c
22
23 # Build using pkg-config variables if possible
24 ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
25 $(error "no installation of DPDK found")
26 endif
27
28 all: shared
29 .PHONY: shared static
30 shared: build/$(APP)-shared
31         ln -sf $(APP)-shared build/$(APP)
32 static: build/$(APP)-static
33         ln -sf $(APP)-static build/$(APP)
34
35 PKGCONF ?= pkg-config
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 ifeq ($(MAKECMDGOALS),static)
43 # check for broken pkg-config
44 ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
45 $(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
46 $(error "Cannot generate statically-linked binaries with this version of pkg-config")
47 endif
48 endif
49
50 CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
51
52 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
53
54 build/%.o: %.c Makefile $(PC_FILE) | build
55         $(CC) $(CFLAGS) -c $< -o $@
56
57 build/$(APP)-shared: $(OBJS)
58         $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
59
60 build/$(APP)-static: $(OBJS)
61         $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
62
63 build:
64         @mkdir -p $@
65
66 .PHONY: clean
67 clean:
68         rm -f build/$(APP)* build/*.o
69         test -d build && rmdir -p build || true