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