xref: /dpdk/examples/ntb/Makefile (revision 11e02702)
1c5eebf85SXiaoyun Li# SPDX-License-Identifier: BSD-3-Clause
2c5eebf85SXiaoyun Li# Copyright(c) 2019 Intel Corporation
3c5eebf85SXiaoyun Li
4c5eebf85SXiaoyun Li# binary name
5c5eebf85SXiaoyun LiAPP = ntb_fwd
6c5eebf85SXiaoyun Li
7c5eebf85SXiaoyun Li# all source are stored in SRCS-y
8c5eebf85SXiaoyun LiSRCS-y := ntb_fwd.c
9c5eebf85SXiaoyun Li
10*11e02702SJerin JacobPKGCONF ?= pkg-config
11*11e02702SJerin Jacob
12c5eebf85SXiaoyun Li# Build using pkg-config variables if possible
13*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
14fda34680SCiara Power$(error "no installation of DPDK found")
15fda34680SCiara Powerendif
16c5eebf85SXiaoyun Li
17c5eebf85SXiaoyun Liall: shared
18c5eebf85SXiaoyun Li.PHONY: shared static
19c5eebf85SXiaoyun Lishared: build/$(APP)-shared
20c5eebf85SXiaoyun Li	ln -sf $(APP)-shared build/$(APP)
21c5eebf85SXiaoyun Listatic: build/$(APP)-static
22c5eebf85SXiaoyun Li	ln -sf $(APP)-static build/$(APP)
23c5eebf85SXiaoyun Li
24c5eebf85SXiaoyun LiCFLAGS += -D_FILE_OFFSET_BITS=64
25c5eebf85SXiaoyun LiLDFLAGS += -pthread
26c5eebf85SXiaoyun Li
2769b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
2812a652a0SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
2912a652a0SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
308549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
31c5eebf85SXiaoyun Li
325a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
335a196330SBruce Richardson# check for broken pkg-config
345a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
355a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
365a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
375a196330SBruce Richardsonendif
385a196330SBruce Richardsonendif
395a196330SBruce Richardson
405a196330SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API
415a196330SBruce Richardson
42c5eebf85SXiaoyun Libuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
43c5eebf85SXiaoyun Li	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
44c5eebf85SXiaoyun Li
45c5eebf85SXiaoyun Libuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
46c5eebf85SXiaoyun Li	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
47c5eebf85SXiaoyun Li
48c5eebf85SXiaoyun Libuild:
49c5eebf85SXiaoyun Li	@mkdir -p $@
50c5eebf85SXiaoyun Li
51c5eebf85SXiaoyun Li.PHONY: clean
52c5eebf85SXiaoyun Liclean:
53c5eebf85SXiaoyun Li	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
549bb2997cSDavid Marchand	test -d build && rmdir -p build || true
55