File: meson.build

package info (click to toggle)
papers 48.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,096 kB
  • sloc: ansic: 38,478; sh: 195; xml: 127; makefile: 117
file content (376 lines) | stat: -rw-r--r-- 12,066 bytes parent folder | download
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
project(
  'papers', ['c'],
  version: '48.3',
  license: 'GPL-2.0-or-later',
  meson_version: '>= 0.59.0',
  default_options: [
    'buildtype=debugoptimized',
  ]
)

if get_option('profile') == 'devel'
  profile = '.Devel'
  object_profile = '/Devel'
else
  profile = ''
  object_profile = ''
endif
app_id = 'org.gnome.Papers@0@'.format(profile)

pps_name = meson.project_name().to_lower()

pps_version = meson.project_version()
version_array = pps_version.split('.')
pps_major_version = version_array[0].to_int()
pps_minor_version = version_array[1]

pps_prefix = get_option('prefix')
pps_datadir = join_paths(pps_prefix, get_option('datadir'))
pps_includedir = join_paths(pps_prefix, get_option('includedir'))
pps_libdir = join_paths(pps_prefix, get_option('libdir'))
pps_localedir = join_paths(pps_prefix, get_option('localedir'))
pps_mandir = join_paths(pps_prefix, get_option('mandir'))

# Libtool versioning. The backend and view libraries have separate versions.
# Before making a release, the libtool version should be modified.
# The string is of the form C:R:A.
# - If interfaces have been changed or added, but binary compatibility has
#   been preserved, change to C+1:0:A+1
# - If binary compatibility has been broken (eg removed or changed interfaces)
#   change to C+1:0:0
# - If the interface is the same as the previous version, change to C:R+1:A

# Libtool version of the backend library
pps_document_current = 5
pps_document_revision = 0
pps_document_age = 0
pps_document_version = '@0@.@1@.@2@'.format(pps_document_current, pps_document_revision, pps_document_age)
pps_document_current_minus_age = pps_document_current - pps_document_age

# Libtool version of the view library
pps_view_current = 4
pps_view_revision = 0
pps_view_age = 0
pps_view_version = '@0@.@1@.@2@'.format(pps_view_current, pps_view_revision, pps_view_age)
pps_view_current_minus_age = pps_view_current - pps_view_age

pps_api_version = '4.0'

pps_include_subdir = join_paths(pps_name, pps_api_version)

# Backends directory
pps_backends_binary_version = pps_document_current
pps_backends_subdir = join_paths(pps_name, pps_backends_binary_version.to_string(), 'backends')
pps_backendsdir = join_paths(pps_libdir, pps_backends_subdir)

pps_namespace = 'org.gnome.Papers'

pps_code_prefix = 'Pps'

cc = meson.get_compiler('c')

config_h = configuration_data()
config_h.set10('_GNU_SOURCE', true)

# package
config_h.set_quoted('APP_ID', app_id)
config_h.set_quoted('PROFILE', profile)
config_h.set_quoted('OBJECT_PROFILE', object_profile)
config_h.set_quoted('PACKAGE_VERSION', pps_version)
config_h.set_quoted('VERSION', pps_version)
config_h.set_quoted('PPS_LOCALEDIR', pps_localedir)

# i18n
config_h.set_quoted('GETTEXT_PACKAGE', pps_name)

# Support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
langinfo_measurement_src = '''
  #include <langinfo.h>
  int main() {
    char c;
    c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
  };
'''
config_h.set('HAVE__NL_MEASUREMENT_MEASUREMENT', cc.compiles(langinfo_measurement_src, name: 'Support for nl_langinfo'),
             description: 'Define if _NL_MEASUREMENT_MEASUREMENT is available')

# compiler flags
common_flags = ['-DHAVE_CONFIG_H'] + cc.get_supported_arguments([
    '-Wnested-externs',
    '-Wstrict-prototypes',
    '-Wformat=2',
    '-Wmissing-include-dirs',
    '-Wmissing-prototypes',
    '-Wpointer-arith',
  ])

common_ldflags = []

libsysprof_capture_dep = dependency('sysprof-capture-4', required: get_option('sysprof'))

if libsysprof_capture_dep.found()
  common_flags += ['-DHAVE_SYSPROF']
endif

add_project_arguments(common_flags, language: 'c')
add_project_arguments('-DI_KNOW_THE_PAPERS_LIBS_ARE_UNSTABLE_AND_HAVE_TALKED_WITH_THE_AUTHORS',
                      language: 'c')

gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')

source_root = meson.current_source_dir()

