summaryrefslogtreecommitdiff
path: root/config.sub
blob: d5a9596be7bc1bbfd6b2e04f7f93ea95ee236e05 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh
#
# GMP config.sub wrapper.


# Copyright 2000, 2001 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# The GNU MP Library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.


# Usage: config.sub CPU-VENDOR-OS
#        config.sub ALIAS
#
# Validate and canonicalize the given configuration name, with special
# handling for GMP extra CPU names.
#
# When the CPU isn't special the whole name is simply passed straight
# through to configfsf.sub.
#
# When the CPU is a GMP extra, configfsf.sub is run on a similar CPU that it
# will recognise.  For example "athlon-pc-freebsd3.5" is validated using
# "i386-pc-freebsd3.5".
#
# Any canonicalizations made by configfsf.sub are preserved.  For example
# given "athlon-linux", configfsf.sub is called with "i386-linux" and will
# give back "i386-pc-linux-gnu".  "athlon" is then reinstated, so we print
# "athlon-pc-linux-gnu".


# Expect to find configfsf.sub in the same directory as this config.sub
configfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`"
if test "$configfsf_sub" = "$0"; then
  echo "Cannot derive configfsf.sub from $0" 1>&2
  exit 1
fi
if test -f "$configfsf_sub"; then
  :
else
  echo "$configfsf_sub not found" 1>&2
  exit 1
fi

# Always run configfsf.sub with $SHELL, like autoconf does for config.sub
SHELL=${CONFIG_SHELL-/bin/sh}

# Identify ourselves on --version, --help, etc
case "$1" in
"" | -*)
  echo "(GNU MP wrapped config.sub)" 1>&2
  $SHELL $configfsf_sub "$@"
  exit
  ;;
esac

given_full="$1"
given_cpu=`echo "$given_full" | sed 's/-.*$//'`
given_rest=`echo "$given_full" | sed 's/^[^-]*//'`


# Aliases for GMP extras
case "$given_cpu" in
p5 | p54)   given_cpu=pentium ;;
p55)        given_cpu=pentiummmx ;;
p6)         given_cpu=pentiumpro ;;
pentiumii)  given_cpu=pentium2 ;;
pentiumiii) given_cpu=pentium3 ;;
esac
given_full="$given_cpu$given_rest"


# GMP extras and what to use for the config.sub test
case "$given_cpu" in
pentium | pentiummmx | pentiumpro | pentium[234] | k[56] | k6[23] | athlon)
  test_cpu=i386 ;;
power[12] | power2sc)
  test_cpu=power ;;
powerpc64)
  test_cpu=powerpc ;;
sparcv8 | supersparc | microsparc | ultrasparc | ultrasparc[123])
  test_cpu=sparc ;;
sh2)
  test_cpu=sh ;;

*)
  # Don't need or want to change the given name, just run configfsf.sub
  $SHELL $configfsf_sub "$given_full"
  if test $? = 0; then
    exit 0
  else
    echo "(GNU MP wrapped config.sub, testing \"$given_full\")"
    exit 1
  fi
esac


test_full="$test_cpu$given_rest"
canonical_full=`$SHELL $configfsf_sub "$test_full"`
if test $? = 0; then
  :
else
  echo "(GNU MP wrapped config.sub, testing \"$given_full\" as \"$test_full\")"
  exit 1
fi

canonical_rest=`echo "$canonical_full" | sed 's/^[^-]*//'`
echo "$given_cpu$canonical_rest"
exit 0



# Local variables:
# fill-column: 76
# End: