summaryrefslogtreecommitdiff
path: root/meson.build
blob: e58e97e6834b747d17e4e0ea144ccf6861f6f396 (plain)
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
project('gcr', 'c',
  version: '3.90.0',
  meson_version: '>= 0.59',
  license: 'GPL2+',
)

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

# Versioning
gcr_api_version = '4'
gcr_version = meson.project_version()
gcr_soversion = '0.0.0'
gcr_version_array = gcr_version.split('.')
gcr_major_version = gcr_version_array[0].to_int()
gcr_minor_version = gcr_version_array[1].to_int()
gcr_micro_version = gcr_version_array[2].to_int()

gck_api_version = '2'
gck_version = '1.90.0'
gck_soversion = '0.0.0'
gck_version_array = gck_version.split('.')
gck_major_version = gck_version_array[0].to_int()
gck_minor_version = gck_version_array[1].to_int()
gck_micro_version = gck_version_array[2].to_int()

# Some variables
source_root = meson.current_source_dir()
build_root = meson.current_build_dir()
cc = meson.get_compiler('c')

gcr_prefix = get_option('prefix')
libexecbindir = gcr_prefix / get_option('libexecdir')
podir = source_root / 'po'

gck_basename = 'gck-@0@'.format(gck_api_version)
gcr_base_basename = 'gcr-base-@0@'.format(gcr_api_version)
gcr_basename = 'gcr-@0@'.format(gcr_api_version)
gcr_gtk3_basename = 'gcr-@0@-gtk3'.format(gcr_api_version)
gcr_gtk4_basename = 'gcr-@0@-gtk4'.format(gcr_api_version)

# Dependencies
min_glib_version = '2.44'
glib_dep = dependency('glib-2.0', version: '>=' + min_glib_version)
gmodule_dep = dependency('gmodule-no-export-2.0', version: '>=' + min_glib_version)
gthread_dep = dependency('gthread-2.0', version: '>=' + min_glib_version)
gobject_dep = dependency('gobject-2.0', version: '>=' + min_glib_version)
gio_dep = dependency('gio-2.0', version: '>=' + min_glib_version)
gio_unix_dep = dependency('gio-unix-2.0',version: '>=' + min_glib_version)
glib_deps = [ glib_dep, gmodule_dep, gthread_dep, gobject_dep, gio_dep, gio_unix_dep, ]
gpg_path = get_option('gpg_path')
if gpg_path == ''
  gpg_path = find_program('gpg2', 'gpg').path()
endif
libgcrypt_dep = dependency('libgcrypt', version: '>= 1')
p11kit_dep = dependency('p11-kit-1', version: '>= 0.19.0')
p11_system_config_modules = p11kit_dep.get_variable('p11_system_config_modules')
if p11_system_config_modules == ''
  error('Couldn\'t find location for pkcs11 module config')
endif
libsecret_dep = dependency('libsecret-1', version: '>= 0.20', required: get_option('ssh_agent'))
ssh_add_path = find_program('ssh-add', required: get_option('ssh_agent')).path()
ssh_agent_path = find_program('ssh-agent', required: get_option('ssh_agent')).path()

with_systemd = false
libsystemd_deps = []
libsystemd = dependency('libsystemd', required: get_option('systemd'))
systemd = dependency('systemd', required: get_option('systemd'))
if libsystemd.found() and systemd.found()
  systemduserunitdir = systemd.get_variable('systemduserunitdir',
    pkgconfig_define: [ 'prefix', get_option('prefix') ],
    default_value: 'lib' / 'systemd' / 'user',
  )
  libsystemd_deps += libsystemd
  with_systemd = true
endif

dbus_dep = dependency('dbus-1', required: false)
if dbus_dep.found()
  dbus_services_dir = dbus_dep.get_variable('session_bus_services_dir',
    pkgconfig_define: [ 'datadir', get_option('datadir') ],
  )
else
  dbus_services_dir = get_option('datadir') / 'dbus-1' / 'services'
endif

if get_option('gtk3')
  gtk3_min_version = '3.22'
  gtk3_dep = dependency('gtk+-3.0', version: '>=' + gtk3_min_version)
endif

if get_option('gtk4')
  gtk4_dep = dependency('gtk4')
endif

enable_gir = get_option('introspection')
enable_vapi = get_option('vapi')
if enable_vapi
  assert(enable_gir, 'vapi support was requested, but introspection support is mandatory.')
endif

# configuration
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('LIBEXECDIR', libexecbindir)
conf.set_quoted('LOCALEDIR', gcr_prefix / get_option('localedir'))
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set('HAVE_GETTEXT', true)
conf.set('HAVE_LOCALE_H', cc.has_header('locale.h'))
conf.set('HAVE_TIMEGM', cc.has_function('timegm'))
conf.set('HAVE_MLOCK', cc.has_function('mlock'))
conf.set_quoted('GPG_EXECUTABLE', gpg_path)
conf.set_quoted('LIBGCRYPT_VERSION', libgcrypt_dep.version())
conf.set_quoted('SSH_ADD_EXECUTABLE', ssh_add_path)
conf.set_quoted('SSH_AGENT_EXECUTABLE', ssh_agent_path)
conf.set10('WITH_SYSTEMD', with_systemd)
config_file = configure_file(
  output: 'config.h',
  configuration: conf,
)
config_h_dir = include_directories('.')

# subdirs
subdir('po')
subdir('egg')
subdir('gck')
subdir('gcr')
subdir('schema')
if get_option('gtk3')
  subdir('gcr-gtk3')
endif
if get_option('gtk4')
  subdir('gcr-gtk4')
endif
subdir('tools')
if get_option('gtk_doc')
  if not get_option('introspection')
    error('Can\'t generate docs without introspection enabled!')
  endif

  subdir('docs')
endif

# Post-install scripts
gnome.post_install(
  gtk_update_icon_cache: true,
  glib_compile_schemas: true,
  update_desktop_database: true,
)