meson.build 15.6 KB
Newer Older
1 2 3
project('tracker', 'c', 'vala',
        version: '2.2.0-alpha2',
        meson_version: '>=0.47')
4 5 6 7 8 9

gnome = import('gnome')
i18n = import('i18n')
cc = meson.get_compiler('c')

# This is the X.Y used in -llibtracker-FOO-X.Y
10
tracker_api_version = '2.0'
11

12 13 14 15 16 17 18
tracker_version = meson.project_version().split('-')[0]
tracker_major_version = tracker_version.split('.')[0].to_int()
tracker_minor_version = tracker_version.split('.')[1].to_int()
tracker_micro_version = tracker_version.split('.')[2].to_int()
tracker_interface_age = 0
tracker_binary_age = 100 * tracker_minor_version + tracker_micro_version - tracker_interface_age

19
# This the .Z used in libtracker-sparql-2.0.so.Z
20 21
soversion = '0'
libversion = '@0@.@1@.@2@'.format(soversion, tracker_binary_age - tracker_interface_age, tracker_interface_age)
22

23 24 25
libdir = join_paths(get_option('prefix'), get_option('libdir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'))

26
glib_required = '2.46.0'
27 28 29 30 31 32

# 3.6.11 for sqlite_backup API
# 3.6.16 to fix test failures
# 3.6.17 for shared cache mode with virtual tables
# 3.7.0 for WAL
# 3.7.9 for FTS4 content= support
33 34 35
# 3.7.15 for sqlite3_errstr() support
# 3.8.3 for SQLITE_DETERMINISTIC
sqlite_required = '3.8.3'
36 37 38 39 40 41 42

dbus = dependency('dbus-1', version: '> 1.3.1')
gio = dependency('gio-2.0', version: '>' + glib_required)
gio_unix = dependency('gio-unix-2.0', version: '>' + glib_required)
glib = dependency('glib-2.0', version: '>' + glib_required)
gmodule = dependency('gmodule-2.0', version: '>' + glib_required)
gobject = dependency('gobject-2.0', version: '>' + glib_required)
43
gobject_introspection = dependency('gobject-introspection-1.0')
44 45 46 47 48 49 50
icu_i18n = dependency('icu-i18n', version: '> 4.8.1.1', required: false)
icu_uc = dependency('icu-uc', version: '> 4.8.1.1', required: false)
json_glib = dependency('json-glib-1.0', version: '>= 1.0', required: true)
libsoup = dependency('libsoup-2.4', version: '> 2.40', required: true)
libxml2 = dependency('libxml-2.0', version: '> 2.6')
sqlite = dependency('sqlite3', version: '>' + sqlite_required)

51
libmath = cc.find_library('m', required: false)
52 53 54 55 56 57 58 59 60

# FIXME: here we work around a quirk todo with Meson and Vala: the 'uuid'
# pkg-config component corresponds to 'libuuid.vapi', but Meson assumes that
# .vapi name always matches pkg-config name, and will add `--pkg uuid` to the
# Vala commandline. By finding 'uuid' using find_library() instead, we get
# a dependency object back that won't cause any `--pkg` arguments to be added
# to the Vala commandline, but still works as expected for C code.
uuid = cc.find_library('uuid')

61 62
add_project_arguments('-Wformat', '-Wformat-security', language: 'c')

63 64 65
# There are various gchar vs. unsigned char warnings that occur in extract
# modules, it's not worth adding casts everywhere so we disable the warning.
add_project_arguments('-Wno-pointer-sign', language: 'c')
66

67 68 69 70 71 72
add_project_arguments('-DTRACKER_COMPILATION',
                      '-DG_LOG_DOMAIN="Tracker"',
                      language: 'c')
add_project_arguments(['-D', 'TRACKER_COMPILATION'],
                      ['-D', 'G_LOG_DOMAIN="Tracker"'],
                      language: 'vala')
73 74 75

enable_fts = get_option('fts')

76 77
network_manager = dependency('libnm', required: get_option('network_manager'))
have_network_manager = network_manager.found()
78

79 80 81 82
##################################################################
# Check for libtracker-common, make sure libstemmer exists
##################################################################

83 84
libstemmer = cc.find_library('stemmer', required: get_option('stemmer'))
have_libstemmer = libstemmer.found()
85 86 87 88 89 90 91 92

##################################################################
# Check for tracker-fts, allow disabling FTS support
##################################################################

