xref: /f-stack/dpdk/examples/ip_pipeline/Makefile (revision 2d9fd380)
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
23# Build using pkg-config variables if possible
24ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
25$(error "no installation of DPDK found")
26endif
27
28all: shared
29.PHONY: shared static
30shared: build/$(APP)-shared
31	ln -sf $(APP)-shared build/$(APP)
32static: build/$(APP)-static
33	ln -sf $(APP)-static build/$(APP)
34
35PKGCONF ?= pkg-config
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
42CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
43
44OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
45
46build/%.o: %.c Makefile $(PC_FILE) | build
47	$(CC) $(CFLAGS) -c $< -o $@
48
49build/$(APP)-shared: $(OBJS)
50	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
51
52build/$(APP)-static: $(OBJS)
53	$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
54
55build:
56	@mkdir -p $@
57
58.PHONY: clean
59clean:
60	rm -f build/$(APP)* build/*.o
61	test -d build && rmdir -p build || true
62