forked from fedora-modularity/libmodulemd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
208 lines (183 loc) · 5.95 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
# This file is part of libmodulemd
# Copyright (C) 2017-2018 Stephen Gallagher
#
# Fedora-License-Identifier: MIT
# SPDX-2.0-License-Identifier: MIT
# SPDX-3.0-License-Identifier: MIT
#
# This program is free software.
# For more information on the license, see COPYING.
# For more information on free software, see <https://www.gnu.org/philosophy/free-sw.en.html>.
project(
'modulemd',
'c',
version : '2.12.1',
default_options : ['buildtype=debugoptimized', 'c_std=c11', 'warning_level=1', 'b_asneeded=true'],
license : 'MIT',
meson_version : '>=0.47.0'
)
libmodulemd_version = meson.project_version()
cc = meson.get_compiler('c')
test_cflags = [
'-Wpointer-arith',
'-Werror=missing-declarations',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wuninitialized',
['-Werror=format-security', '-Werror=format=2'], # Must be checked together
'-Werror=implicit',
'-Werror=init-self',
'-Werror=main',
'-Werror=missing-braces',
'-Werror=return-type',
'-Werror=array-bounds',
'-Werror=write-strings',
'-D_GNU_SOURCE',
'-DG_LOG_USE_STRUCTURED',
'-DG_LOG_DOMAIN="libmodulemd"',
]
foreach cflag: test_cflags
if cc.has_multi_arguments(cflag)
add_project_arguments(cflag, language : 'c')
endif
endforeach
pymod = import('python')
gnome = import('gnome')
pkg = import('pkgconfig')
gobject = dependency('gobject-2.0')
yaml = dependency('yaml-0.1')
with_rpmio = get_option('rpmio')
with_libmagic = get_option('libmagic')
rpm = dependency('rpm', required : with_rpmio)
magic = cc.find_library('magic', required : with_libmagic)
glib = dependency('glib-2.0')
glib_prefix = glib.get_pkgconfig_variable('prefix')
bash = find_program('bash')
sed = find_program('sed')
test = find_program('test')
with_docs = get_option('with_docs')
if with_docs
gtkdoc = dependency('gtk-doc')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
ret = run_command ([test, '-e', join_paths(glib_docpath, 'glib/index.html')])
if ret.returncode() != 0
error('Missing documentation for GLib.')
endif
ret = run_command ([test, '-e', join_paths(glib_docpath, 'gobject/index.html')])
if ret.returncode() != 0
error('Missing documentation for GObject.')
endif
endif
with_manpages = get_option('with_manpages')
help2man = find_program('help2man', required: with_manpages)
if not help2man.found()
help2man = disabler()
endif
# Check whether this version of glib has the GDate autoptr defined
gdate_check = '''#include <glib.h>
int main (int argc, char **argv)
{
g_autoptr(GDate) date = NULL;
return 0;
}
'''
has_gdate_autoptr = cc.compiles(
gdate_check,
dependencies : [ glib ],
name : 'g_autoptr(GDate)')
# Check whether glib2 has g_ptr_array_extend_and_steal or if we
# need to bundle it.
has_extend_and_steal = cc.has_function(
'g_ptr_array_extend_and_steal',
dependencies : [ glib ])
python_name = get_option('python_name')
if python_name != ''
# If we've been instructed to use a specific python version
python3 = pymod.find_installation(python_name)
else
# Use the python installation that is running meson
python3 = pymod.find_installation()
endif
with_py2 = get_option('with_py2')
if with_py2
python2 = pymod.find_installation('python2')
else
python2 = disabler()
endif
rpm_cdata = configuration_data()
rpm_cdata.set('VERSION', meson.project_version())
rpm_cdata.set('BUILDFLAG', '-bb')
srpm_cdata = configuration_data()
srpm_cdata.set('VERSION', meson.project_version())
srpm_cdata.set('BUILDFLAG', '-bs')
subdir('modulemd')
subdir('bindings/python')
if meson.version().version_compare('>=0.53')
if magic.found()
if with_libmagic.enabled()
magic_status = 'Enabled'
elif with_libmagic.auto()
magic_status = 'Enabled (autodetected)'
else
error('libmagic state is unknown')
endif
else
if with_libmagic.disabled()
magic_status = 'Disabled'
elif with_libmagic.auto()
magic_status = 'Disabled (autodetection could not locate libmagic)'
else
error('libmagic state is unknown')
endif
endif
if rpm.found()
if with_rpmio.enabled()
rpmio_status = 'Enabled'
elif with_rpmio.auto()
rpmio_status = 'Enabled (autodetected)'
else
error('rpmio state is unknown')
endif
else
if with_rpmio.disabled()
rpmio_status = 'Disabled'
elif with_rpmio.auto()
rpmio_status = 'Disabled (autodetection could not locate librpm)'
else
error('rpmio state is unknown')
endif
endif
if help2man.found()
if with_manpages.enabled()
manpages_status = 'Enabled'
elif with_manpages.auto()
manpages_status = 'Enabled (autodetected)'
else
error('manpages state is unknown')
endif
else
if with_manpages.disabled()
manpages_status = 'Disabled'
elif with_rpmio.auto()
manpages_status = 'Disabled (autodetection could not locate help2man)'
else
error('manpages state is unknown')
endif
endif
summary({'prefix': get_option('prefix'),
'bindir': get_option('bindir'),
'libdir': get_option('libdir'),
'datadir': get_option('datadir'),
'Python 2 GObject Overrides': gobject_overrides_dir_py2,
'Python 3 GObject Overrides': gobject_overrides_dir_py3
}, section: 'Directories')
summary({'libmagic Support': magic_status,
'Custom Python': get_option('python_name'),
'RPMIO Support': rpmio_status,
'Generate Manpages': manpages_status,
'Generate HTML Documentation': get_option('with_docs'),
'Python 2 Support': get_option('with_py2'),
'Skip Introspection': get_option('skip_introspection'),
'Test Installed Library': get_option('test_installed_lib'),
}, section: 'Build Configuration')
endif