1project('pldm', ['c', 'cpp'], 2 version: '0.1', meson_version: '>=0.57.0', 3 default_options: [ 4 'warning_level=3', 5 'default_library=shared', 6 'werror=true', 7 'cpp_std=c++20', 8 'buildtype=debugoptimized' 9 ]) 10 11# Wno-psabi reduces the number of "Note:" messages when cross-compiling some STL 12# stuff for ARM. See https://stackoverflow.com/questions/48149323/strange-gcc-warning-when-compiling-qt-project 13# Basically, gcc 6 and gcc 7 are not ABI compatible, but since the whole OpenBMC 14# project uses the same compiler, we can safely ignmore these info notes. 15add_project_arguments('-Wno-psabi', language: 'cpp') 16 17 18# Disable FORTIFY_SOURCE when compiling with no optimization 19if(get_option('optimization') == '0') 20 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c']) 21 message('Disabling FORTIFY_SOURCE as optimization is set to 0') 22endif 23 24package_datadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) 25package_localstatedir = join_paths(get_option('prefix'), get_option('localstatedir'), meson.project_name()) 26 27conf_data = configuration_data() 28if get_option('libpldmresponder').enabled() 29conf_data.set_quoted('BIOS_JSONS_DIR', join_paths(package_datadir, 'bios')) 30conf_data.set_quoted('BIOS_TABLES_DIR', join_paths(package_localstatedir, 'bios')) 31conf_data.set_quoted('PDR_JSONS_DIR', join_paths(package_datadir, 'pdr')) 32conf_data.set_quoted('FRU_JSONS_DIR', join_paths(package_datadir, 'fru')) 33conf_data.set_quoted('FRU_MASTER_JSON', join_paths(package_datadir, 'fru_master.json')) 34conf_data.set_quoted('HOST_JSONS_DIR', join_paths(package_datadir, 'host')) 35conf_data.set_quoted('EVENTS_JSONS_DIR', join_paths(package_datadir, 'events')) 36add_project_arguments('-DLIBPLDMRESPONDER', language : ['c','cpp']) 37endif 38if get_option('softoff').enabled() 39 conf_data.set('SOFTOFF_TIMEOUT_SECONDS', get_option('softoff-timeout-seconds')) 40endif 41if get_option('oem-ibm').enabled() 42 conf_data.set_quoted('FILE_TABLE_JSON', join_paths(package_datadir, 'fileTable.json')) 43 conf_data.set_quoted('LID_RUNNING_DIR', '/var/lib/phosphor-software-manager/hostfw/running') 44 conf_data.set_quoted('LID_ALTERNATE_DIR', '/var/lib/phosphor-software-manager/hostfw/alternate') 45 conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging') 46 conf_data.set_quoted('LID_RUNNING_PATCH_DIR', '/usr/local/share/hostfw/running') 47 conf_data.set_quoted('LID_ALTERNATE_PATCH_DIR', '/usr/local/share/hostfw/alternate') 48 conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging') 49 conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize')) 50 add_project_arguments('-DOEM_IBM', language : 'c') 51 add_project_arguments('-DOEM_IBM', language : 'cpp') 52endif 53conf_data.set('PLDM_VERBOSITY',get_option('verbosity')) 54conf_data.set('NUMBER_OF_REQUEST_RETRIES', get_option('number-of-request-retries')) 55conf_data.set('INSTANCE_ID_EXPIRATION_INTERVAL',get_option('instance-id-expiration-interval')) 56conf_data.set('RESPONSE_TIME_OUT',get_option('response-time-out')) 57if get_option('libpldm-only').disabled() 58 conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid')) 59endif 60configure_file(output: 'config.h', 61 configuration: conf_data 62) 63 64phosphor_dbus_interfaces = dependency( 65 'phosphor-dbus-interfaces', 66 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'], 67) 68sdbusplus = dependency( 69 'sdbusplus', 70 fallback: ['sdbusplus', 'sdbusplus_dep'], 71) 72sdeventplus = dependency( 73 'sdeventplus', 74 fallback: ['sdeventplus', 'sdeventplus_dep'], 75) 76 77cpp = meson.get_compiler('cpp') 78 79if cpp.has_header('nlohmann/json.hpp') 80 nlohmann_json = declare_dependency() 81else 82 subproject('nlohmann-json') 83 nlohmann_json = declare_dependency( 84 include_directories: [ 85 'subprojects/nlohmann-json/single_include', 86 'subprojects/nlohmann-json/single_include/nlohmann', 87 ] 88 ) 89endif 90 91if cpp.has_header('CLI/CLI.hpp') 92 CLI11_dep = declare_dependency() 93else 94 CLI11_dep = dependency( 95 'CLI11', 96 fallback: [ 'CLI11', 'CLI11_dep' ], 97 ) 98endif 99 100if cpp.has_header_symbol('function2/function2.hpp', 'fu2::unique_function') 101 function2_dep = declare_dependency() 102else 103 subproject('function2') 104 function2_dep = declare_dependency( 105 include_directories: [ 106 'subprojects/function2/include/function2' 107 ] 108 ) 109endif 110 111if get_option('oe-sdk').enabled() 112 # Setup OE SYSROOT 113 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() 114 if OECORE_TARGET_SYSROOT == '' 115 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') 116 endif 117 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) 118 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) 119 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() 120 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 121else 122 dynamic_linker = [] 123endif 124 125if get_option('tests').enabled() 126 gtest = dependency('gtest', main: true, disabler: true, required: false) 127 gmock = dependency('gmock', disabler: true, required: false) 128 if not gtest.found() or not gmock.found() 129 gtest_proj = import('cmake').subproject('googletest', required: false) 130 if gtest_proj.found() 131 gtest = declare_dependency( 132 dependencies: [ 133 dependency('threads'), 134 gtest_proj.dependency('gtest'), 135 gtest_proj.dependency('gtest_main'), 136 ] 137 ) 138 gmock = gtest_proj.dependency('gmock') 139 else 140 assert( 141 not get_option('tests').enabled(), 142 'Googletest is required if tests are enabled' 143 ) 144 endif 145 endif 146endif 147 148subdir('libpldm') 149 150if get_option('libpldm-only').disabled() 151 152libpldmutils_headers = ['.'] 153libpldmutils = library( 154 'pldmutils', 155 'common/utils.cpp', 156 version: meson.project_version(), 157 dependencies: [ 158 libpldm_dep, 159 phosphor_dbus_interfaces, 160 nlohmann_json, 161 sdbusplus, 162 ], 163 install: true, 164 include_directories: include_directories(libpldmutils_headers), 165) 166 167libpldmutils = declare_dependency( 168 include_directories: include_directories(libpldmutils_headers), 169 link_with: libpldmutils) 170 171deps = [ 172 function2_dep, 173 libpldm_dep, 174 libpldmutils, 175 nlohmann_json, 176 sdbusplus, 177 sdeventplus, 178 phosphor_dbus_interfaces, 179] 180 181if get_option('libpldmresponder').enabled() 182subdir('libpldmresponder') 183deps += [ 184 libpldmresponder 185] 186endif 187 188executable( 189 'pldmd', 190 'pldmd/pldmd.cpp', 191 'pldmd/dbus_impl_requester.cpp', 192 'pldmd/instance_id.cpp', 193 'pldmd/dbus_impl_pdr.cpp', 194 implicit_include_directories: false, 195 dependencies: deps, 196 install: true, 197 install_dir: get_option('bindir')) 198 199if get_option('systemd').enabled() 200 systemd_system_unit_dir = dependency('systemd').get_variable( 201 pkgconfig: 'systemdsystemunitdir') 202 203 configure_file( 204 copy: true, 205 input: 'pldmd/service_files/pldmd.service', 206 install: true, 207 install_dir: systemd_system_unit_dir, 208 output: 'pldmd.service', 209 ) 210 211 configure_file( 212 input: 'pldmd/verbosity/verbosity', 213 output: 'pldm_verbosity', 214 configuration: conf_data, 215 install: true, 216 install_dir: join_paths(get_option('sysconfdir'), 'default')) 217 218 if get_option('oem-ibm').enabled() 219 subdir('oem/ibm/service_files') 220 endif 221endif 222 223subdir('pldmtool') 224 225subdir('configurations') 226 227if get_option('utilities').enabled() 228 subdir('utilities') 229endif 230 231if get_option('softoff').enabled() 232 subdir('softoff') 233endif 234 235if get_option('tests').enabled() 236 subdir('common/test') 237 subdir('host-bmc/test') 238 subdir('requester/test') 239 subdir('test') 240endif 241 242endif # pldm-only 243