13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 25adbc4b8SBruce Richardson# Copyright(c) 2010-2020 Intel Corporation 38db653ffSAlan Carew 45adbc4b8SBruce Richardson# Build using pkg-config variables if possible 55adbc4b8SBruce Richardsonifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 65adbc4b8SBruce Richardson$(error "no installation of DPDK found") 78db653ffSAlan Carewendif 88db653ffSAlan Carew 922119c45SBruce Richardson# binary name 1022119c45SBruce RichardsonAPP = vm_power_mgr 1122119c45SBruce Richardson 1222119c45SBruce Richardson# all source are stored in SRCS-y 1322119c45SBruce RichardsonSRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c 1499a968faSDavid HuntSRCS-y += channel_monitor.c parse.c 155adbc4b8SBruce Richardsonifeq ($(shell uname -m),x86_64) 164b1a631bSDavid HuntSRCS-y += oob_monitor_x86.c 174b1a631bSDavid Huntelse 184b1a631bSDavid HuntSRCS-y += oob_monitor_nop.c 194b1a631bSDavid Huntendif 2022119c45SBruce Richardson 215adbc4b8SBruce Richardsonall: shared 225adbc4b8SBruce Richardson.PHONY: shared static 235adbc4b8SBruce Richardsonshared: build/$(APP)-shared 245adbc4b8SBruce Richardson ln -sf $(APP)-shared build/$(APP) 255adbc4b8SBruce Richardsonstatic: build/$(APP)-static 265adbc4b8SBruce Richardson ln -sf $(APP)-static build/$(APP) 278db653ffSAlan Carew 285adbc4b8SBruce RichardsonPKGCONF ?= pkg-config 292e099bc5SOlivier Matz 305adbc4b8SBruce RichardsonPC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 315adbc4b8SBruce RichardsonCFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 325adbc4b8SBruce RichardsonLDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 335adbc4b8SBruce RichardsonLDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 345adbc4b8SBruce Richardson 35*5a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 36*5a196330SBruce Richardson# check for broken pkg-config 37*5a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 38*5a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 39*5a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 40*5a196330SBruce Richardsonendif 41*5a196330SBruce Richardsonendif 42*5a196330SBruce Richardson 43bc8e3247SDavid MarchandCFLAGS += -DALLOW_EXPERIMENTAL_API 44bc8e3247SDavid Marchand 455adbc4b8SBruce Richardsonifneq ($(shell $(PKGCONF) --atleast-version=0.9.3 libvirt; echo $$?), 0) 465adbc4b8SBruce Richardson$(error vm_power_manager requires libvirt >= 0.9.3) 475adbc4b8SBruce Richardsonendif 485adbc4b8SBruce RichardsonLDFLAGS += $(shell $(PKGCONF) --libs libvirt) 495adbc4b8SBruce Richardson 505adbc4b8SBruce RichardsonJANSSON := $(shell $(PKGCONF) --exists jansson; echo $$?) 51a63504a9SDavid Huntifeq ($(JANSSON), 0) 525adbc4b8SBruce RichardsonLDFLAGS += $(shell $(PKGCONF) --libs jansson) 53a63504a9SDavid HuntCFLAGS += -DUSE_JANSSON 54a63504a9SDavid Huntendif 55a63504a9SDavid Hunt 565adbc4b8SBruce Richardson# for shared library builds, we need to explicitly link these PMDs 577157a9dcSBruce RichardsonLDFLAGS_SHARED += -lrte_net_ixgbe -lrte_net_i40e -lrte_net_bnxt 58f14791a8SRory Sexton 595adbc4b8SBruce Richardsonbuild/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 605adbc4b8SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 61f14791a8SRory Sexton 625adbc4b8SBruce Richardsonbuild/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 635adbc4b8SBruce Richardson $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 64f14791a8SRory Sexton 655adbc4b8SBruce Richardsonbuild: 665adbc4b8SBruce Richardson @mkdir -p $@ 67f14791a8SRory Sexton 685adbc4b8SBruce Richardson.PHONY: clean 695adbc4b8SBruce Richardsonclean: 705adbc4b8SBruce Richardson rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 715adbc4b8SBruce Richardson test -d build && rmdir -p build || true 72