1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2010-2020 Intel Corporation 3 4# Build using pkg-config variables if possible 5ifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 6$(error "no installation of DPDK found") 7endif 8 9# binary name 10APP = vm_power_mgr 11 12# all source are stored in SRCS-y 13SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c 14SRCS-y += channel_monitor.c parse.c 15ifeq ($(shell uname -m),x86_64) 16SRCS-y += oob_monitor_x86.c 17else 18SRCS-y += oob_monitor_nop.c 19endif 20 21all: shared 22.PHONY: shared static 23shared: build/$(APP)-shared 24 ln -sf $(APP)-shared build/$(APP) 25static: build/$(APP)-static 26 ln -sf $(APP)-static build/$(APP) 27 28PKGCONF ?= pkg-config 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 35ifneq ($(shell $(PKGCONF) --atleast-version=0.9.3 libvirt; echo $$?), 0) 36$(error vm_power_manager requires libvirt >= 0.9.3) 37endif 38LDFLAGS += $(shell $(PKGCONF) --libs libvirt) 39 40JANSSON := $(shell $(PKGCONF) --exists jansson; echo $$?) 41ifeq ($(JANSSON), 0) 42LDFLAGS += $(shell $(PKGCONF) --libs jansson) 43CFLAGS += -DUSE_JANSSON 44endif 45 46# for shared library builds, we need to explicitly link these PMDs 47LDFLAGS_SHARED += -lrte_pmd_ixgbe -lrte_pmd_i40e -lrte_pmd_bnxt 48 49build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build 50 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) 51 52build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build 53 $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) 54 55build: 56 @mkdir -p $@ 57 58.PHONY: clean 59clean: 60 rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared 61 test -d build && rmdir -p build || true 62