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'
84 # Broken definition, fails to link
85 if os_name != 'windows'
86 check_functions += 'fork'
92 'struct ether_header',
97 'struct nd_neighbor_solicit',
102 subdir('chacha-poly1305')
143 'multicast_device.c',
156 'raw_socket_device.c',
161 cc_flags_tincd = cc_flags
165 deps_tincd = [cc.find_library('m', required: false)]
167 if os_name != 'windows'
168 src_lib_common += 'random.c'
171 if os_name in ['linux', 'android']
173 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
175 elif os_name == 'sunos'
177 elif os_name == 'windows'
181 foreach h : check_headers
183 cdata.set('HAVE_' + h.to_upper().underscorify(),
185 description: '#include <' + h + '>')
189 if cdata.has('HAVE_SYS_UN_H')
190 src_tincd += 'fd_device.c'
193 confdata = configuration_data()
194 confdata.merge_from(cdata)
195 configure_file(output: 'meson_config.h', configuration: confdata)
198 #include "@0@/src/meson_config.h"
199 #include "@1@/have.h"
200 '''.format(build_root, meson.current_source_dir())
202 foreach f : check_functions
203 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
204 cdata.set('HAVE_' + f.to_upper(),
206 description: 'function ' + f)
210 if cc.has_function('res_init', prefix: '''
211 #include <netinet/in.h>
214 cdata.set('HAVE_DECL_RES_INIT', 1)
217 foreach type : check_types
218 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
219 name = 'HAVE_' + type.to_upper().underscorify()
220 cdata.set(name, 1, description: type)
225 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
226 src_getopt = ['getopt.c', 'getopt1.c']
227 src_lib_common += src_getopt
230 if not opt_miniupnpc.disabled()
231 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
232 if not dep_miniupnpc.found()
233 # No pkg-config files on MinGW
234 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
236 if dep_miniupnpc.found()
237 src_tincd += 'upnp.c'
239 dependency('threads', static: static),
243 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
245 cdata.set('HAVE_MINIUPNPC', 1)
249 if not opt_curses.disabled()
250 # The meta-dependency covers more alternatives, but is only available in 0.54+
251 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
252 dep_curses = dependency(curses_name, required: opt_curses, static: static)
253 if dep_curses.found()
254 cdata.set('HAVE_CURSES', 1)
255 deps_tinc += dep_curses
259 # Some distributions do not supply pkg-config files for readline
260 if opt_readline.auto() and os_name == 'windows'
261 message('readline not available on Windows')
263 dep_readline = dependency('readline', required: opt_readline, static: static)
264 if not dep_readline.found()
265 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
267 if dep_readline.found() and \
268 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
269 cc.has_header('readline/history.h', dependencies: dep_readline)
270 cdata.set('HAVE_READLINE', 1)
271 deps_tinc += dep_readline
275 dep_zlib = dependency('zlib',
278 fallback: ['zlib', 'zlib_dep'])
280 cdata.set('HAVE_ZLIB', 1)
281 deps_tincd += dep_zlib
284 if not opt_lzo.disabled()
285 dep_lzo = dependency('lzo2', required: false, static: static)
286 if not dep_lzo.found()
287 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
289 if not dep_lzo.found()
290 dep_lzo = dependency('lzo2',
293 fallback: ['lzo2', 'lzo2_dep'])
296 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
297 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
298 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
299 cdata.set('LZO1X_H', '<lzo1x.h>')
301 msg = 'lzo1x.h not found'
308 if cdata.has('LZO1X_H')
309 cdata.set('HAVE_LZO', 1)
310 deps_tincd += dep_lzo
315 dep_lz4 = dependency('liblz4',
318 fallback: ['lz4', 'liblz4_dep'])
320 deps_tincd += dep_lz4
321 cdata.set('HAVE_LZ4', 1)
324 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
325 dep_dl = cc.find_library('dl', required: opt_vde)
326 if dep_vde.found() and dep_dl.found()
327 cdata.set('ENABLE_VDE', 1)
328 src_tincd += 'vde_device.c'
329 deps_tincd += [dep_dl, dep_vde]
333 cdata.set('ENABLE_JUMBOGRAMS', 1)
338 if opt_crypto != 'openssl'
339 src_lib_crypto += 'crypto.c'
342 if opt_crypto != 'nolegacy'
343 src_lib_crypto += ['cipher.c', 'digest.c']
348 lib_crypto = static_library(
350 sources: src_lib_crypto,
351 dependencies: dep_crypto,
352 implicit_include_directories: false,
353 include_directories: inc_conf,
354 build_by_default: false,
357 deps_lib_common = [deps_common, dep_crypto]
358 deps_tinc += deps_lib_common
359 deps_tincd += deps_lib_common
361 lib_common = static_library(
363 sources: src_lib_common,
364 dependencies: deps_lib_common,
365 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
366 implicit_include_directories: false,
367 include_directories: inc_conf,
368 build_by_default: false,
371 lib_tinc = static_library(
374 dependencies: deps_tinc,
375 link_with: lib_common,
376 implicit_include_directories: false,
377 include_directories: inc_conf,
378 build_by_default: false,
381 lib_tincd = static_library(
384 dependencies: deps_tincd,
385 link_with: lib_common,
386 c_args: cc_flags_tincd,
387 implicit_include_directories: false,
388 include_directories: inc_conf,
389 build_by_default: false,
392 exe_tinc = executable(
394 sources: 'tincctl.c',
395 dependencies: deps_tinc,
397 implicit_include_directories: false,
398 include_directories: inc_conf,
400 install_dir: dir_sbin,
403 exe_tincd = executable(
406 dependencies: deps_tincd,
407 link_with: lib_tincd,
408 c_args: cc_flags_tincd,
409 implicit_include_directories: false,
410 include_directories: inc_conf,
412 install_dir: dir_sbin,
415 exe_sptps_test = executable(
417 sources: [src_getopt, 'sptps_test.c'],
418 dependencies: deps_lib_common,
419 link_with: lib_common,
420 implicit_include_directories: false,
421 include_directories: inc_conf,
422 build_by_default: false,
425 exe_sptps_keypair = executable(
427 sources: [src_getopt, 'sptps_keypair.c'],
428 dependencies: deps_lib_common,
429 link_with: lib_common,
430 implicit_include_directories: false,
431 include_directories: inc_conf,
432 build_by_default: false,
435 if os_name == 'linux'
436 dep_rt = cc.find_library('rt')
438 exe_sptps_speed = executable(
440 sources: 'sptps_speed.c',
441 dependencies: [deps_lib_common, dep_rt],
442 link_with: lib_common,
443 implicit_include_directories: false,
444 include_directories: inc_conf,
445 build_by_default: false,
448 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)