if enable_fts
  sqlite3_builtin_fts5_test = '''
    #include <sqlite3.h>
93 94 95 96 97 98 99 100 101 102 103

    int main (int argc, char *argv[]) {
      sqlite3 *db;
      int rc;
      rc = sqlite3_open(":memory:", &db);
      if (rc!=SQLITE_OK) return -1;
      rc = sqlite3_exec(db, "create table a(text)", 0, 0, 0);
      if (rc!=SQLITE_OK) return -1;
      rc = sqlite3_exec(db, "create virtual table t using fts5(content='a',text)", 0, 0, 0);
      if (rc!=SQLITE_OK) return -1;
    }
104 105
  '''

106 107 108
  result = cc.run(sqlite3_builtin_fts5_test,
    name: 'sqlite3 has builtin FTS5 module',
    dependencies: sqlite)
109

110 111
  if not result.compiled()
    error('Failed to compile SQLite FTS test.')
112
  endif
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

  if result.returncode() == 0
    message('Using sqlite3 builtin FTS module')
    sqlite3_has_builtin_fts5 = true
  else
    message('FTS support was enabled but SQLite doesn\'t have the FTS module built in')
    if sqlite.version().version_compare('>= 3.20.0')
      error('sqlite3 >= 3.20.0 must be compiled with --enable-fts5 in order to get FTS support.')
    else
      message('sqlite3 is older than version 3.20.0, using FTS module that is bundled with Tracker')
      sqlite3_has_builtin_fts5 = false
    endif
  endif

else
  sqlite3_has_builtin_fts5 = false
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
endif

##################################################################
# Check for libtracker-data and libtracker-fts: Unicode support
#
# By default, AUTO with this order of preference:
#  1)  libunistring
#  2)  libicu
##################################################################

have_libicu = false
unicode_library_name = ''

if icu_i18n.found() and icu_uc.found()
  have_libicu = true
endif

if have_libicu
  if get_option('unicode_support') == 'auto' or get_option('unicode_support') == 'icu'
    unicode_library = declare_dependency(
        dependencies: [icu_uc, icu_i18n]
    )
    unicode_library_name = 'icu'
  endif
elif get_option('unicode_support') == 'icu'
  error('libicu explicitly requested, but icu-i18n and icu-uc libraries were not found')
endif

if unicode_library_name == ''
158
  libunistring = cc.find_library('unistring', required: false)
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174

  if libunistring.found()
    unicode_library = libunistring
    unicode_library_name = 'unistring'
  elif get_option('unicode_support') == 'unistring'
    error('libunistring explicitly requested, but not found')
  else
    error('Neither libicu or libunistring were found for Unicode support.')
  endif
endif

####################################################################
# D-Bus service files
####################################################################

if get_option('dbus_services') == ''
175 176
  dbus_services_dir = dbus.get_pkgconfig_variable('session_bus_services_dir',
                                                  define_variable: [ 'datadir', datadir ])
177 178 179 180 181 182 183 184 185 186 187 188
else
  dbus_services_dir = get_option('dbus_services')
endif

####################################################################
# systemd user services
####################################################################

install_systemd_user_services = false
if get_option('systemd_user_services') == 'yes' or get_option('systemd_user_services') == 'auto'
  systemd = dependency('systemd', required: false)
  if systemd.found()
189 190 191 192
    # FIXME: this would ideally use the systemduserunitdir pkgconfig variable, but
    # it does not depend on variables we can override to install within prefix.
    install_systemd_user_services = true
    systemd_user_services_dir = join_paths(libdir, 'systemd', 'user')
193
  else
194 195
    install_systemd_user_services = false
    systemd_user_services_dir = '(not found)'
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
  endif
elif get_option('systemd_user_services') == 'no' or get_option('systemd_user_services') == ''
  install_systemd_user_services = false
  systemd_user_services_dir = '(disabled)'
else
  install_systemd_user_services = true
  systemd_user_services_dir = get_option('systemd_user_services')
endif

####################################################################
# bash-completion
####################################################################

install_bash_completion = false
if get_option('bash_completion') == 'yes' or get_option('bash_completion') == 'auto'
  bash_completion_package = dependency('bash-completion', required: false)
  if bash_completion_package.found()
213 214
    bash_completion_dir = bash_completion_package.get_pkgconfig_variable('completionsdir',
                                                                         define_variable:  [ 'prefix', get_option('prefix') ])
215
  else
216
    bash_completion_dir = join_paths(datadir, 'bash-completion', 'completions')
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
  endif
  install_bash_completion = true
