1project('libslirp', 'c', 2 version : '4.6.1', 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 19full_version = run_command('build-aux/git-version-gen', 20 '@0@/.tarball-version'.format(meson.current_source_dir()), 21 check : true).stdout().strip() 22if full_version.startswith('UNKNOWN') 23 full_version = meson.project_version() 24elif 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)) 27endif 28conf.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 47lt_current = 3 48lt_revision = 1 49lt_age = 3 50lt_version = '@0@.@1@.@2@'.format(lt_current - lt_age, lt_age, lt_revision) 51 52host_system = host_machine.system() 53 54glib_dep = dependency('glib-2.0') 55 56cc = meson.get_compiler('c') 57 58platform_deps = [] 59 60if host_system == 'windows' 61 platform_deps += [ 62 cc.find_library('ws2_32'), 63 cc.find_library('iphlpapi') 64 ] 65elif host_system == 'darwin' 66 platform_deps += [ 67 cc.find_library('resolv') 68 ] 69endif 70 71cargs = [ 72 '-DG_LOG_DOMAIN="Slirp"', 73] 74 75if cc.check_header('valgrind/valgrind.h') 76 cargs += [ '-DHAVE_VALGRIND=1' ] 77endif 78 79sources = [ 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 113mapfile = 'src/libslirp.map' 114vflag = [] 115vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) 116if cc.has_link_argument(vflag_test) 117 vflag += vflag_test 118endif 119 120install_devel = not meson.is_subproject() 121 122configure_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 130lib = 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 139if install_devel 140 install_headers(['src/libslirp.h'], subdir : 'slirp') 141 142 pkg = import('pkgconfig') 143 144 pkg.generate( 145 version : version, 146 libraries : lib, 147 requires : [ 148 'glib-2.0', 149 ], 150 name : 'slirp', 151 description : 'User-space network stack', 152 filebase : 'slirp', 153 subdirs : 'slirp', 154 ) 155else 156 if get_option('default_library') == 'both' 157 lib = lib.get_static_lib() 158 endif 159 libslirp_dep = declare_dependency( 160 include_directories: include_directories('.', 'src'), 161 link_with: lib) 162endif 163