1project('xreader', 'c', 'cpp', version : '3.2.2') 2 3gnome = import('gnome') 4i18n = import('i18n') 5pkgconfig = import('pkgconfig') 6 7cc = meson.get_compiler('c') 8 9version = meson.project_version() 10version_list = version.split('.') 11major_version = version_list[0] 12minor_version = version_list[1] 13micro_version = version_list[2] 14 15api_version = '1.5' 16binary_version = '3.0.0' 17binary_major_version = binary_version.split('.')[0] 18 19xreader_conf = configuration_data() 20xreader_conf.set_quoted('VERSION', version) 21xreader_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) 22 23if get_option('enable_dbus') 24 xreader_conf.set('ENABLE_DBUS', '') 25endif 26 27# directories 28prefix = get_option('prefix') 29bindir = get_option('bindir') 30datadir = get_option('datadir') 31libdir = get_option('libdir') 32includedir = get_option('includedir') 33libexecdir = get_option('libexecdir') 34desktopdir = join_paths(datadir, 'applications') 35schema_dir = join_paths(datadir, 'glib-2.0', 'schemas') 36header_dir = join_paths(meson.project_name(), api_version) 37 38po_dir = join_paths(meson.source_root(), 'po') 39 40# dependencies 41cairo = dependency('cairo', version: '>= 1.14.0') 42gail = dependency('gail-3.0') 43gio = dependency('gio-2.0', version: '>= 2.36.0') 44glib_version = '2.36.0' 45glib = dependency('glib-2.0', version: '>= ' + glib_version) 46gmodule = dependency('gmodule-2.0') 47gtk_version = '3.14.0' 48gtk_api_version = '3.0' 49gtk = dependency('gtk+-' + gtk_api_version, version: '>= ' + gtk_version) 50ice = dependency('ice') 51sm = dependency('sm') 52X11 = dependency('x11') 53xapp = dependency('xapp', version: '>= 1.9.0') 54xml = dependency('libxml-2.0', version: '>= 2.5.0') 55zlib = dependency('zlib') 56libsecret = dependency('libsecret-1', version: '>= 0.5', required: get_option('keyring')) 57gtk_unix_print = dependency('gtk+-unix-print-3.0', version: '>= ' + gtk_version, required: get_option('gtk_unix_print')) 58 59enabled_backend_names = [] 60backend_subdirs = [] 61xreader_mime_types = '' 62 63if get_option('pdf') 64 poppler = dependency('poppler-glib') 65 backend_subdirs += 'pdf' 66 xreader_mime_types += 'application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;' 67endif 68if get_option('ps') 69 spectre = dependency('libspectre', version: '>= 0.2.0') 70 backend_subdirs += 'ps' 71 xreader_mime_types += 'application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;' 72endif 73if get_option('dvi') 74 kpathsea = dependency('kpathsea') 75 spectre = dependency('libspectre', version: '>= 0.2.0') 76 if get_option('t1lib') 77 t1lib = cc.find_library('t1', required: false) 78 t1_enabled = t1lib.found() 79 else 80 t1_enabled = false 81 endif 82 backend_subdirs += 'dvi' 83 xreader_mime_types += 'application/x-dvi;application/x-bzdvi;application/x-gzdvi;' 84endif 85if get_option('djvu') 86 djvu = dependency('ddjvuapi', version: '>= 3.5.17') 87 backend_subdirs += 'djvu' 88 xreader_mime_types += 'image/vnd.djvu;image/vnd.djvu+multipage;' 89endif 90if get_option('tiff') 91 tiff = dependency('libtiff-4') 92 backend_subdirs += 'tiff' 93 xreader_mime_types += 'image/tiff;' 94endif 95if get_option('pixbuf') 96 backend_subdirs += 'pixbuf' 97 xreader_mime_types += 'image/*;' 98 xreader_conf.set10('ENABLE_PIXBUF', true) 99endif 100if get_option('comics') 101 backend_subdirs += 'comics' 102 xreader_mime_types += 'application/x-cbr;application/x-cbz;application/x-cb7;application/x-cbt;application/vnd.comicbook+zip;application/vnd.comicbook-rar;' 103endif 104if get_option('xps') 105 xps = dependency('libgxps', version: '>= 0.2.1') 106 backend_subdirs += 'xps' 107 xreader_mime_types += 'application/oxps;application/vnd.ms-xpsdocument;' 108endif 109if get_option('epub') 110 webkit = dependency('webkit2gtk-4.0', version: '>= 2.4.3') 111 backend_subdirs += 'epub' 112 xreader_mime_types += 'application/epub+zip;' 113endif 114 115xreader_conf.set_quoted('SUPPORTED_MIMETYPES', xreader_mime_types) # This is generated by backends/meson.build 116 117# on some systems we need to find the math lib to make sure it builds 118math = cc.find_library('m', required: false) 119 120intltool_merge = find_program('intltool-merge') 121 122mathjax_directory = get_option('mathjax-directory') 123if mathjax_directory == '' 124 foreach dir: [ 125 # Arch Linux 126 '/usr/share/mathjax', 127 # Debian 128 '/usr/share/javascript/mathjax' 129 ] 130 if run_command('test', ['-f', join_paths(dir, 'MathJax.js')]).returncode() == 0 131 mathjax_directory = dir 132 # break would require meson_version >= 0.49.0 so just let the last one win 133 endif 134 endforeach 135endif 136 137if mathjax_directory != '' 138 xreader_conf.set_quoted('MATHJAX_DIRECTORY', mathjax_directory) 139elif get_option('epub') 140 error('"mathjax-directory" is undefined and could not be autodetected') 141endif 142 143# generate config.h 144config_h_file = configure_file( 145 output : 'config.h', 146 configuration : xreader_conf 147) 148 149config_h = declare_dependency( 150 sources: config_h_file 151) 152 153include_dirs = include_directories('.', 'libdocument', 'libview', 'libmisc') 154include_root = include_directories('.') 155 156xreader_document_header = [ 157 'xreader-document.h' 158] 159 160xreader_view_header = [ 161 'xreader-view.h' 162] 163 164# compiler flags 165c_args = [ 166 '-DDATADIR="@0@"'.format(join_paths(prefix, datadir)), 167 '-DLIBDIR="@0@"'.format(join_paths(prefix, libdir)), 168 '-DBINDIR="@0@"'.format(join_paths(prefix, bindir)), 169 '-DEV_BACKENDSDIR="@0@"'.format(join_paths(prefix, libdir, meson.project_name(), binary_major_version, 'backends')), 170 '-DXREADERDATADIR="@0@"'.format(join_paths(prefix, datadir, meson.project_name())), 171 '-Werror=implicit-function-declaration' 172] 173 174cpp_args = [ 175 '-DXREADER_LOCALE_DIR="@0@"'.format(join_paths(prefix, datadir, 'locale')), 176 '-DXREADER_COMPILATION', 177 '-DHAVE_CONFIG_H', 178] 179 180if get_option('enable_debug') 181 c_args += '-DEV_ENABLE_DEBUG' 182endif 183 184if get_option('epub') 185 c_args += '-DENABLE_EPUB' 186endif 187 188if not get_option('deprecated_warnings') 189 c_args += [ 190 '-Wno-deprecated-declarations', 191 '-Wno-deprecated', 192 '-Wno-declaration-after-statement', 193 ] 194endif 195 196add_global_arguments(c_args, language: 'c') 197add_global_arguments(cpp_args, language: ['c', 'cpp']) 198 199subdir('cut-n-paste') 200subdir('libdocument') 201subdir('libview') 202subdir('libmisc') 203# 'backend' needs to be run before 'data' because the mimetypes defined in 'backend' 204# are used to generate the .desktop file 205subdir('backend') 206subdir('data') 207if get_option('thumbnailer') 208 subdir('thumbnailer') 209endif 210if get_option('previewer') 211 subdir('previewer') 212endif 213subdir('shell') 214subdir('po') 215subdir('help') 216subdir('install-scripts') 217 218# The tests use an option that doesn't exist in meson before 0.46. 219# Since they aren't strictly necessary, we'll just skip them for earlier versions 220# rather than making 0.46 a hard requirement. This condition can be removed once we 221# no longer need to worry about building on 0.45 or earlier 222if meson.version().version_compare('>=0.46') 223 subdir('test') 224endif 225 226xreader_headers = [ 227 'xreader-document.h', 228 'xreader-view.h', 229] 230 231install_headers( 232 xreader_headers, 233 subdir: header_dir 234) 235 236pc_conf = configuration_data() 237pc_conf.set('prefix', prefix) 238pc_conf.set('exec_prefix', '${prefix}') 239pc_conf.set('libdir', join_paths('${prefix}', libdir)) 240pc_conf.set('includedir', join_paths('${prefix}', includedir)) 241pc_conf.set('EV_API_VERSION', api_version) 242pc_conf.set('EV_BINARY_VERSION', binary_major_version) 243pc_conf.set('VERSION', version) 244pc_conf.set('GLIB_REQUIRED', glib_version) 245pc_conf.set('GTK_API_VERSION', gtk_api_version) 246pc_conf.set('GTK_REQUIRED', gtk_version) 247 248configure_file( 249 input: 'xreader-document.pc.in', 250 output: 'xreader-document-@0@.pc'.format(api_version), 251 configuration: pc_conf, 252 install_dir: join_paths(libdir, 'pkgconfig') 253) 254 255configure_file( 256 input: 'xreader-view.pc.in', 257 output: 'xreader-view-@0@.pc'.format(api_version), 258 configuration: pc_conf, 259 install_dir: join_paths(libdir, 'pkgconfig') 260) 261 262message('prefix = @0@'.format(prefix)) 263message('bindir = @0@'.format(bindir)) 264message('datadir = @0@'.format(datadir)) 265message('libdir = @0@'.format(libdir)) 266message('includedir = @0@'.format(includedir)) 267message('libexecdir = @0@'.format(libexecdir)) 268message('desktopdir = @0@'.format(desktopdir)) 269message('schema_dir = @0@'.format(schema_dir)) 270message('ENABLE_DBUS = @0@'.format(get_option('enable_dbus'))) 271message('MathJax directory = @0@'.format(mathjax_directory)) 272message('Backends enabled:') 273foreach backend_name : backend_subdirs 274 message(' @0@'.format(backend_name)) 275endforeach 276