forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmeson.build
755 lines (615 loc) · 23.7 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
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
# Nix project build file
#============================================================================
# init
#============================================================================
# init project
#-------------------------------------------------
project(
'nix',
'cpp',
default_options : [
'cpp_std=c++17',
],
# version : run_command('cat', './.version').stdout().strip(),
version : '2.1.3', # no cat so far
license : 'MIT'
)
# init compiler
#-------------------------------------------------
build_on_windows = build_machine.system().to_lower().contains('windows')
sys_name = host_machine.system().to_lower()
cpp = meson.get_compiler('cpp')
is_msvc = ['msvc', 'clang-cl', 'intel-cl'].contains(cpp.get_id())
if not is_msvc
add_project_arguments(get_option('cxxflags'), language : 'cpp')
add_project_link_arguments(get_option('ldflags'), language: 'cpp')
# We do a lot of args... we'd otherwise have to convert to __ va_args__
add_project_arguments('-Wno-variadic-macros', language : 'cpp')
endif
if not build_on_windows
cmake = import('cmake')
pkg = import('pkgconfig')
endif
# init configuration
#-------------------------------------------------
config_h = configuration_data()
config_h.set(
'HAVE_CXX17', 1,
description : 'Define if the compiler supports basic C++17 syntax')
package_name = meson.project_name()
config_h.set_quoted(
'PACKAGE_NAME', package_name,
description : 'Define to the full name of this package.'
)
package_tarname = meson.project_name()
config_h.set_quoted(
'PACKAGE_TARNAME', package_tarname,
description : 'Define to the one symbol short name of this package.')
package_version = meson.project_version()
config_h.set_quoted(
'PACKAGE_VERSION', package_version,
description : 'Define to the version of this package.')
package_string = '@0@ @1@'.format(package_name, package_version)
config_h.set_quoted(
'PACKAGE_STRING', package_string,
description : 'Define to the full name and version of this package.')
package_url = 'https://nixos.org/nix/'
config_h.set_quoted(
'PACKAGE_URL', package_url,
description : 'Define to the home page for this package.')
package_bug_url = 'https://github.com/nixos/nix/issues'
config_h.set_quoted(
'PACKAGE_BUGREPORT', package_bug_url,
description : 'Define to the address where bug reports for this package should be sent.')
# env
#============================================================================
# set install directories
#-------------------------------------------------
if not build_on_windows
prefix = get_option('prefix')
libdir = join_paths(prefix, get_option('libdir'))
bindir = join_paths(prefix, get_option('bindir'))
datadir = join_paths(prefix, get_option('datadir'))
sysconfdir = join_paths(prefix, get_option('sysconfdir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
mandir = join_paths(prefix, get_option('mandir'))
includedir = join_paths(prefix, get_option('includedir'))
else
#prefix = get_option('prefix')
libdir = 'C:\\work\\nix-bootstrap\\bin' # join_paths(prefix, get_option('libdir'))
bindir = 'C:\\work\\nix-bootstrap\\bin' # join_paths(prefix, get_option('bindir'))
datadir = 'C:\\work\\nix-bootstrap\\share' # join_paths(prefix, get_option('datadir'))
sysconfdir = 'C:\\work\\nix-bootstrap\\etc' # join_paths(prefix, get_option('sysconfdir'))
includedir = 'C:\\work\\nix-bootstrap\\include' # join_paths(prefix, get_option('includedir'))
endif
# set nix directories
#-------------------------------------------------
if not build_on_windows
# State should be stored in /nix/var, unless the user overrides it explicitly.
if get_option('normal_var')
localstatedir = '/nix/var'
else
localstatedir = join_paths(prefix, get_option('localstatedir'))
endif
nixstoredir = get_option('nixstoredir')
profiledir = join_paths(sysconfdir, 'profile.d')
else
localstatedir = 'C:\\nix\\var'
nixstoredir = 'C:\\nix\\store' # get_option('nixstoredir')
endif
# Construct a Nix system name (like "i686-linux").
#-------------------------------------------------
if not build_on_windows
machine_name = host_machine.cpu()
cpu_archs = ['x86_64', 'armv6', 'armv7', '']
foreach cpu : cpu_archs
if (host_machine.cpu().contains(cpu))
if cpu.contains('armv')
machine_name = cpu + '1'
else
machine_name = cpu
endif
break
endif
endforeach
system= '"' + machine_name + '-' + sys_name + '"'
message('system name: ' + system)
config_h.set(
'SYSTEM', system,
description : 'platform identifier (`cpu-os`)')
endif
# required dependancies
#============================================================================
# look for required programs
#--------------------------------------------------
flex = find_program('flex', required : true)
bison = find_program('bison', required : true)
if not build_on_windows
cat = find_program('cat', required : true)
ln = find_program('ln', required : true)
cp = find_program('cp', required : true)
rm = find_program('rm', required : true)
bash = find_program('bash', required : true)
echo = find_program('echo', required : true)
patch = find_program('patch', required : true)
xmllint = find_program('xmllint', required : true)
sed = find_program('sed', required : true)
tar = find_program('tar', required : true)
bzip2 = find_program('bzip2', required : true)
gzip = find_program('gzip', required : true)
xz = find_program('xz', required : true)
dot = find_program('dot', required : false)
lsof = find_program('lsof', required : false)
tr = find_program('tr', required : true)
coreutils = run_command('dirname', cat.path()).stdout().strip()
# Check whether the store optimiser can optimise symlinks.
#-------------------------------------------------
gen_header = '''
ln -s bla tmp_link
if ln tmp_link tmp_link2 2> /dev/null; then
echo 1
else
echo 0
fi
'''
run_command('sh', '-c', 'rm tmp_link*')
can_link_symlink = run_command('sh', '-c', gen_header).stdout().strip()
if can_link_symlink.to_int() == 1
run_command('sh', '-c', 'rm tmp_link*')
endif
config_h.set('CAN_LINK_SYMLINK', can_link_symlink,
description : 'Whether link() works on symlinks')
endif
# Look for boost, a required dependency.
#--------------------------------------------------
if (get_option('with_boost') != '' and is_msvc)
boost_dep = declare_dependency(
include_directories : [get_option('with_boost') + '/include'],
link_args : ['-L' + get_option('with_boost') + '/lib' ])
elif (get_option('with_boost') != '')
boost_dep = declare_dependency(
variables : {'dlls': get_option('with_boost') + '/bin/libboost_context-mt.dll'},
include_directories : [get_option('with_boost') + '/include'],
link_args : ['-L' + get_option('with_boost') + '/lib', '-lboost_context-mt' ])
else
boost_dep = declare_dependency(
dependencies : [
cpp.find_library('boost_system'),
cpp.find_library('boost_context'),
cpp.find_library('boost_thread')
],
link_args : get_option('boost_link_args')
)
endif
if (boost_dep.found())
config_h.set('HAVE_BOOST', 1, description : 'Define if the Boost library is available.')
endif
# Look for liblzma, a required dependency.
#--------------------------------------------------
if (get_option('with_lzma') != '') and is_msvc
liblzma_dep = declare_dependency(
variables : {'dlls': get_option('with_lzma') + '/bin/liblzma.dll' },
include_directories : [get_option('with_lzma') + '/include'],
link_args : ['-L' + get_option('with_lzma') + '/lib', '-lliblzma' ])
elif (get_option('with_lzma') != '')
liblzma_dep = declare_dependency(
variables : {'dlls': get_option('with_lzma') + '/bin/liblzma-5.dll' },
include_directories : [get_option('with_lzma') + '/include'],
link_args : ['-L' + get_option('with_lzma') + '/lib', '-llzma' ])
else
liblzma_dep = declare_dependency(
dependencies: dependency('liblzma'),
link_args : get_option('lzma_link_args'),
)
endif
# Look for libbrotli{enc,dec}.
#--------------------------------------------------
if build_on_windows
# todo
libbrotli_dep = dependency('', required: false)
else
libbrotli_dep = declare_dependency(
dependencies: [
dependency('libbrotlienc'),
dependency('libbrotlidec')],
link_args : get_option('brotli_link_args'))
endif
# Look for OpenSSL, a required dependency.
#--------------------------------------------------
if get_option('with_openssl') != '' and is_msvc
openssl_dep = declare_dependency(
variables : {'dlls': ';'.join([ get_option('with_openssl') + '/bin/libeay32.dll',
get_option('with_openssl') + '/bin/ssleay32.dll']) },
include_directories : [get_option('with_openssl') + '/include'],
link_args : ['-L' + get_option('with_openssl') + '/lib', '-llibeay32' ],
)
elif (get_option('with_openssl') != '')
openssl_dep = declare_dependency(
variables : {'dlls': ';'.join([ get_option('with_openssl') + '/bin/libssl-1_1.dll',
get_option('with_openssl') + '/bin/libcrypto-1_1.dll']) },
include_directories : [get_option('with_openssl') + '/include'],
link_args : ['-L' + get_option('with_openssl') + '/lib', '-lssl', '-lcrypto' ],
)
else
openssl_dep = declare_dependency(
dependencies: cpp.find_library('ssl'),
link_args : get_option('openssl_link_args'),
)
endif
# Look for SQLite, a required dependency.
#--------------------------------------------------
if get_option('with_sqlite3') != '' and is_msvc
sqlite3_dep = declare_dependency(
variables : {'dlls': get_option('with_sqlite3') + '/bin/sqlite3.dll' },
include_directories : [get_option('with_sqlite3') + '/include'],
link_args : ['-L' + get_option('with_sqlite3') + '/lib', '-lsqlite3' ])
elif get_option('with_sqlite3') != ''
sqlite3_dep = declare_dependency(
variables : {'dlls': get_option('with_sqlite3') + '/bin/libsqlite3-0.dll' },
include_directories : [get_option('with_sqlite3') + '/include'],
link_args : ['-L' + get_option('with_sqlite3') + '/lib', '-lsqlite3' ])
else
sqlite3_dep = declare_dependency(
dependencies : dependency('sqlite3', version : '>= 3.6.19'),
link_args : get_option('sqlite3_link_args')
)
endif
# Look for libcurl, a required dependency.
#--------------------------------------------------
if get_option('with_curl') != '' and is_msvc
libcurl_dep = declare_dependency(
variables : {'dlls': ';'.join([ get_option('with_curl') + '/bin/libcurl.dll',
get_option('with_curl') + '/bin/zlib1.dll']) },
include_directories : [get_option('with_curl') + '/include'],
link_args : ['-L' + get_option('with_curl') + '/lib', '-llibcurl'])
elif (get_option('with_curl') != '')
libcurl_dep = declare_dependency(
variables : {'dlls': ';'.join([ get_option('with_curl') + '/bin/libcurl-4.dll',
get_option('with_curl') + '/bin/zlib1.dll',
get_option('with_curl') + '/bin/libbrotlicommon.dll',
get_option('with_curl') + '/bin/libbrotlidec.dll',
get_option('with_curl') + '/bin/libbrotlienc.dll',
get_option('with_curl') + '/bin/libidn2-0.dll',
get_option('with_curl') + '/bin/libpsl-5.dll',
get_option('with_curl') + '/bin/libnghttp2-14.dll',
get_option('with_curl') + '/bin/libssh2-1.dll',
get_option('with_curl') + '/bin/libidn2-0.dll',
get_option('with_curl') + '/bin/libintl-8.dll',
get_option('with_curl') + '/bin/libzstd.dll',
get_option('with_curl') + '/bin/libunistring-2.dll',
get_option('with_curl') + '/bin/libiconv-2.dll']) },
include_directories : [get_option('with_curl') + '/include'],
link_args : ['-L' + get_option('with_curl') + '/lib', '-lcurl'])
else
libcurl_dep = declare_dependency(
dependencies : dependency(
'libcurl',
# Meson was getting confused for some reason
static : sys_name.contains('windows'),
),
link_args : get_option('curl_link_args')
)
endif
# Look for pthread, a required dependency.
#--------------------------------------------------
# Work around Meson not recognizing obscure alternative MCF threading.
# https://github.com/mesonbuild/meson/issues/553#issuecomment-552602641
if sys_name.contains('windows') and not is_msvc
pthread_dep = dependency('', required : false)
else
pthread_dep = dependency('threads')
endif
# Look for libdl, a required dependency on Unix.
#--------------------------------------------------
libdl_needed = not sys_name.contains('windows')
libdl_lib = cpp.find_library('dl', required : libdl_needed)
if libdl_lib.found()
libdl_dep = declare_dependency(
dependencies : libdl_lib,
link_args : get_option('dl_link_args'),
required : libdl_needed)
else
libdl_dep = dependency('', required: false)
endif
# Look for libbz2, a required dependency.
#--------------------------------------------------
if get_option('with_bz2') != '' and is_msvc
libbz2_dep = declare_dependency(
include_directories : [get_option('with_bz2') + '/include'],
link_args : ['-L' + get_option('with_bz2') + '/lib', '-llibbz2'])
elif get_option('with_bz2') != ''
libbz2_dep = declare_dependency(
variables : {'dlls': get_option('with_bz2') + '/bin/libbz2-1.dll' },
include_directories : [get_option('with_bz2') + '/include'],
link_args : ['-L' + get_option('with_bz2') + '/lib', '-llibbz2'])
else
libbz2_dep = declare_dependency(
dependencies : cpp.find_library('bz2'),
link_args : get_option('bz2_link_args'),
)
endif
# Optional dependancies
#============================================================================
# Look for libsodium, an optional dependency.
#--------------------------------------------------
libsodium_lib = cpp.find_library('sodium', required: get_option('with_libsodium'))
if (libsodium_lib.found())
libsodium_dep = declare_dependency(
dependencies : libsodium_lib,
link_args : get_option('sodium_link_args'))
config_h.set('HAVE_SODIUM', 1, description : 'Whether to use libsodium for cryptography.')
else
libsodium_dep = dependency('', required: false)
endif
# Look for Boehm garbage collector, an optional dependency.
#--------------------------------------------------
gc_c_lib = dependency(
'bdw-gc',
required : get_option('with_gc'),
disabler : true,
)
gc_cpp_lib = cpp.find_library(
'gccpp',
required : get_option('with_gc'),
)
if (gc_cpp_lib.found())
gc_dep = declare_dependency(
dependencies : [gc_cpp_lib, gc_c_lib],
link_args : get_option('gc_link_args'),
)
config_h.set(
'HAVE_BOEHMGC', 1,
description : 'Whether to use the Boehm garbage collector.')
else
gc_dep = dependency('', required: false)
endif
# Look for aws-cpp-sdk-s3.
#--------------------------------------------------
if (get_option('with_s3'))
enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h')
aws_version = meson.get_compiler('cpp').get_define(
'AWS_SDK_VERSION_STRING',
prefix : '#include <aws/core/VersionConfig.h>'
).strip('"').split('.')
conf_data.set('ENABLE_S3', 1, description : 'Whether to enable S3 support via aws-sdk-cpp.')
conf_data.set('AWS_VERSION_MAJOR', aws_version[0], description : 'Major version of aws-sdk-cpp.')
conf_data.set('AWS_VERSION_MINOR', aws_version[1], description : 'Minor version of aws-sdk-cpp.')
endif
# Look for editline, a dependency required just by nix-repl.
#--------------------------------------------------
# NOTE: The the libeditline.pc file was added only in libeditline >= 1.15.2, see
# https://github.com/troglobit/editline/commit/0a8f2ef4203c3a4a4726b9dd1336869cd0da8607,
# but e.g. Ubuntu 16.04 has an older version, so we fall back to searching for
# editline.h when the pkg-config approach fails.
editline_dep = dependency(
'libeditline',
include_type : 'system', # force -isystem so we don't forget to use <..>
required : get_option('with_editline'),
)
if (editline_dep.found() and not cpp.has_function(
'read_history',
prefix : '#include <stdio.h>\n#include "editline.h"',
args : '-lreadline'))
warning('Nix requires libeditline; However, required functions do not work. Maybe ' +\
'it is too old? >= 1.14 is required.')
endif
# OS Specific checks
#============================================================================
# Look for libsecppomp, required for Linux sandboxing.
if sys_name.contains('linux')
libseccomp_dep = dependency(
'libseccomp',
version : '>= 2.3.1',
not_found_message : 'Nix requires libseccomp on a linux host system')
config_h.set(
'HAVE_SECCOMP', 1,
description : 'Whether seccomp is available and should be used for sandboxing.')
else
libseccomp_dep = dependency('', required: false)
endif
if (sys_name.contains('freebsd'))
add_project_arguments('-D_GNU_SOURCE', language : 'cpp')
config_h.set('_GNU_SOURCE', 1)
endif
if (sys_name.contains('sunos'))
# Solaris requires -lsocket -lnsl for network functions
endif
#if build_on_windows
# windows_version_desc = '''
# Windows SDK version we will use.
# Newer version will have their headers trimmed of new functionality.
# '''
# windows_version = '0x0A00' # Windows 10
# config_h.set('WINVER', windows_version, description : windows_version_desc)
# config_h.set('_WIN32_WINNT', windows_version, description : windows_version_desc)
#endif
# checking headers
#============================================================================
if (cpp.has_header('sys/stat.h'))
config_h.set(
'HAVE_SYS_STAT_H', 1,
description : 'Define to 1 if you have the <sys/stat.h> header file.')
endif
if (cpp.has_header('sys/types.h'))
config_h.set(
'HAVE_SYS_TYPES_H', 1,
description : 'Define to 1 if you have the <sys/types.h> header file.')
endif
if (cpp.has_header('sys/dir.h'))
config_h.set(
'HAVE_DIR_H', 1,
description : 'Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR`')
endif
if (cpp.has_header('sys/ndir.h'))
config_h.set(
'HAVE_NDIR_H', 1,
description : 'Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR`')
endif
has_dirent_h = cpp.has_header('dirent.h')
if (has_dirent_h)
config_h.set(
'HAVE_DIRENT_H', 1,
description : 'Define to 1 if you have the <dirent.h> header file, and it defines `DIR`')
endif
if (cpp.has_header('locale.h'))
config_h.set(
'HAVE_LOCALE', 1,
description : 'Define to 1 if you have the <locale.h> header file.')
endif
if (cpp.has_header('unistd.h'))
config_h.set(
'HAVE_UNISTD_H', 1,
description: 'Define to 1 if you have the <unistd.h> header file.')
endif
if (cpp.has_header('stdint.h'))
config_h.set(
'HAVE_STDINT_H', 1,
description: 'Define to 1 if you have the <stdint.h> header file.')
endif
if (cpp.has_header('stdlib.h'))
config_h.set(
'HAVE_STDLIB_H', 1,
description: 'Define to 1 if you have the <stdlib.h> header file.')
endif
if (cpp.has_header('strings.h'))
config_h.set(
'HAVE_STRINGS_H', 1,
description: 'Define to 1 if you have the <strings.h> header file.')
endif
if (cpp.has_header('string.h'))
config_h.set(
'HAVE_STRING_H', 1,
description: 'Define to 1 if you have the <strings.h> header file.')
endif
if (cpp.has_header('bzlib.h')) # dependencies : [ libbz2_dep ]
# Unfortunately cannot results of `declare_dependency` above, and package
# is missing pkg-config file.
config_h.set(
'HAVE_BZLIB_H', 1,
description : 'Define to 1 if you have the <bzlib.h> header file.')
endif
if (cpp.has_header('inttypes.h'))
config_h.set(
'HAVE_INTTYPES_H', 1,
description : 'Define to 1 if you have the <inttypes.h> header file.')
endif
if (cpp.has_header('memory.h'))
config_h.set(
'HAVE_MEMORY_H', 1,
description : 'Define to 1 if you have the <memory.h> header file.')
endif
if (cpp.has_header('editline.h', dependencies : [ editline_dep ]))
config_h.set(
'HAVE_EDITLINE_H', 1,
description : 'Define to 1 if you have the <editline.h> header file.')
endif
# checking functions
#============================================================================
if (cpp.has_function('lutimes'))
config_h.set(
'HAVE_LUTIMES', 1,
description : 'Define to 1 if you have the `lutimes` function.')
endif
if (cpp.has_function('lchown'))
config_h.set(
'HAVE_LCHOWN', 1,
description : 'Define to 1 if you have the `lchown` function.')
endif
if (cpp.has_function('pipe2'))
config_h.set(
'HAVE_PIPE2', 1,
description : 'Define to 1 if you have the `pipe2` function.')
endif
if (cpp.has_function('posix_fallocate'))
config_h.set(
'HAVE_POSIX_FALLOCATE', 1,
description : 'Define to 1 if you have the `posix_fallocate` function.')
endif
if (cpp.has_function('setresuid'))
config_h.set(
'HAVE_SETRESUID', 1,
description : 'Define to 1 if you have the `setresuid` function.')
endif
if (cpp.has_function('setreuid'))
config_h.set(
'HAVE_SETREUID', 1,
description : 'Define to 1 if you have the `setreuid` function.')
endif
if (cpp.has_function('statvfs'))
config_h.set(
'HAVE_STATVFS', 1,
description : 'Define to 1 if you have the `statvfs` function.')
endif
if (cpp.has_function('strsignal'))
config_h.set(
'HAVE_STRSIGNAL', 1,
description : 'Define to 1 if you have the `strsignal` function.')
endif
if (cpp.has_function('sysconf'))
config_h.set(
'HAVE_SYSCONF', 1,
description : 'Define to 1 if you have the `sysconf` function.')
endif
pubsetbuff_c = '''
#include <iostream>
using namespace std;
static char buf[1024];
void func() {
cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
}'''
if meson.get_compiler('cpp').compiles(
pubsetbuff_c,
name : 'pubsetbuf'
)
config_h.set(
'HAVE_PUBSETBUF', 1,
description : 'Define to 1 if you have the `pubsetbuf` function.')
endif
# checking data types
#============================================================================
dirent_h_prefix = '''
#include <sys/types.h>
#include <dirent.h>
'''
if has_dirent_h and meson.get_compiler('cpp').has_member('struct dirent', 'd_type', prefix: dirent_h_prefix)
config_h.set('HAVE_STRUCT_DIRENT_D_TYPE', 1)
endif
# build
#============================================================================
conf = configure_file(
output : 'config.h',
configuration : config_h)
if not build_on_windows
install_headers(
conf,
install_dir : join_paths(includedir, 'nix'))
endif
if is_msvc
add_project_arguments('-FI', 'config.h', language : 'cpp')
else
add_project_arguments('-include', 'config.h', language : 'cpp')
endif
src_inc = [include_directories('.', 'src')]
if not build_on_windows
project_dirs = [
'src',
'scripts',
'corepkgs',
'misc',
'doc',
'tests'
]
else
project_dirs = [
'src',
]
endif
foreach dir : project_dirs
subdir(dir)
endforeach
if build_on_windows
install_data('corepkgs/fetchurl.nix', install_dir : bindir+'/../nix/corepkgs')
install_data('corepkgs/derivation.nix', install_dir : bindir+'/../nix/corepkgs')
install_data('corepkgs/imported-drv-to-derivation.nix', install_dir : bindir+'/../nix/corepkgs')
install_data('corepkgs/buildenv.nix', install_dir : bindir+'/../nix/corepkgs')
endif