better error testing on perverse cases (eg, ./config.sub -sun3)
[external/binutils.git] / config.sub
1 #!/bin/sh
2 # Configuration validation subroutine script, version 1.0.
3 #   Copyright (C) 1991, 1992 Free Software Foundation, Inc.
4
5 #This file is free software; you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation; either version 2 of the License, or
8 #(at your option) any later version.
9
10 #This program is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #GNU General Public License for more details.
14
15 #You should have received a copy of the GNU General Public License
16 #along with this program; if not, write to the Free Software
17 #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19
20 # Configuration subroutine to validate and canonicalize a configuration type.
21 # Supply the specified configuration type as an argument.
22 # If it is invalid, we print an error message on stderr and exit with code 1.
23 # Otherwise, we print the canonical config type on stdout and succeed.
24
25 # This file is supposed to be the same for all GNU packages
26 # and recognize all the CPU types, system types and aliases
27 # that are meaningful with *any* GNU software.
28 # Each package is responsible for reporting which valid configurations
29 # it does not support.  The user should be able to distinguish
30 # a failure to support a valid configuration from a meaningless
31 # configuration.
32
33 # The goal of this file is to map all the various variations of a given
34 # machine specification into a single specification in the form:
35 #       CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
36 # it is wrong to echo any other type of specification
37
38 # First pass through any local machine types.
39 case $1 in
40         *local*)
41                 echo $1
42                 exit 0
43                 ;;
44         *)
45         ;;
46 esac
47
48 # Separate what the user gave into CPU-COMPANY and OS (if any).
49 basic_machine=`echo $1 | sed 's/-[^-]+$//'`
50 if [ $basic_machine != $1 ]
51 then os=`echo $1 | sed 's/.*-/-/'`
52 else os=; fi
53
54 # Lets recognize common machines as not being OS so that things like
55 # config.subr decstation-3100 as legal.
56 case $os in
57         -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
58         -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
59         -unicom* | -ibm* | -next* | -hp | -isi* | -apollo | -altos* | \
60         -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -osf* | \
61         -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
62         -harris)
63                 os=
64                 basic_machine=$1
65                 ;;
66         -sco*)
67                 os=-scosysv322
68                 basic_machine=i386-unknown
69                 ;;
70         -isc*)
71                 os=-iscsysv
72                 basic_machine=i386-unknown
73                 ;;
74 # start-sanitize-v9
75         -32)
76                 basic_machine=sparc64-hal
77                 os=-hal32
78                 ;;
79         -64)
80                 basic_machine=sparc64-hal
81                 os=-hal64
82                 ;;
83         -v7)
84                 basic_machine=sparc64-sun
85                 os=-v7
86                 ;;
87 # end-sanitize-v9       
88 esac
89
90 # Decode aliases for certain CPU-COMPANY combinations.
91 case $basic_machine in
92         # Recognize the basic CPU types with without company name.
93         tahoe | i386 | i860 | m68k | m68000 | m88k | ns32k | arm | pyramid \
94                 | tron | a29k | 580 | i960 | h8300 | v70)
95                 basic_machine=$basic_machine-unknown
96                 ;;
97         # Recognize the basic CPU types with with company name.
98         vax-* | tahoe-* | i386-* | i860-* | m68k-* | m68000-* | m88k-* \
99               | sparc-* | ns32k-* | alliant-* | arm-* | c[123]* \
100               | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
101               | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
102               | hppa-*)
103                 ;;
104         # Recognize the various machine names and aliases which stand
105         # for a CPU type and a company and sometimes even an OS.
106 # start-sanitize-life
107         life-*) ;;
108         life)
109                 basic_machine=life-philips
110                 os=-none
111                 ;;
112 # end-sanitize-life
113
114 # start-sanitize-v9
115         sparc64-*) ;;
116         hal-32 | hal32)
117                 basic_machine=sparc64-hal
118                 os=-hal32
119                 ;;
120         hal-64 | hal64)
121                 basic_machine=sparc64-hal
122                 os=-hal64
123                 ;;
124         sparc64)
125                 basic_machine=sparc64-sun
126                 os=-v9
127                 ;;
128         sparc64-v7 | sparc64v7)
129                 basic_machine=sparc64-sun
130                 os=-v7
131                 ;;
132 # end-sanitize-v9
133
134         vaxv)
135                 basic_machine=vax-dec
136                 os=-sysv
137                 ;;
138         vms)
139                 basic_machine=vax-dec
140                 os=-vms
141                 ;;
142         i386mach)
143                 basic_machine=i386-mach
144                 os=-mach
145                 ;;
146         i386v32)
147                 basic_machine=i386-unknown
148                 os=-sysv32
149                 ;;
150         i386-sco* | i386sco | sco)
151                 basic_machine=i386-unknown
152                 os=-scosysv322
153                 ;;
154         go32 | i386-go32)
155                 basic_machine=i386-unknown
156                 os=-go32
157                 ;;
158         i386-isc* | isc)
159                 basic_machine=i386-unknown
160                 os=-iscsysv
161                 ;;
162         i386v4*)
163                 basic_machine=i386-unknown
164                 os=-sysv4
165                 ;;
166         i386v)
167                 basic_machine=i386-unknown
168                 os=-sysv
169                 ;;
170         spur)
171                 basic_machine=spur-unknown
172                 ;;
173         alliant)
174                 basic_machine=alliant-alliant
175                 ;;
176         convex-c1)
177                 basic_machine=c1-convex
178                 os=-sysv
179                 ;;
180         convex-c2)
181                 basic_machine=c2-convex
182                 os=-sysv
183                 ;;
184         convex-c32)
185                 basic_machine=c32-convex
186                 os=-sysv
187                 ;;
188         convex-c34)
189                 basic_machine=c34-convex
190                 os=-sysv
191                 ;;
192         convex-c38)
193                 basic_machine=c38-convex
194                 os=-sysv
195                 ;;
196         m88k-omron*)
197                 basic_machine=m88k-omron
198                 ;;
199         merlin)
200                 basic_machine=ns32k-utek
201                 os=-sysv
202                 ;;
203         crds | unos)
204                 basic_machine=m68k-crds
205                 ;;
206         encore | umax | mmax)
207                 basic_machine=ns32k-encore
208                 os=-sysv
209                 ;;
210         genix)
211                 basic_machine=ns32k-ns
212                 ;;
213         iris | iris3 | iris4d)
214                 basic_machine=mips-sgi
215                 os=-irix3
216                 ;;
217         iris4)
218                 basic_machine=mips-sgi
219                 os=-irix4
220                 ;;
221         news | news700 | news800 | news900)
222                 basic_machine=m68k-sony
223                 os=-newsos
224                 ;;
225         3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
226                 basic_machine=m68k-att
227                 ;;
228         delta | 3300 | motorola-3300 | motorola-delta \
229               | 3300-motorola | delta-motorola)
230                 basic_machine=m68k-motorola
231                 ;;
232         balance)
233                 basic_machine=ns32k-sequent
234                 os=-dynix
235                 ;;
236         pc532)
237                 basic_machine=ns32k-pc532
238                 ;;
239         symmetry)
240                 basic_machine=i386-sequent
241                 os=-dynix
242                 ;;
243         sun2)
244                 basic_machine=m68000-sun
245                 ;;
246         sun2os3)
247                 basic_machine=m68000-sun
248                 os=-sunos3
249                 ;;
250         sun2os4)
251                 basic_machine=m68000-sun
252                 os=-sunos4
253                 ;;
254         sun3os3)
255                 basic_machine=m68k-sun
256                 os=-sunos3
257                 ;;
258         sun3os4)
259                 basic_machine=m68k-sun
260                 os=-sunos4
261                 ;;
262         sun4os3)
263                 basic_machine=sparc-sun
264                 os=-sunos3
265                 ;;
266         sun4os4)
267                 basic_machine=sparc-sun
268                 os=-sunos4
269                 ;;
270         sun3)
271                 basic_machine=m68k-sun
272                 ;;
273         sun4)
274                 basic_machine=sparc-sun
275                 ;;
276         pbd)
277                 basic_machine=sparc-unicom
278                 ;;
279         sun386 | sun386i | roadrunner)
280                 basic_machine=i386-sun
281                 ;;
282         ps2)
283                 basic_machine=i386-ibm
284                 ;;
285         next)
286                 basic_machine=m68k-next
287                 os=-bsd
288                 ;;
289         hp9k3[2-9][0-9])
290                 basic_machine=m68k-hp
291                 ;;
292         hp9k31[0-9] | hp9k2[0-9][0-9])
293                 basic_machine=m68000-hp
294                 ;;
295         hp9k8[0-9][0-9] | hp9k7[0-9][0-9] | hp8[0-9][0-9] | hp7[0-9][0-9])
296                 basic_machine=hp800-hp
297                 ;;
298         isi68 | isi)
299                 basic_machine=m68k-isi
300                 os=-sysv
301                 ;;
302         apollo68)
303                 basic_machine=m68k-apollo
304                 os=-sysv
305                 ;;
306         apollo68bsd)
307                 basic_machine=m68k-apollo
308                 os=-bsd
309                 ;;
310         altos | altos3068)
311                 basic_machine=m68k-altos
312                 ;;
313         miniframe)
314                 basic_machine=m68000-convergent
315                 ;;
316         tower | tower-32)
317                 basic_machine=m68k-ncr
318                 ;;
319         news-3600 | risc-news)
320                 basic_machine=mips-sony
321                 os=-newsos
322                 ;;
323         st2000)
324                 basic_machine=m68kmote-tandem
325                 ;;
326         decstation-dec | decstation | decstation-3100 | pmax | pmin | dec3100 | decstatn)
327                 basic_machine=mips-dec
328                 ;;
329         magnum | m3230)
330                 basic_machine=mips-mips
331                 os=-sysv
332                 ;;
333         gmicro)
334                 basic_machine=tron-gmicro
335                 os=-sysv
336                 ;;
337         rtpc | rtpc-*)
338                 basic_machine=romp-ibm
339                 ;;
340         am29k)
341                 basic_machine=a29k-none
342                 os=-bsd
343                 ;;
344         amdahl)
345                 basic_machine=580-amdahl
346                 os=-sysv
347                 ;;
348         amigados)
349                 basic_machine=m68k-cbm
350                 os=-amigados
351                 ;;
352         amigaunix | amix)
353                 basic_machine=m68k-cbm
354                 os=-sysv4
355                 ;;
356         stratus)
357                 basic_machine=i860-stratus
358                 os=-sysv4
359                 ;;
360         cray | ymp)
361                 basic_machine=ymp-cray
362                 os=-unicos
363                 ;;
364         cray2)
365                 basic_machine=cray2-cray
366                 os=-unicos
367                 ;;
368         xmp)
369                 basic_machine=xmp-cray
370                 os=-unicos
371                 ;;
372         delta88)
373                 basic_machine=m88k-motorola
374                 os=-m88kbcs
375                 ;;
376         dpx2)
377                 basic_machine=m68k-bull
378                 os=-sysv
379                 ;;
380         ebmon29k)
381                 basic_machine=a29k-amd
382                 os=-ebmon
383                 ;;
384
385         h8300hms)
386                 basic_machine=h8300-hitachi
387                 os=-hms
388                 ;;
389         udi29k)
390                 basic_machine=a29k-amd
391                 os=-udi
392                 ;;
393         a29khif)
394                 basic_machine=a29k-amd
395                 os=-udi
396                 ;;
397         sa29200)
398                 basic_machine=a29k-amd
399                 os=-udi
400                 ;;
401         h8300xray)
402                 basic_machine=h8300-hitachi
403                 os=-xray
404                 ;;
405         harris)
406                 basic_machine=m88k-harris
407                 os=-m88kbcs
408                 ;;
409         hp300bsd)
410                 basic_machine=m68k-hp
411                 os=-bsd
412                 ;;
413         hp300hpux)
414                 basic_machine=m68k-hp
415                 os=-hpux
416                 ;;
417         hp9k2[0-9][0-9] | hp9k31[0-9])
418                 basic_machine=m68000-hp
419                 os=-hpux
420                 ;;
421         hp9k3[2-9][0-9])
422                 basic_machine=m68k-hp
423                 os=-hpux
424                 ;;
425         ncr3000)
426                 basic_machine=i386-ncr
427                 os=-sysv4
428                 ;;
429         necv70)
430                 basic_machine=v70-nec
431                 os=-sysv
432                 ;;
433         news1000)
434                 basic_machine=m68030-sony
435                 os=-newsos
436                 ;;
437         nindy960)
438                 basic_machine=i960-intel
439                 os=-nindy
440                 ;;
441         pn)
442                 basic_machine=pn-gould
443                 os=-sysv
444                 ;;
445         np1)
446                 basic_machine=np1-gould
447                 os=-sysv
448                 ;;
449         ultra3)
450                 basic_machine=a29k-nyu
451                 os=-sym1
452                 ;;
453         vxworks960)
454                 basic_machine=i960-wrs
455                 os=-vxworks
456                 ;;
457         vxworks68)
458                 basic_machine=m68k-wrs
459                 os=-vxworks
460                 ;;
461         os68k)
462                 basic_machine=m68k-none
463                 os=-os68k
464                 ;;
465         sparclite)
466                 basic_machine=sparclite-fujitsu
467                 os=-none
468                 ;;
469
470         none)
471                 basic_machine=none-none
472                 os=-none
473                 ;;
474
475 # Here we handle the default manufacturer of certain CPU types.  It is in
476 # some cases the only manufacturer, in others, it is the most popular.
477         mips)
478                 basic_machine=mips-mips
479                 ;;
480         romp)
481                 basic_machine=romp-ibm
482                 ;;
483         rs6000)
484                 basic_machine=rs6000-ibm
485                 ;;
486         vax)
487                 basic_machine=vax-dec
488                 ;;
489         sparc)
490                 basic_machine=sparc-sun
491                 ;;
492         fx2800)
493                 basic_machine=i860-alliant
494                 ;;
495         *)
496                 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
497                 exit 1
498                 ;;
499 esac
500
501 # Decode manufacturer-specific aliases for certain operating systems.
502
503 if [ "$os" ]
504 then
505 case $os in
506         # First accept the basic system types.
507         # The portable systems comes first.
508         # Each alternative must end in a *, to match a version number.
509         -bsd* | -sysv* | -mach* | -minix* | -genix* | -ultrix* | -aout \
510               | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos* | -hpux* \
511               | -unos* | -osf* | -v88r* | -luna* | -dgux* | -solari* | -sym* \
512               | -newsos | -amigados* | -msdos* | -none* | -os68k* | -irix* \
513               | -nindy* | -vxworks* | -ebmon* | -udi | -hms* | -xray | -m88kbcs* | -go32)
514         ;;
515 # start-sanitize-v9
516         -v7 | -v9 | -hal32 | -hal64) ;;
517 # end-sanitize-v9
518
519 # Note that readline checks for newsos
520 #       -newsos*)
521 #               os=-bsd
522 #               ;;
523         -osfrose*)
524                 os=-osf
525                 ;;
526         -osf*)
527                 os=-bsd
528                 ;;
529         -dynix*)
530                 os=-bsd
531                 ;;
532         -aos*)
533                 os=-bsd
534                 ;;
535         -ctix* | -uts*)
536                 os=-sysv
537                 ;;
538         -svr4)
539                 os=-sysv4
540                 ;;
541         -svr3)
542                 os=-sysv3
543                 ;;
544         *)
545                 # Get rid of the `-' at the beginning of $os.
546                 os=`echo $1 | sed 's/[^-]*-//'`
547                 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
548                 exit 1
549                 ;;
550 esac
551 else
552
553 # Here we handle the default operating systems that come with various machines.
554 # The value should be what the vendor currently ships out the door with their
555 # machine or put another way, the most popular os provided with the machine.
556 case $basic_machine in
557         *-dec | vax-*)
558                 os=-ultrix42
559                 ;;
560         i386-sun)
561                 os=-sunos402
562                 ;;
563         m68000-sun)
564                 os=-sunos3
565                 # This also exists in the configure program, but was not the
566                 # default.
567                 # os=-sunos4
568                 ;;
569         sparc-* | *-sun)
570                 os=-sunos411
571                 ;;
572         romp-*)
573                 os=-bsd
574                 ;;
575         *-ibm)
576                 os=-aix
577                 ;;
578         *-hp)
579                 os=-hpux
580                 ;;
581         *-sgi | i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
582                 os=-sysv
583                 ;;
584         *-dg)
585                 os=-dgux
586                 ;;
587         m88k-omron*)
588                 os=-luna
589                 ;;
590         *-crds)
591                 os=-unos
592                 ;;
593         *-ns)
594                 os=-genix
595                 ;;
596         i386-*)
597                 os=-scosysv322
598                 ;;
599         *)
600                 os=-none
601                 ;;
602 esac
603 fi
604
605 # Here we handle the case where we know the os, and the CPU type, but not the
606 # manufacturer.  We pick the logical manufacturer.
607 vendor=unknown
608 case $basic_machine in
609         *-unknown)
610                 case $os in
611                         -sunos*)
612                                 vendor=sun
613                                 ;;
614                         -aix*)
615                                 vendor=ibm
616                                 ;;
617                         -hpux*)
618                                 vendor=hp
619                                 ;;
620                         -unos*)
621                                 vendor=crds
622                                 ;;
623                         -dgux*)
624                                 vendor=dg
625                                 ;;
626                         -luna*)
627                                 vendor=omron
628                                 ;;
629                         -genix*)
630                                 vendor=ns
631                                 ;;
632                 esac
633                 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
634                 ;;
635 esac
636
637 echo $basic_machine$os