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']
15 cc.has_function_attribute(attr)
19 _Static_assert(1, "ok");
20 int main(void) { return 0; }
22 cdata.set('HAVE_STATIC_ASSERT', 1,
23 description: 'C11 _Static_assert()')
65 # 'struct msghdr' misses some required fields
67 check_headers += 'sys/un.h'
81 # Broken definition, fails to link
82 if os_name != 'windows'
83 check_functions += 'fork'
89 'struct ether_header',
94 'struct nd_neighbor_solicit',
99 subdir('chacha-poly1305')
139 'multicast_device.c',
152 'raw_socket_device.c',
157 cc_flags_tincd = cc_flags
161 deps_tincd = [cc.find_library('m', required: false)]
163 if os_name in ['linux', 'android']
165 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
167 elif os_name == 'sunos'
169 elif os_name == 'windows'
173 foreach h : check_headers
175 cdata.set('HAVE_' + h.to_upper().underscorify(),
177 description: '#include <' + h + '>')
181 if cdata.has('HAVE_SYS_UN_H')
182 src_tincd += 'fd_device.c'
185 confdata = configuration_data()
186 confdata.merge_from(cdata)
187 configure_file(output: 'meson_config.h', configuration: confdata)
190 #include "@0@/src/meson_config.h"
191 #include "@1@/have.h"
192 '''.format(build_root, meson.current_source_dir())
194 foreach f : check_functions
195 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
196 cdata.set('HAVE_' + f.to_upper(),
198 description: 'function ' + f)
202 if cc.has_function('res_init', prefix: '''
203 #include <netinet/in.h>
206 cdata.set('HAVE_DECL_RES_INIT', 1)
209 foreach type : check_types
210 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
211 name = 'HAVE_' + type.to_upper().underscorify()
212 cdata.set(name, 1, description: type)
216 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
217 src_lib_common += ['getopt.c', 'getopt1.c']
220 if not opt_miniupnpc.disabled()
221 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
222 if not dep_miniupnpc.found()
223 # No pkg-config files on MinGW
224 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
226 if dep_miniupnpc.found()
227 src_tincd += 'upnp.c'
229 dependency('threads', static: static),
233 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
235 cdata.set('HAVE_MINIUPNPC', 1)
239 if not opt_curses.disabled()
240 # The meta-dependency covers more alternatives, but is only available in 0.54+
241 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
242 dep_curses = dependency(curses_name, required: opt_curses, static: static)
243 if dep_curses.found()
244 cdata.set('HAVE_CURSES', 1)
245 deps_tinc += dep_curses
249 # Some distributions do not supply pkg-config files for readline
250 if opt_readline.auto() and os_name == 'windows'
251 message('readline not available on Windows')
253 dep_readline = dependency('readline', required: opt_readline, static: static)
254 if not dep_readline.found()
255 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
257 if dep_readline.found() and \
258 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
259 cc.has_header('readline/history.h', dependencies: dep_readline)
260 cdata.set('HAVE_READLINE', 1)
261 deps_tinc += dep_readline
265 dep_zlib = dependency('zlib',
268 fallback: ['zlib', 'zlib_dep'])
270 cdata.set('HAVE_ZLIB', 1)
271 deps_tincd += dep_zlib
274 if not opt_lzo.disabled()
275 dep_lzo = dependency('lzo2', required: false, static: static)
276 if not dep_lzo.found()
277 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
279 if not dep_lzo.found()
280 dep_lzo = dependency('lzo2',
283 fallback: ['lzo2', 'lzo2_dep'])
286 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
287 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
288 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
289 cdata.set('LZO1X_H', '<lzo1x.h>')
291 msg = 'lzo1x.h not found'
298 if cdata.has('LZO1X_H')
299 cdata.set('HAVE_LZO', 1)
300 deps_tincd += dep_lzo
305 dep_lz4 = dependency('liblz4',
308 fallback: ['lz4', 'liblz4_dep'])
310 deps_tincd += dep_lz4
311 cdata.set('HAVE_LZ4', 1)
314 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
315 dep_dl = cc.find_library('dl', required: opt_vde)
316 if dep_vde.found() and dep_dl.found()
317 cdata.set('ENABLE_VDE', 1)
318 src_tincd += 'vde_device.c'
319 deps_tincd += [dep_dl, dep_vde]
323 cdata.set('ENABLE_JUMBOGRAMS', 1)
328 if opt_crypto != 'nolegacy'
329 src_lib_crypto += ['cipher.c', 'digest.c']
334 lib_crypto = static_library(
336 sources: src_lib_crypto,
337 dependencies: dep_crypto,
338 implicit_include_directories: false,
339 include_directories: inc_conf,
340 build_by_default: false,
343 deps_lib_common = [deps_common, dep_crypto]
344 deps_tinc += deps_lib_common
345 deps_tincd += deps_lib_common
347 lib_common = static_library(
349 sources: src_lib_common,
350 dependencies: deps_lib_common,
351 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
352 implicit_include_directories: false,
353 include_directories: inc_conf,
354 build_by_default: false,
357 lib_tinc = static_library(
360 dependencies: deps_tinc,
361 link_with: lib_common,
362 implicit_include_directories: false,
363 include_directories: inc_conf,
364 build_by_default: false,
367 lib_tincd = static_library(
370 dependencies: deps_tincd,
371 link_with: lib_common,
372 c_args: cc_flags_tincd,
373 implicit_include_directories: false,
374 include_directories: inc_conf,
375 build_by_default: false,
378 exe_tinc = executable(
380 sources: 'tincctl.c',
381 dependencies: deps_tinc,
383 implicit_include_directories: false,
384 include_directories: inc_conf,
386 install_dir: dir_sbin,
389 exe_tincd = executable(
392 dependencies: deps_tincd,
393 link_with: lib_tincd,
394 c_args: cc_flags_tincd,
395 implicit_include_directories: false,
396 include_directories: inc_conf,
398 install_dir: dir_sbin,
401 exe_sptps_test = executable(
403 sources: 'sptps_test.c',
404 dependencies: deps_lib_common,
405 link_with: lib_common,
406 implicit_include_directories: false,
407 include_directories: inc_conf,
408 build_by_default: false,
411 exe_sptps_keypair = executable(
413 sources: 'sptps_keypair.c',
414 dependencies: deps_lib_common,
415 link_with: lib_common,
416 implicit_include_directories: false,
417 include_directories: inc_conf,
418 build_by_default: false,
421 if os_name == 'linux'
422 dep_rt = cc.find_library('rt')
424 exe_sptps_speed = executable(
426 sources: 'sptps_speed.c',
427 dependencies: [deps_lib_common, dep_rt],
428 link_with: lib_common,
429 implicit_include_directories: false,
430 include_directories: inc_conf,
431 build_by_default: false,
434 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)