VirtualBox

source: vbox/trunk/src/libs/libslirp-4.8.0/meson.build@ 106199

Last change on this file since 106199 was 105533, checked in by vboxsync, 4 months ago

libs/libslirp: merged our changes into libslirp 4.8.0. enabled updated version. bugref:10268

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1project('libslirp', 'c',
2 version : '4.8.0',
3 license : 'BSD-3-Clause',
4 default_options : ['warning_level=1', 'c_std=gnu99'],
5 meson_version : '>= 0.50',
6)
7
8version = meson.project_version()
9varr = version.split('.')
10major_version = varr[0]
11minor_version = varr[1]
12micro_version = varr[2]
13
14conf = configuration_data()
15conf.set('SLIRP_MAJOR_VERSION', major_version)
16conf.set('SLIRP_MINOR_VERSION', minor_version)
17conf.set('SLIRP_MICRO_VERSION', micro_version)
18
19want_ossfuzz = get_option('oss-fuzz')
20want_libfuzzer = get_option('llvm-fuzz')
21fuzz_reproduce = get_option('fuzz-reproduce')
22if want_ossfuzz and want_libfuzzer
23 error('only one of oss-fuzz and llvm-fuzz can be specified')
24endif
25fuzzer_build = want_ossfuzz or want_libfuzzer
26if fuzzer_build and fuzz_reproduce
27 error('fuzzer build and reproducer build are mutually exclusive')
28endif
29
30cc = meson.get_compiler('c')
31add_languages('cpp', required : fuzzer_build)
32
33if get_option('static') == true
34 add_global_arguments('-static', language : 'c')
35endif
36
37if cc.get_argument_syntax() != 'msvc'
38 r = run_command('build-aux/git-version-gen',
39 '@0@/.tarball-version'.format(meson.current_source_dir()),
40 check : false)
41
42 full_version = r.stdout().strip()
43 if r.returncode() != 0 or full_version.startswith('UNKNOWN')
44 full_version = meson.project_version()
45 elif not full_version.startswith(meson.project_version())
46 error('meson.build project version @0@ does not match git-describe output @1@'
47 .format(meson.project_version(), full_version))
48 endif
49else
50 full_version = meson.project_version()
51endif
52conf.set_quoted('SLIRP_VERSION_STRING', full_version + get_option('version_suffix'))
53
54# libtool versioning - this applies to libslirp
55#
56# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
57#
58# - If interfaces have been changed or added, but binary compatibility
59# has been preserved, change:
60# CURRENT += 1
61# REVISION = 0
62# AGE += 1
63# - If binary compatibility has been broken (eg removed or changed
64# interfaces), change:
65# CURRENT += 1
66# REVISION = 0
67# AGE = 0
68# - If the interface is the same as the previous version, but bugs are
69# fixed, change:
70# REVISION += 1
71lt_current = 4
72lt_revision = 0
73lt_age = 4
74lt_version = '@0@.@1@.@2@'.format(lt_current - lt_age, lt_age, lt_revision)
75
76host_system = host_machine.system()
77
78glib_dep = dependency('glib-2.0', static : get_option('static'))
79
80add_project_arguments(cc.get_supported_arguments('-Wmissing-prototypes', '-Wstrict-prototypes',
81 '-Wredundant-decls', '-Wundef', '-Wwrite-strings'),
82 language: 'c', native: false)
83
84platform_deps = []
85
86if host_system == 'windows'
87 platform_deps += [
88 cc.find_library('ws2_32'),
89 cc.find_library('iphlpapi')
90 ]
91elif host_system == 'darwin'
92 platform_deps += [
93 cc.find_library('resolv')
94 ]
95elif host_system == 'haiku'
96 platform_deps += [
97 cc.find_library('network')
98 ]
99endif
100
101cargs = [
102 '-DG_LOG_DOMAIN="Slirp"',
103 '-DBUILDING_LIBSLIRP',
104]
105
106if cc.check_header('valgrind/valgrind.h')
107 cargs += [ '-DHAVE_VALGRIND=1' ]
108endif
109
110sources = [
111 'src/arp_table.c',
112 'src/bootp.c',
113 'src/cksum.c',
114 'src/dhcpv6.c',
115 'src/dnssearch.c',
116 'src/if.c',
117 'src/ip6_icmp.c',
118 'src/ip6_input.c',
119 'src/ip6_output.c',
120 'src/ip_icmp.c',
121 'src/ip_input.c',
122 'src/ip_output.c',
123 'src/mbuf.c',
124 'src/misc.c',
125 'src/ncsi.c',
126 'src/ndp_table.c',
127 'src/sbuf.c',
128 'src/slirp.c',
129 'src/socket.c',
130 'src/state.c',
131 'src/stream.c',
132 'src/tcp_input.c',
133 'src/tcp_output.c',
134 'src/tcp_subr.c',
135 'src/tcp_timer.c',
136 'src/tftp.c',
137 'src/udp.c',
138 'src/udp6.c',
139 'src/util.c',
140 'src/version.c',
141 'src/vmstate.c',
142]
143
144mapfile = 'src/libslirp.map'
145vflag = []
146vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
147if cc.has_link_argument(vflag_test)
148 vflag += vflag_test
149endif
150
151if fuzzer_build
152 cargs += '-fsanitize-coverage=edge,indirect-calls,trace-cmp'
153 cargs += '-fsanitize=fuzzer-no-link,address'
154 cargs += '-fprofile-instr-generate'
155 cargs += '-fcoverage-mapping'
156 cargs += '-g'
157 cargs += '-DSLIRP_DEBUG'
158 vflag += '-fsanitize=fuzzer-no-link,address'
159 vflag += '-fsanitize-coverage=edge,indirect-calls,trace-cmp'
160 vflag += '-fprofile-instr-generate'
161 vflag += '-fcoverage-mapping'
162endif
163if fuzz_reproduce
164 cargs += '-DSLIRP_DEBUG'
165 cargs += '-g'
166endif
167
168install_devel = not meson.is_subproject()
169
170configure_file(
171 input : 'src/libslirp-version.h.in',
172 output : 'libslirp-version.h',
173 install : install_devel,
174 install_dir : join_paths(get_option('includedir'), 'slirp'),
175 configuration : conf
176)
177
178if fuzzer_build or fuzz_reproduce
179 lib = static_library('slirp', sources,
180 c_args : cargs,
181 link_args : vflag,
182 link_depends : mapfile,
183 dependencies : [glib_dep, platform_deps],
184 )
185else
186 lib = library('slirp', sources,
187 version : lt_version,
188 c_args : cargs,
189 link_args : vflag,
190 link_depends : mapfile,
191 dependencies : [glib_dep, platform_deps],
192 install : install_devel or get_option('default_library') == 'shared',
193 )
194endif
195
196pingtest = executable('pingtest', 'test/pingtest.c',
197 link_with: [ lib ],
198 c_args : cargs,
199 link_args : vflag,
200 include_directories: [ 'src' ],
201 dependencies : [ platform_deps ]
202)
203
204test('ping', pingtest)
205
206ncsitest = executable('ncsitest', 'test/ncsitest.c',
207 link_with: [lib],
208 c_args : cargs,
209 link_args : vflag,
210 include_directories: ['src'],
211 dependencies: [glib_dep, platform_deps]
212)
213
214test('ncsi', ncsitest)
215
216if install_devel
217 install_headers(['src/libslirp.h'], subdir : 'slirp')
218
219 pkg = import('pkgconfig')
220
221 pkg.generate(
222 version : version,
223 libraries : lib,
224 requires : [
225 'glib-2.0',
226 ],
227 name : 'slirp',
228 description : 'User-space network stack',
229 filebase : 'slirp',
230 subdirs : 'slirp',
231 )
232else
233 if get_option('default_library') == 'both'
234 lib = lib.get_static_lib()
235 endif
236endif
237
238libslirp_dep = declare_dependency(
239 link_with : lib,
240 include_directories : [include_directories('src'), include_directories('.')],
241)
242
243subdir('fuzzing')
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette