swaylock/meson.build

217 lines
5.2 KiB
Meson
Raw Normal View History

project(
'swaylock',
'c',
2022-11-27 07:07:27 -06:00
version: '1.7',
license: 'MIT',
meson_version: '>=0.59.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', version: '>=1.20.0')
wayland_protos = dependency('wayland-protocols', version: '>=1.25', fallback: 'wayland-protocols')
wayland_scanner = dependency('wayland-scanner', version: '>=1.15.0', native: true)
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
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)
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'))
2022-11-27 07:13:37 -06:00
wayland_scanner_prog = find_program(wayland_scanner.get_variable('wayland_scanner'), native: true)
version = '"@0@"'.format(meson.project_version())
if git.found()
git_commit_hash = run_command([git, 'describe', '--always', '--tags'], check: false)
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
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_variable('pkgdatadir')
wayland_scanner_code = generator(
wayland_scanner_prog,
output: '@BASENAME@-protocol.c',
arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
)
wayland_scanner_client = generator(
wayland_scanner_prog,
output: '@BASENAME@-client-protocol.h',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)
client_protos_src = []
client_protos_headers = []
client_protocols = [
2022-09-24 05:51:19 -05:00
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
wl_protocol_dir / 'staging/ext-session-lock/ext-session-lock-v1.xml',
'wlr-layer-shell-unstable-v1.xml',
'wlr-input-inhibitor-unstable-v1.xml',
]
2022-09-24 05:51:19 -05:00
foreach xml : client_protocols
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',
2022-05-30 04:50:30 -05:00
'password-buffer.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()
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: scdoc,
feed: true,
capture: true,
2019-01-13 20:24:33 -06:00
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_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_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