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