meson.build 15.4 KB
Newer Older
1 2
project(
  'gvfs', 'c',
Ondrej Holy's avatar
Ondrej Holy committed
3
  version: '1.40.1',
4
  license: 'LGPL2+',
5
  default_options: 'buildtype=debugoptimized',
6
  meson_version: '>= 0.49.0',
7 8 9 10 11 12
)

gvfs_name = meson.project_name()
gvfs_version = meson.project_version()

gvfs_prefix = get_option('prefix')
13 14 15 16 17
gvfs_datadir = get_option('datadir')
gvfs_libdir = get_option('libdir')
gvfs_libexecdir = get_option('libexecdir')
gvfs_localedir = get_option('localedir')
gvfs_mandir = get_option('mandir')
18

19 20
gvfs_pkgdatadir = gvfs_datadir / gvfs_name
gvfs_pkglibdir = gvfs_libdir / gvfs_name
21

22
gvfs_rpath = gvfs_prefix / gvfs_pkglibdir
23

24
gvfs_remote_volume_monitors_dir = gvfs_pkgdatadir / 'remote-volume-monitors'
25

26
gvfs_mounts_dir = gvfs_pkgdatadir / 'mounts'
27 28 29 30 31

gvfs_namespace = 'org.gtk.vfs'

gvfs_debug = get_option('buildtype').contains('debug')

32 33 34 35 36 37 38 39 40 41 42
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')

po_dir = meson.current_source_dir() / 'po'

top_inc = include_directories('.')

service_conf = configuration_data()
service_conf.set('libexecdir', gvfs_prefix / gvfs_libexecdir)

43 44 45 46 47 48 49 50 51 52
cc = meson.get_compiler('c')

config_h = configuration_data()

# defines
set_defines = [
  # package
  ['PACKAGE_STRING', '@0@ @1@'.format(gvfs_name, gvfs_version)],
  ['VERSION', gvfs_version],
  # i18n
53
  ['GETTEXT_PACKAGE', gvfs_name],
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
]

foreach define: set_defines
  config_h.set_quoted(define[0], define[1])
endforeach

# Globally define_GNU_SOURCE and therefore enable the GNU extensions
config_h.set('_GNU_SOURCE', true)

# Pull in the right libraries for various functions which might not be
# bundled into an exploded libc.
have_socketpair = cc.has_function('socketpair')
socket_deps = []

if not have_socketpair
  socket_dep = cc.find_library('socket', required: false)
  have_socketpair = socket_dep.found() and cc.has_function('socketpair', dependencies: socket_dep)

  if have_socketpair
    socket_deps += socket_dep
  endif
endif

config_h.set('HAVE_SOCKETPAIR', have_socketpair,
             description: 'Define if you have the socketpair function.')

util_dep = cc.find_library('util', required: false)
81
config_h.set('HAVE_UTIL_H', cc.has_header('util.h', dependencies: util_dep))
82

83
have_openpty = cc.has_function('openpty', dependencies: util_dep)
84 85 86 87 88 89 90

config_h.set('HAVE_OPENPTY', have_openpty,
             description: 'Define if you have the openpty function.')

config_h.set('HAVE_LOGIN_TTY', util_dep.found() and cc.has_function('login_tty', dependencies: util_dep),
             description: 'Whether login_tty is available')

91 92 93
# headers
check_headers = [
  # fs + pty
94
  'sys/param.h',
95
  # fs
96 97 98
  'sys/mount.h',
  'sys/statfs.h',
  'sys/statvfs.h',
99
  'sys/vfs.h',
100 101 102 103 104
]

statfs_includes = ''

foreach header: check_headers
105 106
  has_header = cc.has_header(header)
  config_h.set10('HAVE_' + header.underscorify().to_upper(), has_header)
107
  if has_header
108
    statfs_includes += '#include <@0@>\n'.format(header)
109 110 111
  endif
endforeach

112
# if statfs() takes 2 arguments (Posix) or 4 (Solaris)
113
statfs_code = statfs_includes + '''
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
  int main() {
    struct statfs st;
    @0@;
  };
'''

if cc.compiles(statfs_code.format('statfs("/", &st)'))
  config_h.set('STATFS_ARGS', 2)
