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')
146 'multicast_device.c',
160 'raw_socket_device.c',
165 cc_flags_tincd = cc_flags
169 deps_tincd = [cc.find_library('m', required: false)]
171 if os_name != 'windows'
172 src_lib_common += 'random.c'
175 if os_name in ['linux', 'android']
177 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
179 elif os_name == 'sunos'
181 elif os_name == 'windows'
185 foreach h : check_headers
187 cdata.set('HAVE_' + h.to_upper().underscorify(),
189 description: '#include <' + h + '>')
193 if cdata.has('HAVE_SYS_UN_H')
194 src_tincd += 'fd_device.c'
197 confdata = configuration_data()
198 confdata.merge_from(cdata)
199 configure_file(output: 'meson_config.h', configuration: confdata)
202 #include "@0@/src/meson_config.h"
203 #include "@1@/have.h"
204 '''.format(build_root, meson.current_source_dir())
206 foreach f : check_functions
207 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
208 cdata.set('HAVE_' + f.to_upper(),
210 description: 'function ' + f)
214 if cc.has_function('res_init', prefix: '''
215 #include <netinet/in.h>
218 cdata.set('HAVE_DECL_RES_INIT', 1)
221 foreach type : check_types
222 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
223 name = 'HAVE_' + type.to_upper().underscorify()
224 cdata.set(name, 1, description: type)
229 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
230 src_getopt = ['getopt.c', 'getopt1.c']
231 src_lib_common += src_getopt
234 if not opt_miniupnpc.disabled()
235 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
236 if not dep_miniupnpc.found()
237 # No pkg-config files on MinGW
238 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
240 if dep_miniupnpc.found()
241 src_tincd += 'upnp.c'
243 dependency('threads', static: static),
247 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
249 cdata.set('HAVE_MINIUPNPC', 1)
253 if not opt_curses.disabled()
254 # The meta-dependency covers more alternatives, but is only available in 0.54+
255 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
256 dep_curses = dependency(curses_name, required: opt_curses, static: static)
257 if dep_curses.found()
258 cdata.set('HAVE_CURSES', 1)
259 deps_tinc += dep_curses
263 # Some distributions do not supply pkg-config files for readline
264 if opt_readline.auto() and os_name == 'windows'
265 message('readline not available on Windows')
267 dep_readline = dependency('readline', required: opt_readline, static: static)
268 if not dep_readline.found()
269 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
271 if dep_readline.found() and \
272 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
273 cc.has_header('readline/history.h', dependencies: dep_readline)
274 cdata.set('HAVE_READLINE', 1)
275 deps_tinc += dep_readline
279 dep_zlib = dependency('zlib',
282 fallback: ['zlib', 'zlib_dep'])
284 cdata.set('HAVE_ZLIB', 1)
285 deps_tincd += dep_zlib
288 if not opt_lzo.disabled()
289 dep_lzo = dependency('lzo2', required: false, static: static)
290 if not dep_lzo.found()
291 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
293 if not dep_lzo.found()
294 dep_lzo = dependency('lzo2',
297 fallback: ['lzo2', 'lzo2_dep'])
300 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
301 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
302 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
303 cdata.set('LZO1X_H', '<lzo1x.h>')
305 msg = 'lzo1x.h not found'
312 if cdata.has('LZO1X_H')
313 cdata.set('HAVE_LZO', 1)
314 deps_tincd += dep_lzo
319 dep_lz4 = dependency('liblz4',
322 fallback: ['lz4', 'liblz4_dep'])
324 deps_tincd += dep_lz4
325 cdata.set('HAVE_LZ4', 1)
328 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
329 dep_dl = cc.find_library('dl', required: opt_vde)
330 if dep_vde.found() and dep_dl.found()
331 cdata.set('ENABLE_VDE', 1)
332 src_tincd += 'vde_device.c'
333 deps_tincd += [dep_dl, dep_vde]
337 cdata.set('ENABLE_JUMBOGRAMS', 1)
342 if opt_crypto != 'openssl'
343 src_lib_crypto += 'crypto.c'
346 if opt_crypto != 'nolegacy'
347 src_lib_crypto += ['cipher.c', 'digest.c']
352 lib_crypto = static_library(
354 sources: src_lib_crypto,
355 dependencies: dep_crypto,
356 implicit_include_directories: false,
357 include_directories: inc_conf,
358 build_by_default: false,
361 deps_lib_common = [deps_common, dep_crypto]
362 deps_tinc += deps_lib_common
363 deps_tincd += deps_lib_common
365 lib_common = static_library(
367 sources: src_lib_common,
368 dependencies: deps_lib_common,
369 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
370 implicit_include_directories: false,
371 include_directories: inc_conf,
372 build_by_default: false,
375 lib_tinc = static_library(
378 dependencies: deps_tinc,
379 link_with: lib_common,
380 implicit_include_directories: false,
381 include_directories: inc_conf,
382 build_by_default: false,
385 lib_tincd = static_library(
388 dependencies: deps_tincd,
389 link_with: lib_common,
390 c_args: cc_flags_tincd,
391 implicit_include_directories: false,
392 include_directories: inc_conf,
393 build_by_default: false,
396 exe_tinc = executable(
398 sources: 'tincctl.c',
399 dependencies: deps_tinc,
401 implicit_include_directories: false,
402 include_directories: inc_conf,
404 install_dir: dir_sbin,
407 exe_tincd = executable(
410 dependencies: deps_tincd,
411 link_with: lib_tincd,
412 c_args: cc_flags_tincd,
413 implicit_include_directories: false,
414 include_directories: inc_conf,
416 install_dir: dir_sbin,
419 exe_sptps_test = executable(
421 sources: [src_getopt, 'sptps_test.c'],
422 dependencies: deps_lib_common,
423 link_with: lib_common,
424 implicit_include_directories: false,
425 include_directories: inc_conf,
426 build_by_default: false,
429 exe_sptps_keypair = executable(
431 sources: [src_getopt, 'sptps_keypair.c'],
432 dependencies: deps_lib_common,
433 link_with: lib_common,
434 implicit_include_directories: false,
435 include_directories: inc_conf,
436 build_by_default: false,
439 if os_name == 'linux'
440 dep_rt = cc.find_library('rt')
442 exe_sptps_speed = executable(
444 sources: 'sptps_speed.c',
445 dependencies: [deps_lib_common, dep_rt],
446 link_with: lib_common,
447 implicit_include_directories: false,
448 include_directories: inc_conf,
449 build_by_default: false,
452 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)