-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmeson.build
138 lines (113 loc) · 3.89 KB
/
meson.build
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
project('bsdutils',
[ 'c', 'cpp' ],
version : '13.2',
default_options : [
'c_std=c99',
'warning_level=2',
'werror=false',
'buildtype=debugoptimized'
],
license : 'BSD-3-Clause')
# Start with compilers for C and C++
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
# FreeBSD code sometimes ignores things
add_global_arguments([ '-Wno-unused-result' ], language : [ 'c', 'cpp' ])
# Avoid a pointless warning in some programs
if cc.has_argument('-Wstring-plus-int')
add_global_arguments([ '-Wno-string-plus-int' ], language : [ 'c' ])
endif
# Find lex
lex_prog = find_program('flex', 'lex', required : true)
lex = generator(
lex_prog,
output : [ '@[email protected]' ],
arguments: [ '-o', '@OUTPUT0@', '@INPUT@' ],
)
# Find yacc
# (With help from libxkbcommon at https://github.com/xkbcommon/libxkbcommon)
byacc = find_program('byacc', required : false)
if byacc.found()
yacc = generator(
byacc,
output : [ '@[email protected]', '@[email protected]' ],
arguments: [ '-H', '@OUTPUT1@', '-o', '@OUTPUT0@', '@INPUT@' ],
)
else
bison = find_program('bison', required : false)
if bison.found()
yacc = generator(
bison,
output: [ '@[email protected]', '@[email protected]' ],
arguments: [ '--defines=@OUTPUT1@', '-o', '@OUTPUT0@', '@INPUT@' ],
)
else
error('Could not find a compatible yacc(1) program (bison or byacc)')
endif
endif
# Define some macros to eliminate some FreeBSD-specifics in the code
add_global_arguments(
[ '-Dlint',
'-DDEFFILEMODE=(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)',
'-DALLPERMS=(S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)',
'-DO_FSYNC=O_SYNC',
'-DREG_STARTEND=0',
],
language : [ 'c', 'cpp' ]
)
if not cc.has_function('strtoq')
add_global_arguments([ '-Dstrtoq=strtoull' ], language : [ 'c', 'cpp' ])
endif
if cc.has_function('strlcpy')
add_global_arguments('-DHAVE_STRLCPY', language : [ 'c', 'cpp' ])
endif
if cc.has_function('strlcat')
add_global_arguments('-DHAVE_STRLCAT', language : [ 'c', 'cpp' ])
endif
# Build everything with _GNU_SOURCE enabled
add_global_arguments('-D_GNU_SOURCE', language : [ 'c', 'cpp' ])
# Always use 64-bit file offsets on glibc
add_global_arguments('-D_FILE_OFFSET_BITS=64', language : [ 'c', 'cpp' ])
# ls(1) needs the terminfo library
foreach opt : ['tinfo', 'ncursesw', 'ncurses']
libtinfo = cc.find_library(opt, required : false)
if libtinfo.found()
break
endif
endforeach
if not libtinfo.found() and get_option('color_ls')
error('a terminfo library is needed')
endif
# bc(1) needs libedit
libedit = dependency('libedit', required : get_option('libedit'))
# dc(1), install(1) and sort(1) need libcrypto
libcrypto = dependency('libcrypto', required : get_option('libcrypto'))
# seq(1) needs libm
libm = cc.find_library('m', required : true)
# df(1) needs libxo
libxo = dependency('libxo', required : true)
# needed by a few utils; provided by glibc, but not by e.g. musl
fts_dirs = []
rpmatch_dirs = []
if get_option('fts_path') != ''
fts_dirs += get_option('fts_path')
endif
if get_option('rpmatch_path') != ''
rpmatch_dirs += get_option('rpmatch_path')
endif
libfts = dependency('', required: false, static : get_option('static_fts'))
if not cc.has_function('fts_open', prefix: '#include <fts.h>')
libfts = cc.find_library('fts', static : get_option('static_fts'), dirs : fts_dirs)
endif
librpmatch = cc.find_library('rpmatch',
required : false, static : get_option('static_rpmatch'), dirs : rpmatch_dirs
)
# sort needs pthreads
libpthread = dependency('threads')
# Header files for libcompat
inc = include_directories('include')
# Symlink installation script
install_link = meson.current_source_dir() / 'utils/install-link.sh'
# Include all of the relevant subdirectories
subdir('compat')
subdir('src')