elif cc.compiles(statfs_code.format('statfs("/", &st, sizeof (st), 0)'))
  config_h.set('STATFS_ARGS', 4)
else
  error('unable to determine number of arguments to statfs()')
endif

# pty
check_headers = [
130 131 132
  'stropts.h',
  'sys/un.h',
  'termios.h',
133
  'utmp.h',
134 135 136
]

foreach header: check_headers
137
  config_h.set('HAVE_' + header.underscorify().to_upper(), cc.has_header(header))
138 139 140 141 142
endforeach

# functions
check_functions = [
  # pty
143 144 145 146 147 148
  'getpt',
  'grantpt',
  'posix_openpt',
  'ptsname',
  'ptsname_r',
  'unlockpt',
149
  # fs
150
  'statfs',
151
  'statvfs',
152 153 154
]

foreach func: check_functions
155
  config_h.set('HAVE_' + func.to_upper(), cc.has_function(func))
156 157 158 159 160
endforeach

# symbols
check_symbols = [
  # i18n
161
  ['_NL_ADDRESS_LANG_TERM', 'langinfo.h'],
162
  ['_NL_ADDRESS_COUNTRY_AB3', 'langinfo.h'],
163 164 165
]

foreach symbol: check_symbols
166
  config_h.set('HAVE' + symbol[0], cc.has_header_symbol(symbol[1], symbol[0]))
167 168 169
endforeach

# fs, check major, minor and makedev functions
170
foreach name: ['mkdev', 'sysmacros']
171
  have_major = true
172 173 174
  header = 'sys/@0@.h'.format(name)
  foreach func: ['major', 'minor', 'makedev']
    have_major = have_major and cc.has_header_symbol(header, func)
175 176
  endforeach

177
  config_h.set10('MAJOR_IN_' + name.to_upper(), have_major)
178 179 180 181
endforeach

# types
check_types = [
182 183 184 185
  # type, fallback type
  ['gid_t', 'int'],
  ['pid_t', 'int'],
  ['size_t', 'unsigned int'],
186
  ['uid_t', 'int'],
187 188 189
]

foreach type: check_types
190 191
  if not cc.has_type(type[0], prefix: '#include<sys/types.h>')
    config_h.set(type[0], type[1])
192 193 194 195 196 197
  endif
endforeach

# members
check_members = [
  # define, typename, membername, prefix
198 199 200 201 202 203 204
  ['struct statfs', 'f_bavail', 'sys/statfs.h'],
  ['struct statvfs', 'f_basetype', 'sys/statvfs.h'],
  ['struct stat', 'st_atimensec', 'sys/stat.h'],
  ['struct stat', 'st_atim.tv_nsec', 'sys/stat.h'],
  ['struct stat', 'st_ctimensec', 'sys/stat.h'],
  ['struct stat', 'st_ctim.tv_nsec', 'sys/stat.h'],
  ['struct stat', 'st_mtimensec', 'sys/stat.h'],
205
  ['struct stat', 'st_mtim.tv_nsec', 'sys/stat.h'],
206 207 208
]

foreach member: check_members
209
  config_h.set('HAVE_@0@_@1@'.format(member[0].underscorify().to_upper(), member[1].underscorify().to_upper()), cc.has_members(member[0], member[1], prefix: '#include<@0@>'.format(member[2])))
210 211 212 213 214 215
endforeach

# compiler flags
common_flags = ['-DHAVE_CONFIG_H']

if gvfs_debug
216
  common_flags += cc.get_supported_arguments([
217 218 219 220 221
    '-Wcast-align',
    '-Wmissing-declarations',
    '-Wmissing-prototypes',
    '-Wnested-externs',
    '-Wno-sign-compare',
222
    '-Wno-strict-aliasing',
223
  ])
224 225 226 227
endif

add_project_arguments(common_flags, language: 'c')

228
version_script_ldflag = '-Wl,--version-script'
229
have_version_script = cc.has_link_argument('@0@,@1@'.format(version_script_ldflag, meson.current_source_dir() / 'client/symbol.map'))
230

231
gio_dep = dependency('gio-2.0')
232
gio_unix_dep = dependency('gio-unix-2.0')
233
glib_dep = dependency('glib-2.0', version: '>= 2.57.2')
234
gobject_dep = dependency('gobject-2.0')
235

