Blame src/config.sub

13db49
#!/bin/sh
13db49
13db49
# config.sub: a neutral implementation for modern (cross-)systems.
13db49
# any-target: all are assumed to be supported, no door-keeper failures.
13db49
13db49
# this file is covered by COPYING.BAUTOMAKE.
13db49
13db49
13db49
set -eu
13db49
13db49
mb_script="$0"
13db49
mb_status=1
13db49
mb_dstamp='2020-01-18'
13db49
13db49
mb_target="${1:-}"
13db49
mb_extarg="${2:-}"
13db49
13db49
export LC_ALL=C
13db49
13db49
13db49
config_usage()
13db49
{
13db49
	printf 'usage:\n'                                   >&2
13db49
	printf '\t%s [OPTION]\n' "$mb_script"               >&2
13db49
	printf '\t%s (cross-)target-alias\n\n' "$mb_script" >&2
13db49
13db49
	printf 'Options:\n' >&2
13db49
	printf '\t%s\n'            \
13db49
		'-h, --help'       \
13db49
		'-t, --time-stamp' \
13db49
		'-v, --version'    \
13db49
		>&2
13db49
13db49
	printf '\nThis is a neutral config.sub implementation for modern (cross-)systems.' >&2
13db49
	printf '\nAll (cross-)targets are assumed to be supported, and there are no door-keeper failures.\n\n' >&2
13db49
13db49
	printf 'pkgsite: https://git.foss21.org/bautomake\n' >&2
13db49
	printf 'pkgbugs: bugs.automake@foss21.org\n'         >&2
13db49
13db49
	exit ${mb_status}
13db49
}
13db49
13db49
13db49
for arg ; do
13db49
	case "$arg" in
13db49
		-h | --help)
13db49
			mb_status=0
13db49
			config_usage
13db49
			;;
13db49
13db49
		-t | --time-stamp)
13db49
			printf '%s\n' "$mb_dstamp"
13db49
			exit 0
13db49
			;;
13db49
13db49
		-v | --version)
13db49
			printf 'foss21.org config.sub (%s)\n' "$mb_dstamp"
13db49
			exit 0
13db49
			;;
13db49
13db49
		-*)
13db49
			printf '%s: the argument `%s is not supported.\n\n' "$mb_script" "$arg'" >&2
13db49
			exit 2
13db49
	esac
13db49
done
13db49
13db49
13db49
# required target argument
13db49
if [ -z "$mb_target" ]; then
13db49
	config_usage
13db49
fi
13db49
13db49
# no unused arguments
13db49
if [ -n "$mb_extarg" ]; then
13db49
	mb_status=2
13db49
	config_usage
13db49
fi
13db49
13db49
# validation
13db49
if [ "$mb_target" != ${mb_target%% *} ]; then
13db49
	printf '%s: input error: target alias may not contain spaces.\n\n' "$mb_script" >&2
13db49
	exit 2
13db49
fi
13db49
13db49
# compatible output
13db49
printf '%s\n' "$mb_target"
13db49
13db49
# all done
13db49
exit 0