swaylock/meson.build

222 lines
5.2 KiB
Meson
Raw Normal View History

project(
'swaylock',
'c',
2019-05-23 01:18:14 -05:00
version: '1.4',
license: 'MIT',
2019-01-18 01:58:57 -06:00
meson_version: '>=0.48.0',
default_options: [
'c_std=c11',
'warning_level=2',
'werror=true',
],
)
add_project_arguments(
[
'-Wno-unused-parameter',
'-Wno-unused-result',
'-Wundef',
2019-01-18 06:27:42 -06:00
'-Wvla',
],
language: 'c',
)
cc = meson.get_compiler('c')
2018-04-19 19:25:51 -05:00
sysconfdir = get_option('sysconfdir')
prefix = get_option('prefix')
is_freebsd = host_machine.system().startswith('freebsd')
add_project_arguments(
'-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)),
language : 'c')
if is_freebsd
add_project_arguments('-D_C11_SOURCE', language: 'c')
endif
wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
2019-01-18 01:58:57 -06:00
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false)
2019-01-18 01:58:57 -06:00
libpam = cc.find_library('pam', required: get_option('pam'))
crypt = cc.find_library('crypt', required: not libpam.found())
math = cc.find_library('m')
git = find_program('git', required: false)
scdoc = find_program('scdoc', required: get_option('man-pages'))
wayland_scanner = find_program('wayland-scanner')
version = '"@0@"'.format(meson.project_version())
if git.found()
git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags'])
git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD'])
if git_commit_hash.returncode() == 0 and git_branch.returncode() == 0
version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash.stdout().strip(), git_branch.stdout().strip())
endif
endif
add_project_arguments('-DSWAYLOCK_VERSION=@0@'.format(version), language: 'c')
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
if wayland_client.version().version_compare('>=1.14.91')
code_type = 'private-code'
else
code_type = 'code'
endif
wayland_scanner_code = generator(
wayland_scanner,
output: '@BASENAME@-protocol.c',
arguments: [code_type, '@INPUT@', '@OUTPUT@'],
)
wayland_scanner_client = generator(
wayland_scanner,
output: '@BASENAME@-client-protocol.h',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)
client_protos_src = []
client_protos_headers = []
client_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-input-inhibitor-unstable-v1.xml'],
]
foreach p : client_protocols
xml = join_paths(p)
client_protos_src += wayland_scanner_code.process(xml)
client_protos_headers += wayland_scanner_client.process(xml)
endforeach
lib_client_protos = static_library(
'client_protos',
client_protos_src + client_protos_headers,
dependencies: [wayland_client]
) # for the include directory
client_protos = declare_dependency(
link_with: lib_client_protos,
sources: client_protos_headers,
)
conf_data = configuration_data()
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
subdir('include')
2018-04-19 19:25:51 -05:00
dependencies = [
2019-01-16 15:45:38 -06:00
cairo,
client_protos,
gdk_pixbuf,
math,
xkbcommon,
wayland_client,
]
sources = [
'background-image.c',
'cairo.c',
2019-01-16 16:35:14 -06:00
'comm.c',
'log.c',
'loop.c',
'main.c',
'password.c',
'pool-buffer.c',
'render.c',
'seat.c',
'unicode.c',
]
2019-01-18 01:58:57 -06:00
if libpam.found()
2019-01-16 15:45:38 -06:00
sources += ['pam.c']
dependencies += [libpam]
else
2019-01-16 15:45:38 -06:00
warning('The swaylock binary must be setuid when compiled without libpam')
warning('You must do this manually post-install: chmod a+s /path/to/swaylock')
sources += ['shadow.c']
2019-01-18 01:58:57 -06:00
dependencies += [crypt]
endif
swaylock_inc = include_directories('include')
executable('swaylock',
2019-01-16 15:45:38 -06:00
sources,
include_directories: [swaylock_inc],
dependencies: dependencies,
2018-04-02 21:48:13 -05:00
install: true
)
2018-04-19 19:25:51 -05:00
install_data(
'pam/swaylock',
install_dir: sysconfdir + '/pam.d/'
)
2019-01-13 20:24:33 -06:00
if scdoc.found()
sh = find_program('sh')
mandir = get_option('mandir')
man_files = [
'swaylock.1.scd',
]
foreach filename : man_files
topic = filename.split('.')[-3].split('/')[-1]
section = filename.split('.')[-2]
output = '@0@.@1@'.format(topic, section)
custom_target(
output,
input: filename,
output: output,
command: [
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc.path(), output)
],
install: true,
install_dir: '@0@/man@1@'.format(mandir, section)
)
endforeach
endif
2019-01-14 18:38:03 -06:00
datadir = get_option('datadir')
2019-01-16 15:45:38 -06:00
if get_option('zsh-completions')
2019-01-14 18:38:03 -06:00
zsh_files = files(
'completions/zsh/_swaylock',
)
zsh_install_dir = datadir + '/zsh/site-functions'
install_data(zsh_files, install_dir: zsh_install_dir)
endif
2019-01-16 15:45:38 -06:00
if get_option('bash-completions')
2019-01-14 18:38:03 -06:00
bash_files = files(
'completions/bash/swaylock',
)
if bash_comp.found()
bash_install_dir = bash_comp.get_pkgconfig_variable('completionsdir')
else
bash_install_dir = datadir + '/bash-completion/completions'
endif
2019-01-14 18:38:03 -06:00
install_data(bash_files, install_dir: bash_install_dir)
endif
2019-01-16 15:45:38 -06:00
if get_option('fish-completions')
2019-01-14 18:38:03 -06:00
fish_files = files(
'completions/fish/swaylock.fish',
)
if fish_comp.found()
fish_install_dir = fish_comp.get_pkgconfig_variable('completionsdir')
else
fish_install_dir = datadir + '/fish/vendor_completions.d'
endif
2019-01-14 18:38:03 -06:00
install_data(fish_files, install_dir: fish_install_dir)
endif