1 inc_conf = include_directories('include')
3 cdata = configuration_data()
5 cdata.set_quoted('PACKAGE', meson.project_name())
6 cdata.set_quoted('VERSION', meson.project_version())
7 cdata.set_quoted('CONFDIR', dir_sysconf)
8 cdata.set_quoted('RUNSTATEDIR', dir_run_state)
9 cdata.set_quoted('LOCALSTATEDIR', dir_local_state)
10 cdata.set_quoted('SBINDIR', dir_sbin)
12 cdata.set('HAVE_' + os_name.to_upper(), 1)
14 foreach attr : ['malloc', 'nonnull', 'warn_unused_result']
15 cc.has_function_attribute(attr)
70 'struct ether_header',
75 'struct nd_neighbor_solicit',
80 subdir('chacha-poly1305')
122 'multicast_device.c',
135 'raw_socket_device.c',
141 cc_flags_tincd = cc_flags
145 deps_tincd = [cc.find_library('m', required: false)]
147 if os_name in ['linux', 'android']
149 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
151 elif os_name == 'sunos'
153 elif os_name == 'windows'
157 foreach h : check_headers
159 cdata.set('HAVE_' + h.to_upper().underscorify(),
161 description: '#include <' + h + '>')
165 confdata = configuration_data()
166 confdata.merge_from(cdata)
167 configure_file(output: 'meson_config.h', configuration: confdata)
170 #include "@0@/src/meson_config.h"
171 #include "@1@/have.h"
172 '''.format(build_root, meson.current_source_dir())
174 foreach f : check_functions
175 if f == 'fork' and os_name == 'windows'
176 message('MinGW does not have correct definition for fork()')
178 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
179 cdata.set('HAVE_' + f.to_upper(),
181 description: 'function ' + f)
186 if cc.has_function('res_init', prefix: '''
187 #include <netinet/in.h>
190 cdata.set('HAVE_DECL_RES_INIT', 1)
193 foreach type : check_types
194 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
195 name = 'HAVE_' + type.to_upper().underscorify()
196 cdata.set(name, 1, description: type)
200 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
201 src_lib_tinc += ['getopt.c', 'getopt1.c']
204 if not opt_miniupnpc.disabled()
205 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
206 if not dep_miniupnpc.found()
207 # No pkg-config files on MinGW
208 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
210 if dep_miniupnpc.found()
211 src_tincd += 'upnp.c'
213 dependency('threads', static: static),
217 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
219 cdata.set('HAVE_MINIUPNPC', 1)
223 if opt_curses.auto() and os_name == 'windows'
224 message('curses does not link under MinGW')
226 # The meta-dependency covers more alternatives, but is only available in 0.54+
227 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
228 dep_curses = dependency(curses_name, required: opt_curses, static: static)
229 if dep_curses.found()
230 cdata.set('HAVE_CURSES', 1)
231 deps_tinc += dep_curses
235 # Some distributions do not supply pkg-config files for readline
236 if opt_readline.auto() and os_name == 'windows'
237 message('readline does not link under MinGW')
239 dep_readline = dependency('readline', required: opt_readline, static: static)
240 if not dep_readline.found()
241 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
243 if dep_readline.found() and \
244 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
245 cc.has_header('readline/history.h', dependencies: dep_readline)
246 cdata.set('HAVE_READLINE', 1)
247 deps_tinc += dep_readline
251 dep_zlib = dependency('zlib',
254 fallback: ['zlib', 'zlib_dep'])
256 cdata.set('HAVE_ZLIB', 1)
257 deps_tincd += dep_zlib
260 if not opt_lzo.disabled()
261 dep_lzo = dependency('lzo2', required: false, static: static)
262 if not dep_lzo.found()
263 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
265 if not dep_lzo.found()
266 dep_lzo = dependency('lzo2',
269 fallback: ['lzo2', 'lzo2_dep'])
272 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
273 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
274 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
275 cdata.set('LZO1X_H', '<lzo1x.h>')
277 msg = 'lzo1x.h not found'
284 if cdata.has('LZO1X_H')
285 cdata.set('HAVE_LZO', 1)
286 deps_tincd += dep_lzo
291 dep_lz4 = dependency('liblz4',
294 fallback: ['lz4', 'liblz4_dep'])
296 deps_tincd += dep_lz4
297 cdata.set('HAVE_LZ4', 1)
300 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
301 dep_dl = cc.find_library('dl', required: opt_vde)
302 if dep_vde.found() and dep_dl.found()
303 cdata.set('ENABLE_VDE', 1)
304 src_tincd += 'vde_device.c'
305 deps_tincd += [dep_dl, dep_vde]
309 cdata.set('ENABLE_JUMBOGRAMS', 1)
314 if opt_crypto != 'nolegacy'
315 src_lib_crypto += ['cipher.c', 'digest.c']
320 lib_crypto = static_library(
322 sources: src_lib_crypto,
323 dependencies: dep_crypto,
324 implicit_include_directories: false,
325 include_directories: inc_conf,
326 build_by_default: false,
329 deps_lib_tinc = [deps_common, dep_crypto]
331 lib_tinc = static_library(
333 sources: src_lib_tinc,
334 dependencies: deps_lib_tinc,
335 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
336 implicit_include_directories: false,
337 include_directories: inc_conf,
338 build_by_default: false,
341 exe_tinc = executable(
344 dependencies: [deps_lib_tinc, deps_tinc],
346 implicit_include_directories: false,
347 include_directories: inc_conf,
349 install_dir: dir_sbin,
352 exe_tincd = executable(
355 dependencies: [deps_lib_tinc, deps_tincd],
357 c_args: cc_flags_tincd,
358 implicit_include_directories: false,
359 include_directories: inc_conf,
361 install_dir: dir_sbin,
364 exe_sptps_test = executable(
366 sources: 'sptps_test.c',
367 dependencies: deps_lib_tinc,
369 implicit_include_directories: false,
370 include_directories: inc_conf,
371 build_by_default: false,
374 exe_sptps_keypair = executable(
376 sources: 'sptps_keypair.c',
377 dependencies: deps_lib_tinc,
379 implicit_include_directories: false,
380 include_directories: inc_conf,
381 build_by_default: false,
384 if os_name == 'linux'
385 dep_rt = cc.find_library('rt')
387 exe_sptps_speed = executable(
389 sources: 'sptps_speed.c',
390 dependencies: [deps_lib_tinc, dep_rt],
392 implicit_include_directories: false,
393 include_directories: inc_conf,
394 build_by_default: false,
397 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)