forked from iputils/iputils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
384 lines (344 loc) · 10.2 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
project('iputils', 'c',
default_options : [
'c_std=c99',
'warning_level=3',
'localstatedir=var',
],
meson_version : '>=0.39',
version : '20210722') # keep in sync with: git describe | awk -F- '{print $1}'
cc = meson.get_compiler('c')
add_project_arguments(
'-include', 'config.h',
'-include', 'git-version.h',
language : 'c'
)
conf = configuration_data()
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set('_GNU_SOURCE', 1, description : 'Enable GNU extensions on systems that have them.')
build_arping = get_option('BUILD_ARPING')
build_clockdiff = get_option('BUILD_CLOCKDIFF')
build_ninfod = get_option('BUILD_NINFOD')
nifold_messages = get_option('NINFOD_MESSAGES')
build_ping = get_option('BUILD_PING')
build_rarpd = get_option('BUILD_RARPD')
build_rdisc = get_option('BUILD_RDISC')
build_rdisc_server = get_option('ENABLE_RDISC_SERVER')
build_tftpd = get_option('BUILD_TFTPD')
build_tracepath = get_option('BUILD_TRACEPATH')
build_traceroute6 = get_option('BUILD_TRACEROUTE6')
build_mans = get_option('BUILD_MANS')
build_html_mans = get_option('BUILD_HTML_MANS')
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
localedir = join_paths(prefix, get_option('localedir'))
sbindir = join_paths(prefix, get_option('sbindir'))
systemd = dependency('systemd', required : false)
install_systemd_units = systemd.found() or get_option('INSTALL_SYSTEMD_UNITS')
systemdunitdir = get_option('systemdunitdir')
if systemdunitdir == '' and install_systemd_units
systemdunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
endif
setcap_arping = false
setcap_clockdiff = false
setcap_ping = false
setcap_traceroute6 = false
setcap_rdisc = false
if (not get_option('NO_SETCAP_OR_SUID'))
setcap_arping = get_option('SETCAP_OR_SUID_ARPING')
setcap_clockdiff = get_option('SETCAP_OR_SUID_CLOCKDIFF')
setcap_ping = get_option('SETCAP_OR_SUID_PING')
setcap_traceroute6 = get_option('SETCAP_OR_SUID_TRACEROUTE6')
setcap_rdisc = get_option('SETCAP_OR_SUID_RDISC')
endif
# Check functions.
foreach f : '''
__fpending
getrandom
nanosleep
'''.split()
if cc.has_function(f, args : '-D_GNU_SOURCE')
conf.set('HAVE_' + f.to_upper(), 1,
description : 'Define to 1 if you have the ' + f + ' function')
endif
endforeach
if cc.compiles('''
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/icmp6.h>
int main(void) {
struct icmp6_nodeinfo nodeinfo;
return 0;
}
''', name : 'struct icmp6_nodeinfo')
conf.set('HAVE_STRUCT_ICMP6_NODEINFO', 1,
description : 'Defined if struct icmp6_nodeinfo exists.')
endif
if cc.compiles('''
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
int main(void) {
struct tm time;
return 0;
}
''', name : 'struct tm time;')
conf.set('TIME_WITH_SYS_TIME', 1,
description : 'Defined if struct tm exists.')
endif
m_dep = cc.find_library('m')
resolv_dep = cc.find_library('resolv')
if cc.has_function('clock_gettime')
rt_dep = cc.find_library('disabler-appears-to-disable-executable-build', required : false)
else
rt_dep = cc.find_library('rt')
endif
cap = get_option('USE_CAP')
if cap == true
cap_dep = cc.find_library('cap')
conf.set('HAVE_LIBCAP', 1,
description : 'Defined if libcap exists.')
else
cap_dep = dependency('disabler-appears-to-disable-executable-build', required : false)
endif
opt = get_option('ARPING_DEFAULT_DEVICE')
if opt != ''
conf.set_quoted('DEFAULT_DEVICE', opt, description : 'arping default device.')
endif
# Some systems needs intl for gettext
intl_dep = []
gettext = get_option('USE_GETTEXT')
if gettext == true
add_project_arguments(['-DGETTEXT_PACKAGE="iputils"'], language: 'c')
conf.set('ENABLE_NLS', 1, description : 'If set enable I18N.')
conf.set_quoted('LOCALEDIR', localedir)
subdir ('po')
intl_dep += cc.find_library('intl', required : false)
endif
idn = get_option('USE_IDN')
if idn == true
idn_dep = dependency('libidn2', required : false)
if idn_dep.found()
add_project_arguments('-DUSE_IDN', language : 'c')
conf.set('USE_IDN', 1,
description : 'If set use Internationalized Domain Name library.')
endif
else
idn_dep = dependency('disabler-appears-to-disable-executable-build', required : false)
endif
if host_machine.endian() == 'big'
conf.set('WORDS_BIGENDIAN', '1')
endif
if build_rdisc == true
if build_rdisc_server == true
conf.set('RDISC_SERVER', 1, description : 'If set build rdisc server.')
endif
endif
if build_ninfod == true
foreach h : [
'inttypes.h',
'limits.h',
'linux/rtnetlink.h',
'memory.h',
'netdb.h',
'netinet/icmp6.h',
'netinet/in.h',
'netinet/ip6.h',
'pwd.h',
'stdint.h',
'stdlib.h',
'string.h',
'strings.h',
'sys/capability.h',
'syslog.h',
'sys/time.h',
'sys/types.h',
'sys/uio.h',
'sys/utsname.h',
'unistd.h',
]
if cc.has_header(h)
conf.set('HAVE_' + h.to_upper().underscorify(), 1,
description : 'Define if ' + h + ' can be included.')
endif
endforeach
if cc.has_header('stdio.h') and cc.has_header('stdlib.h') and cc.has_header('stddef.h') and cc.has_header('stdarg.h')
conf.set('STDC_HEADERS', 1,
description : 'Define to 1 if you have the ANSI C header files.')
endif
threads = dependency('threads')
if threads.found()
conf.set('ENABLE_THREADS', 1,
description : 'Defined if libpthread is found.')
endif
if host_machine.endian() == 'big'
conf.set('WORDS_BIGENDIAN', 1,
description : 'Defined if processor stores words with the most significant byte first.')
endif
if nifold_messages == true
conf.set('ENABLE_DEBUG', 1, description : 'Enable ninfod syslog messages.')
endif
endif
foreach h : [
'error.h',
]
if cc.has_header(h)
conf.set('HAVE_' + h.to_upper().underscorify(), 1,
description : 'Define if ' + h + ' can be included.')
endif
endforeach
git_version_h = vcs_tag(
input : 'git-version.h.meson',
output : 'git-version.h',
fallback : meson.project_version()
)
config_h = configure_file(
output : 'config.h',
configuration : conf)
setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
if cap_dep.found() and setcap.found()
perm_type = 'caps'
setcap_path = setcap.path()
else
perm_type = 'setuid'
setcap_path = '/dev/null'
endif
############################################################
common_sources = files(
'iputils_common.h', 'iputils_common.c',
'md5.h', 'md5.c'
)
libcommon = static_library(
'common',
[common_sources, git_version_h],
install : false)
if build_ping == true
subdir ('ping')
endif
if build_tracepath == true
executable('tracepath', ['tracepath.c', git_version_h],
dependencies : [idn_dep, intl_dep],
link_with : [libcommon],
install: true)
endif
if build_traceroute6 == true
executable('traceroute6', ['traceroute6.c', git_version_h],
dependencies : [cap_dep, intl_dep, idn_dep],
link_with : [libcommon],
install: true)
if (setcap_traceroute6)
meson.add_install_script('build-aux/setcap-setuid.sh',
bindir,
'traceroute6',
perm_type,
setcap_path
)
endif
endif
if build_clockdiff == true
executable('clockdiff', ['clockdiff.c', git_version_h],
dependencies : [cap_dep, intl_dep],
link_with : [libcommon],
install: true)
if (setcap_clockdiff)
meson.add_install_script('build-aux/setcap-setuid.sh',
bindir,
'clockdiff',
perm_type,
setcap_path
)
endif
endif
if build_rdisc == true
executable('rdisc', ['rdisc.c', git_version_h],
install_dir: sbindir,
link_with : [libcommon],
install: true)
if (setcap_rdisc)
meson.add_install_script('build-aux/setcap-setuid.sh',
sbindir,
'rdisc',
perm_type,
setcap_path
)
endif
if install_systemd_units
subs = configuration_data()
subs.set('sbindir', sbindir)
unit_file = configure_file(
input: 'systemd/rdisc.service.in',
output: 'rdisc.service',
configuration: subs
)
install_data(unit_file, install_dir: systemdunitdir)
endif
endif
if build_arping == true
executable('arping', ['arping.c', git_version_h],
dependencies : [rt_dep, cap_dep, idn_dep, intl_dep],
link_with : [libcommon],
install: true)
if (setcap_arping)
meson.add_install_script('build-aux/setcap-setuid.sh',
bindir,
'arping',
perm_type,
setcap_path
)
endif
endif
if build_tftpd == true
subdir ('tftpd')
endif
if build_rarpd == true
executable('rarpd', ['rarpd.c', git_version_h],
install_dir: sbindir,
link_with : [libcommon],
install: true)
if install_systemd_units
subs = configuration_data()
subs.set('sbindir', sbindir)
unit_file = configure_file(
input: 'systemd/rarpd.service.in',
output: '[email protected]',
configuration: subs
)
install_data(unit_file, install_dir: systemdunitdir)
endif
endif
if build_ninfod == true
subdir ('ninfod')
endif
if build_mans == true or build_html_mans == true
subdir ('doc')
endif
output = '\n\nAPPLICATIONS (build)\n'
output += 'man: ' + build_mans.to_string() + '\n'
output += 'HTML man: ' + build_html_mans.to_string() + '\n'
output += 'arping: ' + build_arping.to_string()
output += ' (capability or suid: ' + setcap_arping.to_string() + ')\n'
output += 'clockdiff: ' + build_clockdiff.to_string()
output += ' (capability or suid: ' + setcap_clockdiff.to_string() + ')\n'
output += 'ninfod: ' + build_ninfod.to_string()
output += ' (syslog: ' + nifold_messages.to_string() + ')\n'
output += 'ping: ' + build_ping.to_string()
output += ' (capability or suid: ' + setcap_ping.to_string() + ')\n'
output += 'rarpd: ' + build_rarpd.to_string() + '\n'
output += 'rdisc: ' + build_rdisc.to_string()
output += ' (server: ' + build_rdisc_server.to_string() + ', '
output += 'capability or suid: ' + setcap_rdisc.to_string() + ')\n'
output += 'tftpd: ' + build_tftpd.to_string() + '\n'
output += 'tracepath: ' + build_tracepath.to_string() + '\n'
output += 'traceroute6: ' + build_traceroute6.to_string()
output += ' (capability or suid: ' + setcap_traceroute6.to_string() + ')\n'
output += '\nCONFIGURATION\n'
output += 'Capatiblity (with libcap): ' + cap.to_string() + '\n'
output += 'IDN (with libidn2): ' + idn.to_string() + '\n'
output += 'I18N (with gettext): ' + gettext.to_string() + '\n'
output += 'systemd: ' + install_systemd_units.to_string() + '\n'
output += '\nSYSTEM PATHS\n'
output += 'prefix: ' + prefix + '\n'
output += 'bindir: ' + bindir + '\n'
output += 'localedir: ' + localedir + '\n'
output += 'sbindir: ' + sbindir + '\n'
output += 'systemdunitdir: ' + systemdunitdir + '\n'
message(output)