diff options
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..695e237e --- /dev/null +++ b/meson.build | |||
@@ -0,0 +1,147 @@ | |||
1 | project( | ||
2 | 'sway', | ||
3 | 'c', | ||
4 | license: 'MIT', | ||
5 | default_options: [ | ||
6 | 'c_std=c11', | ||
7 | 'warning_level=2', | ||
8 | 'werror=true', | ||
9 | ], | ||
10 | ) | ||
11 | |||
12 | add_project_arguments('-Wno-unused-parameter', language: 'c') | ||
13 | |||
14 | cc = meson.get_compiler('c') | ||
15 | |||
16 | is_freebsd = host_machine.system().startswith('freebsd') | ||
17 | datadir = get_option('datadir') | ||
18 | sysconfdir = get_option('sysconfdir') | ||
19 | prefix = get_option('prefix') | ||
20 | |||
21 | jsonc = dependency('json-c', version: '>=0.12.1') | ||
22 | pcre = dependency('libpcre') | ||
23 | wlroots = dependency('wlroots') | ||
24 | wayland_server = dependency('wayland-server') | ||
25 | wayland_client = dependency('wayland-client') | ||
26 | wayland_egl = dependency('wayland-egl') | ||
27 | wayland_protos = dependency('wayland-protocols') | ||
28 | xkbcommon = dependency('xkbcommon') | ||
29 | pango = dependency('pango') | ||
30 | pixman = dependency('pixman-1') | ||
31 | libcap = dependency('libcap') | ||
32 | math = cc.find_library('m') | ||
33 | git = find_program('git', required: false) | ||
34 | a2x = find_program('a2x', required: false) | ||
35 | |||
36 | if a2x.found() | ||
37 | mandir = get_option('mandir') | ||
38 | man_files = [ | ||
39 | 'sway/sway.1.txt', | ||
40 | 'sway/sway.5.txt', | ||
41 | 'sway/sway-bar.5.txt', | ||
42 | 'sway/sway-input.5.txt', | ||
43 | 'sway/sway-security.7.txt', | ||
44 | 'swaymsg/swaymsg.1.txt', | ||
45 | ] | ||
46 | foreach filename : man_files | ||
47 | topic = filename.split('.')[-3].split('/')[-1] | ||
48 | section = filename.split('.')[-2] | ||
49 | |||
50 | custom_target( | ||
51 | 'man-@0@-@1@'.format(topic, section), | ||
52 | input: filename, | ||
53 | output: '@BASENAME@', | ||
54 | command: [ | ||
55 | a2x, | ||
56 | '--no-xmllint', | ||
57 | '--doctype', 'manpage', | ||
58 | '--format', 'manpage', | ||
59 | '--destination-dir', meson.current_build_dir(), | ||
60 | '@INPUT@' | ||
61 | ], | ||
62 | install: true, | ||
63 | install_dir: '@0@/man@1@'.format(mandir, section) | ||
64 | ) | ||
65 | endforeach | ||
66 | endif | ||
67 | |||
68 | version = get_option('sway_version') | ||
69 | if version != '' | ||
70 | version = '"@0@"'.format(version) | ||
71 | else | ||
72 | if not git.found() | ||
73 | error('git is required to make the version string') | ||
74 | endif | ||
75 | |||
76 | git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip() | ||
77 | git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip() | ||
78 | version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) | ||
79 | endif | ||
80 | add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') | ||
81 | |||
82 | sway_inc = include_directories('include') | ||
83 | |||
84 | subdir('common') | ||
85 | subdir('sway') | ||
86 | subdir('swaymsg') | ||
87 | |||
88 | config = configuration_data() | ||
89 | config.set('sysconfdir', join_paths(prefix, sysconfdir)) | ||
90 | config.set('datadir', join_paths(prefix, datadir)) | ||
91 | config.set('prefix', prefix) | ||
92 | |||
93 | configure_file( | ||
94 | configuration: config, | ||
95 | input: 'config.in', | ||
96 | output: '@BASENAME@', | ||
97 | install_dir: sysconfdir + '/sway' | ||
98 | ) | ||
99 | |||
100 | if is_freebsd | ||
101 | configure_file( | ||
102 | configuration: config, | ||
103 | input: 'security.d/10-freebsd.in', | ||
104 | output: '@BASENAME@', | ||
105 | install_dir: sysconfdir + '/sway/security.d' | ||
106 | ) | ||
107 | else | ||
108 | configure_file( | ||
109 | configuration: config, | ||
110 | input: 'security.d/00-defaults.in', | ||
111 | output: '@BASENAME@', | ||
112 | install_dir: sysconfdir + '/sway/security.d' | ||
113 | ) | ||
114 | endif | ||
115 | |||
116 | install_data( | ||
117 | 'sway.desktop', | ||
118 | install_dir: datadir + '/wayland-sessions' | ||
119 | ) | ||
120 | |||
121 | if (get_option('default_wallpaper')) | ||
122 | wallpaper_files = files( | ||
123 | 'assets/Sway_Wallpaper_Blue_768x1024.png', | ||
124 | 'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png', | ||
125 | 'assets/Sway_Wallpaper_Blue_1136x640.png', | ||
126 | 'assets/Sway_Wallpaper_Blue_1136x640_Portrait.png', | ||
127 | 'assets/Sway_Wallpaper_Blue_1366x768.png', | ||
128 | 'assets/Sway_Wallpaper_Blue_1920x1080.png', | ||
129 | 'assets/Sway_Wallpaper_Blue_2048x1536.png', | ||
130 | 'assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png', | ||
131 | ) | ||
132 | wallpaper_install_dir = datadir + '/backgrounds/sway' | ||
133 | |||
134 | install_data(wallpaper_files, install_dir: wallpaper_install_dir) | ||
135 | endif | ||
136 | |||
137 | if (get_option('zsh_completions')) | ||
138 | zsh_files = files( | ||
139 | 'completions/zsh/_sway', | ||
140 | 'completions/zsh/_swaygrab', | ||
141 | 'completions/zsh/_swaylock', | ||
142 | 'completions/zsh/_swaymsg', | ||
143 | ) | ||
144 | zsh_install_dir = datadir + '/zsh/site-functions' | ||
145 | |||
146 | install_data(zsh_files, install_dir: zsh_install_dir) | ||
147 | endif | ||