# Dependencies
+## Required
+
Before you can start compiling tinc from a fresh git clone, you have
to install the very latest versions of the following packages:
-- `meson`
-- `ninja`
+- `meson` or `muon` (read below)
+- `ninja` or `samurai`
- `pkgconf` or `pkg-config`
- `GCC` or `Clang` (any version with C11 support, although older versions might work)
- `OpenSSL`\* (1.1.0+) or `LibreSSL` or `libgcrypt` (not needed if legacy protocol is disabled)
+### No Python?
+
+If you're on a constrained system that doesn't have (or cannot run) Python, you can try building tinc with [muon][muon],
+which is a pure C reimplementation of the same idea.
+Please note that `meson` is considered to be the main way of building tinc, and `muon` is supported on a best-effort basis.
+
+[muon]: https://git.sr.ht/~lattis/muon
+
+## Optional
+
Plus a few optional dependencies. Support for them will be enabled if they're present:
- `ncurses` or `PDCurses`
project('tinc', 'c',
- version: run_command([find_program('python3'), 'version.py', 'short'], check: true).stdout(),
+ version: '1.1pre18',
license: 'GPL-2.0-or-later',
meson_version: '>=0.51',
default_options: [
cpu_family = host_machine.cpu_family()
cc_name = cc.get_id()
-python = find_program('python3')
-if meson_version.version_compare('>=0.55')
- python_path = python.full_path()
+python = find_program('python3', required: false)
+if python.found()
+ if meson_version.version_compare('>=0.55')
+ python_path = python.full_path()
+ else
+ python_path = python.path()
+ endif
else
- python_path = python.path()
+ python_path = ''
endif
cc_defs = ['-D_GNU_SOURCE']
subdir('systemd')
endif
-run_target('reformat', command: [
- python,
- '@SOURCE_ROOT@/lint.py',
- '--fix',
-])
-
-run_target('lint', command: [
- python,
- '@SOURCE_ROOT@/lint.py',
-])
+if python.found()
+ run_target('reformat', command: [
+ python,
+ '@SOURCE_ROOT@/lint.py',
+ '--fix',
+ ])
+
+ run_target('lint', command: [
+ python,
+ '@SOURCE_ROOT@/lint.py',
+ ])
+endif
if meson_version.version_compare('>=0.53')
summary({
src_lib_common += vcs_tag(
command: [python_path, src_root / 'version.py'],
- fallback: 'unknown',
input: '../version_git.h.in',
output: 'version_git.h',
)
-subdir('integration')
+if python.found()
+ subdir('integration')
+endif
+
subdir('unit')
#!/usr/bin/env python3
-"""Print current tinc version for using in build scripts.
-
-First try to determine the latest version using git tags. If this fails (because
-the .git directory is missing, git is not installed, or for some other reason),
-fall back to using the VERSION file. If it is not present or could not be read,
-use 'unknown'.
-"""
+"""Print current tinc version for using in build scripts."""
from os import path, environ
-from sys import argv, stderr
import subprocess as subp
-import typing as T
PREFIX = "release-"
SOURCE_ROOT = path.dirname(path.realpath(__file__))
"--match=" + PREFIX + "*",
]
-if "short" in argv:
- cmd.append("--abbrev=0")
-
-version: T.Optional[str] = None
-
-try:
- result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=False)
- if not result.returncode:
- version = result.stdout
-except FileNotFoundError:
- pass
-
-if not version:
- try:
- with open(path.join(SOURCE_ROOT, "VERSION"), "r", encoding="utf-8") as f:
- version = f.read().strip()
- except OSError as e:
- print("could not read version from file", e, file=stderr)
-elif version.startswith(PREFIX):
- version = version[len(PREFIX) :].strip()
-
-print(version if version else "unknown", end="")
+result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=True)
+version = result.stdout.strip().removeprefix("release-")
+print(version)