-
Notifications
You must be signed in to change notification settings - Fork 200
/
meson.build
160 lines (137 loc) · 3.75 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
project(
'swaylock',
'c',
version: '1.8.0',
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',
'-Wvla',
],
language: 'c',
)
cc = meson.get_compiler('c')
is_freebsd = host_machine.system().startswith('freebsd')
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'))
libpam = cc.find_library('pam', required: get_option('pam'))
crypt = cc.find_library('crypt', required: not libpam.found())
math = cc.find_library('m')
rt = cc.find_library('rt')
git = find_program('git', required: false)
scdoc = find_program('scdoc', required: get_option('man-pages'))
wayland_scanner_prog = find_program(wayland_scanner.get_variable('wayland_scanner'), native: true)
version = 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
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
wayland_scanner_code = generator(
wayland_scanner_prog,
output: '@[email protected]',
arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
)
wayland_scanner_client = generator(
wayland_scanner_prog,
output: '@[email protected]',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)
client_protocols = [
wl_protocol_dir / 'staging/ext-session-lock/ext-session-lock-v1.xml',
]
protos_src = []
foreach xml : client_protocols
protos_src += wayland_scanner_code.process(xml)
protos_src += wayland_scanner_client.process(xml)
endforeach
conf_data = configuration_data()
conf_data.set_quoted('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
conf_data.set_quoted('SWAYLOCK_VERSION', version)
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
subdir('include')
dependencies = [
cairo,
gdk_pixbuf,
math,
rt,
xkbcommon,
wayland_client,
]
sources = [
'background-image.c',
'cairo.c',
'comm.c',
'log.c',
'loop.c',
'main.c',
'password.c',
'password-buffer.c',
'pool-buffer.c',
'render.c',
'seat.c',
'unicode.c',
]
if libpam.found()
sources += ['pam.c']
dependencies += [libpam]
else
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']
dependencies += [crypt]
endif
swaylock_inc = include_directories('include')
executable('swaylock',
sources + protos_src,
include_directories: [swaylock_inc],
dependencies: dependencies,
install: true
)
if libpam.found()
install_data(
'pam/swaylock',
install_dir: get_option('sysconfdir') / 'pam.d'
)
endif
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,
install: true,
install_dir: '@0@/man@1@'.format(mandir, section)
)
endforeach
endif
subdir('completions')