2019-01-13 20:15:32 -06:00
|
|
|
project(
|
|
|
|
'swaylock',
|
|
|
|
'c',
|
2019-05-23 01:18:14 -05:00
|
|
|
version: '1.4',
|
2019-01-13 20:15:32 -06:00
|
|
|
license: 'MIT',
|
2019-01-18 01:58:57 -06:00
|
|
|
meson_version: '>=0.48.0',
|
2019-01-13 20:15:32 -06:00
|
|
|
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',
|
2019-01-13 20:15:32 -06:00
|
|
|
],
|
|
|
|
language: 'c',
|
|
|
|
)
|
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
2018-04-19 19:25:51 -05:00
|
|
|
sysconfdir = get_option('sysconfdir')
|
2019-01-13 20:15:32 -06:00
|
|
|
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'))
|
2020-01-21 22:19:13 -06:00
|
|
|
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())
|
2019-01-13 20:15:32 -06:00
|
|
|
math = cc.find_library('m')
|
|
|
|
|
|
|
|
git = find_program('git', required: false)
|
2019-01-24 15:14:13 -06:00
|
|
|
scdoc = find_program('scdoc', required: get_option('man-pages'))
|
2019-01-13 20:15:32 -06:00
|
|
|
wayland_scanner = find_program('wayland-scanner')
|
|
|
|
|
2019-02-12 16:25:56 -06:00
|
|
|
version = '"@0@"'.format(meson.project_version())
|
2019-02-05 07:09:32 -06:00
|
|
|
if git.found()
|
2019-02-12 16:25:56 -06:00
|
|
|
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
|
2019-01-13 20:15:32 -06:00
|
|
|
endif
|
2019-01-17 10:17:36 -06:00
|
|
|
add_project_arguments('-DSWAYLOCK_VERSION=@0@'.format(version), language: 'c')
|
2019-01-13 20:15:32 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-09-28 05:18:54 -05:00
|
|
|
dependencies = [
|
2019-01-16 15:45:38 -06:00
|
|
|
cairo,
|
|
|
|
client_protos,
|
|
|
|
gdk_pixbuf,
|
|
|
|
math,
|
|
|
|
xkbcommon,
|
|
|
|
wayland_client,
|
2018-09-28 05:18:54 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
sources = [
|
2019-01-13 20:15:32 -06:00
|
|
|
'background-image.c',
|
|
|
|
'cairo.c',
|
2019-01-16 16:35:14 -06:00
|
|
|
'comm.c',
|
2019-01-14 22:30:54 -06:00
|
|
|
'log.c',
|
2019-01-13 20:15:32 -06:00
|
|
|
'loop.c',
|
|
|
|
'main.c',
|
|
|
|
'password.c',
|
|
|
|
'pool-buffer.c',
|
|
|
|
'render.c',
|
|
|
|
'seat.c',
|
|
|
|
'unicode.c',
|
2018-09-28 05:18:54 -05:00
|
|
|
]
|
|
|
|
|
2019-01-18 01:58:57 -06:00
|
|
|
if libpam.found()
|
2019-01-16 15:45:38 -06:00
|
|
|
sources += ['pam.c']
|
|
|
|
dependencies += [libpam]
|
2018-09-28 05:18:54 -05:00
|
|
|
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]
|
2018-09-28 05:18:54 -05:00
|
|
|
endif
|
|
|
|
|
2019-01-13 20:15:32 -06:00
|
|
|
swaylock_inc = include_directories('include')
|
|
|
|
|
2018-09-28 05:18:54 -05:00
|
|
|
executable('swaylock',
|
2019-01-16 15:45:38 -06:00
|
|
|
sources,
|
2019-01-13 20:15:32 -06:00
|
|
|
include_directories: [swaylock_inc],
|
2018-09-28 05:18:54 -05:00
|
|
|
dependencies: dependencies,
|
2018-04-02 21:48:13 -05:00
|
|
|
install: true
|
|
|
|
)
|
2018-04-19 19:25:51 -05:00
|
|
|
|
2020-01-06 11:17:15 -06: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
|
|
|
|
2019-01-14 18:48:31 -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',
|
|
|
|
)
|
2020-01-21 22:19:13 -06:00
|
|
|
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',
|
|
|
|
)
|
2020-01-21 22:19:13 -06:00
|
|
|
if fish_comp.found()
|
|
|
|
fish_install_dir = fish_comp.get_pkgconfig_variable('completionsdir')
|
|
|
|
else
|
2020-01-21 22:19:37 -06:00
|
|
|
fish_install_dir = datadir + '/fish/vendor_completions.d'
|
2020-01-21 22:19:13 -06:00
|
|
|
endif
|
2019-01-14 18:38:03 -06:00
|
|
|
|
|
|
|
install_data(fish_files, install_dir: fish_install_dir)
|
|
|
|
endif
|