1#! /bin/sh 2# 3# GMP config.sub wrapper. 4 5 6# Copyright 2000-2003, 2006, 2009-2016 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 either: 12# 13# * the GNU Lesser General Public License as published by the Free 14# Software Foundation; either version 3 of the License, or (at your 15# option) any later version. 16# 17# or 18# 19# * the GNU General Public License as published by the Free Software 20# Foundation; either version 2 of the License, or (at your option) any 21# later version. 22# 23# or both in parallel, as here. 24# 25# The GNU MP Library is distributed in the hope that it will be useful, but 26# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 27# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28# for more details. 29# 30# You should have received copies of the GNU General Public License and the 31# GNU Lesser General Public License along with the GNU MP Library. If not, 32# see https://www.gnu.org/licenses/. 33 34 35# Usage: config.sub CPU-VENDOR-OS 36# config.sub ALIAS 37# 38# Validate and canonicalize the given configuration name, with special 39# handling for GMP extra CPU names. 40# 41# When the CPU isn't special the whole name is simply passed straight 42# through to configfsf.sub. 43# 44# When the CPU is a GMP extra, configfsf.sub is run on a similar CPU that it 45# will recognise. For example "athlon-pc-freebsd3.5" is validated using 46# "i386-pc-freebsd3.5". 47# 48# Any canonicalizations made by configfsf.sub are preserved. For example 49# given "athlon-linux", configfsf.sub is called with "i386-linux" and will 50# give back "i386-pc-linux-gnu". "athlon" is then reinstated, so we print 51# "athlon-pc-linux-gnu". 52 53 54# Expect to find configfsf.sub in the same directory as this config.sub 55configfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`" 56if test "$configfsf_sub" = "$0"; then 57 echo "Cannot derive configfsf.sub from $0" 1>&2 58 exit 1 59fi 60if test -f "$configfsf_sub"; then 61 : 62else 63 echo "$configfsf_sub not found" 1>&2 64 exit 1 65fi 66 67# Always run configfsf.sub with $SHELL, like autoconf does for config.sub 68SHELL=${CONFIG_SHELL-/bin/sh} 69 70# Identify ourselves on --version, --help, etc 71case "$1" in 72"" | -*) 73 echo "(GNU MP wrapped config.sub)" 1>&2 74 $SHELL $configfsf_sub "$@" 75 exit 76 ;; 77esac 78 79given_full="$1" 80given_cpu=`echo "$given_full" | sed 's/-.*$//'` 81given_rest=`echo "$given_full" | sed 's/^[^-]*//'` 82 83 84# Aliases for GMP extras 85case "$given_cpu" in 86 # configfsf.sub turns p5 into i586, instead use our exact cpu type 87 p5 | p54) given_cpu=pentium ;; 88 p55) given_cpu=pentiummmx ;; 89 90 # configfsf.sub turns p6, pentiumii and pentiumiii into i686, instead use 91 # our exact cpu types 92 p6) given_cpu=pentiumpro ;; 93 pentiumii) given_cpu=pentium2 ;; 94 pentiumiii) given_cpu=pentium3 ;; 95esac 96given_full="$given_cpu$given_rest" 97 98 99# GMP extras and what to use for the config.sub test 100case "$given_cpu" in 101itanium | itanium2) 102 test_cpu=ia64 ;; 103pentium | pentiummmx | pentiumpro | pentium[234m] | k[567] | k6[23] | geode | athlon | viac3*) 104 test_cpu=i386 ;; 105athlon64 | 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) 106 test_cpu=x86_64 ;; 107power[2-9] | power2sc) 108 test_cpu=power ;; 109powerpc401 | powerpc403 | powerpc405 | \ 110powerpc505 | \ 111powerpc601 | powerpc602 | \ 112powerpc603 | powerpc603e | \ 113powerpc604 | powerpc604e | \ 114powerpc620 | powerpc630 | powerpc970 | \ 115powerpc740 | powerpc7400 | powerpc74[4-5][0-9] | powerpc750 | \ 116powerpc801 | powerpc821 | powerpc823 | powerpc860 | \ 117powerpc64) 118 test_cpu=powerpc ;; 119sparcv8 | supersparc | microsparc | turbosparc | \ 120ultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct[12345]) 121 test_cpu=sparc ;; 122sh2) 123 test_cpu=sh ;; 124 125z900 | z990 | z9 | z10 | z196) 126 test_cpu=s390x;; 127z900esa | z990esa | z9esa | z10esa | z196esa) 128 test_cpu=s390;; 129 130armsa1 | armxscale | arm9tdmi | arm9te | \ 131arm10* | arm11mpcore | armsa1 | arm1136 | arm1156 | arm1176 | \ 132armcortex[arm][0-9] | armcortex[arm][0-9][0-9] | \ 133arm*neon | armxgene1 | armexynosm1 | armthunderx) 134 test_cpu="arm";; 135 136*) 137 # Don't need or want to change the given name, just run configfsf.sub 138 $SHELL $configfsf_sub "$given_full" 139 if test $? = 0; then 140 exit 0 141 else 142 echo "(GNU MP wrapped config.sub, testing \"$given_full\")" 143 exit 1 144 fi 145esac 146 147 148test_full="$test_cpu$given_rest" 149canonical_full=`$SHELL $configfsf_sub "$test_full"` 150if test $? = 0; then 151 : 152else 153 echo "(GNU MP wrapped config.sub, testing \"$given_full\" as \"$test_full\")" 154 exit 1 155fi 156 157canonical_rest=`echo "$canonical_full" | sed 's/^[^-]*//'` 158echo "$given_cpu$canonical_rest" 159exit 0 160 161 162 163# Local variables: 164# fill-column: 76 165# End: 166