blob: c1ff74171d313970b92e9184f1a8a48914927339 [file] [log] [blame]
Brad Bishop919e4082020-10-27 18:55:19 -04001project(
2 'openpower-proc-control',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Brad Bishopf38b35e2020-11-08 10:42:34 -05007 'cpp_std=c++17',
8 'buildtype=debugoptimized',
9 'b_ndebug=if-release',
Brad Bishop919e4082020-10-27 18:55:19 -040010 ],
11 license: 'Apache-2.0',
12 version: '1.0',
13)
14add_project_arguments('-Wno-psabi', language: 'cpp')
15
Brad Bishopf38b35e2020-11-08 10:42:34 -050016if get_option('cpp_std') != 'c++17'
17 error('This project requires c++17')
18endif
19
20if(get_option('buildtype') == 'minsize')
21 add_project_arguments('-DNDEBUG', language : 'cpp')
22endif
23
Brad Bishop919e4082020-10-27 18:55:19 -040024cxx = meson.get_compiler('cpp')
25
26extra_sources = []
27extra_dependencies = []
28extra_unit_files = []
29
30unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050031unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
32unit_subs.set('ENABLE_PHAL_TRUE', '#')
Brad Bishop919e4082020-10-27 18:55:19 -040033
34if get_option('phal').enabled() and get_option('p9').enabled()
35 error('phal and p9 cannot be selected at the same time')
36endif
37
38build_p9 = not get_option('p9').disabled()
39build_openfsi = not get_option('openfsi').disabled()
40build_phal = get_option('phal').enabled()
41
42if get_option('phal').enabled() and not get_option('p9').disabled()
43 build_p9 = false
44endif
45
46summary('building p9', build_p9)
47summary('building openfsi', build_openfsi)
48summary('building phal', build_phal)
49
50if build_p9
51 extra_sources += [
52 'procedures/p9/cleanup_pcie.cpp',
53 'procedures/p9/set_sync_fsi_clock_mode.cpp',
54 'procedures/p9/start_host.cpp',
55 'procedures/p9/start_host_mpreboot.cpp',
56 ]
57endif
58if build_openfsi
59 extra_sources += [
60 'procedures/openfsi/scan.cpp',
61 ]
62endif
63if build_phal
64 extra_sources += [
65 'procedures/phal/start_host.cpp',
66 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -060067 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -050068 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -050069 'extensions/phal/pdbg_utils.cpp',
Andrew Geissler65c01012021-06-15 14:03:34 -050070 'procedures/phal/check_host_running.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -050071 'extensions/phal/create_pel.cpp',
72 'extensions/phal/phal_error.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040073 ]
74 extra_dependencies += [
75 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -040076 cxx.find_library('ekb'),
77 cxx.find_library('ipl'),
78 ]
79 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -050080 'service_files/set-spi-mux.service',
81 'service_files/phal-reinit-devtree.service',
82 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -050083 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -050084 'service_files/op-reset-host-clear.service',
Brad Bishop919e4082020-10-27 18:55:19 -040085 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050086 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -040087endif
88
89executable(
90 'openpower-proc-control',
91 [
92 'cfam_access.cpp',
93 'ext_interface.cpp',
94 'filedescriptor.cpp',
95 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040096 'targeting.cpp',
97 'procedures/common/cfam_overrides.cpp',
98 'procedures/common/cfam_reset.cpp',
99 'procedures/common/enter_mpreboot.cpp',
100 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500101 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400102 ] + extra_sources,
103 dependencies: [
104 dependency('libgpiodcxx'),
105 cxx.find_library('pdbg'),
106 dependency('phosphor-dbus-interfaces'),
107 dependency('phosphor-logging'),
108 dependency('sdbusplus'),
109 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500110 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500111 ] + extra_dependencies,
112 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400113)
114
115executable(
116 'openpower-proc-nmi',
117 [
118 'nmi_main.cpp',
119 'nmi_interface.cpp',
120 ],
121 dependencies: [
122 cxx.find_library('pdbg'),
123 dependency('phosphor-dbus-interfaces'),
124 dependency('phosphor-logging'),
125 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500126 ],
127 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400128)
129
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500130if build_phal
131 executable(
132 'phal-export-devtree',
133 [
134 'extensions/phal/devtree_export.cpp',
135 'extensions/phal/fw_update_watch.cpp',
136 ],
137 dependencies: [
138 dependency('phosphor-logging'),
139 dependency('sdbusplus'),
140 dependency('sdeventplus'),
141 dependency('fmt'),
142 ],
143 install: true
144 )
145endif
146
Brad Bishop919e4082020-10-27 18:55:19 -0400147unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500148 'service_files/pcie-poweroff@.service',
149 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
150 'service_files/op-stop-instructions@.service',
151 'service_files/op-cfam-reset.service',
152 'service_files/op-continue-mpreboot@.service',
153 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400154] + extra_unit_files
155
156systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
157 'systemdsystemunitdir',
158 define_variable: ['prefix', get_option('prefix')])
159foreach u : unit_files
160 configure_file(
161 configuration: unit_subs,
162 input: u + '.in',
163 install: true,
164 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500165 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400166 )
167endforeach
168
169if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400170 test(
171 'utest',
172 executable(
173 'utest',
174 'test/utest.cpp',
175 'targeting.cpp',
176 'filedescriptor.cpp',
177 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500178 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400179 dependency('phosphor-logging'),
180 ],
181 implicit_include_directories: false,
182 include_directories: '.',
183 )
184 )
185endif