13998e2a0SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 25adbc4b8SBruce Richardson# Copyright(c) 2010-2020 Intel Corporation 38db653ffSAlan Carew 4*11e02702SJerin JacobPKGCONF ?= pkg-config 5*11e02702SJerin Jacob 65adbc4b8SBruce Richardson# Build using pkg-config variables if possible 7*11e02702SJerin Jacobifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 85adbc4b8SBruce Richardson$(error "no installation of DPDK found") 98db653ffSAlan Carewendif 108db653ffSAlan Carew 1122119c45SBruce Richardson# binary name 1222119c45SBruce RichardsonAPP = vm_power_mgr 1322119c45SBruce Richardson 1422119c45SBruce Richardson# all source are stored in SRCS-y 1522119c45SBruce RichardsonSRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c 1699a968faSDavid HuntSRCS-y += channel_monitor.c parse.c 175adbc4b8SBruce Richardsonifeq ($(shell uname -m),x86_64) 184b1a631bSDavid HuntSRCS-y += oob_monitor_x86.c 194b1a631bSDavid Huntelse 204b1a631bSDavid HuntSRCS-y += oob_monitor_nop.c 214b1a631bSDavid Huntendif 2222119c45SBruce Richardson 235adbc4b8SBruce Richardsonall: shared 245adbc4b8SBruce Richardson.PHONY: shared static 255adbc4b8SBruce Richardsonshared: build/$(APP)-shared 265adbc4b8SBruce Richardson ln -sf $(APP)-shared build/$(APP) 275adbc4b8SBruce Richardsonstatic: build/$(APP)-static 285adbc4b8SBruce Richardson ln -sf $(APP)-static build/$(APP) 298db653ffSAlan Carew 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 355a196330SBruce Richardsonifeq ($(MAKECMDGOALS),static) 365a196330SBruce Richardson# check for broken pkg-config 375a196330SBruce Richardsonifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 385a196330SBruce Richardson$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 395a196330SBruce Richardson$(error "Cannot generate statically-linked binaries with this version of pkg-config") 405a196330SBruce Richardsonendif 415a196330SBruce Richardsonendif 425a196330SBruce 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