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