elif get_option('bash_completion') == 'no' or get_option('bash_completion') == ''
  install_bash_completion = false
  bash_completion_dir = '(disabled)'
else
  install_bash_completion = true
  bash_completion_dir = get_option('bash_completion')
endif

conf = configuration_data()

# Config that goes in config.h
conf.set('DISABLE_JOURNAL', get_option('journal') == false)

conf.set10('HAVE_TRACKER_FTS', enable_fts)

conf.set('HAVE_BUILTIN_FTS', sqlite3_has_builtin_fts5)
235
conf.set('HAVE_LIBICU', unicode_library_name == 'icu')
236 237
conf.set('HAVE_LIBSTEMMER', have_libstemmer)
conf.set('HAVE_LIBUNISTRING', unicode_library_name == 'unistring')
238
conf.set('HAVE_NETWORK_MANAGER', have_network_manager)
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259

conf.set('HAVE_GETLINE', cc.has_function('getline', prefix : '#include <stdio.h>'))
conf.set('HAVE_POSIX_FADVISE', cc.has_function('posix_fadvise', prefix : '#include <fcntl.h>'))
conf.set('HAVE_STATVFS64', cc.has_header_symbol('sys/statvfs.h', 'statvfs64', args: '-D_LARGEFILE64_SOURCE'))
conf.set('HAVE_STRNLEN', cc.has_function('strnlen', prefix : '#include <string.h>'))

conf.set('LOCALEDIR', '"@0@/@1@"'.format(get_option('prefix'), get_option('localedir')))
conf.set('SHAREDIR', '"@0@/@1@"'.format(get_option('prefix'), get_option('datadir')))
conf.set('TRACKER_MINERS_DIR', '"@0@/@1@/tracker/miners"'.format(get_option('prefix'), get_option('datadir')))

conf.set('GETTEXT_PACKAGE', '"tracker"')
conf.set('PACKAGE_VERSION', '"@0@"'.format(meson.project_version()))
conf.set('TRACKER_VERSION', '"@0@"'.format(meson.project_version()))
conf.set('TRACKER_MAJOR_VERSION', tracker_major_version)
conf.set('TRACKER_MINOR_VERSION', tracker_minor_version)
conf.set('TRACKER_MICRO_VERSION', tracker_micro_version)
conf.set('TRACKER_INTERFACE_AGE', 0)
conf.set('TRACKER_BINARY_AGE', 100 * tracker_minor_version + tracker_micro_version)

# Config that goes in some other generated files (.desktop, .pc, etc)
conf.set('exec_prefix', get_option('prefix'))
260
conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
261
conf.set('datadir', datadir)
262
conf.set('datarootdir', join_paths(get_option('prefix'), get_option('datadir')))
263
conf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
264
conf.set('libdir', libdir)
265 266
conf.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir')))
conf.set('prefix', get_option('prefix'))
267
conf.set('TRACKER_API_VERSION', tracker_api_version)
268
conf.set('VERSION', meson.project_version())
269 270 271
conf.set('tracker_store', join_paths ('${libexecdir}', 'tracker-store'))
conf.set('ontologies_dir', join_paths ('${datadir}', 'tracker', 'ontologies'))
conf.set('domain_ontologies_dir', join_paths('${datadir}', 'tracker', 'domain-ontologies'))
272

273 274 275 276 277 278 279 280 281 282 283 284 285
# Configure functional tests to run completely from source tree.
conf.set('FUNCTIONAL_TESTS_ONTOLOGIES_DIR', join_paths(meson.current_source_dir(), 'tests', 'functional-tests', 'test-ontologies'))
conf.set('FUNCTIONAL_TESTS_TRACKER_STORE_PATH', join_paths(meson.current_build_dir(), 'src', 'tracker-store', 'tracker-store'))

# This is set in an awkward way for compatibility with Autoconf. Switch it
# to a normal boolean once we get rid of the Autotools build system. It's
# only used in tests/functional-tests/common/utils/configuration.py.in.
if get_option('journal')
    conf.set('DISABLE_JOURNAL_TRUE', 'true')
else
    conf.set('DISABLE_JOURNAL_TRUE', '')
endif

286 287 288 289
configure_file(input: 'config.h.meson.in',
               output: 'config.h',
               configuration: conf)

290 291 292 293 294 295 296 297 298
# Global compiler defines. We avoid add_global_arguments() as it breaks
# when we are included by another project as a subproject.
tracker_c_args = [
  # Needed for O_NOATIME, and probably other stuff.
  '-D_GNU_SOURCE',

  # Needed for statvfs64, and probably other stuff
  '-D_LARGEFILE64_SOURCE',
]
299 300 301 302

