blob: d9845faa60ff05248c5e0a39657bc5bc69f4fe29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env bash
set -e
tool=${1##*/}
if [[ $tool = *-host.tool ]]; then prefix=H; else prefix=T; fi
case "$tool" in
compile*.tool)
vars=(CC CFLAGS CPPFLAGS)
cmd='"$CC" -MMD -MF - "${CFLAGS[@]}" "${CPPFLAGS[@]}" -c -o "$3" "${1%.o}.c"'
;;
link-*.tool)
vars=(CC LDFLAGS LDLIBS)
if [[ $1 = *-library* ]]; then shared='-shared '; else shared=''; fi
cmd='"$CC" "${LDFLAGS[@]}" '"$shared"'"${objects[@]}" "${LDLIBS[@]}" -o "$3"'
;;
*)
echo "Invalid tool name $1" >&2
exit 1 ;;
esac
for v in "${vars[@]}"; do cmd=${cmd//$v/$prefix$v}; done
redo-ifchange .vars.rc
. ./.vars.rc
exec >"$3"
echo "#generated by $0 $1"
declare -p "${vars[@]/#/$prefix}"
echo "cmd=($cmd)"
if command -v redo-stamp &>/dev/null; then redo-stamp <"$3"; fi
|