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')
142 'multicast_device.c',
155 'raw_socket_device.c',
160 cc_flags_tincd = cc_flags
164 deps_tincd = [cc.find_library('m', required: false)]
166 if os_name != 'windows'
167 src_lib_common += 'random.c'
170 if os_name in ['linux', 'android']
172 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
174 elif os_name == 'sunos'
176 elif os_name == 'windows'
180 foreach h : check_headers
182 cdata.set('HAVE_' + h.to_upper().underscorify(),
184 description: '#include <' + h + '>')
188 if cdata.has('HAVE_SYS_UN_H')
189 src_tincd += 'fd_device.c'
192 confdata = configuration_data()
193 confdata.merge_from(cdata)
194 configure_file(output: 'meson_config.h', configuration: confdata)
197 #include "@0@/src/meson_config.h"
198 #include "@1@/have.h"
199 '''.format(build_root, meson.current_source_dir())
201 foreach f : check_functions
202 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
203 cdata.set('HAVE_' + f.to_upper(),
205 description: 'function ' + f)
209 if cc.has_function('res_init', prefix: '''
210 #include <netinet/in.h>
213 cdata.set('HAVE_DECL_RES_INIT', 1)
216 foreach type : check_types
217 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
218 name = 'HAVE_' + type.to_upper().underscorify()
219 cdata.set(name, 1, description: type)
224 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
225 src_getopt = ['getopt.c', 'getopt1.c']
226 src_lib_common += src_getopt
229 if not opt_miniupnpc.disabled()
230 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
231 if not dep_miniupnpc.found()
232 # No pkg-config files on MinGW
233 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
235 if dep_miniupnpc.found()
236 src_tincd += 'upnp.c'
238 dependency('threads', static: static),
242 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
244 cdata.set('HAVE_MINIUPNPC', 1)
248 if not opt_curses.disabled()
249 # The meta-dependency covers more alternatives, but is only available in 0.54+
250 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
251 dep_curses = dependency(curses_name, required: opt_curses, static: static)
252 if dep_curses.found()
253 cdata.set('HAVE_CURSES', 1)
254 deps_tinc += dep_curses
258 # Some distributions do not supply pkg-config files for readline
259 if opt_readline.auto() and os_name == 'windows'
260 message('readline not available on Windows')
262 dep_readline = dependency('readline', required: opt_readline, static: static)
263 if not dep_readline.found()
264 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
266 if dep_readline.found() and \
267 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
268 cc.has_header('readline/history.h', dependencies: dep_readline)
269 cdata.set('HAVE_READLINE', 1)
270 deps_tinc += dep_readline
274 dep_zlib = dependency('zlib',
277 fallback: ['zlib', 'zlib_dep'])
279 cdata.set('HAVE_ZLIB', 1)
280 deps_tincd += dep_zlib
283 if not opt_lzo.disabled()
284 dep_lzo = dependency('lzo2', required: false, static: static)
285 if not dep_lzo.found()
286 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
288 if not dep_lzo.found()
289 dep_lzo = dependency('lzo2',
292 fallback: ['lzo2', 'lzo2_dep'])
295 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
296 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
297 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
298 cdata.set('LZO1X_H', '<lzo1x.h>')
300 msg = 'lzo1x.h not found'
307 if cdata.has('LZO1X_H')
308 cdata.set('HAVE_LZO', 1)
309 deps_tincd += dep_lzo
314 dep_lz4 = dependency('liblz4',
317 fallback: ['lz4', 'liblz4_dep'])
319 deps_tincd += dep_lz4
320 cdata.set('HAVE_LZ4', 1)
323 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
324 dep_dl = cc.find_library('dl', required: opt_vde)
325 if dep_vde.found() and dep_dl.found()
326 cdata.set('ENABLE_VDE', 1)
327 src_tincd += 'vde_device.c'
328 deps_tincd += [dep_dl, dep_vde]
332 cdata.set('ENABLE_JUMBOGRAMS', 1)
337 if opt_crypto != 'openssl'
338 src_lib_crypto += 'crypto.c'
341 if opt_crypto != 'nolegacy'
342 src_lib_crypto += ['cipher.c', 'digest.c']
347 lib_crypto = static_library(
349 sources: src_lib_crypto,
350 dependencies: dep_crypto,
351 implicit_include_directories: false,
352 include_directories: inc_conf,
353 build_by_default: false,
356 deps_lib_common = [deps_common, dep_crypto]
357 deps_tinc += deps_lib_common
358 deps_tincd += deps_lib_common
360 lib_common = static_library(
362 sources: src_lib_common,
363 dependencies: deps_lib_common,
364 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
365 implicit_include_directories: false,
366 include_directories: inc_conf,
367 build_by_default: false,
370 lib_tinc = static_library(
373 dependencies: deps_tinc,
374 link_with: lib_common,
375 implicit_include_directories: false,
376 include_directories: inc_conf,
377 build_by_default: false,
380 lib_tincd = static_library(
383 dependencies: deps_tincd,
384 link_with: lib_common,
385 c_args: cc_flags_tincd,
386 implicit_include_directories: false,
387 include_directories: inc_conf,
388 build_by_default: false,
391 exe_tinc = executable(
393 sources: 'tincctl.c',
394 dependencies: deps_tinc,
396 implicit_include_directories: false,
397 include_directories: inc_conf,
399 install_dir: dir_sbin,
402 exe_tincd = executable(
405 dependencies: deps_tincd,
406 link_with: lib_tincd,
407 c_args: cc_flags_tincd,
408 implicit_include_directories: false,
409 include_directories: inc_conf,
411 install_dir: dir_sbin,
414 exe_sptps_test = executable(
416 sources: [src_getopt, 'sptps_test.c'],
417 dependencies: deps_lib_common,
418 link_with: lib_common,
419 implicit_include_directories: false,
420 include_directories: inc_conf,
421 build_by_default: false,
424 exe_sptps_keypair = executable(
426 sources: [src_getopt, 'sptps_keypair.c'],
427 dependencies: deps_lib_common,
428 link_with: lib_common,
429 implicit_include_directories: false,
430 include_directories: inc_conf,
431 build_by_default: false,
434 if os_name == 'linux'
435 dep_rt = cc.find_library('rt')
437 exe_sptps_speed = executable(
439 sources: 'sptps_speed.c',
440 dependencies: [deps_lib_common, dep_rt],
441 link_with: lib_common,
442 implicit_include_directories: false,
443 include_directories: inc_conf,
444 build_by_default: false,
447 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)