2019-01-13 20:15:32 -06:00
project (
'swaylock' ,
'c' ,
2020-01-23 03:00:38 -06:00
version : '1.6' ,
2019-01-13 20:15:32 -06:00
license : 'MIT' ,
2022-02-02 08:44:41 -06:00
meson_version : '>=0.59.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 ) ) ,
2022-02-02 08:35:52 -06:00
language : 'c' ,
)
2019-01-13 20:15:32 -06:00
if is_freebsd
add_project_arguments ( '-D_C11_SOURCE' , language : 'c' )
endif
2022-02-02 09:43:58 -06:00
wayland_client = dependency ( 'wayland-client' , version : '>=1.20.0' )
2021-12-20 10:25:44 -06:00
wayland_protos = dependency ( 'wayland-protocols' , version : '>=1.25' , fallback : 'wayland-protocols' )
2022-04-25 14:28:34 -05:00
# use native version of wayland-scanner when cross-compiling
# meson does this too: https://github.com/mesonbuild/meson/blob/c649a2b8c59c9f49affca9bd89c126bfa0f54449/mesonbuild/modules/unstable_wayland.py#L48-L53
wayland_scanner = dependency ( 'wayland-scanner' , version : '>=1.15.0' , native : true )
2022-02-02 08:35:52 -06:00
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' )
2019-01-13 20:15:32 -06:00
git = find_program ( 'git' , required : false )
2019-01-24 15:14:13 -06:00
scdoc = find_program ( 'scdoc' , required : get_option ( 'man-pages' ) )
2022-02-02 08:42:29 -06:00
wayland_scanner_prog = find_program ( wayland_scanner . get_variable ( 'wayland_scanner' ) )
2019-01-13 20:15:32 -06:00
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 ( )
2022-02-02 08:34:13 -06:00
git_commit_hash = run_command ( [ git , 'describe' , '--always' , '--tags' ] , check : false )
git_branch = run_command ( [ git , 'rev-parse' , '--abbrev-ref' , 'HEAD' ] , check : false )
2019-02-12 16:25:56 -06:00
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
2021-12-20 09:41:10 -06:00
wl_protocol_dir = wayland_protos . get_variable ( 'pkgdatadir' )
2019-01-13 20:15:32 -06:00
wayland_scanner_code = generator (
2022-02-02 08:42:29 -06:00
wayland_scanner_prog ,
2019-01-13 20:15:32 -06:00
output : '@BASENAME@-protocol.c' ,
2022-02-02 08:42:29 -06:00
arguments : [ 'private-code' , '@INPUT@' , '@OUTPUT@' ] ,
2019-01-13 20:15:32 -06:00
)
wayland_scanner_client = generator (
2022-02-02 08:42:29 -06:00
wayland_scanner_prog ,
2019-01-13 20:15:32 -06:00
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' ] ,
2021-12-20 10:25:44 -06:00
[ wl_protocol_dir , 'staging/ext-session-lock/ext-session-lock-v1.xml' ] ,
2019-01-13 20:15:32 -06:00
[ '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 ( )
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 ,
2022-02-02 08:44:41 -06:00
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
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 ( )
2021-12-20 09:41:10 -06:00
bash_install_dir = bash_comp . get_variable ( 'completionsdir' )
2020-01-21 22:19:13 -06:00
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 ( )
2021-12-20 09:41:10 -06:00
fish_install_dir = fish_comp . get_variable ( 'completionsdir' )
2020-01-21 22:19:13 -06:00
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