summaryrefslogtreecommitdiff
path: root/meson.build
blob: 98587c6ecdcc5dc8d351c3170208a1fd0f3965d9 (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
project('PackageKit', 'c',
  version : '1.2.5',
  license : 'LGPL-2.1+',
  meson_version : '>=0.50',
  default_options : ['warning_level=2', 'c_std=c99'],
)

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

glib_dep = dependency('glib-2.0', version: '>=2.62')
gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.16.1')
gmodule_dep = dependency('gmodule-2.0', version: '>=2.16.1')
sqlite3_dep = dependency('sqlite3')
polkit_dep = dependency('polkit-gobject-1', version: '>=0.98')
if polkit_dep.version().version_compare('>=0.114')
  add_project_arguments ('-DHAVE_POLKIT_0_114=1', language: 'c')
endif

libsystemd = []
if get_option('systemd')
  libsystemd = dependency('libsystemd', version: '>=213')
  systemd_system_unit_dir = get_option('systemdsystemunitdir')
  systemd_user_unit_dir = get_option('systemduserunitdir')
  if systemd_system_unit_dir == '' or systemd_user_unit_dir == ''
    systemd = dependency('systemd')
  endif
  if systemd_system_unit_dir == ''
    systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
  endif
  if systemd_user_unit_dir == ''
    systemd_user_unit_dir = systemd.get_pkgconfig_variable('systemduserunitdir')
  endif

  add_project_arguments ('-DHAVE_SYSTEMD_SD_DAEMON_H=1', language: 'c')
  add_project_arguments ('-DHAVE_SYSTEMD_SD_LOGIN_H=1', language: 'c')
else
  if get_option('offline_update')
    error('Offline updates requires Systemd, use -Dsystemd=true to enable it or -Doffline_update=false to disable offline updates')
  endif
endif

elogind = []
if get_option('elogind')
  elogind = dependency('elogind', version: '>=229.4')
  add_project_arguments ('-DHAVE_SYSTEMD_SD_LOGIN_H=1', language: 'c')
endif

if get_option('local_checkout')
  add_project_arguments ('-DPK_BUILD_LOCAL=1', language: 'c')
endif

if get_option('daemon_tests')
  add_project_arguments ('-DPK_ENABLE_DAEMON_TESTS=1', language: 'c')
endif

if dependency('ply-boot-client', version: '>=0.9.5', required: false).found()
  add_project_arguments ('-DPLYMOUTH_0_9_5=1', language: 'c')
endif

# Ensure functions like realpath(3) and other "default" functions are available
add_project_arguments ('-D_DEFAULT_SOURCE', language: 'c')

# Avoid g_simple_async_result deprecation warnings in glib 2.46+
add_project_arguments ('-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44', language: 'c')

# allow the daemon to include library files directly
add_project_arguments ('-DPK_COMPILATION', language: 'c')

conf = configuration_data()
conf.set_quoted('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
conf.set_quoted('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
conf.set_quoted('SYSCONFDIR', get_option('sysconfdir'))

conf.set_quoted('PROJECT_NAME', meson.project_name())
conf.set_quoted('PROJECT_VERSION', meson.project_version())

cc = meson.get_compiler('c')
if cc.has_function('setpriority')
  conf.set('HAVE_SETPRIORITY', '1')
endif
if cc.has_function('clearenv')
  conf.set('HAVE_CLEARENV', '1')
endif
if cc.has_header('unistd.h')
  conf.set('HAVE_UNISTD_H', '1')
endif

config_header = configure_file(
  output: 'config.h',
  configuration: conf,
)

config_dep = declare_dependency(
  sources: config_header,
  include_directories: include_directories('.')
)

pk_db_dir = join_paths(get_option('localstatedir'), 'lib', 'PackageKit')
local_state_dir = get_option('localstatedir')
test_data_dir = join_paths(meson.source_root(), 'data', 'tests')
package_data_dir = get_option('datadir')
package_locale_dir = join_paths(get_option('prefix'), get_option('datadir'), 'locale')
pk_plugin_dir = join_paths(get_option('prefix'), get_option('libdir'), 'packagekit-backend')

# work both in C and C++
add_project_arguments(
  '-Wall',
  '-Wcast-align', '-Wno-uninitialized',
  '-Wmissing-declarations',
  '-Wredundant-decls',
  '-Wpointer-arith',
  '-Wcast-align',
  '-Wwrite-strings',
  '-Winit-self',
  '-Wreturn-type',
  '-Wformat-nonliteral',
  '-Wformat-security',
  '-Wmissing-include-dirs',
  '-Wmissing-format-attribute',
  '-Wclobbered',
  '-Wempty-body',
  '-Wignored-qualifiers',
  '-Wsign-compare',
  '-Wtype-limits',
  '-Wuninitialized',
  '-Wno-unused-parameter',
  language: ['c', 'cpp']
)

# work only in C
add_project_arguments(
  '-Waggregate-return',
  '-Wdeclaration-after-statement',
  '-Wshadow',
  '-Wno-strict-aliasing',
  '-Winline',
  '-Wmissing-parameter-type',
  '-Woverride-init',
  language: 'c'
)

subdir('po')
subdir('policy')
subdir('etc')
subdir('data')
subdir('lib')
subdir('src')
subdir('client')
subdir('backends')
subdir('contrib')
subdir('docs')