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)
70 'struct ether_header',
75 'struct nd_neighbor_solicit',
80 subdir('chacha-poly1305')
121 'multicast_device.c',
134 'raw_socket_device.c',
139 cc_flags_tincd = cc_flags
143 deps_tincd = [cc.find_library('m', required: false)]
145 if os_name in ['linux', 'android']
147 elif os_name.endswith('bsd') or os_name in ['dragonfly', 'darwin']
149 elif os_name == 'sunos'
151 elif os_name == 'windows'
155 foreach h : check_headers
157 cdata.set('HAVE_' + h.to_upper().underscorify(),
159 description: '#include <' + h + '>')
163 confdata = configuration_data()
164 confdata.merge_from(cdata)
165 configure_file(output: 'meson_config.h', configuration: confdata)
168 #include "@0@/src/meson_config.h"
169 #include "@1@/have.h"
170 '''.format(build_root, meson.current_source_dir())
172 foreach f : check_functions
173 if f == 'fork' and os_name == 'windows'
174 message('MinGW does not have correct definition for fork()')
176 if cc.has_function(f, prefix: have_prefix, args: cc_defs)
177 cdata.set('HAVE_' + f.to_upper(),
179 description: 'function ' + f)
184 if cc.has_function('res_init', prefix: '''
185 #include <netinet/in.h>
188 cdata.set('HAVE_DECL_RES_INIT', 1)
191 foreach type : check_types
192 if cc.has_type(type, prefix: have_prefix, args: cc_defs)
193 name = 'HAVE_' + type.to_upper().underscorify()
194 cdata.set(name, 1, description: type)
198 if not cdata.has('HAVE_GETOPT_H') or not cc.has_function('getopt_long', prefix: have_prefix, args: cc_defs)
199 src_lib_common += ['getopt.c', 'getopt1.c']
202 if not opt_miniupnpc.disabled()
203 dep_miniupnpc = dependency('miniupnpc', required: false, static: static)
204 if not dep_miniupnpc.found()
205 # No pkg-config files on MinGW
206 dep_miniupnpc = cc.find_library('miniupnpc', required: opt_miniupnpc, static: static)
208 if dep_miniupnpc.found()
209 src_tincd += 'upnp.c'
211 dependency('threads', static: static),
215 cc_flags_tincd += '-DMINIUPNP_STATICLIB'
217 cdata.set('HAVE_MINIUPNPC', 1)
221 if opt_curses.auto() and os_name == 'windows'
222 message('curses does not link under MinGW')
224 # The meta-dependency covers more alternatives, but is only available in 0.54+
225 curses_name = meson_version.version_compare('>=0.54') ? 'curses' : 'ncurses'
226 dep_curses = dependency(curses_name, required: opt_curses, static: static)
227 if dep_curses.found()
228 cdata.set('HAVE_CURSES', 1)
229 deps_tinc += dep_curses
233 # Some distributions do not supply pkg-config files for readline
234 if opt_readline.auto() and os_name == 'windows'
235 message('readline does not link under MinGW')
237 dep_readline = dependency('readline', required: opt_readline, static: static)
238 if not dep_readline.found()
239 dep_readline = cc.find_library('readline', required: opt_readline, static: static)
241 if dep_readline.found() and \
242 cc.has_header('readline/readline.h', dependencies: dep_readline) and \
243 cc.has_header('readline/history.h', dependencies: dep_readline)
244 cdata.set('HAVE_READLINE', 1)
245 deps_tinc += dep_readline
249 dep_zlib = dependency('zlib',
252 fallback: ['zlib', 'zlib_dep'])
254 cdata.set('HAVE_ZLIB', 1)
255 deps_tincd += dep_zlib
258 if not opt_lzo.disabled()
259 dep_lzo = dependency('lzo2', required: false, static: static)
260 if not dep_lzo.found()
261 dep_lzo = cc.find_library('lzo2', required: opt_lzo, static: static)
263 if not dep_lzo.found()
264 dep_lzo = dependency('lzo2',
267 fallback: ['lzo2', 'lzo2_dep'])
270 if dep_lzo.type_name() == 'internal' or cc.has_header('lzo/lzo1x.h', dependencies: dep_lzo)
271 cdata.set('LZO1X_H', '<lzo/lzo1x.h>')
272 elif cc.has_header('lzo1x.h', dependencies: dep_lzo)
273 cdata.set('LZO1X_H', '<lzo1x.h>')
275 msg = 'lzo1x.h not found'
282 if cdata.has('LZO1X_H')
283 cdata.set('HAVE_LZO', 1)
284 deps_tincd += dep_lzo
289 dep_lz4 = dependency('liblz4',
292 fallback: ['lz4', 'liblz4_dep'])
294 deps_tincd += dep_lz4
295 cdata.set('HAVE_LZ4', 1)
298 dep_vde = dependency('vdeplug', required: opt_vde, static: static)
299 dep_dl = cc.find_library('dl', required: opt_vde)
300 if dep_vde.found() and dep_dl.found()
301 cdata.set('ENABLE_VDE', 1)
302 src_tincd += 'vde_device.c'
303 deps_tincd += [dep_dl, dep_vde]
307 cdata.set('ENABLE_JUMBOGRAMS', 1)
312 if opt_crypto != 'nolegacy'
313 src_lib_crypto += ['cipher.c', 'digest.c']
318 lib_crypto = static_library(
320 sources: src_lib_crypto,
321 dependencies: dep_crypto,
322 implicit_include_directories: false,
323 include_directories: inc_conf,
324 build_by_default: false,
327 deps_lib_common = [deps_common, dep_crypto]
328 deps_tinc += deps_lib_common
329 deps_tincd += deps_lib_common
331 lib_common = static_library(
333 sources: src_lib_common,
334 dependencies: deps_lib_common,
335 link_with: [lib_ed25519, lib_chacha_poly, lib_crypto],
336 implicit_include_directories: false,
337 include_directories: inc_conf,
338 build_by_default: false,
341 lib_tinc = static_library(
344 dependencies: deps_tinc,
345 link_with: lib_common,
346 implicit_include_directories: false,
347 include_directories: inc_conf,
348 build_by_default: false,
351 lib_tincd = static_library(
354 dependencies: deps_tincd,
355 link_with: lib_common,
356 c_args: cc_flags_tincd,
357 implicit_include_directories: false,
358 include_directories: inc_conf,
359 build_by_default: false,
362 exe_tinc = executable(
364 sources: 'tincctl.c',
365 dependencies: deps_tinc,
367 implicit_include_directories: false,
368 include_directories: inc_conf,
370 install_dir: dir_sbin,
373 exe_tincd = executable(
376 dependencies: deps_tincd,
377 link_with: lib_tincd,
378 c_args: cc_flags_tincd,
379 implicit_include_directories: false,
380 include_directories: inc_conf,
382 install_dir: dir_sbin,
385 exe_sptps_test = executable(
387 sources: 'sptps_test.c',
388 dependencies: deps_lib_common,
389 link_with: lib_common,
390 implicit_include_directories: false,
391 include_directories: inc_conf,
392 build_by_default: false,
395 exe_sptps_keypair = executable(
397 sources: 'sptps_keypair.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 if os_name == 'linux'
406 dep_rt = cc.find_library('rt')
408 exe_sptps_speed = executable(
410 sources: 'sptps_speed.c',
411 dependencies: [deps_lib_common, dep_rt],
412 link_with: lib_common,
413 implicit_include_directories: false,
414 include_directories: inc_conf,
415 build_by_default: false,
418 benchmark('sptps_speed', exe_sptps_speed, timeout: 90)