| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Shell script that checks for all possible build combination with TCC. |
| 4 | # Usage: call the script while in the nsxiv root directory |
| 5 | |
| 6 | set -- $(grep -o '^HAVE_[[:alpha:]]* ' config.mk) |
| 7 | CFLAGS="$(sed '/^#/d' etc/woodpecker/CFLAGS | paste -d ' ' -s)" |
| 8 | z=$(echo "2 ^ $#" | bc) |
| 9 | |
| 10 | print_opt_name() { |
| 11 | shift "$(( $1 + 1 ))" |
| 12 | printf "%s=" "$1" |
| 13 | } |
| 14 | |
| 15 | print_opt_arg() { |
| 16 | bn=$(echo "$1 / (2 ^ $2)" | bc) |
| 17 | printf "%d " $(( bn % 2 )) |
| 18 | } |
| 19 | |
| 20 | n=0 |
| 21 | while [ "$n" -lt "$z" ]; do |
| 22 | i=0 |
| 23 | while [ "$i" -lt "$#" ]; do |
| 24 | print_opt_name "$i" "$@" |
| 25 | print_opt_arg "$n" "$i" |
| 26 | i=$((i + 1)) |
| 27 | done | tee "/dev/stderr" | ( |
| 28 | make clean |
| 29 | if ! xargs make -j"$(nproc)" CC=tcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS"; then |
| 30 | echo "[FAILED]" >&2 |
| 31 | exit 1 |
| 32 | else |
| 33 | echo "[SUCCESS]" >&2 |
| 34 | fi |
| 35 | ) |
| 36 | [ "$?" -ne 0 ] && exit "$?" |
| 37 | n=$((n + 1)) |
| 38 | done >/dev/null |