2019-10-21 18:57:38 +02:00
|
|
|
project(
|
|
|
|
'nix',
|
|
|
|
'cpp',
|
2020-05-17 21:45:47 +02:00
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
default_options : [
|
|
|
|
'cpp_std=c++17',
|
2019-10-25 15:42:29 +02:00
|
|
|
'warning_level=3',
|
|
|
|
'optimization=3',
|
|
|
|
'debug=true'
|
2019-10-21 18:57:38 +02:00
|
|
|
],
|
|
|
|
version : run_command('cat', './.version').stdout().strip(),
|
|
|
|
license : 'MIT'
|
|
|
|
)
|
|
|
|
|
2020-05-17 21:45:47 +02:00
|
|
|
# init compiler
|
2019-10-21 18:57:38 +02:00
|
|
|
cpp = meson.get_compiler('cpp')
|
|
|
|
|
2019-10-25 15:42:29 +02:00
|
|
|
add_project_arguments(get_option('cxxflags'), language : 'cpp')
|
2019-10-21 18:57:38 +02:00
|
|
|
add_project_link_arguments(get_option('ldflags'), language: 'cpp')
|
|
|
|
|
|
|
|
cmake = import('cmake')
|
|
|
|
pkg = import('pkgconfig')
|
|
|
|
|
|
|
|
config_h = configuration_data()
|
|
|
|
|
|
|
|
config_h.set(
|
|
|
|
'HAVE_CXX17', 1,
|
2019-11-01 16:23:08 +01:00
|
|
|
description : 'Define if the compiler supports basic C++17 syntax')
|
2019-10-21 18:57:38 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
#-------------------------------------------------
|
|
|
|
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'))
|
|
|
|
|
|
|
|
# set nix directories
|
|
|
|
|
|
|
|
# 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')
|
|
|
|
|
|
|
|
# Construct a Nix system name (like "i686-linux").
|
|
|
|
#-------------------------------------------------
|
|
|
|
machine_name = host_machine.cpu()
|
|
|
|
sys_name = host_machine.system().to_lower()
|
|
|
|
|
|
|
|
cpu_archs = ['x86_64', 'armv6', 'armv7', '']
|
|
|
|
|
2020-05-17 21:45:47 +02:00
|
|
|
foreach cpu : cpu_archs
|
2019-10-21 18:57:38 +02:00
|
|
|
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`)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2019-10-25 16:39:02 +02:00
|
|
|
has_dirent_h = cpp.has_header('dirent.h')
|
|
|
|
if (has_dirent_h)
|
2019-10-21 18:57:38 +02:00
|
|
|
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'))
|
|
|
|
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'))
|
|
|
|
config_h.set(
|
|
|
|
'HAVE_EDITLINE_H', 1,
|
|
|
|
description : 'Define to 1 if you have the <editline.h> header file.')
|
|
|
|
else
|
|
|
|
error('Nix requires editline.h; however the header was not found.')
|
|
|
|
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
|
|
|
|
|
2019-10-25 16:39:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
# 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)
|
2019-11-04 18:37:24 +01:00
|
|
|
config_h.set('HAVE_STRUCT_DIRENT_D_TYPE', 1)
|
2019-10-25 16:39:02 +02:00
|
|
|
endif
|
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
# required dependancies
|
|
|
|
#============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
# look for required programs
|
|
|
|
#--------------------------------------------------
|
|
|
|
cat = find_program('cat', required : true)
|
2019-10-24 12:15:22 +02:00
|
|
|
ln = find_program('ln', required : true)
|
|
|
|
cp = find_program('cp', required : true)
|
|
|
|
rm = find_program('rm', required : true)
|
2019-10-21 18:57:38 +02:00
|
|
|
bash = find_program('bash', required : true)
|
|
|
|
echo = find_program('echo', required : true)
|
|
|
|
patch = find_program('patch', required : true)
|
|
|
|
xmllint = find_program('xmllint', required : true)
|
|
|
|
flex = find_program('flex', required : true)
|
|
|
|
bison = find_program('bison', 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)
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
dot = find_program('dot', required : false)
|
|
|
|
lsof = find_program('lsof', required : false)
|
2019-10-21 18:57:38 +02:00
|
|
|
tr = find_program('tr', required : true)
|
|
|
|
coreutils = run_command('dirname', cat.path()).stdout().strip()
|
|
|
|
|
|
|
|
|
2019-10-24 12:15:22 +02:00
|
|
|
# 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
|
|
|
|
'''
|
|
|
|
|
2020-05-17 21:45:47 +02:00
|
|
|
run_command('sh', '-c', 'rm tmp_link*')
|
2019-10-24 12:15:22 +02:00
|
|
|
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*')
|
2020-05-17 21:45:47 +02:00
|
|
|
endif
|
2019-10-24 12:15:22 +02:00
|
|
|
|
|
|
|
config_h.set('CAN_LINK_SYMLINK', can_link_symlink,
|
|
|
|
description : 'Whether link() works on symlinks')
|
|
|
|
|
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
# Look for boost, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
boost_dep = declare_dependency(
|
|
|
|
dependencies : [
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
cpp.find_library('boost_system'),
|
|
|
|
cpp.find_library('boost_context'),
|
|
|
|
cpp.find_library('boost_thread')],
|
2019-10-21 18:57:38 +02:00
|
|
|
link_args : get_option('boost_link_args'))
|
|
|
|
|
|
|
|
if (boost_dep.found())
|
2019-11-01 16:23:08 +01:00
|
|
|
config_h.set('HAVE_BOOST', 1, description : 'Define if the Boost library is available.')
|
2019-10-21 18:57:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# Look for liblzma, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
liblzma_dep = declare_dependency(
|
|
|
|
dependencies: dependency('liblzma'),
|
|
|
|
link_args : get_option('lzma_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for libbrotli{enc,dec}.
|
|
|
|
#--------------------------------------------------
|
|
|
|
libbrotli_dep = declare_dependency(
|
|
|
|
dependencies: [
|
|
|
|
dependency('libbrotlienc'),
|
|
|
|
dependency('libbrotlidec')],
|
|
|
|
link_args : get_option('brotli_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for OpenSSL, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
openssl_dep = declare_dependency(
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
dependencies: cpp.find_library('ssl'),
|
2019-10-21 18:57:38 +02:00
|
|
|
link_args : get_option('openssl_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for SQLite, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
sqlite3_dep = declare_dependency(
|
|
|
|
dependencies : dependency('sqlite3', version : '>= 3.6.19'),
|
|
|
|
link_args : get_option('sqlite3_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for libcurl, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
libcurl_dep = declare_dependency(
|
|
|
|
dependencies : dependency('libcurl'),
|
|
|
|
link_args : get_option('curl_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for pthread, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
pthread_dep = declare_dependency(
|
|
|
|
dependencies : dependency('threads'),
|
|
|
|
link_args : get_option('pthread_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for libdl, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
libdl_dep = declare_dependency(
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
dependencies : cpp.find_library('dl'),
|
2019-10-21 18:57:38 +02:00
|
|
|
link_args : get_option('dl_link_args'))
|
|
|
|
|
|
|
|
|
|
|
|
# Look for libbz2, a required dependency.
|
|
|
|
#--------------------------------------------------
|
|
|
|
libbz2_dep = declare_dependency(
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
dependencies : cpp.find_library('bz2'),
|
2020-05-18 00:58:51 +02:00
|
|
|
link_args : get_option('bz2_link_args'))
|
2019-10-21 18:57:38 +02:00
|
|
|
|
2020-05-18 00:58:51 +02:00
|
|
|
# Look for glog, a required dependency.
|
|
|
|
#--------------------------------------
|
|
|
|
glog_dep = declare_dependency(
|
|
|
|
dependencies : cpp.find_library('glog'),
|
|
|
|
link_args : get_option('glog_link_args'))
|
2019-10-21 18:57:38 +02:00
|
|
|
|
|
|
|
# Look for editline, a required dependency.
|
|
|
|
#--------------------------------------------------
|
2020-05-17 21:45:47 +02:00
|
|
|
# NOTE: The the libeditline.pc file was added only in libeditline >= 1.15.2, see
|
2019-10-21 18:57:38 +02:00
|
|
|
# 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 = declare_dependency(
|
feat(3p/nix): meson: Don't look for libraries in lib dir
1. First of all, this doesn't work in nixpkgs. Per [1], gcc ignores `-L`
for purposes of `--print-file-dirs`, which breaks horribly on linux. But
if we don't pass extra dirs, meosn first just tries `-l...`, which does
work.
2. Even if it did work, `libdir` means where we are installing libs, not
where libs are expected to be found. Those are not necessarily the
same (again, nixpkgs), and even when they are and non-standard, it is
better to use DESTDIR or have a modified toolchain.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87758
(cherry picked from commit a142164e746644e20f66908c156ca913bef4664f)
2019-10-25 16:39:33 +02:00
|
|
|
dependencies : cpp.find_library('editline'),
|
2019-10-21 18:57:38 +02:00
|
|
|
link_args : get_option('editline_link_args'))
|
|
|
|
|
|
|
|
if 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
|
|
|
|
|
|
|
|
|
|
|
|
# Optional dependancies
|
|
|
|
#============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
# Look for libsodium, an optional dependency.
|
|
|
|
#--------------------------------------------------
|
2019-10-26 11:16:39 +02:00
|
|
|
libsodium_lib = cpp.find_library('sodium', required: get_option('with_libsodium'))
|
|
|
|
if (libsodium_lib.found())
|
2019-10-21 18:57:38 +02:00
|
|
|
libsodium_dep = declare_dependency(
|
2019-10-26 11:16:39 +02:00
|
|
|
dependencies : libsodium_lib,
|
2019-10-21 18:57:38 +02:00
|
|
|
link_args : get_option('sodium_link_args'))
|
|
|
|
config_h.set('HAVE_SODIUM', 1, description : 'Whether to use libsodium for cryptography.')
|
|
|
|
else
|
2019-10-26 12:27:27 +02:00
|
|
|
libsodium_dep = dependency('', required: false)
|
2019-10-21 18:57:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2020-05-17 23:27:53 +02:00
|
|
|
# Look for Boehm garbage collector, a required dependency.
|
|
|
|
# TODO(tazjin): Remove option to disable GC
|
|
|
|
gc_dep = declare_dependency(
|
|
|
|
dependencies : dependency('bdw-gc'),
|
|
|
|
link_args : get_option('gc_link_args'))
|
|
|
|
config_h.set(
|
|
|
|
'HAVE_BOEHMGC', 1,
|
|
|
|
description : 'Whether to use the Boehm garbage collector.')
|
2019-10-24 12:15:22 +02:00
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
# Look for aws-cpp-sdk-s3.
|
|
|
|
#--------------------------------------------------
|
|
|
|
if (get_option('with_s3'))
|
|
|
|
enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h')
|
2020-05-17 21:45:47 +02:00
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
aws_version = meson.get_compiler('cpp').get_define(
|
|
|
|
'AWS_SDK_VERSION_STRING',
|
|
|
|
prefix : '#include <aws/core/VersionConfig.h>'
|
|
|
|
).strip('"').split('.')
|
2020-05-17 21:45:47 +02:00
|
|
|
|
2019-10-21 18:57:38 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-05-17 21:45:47 +02:00
|
|
|
# OS Specific checks
|
2019-10-21 18:57:38 +02:00
|
|
|
#============================================================================
|
|
|
|
# Look for libsecppomp, required for Linux sandboxing.
|
|
|
|
if sys_name.contains('linux')
|
2019-11-04 20:20:15 +01:00
|
|
|
libseccomp_dep = dependency(
|
|
|
|
'libseccomp',
|
|
|
|
version : '>= 2.3.1',
|
|
|
|
not_found_message : 'Nix requires libseccomp on a linux host system')
|
2019-10-21 18:57:38 +02:00
|
|
|
config_h.set(
|
|
|
|
'HAVE_SECCOMP', 1,
|
2019-11-04 20:20:15 +01:00
|
|
|
description : 'Whether seccomp is available and should be used for sandboxing.')
|
|
|
|
else
|
|
|
|
libseccomp_dep = dependency('', required: false)
|
2019-10-21 18:57:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
if (sys_name.contains('freebsd'))
|
|
|
|
add_project_arguments('-D_GNU_SOURCE', language : 'cpp')
|
2020-05-17 21:45:47 +02:00
|
|
|
config_h.set('_GNU_SOURCE', 1)
|
2019-10-21 18:57:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
if (sys_name.contains('sunos'))
|
2020-05-17 21:45:47 +02:00
|
|
|
# Solaris requires -lsocket -lnsl for network functions
|
2019-10-21 18:57:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# build
|
|
|
|
#============================================================================
|
|
|
|
|
|
|
|
conf = configure_file(
|
|
|
|
output : 'config.h',
|
|
|
|
configuration : config_h)
|
|
|
|
|
|
|
|
install_headers(
|
|
|
|
conf,
|
|
|
|
install_dir : join_paths(includedir, 'nix'))
|
|
|
|
|
2019-10-25 15:42:29 +02:00
|
|
|
add_project_arguments('-include', 'config.h', language : 'cpp')
|
2019-10-21 18:57:38 +02:00
|
|
|
src_inc = [include_directories('.', 'src')]
|
|
|
|
|
2019-10-24 12:15:22 +02:00
|
|
|
project_dirs = [
|
|
|
|
'src',
|
|
|
|
'scripts',
|
|
|
|
'corepkgs',
|
|
|
|
'misc',
|
|
|
|
'doc',
|
|
|
|
'tests'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
foreach dir : project_dirs
|
|
|
|
subdir(dir)
|
2019-10-25 16:39:02 +02:00
|
|
|
endforeach
|