236 237
config_h.set('HAVE_G_UNIX_MOUNT_GET_ROOT_PATH', cc.has_function('g_unix_mount_get_root_path', dependencies: gio_dep))

238 239 240 241 242
# *** Check for libXML ***
libxml_dep = dependency('libxml-2.0', required: false)
have_libxml = libxml_dep.found()

# *** Check for libgcrypt ***
243
enable_gcrypt = get_option('gcrypt')
244
if enable_gcrypt
245
  libgcrypt_dep = dependency('libgcrypt', version: '>= 1.2.2')
246 247
endif
config_h.set('HAVE_GCRYPT', enable_gcrypt)
248 249

# *** Check for dbus service dir ***
250 251
dbus_session_bus_services_dir = dependency('dbus-1').get_pkgconfig_variable(
  'session_bus_services_dir',
252
  define_variable: ['datadir', gvfs_prefix / gvfs_datadir],
253
)
254

255 256
dbus_service_in = files('dbus.service.in')

257 258 259
# *** Check for giomoduledir and schemasdir ***
gio_giomoduledir = gio_dep.get_pkgconfig_variable(
  'giomoduledir',
260
  define_variable: ['libdir', gvfs_prefix / gvfs_libdir],
261 262 263 264
)

gio_schemasdir = gio_dep.get_pkgconfig_variable(
  'schemasdir',
265 266
  define_variable: ['datadir', gvfs_prefix / gvfs_datadir],
  default: gvfs_prefix / gvfs_datadir / 'glib-2.0/schemas',
267
)
268

269
# *** Check for systemd options ***
270 271
systemd_systemduserunitdir = get_option('systemduserunitdir')
install_systemd_systemduserunitdir = (systemd_systemduserunitdir != 'no')
272

273 274
systemd_tmpfilesdir = get_option('tmpfilesdir')
install_systemd_tmpfilesdir = (systemd_tmpfilesdir != 'no')
275

276 277
if install_systemd_systemduserunitdir or install_systemd_tmpfilesdir
  if systemd_systemduserunitdir == '' or systemd_tmpfilesdir == ''
278 279
    systemd_dep = dependency('systemd', version: '>= 206', required: false)

280
    if install_systemd_systemduserunitdir and systemd_systemduserunitdir == ''
281
      assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit dir or disable it')
282
      systemd_systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
283 284
    endif

285
    if install_systemd_tmpfilesdir and systemd_tmpfilesdir == ''
286
      assert(systemd_dep.found(), 'systemd not found, if you use opentmpfiles please provide a valid systemd user unit dir or disable it')
287
      systemd_tmpfilesdir = systemd_dep.get_pkgconfig_variable('tmpfilesdir')
288
    endif
289 290 291 292
  endif
endif

# *** Check for gcr ***
293
enable_gcr = get_option('gcr')
294 295 296
if enable_gcr
  gcr_dep = dependency('gcr-base-3')
endif
297
config_h.set('HAVE_GCR', enable_gcr)
298 299

# *** Check if we should build with admin backend ***
300
enable_admin = get_option('admin')
301 302
if enable_admin
  libcap_dep = dependency('libcap')
303
  polkit_gobject_dep = dependency('polkit-gobject-1', version: '>= 0.114')
304 305 306
endif

# *** Check if we should build with http backend ***
307
enable_http = get_option('http')
308 309
if enable_http
  assert(have_libxml, 'http required but libxml-2.0 not found')
310
  libsoup_dep = dependency('libsoup-2.4', version: '>= 2.58.0')
311 312 313
endif

# *** Check if we should build with DNS-SD backend ***
314
enable_dnssd = get_option('dnssd')
315
if enable_dnssd
316 317 318
  avahi_client_dep = dependency('avahi-client', version: '>= 0.6')
  avahi_glib_dep = dependency('avahi-glib', version: '>= 0.6')
endif
319
config_h.set('HAVE_AVAHI', enable_dnssd)
320 321

# *** Check for gudev ***
322
enable_gudev = get_option('gudev')
323 324 325 326 327 328
if enable_gudev
  gudev_dep = dependency('gudev-1.0', version: '>= 147')
endif
config_h.set('HAVE_GUDEV', enable_gudev)

