1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2018 Intel Corporation
7 # all source are stored in SRCS-y
25 # Build using pkg-config variables if possible
26 ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
27 $(error "no installation of DPDK found")
32 shared: build/$(APP)-shared
33 ln -sf $(APP)-shared build/$(APP)
34 static: build/$(APP)-static
35 ln -sf $(APP)-static build/$(APP)
37 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
38 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
39 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
40 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
42 ifeq ($(MAKECMDGOALS),static)
43 # check for broken pkg-config
44 ifeq ($(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")
50 CFLAGS += -I. -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE
52 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
54 build/%.o: %.c Makefile $(PC_FILE) | build
55 $(CC) $(CFLAGS) -c $< -o $@
57 build/$(APP)-shared: $(OBJS)
58 $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
60 build/$(APP)-static: $(OBJS)
61 $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
68 rm -f build/$(APP)* build/*.o
69 test -d build && rmdir -p build || true