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', 'packed', 'format']
15 if cc.has_function_attribute(attr)
16 cdata.set('HAVE_ATTR_' + attr.to_upper(), 1,
17 description: '__attribute__((__@0@__))'.format(attr))
22 _Static_assert(1, "ok");
23 int main(void) { return 0; }
25 cdata.set('HAVE_STATIC_ASSERT', 1,
26 description: 'C11 _Static_assert()')
68 # 'struct msghdr' misses some required fields
70 check_headers += 'sys/un.h'
87 # Broken definition, fails to link
88 if os_name != 'windows'
89 check_functions += 'fork'
95 'struct ether_header',
100 'struct nd_neighbor_solicit',
105 subdir('chacha-poly1305')
147 'multicast_device.c',
161 'raw_socket_device.c',
166 cc_flags_tincd = cc_flags
170 deps_tincd = [cc.find_library('m', required: false)]
172 if os_name != 'windows'
173 src_lib_common += 'random.c'
176 if os_name in ['linux', 'android']
178 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
180 elif os_name == 'sunos'
182 elif os_name == 'windows'
186 foreach h : check_headers
188 cdata.set('HAVE_' + h.to_upper().underscorify(),
190 description: '#include <' + h + '>')
194 if cdata.has('HAVE_SYS_UN_H')
195 src_tincd += 'fd_device.c'
198 confdata = configuration_data()
199 confdata.merge_from(cdata)
200 configure_file(output: 'meson_config.h', configuration: confdata)
203 #include "@0@/src/meson_config.h"
204 #include "@1@/have.h"
205 '''.format(build_root, meson.current_source_dir())
207 foreach f : check_functions
208 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
209 cdata.set('HAVE_' + f.to_upper(),
211 description: 'function ' + f)
215 if cc.has_function('res_init', prefix: '''
216 #include <netinet/in.h>
219 cdata.set('HAVE_DECL_RES_INIT', 1)
222 foreach type : check_types
223 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
224 name = 'HAVE_' + type.to_upper().underscorify()
225 cdata.set(name, 1, description: type)
230 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
231 src_getopt = ['getopt.c', 'getopt1.c']
232 src_lib_common += src_getopt
235 if not opt_miniupnpc.disabled()
236 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
237 if not dep_miniupnpc.found()
238 # No pkg-config files on MinGW
239 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
241 if dep_miniupnpc.found()
242 src_tincd += 'upnp.c'
244 dependency('threads', static: static),
248 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
250 cdata.set('HAVE_MINIUPNPC', 1)
254 if not opt_curses.disabled()
255 # The meta-dependency covers more alternatives, but is only available in 0.54+
256 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
257 dep_curses = dependency(curses_name, required: opt_curses, static: static)
258 if dep_curses.found()
259 cdata.set('HAVE_CURSES', 1)
260 deps_tinc += dep_curses
264 # Some distributions do not supply pkg-config files for readline
265 if opt_readline.auto() and os_name == 'windows'
266 message('readline not available on Windows')
268 dep_readline = dependency('readline', required: opt_readline, static: static)
269 if not dep_readline.found()
270 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
272 if dep_readline.found() and \
273 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
274 cc.has_header('readline/history.h', dependencies: dep_readline)
275 cdata.set('HAVE_READLINE', 1)
276 deps_tinc += dep_readline
280 dep_zlib = dependency('zlib',
283 fallback: ['zlib', 'zlib_dep'])
285 cdata.set('HAVE_ZLIB', 1)
286 deps_tincd += dep_zlib
289 if not opt_lzo.disabled()
290 dep_lzo = dependency('lzo2', required: false, static: static)
291 if not dep_lzo.found()
292 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
294 if not dep_lzo.found()
295 dep_lzo = dependency('lzo2',
298 fallback: ['lzo2', 'lzo2_dep'])
301 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
302 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
303 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
304 cdata.set('LZO1X_H', '<lzo1x.h>')
306 msg = 'lzo1x.h not found'
313 if cdata.has('LZO1X_H')
314 cdata.set('HAVE_LZO', 1)
315 deps_tincd += dep_lzo
320 dep_lz4 = dependency('liblz4',
323 fallback: ['lz4', 'liblz4_dep'])
325 deps_tincd += dep_lz4
326 cdata.set('HAVE_LZ4', 1)
329 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
330 dep_dl = cc.find_library('dl', required: opt_vde)
331 if dep_vde.found() and dep_dl.found()
332 cdata.set('ENABLE_VDE', 1)
333 src_tincd += 'vde_device.c'
334 deps_tincd += [dep_dl, dep_vde]
338 cdata.set('ENABLE_JUMBOGRAMS', 1)
343 if opt_crypto != 'openssl'
344 src_lib_crypto += 'crypto.c'
347 if opt_crypto != 'nolegacy'
348 src_lib_crypto += ['cipher.c', 'digest.c']
353 lib_crypto = static_library(
355 sources: src_lib_crypto,
356 dependencies: dep_crypto,
357 implicit_include_directories: false,
358 include_directories: inc_conf,
359 build_by_default: false,
362 deps_lib_common = [deps_common, dep_crypto]
363 deps_tinc += deps_lib_common
364 deps_tincd += deps_lib_common
366 lib_common = static_library(
368 sources: src_lib_common,
369 dependencies: deps_lib_common,
370 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
371 implicit_include_directories: false,
372 include_directories: inc_conf,
373 build_by_default: false,
376 lib_tinc = static_library(
379 dependencies: deps_tinc,
380 link_with: lib_common,
381 implicit_include_directories: false,
382 include_directories: inc_conf,
383 build_by_default: false,
386 lib_tincd = static_library(
389 dependencies: deps_tincd,
390 link_with: lib_common,
391 c_args: cc_flags_tincd,
392 implicit_include_directories: false,
393 include_directories: inc_conf,
394 build_by_default: false,
397 exe_tinc = executable(
399 sources: 'tincctl.c',
400 dependencies: deps_tinc,
402 implicit_include_directories: false,
403 include_directories: inc_conf,
405 install_dir: dir_sbin,
408 exe_tincd = executable(
411 dependencies: deps_tincd,
412 link_with: lib_tincd,
413 c_args: cc_flags_tincd,
414 implicit_include_directories: false,
415 include_directories: inc_conf,
417 install_dir: dir_sbin,
420 exe_sptps_test = executable(
422 sources: [src_getopt, 'sptps_test.c'],
423 dependencies: deps_lib_common,
424 link_with: lib_common,
425 implicit_include_directories: false,
426 include_directories: inc_conf,
427 build_by_default: false,
430 exe_sptps_keypair = executable(
432 sources: [src_getopt, 'sptps_keypair.c'],
433 dependencies: deps_lib_common,
434 link_with: lib_common,
435 implicit_include_directories: false,
436 include_directories: inc_conf,
437 build_by_default: false,
440 if os_name == 'linux'
441 dep_rt = cc.find_library('rt')
443 exe_sptps_speed = executable(
445 sources: 'sptps_speed.c',
446 dependencies: [deps_lib_common, dep_rt],
447 link_with: lib_common,
448 implicit_include_directories: false,
449 include_directories: inc_conf,
450 build_by_default: false,
453 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)