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)
57 # 'struct msghdr' misses some required fields
59 check_headers += 'sys/un.h'
73 # Broken definition, fails to link
74 if os_name != 'windows'
75 check_functions += 'fork'
81 'struct ether_header',
86 'struct nd_neighbor_solicit',
91 subdir('chacha-poly1305')
131 'multicast_device.c',
144 'raw_socket_device.c',
149 cc_flags_tincd = cc_flags
153 deps_tincd = [cc.find_library('m', required: false)]
155 if os_name in ['linux', 'android']
157 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
159 elif os_name == 'sunos'
161 elif os_name == 'windows'
165 foreach h : check_headers
167 cdata.set('HAVE_' + h.to_upper().underscorify(),
169 description: '#include <' + h + '>')
173 if cdata.has('HAVE_SYS_UN_H')
174 src_tincd += 'fd_device.c'
177 confdata = configuration_data()
178 confdata.merge_from(cdata)
179 configure_file(output: 'meson_config.h', configuration: confdata)
182 #include "@0@/src/meson_config.h"
183 #include "@1@/have.h"
184 '''.format(build_root, meson.current_source_dir())
186 foreach f : check_functions
187 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
188 cdata.set('HAVE_' + f.to_upper(),
190 description: 'function ' + f)
194 if cc.has_function('res_init', prefix: '''
195 #include <netinet/in.h>
198 cdata.set('HAVE_DECL_RES_INIT', 1)
201 foreach type : check_types
202 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
203 name = 'HAVE_' + type.to_upper().underscorify()
204 cdata.set(name, 1, description: type)
208 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
209 src_lib_common += ['getopt.c', 'getopt1.c']
212 if not opt_miniupnpc.disabled()
213 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
214 if not dep_miniupnpc.found()
215 # No pkg-config files on MinGW
216 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
218 if dep_miniupnpc.found()
219 src_tincd += 'upnp.c'
221 dependency('threads', static: static),
225 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
227 cdata.set('HAVE_MINIUPNPC', 1)
231 if opt_curses.auto() and os_name == 'windows'
232 message('curses does not link under MinGW')
234 # The meta-dependency covers more alternatives, but is only available in 0.54+
235 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
236 dep_curses = dependency(curses_name, required: opt_curses, static: static)
237 if dep_curses.found()
238 cdata.set('HAVE_CURSES', 1)
239 deps_tinc += dep_curses
243 # Some distributions do not supply pkg-config files for readline
244 if opt_readline.auto() and os_name == 'windows'
245 message('readline does not link under MinGW')
247 dep_readline = dependency('readline', required: opt_readline, static: static)
248 if not dep_readline.found()
249 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
251 if dep_readline.found() and \
252 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
253 cc.has_header('readline/history.h', dependencies: dep_readline)
254 cdata.set('HAVE_READLINE', 1)
255 deps_tinc += dep_readline
259 dep_zlib = dependency('zlib',
262 fallback: ['zlib', 'zlib_dep'])
264 cdata.set('HAVE_ZLIB', 1)
265 deps_tincd += dep_zlib
268 if not opt_lzo.disabled()
269 dep_lzo = dependency('lzo2', required: false, static: static)
270 if not dep_lzo.found()
271 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
273 if not dep_lzo.found()
274 dep_lzo = dependency('lzo2',
277 fallback: ['lzo2', 'lzo2_dep'])
280 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
281 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
282 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
283 cdata.set('LZO1X_H', '<lzo1x.h>')
285 msg = 'lzo1x.h not found'
292 if cdata.has('LZO1X_H')
293 cdata.set('HAVE_LZO', 1)
294 deps_tincd += dep_lzo
299 dep_lz4 = dependency('liblz4',
302 fallback: ['lz4', 'liblz4_dep'])
304 deps_tincd += dep_lz4
305 cdata.set('HAVE_LZ4', 1)
308 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
309 dep_dl = cc.find_library('dl', required: opt_vde)
310 if dep_vde.found() and dep_dl.found()
311 cdata.set('ENABLE_VDE', 1)
312 src_tincd += 'vde_device.c'
313 deps_tincd += [dep_dl, dep_vde]
317 cdata.set('ENABLE_JUMBOGRAMS', 1)
322 if opt_crypto != 'nolegacy'
323 src_lib_crypto += ['cipher.c', 'digest.c']
328 lib_crypto = static_library(
330 sources: src_lib_crypto,
331 dependencies: dep_crypto,
332 implicit_include_directories: false,
333 include_directories: inc_conf,
334 build_by_default: false,
337 deps_lib_common = [deps_common, dep_crypto]
338 deps_tinc += deps_lib_common
339 deps_tincd += deps_lib_common
341 lib_common = static_library(
343 sources: src_lib_common,
344 dependencies: deps_lib_common,
345 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
346 implicit_include_directories: false,
347 include_directories: inc_conf,
348 build_by_default: false,
351 lib_tinc = static_library(
354 dependencies: deps_tinc,
355 link_with: lib_common,
356 implicit_include_directories: false,
357 include_directories: inc_conf,
358 build_by_default: false,
361 lib_tincd = static_library(
364 dependencies: deps_tincd,
365 link_with: lib_common,
366 c_args: cc_flags_tincd,
367 implicit_include_directories: false,
368 include_directories: inc_conf,
369 build_by_default: false,
372 exe_tinc = executable(
374 sources: 'tincctl.c',
375 dependencies: deps_tinc,
377 implicit_include_directories: false,
378 include_directories: inc_conf,
380 install_dir: dir_sbin,
383 exe_tincd = executable(
386 dependencies: deps_tincd,
387 link_with: lib_tincd,
388 c_args: cc_flags_tincd,
389 implicit_include_directories: false,
390 include_directories: inc_conf,
392 install_dir: dir_sbin,
395 exe_sptps_test = executable(
397 sources: 'sptps_test.c',
398 dependencies: deps_lib_common,
399 link_with: lib_common,
400 implicit_include_directories: false,
401 include_directories: inc_conf,
402 build_by_default: false,
405 exe_sptps_keypair = executable(
407 sources: 'sptps_keypair.c',
408 dependencies: deps_lib_common,
409 link_with: lib_common,
410 implicit_include_directories: false,
411 include_directories: inc_conf,
412 build_by_default: false,
415 if os_name == 'linux'
416 dep_rt = cc.find_library('rt')
418 exe_sptps_speed = executable(
420 sources: 'sptps_speed.c',
421 dependencies: [deps_lib_common, dep_rt],
422 link_with: lib_common,
423 implicit_include_directories: false,
424 include_directories: inc_conf,
425 build_by_default: false,
428 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)