xref: /dpdk/examples/vhost_crypto/Makefile (revision 11e02702)
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
11*11e02702SJerin JacobPKGCONF ?= pkg-config
12*11e02702SJerin Jacob
13291d0903SBruce Richardson# Build using pkg-config variables if possible
14*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
15fda34680SCiara Power$(error "no installation of DPDK found")
16fda34680SCiara Powerendif
17291d0903SBruce Richardson
18291d0903SBruce Richardsonall: shared
19291d0903SBruce Richardson.PHONY: shared static
20291d0903SBruce Richardsonshared: build/$(APP)-shared
21291d0903SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
22291d0903SBruce Richardsonstatic: build/$(APP)-static
23291d0903SBruce Richardson	ln -sf $(APP)-static build/$(APP)
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
305a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static)
315a196330SBruce Richardson# check for broken pkg-config
325a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
335a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.")
345a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config")
355a196330SBruce Richardsonendif
365a196330SBruce Richardsonendif
375a196330SBruce 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