aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build190
1 files changed, 72 insertions, 118 deletions
diff --git a/meson.build b/meson.build
index 38a55678..1043e4ba 100644
--- a/meson.build
+++ b/meson.build
@@ -1,9 +1,9 @@
1project( 1project(
2 'sway', 2 'sway',
3 'c', 3 'c',
4 version: '1.5', #release_version 4 version: '1.10-dev',
5 license: 'MIT', 5 license: 'MIT',
6 meson_version: '>=0.53.0', 6 meson_version: '>=0.60.0',
7 default_options: [ 7 default_options: [
8 'c_std=c11', 8 'c_std=c11',
9 'warning_level=2', 9 'warning_level=2',
@@ -14,10 +14,12 @@ project(
14add_project_arguments( 14add_project_arguments(
15 [ 15 [
16 '-DWLR_USE_UNSTABLE', 16 '-DWLR_USE_UNSTABLE',
17 '-D_POSIX_C_SOURCE=200809L',
17 18
18 '-Wno-unused-parameter', 19 '-Wno-unused-parameter',
19 '-Wno-unused-result', 20 '-Wno-unused-result',
20 '-Wno-missing-braces', 21 '-Wno-missing-braces',
22 '-Wno-format-zero-length',
21 '-Wundef', 23 '-Wundef',
22 '-Wvla', 24 '-Wvla',
23 ], 25 ],
@@ -35,79 +37,65 @@ if is_freebsd
35 add_project_arguments('-D_C11_SOURCE', language: 'c') 37 add_project_arguments('-D_C11_SOURCE', language: 'c')
36endif 38endif
37 39
38jsonc = dependency('json-c', version: '>=0.13') 40# Execute the wlroots subproject, if any
39pcre = dependency('libpcre') 41wlroots_version = ['>=0.18.0', '<0.19.0']
40wayland_server = dependency('wayland-server') 42subproject(
41wayland_client = dependency('wayland-client')
42wayland_cursor = dependency('wayland-cursor')
43wayland_egl = dependency('wayland-egl')
44wayland_protos = dependency('wayland-protocols', version: '>=1.14')
45xkbcommon = dependency('xkbcommon')
46cairo = dependency('cairo')
47pango = dependency('pango')
48pangocairo = dependency('pangocairo')
49gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
50pixman = dependency('pixman-1')
51glesv2 = dependency('glesv2')
52libevdev = dependency('libevdev')
53libinput = dependency('libinput', version: '>=1.6.0')
54xcb = dependency('xcb', required: get_option('xwayland'))
55bash_comp = dependency('bash-completion', required: false)
56fish_comp = dependency('fish', required: false)
57math = cc.find_library('m')
58rt = cc.find_library('rt')
59
60# Try first to find wlroots as a subproject, then as a system dependency
61wlroots_version = ['>=0.12.0', '<0.13.0']
62wlroots_proj = subproject(
63 'wlroots', 43 'wlroots',
64 default_options: ['examples=false'], 44 default_options: ['examples=false'],
65 required: false, 45 required: false,
66 version: wlroots_version, 46 version: wlroots_version,
67) 47)
48wlroots = dependency('wlroots', version: wlroots_version)
68wlroots_features = { 49wlroots_features = {
69 'xwayland': false, 50 'xwayland': false,
70 'systemd': false, 51 'libinput_backend': false,
71 'elogind': false, 52 'session': false,
72 'libseat': false,
73} 53}
74if wlroots_proj.found() 54foreach name, _ : wlroots_features
75 wlroots = wlroots_proj.get_variable('wlroots') 55 var_name = 'have_' + name.underscorify()
76 wlroots_conf = wlroots_proj.get_variable('conf_data') 56 have = wlroots.get_variable(pkgconfig: var_name, internal: var_name) == 'true'
77 foreach name, _ : wlroots_features 57 wlroots_features += { name: have }
78 has = wlroots_conf.get('WLR_HAS_' + name.to_upper()) == 1 58endforeach
79 wlroots_features += { name: has }
80 endforeach
81else
82 wlroots = dependency('wlroots', version: wlroots_version)
83 foreach name, _ : wlroots_features
84 has = cc.get_define('WLR_HAS_' + name.to_upper(), prefix: '#include <wlr/config.h>', dependencies: wlroots) == '1'
85 wlroots_features += { name: has }
86 endforeach
87endif
88 59
89if get_option('xwayland').enabled() and not wlroots_features['xwayland'] 60if get_option('xwayland').enabled() and not wlroots_features['xwayland']
90 error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support') 61 error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support')
91endif 62endif
92have_xwayland = xcb.found() and wlroots_features['xwayland'] 63
64null_dep = dependency('', required: false)
65
66jsonc = dependency('json-c', version: '>=0.13')
67pcre2 = dependency('libpcre2-8')
68wayland_server = dependency('wayland-server', version: '>=1.21.0')
69wayland_client = dependency('wayland-client')
70wayland_cursor = dependency('wayland-cursor')
71wayland_protos = dependency('wayland-protocols', version: '>=1.24')
72xkbcommon = dependency('xkbcommon', version: '>=1.5.0')
73cairo = dependency('cairo')
74pango = dependency('pango')
75pangocairo = dependency('pangocairo')
76gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
77pixman = dependency('pixman-1')
78libevdev = dependency('libevdev')
79libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
80xcb = dependency('xcb', required: get_option('xwayland'))
81drm = dependency('libdrm')
82libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep
83math = cc.find_library('m')
84rt = cc.find_library('rt')
85xcb_icccm = dependency('xcb-icccm', required: get_option('xwayland'))
86threads = dependency('threads') # for pthread_setschedparam
87
88have_xwayland = xcb.found() and xcb_icccm.found() and wlroots_features['xwayland']
93 89
94if get_option('sd-bus-provider') == 'auto' 90if get_option('sd-bus-provider') == 'auto'
95 if not get_option('tray').disabled() 91 if not get_option('tray').disabled()
96 assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto') 92 assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
97 endif 93 endif
98 sdbus = dependency('libsystemd', 94 sdbus = dependency(['libsystemd', 'libelogind'],
99 required: false, 95 required: false,
100 version: '>=239', 96 version: '>=239',
101 not_found_message: 'libsystemd not found, trying libelogind',
102 ) 97 )
103 if not sdbus.found() 98 if not sdbus.found()
104 sdbus = dependency('libelogind',
105 required: false,
106 version: '>=239',
107 not_found_message: 'libelogind not found, trying basu',
108 )
109 endif
110 if not sdbus.found()
111 sdbus = dependency('basu', required: false) 99 sdbus = dependency('basu', required: false)
112 endif 100 endif
113else 101else
@@ -128,11 +116,15 @@ conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd
128conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind') 116conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
129conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu') 117conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu')
130conf_data.set10('HAVE_TRAY', have_tray) 118conf_data.set10('HAVE_TRAY', have_tray)
119conf_data.set10('HAVE_LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM', cc.has_header_symbol(
120 'libinput.h',
121 'LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM',
122 dependencies: libinput,
123))
131 124
132scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages')) 125scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
133if scdoc.found() 126if scdoc.found()
134 scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true) 127 scdoc_prog = find_program(scdoc.get_variable(pkgconfig: 'scdoc'), native: true)
135 sh = find_program('sh', native: true)
136 mandir = get_option('mandir') 128 mandir = get_option('mandir')
137 man_files = [ 129 man_files = [
138 'sway/sway.1.scd', 130 'sway/sway.1.scd',
@@ -143,9 +135,15 @@ if scdoc.found()
143 'sway/sway-output.5.scd', 135 'sway/sway-output.5.scd',
144 'swaybar/swaybar-protocol.7.scd', 136 'swaybar/swaybar-protocol.7.scd',
145 'swaymsg/swaymsg.1.scd', 137 'swaymsg/swaymsg.1.scd',
146 'swaynag/swaynag.1.scd',
147 'swaynag/swaynag.5.scd',
148 ] 138 ]
139
140 if get_option('swaynag')
141 man_files += [
142 'swaynag/swaynag.1.scd',
143 'swaynag/swaynag.5.scd',
144 ]
145 endif
146
149 foreach filename : man_files 147 foreach filename : man_files
150 topic = filename.split('.')[-3].split('/')[-1] 148 topic = filename.split('.')[-3].split('/')[-1]
151 section = filename.split('.')[-2] 149 section = filename.split('.')[-2]
@@ -155,10 +153,10 @@ if scdoc.found()
155 output, 153 output,
156 input: filename, 154 input: filename,
157 output: output, 155 output: output,
158 command: [ 156 command: scdoc_prog,
159 sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output)
160 ],
161 install: true, 157 install: true,
158 feed: true,
159 capture: true,
162 install_dir: '@0@/man@1@'.format(mandir, section) 160 install_dir: '@0@/man@1@'.format(mandir, section)
163 ) 161 )
164 endforeach 162 endforeach
@@ -169,8 +167,8 @@ add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir
169version = '"@0@"'.format(meson.project_version()) 167version = '"@0@"'.format(meson.project_version())
170git = find_program('git', native: true, required: false) 168git = find_program('git', native: true, required: false)
171if git.found() 169if git.found()
172 git_commit = run_command([git, 'rev-parse', '--short', 'HEAD']) 170 git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
173 git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD']) 171 git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
174 if git_commit.returncode() == 0 and git_branch.returncode() == 0 172 if git_commit.returncode() == 0 and git_branch.returncode() == 0
175 version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format( 173 version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format(
176 meson.project_version(), 174 meson.project_version(),
@@ -183,7 +181,7 @@ add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
183 181
184# Compute the relative path used by compiler invocations. 182# Compute the relative path used by compiler invocations.
185source_root = meson.current_source_dir().split('/') 183source_root = meson.current_source_dir().split('/')
186build_root = meson.build_root().split('/') 184build_root = meson.global_build_root().split('/')
187relative_dir_parts = [] 185relative_dir_parts = []
188i = 0 186i = 0
189in_prefix = true 187in_prefix = true
@@ -227,9 +225,15 @@ subdir('common')
227subdir('sway') 225subdir('sway')
228subdir('swaymsg') 226subdir('swaymsg')
229 227
230subdir('client') 228if get_option('swaybar') or get_option('swaynag')
231subdir('swaybar') 229 subdir('client')
232subdir('swaynag') 230endif
231if get_option('swaybar')
232 subdir('swaybar')
233endif
234if get_option('swaynag')
235 subdir('swaynag')
236endif
233 237
234config = configuration_data() 238config = configuration_data()
235config.set('datadir', join_paths(prefix, datadir)) 239config.set('datadir', join_paths(prefix, datadir))
@@ -264,61 +268,11 @@ if get_option('default-wallpaper')
264 install_data(wallpaper_files, install_dir: wallpaper_install_dir) 268 install_data(wallpaper_files, install_dir: wallpaper_install_dir)
265endif 269endif
266 270
267if get_option('zsh-completions') 271subdir('completions')
268 zsh_files = files(
269 'completions/zsh/_sway',
270 'completions/zsh/_swaymsg',
271 )
272 zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')
273
274 install_data(zsh_files, install_dir: zsh_install_dir)
275endif
276
277if get_option('bash-completions')
278 bash_files = files(
279 'completions/bash/sway',
280 'completions/bash/swaybar',
281 'completions/bash/swaymsg',
282 )
283 if bash_comp.found()
284 bash_install_dir = bash_comp.get_pkgconfig_variable(
285 'completionsdir',
286 define_variable: ['datadir', datadir]
287 )
288 else
289 bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
290 endif
291
292 install_data(bash_files, install_dir: bash_install_dir)
293endif
294
295if get_option('fish-completions')
296 fish_files = files(
297 'completions/fish/sway.fish',
298 'completions/fish/swaymsg.fish',
299 'completions/fish/swaynag.fish',
300 )
301 if fish_comp.found()
302 fish_install_dir = fish_comp.get_pkgconfig_variable(
303 'completionsdir',
304 define_variable: ['datadir', datadir]
305 )
306 else
307 fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
308 endif
309
310 install_data(fish_files, install_dir: fish_install_dir)
311endif
312 272
313summary({ 273summary({
314 'xwayland': have_xwayland, 274 'xwayland': have_xwayland,
315 'gdk-pixbuf': gdk_pixbuf.found(), 275 'gdk-pixbuf': gdk_pixbuf.found(),
316 'sd-bus': sdbus.found(),
317 'tray': have_tray, 276 'tray': have_tray,
318 'man-pages': scdoc.found(), 277 'man-pages': scdoc.found(),
319}, bool_yn: true) 278}, bool_yn: true)
320
321if not wlroots_features['systemd'] and not wlroots_features['elogind'] and not wlroots_features['libseat']
322 warning('The sway binary must be setuid when compiled without (e)logind or libseat')
323 warning('You must do this manually post-install: chmod a+s /path/to/sway')
324endif