1project(
2 'swaylock',
3 'c',
4 version: '1.7.0.0',
5 license: 'MIT',
6 meson_version: '>=0.59.0',
7 default_options: [
8 'c_std=c11',
9 'warning_level=2',
10 'werror=true',
11 ],
12)
13
14add_project_arguments(
15 [
16 '-Wno-unused-parameter',
17 '-Wno-unused-result',
18 '-Wundef',
19 '-Wvla',
20 ],
21 language: 'c',
22)
23
24cc = meson.get_compiler('c')
25
26if get_option('sse')
27 add_project_arguments('-DUSE_SSE', language: 'c')
28endif
29
30wayland_client = dependency('wayland-client', version: '>=1.20.0')
31wayland_protos = dependency('wayland-protocols', version: '>=1.25', fallback: 'wayland-protocols')
32wayland_scanner = dependency('wayland-scanner', version: '>=1.15.0', native: true)
33xkbcommon = dependency('xkbcommon')
34cairo = dependency('cairo')
35omp = dependency('openmp')
36gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
37libpam = cc.find_library('pam', required: get_option('pam'))
38crypt = cc.find_library('crypt', required: not libpam.found())
39math = cc.find_library('m')
40rt = cc.find_library('rt')
41dl = cc.find_library('dl')
42
43wayland_scanner_prog = find_program(wayland_scanner.get_variable('wayland_scanner'), native: true)
44
45version = meson.project_version()
46wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
47
48wayland_scanner_code = generator(
49 wayland_scanner_prog,
50 output: '@BASENAME@-protocol.c',
51 arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
52)
53
54wayland_scanner_client = generator(
55 wayland_scanner_prog,
56 output: '@BASENAME@-client-protocol.h',
57 arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
58)
59
60client_protocols = [
61 wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
62 wl_protocol_dir / 'staging/ext-session-lock/ext-session-lock-v1.xml',
63 'wlr-layer-shell-unstable-v1.xml',
64 'wlr-input-inhibitor-unstable-v1.xml',
65 'wlr-screencopy-unstable-v1.xml',
66]
67
68protos_src = []
69foreach xml : client_protocols
70 protos_src += wayland_scanner_code.process(xml)
71 protos_src += wayland_scanner_client.process(xml)
72endforeach
73
74conf_data = configuration_data()
75conf_data.set_quoted('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
76conf_data.set_quoted('SWAYLOCK_VERSION', version)
77conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
78
79subdir('include')
80
81dependencies = [
82 cairo,
83 gdk_pixbuf,
84 math,
85 rt,
86 dl,
87 xkbcommon,
88 wayland_client,
89 omp
90]
91
92sources = [
93 'background-image.c',
94 'cairo.c',
95 'comm.c',
96 'log.c',
97 'loop.c',
98 'main.c',
99 'password.c',
100 'password-buffer.c',
101 'pool-buffer.c',
102 'render.c',
103 'seat.c',
104 'unicode.c',
105 'effects.c',
106 'fade.c',
107]
108
109if libpam.found()
110 sources += ['pam.c']
111 dependencies += [libpam]
112else
113 warning('The swaylock binary must be setuid when compiled without libpam')
114 warning('You must do this manually post-install: chmod a+s /path/to/swaylock')
115 sources += ['shadow.c']
116 dependencies += [crypt]
117endif
118
119swaylock_inc = include_directories('include')
120
121executable('swaylock',
122 sources + protos_src,
123 include_directories: [swaylock_inc],
124 dependencies: dependencies,
125 install: true
126)
127
128install_data(
129 'pam/swaylock',
130 install_dir: get_option('sysconfdir') / 'pam.d'
131)