From: Marc-André Lureau <marcandre.lur...@redhat.com> 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.lur...@redhat.com> --- meson.build | 111 +++++++++++++++++++++++++++++++++++++++++++++++ src/libslirp.map | 21 +++++++++ 2 files changed, 132 insertions(+) create mode 100644 meson.build create mode 100644 src/libslirp.map diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..d53d17a --- /dev/null +++ b/meson.build @@ -0,0 +1,111 @@ +project('slirp', 'c', + version : '4.0.0', + license : 'BSD-3-Clause', + default_options : ['warning_level=1', 'c_std=gnu99'] +) + +version = meson.project_version() +varr = version.split('.') +major_version = varr[0] +minor_version = varr[1] +micro_version = varr[2] + +# libtool versioning - this applies to libpackagekit +# +# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details +# +# - If interfaces have been changed or added, but binary compatibility +# has been preserved, change: +# CURRENT += 1 +# REVISION = 0 +# AGE += 1 +# - If binary compatibility has been broken (eg removed or changed +# interfaces), change: +# CURRENT += 1 +# REVISION = 0 +# AGE = 0 +# - If the interface is the same as the previous version, but bugs are +# fixed, change: +# REVISION += 1 +lt_current = '0' +lt_revision = '0' +lt_age = '0' +lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) + +host_system = host_machine.system() + +glib_dep = dependency('glib-2.0') + +cc = meson.get_compiler('c') + +platform_deps = [] + +if host_system == 'windows' + platform_deps += [ + cc.find_library('ws2_32'), + cc.find_library('iphlpapi') + ] +endif + +cargs = [ + '-DG_LOG_DOMAIN="Slirp"', +] + +sources = [ + 'src/arp_table.c', + 'src/bootp.c', + 'src/cksum.c', + 'src/dhcpv6.c', + 'src/dnssearch.c', + 'src/if.c', + 'src/ip6_icmp.c', + 'src/ip6_input.c', + 'src/ip6_output.c', + 'src/ip_icmp.c', + 'src/ip_input.c', + 'src/ip_output.c', + 'src/mbuf.c', + 'src/misc.c', + 'src/ncsi.c', + 'src/ndp_table.c', + 'src/sbuf.c', + 'src/slirp.c', + 'src/socket.c', + 'src/tcp_input.c', + 'src/tcp_output.c', + 'src/tcp_subr.c', + 'src/tcp_timer.c', + 'src/tftp.c', + 'src/udp.c', + 'src/udp6.c', + 'src/util.c', +] + +mapfile = 'src/libslirp.map' +vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) + +lib = shared_library('slirp', sources, + soversion : lt_current, + version : lt_version, + c_args : cargs, + link_args : vflag, + link_depends : mapfile, + dependencies : [glib_dep, platform_deps], + install : true +) + +install_headers(['src/libslirp.h'], subdir : 'slirp') + +pkg = import('pkgconfig') + +pkg.generate( + version : version, + libraries : lib, + requires : [ + 'glib-2.0', + ], + name : 'slirp', + description : 'User-space network stack', + filebase : 'slirp', + subdirs : 'slirp', +) diff --git a/src/libslirp.map b/src/libslirp.map new file mode 100644 index 0000000..3eb730a --- /dev/null +++ b/src/libslirp.map @@ -0,0 +1,21 @@ +SLIRP_4.0 { +global: + slirp_add_exec; + slirp_add_guestfwd; + slirp_add_hostfwd; + slirp_cleanup; + slirp_connection_info; + slirp_init; + slirp_input; + slirp_pollfds_fill; + slirp_pollfds_poll; + slirp_remove_hostfwd; + slirp_socket_can_recv; + slirp_socket_recv; + slirp_state_load; + slirp_state_save; + slirp_state_version; + slirp_version_string; +local: + *; +}; -- 2.21.0.rc0.1.g036caf7885