1project('libslirp', 'c',
2  version : '4.1.0',
3  license : 'BSD-3-Clause',
4  default_options : ['warning_level=1', 'c_std=gnu99']
5)
6
7version = meson.project_version()
8varr = version.split('.')
9major_version = varr[0]
10minor_version = varr[1]
11micro_version = varr[2]
12
13conf = configuration_data()
14conf.set('SLIRP_MAJOR_VERSION', major_version)
15conf.set('SLIRP_MINOR_VERSION', minor_version)
16conf.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
35lt_current = 1
36lt_revision = 0
37lt_age = 1
38lt_version = '@0@.@1@.@2@'.format(lt_current - lt_age, lt_age, lt_revision)
39
40host_system = host_machine.system()
41
42glib_dep = dependency('glib-2.0')
43
44cc = meson.get_compiler('c')
45
46platform_deps = []
47
48if host_system == 'windows'
49  platform_deps += [
50    cc.find_library('ws2_32'),
51    cc.find_library('iphlpapi')
52  ]
53endif
54
55cargs = [
56  '-DG_LOG_DOMAIN="Slirp"',
57]
58
59sources = [
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/version.c',
90  'src/vmstate.c',
91]
92
93mapfile = 'src/libslirp.map'
94vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
95
96configure_file(
97  input : 'src/libslirp-version.h.in',
98  output : 'libslirp-version.h',
99  install_dir : join_paths(get_option('includedir'), 'slirp'),
100  configuration : conf
101)
102
103lib = library('slirp', sources,
104  version : lt_version,
105  c_args : cargs,
106  link_args : vflag,
107  link_depends : mapfile,
108  dependencies : [glib_dep, platform_deps],
109  install : true
110)
111
112libslirp_dep = declare_dependency(
113  include_directories: include_directories('.', 'src'),
114  link_with: lib)
115
116install_headers(['src/libslirp.h'], subdir : 'slirp')
117
118pkg = import('pkgconfig')
119
120pkg.generate(
121  version : version,
122  libraries : lib,
123  requires : [
124    'glib-2.0',
125  ],
126  name : 'slirp',
127  description : 'User-space network stack',
128  filebase : 'slirp',
129  subdirs : 'slirp',
130)
131