8e7227a8f6b8b3e6205837244d3a86b955dbb1d2
[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 | -sim)
63                 os=
64                 basic_machine=$1
65                 ;;
66         -scout)
67                 ;;
68         -sco*)
69                 os=-scosysv322
70                 basic_machine=i386-unknown
71                 ;;
72         -OSE68k | -ose68k | -OSE | -ose | -es1800)
73                 os=-ose
74                 basic_machine=m68k-ericsson
75                 ;;
76         -OSE68000 | -ose68000)
77                 os=-ose
78                 basic_machine=m68000-ericsson
79                 ;;
80         -isc*)
81                 os=-iscsysv
82                 basic_machine=i386-unknown
83                 ;;
84 # start-sanitize-v9
85         -32)
86                 basic_machine=sparc64-hal
87                 os=-hal32
88                 ;;
89         -64)
90                 basic_machine=sparc64-hal
91                 os=-hal64
92                 ;;
93         -v7)
94                 basic_machine=sparc64-sun
95                 os=-v7
96                 ;;
97 # end-sanitize-v9       
98 esac
99
100 # Decode aliases for certain CPU-COMPANY combinations.
101 case $basic_machine in
102         # Recognize the basic CPU types with without company name.
103         tahoe | i386 | i486 | i860 | m68k | m680[01234]0 | m683?2 \
104                 | m88k | ns32k | arm | pyramid \
105                 | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 | we32k\
106                 | v70 | we32k | z8k)
107                 basic_machine=$basic_machine-unknown
108                 ;;
109         # Recognize the basic CPU types with with company name.
110         vax-* | tahoe-* | i386-* | i486-* | i860-* | m68k-* \
111               | m680[01234]0-* | m683?2-* | m88k-* \
112               | sparc-* | ns32k-* | alliant-* | arm-* | c[123]* \
113               | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
114               | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
115               | hppa1.0-* | hppa1.1-* | we32k-* | z8k-*)
116                 ;;
117         # Recognize the various machine names and aliases which stand
118         # for a CPU type and a company and sometimes even an OS.
119 # start-sanitize-life
120         life-*) ;;
121         life)
122                 basic_machine=life-philips
123                 os=-none
124                 ;;
125 # end-sanitize-life
126
127 # start-sanitize-v9
128         sparc64-*) ;;
129         hal-32 | hal32)
130                 basic_machine=sparc64-hal
131                 os=-hal32
132                 ;;
133         hal-64 | hal64)
134                 basic_machine=sparc64-hal
135                 os=-hal64
136                 ;;
137         sparc64)
138                 basic_machine=sparc64-sun
139                 os=-v9
140                 ;;
141         sparc64-v7 | sparc64v7)
142                 basic_machine=sparc64-sun
143                 os=-v7
144                 ;;
145 # end-sanitize-v9
146
147         vaxv)
148                 basic_machine=vax-dec
149                 os=-sysv
150                 ;;
151         vms)
152                 basic_machine=vax-dec
153                 os=-vms
154                 ;;
155         i386mach)
156                 basic_machine=i386-mach
157                 os=-mach
158                 ;;
159         i386v32)
160                 basic_machine=i386-unknown
161                 os=-sysv32
162                 ;;
163         i386-sco* | i386sco | sco)
164                 basic_machine=i386-unknown
165                 os=-scosysv322
166                 ;;
167         go32 | i386-go32)
168                 basic_machine=i386-unknown
169                 os=-go32
170                 ;;
171         i386-isc* | isc)
172                 basic_machine=i386-unknown
173                 os=-iscsysv
174                 ;;
175         i386-linux* | linux)
176                 basic_machine=i386-unknown
177                 os=-linux
178                 ;;
179         i386v4*)
180                 basic_machine=i386-unknown
181                 os=-sysv4
182                 ;;
183         i486v4*)
184                 basic_machine=i486-unknown
185                 os=-sysv4
186                 ;;
187         i386v)
188                 basic_machine=i386-unknown
189                 os=-sysv
190                 ;;
191         i486v)
192                 basic_machine=i486-unknown
193                 os=-sysv
194                 ;;
195         spur)
196                 basic_machine=spur-unknown
197                 ;;
198         alliant)
199                 basic_machine=alliant-alliant
200                 ;;
201         convex-c1)
202                 basic_machine=c1-convex
203                 os=-sysv
204                 ;;
205         convex-c2)
206                 basic_machine=c2-convex
207                 os=-sysv
208                 ;;
209         convex-c32)
210                 basic_machine=c32-convex
211                 os=-sysv
212                 ;;
213         convex-c34)
214                 basic_machine=c34-convex
215                 os=-sysv
216                 ;;
217         convex-c38)
218                 basic_machine=c38-convex
219                 os=-sysv
220                 ;;
221         m88k-omron*)
222                 basic_machine=m88k-omron
223                 ;;
224         merlin)
225                 basic_machine=ns32k-utek
226                 os=-sysv
227                 ;;
228         crds | unos)
229                 basic_machine=m68k-crds
230                 ;;
231         encore | umax | mmax)
232                 basic_machine=ns32k-encore
233                 os=-sysv
234                 ;;
235         genix)
236                 basic_machine=ns32k-ns
237                 ;;
238         iris | iris3 | iris4d)
239                 basic_machine=mips-sgi
240                 os=-irix3
241                 ;;
242         iris4)
243                 basic_machine=mips-sgi
244                 os=-irix4
245                 ;;
246         news | news700 | news800 | news900)
247                 basic_machine=m68k-sony
248                 os=-newsos
249                 ;;
250         3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
251                 basic_machine=m68k-att
252                 ;;
253         3b* | we32k* )
254                 basic_machine=we32k-att
255                 os=-sysv
256                 ;;
257         delta | 3300 | motorola-3300 | motorola-delta \
258               | 3300-motorola | delta-motorola)
259                 basic_machine=m68k-motorola
260                 ;;
261         balance)
262                 basic_machine=ns32k-sequent
263                 os=-dynix
264                 ;;
265         pc532)
266                 basic_machine=ns32k-pc532
267                 ;;
268         symmetry)
269                 basic_machine=i386-sequent
270                 os=-dynix
271                 ;;
272         sun2)
273                 basic_machine=m68000-sun
274                 ;;
275         sun2os3)
276                 basic_machine=m68000-sun
277                 os=-sunos3
278                 ;;
279         sun2os4)
280                 basic_machine=m68000-sun
281                 os=-sunos4
282                 ;;
283         sun3os3)
284                 basic_machine=m68k-sun
285                 os=-sunos3
286                 ;;
287         sun3os4)
288                 basic_machine=m68k-sun
289                 os=-sunos4
290                 ;;
291         sun4os3)
292                 basic_machine=sparc-sun
293                 os=-sunos3
294                 ;;
295         sun4os4)
296                 basic_machine=sparc-sun
297                 os=-sunos4
298                 ;;
299         sun4sol2)
300                 basic_machine=sparc-sun
301                 os=-solaris2
302                 ;;
303         z8ksim)
304                 basic_machine=z8k-unknown
305                 os=-sim
306                 ;;
307         sun3)
308                 basic_machine=m68k-sun
309                 ;;
310         sun4)
311                 basic_machine=sparc-sun
312                 ;;
313         msdos)
314                 basic_machine=i386-unknown      
315                 os=-msdos
316                 ;;
317         pbd)
318                 basic_machine=sparc-unicom
319                 ;;
320         sun386 | sun386i | roadrunner)
321                 basic_machine=i386-sun
322                 ;;
323         ps2)
324                 basic_machine=i386-ibm
325                 ;;
326         next)
327                 basic_machine=m68k-next
328                 os=-bsd
329                 ;;
330         hp9k3[2-9][0-9])
331                 basic_machine=m68k-hp
332                 ;;
333         hp9k31[0-9] | hp9k2[0-9][0-9])
334                 basic_machine=m68000-hp
335                 ;;
336         hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
337                 basic_machine=hppa1.1-hp
338                 ;;
339         hp9k8[0-9][0-9] | hp8[0-9][0-9])
340                 basic_machine=hppa1.0-hp
341                 ;;
342         isi68 | isi)
343                 basic_machine=m68k-isi
344                 os=-sysv
345                 ;;
346         apollo68)
347                 basic_machine=m68k-apollo
348                 os=-sysv
349                 ;;
350         apollo68bsd)
351                 basic_machine=m68k-apollo
352                 os=-bsd
353                 ;;
354         altos | altos3068)
355                 basic_machine=m68k-altos
356                 ;;
357         miniframe)
358                 basic_machine=m68000-convergent
359                 ;;
360         tower | tower-32)
361                 basic_machine=m68k-ncr
362                 ;;
363         news-3600 | risc-news)
364                 basic_machine=mips-sony
365                 os=-newsos
366                 ;;
367         st2000)
368                 basic_machine=m68kmote-tandem
369                 ;;
370         decstation-dec | decstation | decstation-3100 | pmax | pmin | dec3100 | decstatn)
371                 basic_machine=mips-dec
372                 ;;
373         magnum | m3230)
374                 basic_machine=mips-mips
375                 os=-sysv
376                 ;;
377         gmicro)
378                 basic_machine=tron-gmicro
379                 os=-sysv
380                 ;;
381         rtpc | rtpc-*)
382                 basic_machine=romp-ibm
383                 ;;
384         am29k)
385                 basic_machine=a29k-none
386                 os=-bsd
387                 ;;
388         amdahl)
389                 basic_machine=580-amdahl
390                 os=-sysv
391                 ;;
392         amigados)
393                 basic_machine=m68k-cbm
394                 os=-amigados
395                 ;;
396         amigaunix | amix)
397                 basic_machine=m68k-cbm
398                 os=-sysv4
399                 ;;
400         stratus)
401                 basic_machine=i860-stratus
402                 os=-sysv4
403                 ;;
404         cray | ymp)
405                 basic_machine=ymp-cray
406                 os=-unicos
407                 ;;
408         cray2)
409                 basic_machine=cray2-cray
410                 os=-unicos
411                 ;;
412         xmp)
413                 basic_machine=xmp-cray
414                 os=-unicos
415                 ;;
416         delta88)
417                 basic_machine=m88k-motorola
418                 os=-m88kbcs
419                 ;;
420         dpx2)
421                 basic_machine=m68k-bull
422                 os=-sysv
423                 ;;
424         ebmon29k)
425                 basic_machine=a29k-amd
426                 os=-ebmon
427                 ;;
428
429         h8300hms)
430                 basic_machine=h8300-hitachi
431                 os=-hms
432                 ;;
433         udi29k)
434                 basic_machine=a29k-amd
435                 os=-udi
436                 ;;
437         a29khif)
438                 basic_machine=a29k-amd
439                 os=-udi
440                 ;;
441         sa29200)
442                 basic_machine=a29k-amd
443                 os=-udi
444                 ;;
445         h8300xray)
446                 basic_machine=h8300-hitachi
447                 os=-xray
448                 ;;
449         harris)
450                 basic_machine=m88k-harris
451                 os=-m88kbcs
452                 ;;
453         hp300bsd)
454                 basic_machine=m68k-hp
455                 os=-bsd
456                 ;;
457         hp300hpux)
458                 basic_machine=m68k-hp
459                 os=-hpux
460                 ;;
461         hp9k2[0-9][0-9] | hp9k31[0-9])
462                 basic_machine=m68000-hp
463                 os=-hpux
464                 ;;
465         hp9k3[2-9][0-9])
466                 basic_machine=m68k-hp
467                 os=-hpux
468                 ;;
469         hppabsd)
470                 basic_machine=hppa-hp
471                 os=-bsd
472                 ;;
473         hppahpux)
474                 basic_machine=hppa-hp
475                 os=-hpux
476                 ;;
477         ncr3000)
478                 basic_machine=i486-ncr
479                 os=-sysv4
480                 ;;
481         necv70)
482                 basic_machine=v70-nec
483                 os=-sysv
484                 ;;
485         news1000)
486                 basic_machine=m68030-sony
487                 os=-newsos
488                 ;;
489         nindy960)
490                 basic_machine=i960-intel
491                 os=-nindy
492                 ;;
493         pn)
494                 basic_machine=pn-gould
495                 os=-sysv
496                 ;;
497         np1)
498                 basic_machine=np1-gould
499                 os=-sysv
500                 ;;
501         ultra3)
502                 basic_machine=a29k-nyu
503                 os=-sym1
504                 ;;
505         vxworks960)
506                 basic_machine=i960-wrs
507                 os=-vxworks
508                 ;;
509         vxworks68)
510                 basic_machine=m68k-wrs
511                 os=-vxworks
512                 ;;
513         es1800 | OSE68k | ose68k)
514                 basic_machine=m68k-ericsson
515                 os=-ose
516                 ;;
517         OSE68000 | ose68000)
518                 basic_machine=m68000-ericsson
519                 os=-ose
520                 ;;
521         os68k)
522                 basic_machine=m68k-none
523                 os=-os68k
524                 ;;
525         sparclite)
526                 basic_machine=sparclite-fujitsu
527                 os=-none
528                 ;;
529         sparclite-wrs)
530                 basic_machine=sparclite-wrs
531                 os=-vxworks
532                 ;;
533         sparcfrw)
534                 basic_machine=sparcfrw-sun
535                 os=-sunos4
536                 ;;
537         sparcfrwcompat)
538                 basic_machine=sparcfrwcompat-sun
539                 os=-sunos4
540                 ;;
541         sparclitefrw)
542                 basic_machine=sparclitefrw-fujitsu
543                 os=-none
544                 ;;
545         sparclitefrwcompat)
546                 basic_machine=sparclitefrwcompat-fujitsu
547                 os=-none
548                 ;;
549         adobe68k)
550                 basic_machine=m68010-adobe
551                 os=-scout
552                 ;;
553
554         none)
555                 basic_machine=none-none
556                 os=-none
557                 ;;
558
559 # Here we handle the default manufacturer of certain CPU types.  It is in
560 # some cases the only manufacturer, in others, it is the most popular.
561         mips)
562                 basic_machine=mips-mips
563                 ;;
564         romp)
565                 basic_machine=romp-ibm
566                 ;;
567         rs6000)
568                 basic_machine=rs6000-ibm
569                 ;;
570         vax)
571                 basic_machine=vax-dec
572                 ;;
573         sparc)
574                 basic_machine=sparc-sun
575                 ;;
576         fx2800)
577                 basic_machine=i860-alliant
578                 ;;
579         *)
580                 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
581                 exit 1
582                 ;;
583 esac
584
585 # Decode manufacturer-specific aliases for certain operating systems.
586
587 if [ "$os" ]
588 then
589 case $os in
590         # First accept the basic system types.
591         # The portable systems comes first.
592         # Each alternative must end in a *, to match a version number.
593         -bsd* | -sysv* | -mach* | -minix* | -genix* | -ultrix* \
594               | -aout | -coff | -elf \
595               | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos* | -hpux* \
596               | -unos* | -osf* | -v88r* | -luna* | -dgux* | -solaris* | -sym* \
597               | -newsos | -amigados* | -msdos* | -none* | -os68k* | -irix* \
598               | -nindy* | -vxworks* | -ebmon* | -udi | -hms* | -xray \
599               | -m88kbcs* | -go32 | -linux* | -sim | -es1800*)
600         ;;
601 # start-sanitize-v9
602         -v7 | -v9 | -hal32 | -hal64) ;;
603 # end-sanitize-v9
604
605 # Note that readline checks for newsos
606 #       -newsos*)
607 #               os=-bsd
608 #               ;;
609         -osfrose*)
610                 os=-osf
611                 ;;
612         -osf*)
613                 os=-bsd
614                 ;;
615         -dynix*)
616                 os=-bsd
617                 ;;
618         -aos*)
619                 os=-bsd
620                 ;;
621         -ctix* | -uts*)
622                 os=-sysv
623                 ;;
624         -svr4)
625                 os=-sysv4
626                 ;;
627         -svr3)
628                 os=-sysv3
629                 ;;
630         -ose*)
631                 os=-ose
632                 ;;
633         -es1800*)
634                 os=-ose
635                 ;;
636         *)
637                 # Get rid of the `-' at the beginning of $os.
638                 os=`echo $1 | sed 's/[^-]*-//'`
639                 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
640                 exit 1
641                 ;;
642 esac
643 else
644
645 # Here we handle the default operating systems that come with various machines.
646 # The value should be what the vendor currently ships out the door with their
647 # machine or put another way, the most popular os provided with the machine.
648 case $basic_machine in
649         *-dec | vax-*)
650                 os=-ultrix42
651                 ;;
652         i386-sun)
653                 os=-sunos402
654                 ;;
655         m68000-sun)
656                 os=-sunos3
657                 # This also exists in the configure program, but was not the
658                 # default.
659                 # os=-sunos4
660                 ;;
661         sparc-* | *-sun)
662                 os=-sunos411
663                 ;;
664         romp-*)
665                 os=-bsd
666                 ;;
667         *-ibm)
668                 os=-aix
669                 ;;
670         *-hp)
671                 os=-hpux
672                 ;;
673         *-sgi | i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
674                 os=-sysv
675                 ;;
676         *-dg)
677                 os=-dgux
678                 ;;
679         m88k-omron*)
680                 os=-luna
681                 ;;
682         *-crds)
683                 os=-unos
684                 ;;
685         *-ns)
686                 os=-genix
687                 ;;
688         i386-*)
689                 os=-scosysv322
690                 ;;
691         *)
692                 os=-none
693                 ;;
694 esac
695 fi
696
697 # Here we handle the case where we know the os, and the CPU type, but not the
698 # manufacturer.  We pick the logical manufacturer.
699 vendor=unknown
700 case $basic_machine in
701         *-unknown)
702                 case $os in
703                         -sunos*)
704                                 vendor=sun
705                                 ;;
706                         -aix*)
707                                 vendor=ibm
708                                 ;;
709                         -hpux*)
710                                 vendor=hp
711                                 ;;
712                         -unos*)
713                                 vendor=crds
714                                 ;;
715                         -dgux*)
716                                 vendor=dg
717                                 ;;
718                         -luna*)
719                                 vendor=omron
720                                 ;;
721                         -genix*)
722                                 vendor=ns
723                                 ;;
724                         -vxworks*)
725                                 vendor=wrs
726                                 ;;
727                 esac
728                 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
729                 ;;
730 esac
731
732 echo $basic_machine$os