1c19beb3fSJin Yu# SPDX-License-Identifier: BSD-3-Clause 2c19beb3fSJin Yu# Copyright(c) 2010-2014 Intel Corporation 3c19beb3fSJin Yu 4c19beb3fSJin Yu# binary name 5c19beb3fSJin YuAPP = vhost-blk 6c19beb3fSJin Yu 7c19beb3fSJin Yu# all source are stored in SRCS-y 8c19beb3fSJin YuSRCS-y := blk.c vhost_blk.c vhost_blk_compat.c 9c19beb3fSJin Yu 10*11e02702SJerin JacobPKGCONF ?= pkg-config 11*11e02702SJerin Jacob 12c19beb3fSJin Yu# 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 16c19beb3fSJin Yu 17c19beb3fSJin Yuall: shared 18c19beb3fSJin Yu.PHONY: shared static 19c19beb3fSJin Yushared: build/$(APP)-shared 20c19beb3fSJin Yu ln -sf $(APP)-shared build/$(APP) 21c19beb3fSJin Yustatic: build/$(APP)-static 22c19beb3fSJin Yu ln -sf $(APP)-static build/$(APP) 23c19beb3fSJin Yu 24c19beb3fSJin YuLDFLAGS += -pthread 25c19beb3fSJin Yu 2669b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 2712a652a0SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 2812a652a0SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 298549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 30c19beb3fSJin Yu 315a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 325a196330SBruce Richardson# check for broken pkg-config 335a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 345a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 355a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 365a196330SBruce Richardsonendif 375a196330SBruce Richardsonendif 385a196330SBruce Richardson 39c19beb3fSJin YuCFLAGS += -DALLOW_EXPERIMENTAL_API 40c19beb3fSJin Yu 41c19beb3fSJin Yubuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 42c19beb3fSJin Yu $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 43c19beb3fSJin Yu 44c19beb3fSJin Yubuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 45c19beb3fSJin Yu $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 46c19beb3fSJin Yu 47c19beb3fSJin Yubuild: 48c19beb3fSJin Yu @mkdir -p $@ 49c19beb3fSJin Yu 50c19beb3fSJin Yu.PHONY: clean 51c19beb3fSJin Yuclean: 52c19beb3fSJin Yu rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 53c19beb3fSJin Yu test -d build && rmdir -p build || true 54