1project( 2 'openpower-proc-control', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++17', 8 'buildtype=debugoptimized', 9 'b_ndebug=if-release', 10 ], 11 license: 'Apache-2.0', 12 version: '1.0', 13) 14add_project_arguments('-Wno-psabi', language: 'cpp') 15 16if 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 24cxx = meson.get_compiler('cpp') 25 26extra_sources = [] 27extra_dependencies = [] 28extra_unit_files = [] 29 30unit_subs = configuration_data() 31unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 32unit_subs.set('ENABLE_PHAL_TRUE', '#') 33 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', 67 'procedures/phal/proc_pre_poweroff.cpp', 68 'procedures/phal/common_utils.cpp', 69 'phalerror/create_pel.cpp', 70 'phalerror/phal_error.cpp', 71 ] 72 extra_dependencies += [ 73 dependency('libdt-api'), 74 cxx.find_library('ekb'), 75 cxx.find_library('ipl'), 76 ] 77 extra_unit_files = [ 78 'set-spi-mux.service', 79 'phal-reinit-devtree.service', 80 'proc-pre-poweroff@.service', 81 ] 82 unit_subs.set('ENABLE_PHAL_TRUE', '') 83endif 84 85executable( 86 'openpower-proc-control', 87 [ 88 'cfam_access.cpp', 89 'ext_interface.cpp', 90 'filedescriptor.cpp', 91 'proc_control.cpp', 92 'registration.cpp', 93 'targeting.cpp', 94 'procedures/common/cfam_overrides.cpp', 95 'procedures/common/cfam_reset.cpp', 96 'procedures/common/enter_mpreboot.cpp', 97 'procedures/common/collect_sbe_hb_data.cpp', 98 'util.cpp', 99 ] + extra_sources, 100 dependencies: [ 101 dependency('libgpiodcxx'), 102 cxx.find_library('pdbg'), 103 dependency('phosphor-dbus-interfaces'), 104 dependency('phosphor-logging'), 105 dependency('sdbusplus'), 106 dependency('threads'), 107 dependency('fmt'), 108 ] + extra_dependencies, 109 install: true 110) 111 112executable( 113 'openpower-proc-nmi', 114 [ 115 'nmi_main.cpp', 116 'nmi_interface.cpp', 117 ], 118 dependencies: [ 119 cxx.find_library('pdbg'), 120 dependency('phosphor-dbus-interfaces'), 121 dependency('phosphor-logging'), 122 dependency('sdbusplus'), 123 ], 124 install: true 125) 126 127unit_files = [ 128 'pcie-poweroff@.service', 129 'xyz.openbmc_project.Control.Host.NMI.service', 130 'op-stop-instructions@.service', 131 'op-cfam-reset.service', 132 'op-continue-mpreboot@.service', 133 'op-enter-mpreboot@.service', 134] + extra_unit_files 135 136systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( 137 'systemdsystemunitdir', 138 define_variable: ['prefix', get_option('prefix')]) 139foreach u : unit_files 140 configure_file( 141 configuration: unit_subs, 142 input: u + '.in', 143 install: true, 144 install_dir: systemd_system_unit_dir, 145 output: u 146 ) 147endforeach 148 149if not get_option('tests').disabled() 150 test( 151 'utest', 152 executable( 153 'utest', 154 'test/utest.cpp', 155 'targeting.cpp', 156 'filedescriptor.cpp', 157 dependencies: [ 158 dependency('gtest', main: true), 159 dependency('phosphor-logging'), 160 ], 161 implicit_include_directories: false, 162 include_directories: '.', 163 ) 164 ) 165endif 166