-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
45 lines (35 loc) · 1.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
BUILDDIR=objs
SRCDIR=src
DPDKCOMMONSRC := dpdk_common.c
DPDKCOMMONOBJ := dpdk_common.o
PKGCONF ?= pkg-config
# Build using pkg-config variables if possible
ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
$(error "no installation of DPDK found")
endif
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
# Add flag to allow experimental API as forwarding uses rte_ethdev_set_ptype API.
CFLAGS += -DALLOW_EXPERIMENTAL_API
LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
ifeq ($(MAKECMDGOALS),static)
# check for broken pkg-config
ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
$(error "Cannot generate statically-linked binaries with this version of pkg-config")
endif
endif
all: static shared
.PHONY: all
makebuilddir:
mkdir -p $(BUILDDIR)/static
mkdir -p $(BUILDDIR)/shared
static: $(SRCDIR)/$(DPDKCOMMONSRC) Makefile $(PC_FILE) | makebuilddir
$(CC) -c $(CFLAGS) $(SRCDIR)/$(DPDKCOMMONSRC) -o $(BUILDDIR)/static/$(DPDKCOMMONOBJ) $(LDFLAGS) $(LDFLAGS_STATIC)
shared: $(SRCDIR)/$(DPDKCOMMONSRC) Makefile $(PC_FILE) | makebuilddir
$(CC) -c $(CFLAGS) $(SRCDIR)/$(DPDKCOMMONSRC) -o $(BUILDDIR)/shared/$(DPDKCOMMONOBJ) $(LDFLAGS) $(LDFLAGS_SHARED)
.PHONY: clean
clean:
rm -f $(BUILDDIR)/static/$(DPDKCOMMONOBJ)
rm -f $(BUILDDIR)/shared/$(DPDKCOMMONOBJ)