1project( 2 'phosphor-pid-control', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 ] 10) 11 12cxx = meson.get_compiler('cpp') 13 14conf_data = configuration_data() 15 16bindir = get_option('prefix') / get_option('bindir') 17conf_data.set('BINDIR', bindir) 18conf_data.set('SYSTEMD_TARGET', get_option('systemd_target')) 19conf_data.set('STRICT_FAILSAFE_PWM', get_option('strict-failsafe-pwm')) 20conf_data.set('OFFLINE_FAILSAFE_PWM', get_option('offline-failsafe-pwm')) 21 22configure_file(output: 'config.h', 23 configuration: conf_data 24) 25 26if get_option('oe-sdk').allowed() 27 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() 28 if OECORE_TARGET_SYSROOT == '' 29 error('OECORE_TARGET_SYSROOT must be set with enable oe-sdk') 30 endif 31 message('Enabling OE-SDK at OECORE_TARGET_SYSROOT: ' + OECORE_TARGET_SYSROOT) 32 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) 33 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() 34 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 35else 36 dynamic_linker = [] 37endif 38 39systemd = dependency('systemd') 40systemd_system_unit_dir = systemd.get_variable( 41 'systemdsystemunitdir', 42 pkgconfig_define: ['prefix', get_option('prefix')]) 43 44configure_file(input: 'phosphor-pid-control.service.in', 45 output: 'phosphor-pid-control.service', 46 configuration: conf_data, 47 install: true, 48 install_dir: systemd_system_unit_dir) 49 50nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 51phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 52phosphor_logging_dep = dependency('phosphor-logging') 53sdbusplus_dep = dependency('sdbusplus') 54libsystemd_dep = dependency('libsystemd') 55ipmid_dep = dependency('libipmid') 56 57 58if cxx.has_header('CLI/CLI.hpp') 59 CLI11_dep = declare_dependency() 60else 61 CLI11_dep = dependency('CLI11') 62endif 63 64deps = [ 65 CLI11_dep, 66 ipmid_dep, 67 libsystemd_dep, 68 nlohmann_json_dep, 69 phosphor_dbus_interfaces_dep, 70 phosphor_logging_dep, 71 sdbusplus_dep, 72] 73 74root_inc = include_directories( 75 '.', 76 'buildjson', 77 'dbus', 78 'errors', 79 'experiments', 80 'ipmi', 81 'notimpl', 82 'pid', 83 'sensors', 84 'sysfs', 85) 86 87setsensor_sources = [ 88 'setsensor.cpp' 89] 90 91libswampd_sources = [ 92 'main.cpp', 93 'util.cpp', 94 'notimpl/readonly.cpp', 95 'notimpl/writeonly.cpp', 96 'dbus/dbusconfiguration.cpp', 97 'dbus/dbusutil.cpp', 98 'dbus/dbushelper.cpp', 99 'dbus/dbuspassiveredundancy.cpp', 100 'dbus/dbuspassive.cpp', 101 'dbus/dbusactiveread.cpp', 102 'dbus/dbuswrite.cpp', 103 'sysfs/sysfsread.cpp', 104 'sysfs/sysfswrite.cpp', 105 'sysfs/util.cpp', 106 'sensors/pluggable.cpp', 107 'sensors/host.cpp', 108 'sensors/builder.cpp', 109 'sensors/buildjson.cpp', 110 'sensors/manager.cpp', 111 'sensors/build_utils.cpp', 112 'pid/ec/pid.cpp', 113 'pid/ec/logging.cpp', 114 'pid/ec/stepwise.cpp', 115 'pid/fancontroller.cpp', 116 'pid/thermalcontroller.cpp', 117 'pid/pidcontroller.cpp', 118 'pid/stepwisecontroller.cpp', 119 'pid/builder.cpp', 120 'pid/buildjson.cpp', 121 'pid/zone.cpp', 122 'pid/util.cpp', 123 'pid/pidloop.cpp', 124 'pid/tuning.cpp', 125 'buildjson/buildjson.cpp', 126 'experiments/drive.cpp', 127] 128 129libmanualcmds_sources = [ 130 'ipmi/main_ipmi.cpp', 131 'ipmi/manualcmds.cpp', 132 'ipmi/dbus_mode.cpp', 133] 134 135libmanualcmds = library( 136 'manualcmds', 137 libmanualcmds_sources, 138 implicit_include_directories: false, 139 dependencies: deps, 140 version: meson.project_version(), 141 override_options: ['b_lundef=false'], 142 install: true, 143 install_dir: get_option('libdir') / 'ipmid-providers') 144 145executable( 146 'swampd', 147 libswampd_sources, 148 implicit_include_directories: false, 149 include_directories: root_inc, 150 dependencies: deps, 151 install: true, 152 install_dir: get_option('bindir') 153) 154 155executable( 156 'setsensor', 157 setsensor_sources, 158 implicit_include_directories: true, 159 dependencies: deps, 160 install: true, 161 install_dir: get_option('bindir') 162) 163 164if not get_option('tests').disabled() 165 subdir('test') 166endif 167