xref: /openbmc/openpower-proc-control/meson.build (revision 6aba83d21d9fe55ee0dca3f829de44824cc16c28)
1project(
2    'openpower-proc-control',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++20',
8        'buildtype=debugoptimized',
9        'b_ndebug=if-release',
10    ],
11    license: 'Apache-2.0',
12    version: '1.0',
13    meson_version: '>=0.57.0',
14)
15add_project_arguments('-Wno-psabi', language: 'cpp')
16
17if get_option('cpp_std') != 'c++20'
18    error('This project requires c++20')
19endif
20
21if(get_option('buildtype') == 'minsize')
22    add_project_arguments('-DNDEBUG', language : 'cpp')
23endif
24
25cxx = meson.get_compiler('cpp')
26
27extra_sources = []
28extra_dependencies = []
29extra_unit_files = []
30
31# Configuration header file(config.h) generation
32conf_data = configuration_data()
33
34conf_data.set_quoted('DEVTREE_EXPORT_FILTER_FILE', get_option('DEVTREE_EXPORT_FILTER_FILE'),
35                      description : 'Path to the phal devtree export filter file'
36                    )
37
38conf_data.set_quoted('DEVTREE_EXP_FILE', get_option('DEVTREE_EXP_FILE'),
39                      description : 'Path to the devtree export copy file'
40                    )
41
42configure_file(configuration : conf_data,
43               output : 'config.h'
44              )
45
46unit_subs = configuration_data()
47unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
48unit_subs.set('ENABLE_PHAL_TRUE', '#')
49
50if get_option('phal').enabled() and get_option('p9').enabled()
51    error('phal and p9 cannot be selected at the same time')
52endif
53
54build_p9 = not get_option('p9').disabled()
55build_openfsi = not get_option('openfsi').disabled()
56build_phal = get_option('phal').enabled()
57
58if get_option('phal').enabled() and not get_option('p9').disabled()
59    build_p9 = false
60endif
61
62summary('building p9', build_p9)
63summary('building openfsi', build_openfsi)
64summary('building phal', build_phal)
65
66if build_p9
67    extra_sources += [
68        'procedures/p9/cleanup_pcie.cpp',
69        'procedures/p9/set_sync_fsi_clock_mode.cpp',
70        'procedures/p9/start_host.cpp',
71        'procedures/p9/start_host_mpreboot.cpp',
72        'procedures/p9/enter_mpreboot.cpp',
73    ]
74endif
75if build_openfsi
76    extra_sources += [
77        'procedures/openfsi/scan.cpp',
78    ]
79endif
80if build_phal
81    extra_sources += [
82        'procedures/phal/start_host.cpp',
83        'procedures/phal/set_SPI_mux.cpp',
84        'procedures/phal/proc_pre_poweroff.cpp',
85        'procedures/phal/check_host_running.cpp',
86        'procedures/phal/import_devtree.cpp',
87        'procedures/phal/enter_mpreboot.cpp',
88        'extensions/phal/common_utils.cpp',
89        'extensions/phal/pdbg_utils.cpp',
90        'extensions/phal/create_pel.cpp',
91        'extensions/phal/phal_error.cpp',
92        'extensions/phal/dump_utils.cpp',
93    ]
94    extra_dependencies += [
95        dependency('libdt-api'),
96        cxx.find_library('ekb'),
97        cxx.find_library('ipl'),
98        cxx.find_library('phal'),
99    ]
100    extra_unit_files = [
101        'service_files/set-spi-mux.service',
102        'service_files/phal-reinit-devtree.service',
103        'service_files/proc-pre-poweroff@.service',
104        'service_files/op-reset-host-check@.service',
105        'service_files/op-reset-host-clear.service',
106        'service_files/phal-import-devtree@.service',
107        'service_files/phal-export-devtree@.service',
108    ]
109    unit_subs.set('ENABLE_PHAL_TRUE', '')
110endif
111
112executable(
113    'openpower-proc-control',
114    [
115        'cfam_access.cpp',
116        'ext_interface.cpp',
117        'filedescriptor.cpp',
118        'proc_control.cpp',
119        'targeting.cpp',
120        'procedures/common/cfam_overrides.cpp',
121        'procedures/common/cfam_reset.cpp',
122        'procedures/common/collect_sbe_hb_data.cpp',
123        'util.cpp',
124    ] + extra_sources,
125    dependencies: [
126        dependency('libgpiodcxx'),
127        cxx.find_library('pdbg'),
128        dependency('phosphor-dbus-interfaces'),
129        dependency('phosphor-logging'),
130        dependency('sdbusplus'),
131        dependency('threads'),
132        dependency('fmt'),
133    ] + extra_dependencies,
134    install: true
135)
136
137executable(
138    'openpower-proc-nmi',
139    [
140        'nmi_main.cpp',
141        'nmi_interface.cpp',
142    ],
143    dependencies: [
144        cxx.find_library('pdbg'),
145        dependency('phosphor-dbus-interfaces'),
146        dependency('phosphor-logging'),
147        dependency('sdbusplus'),
148   ],
149   install: true
150)
151
152if build_phal
153    executable(
154        'phal-export-devtree',
155        [
156            'extensions/phal/devtree_export.cpp',
157            'extensions/phal/fw_update_watch.cpp',
158            'extensions/phal/pdbg_utils.cpp',
159            'extensions/phal/create_pel.cpp',
160            'util.cpp',
161        ],
162        dependencies: [
163            dependency('phosphor-logging'),
164            dependency('sdbusplus'),
165            dependency('sdeventplus'),
166            dependency('fmt'),
167            dependency('phosphor-dbus-interfaces'),
168            cxx.find_library('pdbg'),
169       ],
170       install: true
171   )
172endif
173
174unit_files = [
175    'service_files/pcie-poweroff@.service',
176    'service_files/xyz.openbmc_project.Control.Host.NMI.service',
177    'service_files/op-stop-instructions@.service',
178    'service_files/op-cfam-reset.service',
179    'service_files/op-continue-mpreboot@.service',
180    'service_files/op-enter-mpreboot@.service',
181] + extra_unit_files
182
183systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
184    'systemdsystemunitdir',
185    define_variable: ['prefix', get_option('prefix')])
186foreach u : unit_files
187    configure_file(
188        configuration: unit_subs,
189        input: u + '.in',
190        install: true,
191        install_dir: systemd_system_unit_dir,
192        output: '@BASENAME@'
193    )
194endforeach
195
196if not get_option('tests').disabled()
197    test(
198        'utest',
199        executable(
200            'utest',
201            'test/utest.cpp',
202            'targeting.cpp',
203            'filedescriptor.cpp',
204            dependencies: [
205                dependency('gtest', main: true),
206                dependency('phosphor-logging'),
207            ],
208            implicit_include_directories: false,
209            include_directories: '.',
210        )
211    )
212endif
213