1project(
2    'phosphor-gpio-monitor',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++20',
8        'buildtype=debugoptimized'
9    ],
10    license: 'Apache-2.0',
11    version: '1.0',
12    meson_version: '>=0.58.0',
13)
14
15build_tests = get_option('tests')
16
17libevdev = dependency('libevdev')
18libsystemd = dependency('libsystemd')
19libgpiod = dependency('libgpiod')
20phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
21phosphor_logging = dependency('phosphor-logging')
22sdbusplus = dependency('sdbusplus')
23systemd = dependency('systemd')
24
25boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
26              '-DBOOST_ERROR_CODE_HEADER_ONLY',
27              '-DBOOST_SYSTEM_NO_DEPRECATED']
28
29systemd_system_unit_dir = systemd.get_variable(
30    'systemdsystemunitdir',
31    pkgconfig_define: ['prefix', get_option('prefix')])
32
33configure_file(
34    copy: true,
35    input: 'phosphor-gpio-monitor@.service',
36    install: true,
37    install_dir: systemd_system_unit_dir,
38    output: 'phosphor-gpio-monitor@.service'
39)
40
41configure_file(
42    copy: true,
43    input: 'phosphor-multi-gpio-monitor.service',
44    install: true,
45    install_dir: systemd_system_unit_dir,
46    output: 'phosphor-multi-gpio-monitor.service'
47)
48
49configure_file(
50    copy: true,
51    input: 'phosphor-gpio-presence@.service',
52    install: true,
53    install_dir: systemd_system_unit_dir,
54    output: 'phosphor-gpio-presence@.service'
55)
56
57udev = dependency('udev')
58udev_rules_dir = join_paths(
59    udev.get_variable(
60        'udevdir',
61        pkgconfig_define: ['prefix', get_option('prefix')],
62    ),
63    'rules.d',
64)
65
66configure_file(
67    copy: true,
68    input: '99-gpio-keys.rules',
69    install: true,
70    install_dir: udev_rules_dir,
71    output: '99-gpio-keys.rules'
72)
73
74
75configure_file(
76    copy: true,
77    input: 'phosphor-multi-gpio-monitor.json',
78    install: true,
79    install_dir: '/usr/share/phosphor-gpio-monitor',
80    output: 'phosphor-multi-gpio-monitor.json'
81)
82
83libevdev_o = static_library(
84    'libevdev_o',
85    'evdev.cpp',
86    dependencies: [
87        libevdev,
88        phosphor_dbus_interfaces,
89        phosphor_logging,
90        sdbusplus,
91    ]
92)
93
94libmonitor_o = static_library(
95    'libmonitor_o',
96     'monitor.cpp',
97    dependencies: [
98        libevdev,
99        libsystemd,
100        phosphor_logging,
101    ],
102    link_with: [
103        libevdev_o,
104    ],
105)
106
107phosphor_gpio_monitor = executable(
108    'phosphor-gpio-monitor',
109    'argument.cpp',
110    'mainapp.cpp',
111    dependencies: [
112        libevdev,
113        libsystemd,
114        phosphor_logging,
115    ],
116    install: true,
117    link_with: [
118        libevdev_o,
119        libmonitor_o,
120    ],
121)
122
123executable(
124   'phosphor-multi-gpio-monitor',
125   'gpioMonMain.cpp',
126   'gpioMon.cpp',
127   dependencies: [
128        phosphor_logging,
129        sdbusplus,
130        libgpiod,
131    ],
132    cpp_args: boost_args,
133    install: true,
134)
135
136subdir('gpio-util')
137subdir('presence')
138subdir('test')
139