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 11*11e02702SJerin JacobPKGCONF ?= pkg-config 12*11e02702SJerin Jacob 13f3558ec2SBruce Richardson# Build using pkg-config variables if possible 14*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 15fda34680SCiara Power$(error "no installation of DPDK found") 16fda34680SCiara Powerendif 17f3558ec2SBruce Richardson 18f3558ec2SBruce Richardsonall: shared 19f3558ec2SBruce Richardson.PHONY: shared static 20f3558ec2SBruce Richardsonshared: build/$(APP)-shared 21f3558ec2SBruce Richardson ln -sf $(APP)-shared build/$(APP) 22f3558ec2SBruce Richardsonstatic: build/$(APP)-static 23f3558ec2SBruce Richardson ln -sf $(APP)-static build/$(APP) 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 305a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 315a196330SBruce Richardson# check for broken pkg-config 325a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 335a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 345a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 355a196330SBruce Richardsonendif 365a196330SBruce Richardsonendif 375a196330SBruce 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