1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2010-2020 Intel Corporation 3 4PKGCONF ?= pkg-config 5 6# Build using pkg-config variables if possible 7ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) 8$(error "no installation of DPDK found") 9endif 10 11# binary name 12APP = vm_power_mgr 13 14# all source are stored in SRCS-y 15SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c 16SRCS-y += channel_monitor.c parse.c 17ifeq ($(shell uname -m),x86_64) 18SRCS-y += oob_monitor_x86.c 19else 20SRCS-y += oob_monitor_nop.c 21endif 22 23all: shared 24.PHONY: shared static 25shared: build/$(APP)-shared 26 ln -sf $(APP)-shared build/$(APP) 27static: build/$(APP)-static 28 ln -sf $(APP)-static build/$(APP) 29 30PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) 31CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) 32LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) 33LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) 34 35ifeq ($(MAKECMDGOALS),static) 36# check for broken pkg-config 37ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) 38$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") 39$(error "Cannot generate statically-linked binaries with this version of pkg-config") 40endif 41endif 42 43CFLAGS += -DALLOW_EXPERIMENTAL_API 44 45ifneq ($(shell $(PKGCONF) --atleast-version=0.9.3 libvirt; echo $$?), 0) 46$(error vm_power_manager requires libvirt >= 0.9.3) 47endif 48LDFLAGS += $(shell $(PKGCONF) --libs libvirt) 49 50JANSSON := $(shell $(PKGCONF) --exists jansson; echo $$?) 51ifeq ($(JANSSON), 0) 52LDFLAGS += $(shell $(PKGCONF) --libs jansson) 53CFLAGS += -DUSE_JANSSON 54endif 55 56# for shared library builds, we need to explicitly link these PMDs 57LDFLAGS_SHARED += -lrte_net_ixgbe -lrte_net_i40e -lrte_net_bnxt 58 59build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 60 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 61 62build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 63 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 64 65build: 66 @mkdir -p $@ 67 68.PHONY: clean 69clean: 70 rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 71 test -d build && rmdir -p build || true 72