forked from pwmt/zathura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
226 lines (199 loc) · 6.41 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
project('zathura', 'c',
version: '0.5.8',
meson_version: '>=0.61',
default_options: ['c_std=c17', 'warning_level=3'],
)
version = meson.project_version()
version_array = version.split('.')
# Rules for plugin API and ABI (non-exhaustive):
# * zathura_plugin_function_t: If functions are addedd or removed or their
# signature changes, bump both ABI and API.
# * zathura_plugin_definition_t: If the struct changes in an ABI-incompatible
# way, bump the ABI.
plugin_api_version = '6'
plugin_abi_version = '7'
conf_data = configuration_data()
conf_data.set('ZVMAJOR', version_array[0])
conf_data.set('ZVMINOR', version_array[1])
conf_data.set('ZVREV', version_array[2])
conf_data.set('ZVAPI', plugin_api_version)
conf_data.set('ZVABI', plugin_abi_version)
conf_data.set('version', version)
cc = meson.get_compiler('c')
prefix = get_option('prefix')
localedir = get_option('localedir')
datadir = get_option('datadir')
metainfodir = join_paths(datadir, 'metainfo')
desktopdir = join_paths(datadir, 'applications')
dbusinterfacesdir = join_paths(datadir, 'dbus-1', 'interfaces')
plugindir = join_paths(get_option('libdir'), 'zathura')
# required dependencies
libm = cc.find_library('m', required: false)
girara = dependency('girara-gtk3', version: '>=0.4.3', fallback: ['girara', 'girara_dependency'])
glib = dependency('glib-2.0', version: '>=2.72')
gio = dependency('gio-unix-2.0', required: host_machine.system() != 'windows')
gthread = dependency('gthread-2.0', version: '>=2.72')
gmodule = dependency('gmodule-no-export-2.0', version: '>=2.72')
gtk3 = dependency('gtk+-3.0', version: '>=3.24')
json_glib = dependency('json-glib-1.0')
cairo = dependency('cairo')
magic = dependency('libmagic')
sqlite = dependency('sqlite3', version: '>=3.6.23')
build_dependencies = [libm, girara, glib, gio, gthread, gmodule, gtk3, cairo, magic, json_glib, sqlite]
if host_machine.system() == 'darwin'
gtk_mac_integration = dependency('gtk-mac-integration-gtk3')
build_dependencies += gtk_mac_integration
endif
# defines
defines = [
'-DGETTEXT_PACKAGE="zathura"',
'-DLOCALEDIR="@0@"'.format(join_paths(prefix, localedir)),
'-DZATHURA_PLUGINDIR="@0@"'.format(join_paths(prefix, plugindir)),
'-D_DEFAULT_SOURCE',
]
if host_machine.system() == 'darwin'
defines += '-DGTKOSXAPPLICATION'
endif
# compile flags
flags = [
'-Werror=implicit-function-declaration',
'-Werror=vla',
'-fvisibility=hidden',
'-Werror=int-conversion'
]
flags = cc.get_supported_arguments(flags)
# optional dependencies
synctex = dependency('synctex', version: '>=1.19', required: get_option('synctex'))
seccomp = dependency('libseccomp', required: get_option('seccomp'))
landlock = cc.check_header('linux/landlock.h', required: get_option('landlock'))
if synctex.found()
build_dependencies += synctex
defines += '-DWITH_SYNCTEX'
if synctex.version() < '2.0.0' and synctex.version() >= '1.19.0'
warning('You are using a synctex version pre-SONAME bump, but post-ABI-break. Please make sure to always run zathura using the correct synctex version.')
endif
endif
# generate version header file
version_header = configure_file(
input: 'zathura/version.h.in',
output: 'zathura-version.h',
configuration: conf_data
)
include_directories = [
include_directories('.')
]
subdir('data')
subdir('po')
# source files
sources = files(
'zathura/adjustment.c',
'zathura/bookmarks.c',
'zathura/callbacks.c',
'zathura/checked-integer-arithmetic.c',
'zathura/commands.c',
'zathura/completion.c',
'zathura/config.c',
'zathura/content-type.c',
'zathura/database.c',
'zathura/database-sqlite.c',
'zathura/dbus-interface.c',
'zathura/document.c',
'zathura/file-monitor.c',
'zathura/file-monitor-glib.c',
'zathura/file-monitor-noop.c',
'zathura/file-monitor-signal.c',
'zathura/jumplist.c',
'zathura/links.c',
'zathura/marks.c',
'zathura/page.c',
'zathura/page-widget.c',
'zathura/plugin.c',
'zathura/print.c',
'zathura/render.c',
'zathura/shortcuts.c',
'zathura/synctex.c',
'zathura/types.c',
'zathura/utils.c',
'zathura/zathura.c',
)
sources += zathura_resources
# header files to install
headers = files(
'zathura/document.h',
'zathura/links.h',
'zathura/macros.h',
'zathura/page.h',
'zathura/plugin-api.h',
'zathura/types.h',
)
headers += version_header
# zathura helper library
libzathura = static_library('zathura',
sources,
dependencies: build_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
libzathura_dep = declare_dependency(link_with: libzathura)
# zathura-sandbox executable
if seccomp.found() or landlock
sandbox_sources = files()
sandbox_defines = ['-DWITH_SANDBOX']
sandbox_dependencies = []
if seccomp.found()
sandbox_defines += '-DWITH_SECCOMP'
sandbox_dependencies += seccomp
sandbox_sources += files('zathura/seccomp-filters.c')
endif
if landlock
sandbox_defines += '-DWITH_LANDLOCK'
sandbox_sources += files('zathura/landlock.c')
endif
# zathura helper library
libzathura_sandbox = static_library('zathura-sandbox',
sources + sandbox_sources,
dependencies: build_dependencies + sandbox_dependencies,
include_directories: include_directories,
c_args: defines + flags + sandbox_defines
)
libzathura_sandbox_dep = declare_dependency(link_with: libzathura_sandbox)
zathura_sandbox = executable(
'zathura-sandbox',
files('zathura/main-sandbox.c') + sandbox_sources,
dependencies: build_dependencies + [libzathura_sandbox_dep] + sandbox_dependencies,
install: true,
include_directories: include_directories,
c_args: defines + sandbox_defines + flags,
export_dynamic: true,
win_subsystem: 'windows'
)
endif
# zathura executable
zathura = executable(
'zathura',
files('zathura/main.c'),
dependencies: build_dependencies + [libzathura_dep],
install: true,
include_directories: include_directories,
c_args: defines + flags,
export_dynamic: true,
win_subsystem: 'windows'
)
install_headers(headers, subdir: 'zathura')
# pkg-config file
pkg = import('pkgconfig')
pkg.generate(
name: 'zathura',
description: 'document viewer - plugin API',
url: 'https://pwmt.org/projects/zathura',
version: version,
requires: ['girara-gtk3', 'cairo'],
variables: [
'apiversion=@0@'.format(plugin_api_version),
'abiversion=@0@'.format(plugin_abi_version),
'plugindir=${libdir}/zathura'
]
)
zathura_dependency = declare_dependency(link_with: zathura, include_directories: include_directories)
subdir('doc')
subdir('tests')