blob: 01467dce9e260552ee8e4804c59f36a8fa75c4ef [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',
68 'procedures/phal/common_utils.cpp',
Andrew Geissler65c01012021-06-15 14:03:34 -050069 'procedures/phal/check_host_running.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040070 'phalerror/create_pel.cpp',
71 'phalerror/phal_error.cpp',
72 ]
73 extra_dependencies += [
74 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -040075 cxx.find_library('ekb'),
76 cxx.find_library('ipl'),
77 ]
78 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -050079 'service_files/set-spi-mux.service',
80 'service_files/phal-reinit-devtree.service',
81 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -050082 'service_files/op-reset-host-check@.service',
Brad Bishop919e4082020-10-27 18:55:19 -040083 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050084 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -040085endif
86
87executable(
88 'openpower-proc-control',
89 [
90 'cfam_access.cpp',
91 'ext_interface.cpp',
92 'filedescriptor.cpp',
93 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040094 'targeting.cpp',
95 'procedures/common/cfam_overrides.cpp',
96 'procedures/common/cfam_reset.cpp',
97 'procedures/common/enter_mpreboot.cpp',
98 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -050099 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400100 ] + extra_sources,
101 dependencies: [
102 dependency('libgpiodcxx'),
103 cxx.find_library('pdbg'),
104 dependency('phosphor-dbus-interfaces'),
105 dependency('phosphor-logging'),
106 dependency('sdbusplus'),
107 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500108 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500109 ] + extra_dependencies,
110 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400111)
112
113executable(
114 'openpower-proc-nmi',
115 [
116 'nmi_main.cpp',
117 'nmi_interface.cpp',
118 ],
119 dependencies: [
120 cxx.find_library('pdbg'),
121 dependency('phosphor-dbus-interfaces'),
122 dependency('phosphor-logging'),
123 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500124 ],
125 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400126)
127
128unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500129 'service_files/pcie-poweroff@.service',
130 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
131 'service_files/op-stop-instructions@.service',
132 'service_files/op-cfam-reset.service',
133 'service_files/op-continue-mpreboot@.service',
134 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400135] + extra_unit_files
136
137systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
138 'systemdsystemunitdir',
139 define_variable: ['prefix', get_option('prefix')])
140foreach u : unit_files
141 configure_file(
142 configuration: unit_subs,
143 input: u + '.in',
144 install: true,
145 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500146 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400147 )
148endforeach
149
150if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400151 test(
152 'utest',
153 executable(
154 'utest',
155 'test/utest.cpp',
156 'targeting.cpp',
157 'filedescriptor.cpp',
158 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500159 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400160 dependency('phosphor-logging'),
161 ],
162 implicit_include_directories: false,
163 include_directories: '.',
164 )
165 )
166endif