1# SPDX-License-Identifier: LGPL-2.1-or-later
2
3_systemd_headers = [
4        'sd-bus.h',
5        'sd-bus-protocol.h',
6        'sd-bus-vtable.h',
7        'sd-daemon.h',
8        'sd-device.h',
9        'sd-event.h',
10        'sd-hwdb.h',
11        'sd-id128.h',
12        'sd-journal.h',
13        'sd-login.h',
14        'sd-messages.h',
15        'sd-path.h',
16]
17
18# https://github.com/mesonbuild/meson/issues/1633
19systemd_headers = files(_systemd_headers)
20
21_not_installed_headers = [
22        'sd-dhcp6-client.h',
23        'sd-dhcp6-lease.h',
24        'sd-dhcp-client.h',
25        'sd-dhcp-lease.h',
26        'sd-dhcp-option.h',
27        'sd-dhcp6-option.h',
28        'sd-dhcp-server.h',
29        'sd-ipv4acd.h',
30        'sd-ipv4ll.h',
31        'sd-lldp-rx.h',
32        'sd-lldp-tx.h',
33        'sd-lldp.h',
34        'sd-ndisc.h',
35        'sd-netlink.h',
36        'sd-network.h',
37        'sd-radv.h',
38        'sd-resolve.h',
39        'sd-utf8.h',
40]
41
42install_headers(
43        systemd_headers,
44        '_sd-common.h',
45        subdir : 'systemd')
46
47############################################################
48
49if want_tests == 'false'
50        subdir_done()
51endif
52
53opts = [['c'],
54        ['c', '-ansi'],
55        ['c', '-std=iso9899:1990'],
56        ['c', '-std=iso9899:2011']]
57
58if cc.has_argument('-std=iso9899:2017')
59        opts += [['c', '-std=iso9899:2017']]
60endif
61
62if cxx_cmd != ''
63        opts += [['c++'],
64                 ['c++', '-std=c++98'],
65                 ['c++', '-std=c++11']]
66        if cxx.has_argument('-std=c++14')
67                opts += [['c++', '-std=c++14']]
68        endif
69        if cxx.has_argument('-std=c++17')
70                opts += [['c++', '-std=c++17']]
71        endif
72        if cxx.has_argument('-std=c++20')
73                opts += [['c++', '-std=c++20']]
74        endif
75endif
76
77foreach header : _systemd_headers + _not_installed_headers + [libudev_h_path]
78        foreach opt : opts
79                std_name = opt.length() == 2 ? '_'.join(opt[1].split(':')) : ''
80                test('cc-' + header.split('/')[-1] + '_' + opt[0] + std_name,
81                     env,
82                     suite : 'headers',
83                     args : [cc.cmd_array(),
84                             '-c',
85                             '-x', opt,
86                             '-Wall',
87                             '-Wextra',
88                             '-Werror',
89                             '-include', meson.current_source_dir() / header,
90                             '-o/dev/null',
91                             '/dev/null'])
92        endforeach
93endforeach
94