Commit 9370b2a7 authored by Tomas Krizek's avatar Tomas Krizek

meson: kresd builds \o/

parent 50911e89
......@@ -7,6 +7,7 @@ addons:
- cmocka
- luajit
- libuv
- lmdb
compiler:
- clang
notifications:
......
project(
'knot-resolver', 'c',
license: 'GPLv3+',
version: '3.0.0',
default_options: ['c_std=c11'],
version: '3.2.1', # TODO dev version from git
default_options: ['c_std=c99'], # TODO why not c11?
)
libkres_soversion = 8
libkres_soversion = 9
# TODO change modules_dir to sensible lua(jit) default
modules_dir = join_paths(get_option('libdir'), 'kdns_modules')
# dependencies
knot_version = '>=2.7.1'
# Dependencies
knot_version = '>=2.7.6'
libknot = dependency('libknot', version: knot_version)
libdnssec = dependency('libdnssec', version: knot_version)
libzscanner = dependency('libzscanner', version: knot_version)
libuv = dependency('libuv', version: '>=1.0')
lmdb = dependency('lmdb', required: false)
lmdb = dependency('lmdb')
gnutls = dependency('gnutls')
nettle = dependency('nettle')
lua = dependency('lua', required: false)
if not lua.found()
lua = dependency('luajit')
endif
luajit = dependency('luajit')
# TODO why isn't libedit required instead?
libedit = dependency('libedit', required: false)
if not libedit.found()
libedit = meson.get_compiler('c').find_library('edit')
endif
# Optional dependencies
libsystemd = dependency('libsystemd', version: '>=227', required: false)
doxygen = find_program('doxygen', required: false)
sphinx_build = find_program('sphinx-build', required: false)
# $(eval $(call find_luapkg,ltn12))
# $(eval $(call find_luapkg,ssl.https))
# $(eval $(call find_pythonpkg,breathe))
cmocka = dependency('cmocka', required: false)
socket_wrapper = dependency('socket_wrapper', required: false)
libsystemd = dependency('libsystemd', version: '>=227', required: false)
libprotobuf_c = dependency('libprotobuf-c', version: '>=1', required: false)
libfstrm = dependency('libfstrm', version: '>=0.2', required: false)
......@@ -48,12 +44,92 @@ protoc_c = find_program('protoc-c', required: false)
lcov = find_program('lcov', required: false)
luacov = find_program('luacov', required: false)
lua_ltn12 = run_command(
'luajit', ['-l', 'ltn12', '-e', 'os.exit(0)']).returncode() == 0
if not lua_ltn12
warning('lua: ltn12 not found')
endif
lua_ssl_https = run_command(
'luajit', ['-l', 'ssl.https', '-e', 'os.exit(0)']).returncode() == 0
if not lua_ssl_https
warning('lua: ssl.https not found')
endif
python_breathe = run_command(
'python3', ['-c', 'import breathe']).returncode() == 0
if not python_breathe
warning('python: breathe not found')
endif
# Variables
luajit_has_setfuncs = run_command(
'pkg-config', ['luajit', '--atleast-version', '2.1.0-beta3']
).returncode() == 0 ? '1' : '0'
# TODO @DATE@. @VERSION@, ...
lib_suffix = '.so'
# TODO seek&destroy LIBEXT
if host_machine.system() == 'darwin'
lib_suffix = '.dylib'
endif
add_global_arguments(
'-D_GNU_SOURCE',
# '-Wtype-limits',
# '-Wformat',
# '-Wformat-security',
# '-Wshadow',
# '-Wall',
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
'-DPREFIX="@0@"'.format(get_option('prefix')),
'-DMODULEDIR="@0@"'.format(modules_dir),
'-fvisibility=hidden',
language: 'c',
)
add_global_link_arguments(
'-ldl',
'-lm',
'-Wl,--export-dynamic',
language: 'c',
)
c_args = [
'-fPIE', # TODO pie=true since 0.49.0
'-DROOTHINTS="@0@/root.hints"'.format(
join_paths(get_option('prefix'), get_option('sysconfdir'))),
'-DLIBEXT="@0@"'.format(lib_suffix),
'-Dlibzscanner_SONAME="@0@"'.format(libzscanner.get_pkgconfig_variable('soname')),
'-Dlibknot_SONAME="@0@"'.format(libknot.get_pkgconfig_variable('soname')),
'-DLUA_HAS_SETFUNCS=@0@'.format(luajit_has_setfuncs),
]
# TODO global
link_args = [
'-ldl',
'-pthread', # TODO fix pthread
]
if libsystemd.found()
c_args += ['-DHAS_SYSTEMD']
endif
if host_machine.system() == 'darwin'
# luajit workaround for OS X https://luajit.org/install.html#embed
c_args += ['-pagezero_size', '10000', '-image_base', '100000000']
endif
## contrib
contrib_sources = [
'contrib/ccan/asprintf/asprintf.c',
'contrib/ccan/ilog/ilog.c',
'contrib/ccan/isaac/isaac.c',
'contrib/ccan/json/json.c',
'contrib/ucw/mempool.c',
'contrib/ucw/mempool-fmt.c',
......@@ -76,15 +152,6 @@ contrib = declare_dependency(
link_with: contrib_lib,
)
## embedded lmdb (optional)
if not lmdb.found()
sources = ['contrib/lmdb/mdb.c', 'contrib/lmdb/midl.c']
includes = include_directories('contrib/lmdb')
lib = static_library('lmdb', sources, include_directories: includes)
lmdb = declare_dependency(link_with: lib, include_directories: includes)
endif
### libkres
libkres_sources = [
......@@ -104,6 +171,7 @@ libkres_sources = [
'lib/dnssec/ta.c',
'lib/generic/lru.c',
'lib/generic/map.c',
'lib/generic/queue.c',
'lib/generic/trie.c',
'lib/layer/cache.c',
'lib/layer/iterate.c',
......@@ -131,6 +199,7 @@ libkres_headers = [
'lib/generic/lru.h',
'lib/generic/map.h',
'lib/generic/pack.h',
'lib/generic/queue.h',
'lib/generic/trie.h',
'lib/layer.h',
'lib/layer/iterate.h',
......@@ -142,42 +211,26 @@ libkres_headers = [
'lib/zonecut.h',
]
libkres_deps = [
contrib, libuv, lua, lmdb, libknot, libdnssec, gnutls
]
if get_option('cookies')
libkres_sources += [
'lib/cookies/alg_containers.c',
'lib/cookies/alg_containers.h',
'lib/cookies/alg_sha.c',
'lib/cookies/alg_sha.h',
'lib/cookies/control.h',
'lib/cookies/helper.c',
'lib/cookies/helper.h',
'lib/cookies/lru_cache.c',
'lib/cookies/lru_cache.h',
'lib/cookies/nonce.c',
'lib/cookies/nonce.h',
]
libkres_deps += [nettle]
endif
libkres_includes = include_directories('lib')
libkres_lib = library('kres',
libkres = library('kres',
libkres_sources,
include_directories: [libkres_includes],
# TODO is this needed?
# include_directories: [
# include_directories('lib'),
# ],
soversion: libkres_soversion,
dependencies: libkres_deps,
dependencies: [
contrib,
libuv,
luajit,
lmdb,
libknot,
libdnssec,
gnutls,
],
install: true,
)
libkres = declare_dependency(
link_with: libkres_lib,
include_directories: libkres_includes,
)
# TODO what dir structure does it create?
install_headers(
libkres_headers,
subdir: 'libkres',
......@@ -197,11 +250,13 @@ kresc_sources = [
'client/kresc.c',
]
# TODO move /usr/sbin to /usr/bin?
kresc = executable(
'kresc',
kresc_sources,
include_directories: include_directories('client'),
dependencies: [contrib, libkres, libedit],
dependencies: [contrib, libedit],
link_with: libkres,
install: true,
install_dir: 'sbin',
)
......@@ -218,7 +273,7 @@ embed_lua = generator(
kresd_lua = embed_lua.process(
'daemon/lua/sandbox.lua',
'daemon/lua/config.lua',
preserve_path_from: meson.current_source_dir(),
preserve_path_from: meson.current_source_dir(), # TODO is this necessary?
)
kresd_sources = [
......@@ -228,6 +283,7 @@ kresd_sources = [
'daemon/io.c',
'daemon/main.c',
'daemon/network.c',
'daemon/session.c',
'daemon/tls.c',
'daemon/tls_ephemeral_credentials.c',
'daemon/tls_session_ticket-srv.c',
......@@ -235,46 +291,45 @@ kresd_sources = [
'daemon/zimport.c',
]
lib_suffix = '.so'
if build_machine.system() == 'darwin'
lib_suffix = '.dylib'
endif
kresd = executable(
'kresd',
kresd_sources, kresd_lua,
include_directories: include_directories('daemon'),
c_args: [
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
'-DPREFIX="@0@"'.format(get_option('prefix')),
'-DMODULEDIR="@0@"'.format(modules_dir),
'-DROOTHINTS="@0@/root.hints"'.format(get_option('sysconfdir')),
'-DLIBEXT="@0@"'.format(lib_suffix),
'-Dlibzscanner_SONAME="TODO.so"',
'-Dlibknot_SONAME="TODO.so"',
'-DLUA_HAS_SETFUNCS=1',
include_directories: include_directories('daemon'), # TODO path to contrib lib/generic ?
dependencies: [
contrib,
libknot,
libzscanner,
libdnssec,
libuv,
luajit,
gnutls,
libsystemd,
],
dependencies: [contrib, libkres, libknot, libzscanner, libdnssec, libuv, lua, gnutls],
link_with: libkres,
c_args: c_args,
link_args: link_args,
install: true,
install_dir: 'sbin',
)
# TODO install man
## modules
library(
'bogus_log',
['modules/bogus_log/bogus_log.c'],
dependencies: [contrib, libkres, libknot, lua, libuv],
install: true,
install_dir: modules_dir,
name_prefix: '',
)
#library(
# 'bogus_log',
# ['modules/bogus_log/bogus_log.c'],
# dependencies: [contrib, libkres, libknot, luajit, libuv],
# install: true,
# install_dir: modules_dir,
# name_prefix: '',
#)
#library(
# 'hints',
# ['modules/hints/hints.c'],
# dependencies: [contrib, libkres, lua],
# dependencies: [contrib, libkres, luajit],
# install: true,
# install_dir: modules_dir,
# name_prefix: '',
......@@ -283,13 +338,13 @@ library(
library(
'stats',
['modules/stats/stats.c'],
dependencies: [contrib, libkres, lua],
dependencies: [contrib, luajit],
link_with: libkres,
install: true,
install_dir: modules_dir,
name_prefix: '',
)
# TODO: cookies
# TODO: dnstap
lua_modules = [
......@@ -324,4 +379,8 @@ install_data(
'modules/daf/daf.js',
install_dir: join_paths(modules_dir, 'daf'),
)
# todo...
# etc
install_data(sources: 'etc/root.hints', install_dir: get_option('sysconfdir'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment