1project( 2 'libcper', 3 ['c', 'cpp'], 4 version: '0.1', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'c_std=c18', 8 'cpp_std=c++23', 9 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 10 'warning_level=2', 11 'werror=true', 12 ], 13) 14 15add_project_arguments( 16 '-DLIBCPER_JSON_SPEC="' 17 + meson.current_source_dir() + '/specification/json/cper-json.json"', 18 language: ['c', 'cpp'], 19) 20 21library_is_share = get_option('default_library') == 'shared' 22add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c') 23 24project_description = 'libcper library' 25 26section_sources = files( 27 'sections/cper-section-ampere.c', 28 'sections/cper-section-arm.c', 29 'sections/cper-section-ccix-per.c', 30 'sections/cper-section-cxl-component.c', 31 'sections/cper-section-cxl-protocol.c', 32 'sections/cper-section-dmar-generic.c', 33 'sections/cper-section-dmar-iommu.c', 34 'sections/cper-section-dmar-vtd.c', 35 'sections/cper-section-firmware.c', 36 'sections/cper-section-generic.c', 37 'sections/cper-section-ia32x64.c', 38 'sections/cper-section-ipf.c', 39 'sections/cper-section-memory.c', 40 'sections/cper-section-nvidia.c', 41 'sections/cper-section-pci-bus.c', 42 'sections/cper-section-pci-dev.c', 43 'sections/cper-section-pcie.c', 44 'sections/cper-section.c', 45) 46 47edk_sources = files('edk/Cper.c') 48 49generator_section_sources = files( 50 'generator/sections/gen-section-ampere.c', 51 'generator/sections/gen-section-arm.c', 52 'generator/sections/gen-section-ccix-per.c', 53 'generator/sections/gen-section-cxl-component.c', 54 'generator/sections/gen-section-cxl-protocol.c', 55 'generator/sections/gen-section-dmar.c', 56 'generator/sections/gen-section-firmware.c', 57 'generator/sections/gen-section-generic.c', 58 'generator/sections/gen-section-ia32x64.c', 59 'generator/sections/gen-section-memory.c', 60 'generator/sections/gen-section-nvidia.c', 61 'generator/sections/gen-section-pci-bus.c', 62 'generator/sections/gen-section-pci-dev.c', 63 'generator/sections/gen-section-pcie.c', 64 'generator/sections/gen-section.c', 65) 66 67cc = meson.get_compiler('c') 68 69json_c_dep = dependency('json-c', required: false) 70if not json_c_dep.found() 71 json_c = subproject( 72 'json-c', 73 required: true, 74 default_options: ['warning_level=0'], 75 ) 76 json_c_dep = json_c.get_variable('json_c_dep') 77endif 78 79libcper_parse_sources = files( 80 'base64.c', 81 'common-utils.c', 82 'cper-parse.c', 83 'cper-utils.c', 84 'ir-parse.c', 85 'json-schema.c', 86) 87 88libcper_include = ['.'] 89 90libcper_parse = library( 91 'cper-parse', 92 libcper_parse_sources, 93 section_sources, 94 edk_sources, 95 version: meson.project_version(), 96 include_directories: include_directories(libcper_include), 97 c_args: '-Wno-address-of-packed-member', 98 dependencies: [json_c_dep], 99 install: true, 100 install_dir: get_option('libdir'), 101) 102libcper_parse_dep = declare_dependency( 103 include_directories: include_directories(libcper_include), 104 link_with: libcper_parse, 105) 106 107libcper_generate_sources = [ 108 'common-utils.c', 109 'generator/cper-generate.c', 110 'generator/gen-utils.c', 111] 112 113libcper_generate = library( 114 'cper-generate', 115 libcper_generate_sources, 116 generator_section_sources, 117 version: meson.project_version(), 118 include_directories: include_directories(libcper_include), 119 dependencies: [libcper_parse_dep, json_c_dep], 120 install: true, 121 install_dir: get_option('libdir'), 122) 123libcper_generate_dep = declare_dependency( 124 include_directories: include_directories(libcper_include), 125 link_with: libcper_generate, 126) 127 128import('pkgconfig').generate( 129 libcper_parse, 130 name: meson.project_name(), 131 version: meson.project_version(), 132 description: 'C bindings for parsing CPER', 133) 134 135install_headers( 136 'cper-parse.h', 137 'cper-parse-str.h', 138 'cper-utils.h', 139 'common-utils.h', 140) 141install_headers('generator/cper-generate.h', subdir: 'generator') 142install_headers('edk/Cper.h', 'edk/BaseTypes.h', subdir: 'edk') 143 144 145if get_option('utility').allowed() 146 executable( 147 'cper-convert', 148 'cli-app/cper-convert.c', 149 include_directories: include_directories(libcper_include), 150 dependencies: [libcper_parse_dep, json_c_dep], 151 install: true, 152 install_dir: get_option('bindir'), 153 ) 154 155 executable( 156 'cper-generate', 157 'generator/cper-generate-cli.c', 158 edk_sources, 159 include_directories: include_directories(libcper_include), 160 dependencies: [libcper_generate_dep], 161 install: true, 162 install_dir: get_option('bindir'), 163 ) 164endif 165 166if get_option('tests').allowed() 167 subdir('tests') 168endif 169