forked from rpminspect/rpminspect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
394 lines (326 loc) · 12.7 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
project('rpminspect',
'c',
version : '2.0',
default_options : [
'warning_level=3',
'werror=true',
'buildtype=debugoptimized'
],
license : 'GPL-3.0-or-later AND LGPL-3.0-or-later AND Apache-2.0 AND MIT')
fs = import('fs')
cc = meson.get_compiler('c')
# Define the program version
add_global_arguments('-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), language : 'c')
# Always add _GNU_SOURCE because some other libraries rely on this macro
add_global_arguments('-D_GNU_SOURCE', language : 'c')
# Define this to get around a problematic json_object.h macro
add_global_arguments('-D__STRICT_ANSI__', language : 'c')
# On NetBSD we need to build without pedantic errors because of some
# things in pkgsrc
if build_machine.system() == 'netbsd'
add_global_arguments('-Wno-pedantic', language : 'c')
endif
# Vendor data directory
add_global_arguments('-DVENDOR_DATA_DIR="@0@"'.format(get_option('vendor_data_dir')), language : 'c')
# Library search dirs
search_dirs = [ '/usr/local/lib', '/usr/pkg/lib', '/usr/lib64', '/usr/lib' ]
# Header search dirs
if build_machine.system() == 'netbsd'
include_dirs = [ '/usr/local/include', '/usr/pkg/include', '/usr/include' ]
else
include_dirs = [ '/usr/local/include', '/usr/include' ]
endif
existing_include_dirs = []
foreach dir : include_dirs
if fs.is_dir(dir)
existing_include_dirs += dir
endif
endforeach
inc = include_directories(existing_include_dirs)
# See if we have reallocarray in libc
if cc.has_function('reallocarray')
add_global_arguments('-D_HAVE_REALLOCARRAY', language : 'c')
endif
# On FreeBSD, figure out where strverscmp() is
libiberty = cc.find_library('iberty',
dirs : search_dirs,
required : false,
static : true)
if build_machine.system() == 'freebsd'
# FreeBSD >= 14.x has it in libc
if cc.has_function('strverscmp')
add_global_arguments('-D__BSD_VISIBLE', language : 'c')
else
# check GNU libiberty
if not libiberty.found()
error('*** unable to find libiberty.a for strverscmp()')
endif
add_global_arguments('-D_FREEBSD_LIBIBERTY', language : 'c')
endif
endif
# Translations
if find_program('xgettext', required : get_option('nls')).found()
if build_machine.system() == 'freebsd'
intl = cc.find_library('intl',
dirs : search_dirs,
required : true,
static : false)
if not intl.found() or not cc.has_function('libintl_gettext', dependencies : [ intl ])
error('*** unable to find libintl (with symbol libintl_gettext())')
endif
endif
add_global_arguments('-DGETTEXT_DOMAIN="' + meson.project_name() + '"', language : 'c')
subdir('po')
endif
# Dependencies that use pkg-config
jsonc = dependency('json-c', required : true)
libxml = dependency('libxml-2.0', required : true)
libcurl = dependency('libcurl', required : true)
zlib = dependency('zlib', required : true)
yaml = dependency('yaml-0.1', required : true)
clamav = dependency('libclamav', required : true)
icu_uc = dependency('icu-uc', required : true)
icu_io = dependency('icu-io', required : true)
# Check for xmlSetGenericErrorFunc in newer releases of libxml
if cc.has_function('xmlSetGenericErrorFunc', dependencies : [ libxml ])
add_project_arguments('-D_HAVE_XMLSETGENERICERRORFUNC', language : 'c')
endif
# Check for newer CURLcode in libcurl
curlinfo_src = '''
#include <curl/curl.h>
int main(void)
{
CURLcode info = CURLINFO_CONTENT_LENGTH_DOWNLOAD_T;
return 0;
}
'''
have_newer_curlinfo = cc.compiles(curlinfo_src,
dependencies: [ libcurl ],
name: 'CURLINFO_CONTENT_LENGTH_DOWNLOAD_T availability test',
no_builtin_args: true)
if have_newer_curlinfo
add_project_arguments('-D_HAVE_NEWER_CURLINFO', language : 'c')
endif
# libkmod
if get_option('with_libkmod')
if build_machine.system() == 'freebsd'
message('libkmod is not supported on FreeBSD, disabling support')
libkmod = disabler()
elif build_machine.system() == 'netbsd'
message('libkmod is not supported on NetBSD, disabling support')
libkmod = disabler()
else
libkmod = dependency('libkmod', required : true)
add_project_arguments('-D_WITH_LIBKMOD', language : 'c')
if not cc.has_header('libkmod.h', include_directories : inc)
if cc.has_header('kmod/libkmod.h', include_directories : inc)
add_project_arguments('-D_LIBKMOD_HEADER_SUBDIR', language : 'c')
else
error('*** unable to find libkmod.h')
endif
endif
endif
else
message('disabling Linux kernel module support (libkmod)')
libkmod = disabler()
endif
# If we're on an older API, note that for the build
rpm = dependency('rpm', required : true)
if rpm.version().version_compare('<4.15.0')
add_project_arguments('-D_HAVE_OLD_RPM_API', language : 'c')
endif
# librpmbuild
rpmbuild = cc.find_library('rpmbuild', dirs : search_dirs, required : true)
if rpmbuild.found()
message('found librpmbuild')
if not cc.has_function('rpmSpecParse', dependencies : [ rpmbuild ])
error('*** unable to find rpmSpecParse() in librpmbuild')
endif
else
error('*** unable to find librpmbuild')
endif
# check for RPMTAG_MODULARITYLABEL usability
rpmtag_src = '''
#include <rpm/rpmtag.h>
int main(void)
{
return RPMTAG_MODULARITYLABEL;
}
'''
have_modularitylabel = cc.compiles(rpmtag_src,
name: 'RPMTAG_MODULARITYLABEL availability test')
if have_modularitylabel
add_project_arguments('-D_HAVE_MODULARITYLABEL', language : 'c')
endif
# libarchive (need to check for specific functions)
libarchive = dependency('libarchive', required : true)
if cc.has_function('archive_version_details', dependencies : [ libarchive ])
add_project_arguments('-D_HAVE_ARCHIVE_VERSION_DETAILS', language : 'c')
elif cc.has_function('archive_version_string', dependencies : [ libarchive ])
add_project_arguments('-D_HAVE_ARCHIVE_VERSION_STRING', language : 'c')
endif
# openssl (need to check for the version info function)
openssl = dependency('openssl', required : true)
have_openssl_version = cc.has_function('OpenSSL_version', dependencies : [ openssl ])
have_ssleay_version = cc.has_function('SSLeay_version', dependencies : [ openssl ])
if not have_openssl_version and have_ssleay_version
add_project_arguments('-DOpenSSL_version=SSLeay_version', language : 'c')
elif not have_openssl_version and not have_ssleay_version
add_project_arguments('-D_NO_OPENSSL_VERSION_FUNCTION', language : 'c')
endif
# Test suite dependencies
run_tests = get_option('tests')
if run_tests
cunit = dependency('cunit', method : 'pkg-config', required : true)
python = find_program(get_option('python_program'), required : false)
else
cunit = disabler()
python = disabler()
endif
# Other dependencies
# libelf
libelf = dependency('libelf', method : 'pkg-config', required : false)
if not libelf.found() and cc.has_function('elf_begin', args : ['-lelf'])
libelf = declare_dependency(link_args : ['-lelf'])
endif
if not libelf.found()
error('*** unable to find libelf')
endif
# xmlrpc-c
xmlrpc_cmd = find_program('xmlrpc-c-config', required : true)
xmlrpc_libs_cmd = run_command(xmlrpc_cmd, '--libs', check : true)
xmlrpc_cflags_cmd = run_command(xmlrpc_cmd, '--cflags', check : true)
if xmlrpc_libs_cmd.returncode() == 0 and xmlrpc_cflags_cmd.returncode() == 0
xmlrpc = declare_dependency(compile_args: xmlrpc_cflags_cmd.stdout().strip().split(),
link_args: xmlrpc_libs_cmd.stdout().strip().split())
message('Declared dependency xmlrpc')
endif
if not xmlrpc.found()
error('*** unable to find libxmlrpc')
endif
xmlrpc_cmd = find_program('xmlrpc-c-config', required : true)
xmlrpc_client_libs_cmd = run_command(xmlrpc_cmd, 'client', '--libs', check : true)
xmlrpc_client_cflags_cmd = run_command(xmlrpc_cmd, 'client', '--cflags', check : true)
if xmlrpc_client_libs_cmd.returncode() == 0 and xmlrpc_client_cflags_cmd.returncode() == 0
xmlrpc_client = declare_dependency(compile_args: xmlrpc_client_cflags_cmd.stdout().strip().split(),
link_args: xmlrpc_client_libs_cmd.stdout().strip().split())
message('Declared dependency xmlrpc_client')
endif
if not xmlrpc_client.found()
error('*** unable to find libxmlrpc_client')
endif
# libmandoc (favor static one over shared one)
mandoc = cc.find_library('mandoc',
dirs : search_dirs,
required : false,
static : true)
if mandoc.found()
message('found static libmandoc')
else
mandoc = cc.find_library('mandoc',
dirs : search_dirs,
required : false,
static : false)
if mandoc.found()
message('found shared libmandoc')
else
error('*** unable to find libmandoc')
endif
endif
if not cc.has_function('mparse_alloc', dependencies : [mandoc, zlib])
error('*** unable to find mparse_alloc() in libmandoc')
endif
if cc.has_header('mandoc_parse.h', include_directories : inc)
add_project_arguments('-DNEWLIBMANDOC', language : 'c')
else
if cc.has_header('mandoc/mandoc_parse.h', include_directories : inc)
add_project_arguments('-DNEWLIBMANDOC', language : 'c')
add_project_arguments('-DMANDOC_INCLUDE_SUBDIR', language : 'c')
else
message('using libmandoc < 1.14.5 API')
endif
endif
# libmagic
if not cc.has_function('magic_open', args : ['-lmagic'])
error('*** unable to find magic_open() in libmagic')
endif
if cc.has_function('magic_version', args : ['-lmagic'])
add_project_arguments('-D_HAVE_MAGIC_VERSION', language : 'c')
endif
magic = declare_dependency(link_args : ['-lmagic'])
# libcap
if get_option('with_libcap')
if build_machine.system() == 'freebsd'
message('libcap is not supported on FreeBSD, disabling support')
libcap = disabler()
elif build_machine.system() == 'netbsd'
message('libcap is not supported on NetBSD, disabling support')
libcap = disabler()
else
libcap = dependency('libcap', method : 'pkg-config', required : false)
if not libcap.found() and cc.has_function('cap_to_text', args : ['-lcap'])
libcap = declare_dependency(link_args : ['-lcap'])
endif
if not libcap.found()
error('*** unable to find libcap')
endif
add_project_arguments('-D_WITH_LIBCAP', language : 'c')
endif
else
message('disabling Linux capability(7) support (libcap)')
libcap = disabler()
endif
# annocheck(1) or libannocheck
if get_option('with_annocheck') and get_option('with_libannocheck')
error('*** you may only use with_annocheck or with_libannocheck, not both')
endif
if get_option('with_annocheck')
if build_machine.system() == 'freebsd'
message('disabling annocheck(1) support on FreeBSD')
else
add_project_arguments('-D_WITH_ANNOCHECK', language : 'c')
endif
endif
if get_option('with_libannocheck')
if build_machine.system() == 'freebsd'
message('libannocheck is not supported on FreeBSD, disabling support')
else
libannocheck = dependency('libannocheck', required : true)
add_project_arguments('-D_WITH_LIBANNOCHECK', language : 'c')
endif
else
message('disabling libannocheck support')
endif
# dlopen
if build_machine.system() != 'netbsd'
# dlopen() is in libc on NetBSD, but in libdl elsewhere
if not cc.has_function('dlopen', args : ['-ldl'], dependencies : [zlib])
error('*** unable to find dlopen() in libdl')
endif
dl = declare_dependency(link_args : ['-ldl'])
endif
# libm
if not cc.has_function('round', args : ['-lm'])
error('*** unable to find round() in libm')
endif
if not cc.has_function('lround', args : ['-lm'])
error('*** unable to find lround() in libm')
endif
m = declare_dependency(link_args : ['-lm'])
# cdson
cdson = dependency('cdson', required : true)
# Check for sys/queue.h
if not cc.has_header('sys/queue.h', include_directories : inc)
message('<sys/queue.h> not found, using bundled copy')
add_project_arguments('-D_COMPAT_QUEUE', language : 'c')
endif
# Header files for builds
inc = include_directories('include')
incxdiff = include_directories('libxdiff')
# Include all of the relevant subdirectories of the source tree
subdir('libxdiff')
subdir('lib')
subdir('src')
subdir('include')
subdir('data')
subdir('test')