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',
159 'raw_socket_device.c',
164 cc_flags_tincd = cc_flags
168 deps_tincd = [cc.find_library('m', required: false)]
170 if os_name != 'windows'
171 src_lib_common += 'random.c'
174 if os_name in ['linux', 'android']
176 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
178 elif os_name == 'sunos'
180 elif os_name == 'windows'
184 foreach h : check_headers
186 cdata.set('HAVE_' + h.to_upper().underscorify(),
188 description: '#include <' + h + '>')
192 if cdata.has('HAVE_SYS_UN_H')
193 src_tincd += 'fd_device.c'
196 confdata = configuration_data()
197 confdata.merge_from(cdata)
198 configure_file(output: 'meson_config.h', configuration: confdata)
201 #include "@0@/src/meson_config.h"
202 #include "@1@/have.h"
203 '''.format(build_root, meson.current_source_dir())
205 foreach f : check_functions
206 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
207 cdata.set('HAVE_' + f.to_upper(),
209 description: 'function ' + f)
213 if cc.has_function('res_init', prefix: '''
214 #include <netinet/in.h>
217 cdata.set('HAVE_DECL_RES_INIT', 1)
220 foreach type : check_types
221 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
222 name = 'HAVE_' + type.to_upper().underscorify()
223 cdata.set(name, 1, description: type)
228 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
229 src_getopt = ['getopt.c', 'getopt1.c']
230 src_lib_common += src_getopt
233 if not opt_miniupnpc.disabled()
234 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
235 if not dep_miniupnpc.found()
236 # No pkg-config files on MinGW
237 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
239 if dep_miniupnpc.found()
240 src_tincd += 'upnp.c'
242 dependency('threads', static: static),
246 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
248 cdata.set('HAVE_MINIUPNPC', 1)
252 if not opt_curses.disabled()
253 # The meta-dependency covers more alternatives, but is only available in 0.54+
254 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
255 dep_curses = dependency(curses_name, required: opt_curses, static: static)
256 if dep_curses.found()
257 cdata.set('HAVE_CURSES', 1)
258 deps_tinc += dep_curses
262 # Some distributions do not supply pkg-config files for readline
263 if opt_readline.auto() and os_name == 'windows'
264 message('readline not available on Windows')
266 dep_readline = dependency('readline', required: opt_readline, static: static)
267 if not dep_readline.found()
268 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
270 if dep_readline.found() and \
271 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
272 cc.has_header('readline/history.h', dependencies: dep_readline)
273 cdata.set('HAVE_READLINE', 1)
274 deps_tinc += dep_readline
278 dep_zlib = dependency('zlib',
281 fallback: ['zlib', 'zlib_dep'])
283 cdata.set('HAVE_ZLIB', 1)
284 deps_tincd += dep_zlib
287 if not opt_lzo.disabled()
288 dep_lzo = dependency('lzo2', required: false, static: static)
289 if not dep_lzo.found()
290 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
292 if not dep_lzo.found()
293 dep_lzo = dependency('lzo2',
296 fallback: ['lzo2', 'lzo2_dep'])
299 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
300 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
301 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
302 cdata.set('LZO1X_H', '<lzo1x.h>')
304 msg = 'lzo1x.h not found'
311 if cdata.has('LZO1X_H')
312 cdata.set('HAVE_LZO', 1)
313 deps_tincd += dep_lzo
318 dep_lz4 = dependency('liblz4',
321 fallback: ['lz4', 'liblz4_dep'])
323 deps_tincd += dep_lz4
324 cdata.set('HAVE_LZ4', 1)
327 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
328 dep_dl = cc.find_library('dl', required: opt_vde)
329 if dep_vde.found() and dep_dl.found()
330 cdata.set('ENABLE_VDE', 1)
331 src_tincd += 'vde_device.c'
332 deps_tincd += [dep_dl, dep_vde]
336 cdata.set('ENABLE_JUMBOGRAMS', 1)
341 if opt_crypto != 'openssl'
342 src_lib_crypto += 'crypto.c'
345 if opt_crypto != 'nolegacy'
346 src_lib_crypto += ['cipher.c', 'digest.c']
351 lib_crypto = static_library(
353 sources: src_lib_crypto,
354 dependencies: dep_crypto,
355 implicit_include_directories: false,
356 include_directories: inc_conf,
357 build_by_default: false,
360 deps_lib_common = [deps_common, dep_crypto]
361 deps_tinc += deps_lib_common
362 deps_tincd += deps_lib_common
364 lib_common = static_library(
366 sources: src_lib_common,
367 dependencies: deps_lib_common,
368 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
369 implicit_include_directories: false,
370 include_directories: inc_conf,
371 build_by_default: false,
374 lib_tinc = static_library(
377 dependencies: deps_tinc,
378 link_with: lib_common,
379 implicit_include_directories: false,
380 include_directories: inc_conf,
381 build_by_default: false,
384 lib_tincd = static_library(
387 dependencies: deps_tincd,
388 link_with: lib_common,
389 c_args: cc_flags_tincd,
390 implicit_include_directories: false,
391 include_directories: inc_conf,
392 build_by_default: false,
395 exe_tinc = executable(
397 sources: 'tincctl.c',
398 dependencies: deps_tinc,
400 implicit_include_directories: false,
401 include_directories: inc_conf,
403 install_dir: dir_sbin,
406 exe_tincd = executable(
409 dependencies: deps_tincd,
410 link_with: lib_tincd,
411 c_args: cc_flags_tincd,
412 implicit_include_directories: false,
413 include_directories: inc_conf,
415 install_dir: dir_sbin,
418 exe_sptps_test = executable(
420 sources: [src_getopt, 'sptps_test.c'],
421 dependencies: deps_lib_common,
422 link_with: lib_common,
423 implicit_include_directories: false,
424 include_directories: inc_conf,
425 build_by_default: false,
428 exe_sptps_keypair = executable(
430 sources: [src_getopt, 'sptps_keypair.c'],
431 dependencies: deps_lib_common,
432 link_with: lib_common,
433 implicit_include_directories: false,
434 include_directories: inc_conf,
435 build_by_default: false,
438 if os_name == 'linux'
439 dep_rt = cc.find_library('rt')
441 exe_sptps_speed = executable(
443 sources: 'sptps_speed.c',
444 dependencies: [deps_lib_common, dep_rt],
445 link_with: lib_common,
446 implicit_include_directories: false,
447 include_directories: inc_conf,
448 build_by_default: false,
451 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)