-
Notifications
You must be signed in to change notification settings - Fork 12
/
meson.build
157 lines (126 loc) · 4.51 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
project(
'chimerautils',
['c', 'cpp'],
version: '14.2.0',
default_options: [
'c_std=c99',
'cpp_rtti=false',
'warning_level=2',
'buildtype=debugoptimized'
],
license: 'BSD-3-Clause',
meson_version: '>=0.61'
)
# to be reused
bindir = get_option('bindir')
sbindir = get_option('sbindir')
man1dir = join_paths(get_option('mandir'), 'man1')
man5dir = join_paths(get_option('mandir'), 'man5')
man8dir = join_paths(get_option('mandir'), 'man8')
tiny = get_option('tiny')
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
# Build everything with _GNU_SOURCE enabled
add_project_arguments('-D_GNU_SOURCE', language: ['c', 'cpp'])
# Always use 64-bit file offsets on glibc
add_project_arguments('-D_FILE_OFFSET_BITS=64', language: ['c', 'cpp'])
# Determine whether we can include config-compat.h from public compat code
add_project_arguments('-D_CHIMERAUTILS_BUILD', language: ['c', 'cpp'])
# Get rid of unused metadata variables
add_project_arguments('-Dlint', language: ['c'])
# locate ncurses, and try accounting for separate tinfo if necessary
# as e.g. color ls functionality needs just terminfo and not full curses
tinfo = dependency('tinfo', required: false)
# in that order of preference; 'curses' will fall back to whatever
# meson built-in behavior, which may or may not be correct, in an
# attempt to be compatible with netbsd curses and so on
#
# some stuff needs full curses (nvi, telnet)
foreach opt: ['ncursesw', 'ncurses', 'curses']
ncurses = dependency(opt, required: false)
if ncurses.found()
break
endif
endforeach
# if tinfo is not found, use ncurses; it may be integrated
if not tinfo.found()
tinfo = ncurses
endif
curses_incdefs = []
if cc.has_header('ncursesw/ncurses.h', dependencies: ncurses)
curses_incdefs += ['-DHAVE_NCURSESW_NCURSES_H']
elif cc.has_header('ncurses.h', dependencies: ncurses)
curses_incdefs += ['-DHAVE_NCURSES_H']
endif
# whether to use our own realpath
chimera_realpath = get_option('chimera_realpath')
# libacl is needed in several tools
libacl = dependency('libacl', required: true)
# bc(1) needs libedit
libedit = dependency('libedit', required: get_option('libedit'))
# dc(1), install(1), sort(1), fetch(1) need libcrypto
libcrypto = dependency('libcrypto', required: get_option('openssl'))
# fetch(1) needs libssl
libssl = dependency('libssl', required: get_option('openssl'))
# seq(1) needs libm
libm = cc.find_library('m', required: true)
# df(1) needs libxo
libxo = dependency('libxo', required: true)
# gzip needs zlib
zlib = dependency('zlib', required: get_option('zlib'))
# gzip needs bzip2
bzip2 = cc.find_library('bz2', required: get_option('bzip2'))
# gzip needs liblzma
lzma = dependency('liblzma', required: get_option('lzma'))
# gzip needs zstd
zstd = dependency('libzstd', required: get_option('zstd'))
# su needs pam
pam = dependency('pam', required: get_option('pam'))
# could be openpam, in which case pam_misc is not present
pam_misc = dependency('pam_misc', required: false)
# sort needs pthreads
libpthread = dependency('threads')
# meson at the moment provides no way to rename installed executables
install_as = files('install-as.sh')
libselinux = dependency('libselinux', required: get_option('selinux'))
if libselinux.found()
add_project_arguments('-DHAVE_SELINUX', language: 'c')
endif
# Include all of the relevant subdirectories
subdir('include')
subdir('src.freebsd')
subdir('src.custom')