summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-01-24 03:34:01 +0000
committermidipix <writeonce@midipix.org>2020-01-24 21:14:10 +0000
commit13db49f0b2411d3c0d56ae7f3f0b32b071575b30 (patch)
treea1a93852634a4b6cae2997e3f5288bc7aaf797d7
parentfc8b64f0bb63cc65501fb386937a00bc537ae458 (diff)
downloadbautomake-13db49f0b2411d3c0d56ae7f3f0b32b071575b30.tar.bz2
bautomake-13db49f0b2411d3c0d56ae7f3f0b32b071575b30.tar.xz
config.sub: initial implementation.
-rwxr-xr-xsrc/config.sub89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/config.sub b/src/config.sub
new file mode 100755
index 0000000..325531a
--- /dev/null
+++ b/src/config.sub
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# config.sub: a neutral implementation for modern (cross-)systems.
+# any-target: all are assumed to be supported, no door-keeper failures.
+
+# this file is covered by COPYING.BAUTOMAKE.
+
+
+set -eu
+
+mb_script="$0"
+mb_status=1
+mb_dstamp='2020-01-18'
+
+mb_target="${1:-}"
+mb_extarg="${2:-}"
+
+export LC_ALL=C
+
+
+config_usage()
+{
+ printf 'usage:\n' >&2
+ printf '\t%s [OPTION]\n' "$mb_script" >&2
+ printf '\t%s (cross-)target-alias\n\n' "$mb_script" >&2
+
+ printf 'Options:\n' >&2
+ printf '\t%s\n' \
+ '-h, --help' \
+ '-t, --time-stamp' \
+ '-v, --version' \
+ >&2
+
+ printf '\nThis is a neutral config.sub implementation for modern (cross-)systems.' >&2
+ printf '\nAll (cross-)targets are assumed to be supported, and there are no door-keeper failures.\n\n' >&2
+
+ printf 'pkgsite: https://git.foss21.org/bautomake\n' >&2
+ printf 'pkgbugs: bugs.automake@foss21.org\n' >&2
+
+ exit ${mb_status}
+}
+
+
+for arg ; do
+ case "$arg" in
+ -h | --help)
+ mb_status=0
+ config_usage
+ ;;
+
+ -t | --time-stamp)
+ printf '%s\n' "$mb_dstamp"
+ exit 0
+ ;;
+
+ -v | --version)
+ printf 'foss21.org config.sub (%s)\n' "$mb_dstamp"
+ exit 0
+ ;;
+
+ -*)
+ printf '%s: the argument `%s is not supported.\n\n' "$mb_script" "$arg'" >&2
+ exit 2
+ esac
+done
+
+
+# required target argument
+if [ -z "$mb_target" ]; then
+ config_usage
+fi
+
+# no unused arguments
+if [ -n "$mb_extarg" ]; then
+ mb_status=2
+ config_usage
+fi
+
+# validation
+if [ "$mb_target" != ${mb_target%% *} ]; then
+ printf '%s: input error: target alias may not contain spaces.\n\n' "$mb_script" >&2
+ exit 2
+fi
+
+# compatible output
+printf '%s\n' "$mb_target"
+
+# all done
+exit 0