data_dir = join_paths(source_root, 'data')
data_build_dir = join_paths(meson.project_build_root(), 'data')
po_dir = join_paths(source_root, 'po')

top_inc = include_directories('.')

glib_req_version = '>= 2.75.0'
gtk_req_version = '>= 4.17.1'
libaw_req_version = '>= 1.6'
exempi_req_version = '>= 2.0'

gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.40.0')
config_h.set_quoted('EXTRA_GDK_PIXBUF_LOADERS_DIR',
                    join_paths (pps_libdir, pps_name, 'gdk-pixbuf', gdk_pixbuf_dep.get_variable(pkgconfig: 'gdk_pixbuf_binary_version')))

gio_dep = dependency('gio-2.0', version: glib_req_version)
glib_dep = dependency('glib-2.0', version: glib_req_version)
gmodule_dep = dependency('gmodule-2.0')
gtk_dep = dependency(
  'gtk4',
  version: gtk_req_version,
  fallback: ['gtk', 'libgtk_dep'],
  default_options: [
    'werror=false',
    'introspection=disabled',
    'build-demos=false',
    'build-testsuite=false',
    'build-tests=false',
    'build-examples=false',
  ])
gthread_dep = dependency('gthread-2.0', version: glib_req_version)
libaw_dep = dependency(
  'libadwaita-1',
  version: libaw_req_version,
  fallback: ['adwaita', 'libadwaita_dep'],
  default_options: [
    'werror=false',
    'introspection=disabled',
    'vapi=false',
    'gtk_doc=false',
    'tests=false',
    'examples=false',
  ])
exempi_dep = dependency('exempi-2.0', version: exempi_req_version)

m_dep = cc.find_library('m')

cairo_dep = dependency('cairo', version: '>= 1.14.0')

# ZLIB support (required)
zlib_dep = cc.find_library('z', required: false)
assert(zlib_dep.found() and cc.has_function('inflate', dependencies: zlib_dep) and cc.has_function('crc32', dependencies: zlib_dep),
      'No sufficient zlib library found on your system')

# *** Nautilus property page build ***
enable_nautilus = get_option('nautilus')
if enable_nautilus
  libnautilus_extension_dep = dependency('libnautilus-extension-4', version: ['>= 43'])
  nautilus_extension_dir = libnautilus_extension_dep.get_variable(pkgconfig: 'extensiondir', pkgconfig_define: ['libdir', pps_libdir])
endif

# *** GNOME Keyring support ***
enable_keyring = get_option('keyring').enabled()

# GKT+ Unix Printing
gtk_unix_print_dep = dependency('gtk4-unix-print', version: gtk_req_version, required: get_option('gtk_unix_print'))
enable_gtk_unix_print = gtk_unix_print_dep.found()
config_h.set10('GTKUNIXPRINT_ENABLED', enable_gtk_unix_print)

# *** GObject Introspection ***
enable_user_doc = get_option('user_doc')
enable_docs = get_option('documentation')
gobject_introspection_dep = dependency(
  'gobject-introspection-1.0',
  version: '>= 1.0',
  required: get_option('introspection'),
)
if not gobject_introspection_dep.found()
  warning('Disable documentation due to introspection is disabled')
  enable_docs = false
endif

# *** Libspelling ***
libspelling_dep = dependency('libspelling-1', version: '>= 0.2', required: get_option('spell_check'))
enable_spellcheck = libspelling_dep.found()
config_h.set10('HAVE_LIBSPELLING', enable_spellcheck)

# *** Mime types list ***
mime_types_list = {
  'comics': [
    'application/vnd.comicbook-rar',
    'application/vnd.comicbook+zip',
    'application/x-cb7',
    'application/x-cbr',
    'application/x-cbt',
    'application/x-cbz',
    'application/x-ext-cb7',
    'application/x-ext-cbr',
    'application/x-ext-cbt',
    'application/x-ext-cbz',
  ],
  'djvu': [
    'application/x-ext-djv',
    'application/x-ext-djvu',
    'image/vnd.djvu',
    'image/vnd.djvu+multipage',
  ],
  'illustrator': [
    'application/illustrator'
  ],
  'pdf': [
    'application/pdf',
    'application/x-bzpdf',
    'application/x-ext-pdf',
    'application/x-gzpdf',
    'application/x-xzpdf',
  ],
  'tiff': [
    'image/tiff'
  ],
}

backends = {}
papers_mime_types = []