# *** Check for FUSE ***
329
enable_fuse = get_option('fuse')
330 331 332 333 334 335
if enable_fuse
  fuse_dep = dependency('fuse', version: '>= 2.8.0')
endif
config_h.set('HAVE_FUSE', enable_fuse)

# *** Check for udisks2 ***
336
enable_udisks2 = get_option('udisks2')
337
if enable_udisks2
338
  assert(enable_gudev, 'UDisks2 requested but gudev is required')
339 340 341 342
  udisks2_dep = dependency('udisks2', version: '>= 1.97')
endif

# *** Check for libsystemd-login ***
343
enable_logind = get_option('logind')
344 345 346 347 348 349 350
if enable_logind
  logind_dep = dependency('libsystemd', required: false)
  if not logind_dep.found()
    logind_dep = dependency('libelogind', version: '>= 229', required: false)
  endif

  assert(logind_dep.found(), 'logind requested but libsystemd nor libelogind not found')
351
endif
352
config_h.set('HAVE_LOGIND', enable_logind)
353 354

# *** Check if we should build with AFC backend ***
355
enable_afc = get_option('afc')
356 357 358 359 360 361
if enable_afc
  libimobiledevice_dep = dependency('libimobiledevice-1.0', version: '>= 1.2')
  libplist_dep = dependency('libplist', version: '>= 0.15')
endif

# *** Check if we should build with GOA volume monitor ***
362
enable_goa = get_option('goa')
363 364 365 366 367
if enable_goa
  goa_dep = dependency('goa-1.0', version: '>= 3.17.1')
endif

# *** Check for GNOME Keyring ***
368
enable_keyring = get_option('keyring')
369 370 371 372 373 374
if enable_keyring
  libsecret_dep = dependency('libsecret-unstable')
endif
config_h.set('HAVE_KEYRING', enable_keyring)

# *** Check if we should build with libbluray ***
375
enable_bluray = get_option('bluray')
376 377 378 379 380 381
if enable_bluray
  libbluray_dep = dependency('libbluray')
endif
config_h.set('HAVE_BLURAY', enable_bluray)

# *** Check if we should build with libusb-1.0 ***
382
enable_libusb = get_option('libusb')
383 384 385 386 387 388
if enable_libusb
  libusb_dep = dependency('libusb-1.0', version: '>= 1.0.21')
endif
config_h.set10('HAVE_LIBUSB', enable_libusb)

# *** Check for samba ***
389
enable_samba = get_option('smb')
390 391
if enable_samba
  smbclient_dep = dependency('smbclient')
392 393

  config_h.set('HAVE_SMBC_SETOPTIONPROTOCOLS', cc.has_function('smbc_setOptionProtocols', dependencies: smbclient_dep))
394 395 396
endif

# *** Check for libarchive ***
397
enable_archive = get_option('archive')
398 399 400 401 402
if enable_archive
  libarchive_dep = dependency('libarchive')
endif

# *** Check if we should build with CDDA backend ***
403
enable_cdda = get_option('cdda')
404 405 406 407 408 409 410 411
if enable_cdda
  assert(enable_gudev, 'CDDA backend requested but gudev is required')

  libcdio_paranoia_dep = dependency('libcdio_paranoia', version: '>= 0.78.2')
  config_h.set('HAVE_PARANOIA_NEW_INCLUDES', cc.has_header('cdio/paranoia/paranoia.h', dependencies: libcdio_paranoia_dep))
endif

# *** Check if we should build with Google backend ***
412
enable_google = get_option('google')
413 414 415 416
if enable_google
  assert(enable_goa, 'Google backend requested but GOA is required')

  libgdata_dep = dependency('libgdata', version: '>= 0.17.3')
417 418 419
  foreach version: ['0.17.7', '0.17.9']
    config_h.set10('HAVE_LIBGDATA_' + version.underscorify(), libgdata_dep.version().version_compare('>= ' + version))
  endforeach
420 421 422
endif

# *** Check for gphoto2 ***
423
enable_gphoto2 = get_option('gphoto2')
424 425 426 427 428 429 430 431 432 433
if enable_gphoto2
  assert(enable_gudev, 'gphoto2 requested but gudev is required')
  assert(host_machine.system().contains('linux') or host_machine.system().contains('bsd'),
         'Cannot build with gphoto2 support. Need OS tweaks in volume monitor.')

  libgphoto2_dep = dependency('libgphoto2', version: '>= 2.4.0')
  config_h.set('HAVE_GPHOTO25', libgphoto2_dep.version().version_compare('>= 2.5.0'))
