summaryrefslogtreecommitdiff
path: root/portability/meson.build
blob: ae8f6bc42c8e44ed85805857a3fc122f71e224fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cc = meson.get_compiler('c')


libportability_src = []


check_functions = [
	['memrchr', 'memrchr.c', 'NEED_MEMRCHR', 'string.h'],
	['strlcpy', 'strlcpy.c', 'NEED_STRLCPY', 'string.h'],
	['pipe2', 'pipe2.c', 'NEED_PIPE2', 'unistd.h'],
	['mknodat', 'mknodat.c', 'NEED_MKNODAT', 'sys/stat.h'],
]


foreach f : check_functions
	if not cc.has_function(f.get(0), prefix: '#include <' + f.get(3) + '>', args: ['-D_GNU_SOURCE']) or not cc.has_header_symbol(f.get(3), f.get(0), args: ['-D_GNU_SOURCE'])
		add_project_arguments('-D' + f.get(2), language: 'c')
		libportability_src += [f.get(1)]
	endif
endforeach


if libportability_src.length() > 0
	libportability = static_library(
		'portability',
		libportability_src,
	)

	libportability_dep = declare_dependency(
		link_whole: libportability,
		include_directories: include_directories('.'),
	)
else
	libportability_dep = declare_dependency(
		include_directories: include_directories('.'),
	)
endif