CI: fix running clang-tidy on full sources
[tinc] / .ci / conf.sh
1 #!/bin/sh
2
3 set -eu
4
5 add_flag() {
6   printf ' %s ' "$@"
7 }
8
9 conf_linux() {
10   . /etc/os-release
11
12   if type rpm >&2; then
13     # CentOS 7 has OpenSSL 1.1 installed in a non-default location.
14     if [ -d /usr/include/openssl11 ]; then
15       add_flag --with-openssl-include=/usr/include/openssl11
16     fi
17
18     if [ -d /usr/lib64/openssl11 ]; then
19       add_flag --with-openssl-lib=/usr/lib64/openssl11
20     fi
21
22     # RHEL 8 does not ship miniupnpc.
23     if rpm -q miniupnpc-devel >&2; then
24       add_flag --enable-miniupnpc
25     fi
26   else
27     # vde2 is available everywhere except the RHEL family.
28     add_flag --enable-vde
29   fi
30
31   # Cross-compilation.
32   if [ -n "${HOST:-}" ]; then
33     case "$HOST" in
34     armhf) triplet=arm-linux-gnueabihf ;;
35     mipsel) triplet=mipsel-linux-gnu ;;
36     *) exit 1 ;;
37     esac
38
39     add_flag --host="$triplet"
40   fi
41
42   add_flag --enable-uml "$@"
43 }
44
45 conf_windows() {
46   add_flag \
47     --enable-miniupnpc \
48     --disable-readline \
49     --with-curses-include=/mingw64/include/ncurses \
50     "$@"
51 }
52
53 conf_macos() {
54   add_flag \
55     --with-openssl="$(brew --prefix openssl)" \
56     --with-miniupnpc="$(brew --prefix miniupnpc)" \
57     --enable-tunemu \
58     --enable-miniupnpc \
59     "$@"
60 }
61
62 case "$(uname -s)" in
63 Linux) conf_linux "$@" ;;
64 MINGW*) conf_windows "$@" ;;
65 Darwin) conf_macos "$@" ;;
66 *) exit 1 ;;
67 esac