Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-hwmon', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Patrick Williams | 64b90bf | 2023-07-12 11:15:51 -0500 | [diff] [blame] | 7 | 'cpp_std=c++23' |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 8 | ], |
| 9 | license: 'Apache-2.0', |
| 10 | version: '1.0', |
Patrick Williams | 64b90bf | 2023-07-12 11:15:51 -0500 | [diff] [blame] | 11 | meson_version: '>=1.1.1', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 12 | ) |
| 13 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 14 | conf = configuration_data() |
| 15 | conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix')) |
| 16 | conf.set_quoted('SENSOR_ROOT', get_option('sensor-root')) |
| 17 | conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail')) |
| 18 | conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail')) |
| 19 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 20 | sysfs_headers = include_directories('.') |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 21 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 22 | sysfs_deps = [ |
Patrick Williams | 6412993 | 2024-02-13 21:10:17 -0600 | [diff] [blame] | 23 | dependency('stdplus'), |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 24 | ] |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 25 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 26 | sysfs_lib = static_library( |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 27 | 'sysfs', |
| 28 | 'sysfs.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 29 | include_directories: sysfs_headers, |
Patrick Williams | 6412993 | 2024-02-13 21:10:17 -0600 | [diff] [blame] | 30 | dependencies: sysfs_deps, |
| 31 | ) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 32 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 33 | sysfs_dep = declare_dependency( |
| 34 | dependencies: sysfs_deps, |
| 35 | include_directories: sysfs_headers, |
| 36 | link_with: sysfs_lib) |
| 37 | |
| 38 | hwmon_headers = include_directories('.') |
| 39 | |
| 40 | hwmon_deps = [ |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 41 | dependency('gpioplus'), |
| 42 | dependency('phosphor-dbus-interfaces'), |
| 43 | dependency('phosphor-logging'), |
| 44 | dependency('sdbusplus'), |
| 45 | dependency('sdeventplus'), |
| 46 | dependency('stdplus'), |
Brandon Kim | 6d50c3e | 2019-08-09 15:38:53 -0700 | [diff] [blame] | 47 | dependency('threads'), |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 48 | sysfs_dep, |
| 49 | ] |
| 50 | |
| 51 | hwmon_lib = static_library( |
| 52 | 'hwmon', |
| 53 | 'average.cpp', |
| 54 | configure_file(output: 'config.h', configuration: conf), |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 55 | 'env.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 56 | 'fan_pwm.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 57 | 'fan_speed.cpp', |
| 58 | 'gpio_handle.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 59 | 'hwmon.cpp', |
| 60 | 'hwmonio.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 61 | 'mainloop.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 62 | 'sensor.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 63 | 'sensorset.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 64 | dependencies: hwmon_deps, |
| 65 | include_directories: hwmon_headers) |
| 66 | |
| 67 | hwmon_dep = declare_dependency( |
| 68 | dependencies: hwmon_deps, |
| 69 | include_directories: hwmon_headers, |
| 70 | link_with: hwmon_lib) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 71 | |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame] | 72 | # 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. |
| 74 | cli11_dep = dependency('cli11', required: false) |
| 75 | has_cli11 = meson.get_compiler('cpp').has_header_symbol( |
| 76 | 'CLI/CLI.hpp', |
| 77 | 'CLI::App', |
| 78 | dependencies: cli11_dep, |
| 79 | required: false) |
| 80 | if 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') |
| 84 | endif |
| 85 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 86 | executable( |
| 87 | 'phosphor-hwmon-readd', |
| 88 | 'readd.cpp', |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame] | 89 | dependencies: [ |
| 90 | cli11_dep, |
| 91 | hwmon_dep, |
| 92 | ], |
| 93 | install: true) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 94 | |
Patrick Williams | 6b5af74 | 2023-04-12 08:05:49 -0500 | [diff] [blame] | 95 | systemd_system_unit_dir = dependency('systemd').get_variable( |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 96 | 'systemdsystemunitdir', |
Patrick Williams | 6b5af74 | 2023-04-12 08:05:49 -0500 | [diff] [blame] | 97 | pkgconfig_define: ['prefix', get_option('prefix')]) |
| 98 | udev_dir = dependency('udev').get_variable( |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 99 | 'udev_dir', |
Patrick Williams | 6b5af74 | 2023-04-12 08:05:49 -0500 | [diff] [blame] | 100 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 101 | |
| 102 | install_data( |
| 103 | 'xyz.openbmc_project.Hwmon@.service', |
| 104 | install_dir: systemd_system_unit_dir |
| 105 | ) |
| 106 | |
| 107 | install_data( |
| 108 | 'phosphor-hwmon.conf', |
| 109 | install_dir: get_option('sysconfdir') / 'dbus-1/system.d' |
| 110 | ) |
| 111 | |
| 112 | install_data( |
| 113 | ['70-hwmon.rules', '70-iio.rules'], |
| 114 | install_dir: udev_dir / 'rules.d' |
| 115 | ) |
| 116 | |
Matt Spinler | 670d92a | 2024-07-22 15:52:02 -0500 | [diff] [blame] | 117 | force_devpath = '' |
| 118 | if get_option('always-use-devpath').enabled() |
| 119 | force_devpath = ' || true' |
| 120 | endif |
| 121 | |
Willy Tu | 24b8b4b | 2023-08-07 17:49:37 -0700 | [diff] [blame] | 122 | configure_file( |
| 123 | input : 'start_hwmon.sh.in', |
| 124 | output : 'start_hwmon.sh', |
Matt Spinler | 670d92a | 2024-07-22 15:52:02 -0500 | [diff] [blame] | 125 | configuration: { |
| 126 | 'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath')), |
| 127 | 'FORCE_DEVPATH': force_devpath |
| 128 | }, |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 129 | install_dir: get_option('bindir'), |
Willy Tu | 24b8b4b | 2023-08-07 17:49:37 -0700 | [diff] [blame] | 130 | install_mode: 'rwxr-xr-x', |
| 131 | install: true, |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 132 | ) |
| 133 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 134 | subdir('msl') |
William A. Kennington III | bb25973 | 2021-05-05 12:35:01 -0700 | [diff] [blame] | 135 | if not get_option('tests').disabled() |
| 136 | subdir('test') |
| 137 | endif |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 138 | subdir('tools') |