1 | project('libslirp', 'c',
|
---|
2 | version : '4.7.0',
|
---|
3 | license : 'BSD-3-Clause',
|
---|
4 | default_options : ['warning_level=1', 'c_std=gnu99'],
|
---|
5 | meson_version : '>= 0.50',
|
---|
6 | )
|
---|
7 |
|
---|
8 | version = meson.project_version()
|
---|
9 | varr = version.split('.')
|
---|
10 | major_version = varr[0]
|
---|
11 | minor_version = varr[1]
|
---|
12 | micro_version = varr[2]
|
---|
13 |
|
---|
14 | conf = configuration_data()
|
---|
15 | conf.set('SLIRP_MAJOR_VERSION', major_version)
|
---|
16 | conf.set('SLIRP_MINOR_VERSION', minor_version)
|
---|
17 | conf.set('SLIRP_MICRO_VERSION', micro_version)
|
---|
18 |
|
---|
19 | full_version = run_command('build-aux/git-version-gen',
|
---|
20 | '@0@/.tarball-version'.format(meson.current_source_dir()),
|
---|
21 | check : true).stdout().strip()
|
---|
22 | if full_version.startswith('UNKNOWN')
|
---|
23 | full_version = meson.project_version()
|
---|
24 | elif not full_version.startswith(meson.project_version())
|
---|
25 | error('meson.build project version @0@ does not match git-describe output @1@'
|
---|
26 | .format(meson.project_version(), full_version))
|
---|
27 | endif
|
---|
28 | conf.set_quoted('SLIRP_VERSION_STRING', full_version + get_option('version_suffix'))
|
---|
29 |
|
---|
30 | # libtool versioning - this applies to libslirp
|
---|
31 | #
|
---|
32 | # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
|
---|
33 | #
|
---|
34 | # - If interfaces have been changed or added, but binary compatibility
|
---|
35 | # has been preserved, change:
|
---|
36 | # CURRENT += 1
|
---|
37 | # REVISION = 0
|
---|
38 | # AGE += 1
|
---|
39 | # - If binary compatibility has been broken (eg removed or changed
|
---|
40 | # interfaces), change:
|
---|
41 | # CURRENT += 1
|
---|
42 | # REVISION = 0
|
---|
43 | # AGE = 0
|
---|
44 | # - If the interface is the same as the previous version, but bugs are
|
---|
45 | # fixed, change:
|
---|
46 | # REVISION += 1
|
---|
47 | lt_current = 4
|
---|
48 | lt_revision = 0
|
---|
49 | lt_age = 4
|
---|
50 | lt_version = '@0@.@1@.@2@'.format(lt_current - lt_age, lt_age, lt_revision)
|
---|
51 |
|
---|
52 | host_system = host_machine.system()
|
---|
53 |
|
---|
54 | glib_dep = dependency('glib-2.0')
|
---|
55 |
|
---|
56 | cc = meson.get_compiler('c')
|
---|
57 |
|
---|
58 | platform_deps = []
|
---|
59 |
|
---|
60 | if host_system == 'windows'
|
---|
61 | platform_deps += [
|
---|
62 | cc.find_library('ws2_32'),
|
---|
63 | cc.find_library('iphlpapi')
|
---|
64 | ]
|
---|
65 | elif host_system == 'darwin'
|
---|
66 | platform_deps += [
|
---|
67 | cc.find_library('resolv')
|
---|
68 | ]
|
---|
69 | endif
|
---|
70 |
|
---|
71 | cargs = [
|
---|
72 | '-DG_LOG_DOMAIN="Slirp"',
|
---|
73 | ]
|
---|
74 |
|
---|
75 | if cc.check_header('valgrind/valgrind.h')
|
---|
76 | cargs += [ '-DHAVE_VALGRIND=1' ]
|
---|
77 | endif
|
---|
78 |
|
---|
79 | sources = [
|
---|
80 | 'src/arp_table.c',
|
---|
81 | 'src/bootp.c',
|
---|
82 | 'src/cksum.c',
|
---|
83 | 'src/dhcpv6.c',
|
---|
84 | 'src/dnssearch.c',
|
---|
85 | 'src/if.c',
|
---|
86 | 'src/ip6_icmp.c',
|
---|
87 | 'src/ip6_input.c',
|
---|
88 | 'src/ip6_output.c',
|
---|
89 | 'src/ip_icmp.c',
|
---|
90 | 'src/ip_input.c',
|
---|
91 | 'src/ip_output.c',
|
---|
92 | 'src/mbuf.c',
|
---|
93 | 'src/misc.c',
|
---|
94 | 'src/ncsi.c',
|
---|
95 | 'src/ndp_table.c',
|
---|
96 | 'src/sbuf.c',
|
---|
97 | 'src/slirp.c',
|
---|
98 | 'src/socket.c',
|
---|
99 | 'src/state.c',
|
---|
100 | 'src/stream.c',
|
---|
101 | 'src/tcp_input.c',
|
---|
102 | 'src/tcp_output.c',
|
---|
103 | 'src/tcp_subr.c',
|
---|
104 | 'src/tcp_timer.c',
|
---|
105 | 'src/tftp.c',
|
---|
106 | 'src/udp.c',
|
---|
107 | 'src/udp6.c',
|
---|
108 | 'src/util.c',
|
---|
109 | 'src/version.c',
|
---|
110 | 'src/vmstate.c',
|
---|
111 | ]
|
---|
112 |
|
---|
113 | mapfile = 'src/libslirp.map'
|
---|
114 | vflag = []
|
---|
115 | vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
|
---|
116 | if cc.has_link_argument(vflag_test)
|
---|
117 | vflag += vflag_test
|
---|
118 | endif
|
---|
119 |
|
---|
120 | install_devel = not meson.is_subproject()
|
---|
121 |
|
---|
122 | configure_file(
|
---|
123 | input : 'src/libslirp-version.h.in',
|
---|
124 | output : 'libslirp-version.h',
|
---|
125 | install : install_devel,
|
---|
126 | install_dir : join_paths(get_option('includedir'), 'slirp'),
|
---|
127 | configuration : conf
|
---|
128 | )
|
---|
129 |
|
---|
130 | lib = library('slirp', sources,
|
---|
131 | version : lt_version,
|
---|
132 | c_args : cargs,
|
---|
133 | link_args : vflag,
|
---|
134 | link_depends : mapfile,
|
---|
135 | dependencies : [glib_dep, platform_deps],
|
---|
136 | install : install_devel or get_option('default_library') == 'shared',
|
---|
137 | )
|
---|
138 |
|
---|
139 | pingtest = executable('pingtest', 'test/pingtest.c',
|
---|
140 | link_with: [ lib ],
|
---|
141 | include_directories: [ 'src' ],
|
---|
142 | dependencies : [ platform_deps ]
|
---|
143 | )
|
---|
144 |
|
---|
145 | test('ping', pingtest)
|
---|
146 |
|
---|
147 | if install_devel
|
---|
148 | install_headers(['src/libslirp.h'], subdir : 'slirp')
|
---|
149 |
|
---|
150 | pkg = import('pkgconfig')
|
---|
151 |
|
---|
152 | pkg.generate(
|
---|
153 | version : version,
|
---|
154 | libraries : lib,
|
---|
155 | requires : [
|
---|
156 | 'glib-2.0',
|
---|
157 | ],
|
---|
158 | name : 'slirp',
|
---|
159 | description : 'User-space network stack',
|
---|
160 | filebase : 'slirp',
|
---|
161 | subdirs : 'slirp',
|
---|
162 | )
|
---|
163 | else
|
---|
164 | if get_option('default_library') == 'both'
|
---|
165 | lib = lib.get_static_lib()
|
---|
166 | endif
|
---|
167 | libslirp_dep = declare_dependency(
|
---|
168 | include_directories: include_directories('.', 'src'),
|
---|
169 | link_with: lib)
|
---|
170 | endif
|
---|