-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathmeson.build
More file actions
2806 lines (2449 loc) · 77.1 KB
/
Copy pathmeson.build
File metadata and controls
2806 lines (2449 loc) · 77.1 KB
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
project(
'netatalk',
version: '4.6.0dev',
license: 'GPLv2',
default_options: ['warning_level=3', 'c_std=c11', 'b_ndebug=if-release'],
meson_version: '>=0.62.0',
)
####################
# Global variables #
####################
cdata = configuration_data()
fs = import('fs')
netatalk_version = meson.project_version()
cpu = host_machine.cpu_family()
host_os = host_machine.system()
target_os = target_machine.system()
build_type = get_option('buildtype')
linux_distro = ''
if host_os == 'linux' and fs.exists('/etc/os-release')
os_release = fs.read('/etc/os-release').strip()
if os_release.contains('alpine')
linux_distro = 'alpine'
elif os_release.contains('arch')
linux_distro = 'arch'
elif os_release.contains('centos')
linux_distro = 'centos'
elif os_release.contains('gentoo')
linux_distro = 'gentoo'
elif os_release.contains('suse')
linux_distro = 'suse'
elif os_release.contains('fedora')
linux_distro = 'fedora'
elif os_release.contains('rhel')
linux_distro = 'rhel'
elif os_release.contains('ubuntu')
linux_distro = 'ubuntu'
elif os_release.contains('debian')
linux_distro = 'debian'
endif
message('Linux distro detected: ' + linux_distro)
endif
uname = find_program('uname', required: false)
uname_stdout = run_command(uname, '-a', check: false).stdout().strip()
#########
# Paths #
#########
prefix = get_option('prefix')
exec_prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
includedir = prefix / get_option('includedir')
libdir = prefix / get_option('libdir')
libexecdir = prefix / get_option('libexecdir')
mandir = prefix / get_option('mandir')
sbindir = prefix / get_option('sbindir')
sysconfdir = prefix / get_option('sysconfdir')
pkgconfdir = get_option('with-pkgconfdir-path')
if pkgconfdir == ''
pkgconfdir = sysconfdir
endif
# TODO: This breaks FHS. Should be /var/lib or the platform-specific equivalent.
# Meson's built-in option is called sharedstatedir.
# Will keep the non-standard location for now to avoid breaking existing setups.
# Ref: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s08.html
localstatedir = prefix / get_option('localstatedir')
statedir_override = get_option('with-statedir-path')
if statedir_override != ''
localstatedir = statedir_override
endif
if host_os == 'darwin'
homedir = '/Users'
elif host_os == 'sunos'
homedir = '/export/home'
else
homedir = '/home'
endif
docs_install_path = datadir / 'doc' / meson.project_name()
if get_option('with-docs-install-path') != ''
docs_install_path = get_option('with-docs-install-path')
endif
with_docs_only = get_option('with-docs-only')
docs_options = get_option('with-docs')
if with_docs_only and docs_options == []
error('with-docs-only requires at least one documentation type in with-docs')
endif
#
# Check for Perl
#
perl_path = get_option('with-perl-path')
if perl_path == ''
perl = find_program('perl', required: false)
else
perl = find_program(perl_path / 'perl', required: false)
endif
#########################
# Prepare documentation #
#########################
cmark = find_program('cmark', required: false)
cmarkgfm = find_program('cmark-gfm', required: false)
pandoc = find_program('pandoc', required: false)
doxygen = find_program('doxygen', required: false)
build_man_docs = false
build_html_docs = false
build_readme_docs = false
build_dev_docs = false
if 'readmes' in docs_options
build_readme_docs = true
readmes_md = [
'CODE_OF_CONDUCT',
'CONTAINERS',
'CONTRIBUTING',
'CONTRIBUTORS',
'INSTALL',
'NEWS',
'README',
'SECURITY',
]
if get_option('with-website') and perl.found()
make_compile_doc = find_program('contrib/scripts/make_compile_docs.pl', required: true)
run_command(
make_compile_doc,
'.github/workflows/build.yml',
'.github/workflows/spectest-macos.yml',
'.github/workflows/spectest-vms.yml',
'COMPILATION.md',
check: true,
)
readmes_md += ['COMPILATION']
endif
foreach file : readmes_md
if get_option('with-website')
install_data(file + '.md', install_dir: docs_install_path / 'manual')
else
if pandoc.found()
custom_target(
'readmes_' + file,
input: file + '.md',
output: file + '.txt',
command: [
pandoc,
'--from', 'gfm+pipe_tables',
'--to', 'plain',
'@INPUT@',
],
capture: true,
install: true,
install_dir: datadir / 'doc/netatalk',
install_tag: 'doc',
)
elif cmarkgfm.found()
custom_target(
'readmes_' + file,
input: file + '.md',
output: file + '.txt',
command: [
cmarkgfm,
'--extension', 'table',
'--width', '80',
'--to', 'plaintext',
'@INPUT@',
],
capture: true,
install: true,
install_dir: datadir / 'doc/netatalk',
install_tag: 'doc',
)
else
install_data(
file + '.md',
install_dir: datadir / 'doc/netatalk',
install_tag: 'doc',
)
endif
endif
endforeach
endif
if 'man' in docs_options
if cmark.found() or cmarkgfm.found() or pandoc.found()
build_man_docs = true
else
warning('cmark, cmark-gfm, or pandoc is required to build man pages')
endif
endif
if 'html_manual' in docs_options
if cmark.found() or cmarkgfm.found() or pandoc.found()
build_html_docs = true
else
warning('cmark, cmark-gfm or pandoc is required to build the html manual')
endif
endif
if 'developer' in docs_options
if doxygen.found()
build_dev_docs = true
else
warning('doxygen is required to build developer documentation')
endif
endif
if with_docs_only
use_dbd_backend = 'dbd' in get_option('with-cnid-backends')
have_appletalk = get_option('with-appletalk')
if docs_options != []
subdir('doc')
endif
summary(
{'Netatalk version': netatalk_version},
section: 'Configuration Summary:',
)
summary(
{'Documentation-only build': true},
bool_yn: true,
section: ' Options:',
)
summary(
{
' developer': build_dev_docs,
' html manual': build_html_docs,
' man pages': build_man_docs,
' readmes': build_readme_docs,
},
bool_yn: true,
section: ' Documentation:',
)
subdir_done()
endif
add_languages('c', native: false)
cc = meson.get_compiler('c')
if not cc.compiles('int func() { return 0; }')
error('The C compiler cannot compile code. Please check the logs.')
endif
##################
# Compiler flags #
##################
# Global
netatalk_common_flags = [
'-DHAVE_CONFIG_H',
'-Wno-pedantic',
'-Wno-extra',
'-Wno-all',
'-Wno-deprecated-declarations',
]
netatalk_c_flags = cc.get_supported_arguments('-Werror=implicit-function-declaration')
if host_os == 'linux'
netatalk_common_flags += '-D_GNU_SOURCE'
elif host_os == 'sunos'
netatalk_common_flags += [
'-D__EXTENSIONS__',
'-D_ISOC9X_SOURCE',
'-D_XOPEN_SOURCE=600',
]
endif
if build_type == 'debug'
netatalk_common_flags += '-DDEBUG'
endif
add_global_arguments(netatalk_common_flags, language: 'c')
add_global_arguments(netatalk_c_flags, language: 'c')
netatalk_common_link_args = []
if 'xapian' in get_option('with-spotlight-backends')
cpp_found = add_languages('cpp', native: false, required: false)
if cpp_found
add_global_arguments(netatalk_common_flags, language: 'cpp')
endif
else
cpp_found = false
endif
# Per target
afpd = '-D_PATH_AFPD="' + sbindir + '/afpd"'
afpdpwfile = '-D_PATH_AFPDPWFILE="' + pkgconfdir + '/afppasswd"'
afpdsrppwfile = '-D_PATH_AFPDSRPPWFILE="' + pkgconfdir + '/afppasswd.srp"'
cnid_dbd = '-D_PATH_CNID_DBD="' + sbindir + '/cnid_dbd"'
cnid_metad = '-D_PATH_CNID_METAD="' + sbindir + '/cnid_metad"'
confdir = '-D_PATH_CONFDIR="' + pkgconfdir + '/"'
dversion = '-DVERSION="' + netatalk_version + '"'
messagedir = '-DSERVERTEXT="' + localstatedir + '/netatalk/msg/"'
naddir = '-D_PATH_NAD="' + bindir + '/nad"'
statedir = '-D_PATH_STATEDIR="' + localstatedir + '/netatalk/"'
uamdir = '-D_PATH_AFPDUAMPATH="' + libdir + '/netatalk/"'
############
# Includes #
############
include_dirs = [
'.',
'include',
'sys',
'etc/afpd',
]
if host_os in ['dragonfly', 'freebsd', 'openbsd']
include_dirs += ['/usr/local/include']
elif host_os == 'netbsd'
include_dirs += ['/usr/pkg/include']
elif uname.found() and uname_stdout.to_lower().contains('omnios')
include_dirs += ['/opt/local/include']
endif
# note: the brew app is not visible from within the brew build wrapper iteslf,
# so rather than checking for brew we apply a blanket prefix
brew_prefix = ''
if get_option('with-homebrew') == true
if host_os == 'darwin'
if cpu == 'aarch64' and fs.is_dir('/opt/homebrew')
brew_prefix = '/opt/homebrew'
if fs.is_dir(brew_prefix + '/include')
include_dirs += brew_prefix + '/include'
endif
elif cpu == 'x86_64'
brew_prefix = '/usr/local'
endif
elif host_os == 'linux' and fs.is_dir('/opt/linuxbrew/.linuxbrew')
brew_prefix = '/home/linuxbrew/.linuxbrew'
if fs.is_dir(brew_prefix + '/include')
include_dirs += brew_prefix + '/include'
endif
endif
endif
#############
# Libraries #
#############
libsearch_dirs = []
if host_os in ['dragonfly', 'freebsd', 'openbsd']
libsearch_dirs += '/usr/local/lib'
elif host_os == 'netbsd'
libsearch_dirs += '/usr/pkg/lib'
elif uname.found() and uname_stdout.to_lower().contains('omnios')
libsearch_dirs += '/opt/local/lib'
endif
if brew_prefix != ''
libsearch_dirs += brew_prefix + '/lib'
endif
socket = cc.find_library('socket', required: false)
if socket.found()
netatalk_common_link_args += '-lsocket'
endif
sendfile = cc.find_library('sendfile', required: false)
if sendfile.found()
netatalk_common_link_args += '-lsendfile'
endif
nsl = cc.find_library('nsl', required: false)
if nsl.found()
netatalk_common_link_args += '-lnsl'
endif
dl = cc.find_library('dl', required: false)
if dl.found()
netatalk_common_link_args += '-ldl'
endif
math = cc.find_library('m', required: true)
if math.found()
netatalk_common_link_args += '-lm'
endif
# Check if GCC atomic builtins need explicit libatomic linkage.
# On some platforms (e.g. 32-bit ARM, MIPS) 64-bit atomics are not inlined
# by the compiler and require an explicit -latomic link flag.
atomic_test_code = '''
#include <stdint.h>
int main(void) {
uint64_t x = 0;
__atomic_fetch_add(&x, 1, __ATOMIC_SEQ_CST);
__atomic_load_n(&x, __ATOMIC_SEQ_CST);
uint64_t y = __atomic_exchange_n(&x, 1, __ATOMIC_SEQ_CST);
(void)y;
return 0;
}
'''
if not cc.links(atomic_test_code, name: 'atomic builtins without -latomic')
# Find the library: system paths, platform paths
atomic = cc.find_library('atomic', required: false)
foreach d : libsearch_dirs
if not atomic.found()
atomic = cc.find_library('atomic', dirs: d, required: false)
if atomic.found()
netatalk_common_link_args += ['-L' + d]
endif
endif
endforeach
if atomic.found()
netatalk_common_link_args += '-latomic'
endif
have_atomic = atomic.found()
if not have_atomic
error('libatomic is required! Please install it.')
endif
endif
add_global_link_arguments(netatalk_common_link_args, language: 'c')
if cpp_found
add_global_link_arguments(netatalk_common_link_args, language: 'cpp')
endif
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif
#################
# Header checks #
#################
header_dir = []
if host_os in ['dragonfly', 'freebsd', 'openbsd']
header_dir += '/usr/local/include'
endif
check_headers = [
'acl/libacl.h',
'attr/xattr.h',
'crypt.h',
'dlfcn.h',
'iniparser/iniparser.h',
'langinfo.h',
'linux/dqblk/xfs.h',
'linux/xqm.h',
'locale.h',
'mntent.h',
'pam/pam_appl.h',
'security/pam_appl.h',
'sgtty.h',
'sys/attr.h',
'sys/ea.h',
'sys/extattr.h',
'sys/mnttab.h',
'sys/mount.h',
'sys/sysinfo.h',
'sys/vfs.h',
'sys/xattr.h',
'ufs/quota.h',
'xfs/xqm.h',
]
foreach h : check_headers
if cc.has_header(h, include_directories: include_directories(header_dir))
cdata.set('HAVE_' + h.underscorify().to_upper(), 1)
endif
endforeach
###################
# Function checks #
###################
check_functions = [
'asprintf',
'backtrace_symbols',
'dirfd',
'explicit_bzero',
'getpwnam_shadow',
'memset_explicit',
'pread',
'pselect',
'pwrite',
'rresvport',
'splice',
'strlcat',
'strlcpy',
'strnlen',
'vasprintf',
]
foreach f : check_functions
if cc.has_function(f)
cdata.set('HAVE_' + f.underscorify().to_upper(), 1)
endif
endforeach
if cc.has_function('mempcpy', prefix: '#include <string.h>')
cdata.set('HAVE_MEMPCPY', 1)
endif
if cc.has_function('getifaddrs', dependencies: socket)
cdata.set('HAVE_GETIFADDRS', 1)
endif
at_functions = [
'openat',
'renameat',
'fstatat',
'unlinkat',
]
foreach f : at_functions
if not cc.has_function(f)
error('Standard C library function @0@ is required'.format(f))
endif
endforeach
##########################
# Type and member checks #
##########################
if cc.has_type('fshare_t', prefix: '#include <fcntl.h>')
cdata.set('HAVE_FSHARE_T', 1)
endif
if cc.has_member('struct stat', 'st_birthtimespec', prefix: '#include <sys/stat.h>')
cdata.set('HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC', 1)
endif
if cc.has_member('struct stat', 'st_mtim', prefix: '#include <sys/stat.h>')
cdata.set('HAVE_STRUCT_STAT_ST_MTIM', 1)
endif
if cc.has_member('struct stat', 'st_atim', prefix: '#include <sys/stat.h>')
cdata.set('HAVE_STRUCT_STAT_ST_ATIM', 1)
endif
if cc.has_member('struct stat', 'st_mtimespec', prefix: '#include <sys/stat.h>')
cdata.set('HAVE_STRUCT_STAT_ST_MTIMESPEC', 1)
endif
if cc.has_member('struct stat', 'st_atimespec', prefix: '#include <sys/stat.h>')
cdata.set('HAVE_STRUCT_STAT_ST_ATIMESPEC', 1)
endif
#################
# Configuration #
#################
#
# Check for 64-bit libraries
#
compiler_64_bit_mode = false
file = find_program('file', required: false)
if file.found()
run_command(
cc,
'-c', meson.project_source_root() / 'libatalk/dummy.c',
'-o', meson.global_build_root() / 'dummy.o',
check: false,
)
compiler_64_bit_mode = run_command(
file,
meson.global_build_root() / 'dummy.o',
check: true,
).stdout().strip().contains('ELF 64')
endif
#
# Check whether to enable rpath (the default on Solaris and NetBSD)
#
rpath_libdir = ''
if host_os == 'sunos' or host_os == 'netbsd' or get_option('with-rpath')
rpath_libdir = libdir
endif
#
# Check which CNID backends to compile
#
cnid_backends = ''
#
# Check for the Berkeley DB library for the Database Daemon CNID backend
#
use_dbd_backend = false
have_bdb = false
grep = find_program('grep', required: false)
if 'dbd' in get_option('with-cnid-backends')
bdb_path = get_option('with-bdb-path')
bdb_include_path_override = get_option('with-bdb-include-path')
bdb_req_version = get_option('with-bdb-version')
bdb_header = ''
bdb_includes = []
bdb_libdir = ''
bdb_major_version = ''
bdb_minor_version = ''
bdb_version = ''
bdb_dirs = []
if bdb_path != ''
bdb_dirs += [bdb_path]
else
if brew_prefix != ''
bdb_dirs += [
brew_prefix / 'opt/berkeley-db@5',
brew_prefix / 'opt/berkeley-db@4',
brew_prefix / 'opt/berkeley-db',
]
endif
bdb_dirs += [
'/usr/local',
'/usr/pkg',
'/opt/local',
'/usr',
]
endif
bdb_subdirs = [
'db62',
'db6.2',
'db61',
'db6.1',
'db5',
'db53',
'db5.3',
'db52',
'db5.2',
'db51',
'db5.1',
'db50',
'db5.0',
'db4',
'db48',
'db4.8',
'db47',
'db4.7',
'db46',
'db4.6',
'',
]
if bdb_req_version != ''
if not bdb_req_version.version_compare('>=4.6')
error('Berkeley DB library version is below supported 4.6')
endif
message('Searching for Berkeley DB library version', bdb_req_version)
endif
foreach dir : bdb_dirs
foreach subdir : bdb_subdirs
if bdb_include_path_override != ''
bdb_include_path = bdb_include_path_override
else
bdb_include_path = dir / 'include' / subdir
endif
bdb_header = bdb_include_path / 'db.h'
if fs.exists(bdb_header)
bdb_includes = include_directories(bdb_include_path)
grep_result = run_command(
'grep',
'DB_VERSION_MAJOR',
bdb_header,
check: false,
)
if grep_result.returncode() != 0
warning(
'Unable to determine Berkeley DB major version from header',
bdb_header,
)
continue
endif
bdb_major_version = grep_result.stdout().strip().substring(25)
grep_result = run_command(
'grep',
'DB_VERSION_MINOR',
bdb_header,
check: false,
)
if grep_result.returncode() != 0
warning(
'Unable to determine Berkeley DB minor version from header',
bdb_header,
)
continue
endif
bdb_minor_version = grep_result.stdout().strip().substring(25)
bdb_version = bdb_major_version + '.' + bdb_minor_version
if not bdb_version.version_compare('>=4.6')
continue
endif
if bdb_req_version != '' and not bdb_version.version_compare('~' + bdb_req_version)
continue
endif
message('Berkeley DB header found at', bdb_header)
# Now find lib file matching header
if target_os == 'sunos' and compiler_64_bit_mode and fs.exists(dir / 'lib/64')
bdb_libdir = dir / 'lib/64'
else
bdb_libdir = dir / 'lib'
endif
# Guess lib name starting from more specific ones
bdb_libnames = [
'db-' + bdb_major_version + '.' + bdb_minor_version,
'db' + bdb_major_version + '.' + bdb_minor_version,
'db' + bdb_major_version + bdb_minor_version,
'db-' + bdb_major_version,
'db' + bdb_major_version,
'db',
]
foreach name : bdb_libnames
libdb = cc.find_library(name, dirs: bdb_libdir, required: false)
if not libdb.found()
libdb = cc.find_library(name, dirs: bdb_libdir / subdir, required: false)
endif
if libdb.found()
have_bdb = true
break
endif
endforeach
if have_bdb
break
endif
endif
endforeach
if have_bdb
break
endif
endforeach
if have_bdb
use_dbd_backend = true
cnid_backends += 'dbd'
cdata.set('CNID_BACKEND_DBD', 1)
else
if bdb_req_version != ''
msg = 'Berkeley DB library version ' + bdb_req_version + ' requested via -Dwith-bdb-version= not found!'
else
msg = 'Berkeley DB library not found, bdb CNID backend will not be built!'
endif
message(
msg,
'If you want dbd CNID backend support, define the Berkeley DB path using the -Dwith-bdb-path= configure option (must include lib and include dirs)',
)
endif
endif
# Check for mysql CNID backend
mysqlclient = dependency('mysqlclient', required: false)
mariadb = dependency('libmariadb', required: false)
use_mysql_backend = false
if 'mysql' in get_option('with-cnid-backends')
if mysqlclient.found()
mysql_deps = mysqlclient
else
mysql_deps = mariadb
endif
if mysql_deps.found()
use_mysql_backend = (
fs.exists(
mysql_deps.get_variable(pkgconfig: 'includedir') / 'mysql.h',
)
)
endif
if use_mysql_backend
if cnid_backends != ''
cnid_backends += ' | '
endif
cnid_backends += 'mysql'
cdata.set('CNID_BACKEND_MYSQL', 1)
# Check for mysql_get_socket() function (added in MySQL 5.7.9 / MariaDB 10.0)
if cc.has_function('mysql_get_socket', dependencies: mysql_deps)
cdata.set('HAVE_MYSQL_GET_SOCKET', 1)
endif
endif
endif
# Check for sqlite CNID backend
sqlite_deps = dependency('sqlite3', required: false)
use_sqlite_backend = false
if 'sqlite' in get_option('with-cnid-backends') and sqlite_deps.found()
use_sqlite_backend = true
if cnid_backends != ''
cnid_backends += ' | '
endif
cnid_backends += 'sqlite'
cdata.set('CNID_BACKEND_SQLITE', 1)
endif
compiled_backends = '"' + cnid_backends + '"'
cdata.set('compiled_backends', compiled_backends)
summary_backends = cnid_backends
# Determine default CNID backend
if use_sqlite_backend
default_backend = 'sqlite'
elif use_mysql_backend
default_backend = 'mysql'
elif use_dbd_backend
default_backend = 'dbd'
else
error('No CNID backends selected for compilation')
endif
cdata.set('DEFAULT_CNID_SCHEME', '"' + default_backend + '"')
#
# Check for Better String Library
#
bgets_test_code = '''
#include <stdio.h>
#include <libgen.h>
int main() {
char buffer[256];
char delim = '\n';
FILE *fp = stdin;
char *result = bgets(buffer, sizeof(buffer), fp, &delim);
return 0;
}
'''
has_bgets = cc.compiles(bgets_test_code, name: 'bgets defined in standard C library')
cdata.set('HAVE_BGETS', has_bgets)
bstring = dependency('bstring', required: false)
if not bstring.found() or get_option('with-subprojects')
bstring_proj = subproject('bstring')
bstring = bstring_proj.get_variable('bstring_dep')
endif
#
# Check for iniparser
#
iniparser_path = get_option('with-iniparser-path')
if iniparser_path != ''
iniparser = cc.find_library(
'iniparser',
dirs: iniparser_path / 'lib',
required: false,
)
include_dirs += [iniparser_path / 'include']
else
iniparser = dependency('iniparser', required: false)
if not iniparser.found()
iniparser = cc.find_library('iniparser', dirs: libsearch_dirs, required: false)
endif
endif
if not iniparser.found()
error('iniparser library required but not found!')
endif
iniparser_const_test_code = '''
#include <iniparser.h>
int main() {
const dictionary *d = 0;
iniparser_getboolean(d, "", 0);
return 0;
}
'''
if cdata.has('HAVE_INIPARSER_INIPARSER_H')
iniparser_const_test_code = '''
#include <iniparser/iniparser.h>
int main() {
const dictionary *d = 0;
iniparser_getboolean(d, "", 0);
return 0;
}
'''
endif
have_iniparser_const = cc.compiles(
iniparser_const_test_code,
dependencies: iniparser,
name: 'iniparser functions accept const dictionary',
)
if have_iniparser_const
cdata.set('HAVE_INIPARSER_CONST_DICTIONARY', 1)
endif
#
# Check for POSIX threads
#
threads = dependency('threads', required: true)
if cc.has_function(
'pthread_condattr_setclock',
dependencies: threads,
prefix: '#include <pthread.h>',
)
cdata.set('HAVE_PTHREAD_CONDATTR_SETCLOCK', 1)
endif
#
# Check for libevent or libev
#
eventloop_opt = get_option('with-eventloop')
have_libevent = false
have_libev = false
if eventloop_opt in ['auto', 'libevent']
libevent = dependency('libevent', required: eventloop_opt == 'libevent')
have_libevent = libevent.found()
endif
if have_libevent
event_lib = libevent
elif eventloop_opt in ['auto', 'libev']
# Try pkg-config / cmake first
libev = dependency('libev', required: false)
# Fall back to manual library + header search
if not libev.found()
# Find the library: system paths, platform paths, then ev/ subdirs
# (e.g. NetBSD pkgsrc installs to /usr/pkg/lib/ev/)
libev_lib = cc.find_library('ev', required: false)
foreach d : libsearch_dirs
if not libev_lib.found()
libev_lib = cc.find_library('ev', dirs: d, required: false)
endif
if not libev_lib.found()
libev_lib = cc.find_library('ev', dirs: d / 'ev', required: false)
endif
endforeach
# Find the header: standard include paths, then ev/ subdirs
# (e.g. NetBSD pkgsrc installs to /usr/pkg/include/ev/)
if libev_lib.found()
libev_incdirs = include_dirs
if not cc.has_header(
'ev.h',
include_directories: include_directories(libev_incdirs),
)
foreach d : libsearch_dirs
libev_hdir = d.replace('/lib', '/include') / 'ev'
if fs.is_dir(libev_hdir)
libev_incdirs += libev_hdir
endif
endforeach
endif
if cc.has_header(
'ev.h',
include_directories: include_directories(libev_incdirs),
)
libev = declare_dependency(
dependencies: libev_lib,
include_directories: include_directories(libev_incdirs),
)
endif