13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 25adbc4b8SBruce 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*11e02702SJerin JacobPKGCONF ?= pkg-config 11*11e02702SJerin Jacob 125adbc4b8SBruce Richardson# Build using pkg-config variables if possible 13*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 145adbc4b8SBruce Richardson$(error "no installation of DPDK found") 15f5e5c334SAlan Carewendif 16f5e5c334SAlan Carew 175adbc4b8SBruce Richardsonall: shared 185adbc4b8SBruce Richardson.PHONY: shared static 195adbc4b8SBruce Richardsonshared: build/$(APP)-shared 205adbc4b8SBruce Richardson ln -sf $(APP)-shared build/$(APP) 215adbc4b8SBruce Richardsonstatic: build/$(APP)-static 225adbc4b8SBruce Richardson ln -sf $(APP)-static build/$(APP) 235adbc4b8SBruce Richardson 245adbc4b8SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 255adbc4b8SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 265adbc4b8SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 275adbc4b8SBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 285adbc4b8SBruce Richardson 295a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 305a196330SBruce Richardson# check for broken pkg-config 315a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 325a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 335a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 345a196330SBruce Richardsonendif 355a196330SBruce Richardsonendif 365a196330SBruce Richardson 37bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API 38bc8e3247SDavid Marchand 395adbc4b8SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 405adbc4b8SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 415adbc4b8SBruce Richardson 425adbc4b8SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 435adbc4b8SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 445adbc4b8SBruce Richardson 455adbc4b8SBruce Richardsonbuild: 465adbc4b8SBruce Richardson @mkdir -p $@ 475adbc4b8SBruce Richardson 485adbc4b8SBruce Richardson.PHONY: clean 495adbc4b8SBruce Richardsonclean: 505adbc4b8SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 515adbc4b8SBruce Richardson test -d build && rmdir -p build || true 52