blob: 804fbaa8834573a9682fe9f7b57d832f23c8fbce [file] [log] [blame]
Brad Bishop59061732019-10-07 15:48:37 -04001project(
2 'phosphor-hwmon',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams64b90bf2023-07-12 11:15:51 -05007 'cpp_std=c++23'
Brad Bishop59061732019-10-07 15:48:37 -04008 ],
9 license: 'Apache-2.0',
10 version: '1.0',
Patrick Williams64b90bf2023-07-12 11:15:51 -050011 meson_version: '>=1.1.1',
Brad Bishop59061732019-10-07 15:48:37 -040012)
13
Brad Bishop59061732019-10-07 15:48:37 -040014conf = configuration_data()
15conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix'))
16conf.set_quoted('SENSOR_ROOT', get_option('sensor-root'))
17conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail'))
18conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail'))
19
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070020sysfs_headers = include_directories('.')
Brad Bishop59061732019-10-07 15:48:37 -040021
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070022sysfs_deps = [
Patrick Williams64129932024-02-13 21:10:17 -060023 dependency('stdplus'),
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070024]
Brad Bishop59061732019-10-07 15:48:37 -040025
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070026sysfs_lib = static_library(
Brad Bishop59061732019-10-07 15:48:37 -040027 'sysfs',
28 'sysfs.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070029 include_directories: sysfs_headers,
Patrick Williams64129932024-02-13 21:10:17 -060030 dependencies: sysfs_deps,
31)
Brad Bishop59061732019-10-07 15:48:37 -040032
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070033sysfs_dep = declare_dependency(
34 dependencies: sysfs_deps,
35 include_directories: sysfs_headers,
36 link_with: sysfs_lib)
37
38hwmon_headers = include_directories('.')
39
40hwmon_deps = [
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070041 dependency('gpioplus'),
42 dependency('phosphor-dbus-interfaces'),
43 dependency('phosphor-logging'),
44 dependency('sdbusplus'),
45 dependency('sdeventplus'),
46 dependency('stdplus'),
Brandon Kim6d50c3e2019-08-09 15:38:53 -070047 dependency('threads'),
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070048 sysfs_dep,
49]
50
51hwmon_lib = static_library(
52 'hwmon',
53 'average.cpp',
54 configure_file(output: 'config.h', configuration: conf),
Brad Bishop59061732019-10-07 15:48:37 -040055 'env.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070056 'fan_pwm.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040057 'fan_speed.cpp',
58 'gpio_handle.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070059 'hwmon.cpp',
60 'hwmonio.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040061 'mainloop.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070062 'sensor.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040063 'sensorset.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070064 dependencies: hwmon_deps,
65 include_directories: hwmon_headers)
66
67hwmon_dep = declare_dependency(
68 dependencies: hwmon_deps,
69 include_directories: hwmon_headers,
70 link_with: hwmon_lib)
Brad Bishop59061732019-10-07 15:48:37 -040071
William A. Kennington IIId3e87942021-05-05 12:26:53 -070072# CLI11 might not have a pkg-config. It is header only so just make
73# sure we can access the needed symbols from the header.
74cli11_dep = dependency('cli11', required: false)
75has_cli11 = meson.get_compiler('cpp').has_header_symbol(
76 'CLI/CLI.hpp',
77 'CLI::App',
78 dependencies: cli11_dep,
79 required: false)
80if not has_cli11
81 cli11_proj = subproject('cli11', required: false)
82 assert(cli11_proj.found(), 'CLI11 is required')
83 cli11_dep = cli11_proj.get_variable('CLI11_dep')
84endif
85
Brad Bishop59061732019-10-07 15:48:37 -040086executable(
87 'phosphor-hwmon-readd',
88 'readd.cpp',
William A. Kennington IIId3e87942021-05-05 12:26:53 -070089 dependencies: [
90 cli11_dep,
91 hwmon_dep,
92 ],
93 install: true)
Brad Bishop59061732019-10-07 15:48:37 -040094
Patrick Williams6b5af742023-04-12 08:05:49 -050095systemd_system_unit_dir = dependency('systemd').get_variable(
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +010096 'systemdsystemunitdir',
Patrick Williams6b5af742023-04-12 08:05:49 -050097 pkgconfig_define: ['prefix', get_option('prefix')])
98udev_dir = dependency('udev').get_variable(
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +010099 'udev_dir',
Patrick Williams6b5af742023-04-12 08:05:49 -0500100 pkgconfig_define: ['prefix', get_option('prefix')])
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +0100101
102install_data(
103 'xyz.openbmc_project.Hwmon@.service',
104 install_dir: systemd_system_unit_dir
105)
106
107install_data(
108 'phosphor-hwmon.conf',
109 install_dir: get_option('sysconfdir') / 'dbus-1/system.d'
110)
111
112install_data(
113 ['70-hwmon.rules', '70-iio.rules'],
114 install_dir: udev_dir / 'rules.d'
115)
116
Matt Spinler670d92a2024-07-22 15:52:02 -0500117force_devpath = ''
118if get_option('always-use-devpath').enabled()
119 force_devpath = ' || true'
120endif
121
Willy Tu24b8b4b2023-08-07 17:49:37 -0700122configure_file(
123 input : 'start_hwmon.sh.in',
124 output : 'start_hwmon.sh',
Matt Spinler670d92a2024-07-22 15:52:02 -0500125 configuration: {
126 'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath')),
127 'FORCE_DEVPATH': force_devpath
128 },
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +0100129 install_dir: get_option('bindir'),
Willy Tu24b8b4b2023-08-07 17:49:37 -0700130 install_mode: 'rwxr-xr-x',
131 install: true,
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +0100132)
133
Brad Bishop59061732019-10-07 15:48:37 -0400134subdir('msl')
William A. Kennington IIIbb259732021-05-05 12:35:01 -0700135if not get_option('tests').disabled()
136 subdir('test')
137endif
Brad Bishop59061732019-10-07 15:48:37 -0400138subdir('tools')