13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
2*5adbc4b8SBruce Richardson# Copyright(c) 2010-2020 Intel Corporation
3f5e5c334SAlan Carew
4f5e5c334SAlan Carew# binary name
5f5e5c334SAlan CarewAPP = guest_vm_power_mgr
6f5e5c334SAlan Carew
7f5e5c334SAlan Carew# all source are stored in SRCS-y
859287933SDavid HuntSRCS-y := main.c vm_power_cli_guest.c parse.c
9f5e5c334SAlan Carew
10*5adbc4b8SBruce Richardson# Build using pkg-config variables if possible
11*5adbc4b8SBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
12*5adbc4b8SBruce Richardson$(error "no installation of DPDK found")
13f5e5c334SAlan Carewendif
14f5e5c334SAlan Carew
15*5adbc4b8SBruce Richardsonall: shared
16*5adbc4b8SBruce Richardson.PHONY: shared static
17*5adbc4b8SBruce Richardsonshared: build/$(APP)-shared
18*5adbc4b8SBruce Richardson	ln -sf $(APP)-shared build/$(APP)
19*5adbc4b8SBruce Richardsonstatic: build/$(APP)-static
20*5adbc4b8SBruce Richardson	ln -sf $(APP)-static build/$(APP)
21*5adbc4b8SBruce Richardson
22*5adbc4b8SBruce RichardsonPKGCONF ?= pkg-config
23*5adbc4b8SBruce Richardson
24*5adbc4b8SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
25*5adbc4b8SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
26*5adbc4b8SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
27*5adbc4b8SBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
28*5adbc4b8SBruce Richardson
29*5adbc4b8SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
30*5adbc4b8SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
31*5adbc4b8SBruce Richardson
32*5adbc4b8SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
33*5adbc4b8SBruce Richardson	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
34*5adbc4b8SBruce Richardson
35*5adbc4b8SBruce Richardsonbuild:
36*5adbc4b8SBruce Richardson	@mkdir -p $@
37*5adbc4b8SBruce Richardson
38*5adbc4b8SBruce Richardson.PHONY: clean
39*5adbc4b8SBruce Richardsonclean:
40*5adbc4b8SBruce Richardson	rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
41*5adbc4b8SBruce Richardson	test -d build && rmdir -p build || true
42