This repository has been archived on 2023-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
tcpaste/meson.build
Thorsten Schubert 64c89e9274
Some checks reported errors
continuous-integration/drone/push Build is passing
continuous-integration/drone Build encountered an error
Bug fixes
2021-11-08 18:39:10 +01:00

138 lines
3.4 KiB
Meson

# vi:set ft=meson ts=4 sw=2 noet noai:
project('tcpaste', 'c',
version : '0.4',
license: 'GPLv3',
default_options : [ 'debug=true',
'optimization=g',
'c_std=gnu99',
'warning_level=3',
'werror=true'])
assert(host_machine.system() == 'linux',
'Only linux (epoll) is supported.')
erased_target_name = 'tcperased'
pasted_target_name = 'tcppasted'
target_dir = get_option('prefix') / get_option('bindir')
sd_conf = configuration_data()
sd_conf.set('bindir', target_dir)
sd_conf.set('path', get_option('path'))
sd_conf.set('pasted_target', pasted_target_name)
sd_conf.set('erased_target', erased_target_name)
addrs_pasted = ' '.join(get_option('addrs_pasted'))
addrs_erased = ' '.join(get_option('addrs_erased'))
sd_conf.set('addrs_pasted', addrs_pasted)
sd_conf.set('addrs_erased', addrs_erased)
configure_file(input : 'contrib/systemd/tcp-expire.service.in',
output : 'tcp-expire.service',
configuration : sd_conf)
configure_file(input : 'contrib/systemd/tcp-pasted.service.in',
output : 'tcp-pasted.service',
configuration : sd_conf)
configure_file(input : 'contrib/systemd/tcp-erased.service.in',
output : 'tcp-erased.service',
configuration : sd_conf)
build_dir = meson.current_build_dir()
install_data([build_dir / 'tcp-pasted.service',
build_dir / 'tcp-erased.service',
build_dir / 'tcp-expire.service',
'contrib/systemd/tcp-expire.timer'],
install_dir : '/etc/systemd/system')
install_data('contrib/scripts/expire',
install_dir : get_option('bindir'))
# thread_dep = dependency('threads')
inc = include_directories('include')
subdir('src')
build_type = get_option('buildtype')
conf = configuration_data()
conf.set('_GNU_SOURCE', true)
options = [ 'loglevel',
'puid_length',
'max_size',
'path',
'min_age',
'max_age',
'scheme',
'domain',
'xattr_sunset',
'xattr_uin' ]
foreach e : options
opt = get_option(e)
if not conf.has(e)
conf.set(e, opt)
endif
summary(e, opt, section : 'Configuration')
endforeach
assert(conf.get('max_age') >= conf.get('min_age'))
if build_type == 'debug' and conf.get('loglevel') < 4
warning('debug build with loglevel < 4 detected, set to 4')
conf.set('loglevel', 4)
summary('loglevel', 4, section : 'Overrides')
endif
configure_file(input : 'conf.h.in',
output : 'conf.h',
configuration : conf)
add_project_arguments('-include', 'conf.h', language : 'c')
cc = meson.get_compiler('c')
build_args = [ ]
build_args += [ '-Wunused-function',
'-Wunused-variable',
'-variadic-macros',
'-Wno-gnu-zero-variadic-macro-arguments',
'-Werror=vla']
if build_type == 'release'
build_args += [ '-march=native',
'-mtune=native',
'-fstack-protector-strong',
'-fno-plt',
'-ffat-lto-objects',
'-Wp,-D_FORTIFY_SOURCE=2',
'-fstack-protector-strong',
'-fasynchronous-unwind-tables',
'-fstack-clash-protection',
'-fcf-protection']
else
# static_analysis = cc.has_argument('-fanalyzer')
# if static_analysis
# build_args += [ '-fanalyzer' ]
# endif
endif
add_project_arguments(cc.get_supported_arguments(build_args), language : 'c')
if cc.cmd_array().get(0).startswith('musl')
message('Musl wrapper detected, building static binary.')
add_project_link_arguments('-static', language : 'c')
endif
pasted_target = executable(pasted_target_name,
pasted_src,
include_directories : inc,
install : true)
erased_target = executable(erased_target_name,
erased_src,
include_directories : inc,
# dependencies: thread_dep,
install : true)