summaryrefslogtreecommitdiffstats
path: root/meson.build
blob: 4eebcfdddad07577f1475663f4bd231dea9b3972 (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
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
project(
  'gnome-session', 'c',
  version: '43.0',
  license: 'GPL2+',
  default_options: 'buildtype=debugoptimized',
  meson_version: '>= 0.53.0'
)

prefix = get_option('prefix')
session_version = meson.project_version()
session_api_name = '@0@-@1@'.format(meson.project_name(), session_version.split('.')[0])

session_prefix = get_option('prefix')
session_bindir = join_paths(session_prefix, get_option('bindir'))
session_datadir = join_paths(session_prefix, get_option('datadir'))
session_libdir = join_paths(session_prefix, get_option('libdir'))
session_libexecdir = join_paths(session_prefix, get_option('libexecdir'))
session_localedir = join_paths(session_prefix, get_option('localedir'))
session_localstatedir = join_paths(session_prefix, get_option('localstatedir'))
session_mandir = join_paths(session_prefix, get_option('mandir'))
session_sbindir = join_paths(session_prefix, get_option('sbindir'))
session_sysconfdir = join_paths(session_prefix, get_option('sysconfdir'))

session_pkgdatadir = join_paths(session_datadir, meson.project_name())

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

cc = meson.get_compiler('c')

config_h = configuration_data()

# defines
set_defines = [
  # package
  ['PACKAGE', meson.project_name()],
  ['PACKAGE_VERSION', session_version],
  ['VERSION', session_version],
  # i18n
  ['GETTEXT_PACKAGE', session_api_name]
]

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

# compiler flags
common_flags = ['-DHAVE_CONFIG_H']

enable_deprecation_flags = get_option('deprecation_flags')
if enable_deprecation_flags
  common_flags += [
    '-DBONOBO_DISABLE_DEPRECATED',
    '-DBONOBO_DISABLE_SINGLE_INCLUDES',
    '-DBONOBO_UI_DISABLE_DEPRECATED',
    '-DBONOBO_UI_DISABLE_SINGLE_INCLUDES',
    '-DGNOME_DISABLE_DEPRECATED',
    '-DGNOME_DISABLE_SINGLE_INCLUDES',
    '-DLIBGLADE_DISABLE_DEPRECATED',
    '-DLIBGLADE_DISABLE_SINGLE_INCLUDES',
    '-DGNOME_VFS_DISABLE_DEPRECATED',
    '-DGNOME_VFS_DISABLE_SINGLE_INCLUDES',
    '-DWNCK_DISABLE_DEPRECATED',
    '-DWNCK_DISABLE_SINGLE_INCLUDES',
    '-DLIBSOUP_DISABLE_DEPRECATED',
    '-DLIBSOUP_DISABLE_SINGLE_INCLUDES'
  ]
endif

compiler_flags = []
if session_debug
  test_cflags = [
    '-Werror=format=2',
    '-Werror=implicit-function-declaration',
    '-Werror=init-self',
    '-Werror=missing-include-dirs',
    '-Werror=missing-prototypes',
    '-Werror=pointer-arith',
    '-Werror=return-type',
    '-Wnested-externs',
    '-Wstrict-prototypes'
  ]

  compiler_flags += cc.get_supported_arguments(test_cflags)
endif

add_project_arguments(common_flags + compiler_flags, language: 'c')

glib_req_version = '>= 2.46.0'

gio_dep = dependency('gio-2.0', version: glib_req_version)
glib_dep = dependency('glib-2.0', version: glib_req_version)
gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.0')
xtrans_dep = dependency('xtrans')
ice_dep = dependency('ice')
sm_dep = dependency('sm')
x11_dep = dependency('x11')

session_deps = [
  gio_dep,
  glib_dep,
  dependency('gnome-desktop-3.0', version: '>= 3.34.2'),
  dependency('json-glib-1.0', version: '>= 0.10')
]

session_bin_deps = session_deps + [
  xtrans_dep,
  ice_dep,
  sm_dep
]

# Check for session selector GTK+ UI
enable_session_selector = get_option('session_selector')

# Check for session tracking backend
session_tracking = 'null backend'

enable_systemd = get_option('systemd')
enable_systemd_session = get_option('systemd_session') != 'disable'
use_systemd_session = get_option('systemd_session') == 'default'
enable_systemd_journal = get_option('systemd_journal')
enable_consolekit = get_option('consolekit')
if enable_systemd or enable_consolekit
  session_bin_deps += dependency('gio-unix-2.0', version: glib_req_version)

  # Check for systemd
  if enable_systemd
    systemd_dep = dependency('systemd', version: '>= 242', required: true)
    systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir',
                                                             define_variable: ['prefix', prefix])

    libsystemd_dep = dependency('libsystemd', version: '>= 209', required: false)
    session_bin_deps += libsystemd_dep

    if not libsystemd_dep.found()
      libsystemd_login_dep = dependency('libsystemd-login', version: '>= 183', required: false)
      libsystemd_daemon_dep = dependency('libsystemd-daemon', required: false)
      libsystemd_journal_dep = dependency('libsystemd-journal', required: false)
      assert(libsystemd_login_dep.found() and libsystemd_daemon_dep.found() and libsystemd_journal_dep.found(),
             'Systemd support explicitly required, but systemd not found')

      session_bin_deps += [
        libsystemd_login_dep,
        libsystemd_daemon_dep,
        libsystemd_journal_dep
      ]
    endif

    session_tracking = 'systemd'
  endif

  # Check for ConsoleKit
  if enable_consolekit
    dbus_glib_dep = dependency('dbus-glib-1', version: '>= 0.76')
    assert(dbus_glib_dep.found(), 'ConsoleKit support explicitly required, but dbus-glib not found')

    session_bin_deps += dbus_glib_dep

    if enable_systemd
      session_tracking += ' (with fallback to ConsoleKit)'
    else
      session_tracking = 'ConsoleKit'
    endif
  endif
