1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2010-2014 Intel Corporation 3 4# binary name 5APP = vhost-blk 6 7# all source are stored in SRCS-y 8SRCS-y := blk.c vhost_blk.c vhost_blk_compat.c 9 10# Build using pkg-config variables if possible 11$(shell pkg-config --exists libdpdk) 12ifeq ($(.SHELLSTATUS),0) 13 14all: shared 15.PHONY: shared static 16shared: build/$(APP)-shared 17 ln -sf $(APP)-shared build/$(APP) 18static: build/$(APP)-static 19 ln -sf $(APP)-static build/$(APP) 20 21PKGCONF ?= pkg-config 22 23LDFLAGS += -pthread 24 25PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 26CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 27LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 28LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) 29 30CFLAGS += -DALLOW_EXPERIMENTAL_API 31 32build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 33 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 34 35build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 36 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 37 38build: 39 @mkdir -p $@ 40 41.PHONY: clean 42clean: 43 rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 44 test -d build && rmdir -p build || true 45 46else # Build using legacy build system 47 48ifeq ($(RTE_SDK),) 49$(error "Please define RTE_SDK environment variable") 50endif 51 52# Default target, detect a build directory, by looking for a path with a .config 53RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) 54 55include $(RTE_SDK)/mk/rte.vars.mk 56 57ifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) 58$(info This application can only operate in a linux environment, \ 59please change the definition of the RTE_TARGET environment variable) 60all: 61else 62 63CFLAGS += -DALLOW_EXPERIMENTAL_API 64CFLAGS += -O2 -D_FILE_OFFSET_BITS=64 65CFLAGS += $(WERROR_FLAGS) 66 67include $(RTE_SDK)/mk/rte.extapp.mk 68 69endif 70endif 71