109b7caa4ea86d60ecb73ee6e6128cc6664ff94d
[dpdk.git] / examples / l2fwd-event / Makefile
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(C) 2019 Marvell International Ltd.
3 #
4
5 # binary name
6 APP = l2fwd-event
7
8 # all source are stored in SRCS-y
9 SRCS-y := main.c
10 SRCS-y += l2fwd_poll.c
11 SRCS-y += l2fwd_event.c
12 SRCS-y += l2fwd_common.c
13 SRCS-y += l2fwd_event_generic.c
14 SRCS-y += l2fwd_event_internal_port.c
15
16 # Build using pkg-config variables if possible
17 ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
18 $(error "no installation of DPDK found")
19 endif
20
21 all: shared
22 .PHONY: shared static
23 shared: build/$(APP)-shared
24         ln -sf $(APP)-shared build/$(APP)
25 static: build/$(APP)-static
26         ln -sf $(APP)-static build/$(APP)
27
28 PKGCONF ?= pkg-config
29
30 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
31 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
32 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
33 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
34
35 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
36         $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
37
38 build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
39         $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
40
41 build:
42         @mkdir -p $@
43
44 .PHONY: clean
45 clean:
46         rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
47         test -d build && rmdir -p build || true