1edbed86dSXiaolong Ye# SPDX-License-Identifier: BSD-3-Clause 2edbed86dSXiaolong Ye# Copyright(c) 2018 Intel Corporation 3edbed86dSXiaolong Ye 4f3558ec2SBruce Richardson# binary name 5f3558ec2SBruce RichardsonAPP = vdpa 6f3558ec2SBruce Richardson 7f3558ec2SBruce Richardson# all source are stored in SRCS-y 8f3558ec2SBruce RichardsonSRCS-y := main.c 9f3558ec2SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API 10f3558ec2SBruce Richardson 11f3558ec2SBruce Richardson# Build using pkg-config variables if possible 12fda34680SCiara Powerifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 13fda34680SCiara Power$(error "no installation of DPDK found") 14fda34680SCiara Powerendif 15f3558ec2SBruce Richardson 16f3558ec2SBruce Richardsonall: shared 17f3558ec2SBruce Richardson.PHONY: shared static 18f3558ec2SBruce Richardsonshared: build/$(APP)-shared 19f3558ec2SBruce Richardson ln -sf $(APP)-shared build/$(APP) 20f3558ec2SBruce Richardsonstatic: build/$(APP)-static 21f3558ec2SBruce Richardson ln -sf $(APP)-static build/$(APP) 22f3558ec2SBruce Richardson 2312a652a0SBruce RichardsonPKGCONF ?= pkg-config 24f3558ec2SBruce Richardson 2569b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 26f3558ec2SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 27f3558ec2SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 288549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 29f3558ec2SBruce Richardson 30*5a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 31*5a196330SBruce Richardson# check for broken pkg-config 32*5a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 33*5a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 34*5a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 35*5a196330SBruce Richardsonendif 36*5a196330SBruce Richardsonendif 37*5a196330SBruce Richardson 38f3558ec2SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 39f3558ec2SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 40f3558ec2SBruce Richardson 41f3558ec2SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 42f3558ec2SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 43f3558ec2SBruce Richardson 44f3558ec2SBruce Richardsonbuild: 45f3558ec2SBruce Richardson @mkdir -p $@ 46f3558ec2SBruce Richardson 47f3558ec2SBruce Richardson.PHONY: clean 48f3558ec2SBruce Richardsonclean: 49f3558ec2SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 50f3558ec2SBruce Richardson test -d build && rmdir -p build || true 51