examples: use pkg-config in makefiles
[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 CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
15
16 PC_FILE := $(shell pkg-config --path libdpdk)
17 CFLAGS += $(shell pkg-config --cflags libdpdk)
18 LDFLAGS += $(shell pkg-config --libs libdpdk)
19
20 build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
21         $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
22
23 build:
24         @mkdir -p $@
25
26 .PHONY: clean
27 clean:
28         rm -f build/$(APP)
29         rmdir --ignore-fail-on-non-empty build
30
31 else # Build using legacy build system
32
33 ifeq ($(RTE_SDK),)
34 $(error "Please define RTE_SDK environment variable")
35 endif
36
37 # Default target, can be overridden by command line or environment
38 RTE_TARGET ?= x86_64-native-linuxapp-gcc
39
40 include $(RTE_SDK)/mk/rte.vars.mk
41
42 ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
43 $(info This application can only operate in a linuxapp environment, \
44 please change the definition of the RTE_TARGET environment variable)
45 all:
46 else
47
48 CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
49 CFLAGS += -O2
50 CFLAGS += $(WERROR_FLAGS)
51
52 include $(RTE_SDK)/mk/rte.extapp.mk
53
54 endif
55 endif