1#! /bin/sh
2#
3# GMP config.sub wrapper.
4
5
6# Copyright 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
7#
8# This file is part of the GNU MP Library.
9#
10# The GNU MP Library is free software; you can redistribute it and/or modify
11# it under the terms of the GNU Lesser General Public License as published
12# by the Free Software Foundation; either version 2.1 of the License, or (at
13# your option) any later version.
14#
15# The GNU MP Library is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18# License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public License
21# along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
22# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23# MA 02110-1301, USA.
24
25
26# Usage: config.sub CPU-VENDOR-OS
27#        config.sub ALIAS
28#
29# Validate and canonicalize the given configuration name, with special
30# handling for GMP extra CPU names.
31#
32# When the CPU isn't special the whole name is simply passed straight
33# through to configfsf.sub.
34#
35# When the CPU is a GMP extra, configfsf.sub is run on a similar CPU that it
36# will recognise.  For example "athlon-pc-freebsd3.5" is validated using
37# "i386-pc-freebsd3.5".
38#
39# Any canonicalizations made by configfsf.sub are preserved.  For example
40# given "athlon-linux", configfsf.sub is called with "i386-linux" and will
41# give back "i386-pc-linux-gnu".  "athlon" is then reinstated, so we print
42# "athlon-pc-linux-gnu".
43
44
45# Expect to find configfsf.sub in the same directory as this config.sub
46configfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`"
47if test "$configfsf_sub" = "$0"; then
48  echo "Cannot derive configfsf.sub from $0" 1>&2
49  exit 1
50fi
51if test -f "$configfsf_sub"; then
52  :
53else
54  echo "$configfsf_sub not found" 1>&2
55  exit 1
56fi
57
58# Always run configfsf.sub with $SHELL, like autoconf does for config.sub
59SHELL=${CONFIG_SHELL-/bin/sh}
60
61# Identify ourselves on --version, --help, etc
62case "$1" in
63"" | -*)
64  echo "(GNU MP wrapped config.sub)" 1>&2
65  $SHELL $configfsf_sub "$@"
66  exit
67  ;;
68esac
69
70given_full="$1"
71given_cpu=`echo "$given_full" | sed 's/-.*$//'`
72given_rest=`echo "$given_full" | sed 's/^[^-]*//'`
73
74
75# Aliases for GMP extras
76case "$given_cpu" in
77  # configfsf.sub turns p5 into i586, instead use our exact cpu type
78  p5 | p54)   given_cpu=pentium ;;
79  p55)        given_cpu=pentiummmx ;;
80
81  # configfsf.sub turns p6, pentiumii and pentiumiii into i686, instead use
82  # our exact cpu types
83  p6)         given_cpu=pentiumpro ;;
84  pentiumii)  given_cpu=pentium2 ;;
85  pentiumiii) given_cpu=pentium3 ;;
86esac
87given_full="$given_cpu$given_rest"
88
89
90# GMP extras and what to use for the config.sub test
91case "$given_cpu" in
92itanium | itanium2)
93  test_cpu=ia64 ;;
94pentium | pentiummmx | pentiumpro | pentium[234] | k[56] | k6[23] | athlon | viac3*)
95  test_cpu=i386 ;;
96power[2-9] | power2sc)
97  test_cpu=power ;;
98powerpc401 | powerpc403 | powerpc405 | \
99powerpc505 | \
100powerpc601 | powerpc602  | \
101powerpc603 | powerpc603e | \
102powerpc604 | powerpc604e | \
103powerpc620 | powerpc630  | powerpc970  | \
104powerpc740 | powerpc7400 | powerpc7450 | powerpc750  | \
105powerpc801 | powerpc821 | powerpc823  | powerpc860 | \
106powerpc64)
107  test_cpu=powerpc ;;
108sparcv8 | supersparc | microsparc | \
109ultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct1)
110  test_cpu=sparc ;;
111sh2)
112  test_cpu=sh ;;
113
114*)
115  # Don't need or want to change the given name, just run configfsf.sub
116  $SHELL $configfsf_sub "$given_full"
117  if test $? = 0; then
118    exit 0
119  else
120    echo "(GNU MP wrapped config.sub, testing \"$given_full\")"
121    exit 1
122  fi
123esac
124
125
126test_full="$test_cpu$given_rest"
127canonical_full=`$SHELL $configfsf_sub "$test_full"`
128if test $? = 0; then
129  :
130else
131  echo "(GNU MP wrapped config.sub, testing \"$given_full\" as \"$test_full\")"
132  exit 1
133fi
134
135canonical_rest=`echo "$canonical_full" | sed 's/^[^-]*//'`
136echo "$given_cpu$canonical_rest"
137exit 0
138
139
140
141# Local variables:
142# fill-column: 76
143# End:
144