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