endif

# *** Check for libmtp ***
434
enable_mtp = get_option('mtp')
435
if enable_mtp
436 437
  assert(enable_gudev, 'libmtp requested but gudev is required')

438 439
  libmtp_dep = dependency('libmtp', version: '>= 1.1.12')
  foreach version: ['1.1.15']
440 441
    config_h.set10('HAVE_LIBMTP_' + version.underscorify(), libmtp_dep.version().version_compare('>= ' + version))
  endforeach
442
endif
443
config_h.set('HAVE_LIBMTP', enable_mtp)
444 445

# *** AFP backend ***
446
enable_afp = get_option('afp')
447 448

# *** NFS backend ***
449
enable_nfs = get_option('nfs')
450 451 452 453
if enable_nfs
  libnfs_dep = dependency('libnfs', version: '>= 1.9.8')
endif

454 455 456 457 458 459 460
# *** SFTP backend ***
enable_sftp = get_option('sftp')
if enable_sftp
  ssh = find_program('ssh', required: false)
  assert(ssh.found(), 'SFTP backend requested but a ssh client is required')
endif

461
# *** Enable development utils ***
462 463
enable_devel_utils = get_option('devel_utils')
enable_installed_tests = get_option('installed_tests')
464 465 466 467 468 469 470

subdir('common')
subdir('metadata')
subdir('client')
subdir('daemon')
subdir('monitor')
subdir('po')
471

472 473
enable_man = get_option('man')
if enable_man
474 475 476 477 478 479 480
  subdir('man')
endif

subdir('test')

configure_file(
  output: 'config.h',
481
  configuration: config_h,
482 483 484 485
)

meson.add_install_script(
  'meson_post_install.py',
486 487
  gio_schemasdir,
  gio_giomoduledir,
488
)
489

490
output = gvfs_name + ' ' + gvfs_version + ' configuration summary:\n'
491
output += '\n'
492 493
output += '  systemduserunitdir: ' + systemd_systemduserunitdir + '\n'
output += '  tmpfilesdir: ' + systemd_tmpfilesdir + '\n'
494 495 496 497 498 499 500 501 502 503 504 505 506
output += '\n'
output += '  admin: ' + enable_admin.to_string() + '\n'
output += '  afc: ' + enable_afc.to_string() + '\n'
output += '  afp: ' + enable_afp.to_string() + '\n'
output += '  archive: ' + enable_archive.to_string() + '\n'
output += '  cdda: ' + enable_cdda.to_string() + '\n'
output += '  dnssd: ' + enable_dnssd.to_string() + '\n'
output += '  goa: ' + enable_goa.to_string() + '\n'
output += '  google: ' + enable_google.to_string() + '\n'
output += '  gphoto2: ' + enable_gphoto2.to_string() + '\n'
output += '  http: ' + enable_http.to_string() + '\n'
output += '  mtp: ' + enable_mtp.to_string() + '\n'
output += '  nfs: ' + enable_nfs.to_string() + '\n'
507
output += '  sftp: ' + enable_sftp.to_string() + '\n'
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
output += '  smb: ' + enable_samba.to_string() + '\n'
output += '  udisks2: ' + enable_udisks2.to_string() + '\n'
output += '\n'
output += '  bluray: ' + enable_bluray.to_string() + '\n'
output += '  fuse: ' + enable_fuse.to_string() + '\n'
output += '  gcr: ' + enable_gcr.to_string() + '\n'
output += '  gcrypt: ' + enable_gcrypt.to_string() + '\n'
output += '  gudev: ' + enable_gudev.to_string() + '\n'
output += '  keyring: ' + enable_keyring.to_string() + '\n'
output += '  logind: ' + enable_logind.to_string() + '\n'
output += '  libusb: ' + enable_libusb.to_string() + '\n'
output += '\n'
output += '  devel_utils: ' + enable_devel_utils.to_string() + '\n'
output += '  installed_tests: ' + enable_installed_tests.to_string() + '\n'
output += '  man: ' + enable_man.to_string() + '\n'
message(output)