xref: /openbmc/libpldm/meson.build (revision 615344fc)
1project(
2    'libpldm',
3    'c',
4    default_options: [
5        'debug=true',
6        'optimization=g',
7        'warning_level=3',
8        'werror=true',
9        'cpp_std=c++23',
10        'c_std=c17',
11        'b_ndebug=if-release',
12        'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
13    ],
14    version: '0.9.1',
15    meson_version: '>=1.1.1',
16)
17
18if get_option('tests').allowed()
19    add_languages('cpp')
20endif
21
22# For memmem() in src/msgbuf.h
23add_project_arguments('-D_GNU_SOURCE', language: ['c'])
24
25compiler = meson.get_compiler('c')
26conf = configuration_data()
27if compiler.has_header('poll.h')
28    conf.set('PLDM_HAS_POLL', 1)
29endif
30
31# ABI control
32visible = '__attribute__((visibility("default")))'
33libpldm_deprecated_aliases = []
34if get_option('abi').contains('deprecated')
35    conf.set('LIBPLDM_ABI_DEPRECATED', visible)
36    add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
37    libpldm_deprecated_aliases += [
38        ['get_fru_record_by_option_check', 'get_fru_record_by_option'],
39        [
40            'pldm_bios_table_append_pad_checksum_check',
41            'pldm_bios_table_append_pad_checksum',
42        ],
43        [
44            'pldm_bios_table_attr_entry_enum_decode_def_num_check',
45            'pldm_bios_table_attr_entry_enum_decode_def_num',
46        ],
47        [
48            'pldm_bios_table_attr_entry_enum_decode_pv_hdls_check',
49            'pldm_bios_table_attr_entry_enum_decode_pv_hdls',
50        ],
51        [
52            'pldm_bios_table_attr_entry_enum_decode_pv_num_check',
53            'pldm_bios_table_attr_entry_enum_decode_pv_num',
54        ],
55        [
56            'pldm_bios_table_attr_entry_enum_encode_check',
57            'pldm_bios_table_attr_entry_enum_encode',
58        ],
59        [
60            'pldm_bios_table_attr_entry_integer_encode_check',
61            'pldm_bios_table_attr_entry_integer_encode',
62        ],
63        [
64            'pldm_bios_table_attr_entry_string_decode_def_string_length_check',
65            'pldm_bios_table_attr_entry_string_decode_def_string_length',
66        ],
67        [
68            'pldm_bios_table_attr_entry_string_encode_check',
69            'pldm_bios_table_attr_entry_string_encode',
70        ],
71        [
72            'pldm_bios_table_attr_value_entry_encode_enum_check',
73            'pldm_bios_table_attr_value_entry_encode_enum',
74        ],
75        [
76            'pldm_bios_table_attr_value_entry_encode_integer_check',
77            'pldm_bios_table_attr_value_entry_encode_integer',
78        ],
79        [
80            'pldm_bios_table_attr_value_entry_encode_string_check',
81            'pldm_bios_table_attr_value_entry_encode_string',
82        ],
83        [
84            'pldm_bios_table_string_entry_decode_string_check',
85            'pldm_bios_table_string_entry_decode_string',
86        ],
87        [
88            'pldm_bios_table_string_entry_encode_check',
89            'pldm_bios_table_string_entry_encode',
90        ],
91        [
92            'pldm_entity_association_pdr_add_check',
93            'pldm_entity_association_pdr_add',
94        ],
95        [
96            'pldm_entity_association_pdr_add_from_node_check',
97            'pldm_entity_association_pdr_add_from_node',
98        ],
99        ['pldm_pdr_add_check', 'pldm_pdr_add'],
100        ['pldm_pdr_add_fru_record_set_check', 'pldm_pdr_add_fru_record_set'],
101    ]
102else
103    conf.set('LIBPLDM_ABI_DEPRECATED', '')
104endif
105conf.set('LIBPLDM_ABI_STABLE', visible)  # Always expose the stable symbols
106if get_option('abi').contains('testing')
107    conf.set('LIBPLDM_ABI_TESTING', visible)
108    add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
109else
110    conf.set('LIBPLDM_ABI_TESTING', '')
111endif
112
113config = configure_file(output: 'config.h', configuration: conf)
114
115add_project_arguments('-include', '@0@'.format(config), language: 'c')
116
117libpldm_include_dir = include_directories('include', is_system: true)
118
119subdir('include')
120subdir('src')
121
122if get_option('tests').allowed()
123    subdir('tests')
124endif
125
126install_subdir(
127    'instance-db',
128    install_mode: 'r--r--r--',
129    install_dir: get_option('datadir') / meson.project_name(),
130)
131