xref: /netbsd/external/lgpl3/gmp/dist/config.sub (revision e05a1779)
14a1767b4Smrg#! /bin/sh
24a1767b4Smrg#
3274b3bceSmrg# GMP config.sub wrapper.
4274b3bceSmrg
5274b3bceSmrg
6274b3bceSmrg# Copyright 2000-2003, 2006, 2009-2016 Free Software Foundation, Inc.
732b71e0eSsevan#
8274b3bceSmrg#  This file is part of the GNU MP Library.
932b71e0eSsevan#
10274b3bceSmrg#  The GNU MP Library is free software; you can redistribute it and/or modify
11274b3bceSmrg#  it under the terms of either:
124a1767b4Smrg#
13274b3bceSmrg#    * the GNU Lesser General Public License as published by the Free
14274b3bceSmrg#      Software Foundation; either version 3 of the License, or (at your
15274b3bceSmrg#      option) any later version.
16274b3bceSmrg#
17274b3bceSmrg#  or
18274b3bceSmrg#
19274b3bceSmrg#    * the GNU General Public License as published by the Free Software
20274b3bceSmrg#      Foundation; either version 2 of the License, or (at your option) any
21274b3bceSmrg#      later version.
22274b3bceSmrg#
23274b3bceSmrg#  or both in parallel, as here.
24274b3bceSmrg#
25274b3bceSmrg#  The GNU MP Library is distributed in the hope that it will be useful, but
26274b3bceSmrg#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27274b3bceSmrg#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28274b3bceSmrg#  for more details.
29274b3bceSmrg#
30274b3bceSmrg#  You should have received copies of the GNU General Public License and the
31274b3bceSmrg#  GNU Lesser General Public License along with the GNU MP Library.  If not,
32274b3bceSmrg#  see https://www.gnu.org/licenses/.
334a1767b4Smrg
344a1767b4Smrg
35274b3bceSmrg# Usage: config.sub CPU-VENDOR-OS
36274b3bceSmrg#        config.sub ALIAS
37274b3bceSmrg#
38274b3bceSmrg# Validate and canonicalize the given configuration name, with special
39274b3bceSmrg# handling for GMP extra CPU names.
40274b3bceSmrg#
41274b3bceSmrg# When the CPU isn't special the whole name is simply passed straight
42274b3bceSmrg# through to configfsf.sub.
43274b3bceSmrg#
44274b3bceSmrg# When the CPU is a GMP extra, configfsf.sub is run on a similar CPU that it
45274b3bceSmrg# will recognise.  For example "athlon-pc-freebsd3.5" is validated using
46274b3bceSmrg# "i386-pc-freebsd3.5".
47274b3bceSmrg#
48274b3bceSmrg# Any canonicalizations made by configfsf.sub are preserved.  For example
49274b3bceSmrg# given "athlon-linux", configfsf.sub is called with "i386-linux" and will
50274b3bceSmrg# give back "i386-pc-linux-gnu".  "athlon" is then reinstated, so we print
51274b3bceSmrg# "athlon-pc-linux-gnu".
524a1767b4Smrg
534a1767b4Smrg
54274b3bceSmrg# Expect to find configfsf.sub in the same directory as this config.sub
55274b3bceSmrgconfigfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`"
56274b3bceSmrgif test "$configfsf_sub" = "$0"; then
57274b3bceSmrg  echo "Cannot derive configfsf.sub from $0" 1>&2
5832b71e0eSsevan  exit 1
59274b3bceSmrgfi
60274b3bceSmrgif test -f "$configfsf_sub"; then
61274b3bceSmrg  :
6232b71e0eSsevanelse
63274b3bceSmrg  echo "$configfsf_sub not found" 1>&2
64274b3bceSmrg  exit 1
654a1767b4Smrgfi
664a1767b4Smrg
67274b3bceSmrg# Always run configfsf.sub with $SHELL, like autoconf does for config.sub
68274b3bceSmrgSHELL=${CONFIG_SHELL-/bin/sh}
69274b3bceSmrg
70274b3bceSmrg# Identify ourselves on --version, --help, etc
71274b3bceSmrgcase "$1" in
72274b3bceSmrg"" | -*)
73274b3bceSmrg  echo "(GNU MP wrapped config.sub)" 1>&2
74274b3bceSmrg  $SHELL $configfsf_sub "$@"
75274b3bceSmrg  exit
7632b71e0eSsevan  ;;
7732b71e0eSsevanesac
784a1767b4Smrg
79274b3bceSmrggiven_full="$1"
80274b3bceSmrggiven_cpu=`echo "$given_full" | sed 's/-.*$//'`
81274b3bceSmrggiven_rest=`echo "$given_full" | sed 's/^[^-]*//'`
82274b3bceSmrg
83274b3bceSmrg
84274b3bceSmrg# Aliases for GMP extras
85274b3bceSmrgcase "$given_cpu" in
86274b3bceSmrg  # configfsf.sub turns p5 into i586, instead use our exact cpu type
87274b3bceSmrg  p5 | p54)   given_cpu=pentium ;;
88274b3bceSmrg  p55)        given_cpu=pentiummmx ;;
89274b3bceSmrg
90274b3bceSmrg  # configfsf.sub turns p6, pentiumii and pentiumiii into i686, instead use
91274b3bceSmrg  # our exact cpu types
92274b3bceSmrg  p6)         given_cpu=pentiumpro ;;
93274b3bceSmrg  pentiumii)  given_cpu=pentium2 ;;
94274b3bceSmrg  pentiumiii) given_cpu=pentium3 ;;
95274b3bceSmrgesac
96274b3bceSmrggiven_full="$given_cpu$given_rest"
97274b3bceSmrg
98274b3bceSmrg
99274b3bceSmrg# GMP extras and what to use for the config.sub test
100274b3bceSmrgcase "$given_cpu" in
101274b3bceSmrgitanium | itanium2)
102274b3bceSmrg  test_cpu=ia64 ;;
103274b3bceSmrgpentium | pentiummmx | pentiumpro | pentium[234m] | k[567] | k6[23] | geode | athlon | viac3*)
104274b3bceSmrg  test_cpu=i386 ;;
105274b3bceSmrgathlon64 | atom | silvermont | goldmont | core2 | corei* | opteron | k[89] | k10 | bobcat | jaguar* | bulldozer* | piledriver* | steamroller* | excavator* | zen* | nano | nehalem | westmere | sandybridge* | ivybridge* | haswell* | broadwell* | skylake* | kabylake* | knightslanding)
106274b3bceSmrg  test_cpu=x86_64 ;;
107274b3bceSmrgpower[2-9] | power2sc)
108274b3bceSmrg  test_cpu=power ;;
109274b3bceSmrgpowerpc401 | powerpc403 | powerpc405 | \
110274b3bceSmrgpowerpc505 | \
111274b3bceSmrgpowerpc601 | powerpc602  | \
112274b3bceSmrgpowerpc603 | powerpc603e | \
113274b3bceSmrgpowerpc604 | powerpc604e | \
114274b3bceSmrgpowerpc620 | powerpc630  | powerpc970  | \
115*e05a1779Smacallanpowerpc740 | powerpc7400 | powerpc74[4-5][0-9] | powerpc750  | \
116274b3bceSmrgpowerpc801 | powerpc821 | powerpc823  | powerpc860 | \
117274b3bceSmrgpowerpc64)
118274b3bceSmrg  test_cpu=powerpc ;;
119274b3bceSmrgsparcv8 | supersparc | microsparc | \
120274b3bceSmrgultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct[12345])
121274b3bceSmrg  test_cpu=sparc ;;
122274b3bceSmrgsh2)
123274b3bceSmrg  test_cpu=sh ;;
124274b3bceSmrg
125274b3bceSmrgz900 | z990 | z9 | z10 | z196)
126274b3bceSmrg  test_cpu=s390x;;
127274b3bceSmrgz900esa | z990esa | z9esa | z10esa | z196esa)
128274b3bceSmrg  test_cpu=s390;;
129274b3bceSmrg
130274b3bceSmrgarmsa1 | armxscale | arm9tdmi | arm9te |				\
131274b3bceSmrgarm10* | arm11mpcore | armsa1 | arm1136 | arm1156 | arm1176 |		\
132274b3bceSmrgarmcortex[arm][0-9] | armcortex[arm][0-9][0-9] |			\
133274b3bceSmrgarm*neon | armxgene1 | armexynosm1 | armthunderx)
134274b3bceSmrg  test_cpu="arm";;
135274b3bceSmrg
136274b3bceSmrg*)
137274b3bceSmrg  # Don't need or want to change the given name, just run configfsf.sub
138274b3bceSmrg  $SHELL $configfsf_sub "$given_full"
139274b3bceSmrg  if test $? = 0; then
140274b3bceSmrg    exit 0
141274b3bceSmrg  else
142274b3bceSmrg    echo "(GNU MP wrapped config.sub, testing \"$given_full\")"
143274b3bceSmrg    exit 1
144274b3bceSmrg  fi
145274b3bceSmrgesac
146274b3bceSmrg
147274b3bceSmrg
148274b3bceSmrgtest_full="$test_cpu$given_rest"
149274b3bceSmrgcanonical_full=`$SHELL $configfsf_sub "$test_full"`
150274b3bceSmrgif test $? = 0; then
151274b3bceSmrg  :
152274b3bceSmrgelse
153274b3bceSmrg  echo "(GNU MP wrapped config.sub, testing \"$given_full\" as \"$test_full\")"
154274b3bceSmrg  exit 1
155274b3bceSmrgfi
156274b3bceSmrg
157274b3bceSmrgcanonical_rest=`echo "$canonical_full" | sed 's/^[^-]*//'`
158274b3bceSmrgecho "$given_cpu$canonical_rest"
159274b3bceSmrgexit 0
160274b3bceSmrg
161274b3bceSmrg
1624a1767b4Smrg
1634a1767b4Smrg# Local variables:
164274b3bceSmrg# fill-column: 76
1654a1767b4Smrg# End:
166