# *** Comic Book ***
libarchive_req_version = '>= 3.6.0'
libarchive_dep = dependency('libarchive', version: libarchive_req_version, required: get_option('comics'))
enable_comics = libarchive_dep.found()
if enable_comics
  backends += {'comics': mime_types_list.get('comics')}
  papers_mime_types += mime_types_list.get('comics')
elif get_option('comics').auto()
  warning('** Comics support is disabled since libarchive (version ' + libarchive_req_version + ') is needed')
endif

# *** DJVU ***
ddjvuapi_req_version = '>= 3.5.22'
ddjvuapi_dep = dependency('ddjvuapi', version: ddjvuapi_req_version, required: get_option('djvu'))
enable_djvu = ddjvuapi_dep.found()
if enable_djvu
  backends += {'djvu': mime_types_list.get('djvu')}
  papers_mime_types += mime_types_list.get('djvu')
elif get_option('djvu').auto()
  warning('Djvu support is disabled since a recent version of the djvulibre library was not found. You need at least djvulibre ' + ddjvuapi_req_version + ' which can be found on http://djvulibre.djvuzone.org')
endif

# *** PDF ***
poppler_req_version = '>= 25.01.0'
poppler_glib_dep = dependency('poppler-glib', version: poppler_req_version, required: get_option('pdf'))

enable_pdf = poppler_glib_dep.found()
if enable_pdf
  cairo_pdf_dep = dependency('cairo-pdf', required: false)
  cairo_ps_dep = dependency('cairo-ps', required: false)

  if cairo_pdf_dep.found()
    config_h.set('HAVE_CAIRO_PDF', true)
  endif

  if cairo_ps_dep.found()
    config_h.set('HAVE_CAIRO_PS', true)
  endif

  backends += {'pdf': mime_types_list.get('pdf') + mime_types_list.get('illustrator')}
  papers_mime_types += mime_types_list.get('pdf')
  papers_mime_types += mime_types_list.get('illustrator')
  if poppler_glib_dep.version().version_compare('>= 25.02.0')
    add_project_arguments ('-DHAVE_FREE_TEXT', language: 'c')
  endif
elif get_option('pdf').auto()
  warning('PDF support is disabled since poppler-glib version ' + poppler_req_version + ' not found')
endif

# *** TIFF ***
libtiff_dep = dependency('libtiff-4', required: get_option('tiff'))
enable_tiff = libtiff_dep.found()
if enable_tiff
  backends += {'tiff': mime_types_list.get('tiff')}
  papers_mime_types += mime_types_list.get('tiff')
elif get_option('tiff').auto()
  warning('Tiff support is disabled since tiff library version 4.0 or newer not found')
endif

mime_types_conf = configuration_data()
mime_types_conf.set('PAPERS_MIME_TYPES', ';'.join(papers_mime_types))
mime_types_conf.set('PACKAGE_ICON_NAME', app_id)

subdir('libdocument')
subdir('libview')
subdir('nautilus')

subdir('rust')

# Print Previewer
enable_previewer = get_option('previewer')
if enable_previewer
  subdir('previewer')
endif

subdir('data')

# *** Papers ***
enable_viewer = get_option('viewer')
if enable_viewer
  subdir('shell')
else
  rust_target = 'n/a'
endif

subdir('po')
subdir('help')

# *** Thumbnailer ***
enable_thumbnailer = get_option('thumbnailer')
if enable_thumbnailer
  subdir('thumbnailer')
endif

configure_file(
  output: 'config.h',
  configuration: config_h,
)

gnome.post_install(
  glib_compile_schemas: true,
  gtk_update_icon_cache: true,
  update_desktop_database: true,
)

summary({'Build type.................': get_option('buildtype'),
         'Application ID.............': app_id,
         'Rust build mode............': rust_target,
        }, section: 'General', bool_yn: true)
summary({'Viewer.....................': enable_viewer,
         'Previewer..................': enable_previewer,
         'Thumbnailer................': enable_thumbnailer,
         'Nautilus extension.........': enable_nautilus,
        }, section: 'Frontends', bool_yn: true)
summary({'Comics.....................': enable_comics,
         'DJVU.......................': enable_djvu,
         'PDF........................': enable_pdf,
         'TIFF.......................': enable_tiff,
        }, section: 'Backends', bool_yn: true)
summary({'tests......................': get_option('tests'),
         'Developer documentation....': enable_docs,
         'User documentation.........': enable_user_doc,
         'GObject introspection......': gobject_introspection_dep.found(),
         'Keyring integration........': enable_keyring,
         'GTK+ Unix print ...........': enable_gtk_unix_print,
         'Spell checker .............': enable_spellcheck,
        }, section: 'Features', bool_yn: true)