configinc = include_directories('./')
srcinc = include_directories('src/')

303 304 305 306
source_root = meson.current_source_dir()
build_root = meson.current_build_dir()
po_subdir = join_paths(source_root, 'po')

307 308
gsettings_schema_dir = join_paths(get_option('datadir'), 'glib-2.0', 'schemas')

309 310 311 312
tracker_internal_libs_dir = join_paths(get_option('prefix'), get_option('libdir'), 'tracker-' + tracker_api_version)

# NOTE: We don't use ${TRACKER_API_VERSION} because other content like
# the ontology is installed to the same location.
313
tracker_ontologies_dir = join_paths(get_option('prefix'), get_option('datadir'), 'tracker/ontologies')
314 315 316

vapi_dir = join_paths(get_option('prefix'), get_option('datadir'), 'vala', 'vapi')

317
glib_mkenums = find_program('glib-mkenums')
318
g_ir_compiler = find_program('g-ir-compiler', gobject_introspection.get_pkgconfig_variable('g_ir_compiler'))
319
g_ir_merge = find_program('g-ir-merge', join_paths(meson.current_source_dir(), 'utils', 'g-ir-merge', 'g-ir-merge'))
320

321 322 323 324
gir_dir = gobject_introspection.get_pkgconfig_variable('girdir',
                                                       define_variable:  [ 'datadir', datadir ])
typelib_dir = gobject_introspection.get_pkgconfig_variable('typelibdir',
                                                           define_variable:  [ 'libdir', libdir ])
325

326
subdir('src')
327
subdir('data')
328
subdir('docs')
329 330 331
subdir('examples')
subdir('utils')

332 333 334 335 336
test_c_args = tracker_c_args + [
    '-DTOP_BUILDDIR="@0@"'.format(build_root),
    '-DTOP_SRCDIR="@0@"'.format(source_root),
]

337 338 339 340
tracker_uninstalled_domain_rule = join_paths(meson.current_source_dir(), 'src', 'tracker-store', 'default.rule')
tracker_uninstalled_nepomuk_ontologies_dir = join_paths(meson.current_source_dir(), 'src', 'ontologies', 'nepomuk')
tracker_uninstalled_stop_words_dir = join_paths(meson.current_source_dir(), 'src', 'libtracker-common', 'stop-words')

341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
subdir('tests')

subdir('po')

# Make sure we're not using versions of SQLite which cause problems.
#
# Avoid versions:
sqlite_safe = true
if sqlite.version().version_compare('>= 3.7.10') and sqlite.version().version_compare('<= 3.7.13')
  # See https://mail.gnome.org/archives/tracker-list/2012-October/msg00028.html
  sqlite_safe = false
elif sqlite.version().version_compare('3.8.1')
  # See https://mail.gnome.org/archives/tracker-list/2013-November/msg00021.html
  sqlite_safe = false
elif sqlite.version().version_compare('3.8.4.2')
  # See https://mail.gnome.org/archives/tracker-list/2014-April/msg00001.html
  sqlite_safe = false
endif

summary = [
  '\nBuild Configuration:',
  '    Prefix:                                 ' + get_option('prefix'),
363
  '    Source code location:                   ' + meson.current_source_dir(),
364 365
  '    Compiler:                               ' + cc.get_id(),
  '\nFeature Support:',
366
  '    Support for network status detection:   ' + have_network_manager.to_string(),
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
  '    Unicode support library:                ' + unicode_library_name,
  '    Build with Journal support:             ' + get_option('journal').to_string(),
  '    Build with SQLite FTS support:          @0@ (built-in FTS: @1@)'.format(
     get_option('fts'), sqlite3_has_builtin_fts5),
  '    Build with Stemming support:            ' + have_libstemmer.to_string(),
  '    Bash completion support:                ' + bash_completion_dir,
]

message('\n'.join(summary))

if not sqlite_safe
  message('''WARNING:
        SQLite3 version @0@ is not safe. For detail
        3.7.10 - 3.7.13: https://mail.gnome.org/archives/tracker-list/2012-October/msg00028.html
        3.8.1:           https://mail.gnome.org/archives/tracker-list/2013-November/msg00021.html
        3.8.4.2:         https://mail.gnome.org/archives/tracker-list/2014-April/msg00001.html
  ''').format(sqlite.version())
endif