blob: 552634e496ae45b8e9dd931b2a18f6c8e99be2a4 [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',
Harvey.Wub1225b22022-10-28 17:42:07 +08009 ]
10)
11
Patrick Williamsa83fae52023-07-13 16:20:06 -050012cxx = meson.get_compiler('cpp')
13
Harvey.Wub1225b22022-10-28 17:42:07 +080014conf_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'))
20
21configure_file(output: 'config.h',
22 configuration: conf_data
23)
24
Patrick Williams397e6bc2023-11-29 06:44:45 -060025if get_option('oe-sdk').allowed()
Harvey.Wub1225b22022-10-28 17:42:07 +080026 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
27 if OECORE_TARGET_SYSROOT == ''
28 error('OECORE_TARGET_SYSROOT must be set with enable oe-sdk')
29 endif
30 message('Enabling OE-SDK at OECORE_TARGET_SYSROOT: ' + OECORE_TARGET_SYSROOT)
31 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
32 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
33 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
34else
35 dynamic_linker = []
36endif
37
38systemd = dependency('systemd')
39systemd_system_unit_dir = systemd.get_variable(
Patrick Williams7e6130a2023-04-12 08:01:19 -050040 'systemdsystemunitdir',
Harvey.Wub1225b22022-10-28 17:42:07 +080041 pkgconfig_define: ['prefix', get_option('prefix')])
42
43configure_file(input: 'phosphor-pid-control.service.in',
44 output: 'phosphor-pid-control.service',
45 configuration: conf_data,
46 install: true,
47 install_dir: systemd_system_unit_dir)
48
Patrick Williamsefda1ce2023-12-08 06:37:28 -060049nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Harvey.Wub1225b22022-10-28 17:42:07 +080050phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
51phosphor_logging_dep = dependency('phosphor-logging')
52sdbusplus_dep = dependency('sdbusplus')
53libsystemd_dep = dependency('libsystemd')
54ipmid_dep = dependency('libipmid')
55
Patrick Williamsa83fae52023-07-13 16:20:06 -050056
57if cxx.has_header('CLI/CLI.hpp')
58 CLI11_dep = declare_dependency()
59else
60 CLI11_dep = dependency('CLI11')
61endif
62
Harvey.Wub1225b22022-10-28 17:42:07 +080063deps = [
Patrick Williamsa83fae52023-07-13 16:20:06 -050064 CLI11_dep,
65 ipmid_dep,
66 libsystemd_dep,
67 nlohmann_json_dep,
Harvey.Wub1225b22022-10-28 17:42:07 +080068 phosphor_dbus_interfaces_dep,
69 phosphor_logging_dep,
70 sdbusplus_dep,
Harvey.Wub1225b22022-10-28 17:42:07 +080071]
72
73root_inc = include_directories(
74 '.',
75 'buildjson',
76 'dbus',
77 'errors',
78 'experiments',
79 'ipmi',
80 'notimpl',
81 'pid',
82 'sensors',
83 'sysfs',
84)
85
86setsensor_sources = [
87 'setsensor.cpp'
88]
89
90libswampd_sources = [
91 'main.cpp',
92 'util.cpp',
93 'notimpl/readonly.cpp',
94 'notimpl/writeonly.cpp',
95 'dbus/dbusconfiguration.cpp',
96 'dbus/dbusutil.cpp',
97 'dbus/dbushelper.cpp',
98 'dbus/dbuspassiveredundancy.cpp',
99 'dbus/dbuspassive.cpp',
100 'dbus/dbusactiveread.cpp',
101 'dbus/dbuswrite.cpp',
102 'sysfs/sysfsread.cpp',
103 'sysfs/sysfswrite.cpp',
104 'sysfs/util.cpp',
105 'sensors/pluggable.cpp',
106 'sensors/host.cpp',
107 'sensors/builder.cpp',
108 'sensors/buildjson.cpp',
109 'sensors/manager.cpp',
110 'sensors/build_utils.cpp',
111 'pid/ec/pid.cpp',
Josh Lehande745422020-11-07 02:14:09 -0800112 'pid/ec/logging.cpp',
Harvey.Wub1225b22022-10-28 17:42:07 +0800113 'pid/ec/stepwise.cpp',
114 'pid/fancontroller.cpp',
115 'pid/thermalcontroller.cpp',
116 'pid/pidcontroller.cpp',
117 'pid/stepwisecontroller.cpp',
118 'pid/builder.cpp',
119 'pid/buildjson.cpp',
120 'pid/zone.cpp',
121 'pid/util.cpp',
122 'pid/pidloop.cpp',
123 'pid/tuning.cpp',
124 'buildjson/buildjson.cpp',
125 'experiments/drive.cpp',
126]
127
128libmanualcmds_sources = [
129 'ipmi/main_ipmi.cpp',
130 'ipmi/manualcmds.cpp',
131 'ipmi/dbus_mode.cpp',
132]
133
134libmanualcmds = library(
135 'manualcmds',
136 libmanualcmds_sources,
137 implicit_include_directories: false,
138 dependencies: deps,
139 version: meson.project_version(),
140 override_options: ['b_lundef=false'],
141 install: true,
142 install_dir: get_option('libdir') / 'ipmid-providers')
143
144executable(
145 'swampd',
146 libswampd_sources,
147 implicit_include_directories: false,
148 include_directories: root_inc,
149 dependencies: deps,
150 install: true,
151 install_dir: get_option('bindir')
152)
153
154executable(
155 'setsensor',
156 setsensor_sources,
157 implicit_include_directories: true,
158 dependencies: deps,
159 install: true,
160 install_dir: get_option('bindir')
161)
162
163if not get_option('tests').disabled()
164 subdir('test')
165endif