endif
if enable_systemd_session
  assert(enable_systemd, 'Systemd support must be enabled when using systemd session management')
endif
config_h.set('HAVE_SYSTEMD', enable_systemd)
config_h.set('ENABLE_SYSTEMD_SESSION', enable_systemd_session)
config_h.set('ENABLE_SYSTEMD_JOURNAL', enable_systemd_journal)
config_h.set('HAVE_CONSOLEKIT', enable_consolekit)
config_h.set10('USE_SYSTEMD_SESSION', use_systemd_session)

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

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

po_dir = join_paths(meson.source_root(), 'po')

top_inc = include_directories('.')

subdir('gnome-session')
subdir('tools')
subdir('data')

enable_docbook = get_option('docbook')
enable_man = get_option('man')
if enable_docbook or enable_man
  subdir('doc')
endif

subdir('po')

meson.add_install_script(
  'meson_post_install.py',
  session_datadir
)

output = '\n                gnome-session ' + session_version + '\n'
output += '                ====================\n\n'
output += '        prefix:                   ' + session_prefix + '\n'
output += '        exec_prefix:              ' + session_libexecdir + '\n'
output += '        libdir:                   ' + session_libdir + '\n'
output += '        bindir:                   ' + session_bindir + '\n'
output += '        sbindir:                  ' + session_sbindir + '\n'
output += '        sysconfdir:               ' + session_sysconfdir + '\n'
output += '        localstatedir:            ' + session_localstatedir + '\n'
output += '        datadir:                  ' + session_datadir + '\n'
output += '        source code location:     ' + meson.source_root() + '\n'
output += '        compiler:                 ' + cc.get_id() + '\n'
output += '        cflags:                   ' + ' '.join(compiler_flags) + '\n'
output += '        Debug mode:               ' + session_debug.to_string() + '\n'
output += '        Use *_DISABLE_DEPRECATED: ' + enable_deprecation_flags.to_string() + '\n\n'
output += '        Session tracking:         ' + session_tracking + ' \n'
output += '        Build Docbook:            ' + enable_docbook.to_string() + '\n'
output += '        Build manpages:           ' + enable_man.to_string()
message(output)