|
Lucio Andrés Illanes Albornoz |
83abda |
#!/bin/sh
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# config.guess: an alternate implementation for modern (cross-)systems.
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# modern-hosts: machine detection either via slibtool's --dumpmachine
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# output, or by way of a native compiler that implements
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# the -dumpmachine switch.
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# this file is covered by COPYING.BAUTOMAKE.
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# the order of attempted things:
|
|
Lucio Andrés Illanes Albornoz |
83abda |
#
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# $NATIVE_CC
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# $CC_FOR_BUILD
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# c99
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# cc
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# ucc
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# gcc
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# clang
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# cparser
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
set -eu
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_script="$0"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_status=1
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_dstamp='2021-06-11'
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_target=
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_extarg="${1:-}"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
export LC_ALL=C
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_usage()
|
|
Lucio Andrés Illanes Albornoz |
83abda |
{
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf 'usage:\n' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf 'Options:\n' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\t%s\n' \
|
|
Lucio Andrés Illanes Albornoz |
83abda |
'-h, --help' \
|
|
Lucio Andrés Illanes Albornoz |
83abda |
'-t, --time-stamp' \
|
|
Lucio Andrés Illanes Albornoz |
83abda |
'-v, --version' \
|
|
Lucio Andrés Illanes Albornoz |
83abda |
>&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\nThis is an alternate config.guess implementation for modern (cross-)systems.' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\nA native system is identified either via `slibtool --dumpmachine`, or by way' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\n of the -dumpmachine output of its priority native compiler.\n\n' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf 'Native compilers are tried in the following order:\n' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\t%s\n' '$NATIVE_CC' '$CC_FOR_BUILD' 'c99' 'cc' 'ucc' 'gcc' 'clang' 'cparser' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\npkgsite: https://git.foss21.org/bautomake' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '\npkgbugs: bugs.automake@foss21.org\n\n' >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit ${mb_status}
|
|
Lucio Andrés Illanes Albornoz |
83abda |
}
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_output()
|
|
Lucio Andrés Illanes Albornoz |
83abda |
{
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '%s\n' "$mb_target"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit 0
|
|
Lucio Andrés Illanes Albornoz |
83abda |
}
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
for arg ; do
|
|
Lucio Andrés Illanes Albornoz |
83abda |
case "$arg" in
|
|
Lucio Andrés Illanes Albornoz |
83abda |
-h | --help)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_status=0
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_usage
|
|
Lucio Andrés Illanes Albornoz |
83abda |
;;
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
-t | --time-stamp)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '%s\n' "$mb_dstamp"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit 0
|
|
Lucio Andrés Illanes Albornoz |
83abda |
;;
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
-v | --version)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf 'foss21.org config.guess (%s)\n' "$mb_dstamp"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit 0
|
|
Lucio Andrés Illanes Albornoz |
83abda |
;;
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
-*)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '%s: the argument `%s is not supported.\n\n' "$mb_script" "$arg'" >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit 2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
esac
|
|
Lucio Andrés Illanes Albornoz |
83abda |
done
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# no unused arguments
|
|
Lucio Andrés Illanes Albornoz |
83abda |
if [ -n "$mb_extarg" ]; then
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_status=2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_usage
|
|
Lucio Andrés Illanes Albornoz |
83abda |
fi
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# try slibtool
|
|
Lucio Andrés Illanes Albornoz |
83abda |
if command -v slibtool > /dev/null 2>&1; then
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_target=$(slibtool --dumpmachine 2>/dev/null || true)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
if [ -n "$mb_target" ]; then
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_output
|
|
Lucio Andrés Illanes Albornoz |
83abda |
fi
|
|
Lucio Andrés Illanes Albornoz |
83abda |
fi
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# explicit
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_native_cc="${NATIVE_CC:-false}"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_cc_for_build="${CC_FOR_BUILD:-false}"
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# try
|
|
Lucio Andrés Illanes Albornoz |
83abda |
for mb_cc_guess in "$mb_native_cc" "$mb_cc_for_build" c99 cc ucc gcc clang cparser; do
|
|
Lucio Andrés Illanes Albornoz |
83abda |
mb_target=$($mb_cc_guess -dumpmachine 2>/dev/null || true)
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
if [ -n "$mb_target" ]; then
|
|
Lucio Andrés Illanes Albornoz |
83abda |
config_output
|
|
Lucio Andrés Illanes Albornoz |
83abda |
fi
|
|
Lucio Andrés Illanes Albornoz |
83abda |
done
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
|
|
Lucio Andrés Illanes Albornoz |
83abda |
# fail
|
|
Lucio Andrés Illanes Albornoz |
83abda |
printf '%s: native compiler not found, or does not support -dumpmachine.\n\n' "$mb_script" >&2
|
|
Lucio Andrés Illanes Albornoz |
83abda |
exit 2
|