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