xref: /dpdk/examples/vhost_crypto/Makefile (revision 291d0903)
1f5188211SFan Zhang# SPDX-License-Identifier: BSD-3-Clause
2f5188211SFan Zhang# Copyright(c) 2017-2018 Intel Corporation
3f5188211SFan Zhang
4*291d0903SBruce Richardson# binary name
5*291d0903SBruce RichardsonAPP = vhost-crypto
6*291d0903SBruce Richardson
7*291d0903SBruce Richardson# all source are stored in SRCS-y
8*291d0903SBruce RichardsonSRCS-y := main.c
9*291d0903SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API
10*291d0903SBruce Richardson
11*291d0903SBruce Richardson# Build using pkg-config variables if possible
12*291d0903SBruce Richardson$(shell pkg-config --exists libdpdk)
13*291d0903SBruce Richardsonifeq ($(.SHELLSTATUS),0)
14*291d0903SBruce Richardson
15*291d0903SBruce Richardsonall: shared
16*291d0903SBruce Richardson.PHONY: shared static
17*291d0903SBruce Richardsonshared: build/$(APP)-shared
18*291d0903SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
19*291d0903SBruce Richardsonstatic: build/$(APP)-static
20*291d0903SBruce Richardson	ln -sf $(APP)-static build/$(APP)
21*291d0903SBruce Richardson
22*291d0903SBruce RichardsonPKGCONF=pkg-config --define-prefix
23*291d0903SBruce Richardson
24*291d0903SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk)
25*291d0903SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
26*291d0903SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
27*291d0903SBruce RichardsonLDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
28*291d0903SBruce Richardson
29*291d0903SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
30*291d0903SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
31*291d0903SBruce Richardson
32*291d0903SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
33*291d0903SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
34*291d0903SBruce Richardson
35*291d0903SBruce Richardsonbuild:
36*291d0903SBruce Richardson	@mkdir -p $@
37*291d0903SBruce Richardson
38*291d0903SBruce Richardson.PHONY: clean
39*291d0903SBruce Richardsonclean:
40*291d0903SBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
41*291d0903SBruce Richardson	test -d build && rmdir -p build || true
42*291d0903SBruce Richardson
43*291d0903SBruce Richardsonelse
44*291d0903SBruce Richardson
45f5188211SFan Zhangifeq ($(RTE_SDK),)
46f5188211SFan Zhang$(error "Please define RTE_SDK environment variable")
47f5188211SFan Zhangendif
48f5188211SFan Zhang
49e9c65942SBruce Richardson# Default target, detect a build directory, by looking for a path with a .config
50e9c65942SBruce RichardsonRTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config)))))
51f5188211SFan Zhang
52f5188211SFan Zhanginclude $(RTE_SDK)/mk/rte.vars.mk
53f5188211SFan Zhang
54742bde12SBruce Richardsonifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y)
55218c4e68SBruce Richardson$(info This application can only operate in a linux environment, \
56f5188211SFan Zhangplease change the definition of the RTE_TARGET environment variable)
57f5188211SFan Zhangall:
58f5188211SFan Zhangelse
59f5188211SFan Zhang
60f5188211SFan ZhangCFLAGS += -DALLOW_EXPERIMENTAL_API
61f5188211SFan ZhangCFLAGS += -O2 -D_FILE_OFFSET_BITS=64
62f5188211SFan ZhangCFLAGS += $(WERROR_FLAGS)
63f5188211SFan Zhang
64f5188211SFan Zhanginclude $(RTE_SDK)/mk/rte.extapp.mk
65f5188211SFan Zhang
66*291d0903SBruce Richardsonendif # Linux
67*291d0903SBruce Richardson
68*291d0903SBruce Richardsonendif # pkg-config
69