blob: cc27fbd3401facf27e2fdb02df56016d575deb07 [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 Williams3a816142021-10-06 15:36:42 -05007 'cpp_std=c++20'
Brad Bishop59061732019-10-07 15:48:37 -04008 ],
9 license: 'Apache-2.0',
10 version: '1.0',
Patrick Williams3a816142021-10-06 15:36:42 -050011 meson_version: '>=0.57.0',
Brad Bishop59061732019-10-07 15:48:37 -040012)
13
Matt Spinler5e034af2020-06-24 15:21:53 -050014fmt = dependency('fmt')
Brad Bishop59061732019-10-07 15:48:37 -040015
16conf = configuration_data()
17conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix'))
18conf.set_quoted('SENSOR_ROOT', get_option('sensor-root'))
19conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail'))
20conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail'))
21
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070022sysfs_headers = include_directories('.')
Brad Bishop59061732019-10-07 15:48:37 -040023
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070024sysfs_deps = [
25 fmt,
26]
Brad Bishop59061732019-10-07 15:48:37 -040027
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070028sysfs_lib = static_library(
Brad Bishop59061732019-10-07 15:48:37 -040029 'sysfs',
30 'sysfs.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070031 include_directories: sysfs_headers,
32 dependencies: sysfs_deps)
Brad Bishop59061732019-10-07 15:48:37 -040033
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070034sysfs_dep = declare_dependency(
35 dependencies: sysfs_deps,
36 include_directories: sysfs_headers,
37 link_with: sysfs_lib)
38
39hwmon_headers = include_directories('.')
40
41hwmon_deps = [
42 fmt,
43 dependency('gpioplus'),
44 dependency('phosphor-dbus-interfaces'),
45 dependency('phosphor-logging'),
46 dependency('sdbusplus'),
47 dependency('sdeventplus'),
48 dependency('stdplus'),
Brandon Kim6d50c3e2019-08-09 15:38:53 -070049 dependency('threads'),
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070050 sysfs_dep,
51]
52
53hwmon_lib = static_library(
54 'hwmon',
55 'average.cpp',
56 configure_file(output: 'config.h', configuration: conf),
Brad Bishop59061732019-10-07 15:48:37 -040057 'env.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070058 'fan_pwm.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040059 'fan_speed.cpp',
60 'gpio_handle.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070061 'hwmon.cpp',
62 'hwmonio.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040063 'mainloop.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070064 'sensor.cpp',
Brad Bishop59061732019-10-07 15:48:37 -040065 'sensorset.cpp',
William A. Kennington IIIf9aff802021-05-05 12:06:24 -070066 dependencies: hwmon_deps,
67 include_directories: hwmon_headers)
68
69hwmon_dep = declare_dependency(
70 dependencies: hwmon_deps,
71 include_directories: hwmon_headers,
72 link_with: hwmon_lib)
Brad Bishop59061732019-10-07 15:48:37 -040073
William A. Kennington IIId3e87942021-05-05 12:26:53 -070074# CLI11 might not have a pkg-config. It is header only so just make
75# sure we can access the needed symbols from the header.
76cli11_dep = dependency('cli11', required: false)
77has_cli11 = meson.get_compiler('cpp').has_header_symbol(
78 'CLI/CLI.hpp',
79 'CLI::App',
80 dependencies: cli11_dep,
81 required: false)
82if not has_cli11
83 cli11_proj = subproject('cli11', required: false)
84 assert(cli11_proj.found(), 'CLI11 is required')
85 cli11_dep = cli11_proj.get_variable('CLI11_dep')
86endif
87
Brad Bishop59061732019-10-07 15:48:37 -040088executable(
89 'phosphor-hwmon-readd',
90 'readd.cpp',
William A. Kennington IIId3e87942021-05-05 12:26:53 -070091 dependencies: [
92 cli11_dep,
93 hwmon_dep,
94 ],
95 install: true)
Brad Bishop59061732019-10-07 15:48:37 -040096
Anton D. Kachalov5b520cf2021-02-03 23:19:39 +010097systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
98 'systemdsystemunitdir',
99 define_variable: ['prefix', get_option('prefix')])
100udev_dir = dependency('udev').get_pkgconfig_variable(
101 'udev_dir',
102 define_variable: ['prefix', get_option('prefix')])
103
104install_data(
105 'xyz.openbmc_project.Hwmon@.service',
106 install_dir: systemd_system_unit_dir
107)
108
109install_data(
110 'phosphor-hwmon.conf',
111 install_dir: get_option('sysconfdir') / 'dbus-1/system.d'
112)
113
114install_data(
115 ['70-hwmon.rules', '70-iio.rules'],
116 install_dir: udev_dir / 'rules.d'
117)
118
119install_data(
120 'start_hwmon.sh',
121 install_dir: get_option('bindir'),
122 install_mode: 'rwxr-xr-x'
123)
124
Brad Bishop59061732019-10-07 15:48:37 -0400125subdir('msl')
William A. Kennington IIIbb259732021-05-05 12:35:01 -0700126if not get_option('tests').disabled()
127 subdir('test')
128endif
Brad Bishop59061732019-10-07 15:48:37 -0400129subdir('tools')