xref: /dpdk/examples/vhost_crypto/Makefile (revision 5a196330)
1f5188211SFan Zhang# SPDX-License-Identifier: BSD-3-Clause
2f5188211SFan Zhang# Copyright(c) 2017-2018 Intel Corporation
3f5188211SFan Zhang
4291d0903SBruce Richardson# binary name
5291d0903SBruce RichardsonAPP = vhost-crypto
6291d0903SBruce Richardson
7291d0903SBruce Richardson# all source are stored in SRCS-y
8291d0903SBruce RichardsonSRCS-y := main.c
9291d0903SBruce RichardsonCFLAGS += -DALLOW_EXPERIMENTAL_API
10291d0903SBruce Richardson
11291d0903SBruce Richardson# Build using pkg-config variables if possible
12fda34680SCiara Powerifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
13fda34680SCiara Power$(error "no installation of DPDK found")
14fda34680SCiara Powerendif
15291d0903SBruce Richardson
16291d0903SBruce Richardsonall: shared
17291d0903SBruce Richardson.PHONY: shared static
18291d0903SBruce Richardsonshared: build/$(APP)-shared
19291d0903SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
20291d0903SBruce Richardsonstatic: build/$(APP)-static
21291d0903SBruce Richardson	ln -sf $(APP)-static build/$(APP)
22291d0903SBruce Richardson
2312a652a0SBruce RichardsonPKGCONF ?= pkg-config
24291d0903SBruce Richardson
2569b1bb49SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
26291d0903SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
27291d0903SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
288549295dSBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
29291d0903SBruce Richardson
30*5a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
31*5a196330SBruce Richardson# check for broken pkg-config
32*5a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
33*5a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
34*5a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
35*5a196330SBruce Richardsonendif
36*5a196330SBruce Richardsonendif
37*5a196330SBruce Richardson
38291d0903SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
39291d0903SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
40291d0903SBruce Richardson
41291d0903SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
42291d0903SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
43291d0903SBruce Richardson
44291d0903SBruce Richardsonbuild:
45291d0903SBruce Richardson	@mkdir -p $@
46291d0903SBruce Richardson
47291d0903SBruce Richardson.PHONY: clean
48291d0903SBruce Richardsonclean:
49291d0903SBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
50291d0903SBruce Richardson	test -d build && rmdir -p build || true
51