xref: /openbmc/libcper/meson.build (revision 358c7e16f6d17229fbc800bf10acff6cf6f2bc30)
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        'werror=true',
11        'warning_level=2',
12    ],
13)
14
15add_global_arguments(
16    '-DLIBCPER_JSON_SPEC="'
17    + meson.current_source_dir()
18    + '/specification/json/cper-json.json"',
19    language: ['c', 'cpp'],
20)
21
22library_is_share = get_option('default_library') == 'shared'
23
24project_description = 'libcper library'
25
26section_sources = files(
27    'sections/cper-section-arm.c',
28    'sections/cper-section-ccix-per.c',
29    'sections/cper-section-cxl-component.c',
30    'sections/cper-section-cxl-protocol.c',
31    'sections/cper-section-dmar-generic.c',
32    'sections/cper-section-dmar-iommu.c',
33    'sections/cper-section-dmar-vtd.c',
34    'sections/cper-section-firmware.c',
35    'sections/cper-section-generic.c',
36    'sections/cper-section-ia32x64.c',
37    'sections/cper-section-ipf.c',
38    'sections/cper-section-memory.c',
39    'sections/cper-section-pci-bus.c',
40    'sections/cper-section-pci-dev.c',
41    'sections/cper-section-pcie.c',
42    'sections/cper-section.c',
43)
44
45edk_sources = files('edk/Cper.c')
46
47generator_section_sources = files(
48    'generator/sections/gen-section-arm.c',
49    'generator/sections/gen-section-ccix-per.c',
50    'generator/sections/gen-section-cxl-component.c',
51    'generator/sections/gen-section-cxl-protocol.c',
52    'generator/sections/gen-section-dmar.c',
53    'generator/sections/gen-section-firmware.c',
54    'generator/sections/gen-section-generic.c',
55    'generator/sections/gen-section-ia32x64.c',
56    'generator/sections/gen-section-memory.c',
57    'generator/sections/gen-section-pci-bus.c',
58    'generator/sections/gen-section-pci-dev.c',
59    'generator/sections/gen-section-pcie.c',
60    'generator/sections/gen-section.c',
61)
62
63cc = meson.get_compiler('c')
64
65json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
66
67libcper_parse_sources = [
68    'base64.c',
69    'cper-parse.c',
70    'ir-parse.c',
71    'cper-utils.c',
72    'common-utils.c',
73    'json-schema.c',
74]
75
76libcper_include = ['.']
77
78libcper_parse = library(
79    'cper-parse',
80    libcper_parse_sources,
81    section_sources,
82    edk_sources,
83    version: meson.project_version(),
84    include_directories: include_directories(libcper_include),
85    c_args: '-Wno-address-of-packed-member',
86    dependencies: [
87        json_c_dep,
88    ],
89    install: true,
90    install_dir: get_option('libdir'),
91)
92libcper_parse = declare_dependency(
93    include_directories: include_directories(libcper_include),
94    link_with: libcper_parse,
95)
96
97libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
98
99libcper_generate = library(
100    'cper-generate',
101    libcper_generate_sources,
102    generator_section_sources,
103    version: meson.project_version(),
104    include_directories: include_directories(libcper_include),
105    dependencies: [
106        libcper_parse,
107        json_c_dep,
108    ],
109    install: true,
110    install_dir: get_option('libdir'),
111)
112libcper_generate = declare_dependency(
113    include_directories: include_directories(libcper_include),
114    link_with: libcper_generate,
115)
116
117install_headers('cper-parse.h')
118install_headers('cper-utils.h')
119install_headers('common-utils.h')
120install_headers('generator/cper-generate.h', subdir: 'generator')
121install_headers('edk/Cper.h', subdir: 'edk')
122install_headers('edk/BaseTypes.h', subdir: 'edk')
123
124if get_option('utility').allowed()
125    executable(
126        'cper-convert',
127        'cli-app/cper-convert.c',
128        include_directories: include_directories(libcper_include),
129        dependencies: [
130            libcper_parse,
131            json_c_dep,
132        ],
133        install: true,
134        install_dir: get_option('bindir'),
135    )
136
137    executable(
138        'cper-generate',
139        'generator/cper-generate-cli.c',
140        edk_sources,
141        include_directories: include_directories(libcper_include),
142        dependencies: [
143            libcper_generate,
144        ],
145        install: true,
146        install_dir: get_option('bindir'),
147    )
148endif
149
150if get_option('tests').allowed()
151    subdir('tests')
152endif