xref: /openbmc/libpldm/src/meson.build (revision c69081afc6e8b5d044448feed9a592396a251238)
1libpldm_sources = files('responder.c', 'utils.c')
2
3subdir('dsp')
4
5if get_option('transport')
6    subdir('requester')
7    subdir('transport')
8endif
9
10if get_option('oem').contains('ibm')
11    subdir('oem/ibm')
12endif
13
14if get_option('oem').contains('meta')
15    subdir('oem/meta')
16endif
17
18libpldm_link_args = []
19foreach alias : libpldm_deprecated_aliases
20    libpldm_link_args += '-Wl,--defsym=@0@=@1@'.format(alias[0], alias[1])
21endforeach
22
23libpldm = library(
24    'pldm',
25    libpldm_sources,
26    implicit_include_directories: false,
27    include_directories: [libpldm_include_dir, include_directories('.')],
28    link_args: libpldm_link_args,
29    version: meson.project_version(),
30    gnu_symbol_visibility: 'hidden',
31    install: true,
32)
33
34libpldm_dep = declare_dependency(
35    include_directories: libpldm_include_dir,
36    link_with: libpldm,
37)
38
39import('pkgconfig').generate(
40    name: 'libpldm',
41    description: 'PLDM protocol encode/decode C lib',
42    version: meson.project_version(),
43    libraries: libpldm,
44)
45
46if get_option('tests')
47    c_suite = meson.get_compiler('c').get_id()
48    cpp_suite = meson.get_compiler('cpp').get_id()
49
50    if get_option('abi-compliance-check') and c_suite == cpp_suite and c_suite == 'gcc'
51        host = host_machine.cpu_family()
52        baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(
53            c_suite,
54        )
55
56        abi_dumper = find_program(
57            'abi-dumper',
58            native: true,
59            required: get_option('abi-compliance-check'),
60        )
61        abi_compliance_checker = find_program(
62            'abi-compliance-checker',
63            native: true,
64            required: get_option('abi-compliance-check'),
65        )
66
67        test_abi_compliance = abi_dumper.found() and\
68abi_compliance_checker.found() and\
69import('fs').is_file(baseline_dump)
70
71        if test_abi_compliance
72            current_dump = custom_target(
73                'abi-dump',
74                input: libpldm,
75                output: 'current.dump',
76                command: [
77                    abi_dumper,
78                    '-mixed-headers',
79                    '-include-paths',
80                    meson.project_source_root() / 'src',
81                    '-public-headers',
82                    meson.project_source_root() / 'include',
83                    '-sort',
84                    '@INPUT@',
85                    '-o',
86                    '@OUTPUT@',
87                    '-lver',
88                    meson.project_version(),
89                ],
90            )
91            abi_compliance = custom_target(
92                'abi-compliance',
93                input: [baseline_dump, current_dump],
94                output: 'abi-compliance',
95                command: [
96                    abi_compliance_checker,
97                    '-l',
98                    meson.project_name(),
99                    '-old',
100                    '@INPUT0@',
101                    '-new',
102                    '@INPUT1@',
103                ],
104                build_by_default: true,
105            )
106        endif
107    endif
108endif
109