Skip to content

Commit 2898b00

Browse files
committed
build-sys: add a meson build
Build a shared library, exporting only slirp_* symbols. Install API headers and a slirp.pc pkg-config. It has been tested to build on Linux and with mingw64 cross-compilation. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent 49b04bc commit 2898b00

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

meson.build

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
project('slirp', 'c',
2+
version : '4.0.0',
3+
license : 'BSD-3-Clause',
4+
default_options : ['warning_level=1', 'c_std=gnu99']
5+
)
6+
7+
version = meson.project_version()
8+
varr = version.split('.')
9+
major_version = varr[0]
10+
minor_version = varr[1]
11+
micro_version = varr[2]
12+
13+
conf = configuration_data()
14+
conf.set('SLIRP_MAJOR_VERSION', major_version)
15+
conf.set('SLIRP_MINOR_VERSION', minor_version)
16+
conf.set('SLIRP_MICRO_VERSION', micro_version)
17+
18+
# libtool versioning - this applies to libslirp
19+
#
20+
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
21+
#
22+
# - If interfaces have been changed or added, but binary compatibility
23+
# has been preserved, change:
24+
# CURRENT += 1
25+
# REVISION = 0
26+
# AGE += 1
27+
# - If binary compatibility has been broken (eg removed or changed
28+
# interfaces), change:
29+
# CURRENT += 1
30+
# REVISION = 0
31+
# AGE = 0
32+
# - If the interface is the same as the previous version, but bugs are
33+
# fixed, change:
34+
# REVISION += 1
35+
lt_current = '0'
36+
lt_revision = '0'
37+
lt_age = '0'
38+
lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
39+
40+
host_system = host_machine.system()
41+
42+
glib_dep = dependency('glib-2.0')
43+
44+
cc = meson.get_compiler('c')
45+
46+
platform_deps = []
47+
48+
if host_system == 'windows'
49+
platform_deps += [
50+
cc.find_library('ws2_32'),
51+
cc.find_library('iphlpapi')
52+
]
53+
endif
54+
55+
cargs = [
56+
'-DG_LOG_DOMAIN="Slirp"',
57+
]
58+
59+
sources = [
60+
'src/arp_table.c',
61+
'src/bootp.c',
62+
'src/cksum.c',
63+
'src/dhcpv6.c',
64+
'src/dnssearch.c',
65+
'src/if.c',
66+
'src/ip6_icmp.c',
67+
'src/ip6_input.c',
68+
'src/ip6_output.c',
69+
'src/ip_icmp.c',
70+
'src/ip_input.c',
71+
'src/ip_output.c',
72+
'src/mbuf.c',
73+
'src/misc.c',
74+
'src/ncsi.c',
75+
'src/ndp_table.c',
76+
'src/sbuf.c',
77+
'src/slirp.c',
78+
'src/socket.c',
79+
'src/state.c',
80+
'src/stream.c',
81+
'src/tcp_input.c',
82+
'src/tcp_output.c',
83+
'src/tcp_subr.c',
84+
'src/tcp_timer.c',
85+
'src/tftp.c',
86+
'src/udp.c',
87+
'src/udp6.c',
88+
'src/util.c',
89+
'src/vmstate.c',
90+
]
91+
92+
mapfile = 'src/libslirp.map'
93+
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
94+
95+
lib = shared_library('slirp', sources,
96+
soversion : lt_current,
97+
version : lt_version,
98+
c_args : cargs,
99+
link_args : vflag,
100+
link_depends : mapfile,
101+
dependencies : [glib_dep, platform_deps],
102+
install : true
103+
)
104+
105+
install_headers(['src/libslirp.h'], subdir : 'slirp')
106+
107+
pkg = import('pkgconfig')
108+
109+
pkg.generate(
110+
version : version,
111+
libraries : lib,
112+
requires : [
113+
'glib-2.0',
114+
],
115+
name : 'slirp',
116+
description : 'User-space network stack',
117+
filebase : 'slirp',
118+
subdirs : 'slirp',
119+
)

src/libslirp.map

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SLIRP_4.0 {
2+
global:
3+
slirp_add_exec;
4+
slirp_add_guestfwd;
5+
slirp_add_hostfwd;
6+
slirp_cleanup;
7+
slirp_connection_info;
8+
slirp_init;
9+
slirp_input;
10+
slirp_pollfds_fill;
11+
slirp_pollfds_poll;
12+
slirp_remove_hostfwd;
13+
slirp_socket_can_recv;
14+
slirp_socket_recv;
15+
slirp_state_load;
16+
slirp_state_save;
17+
slirp_state_version;
18+
slirp_version_string;
19+
local:
20+
*;
21+
};

0 commit comments

Comments
 (0)