Commit 60a89ccb02

60a89ccb02de0b065440bdd805e5408dbf603c80

parent: 8356b2b726

Unsigned

Ilkay Alakay <ilkay@exherbo.domain.foo> · 2026-10-02 14:38 UTC

ilkay/imake: update imake

Layout: unified · split

imake +38 −14
@@ -3,30 +3,54 @@
3 3
4DIR="$(pwd)" 4DIR="$(pwd)"
5IMAKEFILE="$DIR/IMakefile" 5IMAKEFILE="$DIR/IMakefile"
6TARGET="${1:-compile}"
6 7
7if [[ ! -f "$IMAKEFILE" ]]; then 8if [[ ! -f "$IMAKEFILE" ]]; then
8 echo "imake: IMakefile not found in $DIR" >&2 9 echo "imake: IMakefile not found in $DIR" >&2
9 exit 1 10 exit 1
10fi 11fi
11 12
12while IFS= read -r line || [[ -n "$line" ]]; do 13if ! grep -qE "^${TARGET}:" "$IMAKEFILE"; then
13 [[ -z "$line" ]] && continue 14 echo "imake: *** no rule to make target '$TARGET'. stop." >&2
15 exit 1
16fi
14 17
15 printf '%s:\n' "$line" 18in_target=0
16 19
17 output=$(bash -c "$line" 2>&1) 20while IFS= read -r line || [[ -n "$line" ]]; do
18 status=$? 21 [[ "$line" =~ ^[[:space:]]*$ ]] && continue
22 [[ "$line" =~ ^[[:space:]]*# ]] && continue
19 23
20 if [[ -n "$output" ]]; then 24 if [[ "$line" =~ ^([a-zA-Z0-9_-]+):[[:space:]]*$ ]]; then
21 while IFS= read -r output_line || [[ -n "$output_line" ]]; do 25 current_target="${BASH_REMATCH[1]}"
22 printf ' %s\n' "$output_line" 26 if [[ "$current_target" == "$TARGET" ]]; then
23 done <<< "$output" 27 in_target=1
24 else 28 else
25 printf ' \n' 29 in_target=0
30 fi
31 continue
26 fi 32 fi
27 33
28 if [[ $status -ne 0 ]]; then 34 if [[ $in_target -eq 1 ]]; then
29 printf ' Command failed with exit code %d\n' "$status" 35 [[ "$line" =~ ^[[:space:]]*(.*)$ ]]
30 exit "$status" 36 cmd_print="${BASH_REMATCH[1]}"
37
38 printf '%s:\n' "$cmd_print"
39
40 output=$(bash -c "$line" 2>&1)
41 status=$?
42
43 if [[ -n "$output" ]]; then
44 while IFS= read -r output_line || [[ -n "$output_line" ]]; do
45 printf ' %s\n' "$output_line"
46 done <<< "$output"
47 else
48 printf ' \n'
49 fi
50
51 if [[ $status -ne 0 ]]; then
52 printf ' command failed with exit code %d\n' "$status"
53 exit "$status"
54 fi
31 fi 55 fi
32done < "$IMAKEFILE" 56done < "$IMAKEFILE"