This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
forked from fwupd/fwupd
-
Notifications
You must be signed in to change notification settings - Fork 3
/
meson.build
316 lines (284 loc) · 8.46 KB
/
meson.build
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
project('fwupd', 'c',
version : '1.0.6',
license : 'LGPL-2.1+',
meson_version : '>=0.37.0',
default_options : ['warning_level=2', 'c_std=c99'],
)
fwupd_version = meson.project_version()
varr = fwupd_version.split('.')
fwupd_major_version = varr[0]
fwupd_minor_version = varr[1]
fwupd_micro_version = varr[2]
conf = configuration_data()
conf.set('FWUPD_MAJOR_VERSION', fwupd_major_version)
conf.set('FWUPD_MINOR_VERSION', fwupd_minor_version)
conf.set('FWUPD_MICRO_VERSION', fwupd_micro_version)
conf.set_quoted('PACKAGE_VERSION', fwupd_version)
archiver = find_program('git', required : false)
if archiver.found()
result = run_command('git', 'describe')
if result.returncode() == 0
describe = result.stdout().strip()
conf.set_quoted('FWUPD_GIT_DESCRIBE', describe)
endif
endif
# libtool versioning - this applies to libfwupd
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#
# - If interfaces have been changed or added, but binary compatibility
# has been preserved, change:
# CURRENT += 1
# REVISION = 0
# AGE += 1
# - If binary compatibility has been broken (eg removed or changed
# interfaces), change:
# CURRENT += 1
# REVISION = 0
# AGE = 0
# - If the interface is the same as the previous version, but bugs are
# fixed, change:
# REVISION += 1
lt_current = '2'
lt_revision = '0'
lt_age = '0'
lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
# get suported warning flags
test_args = [
'-fstack-protector-strong',
'-Waggregate-return',
'-Wunused',
'-Warray-bounds',
'-Wcast-align',
'-Wclobbered',
'-Wdeclaration-after-statement',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wempty-body',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wformat-signedness',
'-Wignored-qualifiers',
'-Wimplicit-function-declaration',
'-Wincompatible-pointer-types-discards-qualifiers',
'-Winit-self',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-parameter-type',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-error=cpp',
'-Wno-discarded-qualifiers',
'-Wno-missing-field-initializers',
'-Wno-strict-aliasing',
'-Wno-suggest-attribute=format',
'-Wno-unused-parameter',
'-Wnull-dereference',
'-Wold-style-definition',
'-Woverride-init',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wreturn-type',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wtype-limits',
'-Wundef',
'-Wuninitialized',
'-Wunused-but-set-variable',
'-Wunused-variable',
'-Wwrite-strings'
]
cc = meson.get_compiler('c')
foreach arg: test_args
if cc.has_argument(arg)
add_project_arguments(arg, language : 'c')
endif
endforeach
# enable full RELRO where possible
# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
global_link_args = []
test_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
]
foreach arg: test_link_args
if cc.has_argument(arg)
global_link_args += arg
endif
endforeach
add_global_link_arguments(
global_link_args,
language: 'c'
)
# Needed for realpath(), syscall(), cfmakeraw(), etc.
add_project_arguments('-D_DEFAULT_SOURCE', language : 'c')
# do not use deprecated symbols or defines internally
add_project_arguments('-DFWUPD_DISABLE_DEPRECATED', language : 'c')
gio = dependency('gio-2.0', version : '>= 2.45.8')
gmodule = dependency('gmodule-2.0')
giounix = dependency('gio-unix-2.0', version : '>= 2.45.8')
polkit = dependency('polkit-gobject-1', version : '>= 0.103')
if polkit.version().version_compare('>= 0.114')
conf.set('HAVE_POLKIT_0_114', '1')
endif
gudev = dependency('gudev-1.0')
if gudev.version().version_compare('>= 232')
conf.set('HAVE_GUDEV_232', '1')
endif
appstream_glib = dependency('appstream-glib', version : '>= 0.6.13')
gusb = dependency('gusb', version : '>= 0.2.9')
sqlite = dependency('sqlite3')
libarchive = dependency('libarchive')
libjsonglib = dependency('json-glib-1.0', version : '>= 1.1.1')
if meson.version().version_compare('>0.41.0')
valgrind = dependency('valgrind', required: false)
else
valgrind = dependency('valgrindXXX', required: false)
endif
soup = dependency('libsoup-2.4', version : '>= 2.51.92')
if get_option('pkcs7')
gnutls = dependency('gnutls')
conf.set('ENABLE_PKCS7', '1')
endif
if get_option('gpg')
gpgme = cc.find_library('gpgme')
gpgerror = cc.find_library('gpg-error')
conf.set('ENABLE_GPG', '1')
endif
libm = cc.find_library('m', required: false)
udev = dependency('udev')
uuid = dependency('uuid')
libgcab = dependency('libgcab-1.0')
if libgcab.version().version_compare('>= 0.8')
conf.set('HAVE_GCAB_0_8', '1')
endif
if libgcab.version().version_compare('>= 1.0')
conf.set('HAVE_GCAB_1_0', '1')
endif
if get_option('plugin_uefi_labels')
cairo = dependency('cairo')
fontconfig = cc.find_library('fontconfig')
freetype = cc.find_library('freetype')
r = run_command('po/test-deps')
if r.returncode() != 0
error(r.stdout())
endif
endif
if valgrind.found()
conf.set('HAVE_VALGRIND', '1')
endif
if get_option('plugin_colorhug')
colorhug = dependency('colorhug', version : '>= 1.2.12')
conf.set('HAVE_COLORHUG', '1')
endif
if get_option('plugin_altos')
libelf = dependency('libelf')
endif
if get_option('plugin_uefi')
fwup = dependency('fwup', version : '>= 5')
if fwup.version().version_compare('>= 10')
conf.set('HAVE_FWUP_GET_BGRT_INFO', '1')
conf.set('HAVE_FWUP_CUSTOM_ESP', '1')
endif
efivar = dependency('efivar')
conf.set_quoted('EFIVAR_LIBRARY_VERSION', efivar.version())
conf.set_quoted('LIBFWUP_LIBRARY_VERSION', fwup.version())
endif
if get_option('plugin_dell')
libsmbios_c = dependency('libsmbios_c', version : '>= 2.3.0')
efivar = dependency('efivar')
fwup = dependency('fwup', version : '>= 5')
conf.set('HAVE_DELL', '1')
endif
if get_option('plugin_synaptics')
conf.set('HAVE_SYNAPTICS', '1')
endif
if get_option('plugin_thunderbolt')
umockdev = dependency('umockdev-1.0', required: false)
conf.set('HAVE_THUNDERBOLT', '1')
endif
if get_option('systemd')
systemd = dependency('systemd', version : '>= 231')
conf.set('HAVE_SYSTEMD' , '1')
endif
if get_option('consolekit')
conf.set('HAVE_CONSOLEKIT' , '1')
endif
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
libdir = join_paths(prefix, get_option('libdir'))
datadir = join_paths(prefix, get_option('datadir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
sysconfdir = join_paths(prefix, get_option('sysconfdir'))
localstatedir = join_paths(prefix, get_option('localstatedir'))
mandir = join_paths(prefix, get_option('mandir'))
localedir = join_paths(prefix, get_option('localedir'))
systemdunitdir = get_option('systemdunitdir')
if systemdunitdir == '' and get_option('systemd')
systemdunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
endif
udevdir = get_option('udevdir')
if udevdir == ''
udevdir = udev.get_pkgconfig_variable('udevdir')
endif
gnome = import('gnome')
i18n = import('i18n')
plugin_dir = join_paths(libdir, 'fwupd-plugins-3')
conf.set_quoted('BINDIR', bindir)
conf.set_quoted('LIBEXECDIR', libexecdir)
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('LOCALEDIR', localedir)
configure_file(
output : 'config.h',
configuration : conf
)
default_sysconfdir = get_option('sysconfdir')
if default_sysconfdir == 'etc'
message('sysconfdir of etc makes no sense, using /etc')
default_sysconfdir = '/etc'
endif
plugin_deps = []
plugin_deps += appstream_glib
plugin_deps += gio
plugin_deps += giounix
plugin_deps += gmodule
plugin_deps += gusb
plugin_deps += soup
plugin_deps += libarchive
subdir('data')
subdir('docs')
subdir('libfwupd')
subdir('po')
subdir('policy')
subdir('src')
subdir('plugins')
subdir('contrib')
if meson.version().version_compare('<0.41.0')
if archiver.found()
run_target('dist',
# git config tar.tar.xz.command "xz -c"
command: [
'git', 'archive',
'--prefix=' + meson.project_name() + '-' + meson.project_version() + '/',
'HEAD',
'--format=tar.xz',
'--output',
meson.project_name() + '-' + meson.project_version() + '.tar.xz'
]
)
else
message('git not found, you will not be able to run `ninja dist`')
endif
endif
if get_option('systemd')
meson.add_install_script('meson_post_install.sh', systemdunitdir, localstatedir)
endif