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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
## EXPERIMENTAL --- WORK IN PROGRESS --- USE AT YOUR OWN PERIL --- ##
project('gnunet', 'c', license: 'AGPLv3',
version: run_command('sh', 'scripts/get_version.sh', check: true).stdout().strip())
add_project_arguments('-D_GNU_SOURCE', language : 'c')
cc = meson.get_compiler('c')
incdir = include_directories('src/include')
cdata = configuration_data()
# Version
gnunet_version = run_command('sh', 'scripts/get_version.sh', check: true).stdout().strip()
cdata.set('gnunet_version', gnunet_version)
r = run_command('sh', 'scripts/get_version.sh', '--major', check: true)
cdata.set('gnunet_major_version', r.stdout().strip())
r = run_command('sh', 'scripts/get_version.sh', '--minor', check: true)
cdata.set('gnunet_minor_version', r.stdout().strip())
r = run_command('sh', 'scripts/get_version.sh', '--micro', check: true)
cdata.set('gnunet_micro_version', r.stdout().strip())
pkgcfgdir = get_option('datadir')/'gnunet'/'config.d'
docdir = get_option('datadir')/'doc'/'gnunet'
install_emptydir(docdir)
install_data('README', 'COPYING', install_dir: docdir)
gnunet_user = false
getent_bin = find_program('getent', '/usr/bin/getent', required : false)
if getent_bin.found()
gnunet_user = true
if run_command('getent', 'passwd', 'gnunet', check: false).returncode() != 0
gnunet_user = false
endif
if run_command('getent', 'group', 'gnunet', check: false).returncode() != 0
gnunet_user = false
endif
if run_command('getent', 'group', 'gnunetdns', check: false).returncode() != 0
gnunet_user = false
endif
endif
# TODO: Set to true to build a single libgnunet
cdata.set('enable_experimental', get_option('experimental'))
if get_option('experimental')
add_project_arguments('-DHAVE_EXPERIMENTAL', language: 'c')
endif
logging_opt = get_option('logging')
if logging_opt == 'yes'
add_project_arguments('-DGNUNET_EXTRA_LOGGING=0', language: 'c')
endif
if logging_opt == 'no'
add_project_arguments('-DGNUNET_EXTRA_LOGGING=0', language: 'c')
add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c')
endif
if logging_opt == 'verbose'
add_project_arguments('-DGNUNET_EXTRA_LOGGING=1', language: 'c')
endif
if logging_opt == 'veryverbose'
add_project_arguments('-DGNUNET_EXTRA_LOGGING=2', language: 'c')
endif
# FIXME
cdata.set('extractor', 0)
cdata.set('PKGDATADIRECTORY', get_option('prefix')/get_option('datadir')/'gnunet')
cdata.set('SYSCONFDIR', get_option('prefix')/get_option('sysconfdir'))
# Various checks
if cc.has_member ('struct sockaddr_in', 'sin_len', prefix : ['#include <sys/types.h>', '#include <sys/socket.h>', '#include <netinet/in.h>'])
add_project_arguments('-DHAVE_SOCKADDR_IN_SIN_LEN', language: 'c')
endif
if cc.has_member ('struct sockaddr_un', 'sun_len', prefix : ['#include <sys/types.h>', '#include <sys/socket.h>', '#include <sys/un.h>'])
add_project_arguments('-DHAVE_SOCKADDR_UN_SUN_LEN', language: 'c')
endif
if cc.has_member ('struct tm', 'tm_gmtoff', prefix : ['#include <time.h>'])
add_project_arguments('-DHAVE_TM_GMTOFF', language: 'c')
endif
# TODO:
# - Go through configure.ac and convert all defines/detections
# - Compile all libs into a single libgnunet
# Gettext
i18n = import('i18n')
gettext_package = 'gnunet'
add_project_arguments('-DGETTEXT_PACKAGE=' + gettext_package, language: 'c')
subdir('po')
# FIXME lots still missing
cdata.set_quoted('PACKAGE_VERSION', '0.21.0')
cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'en0')
cdata.set_quoted('VCS_VERSION', 'mesonbuild')
add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
# Linker settings
# Compiler settings
add_project_arguments('-fno-strict-aliasing', language : 'c')
if cc.has_argument('-Wno-address-of-packed-member')
add_project_arguments('-Wno-address-of-packed-member', language : 'c')
endif
if cc.has_argument('-Wno-tautological-constant-out-of-range-compare')
add_project_arguments('-Wno-tautological-constant-out-of-range-compare', language : 'c')
endif
# FIXME static here, were dynamic in configure.ac
cdata.set('UNIXONLY', '#')
cdata.set('JAVAPORT', '#')
cdata.set('START_ON_DEMAND', 'YES')
cdata.set_quoted('build_target', host_machine.system())
if host_machine.system() == 'linux'
add_project_arguments('-DLINUX', language : 'c')
add_project_link_arguments(['-Wl,--unresolved-symbols=report-all'], language : 'c')
cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'eth0')
endif
if host_machine.system() == 'darwin'
cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'en0')
add_project_arguments('-DDARWIN', language : 'c')
add_project_arguments('-D_APPLE_C_SOURCE', language : 'c')
add_project_arguments('-D__APPLE_USE_RFC_3542', language : 'c')
add_project_arguments('-fno-common', language : 'c')
add_project_link_arguments (['-Wl,-no_fixup_chains'], language: 'c')
endif
# FIXME: Not all dependencies here yet
ltdl_dep = dependency ('libltdl', required: false)
if not ltdl_dep.found()
ltdl_dep = cc.find_library('ltdl', required : true)
endif
unistr_dep = dependency('libunistring', required : false)
if not unistr_dep.found()
unistr_dep = cc.find_library('unistring', required : true)
endif
sqlite_dep = dependency ('sqlite3', version: '>=3.35.0', required : false)
# FIXME for fallbacks, we need to manually check version
if not sqlite_dep.found()
sqlite_dep = cc.find_library('sqlite3', required : true)
sqlite_version_check ='''#include <sqlite3.h>
int main(int argc, char **argv) {
return (SQLITE_VERSION_NUMBER >= 3035000) ? 0 : 1;
}
'''
if cc.run(sqlite_version_check, name : 'sqlite version check',
dependencies: sqlite_dep).returncode() != 0
error('Sqlite version >= 3.35.0 requried')
endif
endif
curl_dep = dependency('libcurl', version: '>=7.85.0', required : false)
if not curl_dep.found()
curl_dep = cc.find_library('curl', required : true)
curl_version_check ='''#include <curl/curl.h>
int main(int argc, char **argv) {
return (LIBCURL_VERSION_NUM >= 0x075500) ? 0 : 1;
}
'''
if cc.run(curl_version_check, name : 'cURL version check',
dependencies: curl_dep).returncode() != 0
error('cURL version >=7.85.0 required')
endif
endif
zlib_dep = dependency('zlib', required : false)
if not zlib_dep.found()
zlib_dep = cc.find_library('zlib', required : true)
endif
mhd_dep = dependency('libmicrohttpd', required : false)
if not mhd_dep.found()
mhd_dep = cc.find_library('microhttpd', required : true)
endif
json_dep = dependency('jansson', required : false)
if not json_dep.found()
json_dep = cc.find_library('jansson', required : true)
endif
gcrypt_dep = dependency('libgcrypt', required : false)
if not gcrypt_dep.found()
gcrypt_dep = cc.find_library('gcrypt', required : true)
endif
gnutls_dep = dependency('libgnutls', required : false)
if not gnutls_dep.found()
gnutls_dep = cc.find_library('gnutls', required : false)
if not gnutls_dep.found()
gnutls_dep = cc.find_library('gnutls-dane', required : true)
endif
endif
sodium_dep = dependency('libsodium', required : false, version: '>=1.0.18')
if not sodium_dep.found()
sodium_dep = cc.find_library('sodium', required : true)
sodium_version_check ='''#include <sodium.h>
int main(int argc, char **argv) {
return ((SODIUM_LIBRARY_VERSION_MAJOR > 10) ||
((SODIUM_LIBRARY_VERSION_MAJOR == 10) &&
(SODIUM_LIBRARY_VERSION_MINOR >= 3))) ? 0 : 1;
}
'''
if cc.run(sodium_version_check, name : 'sodium version check',
dependencies: sodium_dep).returncode() != 0
error('libsodium version >=1.0.18 required')
endif
endif
quic_dep = dependency('libquiche', required : false)
if not quic_dep.found()
quic_dep = cc.find_library('quiche', required : false)
endif
idn_dep = dependency('libidn2', required : false)
if not idn_dep.found()
idn_dep = cc.find_library('idn2', required : false)
endif
if idn_dep.found()
add_project_arguments('-DHAVE_LIBIDN2', language : 'c')
add_project_arguments('-DHAVE_IDN2_H', language : 'c')
else
idn_dep = dependency('libidn', required : false)
if not idn_dep.found()
idn_dep = cc.find_library('idn', required : true)
add_project_arguments('-DHAVE_LIBIDN', language : 'c')
add_project_arguments('-DHAVE_IDN_H', language : 'c')
endif
endif
pthread_dep = cc.find_library('pthread', required : false)
if pthread_dep.found()
add_project_arguments('-DHAVE_PTHREAD', language : 'c')
endif
m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_arguments('-DHAVE_LIBM', language : 'c')
endif
sock_dep = cc.find_library('socket', required : false)
if sock_dep.found()
add_project_arguments('-DHAVE_LIBSOCKET', language : 'c')
endif
gopt_bin = find_program('getopt', '/usr/bin/getopt', required : false)
if gopt_bin.found()
add_project_arguments('-DHAVE_GETOPT_BINARY='+gopt_bin.full_path(), language : 'c')
endif
ifconfig_bin = find_program('ifconfig', '/usr/sbin/ifconfig', required : false)
if ifconfig_bin.found()
cdata.set_quoted('IFCONFIG', ifconfig_bin.full_path())
endif
ip_bin = find_program('ip', '/usr/sbin/ip', required : false)
if ip_bin.found()
cdata.set_quoted('PATH_TO_IP', ip_bin.full_path())
endif
iptables_bin = find_program('iptables', '/usr/sbin/iptables', required : false)
if iptables_bin.found()
cdata.set_quoted('IPTABLES', iptables_bin.full_path())
endif
adduser_bin = find_program('adduser', '/usr/sbin/adduser', required : false)
pkgc_bin = find_program('pkg-config', '/usr/bin/pkg-config', required : false)
if pkgc_bin.found()
add_project_arguments('-DHAVE_PKG_CONFIG', language : 'c')
endif
ssh_bin = find_program('ssh', '/usr/bin/ssh', required : false)
if ssh_bin.found()
add_project_arguments('-DHAVE_SSH_BINARY', language : 'c')
endif
# FIXME we are not doing anything with this right now
sudo_bin = find_program('sudo', '/usr/bin/sudo', required : false)
doas_bin = find_program('doas', '/usr/bin/doas', required : false)
# Optional dependencies
pq_dep = dependency('libpq', required : false)
if not pq_dep.found()
pq_dep = cc.find_library('pq', required : false)
endif
if pq_dep.found()
add_project_arguments('-DHAVE_POSTGRESQL', language : 'c')
endif
zbar_dep = dependency('libzbar', required : false)
if not zbar_dep.found()
zbar_dep = cc.find_library('zbar', required : false)
endif
if zbar_dep.found()
add_project_arguments('-DHAVE_ZBAR', language : 'c')
endif
jose_dep = dependency('libjose', required : false)
if not jose_dep.found()
jose_dep = cc.find_library('jose', required : false)
endif
if jose_dep.found()
add_project_arguments('-DHAVE_JOSE', language : 'c')
endif
## FIXME conversation: pulse/gst detection in configure.ac obviously
## broken. Needs reconsideration. No idea for now.
pulse_dep = dependency('libpulse', required : false)
if not pulse_dep.found()
pulse_dep = cc.find_library('pulse', required : false)
endif
if pulse_dep.found()
add_project_arguments('-DHAVE_PULSE', language : 'c')
endif
opus_dep = dependency('libopus', required : false)
if not opus_dep.found()
opus_dep = cc.find_library('opus', required : false)
endif
if opus_dep.found()
add_project_arguments('-DHAVE_OPUS', language : 'c')
endif
ogg_dep = dependency('libogg', required : false)
if not ogg_dep.found()
ogg_dep = cc.find_library('ogg', required : false)
endif
if ogg_dep.found()
add_project_arguments('-DHAVE_OGG', language : 'c')
endif
gst_dep = dependency('gstreamer-1.0', required : false)
if not gst_dep.found()
gst_dep = cc.find_library('gstreamer-1.0', required : false)
endif
gst_app_dep = dependency('gstreamer-app-1.0', required : false)
if not gst_app_dep.found()
gst_app_dep = cc.find_library('gstreamer-app-1.0', required : false)
endif
gst_audio_dep = dependency('gstreamer-audio-1.0', required : false)
if not gst_audio_dep.found()
gst_audio_dep = cc.find_library('gstreamer-audio-1.0', required : false)
endif
conversation_backend = 'none'
if pulse_dep.found() and opus_dep.found() and ogg_dep.found()
conversation_backend = 'pulse'
elif gst_dep.found() and gst_app_dep.found() and gst_audio_dep.found()
add_project_arguments('-DHAVE_GST', language : 'c')
conversation_backend = 'gst'
endif
## END conversation
add_project_arguments('-DNEED_LIBGCRYPT_VERSION="1.6.0"', language : 'c')
if cc.check_header('sys/time.h')
add_project_arguments('-DHAVE_SYS_TIME_H', language : 'c')
endif
if cc.check_header('sys/param.h')
add_project_arguments('-DHAVE_SYS_PARAM_H', language : 'c')
endif
# NSS
have_nss = false
if cc.check_header('nss.h')
have_nss = true
add_project_arguments('-DHAVE_GLIBCNSS', language : 'c')
endif
# TUN
tun_found = false
if cc.check_header('if_tun.h')
if cc.has_header_symbol('if_tun.h', 'struct in6_ifreq')
add_project_arguments('-DIF_TUN_HDR="if_tun.h"', language : 'c')
tun_found = true
endif
endif
if not tun_found and cc.check_header('linux/if_tun.h')
if cc.has_header_symbol('linux/if_tun.h', 'struct in6_ifreq')
add_project_arguments('-DIF_TUN_HDR="linux/if_tun.h"', language : 'c')
tun_found = true
endif
endif
if not tun_found and cc.check_header('net/if_tun.h')
if cc.has_header_symbol('net/if_tun.h', 'struct in6_ifreq')
add_project_arguments('-DIF_TUN_HDR="net/if_tun.h"', language : 'c')
tun_found = true
endif
endif
if not tun_found and cc.check_header('net/tun/if_tun.h')
if cc.has_header_symbol('net/tun/if_tun.h', 'struct in6_ifreq')
add_project_arguments('-DIF_TUN_HDR="net/tun/if_tun.h"', language : 'c')
tun_found = true
endif
endif
# NSS
if cc.check_header('nss.h')
add_project_arguments('-DHAVE_GLIBCNSS', language : 'c')
endif
# GNUTLS DANE
if cc.check_header('gnutls/dane.h')
if cc.has_function('dane_verify_crt_raw',
prefix: '#include <gnutls/dane.h>',
dependencies: gnutls_dep)
add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c')
endif
endif
curl_ssl_check ='''#include <curl/curl.h>
int main(int argc, char **argv) {
return (CURLSSLSET_OK != curl_global_sslset(CURLSSLBACKEND_GNUTLS, NULL, NULL));
}
'''
result = cc.run(curl_ssl_check, name : 'cURL gnutls check',
dependencies: curl_dep)
cdata.set('curl_gnutls', 0)
if result.returncode() == 0
cdata.set('curl_gnutls', 1)
endif
if cc.has_function('getloadavg') == false
error('getloadadv missing')
endif
if cc.has_function('strnlen', prefix : '#include <string.h>')
cdata.set('HAVE_STRNLEN', 1)
endif
if cc.has_function('memset_s')
cdata.set('HAVE_MEMSET_S', 1)
endif
if cc.has_function('explicit_bzero')
cdata.set('HAVE_EXPLICIT_BZERO', 1)
endif
if cc.has_function('gethostbyname')
cdata.set('HAVE_GETHOSTBYNAME', 1)
endif
if cc.has_function('gethostbyname2')
cdata.set('HAVE_GETHOSTBYNAME2', 1)
endif
if cc.has_function('getifaddrs')
cdata.set('HAVE_GETIFADDRS', 1)
endif
if cc.has_function('freeifaddrs')
cdata.set('HAVE_FREEIFADDRS', 1)
endif
if cc.check_header('ifaddrs.h')
add_project_arguments('-DHAVE_IFADDRS_H', language : 'c')
endif
configure_file(#input: 'gnunet_private_config.h.in',
output : 'gnunet_private_config.h',
configuration : cdata)
configuration_inc = include_directories('.')
pkg = import('pkgconfig')
subdir('scripts')
subdir('src')
subdir('doc')
subdir('contrib')
subdir('data')
meson.add_dist_script('meson-dist-script')
gnunet_prefix = get_option('prefix')/get_option('libdir')
add_test_setup('default', env: ['GNUNET_PREFIX='+gnunet_prefix], exclude_suites: ['perf'], is_default: true)
add_test_setup('full', env: ['GNUNET_PREFIX='+gnunet_prefix], is_default: false)
summary({'host': host_machine.system(),
'prefix': get_option('prefix'),
'compiler': cc.get_id(),
'libdir': get_option('libdir'),
'datadir': get_option('datadir'),
'default interface': cdata.get('GNUNET_DEFAULT_INTERFACE'),
'PostgreSQL': pq_dep.found(),
'curl w/ gnutls': (cdata.get('curl_gnutls') == 1),
'ifconfig': ifconfig_bin.found(),
'iptables': iptables_bin.found()
}, section: 'Detected system')
if not gnunet_user
message('Please make sure NOW to create a user and group \'gnunet\' and additionally a group \'gnunetdns\'. Make sure that \'/var/lib/gnunet\' is owned (and writable) by user \'gnunet\'')
message('Each user of GNUnet should be added to the \'gnunet\' group')
if adduser_bin.found() and not gnunet_user
message('''Create the gnunet user and add users to the gnunetdns group, run:
# addgroup gnunetdns
# adduser --system --disabled-login --home /var/lib/gnunet gnunet''')
message('''To add users to the gnunet group, run:
# adduser USERNAME gnunet
for each of your users, replacing \'USERNAME\' with the respective login name.
Users may have to login again for the changes to take effect.''')
endif
endif
|