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 10c5eebf85SXiaoyun Li# Build using pkg-config variables if possible 11fda34680SCiara Powerifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 12fda34680SCiara Power$(error "no installation of DPDK found") 13fda34680SCiara Powerendif 14c5eebf85SXiaoyun Li 15c5eebf85SXiaoyun Liall: shared 16c5eebf85SXiaoyun Li.PHONY: shared static 17c5eebf85SXiaoyun Lishared: build/$(APP)-shared 18c5eebf85SXiaoyun Li ln -sf $(APP)-shared build/$(APP) 19c5eebf85SXiaoyun Listatic: build/$(APP)-static 20c5eebf85SXiaoyun Li ln -sf $(APP)-static build/$(APP) 21c5eebf85SXiaoyun Li 2212a652a0SBruce RichardsonPKGCONF ?= pkg-config 2312a652a0SBruce Richardson 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 32*5a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 33*5a196330SBruce Richardson# check for broken pkg-config 34*5a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 35*5a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 36*5a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 37*5a196330SBruce Richardsonendif 38*5a196330SBruce Richardsonendif 39*5a196330SBruce Richardson 40*5a196330SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API 41*5a196330SBruce 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