Debian Codegraph @

doc/example/compiler-etc-dependencies/example-sessions/common_code.sh

raw
1 # shellcheck shell=sh
2 #
3 # This should be sourced from the other scripts
4
5 # Make sure TMP_MODVERSION and TMP_STRATEGY are set
6 if [ -z "$TMP_MODVERSION" ]; then
7 echo >&2 "ERROR: TMP_MODVERSION not set"
8 exit
9 fi
10
11 if [ -z "$TMP_STRATEGY" ]; then
12 echo >&2 "ERROR: TMP_STRATEGY not set"
13 exit
14 fi
15
16 # Set prompt
17 TMP_PROMPT="mod${TMP_MODVERSION}"
18 case $TMP_STRATEGY in
19 flavours)
20 #This really means MODVERSION is flavours version
21 TMP_PROMPT="${TMP_PROMPT}-flavours"
22 ;;
23 homebrewed|modulerc|modulepath)
24 TMP_PROMPT="${TMP_PROMPT} ($TMP_STRATEGY)"
25 ;;
26 *)
27 echo >&2 "ERROR: unrecognized value '$TMP_STRATEGY' for TMP_STRATEGY"
28 exit 1
29 ;;
30 esac
31
32 #Define do_cmd function
33 do_cmd()
34 { cmd="$*"
35 echo "[$TMP_PROMPT]$ $cmd"
36 $cmd
37 }
38
39 #Define variables GCCGNU to be gcc or gnu
40 case $TMP_STRATEGY in
41 flavours)
42 GCCGNU=gnu
43 ;;
44 *)
45 # shellcheck disable=SC2034
46 GCCGNU=gcc
47 ;;
48 esac
49
50 #Define AUTOFLAG to be "" or --auto
51 case $TMP_MODVERSION in
52 3)
53 AUTOFLAG=
54 ;;
55 4)
56 case $TMP_STRATEGY in
57 flavours)
58 AUTOFLAG=
59 ;;
60 *)
61 # shellcheck disable=SC2034
62 AUTOFLAG="--auto"
63 ;;
64 esac
65 ;;
66 esac
67