meson.build 7.46 KB
Newer Older
1 2
project(
  'gnome-session', 'c',
Iain Lane's avatar
Iain Lane committed
3
  version: '3.34.2',
4
  license: 'GPL2+',
5
  default_options: 'buildtype=debugoptimized',
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
  meson_version: '>= 0.43.0'
)

session_version = meson.project_version()
version_array = session_version.split('.')
session_major_version = version_array[0].to_int()
session_minor_version = version_array[1].to_int()
session_micro_version = version_array[2].to_int()

session_api_version = '@0@.0'.format(session_major_version)
session_api_name = '@0@-@1@'.format(meson.project_name(), session_api_version)

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']

Iñigo Martínez's avatar
Iñigo Martínez committed
54
enable_deprecation_flags = get_option('deprecation_flags')
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
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'
  ]

88
  compiler_flags += cc.get_supported_arguments(test_cflags)
89 90 91 92 93 94 95 96 97
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.18.0')
Ray Strode's avatar
Ray Strode committed
98
xtrans_dep = dependency('xtrans')
99 100 101
ice_dep = dependency('ice')
sm_dep = dependency('sm')
x11_dep = dependency('x11')
102
gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.34.2')
103 104 105 106

session_deps = [
  gio_dep,
  glib_dep,
107
  gnome_desktop_dep,
108 109 110 111
  dependency('json-glib-1.0', version: '>= 0.10')
]

session_bin_deps = session_deps + [
Ray Strode's avatar
Ray Strode committed
112
  xtrans_dep,
113
  ice_dep,
114
  sm_dep
115 116
]

117
# Check for session selector GTK+ UI
Iñigo Martínez's avatar
Iñigo Martínez committed
118
enable_session_selector = get_option('session_selector')
119

120
# Check for session tracking backend
121 122
session_tracking = 'null backend'

Iñigo Martínez's avatar
Iñigo Martínez committed
123
enable_systemd = get_option('systemd')
124 125
enable_systemd_session = get_option('systemd_session') != 'disable'
use_systemd_session = get_option('systemd_session') == 'default'
126
enable_systemd_journal = get_option('systemd_journal')
Iñigo Martínez's avatar
Iñigo Martínez committed
127
enable_consolekit = get_option('consolekit')
Ray Strode's avatar
Ray Strode committed
128
if enable_systemd or enable_consolekit
129
  session_bin_deps += dependency('gio-unix-2.0', version: glib_req_version)
130

131
  # Check for systemd
132
  if enable_systemd
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    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
149

150 151
    session_tracking = 'systemd'
  endif
152

153 154 155 156
  # 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')
157

158
    session_bin_deps += dbus_glib_dep
159

Ray Strode's avatar
Ray Strode committed
160
    if enable_systemd
161 162 163
      session_tracking += ' (with fallback to ConsoleKit)'
    else
      session_tracking = 'ConsoleKit'
164 165 166
    endif
  endif
endif
167 168 169
if enable_systemd_session
  assert(enable_systemd, 'Systemd support must be enabled when using systemd session management')
endif
Ray Strode's avatar
Ray Strode committed
170
config_h.set('HAVE_SYSTEMD', enable_systemd)
171
config_h.set('ENABLE_SYSTEMD_SESSION', enable_systemd_session)
172
config_h.set('ENABLE_SYSTEMD_JOURNAL', enable_systemd_journal)
173
config_h.set('HAVE_CONSOLEKIT', enable_consolekit)
174
config_h.set10('USE_SYSTEMD_SESSION', use_systemd_session)
175 176
# Added in gnome-desktop 3.34.2/3.35.2
config_h.set('HAVE_GNOME_SYSTEMD', cc.has_header('libgnome-desktop/gnome-systemd.h', dependencies: gnome_desktop_dep))
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194

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')

Iñigo Martínez's avatar
Iñigo Martínez committed
195 196
enable_docbook = get_option('docbook')
enable_man = get_option('man')
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 223 224 225 226
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)