Krolyxon
Commit 045abbd

Branches

Refs →

nsxivetcwoodpeckertry-all-builds.sh

38 lines · 915 B · Bourne Again Shell (bash)

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
6set -- $(grep -o '^HAVE_[[:alpha:]]* ' config.mk)
7CFLAGS="$(sed '/^#/d' etc/woodpecker/CFLAGS | paste -d ' ' -s)"
8z=$(echo "2 ^ $#" | bc)
9
10print_opt_name() {
11 shift "$(( $1 + 1 ))"
12 printf "%s=" "$1"
13}
14
15print_opt_arg() {
16 bn=$(echo "$1 / (2 ^ $2)" | bc)
17 printf "%d " $(( bn % 2 ))
18}
19
20n=0
21while [ "$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))
38done >/dev/null