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