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