Rather than having an "if" statement in the makefile to select one of two files to build, we can put #ifdefs into the C files themselves so that all files are always built.
This is a better approach as the makefile-based approach relies on having the DPDK build system with all it's config settings available. When building using info from a pkg-config file, this build configuration information is not going to be available to the makefile - though it will be available to the preprocessor through rte_config.h header. Signed-off-by: Bruce Richardson <bruce.richard...@intel.com> --- examples/vm_power_manager/Makefile | 3 --- examples/vm_power_manager/meson.build | 16 ++++++++-------- examples/vm_power_manager/oob_monitor_nop.c | 4 ++++ examples/vm_power_manager/oob_monitor_x86.c | 4 ++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile index d93f900f7..6e573916a 100644 --- a/examples/vm_power_manager/Makefile +++ b/examples/vm_power_manager/Makefile @@ -20,11 +20,8 @@ APP = vm_power_mgr # all source are stored in SRCS-y SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c SRCS-y += channel_monitor.c parse.c -ifeq ($(CONFIG_RTE_ARCH_X86_64),y) SRCS-y += oob_monitor_x86.c -else SRCS-y += oob_monitor_nop.c -endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) diff --git a/examples/vm_power_manager/meson.build b/examples/vm_power_manager/meson.build index f98445bc6..384c778ef 100644 --- a/examples/vm_power_manager/meson.build +++ b/examples/vm_power_manager/meson.build @@ -22,16 +22,16 @@ deps += ['power'] sources = files( - 'channel_manager.c', 'channel_monitor.c', 'main.c', 'parse.c', 'power_manager.c', 'vm_power_cli.c' + 'channel_manager.c', + 'channel_monitor.c', + 'main.c', + 'oob_monitor_nop.c', + 'oob_monitor_x86.c', + 'parse.c', + 'power_manager.c', + 'vm_power_cli.c' ) -# If we're on X86, pull in the x86 code for the branch monitor algo. -if dpdk_conf.has('RTE_ARCH_X86_64') - sources += files('oob_monitor_x86.c') -else - sources += files('oob_monitor_nop.c') -endif - opt_dep = cc.find_library('virt', required : false) build = opt_dep.found() ext_deps += opt_dep diff --git a/examples/vm_power_manager/oob_monitor_nop.c b/examples/vm_power_manager/oob_monitor_nop.c index 7e7b8bc14..90daa7e9b 100644 --- a/examples/vm_power_manager/oob_monitor_nop.c +++ b/examples/vm_power_manager/oob_monitor_nop.c @@ -2,6 +2,8 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#ifndef RTE_ARCH_X86_64 /* X86_64 has separate implementation in another file */ + #include "oob_monitor.h" void branch_monitor_exit(void) @@ -36,3 +38,5 @@ void run_branch_monitor(void) { } + +#endif diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c index ebd96b205..f41bba6ab 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -2,6 +2,8 @@ * Copyright(c) 2018 Intel Corporation */ +#ifdef RTE_ARCH_X86_64 /* this file is only for X86_64 */ + #include <unistd.h> #include <fcntl.h> #include <rte_log.h> @@ -269,3 +271,5 @@ run_branch_monitor(void) } } } + +#endif /* RTE_ARCH_X86_64 */ -- 2.20.1