aboutsummaryrefslogtreecommitdiffstats
path: root/default.tool.do
diff options
context:
space:
mode:
Diffstat (limited to 'default.tool.do')
-rwxr-xr-xdefault.tool.do25
1 files changed, 25 insertions, 0 deletions
diff --git a/default.tool.do b/default.tool.do
new file mode 100755
index 0000000..a4e18e7
--- /dev/null
+++ b/default.tool.do
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange .vars.rc
+if [[ $1 = *-host.tool ]]; then prefix=H; else prefix=T; fi
+case "${1##*/}" 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
+. ./.vars.rc
+exec >"$3"
+echo "#generated by $0 $1"
+declare -p "${vars[@]/#/$prefix}"
+echo "$cmd"
+if command -v redo-stamp &>/dev/null; then redo-stamp <"$3"; fi