summaryrefslogtreecommitdiff
path: root/src/config.sub
blob: 325531aa6b2be1611be084566f0b0dc44339d2e3 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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