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)
54 # 'struct msghdr' misses some required fields
56 check_headers += 'sys/un.h'
70 # Broken definition, fails to link
71 if os_name != 'windows'
72 check_functions += 'fork'
78 'struct ether_header',
83 'struct nd_neighbor_solicit',
88 subdir('chacha-poly1305')
128 'multicast_device.c',
141 'raw_socket_device.c',
146 cc_flags_tincd = cc_flags
150 deps_tincd = [cc.find_library('m', required: false)]
152 if os_name in ['linux', 'android']
154 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
156 elif os_name == 'sunos'
158 elif os_name == 'windows'
162 foreach h : check_headers
164 cdata.set('HAVE_' + h.to_upper().underscorify(),
166 description: '#include <' + h + '>')
170 if cdata.has('HAVE_SYS_UN_H')
171 src_tincd += 'fd_device.c'
174 confdata = configuration_data()
175 confdata.merge_from(cdata)
176 configure_file(output: 'meson_config.h', configuration: confdata)
179 #include "@0@/src/meson_config.h"
180 #include "@1@/have.h"
181 '''.format(build_root, meson.current_source_dir())
183 foreach f : check_functions
184 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
185 cdata.set('HAVE_' + f.to_upper(),
187 description: 'function ' + f)
191 if cc.has_function('res_init', prefix: '''
192 #include <netinet/in.h>
195 cdata.set('HAVE_DECL_RES_INIT', 1)
198 foreach type : check_types
199 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
200 name = 'HAVE_' + type.to_upper().underscorify()
201 cdata.set(name, 1, description: type)
205 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
206 src_lib_common += ['getopt.c', 'getopt1.c']
209 if not opt_miniupnpc.disabled()
210 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
211 if not dep_miniupnpc.found()
212 # No pkg-config files on MinGW
213 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
215 if dep_miniupnpc.found()
216 src_tincd += 'upnp.c'
218 dependency('threads', static: static),
222 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
224 cdata.set('HAVE_MINIUPNPC', 1)
228 if opt_curses.auto() and os_name == 'windows'
229 message('curses does not link under MinGW')
231 # The meta-dependency covers more alternatives, but is only available in 0.54+
232 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
233 dep_curses = dependency(curses_name, required: opt_curses, static: static)
234 if dep_curses.found()
235 cdata.set('HAVE_CURSES', 1)
236 deps_tinc += dep_curses
240 # Some distributions do not supply pkg-config files for readline
241 if opt_readline.auto() and os_name == 'windows'
242 message('readline does not link under MinGW')
244 dep_readline = dependency('readline', required: opt_readline, static: static)
245 if not dep_readline.found()
246 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
248 if dep_readline.found() and \
249 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
250 cc.has_header('readline/history.h', dependencies: dep_readline)
251 cdata.set('HAVE_READLINE', 1)
252 deps_tinc += dep_readline
256 dep_zlib = dependency('zlib',
259 fallback: ['zlib', 'zlib_dep'])
261 cdata.set('HAVE_ZLIB', 1)
262 deps_tincd += dep_zlib
265 if not opt_lzo.disabled()
266 dep_lzo = dependency('lzo2', required: false, static: static)
267 if not dep_lzo.found()
268 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
270 if not dep_lzo.found()
271 dep_lzo = dependency('lzo2',
274 fallback: ['lzo2', 'lzo2_dep'])
277 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
278 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
279 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
280 cdata.set('LZO1X_H', '<lzo1x.h>')
282 msg = 'lzo1x.h not found'
289 if cdata.has('LZO1X_H')
290 cdata.set('HAVE_LZO', 1)
291 deps_tincd += dep_lzo
296 dep_lz4 = dependency('liblz4',
299 fallback: ['lz4', 'liblz4_dep'])
301 deps_tincd += dep_lz4
302 cdata.set('HAVE_LZ4', 1)
305 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
306 dep_dl = cc.find_library('dl', required: opt_vde)
307 if dep_vde.found() and dep_dl.found()
308 cdata.set('ENABLE_VDE', 1)
309 src_tincd += 'vde_device.c'
310 deps_tincd += [dep_dl, dep_vde]
314 cdata.set('ENABLE_JUMBOGRAMS', 1)
319 if opt_crypto != 'nolegacy'
320 src_lib_crypto += ['cipher.c', 'digest.c']
325 lib_crypto = static_library(
327 sources: src_lib_crypto,
328 dependencies: dep_crypto,
329 implicit_include_directories: false,
330 include_directories: inc_conf,
331 build_by_default: false,
334 deps_lib_common = [deps_common, dep_crypto]
335 deps_tinc += deps_lib_common
336 deps_tincd += deps_lib_common
338 lib_common = static_library(
340 sources: src_lib_common,
341 dependencies: deps_lib_common,
342 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
343 implicit_include_directories: false,
344 include_directories: inc_conf,
345 build_by_default: false,
348 lib_tinc = static_library(
351 dependencies: deps_tinc,
352 link_with: lib_common,
353 implicit_include_directories: false,
354 include_directories: inc_conf,
355 build_by_default: false,
358 lib_tincd = static_library(
361 dependencies: deps_tincd,
362 link_with: lib_common,
363 c_args: cc_flags_tincd,
364 implicit_include_directories: false,
365 include_directories: inc_conf,
366 build_by_default: false,
369 exe_tinc = executable(
371 sources: 'tincctl.c',
372 dependencies: deps_tinc,
374 implicit_include_directories: false,
375 include_directories: inc_conf,
377 install_dir: dir_sbin,
380 exe_tincd = executable(
383 dependencies: deps_tincd,
384 link_with: lib_tincd,
385 c_args: cc_flags_tincd,
386 implicit_include_directories: false,
387 include_directories: inc_conf,
389 install_dir: dir_sbin,
392 exe_sptps_test = executable(
394 sources: 'sptps_test.c',
395 dependencies: deps_lib_common,
396 link_with: lib_common,
397 implicit_include_directories: false,
398 include_directories: inc_conf,
399 build_by_default: false,
402 exe_sptps_keypair = executable(
404 sources: 'sptps_keypair.c',
405 dependencies: deps_lib_common,
406 link_with: lib_common,
407 implicit_include_directories: false,
408 include_directories: inc_conf,
409 build_by_default: false,
412 if os_name == 'linux'
413 dep_rt = cc.find_library('rt')
415 exe_sptps_speed = executable(
417 sources: 'sptps_speed.c',
418 dependencies: [deps_lib_common, dep_rt],
419 link_with: lib_common,
420 implicit_include_directories: false,
421 include_directories: inc_conf,
422 build_by_default: false,
425 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)