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 in ['linux', 'android']
168 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
170 elif os_name == 'sunos'
172 elif os_name == 'windows'
176 foreach h : check_headers
178 cdata.set('HAVE_' + h.to_upper().underscorify(),
180 description: '#include <' + h + '>')
184 if cdata.has('HAVE_SYS_UN_H')
185 src_tincd += 'fd_device.c'
188 confdata = configuration_data()
189 confdata.merge_from(cdata)
190 configure_file(output: 'meson_config.h', configuration: confdata)
193 #include "@0@/src/meson_config.h"
194 #include "@1@/have.h"
195 '''.format(build_root, meson.current_source_dir())
197 foreach f : check_functions
198 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
199 cdata.set('HAVE_' + f.to_upper(),
201 description: 'function ' + f)
205 if cc.has_function('res_init', prefix: '''
206 #include <netinet/in.h>
209 cdata.set('HAVE_DECL_RES_INIT', 1)
212 foreach type : check_types
213 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
214 name = 'HAVE_' + type.to_upper().underscorify()
215 cdata.set(name, 1, description: type)
220 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
221 src_getopt = ['getopt.c', 'getopt1.c']
222 src_lib_common += src_getopt
225 if not opt_miniupnpc.disabled()
226 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
227 if not dep_miniupnpc.found()
228 # No pkg-config files on MinGW
229 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
231 if dep_miniupnpc.found()
232 src_tincd += 'upnp.c'
234 dependency('threads', static: static),
238 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
240 cdata.set('HAVE_MINIUPNPC', 1)
244 if not opt_curses.disabled()
245 # The meta-dependency covers more alternatives, but is only available in 0.54+
246 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
247 dep_curses = dependency(curses_name, required: opt_curses, static: static)
248 if dep_curses.found()
249 cdata.set('HAVE_CURSES', 1)
250 deps_tinc += dep_curses
254 # Some distributions do not supply pkg-config files for readline
255 if opt_readline.auto() and os_name == 'windows'
256 message('readline not available on Windows')
258 dep_readline = dependency('readline', required: opt_readline, static: static)
259 if not dep_readline.found()
260 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
262 if dep_readline.found() and \
263 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
264 cc.has_header('readline/history.h', dependencies: dep_readline)
265 cdata.set('HAVE_READLINE', 1)
266 deps_tinc += dep_readline
270 dep_zlib = dependency('zlib',
273 fallback: ['zlib', 'zlib_dep'])
275 cdata.set('HAVE_ZLIB', 1)
276 deps_tincd += dep_zlib
279 if not opt_lzo.disabled()
280 dep_lzo = dependency('lzo2', required: false, static: static)
281 if not dep_lzo.found()
282 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
284 if not dep_lzo.found()
285 dep_lzo = dependency('lzo2',
288 fallback: ['lzo2', 'lzo2_dep'])
291 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
292 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
293 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
294 cdata.set('LZO1X_H', '<lzo1x.h>')
296 msg = 'lzo1x.h not found'
303 if cdata.has('LZO1X_H')
304 cdata.set('HAVE_LZO', 1)
305 deps_tincd += dep_lzo
310 dep_lz4 = dependency('liblz4',
313 fallback: ['lz4', 'liblz4_dep'])
315 deps_tincd += dep_lz4
316 cdata.set('HAVE_LZ4', 1)
319 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
320 dep_dl = cc.find_library('dl', required: opt_vde)
321 if dep_vde.found() and dep_dl.found()
322 cdata.set('ENABLE_VDE', 1)
323 src_tincd += 'vde_device.c'
324 deps_tincd += [dep_dl, dep_vde]
328 cdata.set('ENABLE_JUMBOGRAMS', 1)
333 if opt_crypto != 'nolegacy'
334 src_lib_crypto += ['cipher.c', 'digest.c']
339 lib_crypto = static_library(
341 sources: src_lib_crypto,
342 dependencies: dep_crypto,
343 implicit_include_directories: false,
344 include_directories: inc_conf,
345 build_by_default: false,
348 deps_lib_common = [deps_common, dep_crypto]
349 deps_tinc += deps_lib_common
350 deps_tincd += deps_lib_common
352 lib_common = static_library(
354 sources: src_lib_common,
355 dependencies: deps_lib_common,
356 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
357 implicit_include_directories: false,
358 include_directories: inc_conf,
359 build_by_default: false,
362 lib_tinc = static_library(
365 dependencies: deps_tinc,
366 link_with: lib_common,
367 implicit_include_directories: false,
368 include_directories: inc_conf,
369 build_by_default: false,
372 lib_tincd = static_library(
375 dependencies: deps_tincd,
376 link_with: lib_common,
377 c_args: cc_flags_tincd,
378 implicit_include_directories: false,
379 include_directories: inc_conf,
380 build_by_default: false,
383 exe_tinc = executable(
385 sources: 'tincctl.c',
386 dependencies: deps_tinc,
388 implicit_include_directories: false,
389 include_directories: inc_conf,
391 install_dir: dir_sbin,
394 exe_tincd = executable(
397 dependencies: deps_tincd,
398 link_with: lib_tincd,
399 c_args: cc_flags_tincd,
400 implicit_include_directories: false,
401 include_directories: inc_conf,
403 install_dir: dir_sbin,
406 exe_sptps_test = executable(
408 sources: [src_getopt, 'sptps_test.c'],
409 dependencies: deps_lib_common,
410 link_with: lib_common,
411 implicit_include_directories: false,
412 include_directories: inc_conf,
413 build_by_default: false,
416 exe_sptps_keypair = executable(
418 sources: [src_getopt, 'sptps_keypair.c'],
419 dependencies: deps_lib_common,
420 link_with: lib_common,
421 implicit_include_directories: false,
422 include_directories: inc_conf,
423 build_by_default: false,
426 if os_name == 'linux'
427 dep_rt = cc.find_library('rt')
429 exe_sptps_speed = executable(
431 sources: 'sptps_speed.c',
432 dependencies: [deps_lib_common, dep_rt],
433 link_with: lib_common,
434 implicit_include_directories: false,
435 include_directories: inc_conf,
436 build_by_default: false,
439 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)