xref: /dpdk/examples/ip_pipeline/Makefile (revision 11e02702)
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 += kni.c
12SRCS-y += link.c
13SRCS-y += main.c
14SRCS-y += mempool.c
15SRCS-y += parser.c
16SRCS-y += pipeline.c
17SRCS-y += swq.c
18SRCS-y += tap.c
19SRCS-y += thread.c
20SRCS-y += tmgr.c
21SRCS-y += cryptodev.c
22
23PKGCONF ?= pkg-config
24
25# Build using pkg-config variables if possible
26ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
27$(error "no installation of DPDK found")
28endif
29
30all: shared
31.PHONY: shared static
32shared: build/$(APP)-shared
33	ln -sf $(APP)-shared build/$(APP)
34static: build/$(APP)-static
35	ln -sf $(APP)-static build/$(APP)
36
37PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
38CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
39LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
40LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
41
42ifeq ($(MAKECMDGOALS),static)
43# check for broken pkg-config
44ifeq ($(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")
47endif
48endif
49
50CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
51
52OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
53
54build/%.o: %.c Makefile $(PC_FILE) | build
55	$(CC) $(CFLAGS) -c $< -o $@
56
57build/$(APP)-shared: $(OBJS)
58	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
59
60build/$(APP)-static: $(OBJS)
61	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
62
63build:
64	@mkdir -p $@
65
66.PHONY: clean
67clean:
68	rm -f build/$(APP)* build/*.o
69	test -d build && rmdir -p build || true
70