xref: /trunk/main/solenv/bin/modules/osarch.pm (revision 5e139d9fe42a654147771da4118aea6285c03168)
1#!/usr/bin/perl -w
2# *************************************************************
3#
4#  Licensed to the Apache Software Foundation (ASF) under one
5#  or more contributor license agreements.  See the NOTICE file
6#  distributed with this work for additional information
7#  regarding copyright ownership.  The ASF licenses this file
8#  to you under the Apache License, Version 2.0 (the
9#  "License"); you may not use this file except in compliance
10#  with the License.  You may obtain a copy of the License at
11#
12#    http://www.apache.org/licenses/LICENSE-2.0
13#
14#  Unless required by applicable law or agreed to in writing,
15#  software distributed under the License is distributed on an
16#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17#  KIND, either express or implied.  See the License for the
18#  specific language governing permissions and limitations
19#  under the License.
20#
21# *************************************************************
22
23# ***********************************************************************
24# Description:
25# Filename:    osarch.pm
26# Author:       EG
27# Date:        28.10.96
28# $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/solenv/bin/modules/osarch.pm,v 1.3 2008-08-18 13:11:04 vg Exp $
29# Copyright:   STAR DIVISION
30# **********************************************************************/
31
32package osarch;
33
34$m_str = `uname -m`;
35$s_str = `uname -s`;
36chop( $m_str, $s_str );
37
38%osTable    = ("SunOS",     "solaris",
39               "HP-UX",     "hpux",
40               "AIX",       "aix",
41               "OS/390",    "s390",
42               "Linux",     "linux",
43               "FreeBSD",   "freebsd",
44               "NetBSD",    "netbsd",
45               "OSF1",      "decunix",
46               "SCO_SV",    "scoosr5",
47#              "SCO_SV",    "scouw21",
48               "Darwin",    "macosxp",
49               "Mac OS",    "macosxp",
50               "SINIX-N",   "sinix"
51               );
52
53%osDefTable = ("SunOS",     "-DSYSV -DSOLARIS",
54               "HP-UX",     "-DSYSV -DHPUX",
55               "AIX",       "-DSYSV -DAIX",
56               "Linux",     "-DLINUX",
57               "FreeBSD",   "-DFREEBSD",
58               "NetBSD",    "-DNETBSD",
59               "OSF1",      "-DSYSV -DDECUNIX",
60               "SCO_SV",    "-DSYSV -DSCO -DSCO_OSR5",
61#              "SCO_SV",    "-DSYSV -DSCO -DSCO_UW21",
62               "Darwin",    "-DBSD -DMACOSX",
63               "Mac OS",    "-DBSD -DMACOSX",
64               "SINIX-N",   "-DSYSV -DSINIX"
65               );
66
67%osDosTable = ("SunOS",     "sol",
68               "HP-UX", "hpx",
69               "AIX",   "aix",
70               "OS/390",    "mvs",
71               "Linux", "lng",
72               "FreeBSD",   "fbsd",
73               "NetBSD",    "bsd",
74               "SCO_SV",    "sco",
75               "Darwin",    "macx",
76               "Mac OS",    "macx",
77               "SINIX-N",   "sni"
78               );
79
80%archTable  = ("sun4c",         "sparc",
81               "sun4m",         "sparc",
82               "sun4u",         "sparc",
83               "9000/712",      "hp9000",
84               "9000/715",      "hp9000",
85               "9000/778",      "hp9000",
86               "000029484600",  "rs6000",       # salsa
87               "000328144600",  "rs6000",       # lambada
88               "00245D29E000",  "rs6000",       # segv
89               "00245C46E000",  "rs6000",       # bus
90               "002012974600",  "rs6000",       # tango
91               "0006404C4C00",  "rs6000",       # jive
92               "2003",          "g3",           # ezopen4
93               "i86pc",         "x86",          # blauwal
94               "i386",          "x86",          # SCO_SV, NetBSD, FreeBSD
95               "i486",          "x86",          # tiger
96               "i586",          "x86",          # blauwal
97               "i686",          "x86",
98               "prep",          "ppc",          # hooge
99               "ppc",           "ppc",          # ppc-linux
100               "alpha",         "alpha",
101               "RM400",         "rm400",        # garbo
102               "IP22",          "mips",         # voyager
103               "IP32",          "mips",         # giotto
104               "Power Macintosh",           "ppc",          # NetBSD/arm32
105               "arm32",         "arm32",        # NetBSD/arm32
106               "arm64",         "aarch64",      # macOS Apple Silicon (uname -m)
107               "aarch64",       "aarch64"       # Linux aarch64
108               );
109
110%archDefTable=("sun4c",         "-DSPARC -DSUN -DSUN4", # hawai
111               "sun4m",         "-DSPARC -DSUN -DSUN4", # broccoli
112               "sun4u",         "-DSPARC -DSUN -DSUN4", # broccoli
113               "9000/712",      "-DHP9000",     # tuborg
114               "9000/715",      "-DHP9000",     # koepi
115               "9000/778",      "-DHP9000",     # jever, flens
116               "000029484600",  "-DRS6000",     # salsa
117               "000328144600",  "-DRS6000",     # lambada
118               "00245D29E000",  "-DRS6000",     # segv
119               "00245C46E000",  "-DRS6000",     # segv
120               "002012974600",  "-DRS6000",     # tango
121               "0006404C4C00",  "-DRS6000",     # jive
122               "2003",          "-DG3",         # ezopen4
123               "i86pc",         "-DX86 -DINTEL",# gepard
124               "i386",          "-DX86",        # SCO_SV, NetBSD, FreeBSD
125               "i486",          "-DX86",        # tiger
126               "i586",          "-DX86",        # blauwal
127               "i686",          "-DX86",        #
128               "prep",          "-DPPC",        # hooge
129               "ppc",           "-DPPC",        # ppc-linux
130               "alpha",         "-DALPHA",      # mars
131               "RM400",         "-DMIPS -DRM400",   # ekberg, garbo
132               "IP22",          "-DMIPS",           # voyager
133               "IP32",          "-DMIPS",           # giotto
134               "Power Macintosh",       "-DPPC",        # NetBSD/arm32
135               "arm32",         "-DARM32",      # NetBSD/arm32
136               "arm64",         "-DAARCH64",        # macOS Apple Silicon (uname -m)
137               "aarch64",       "-DAARCH64"     # Linux aarch64
138               );
139
140%archDosTable=("sun4c",         "s",        # hawai
141               "sun4m",         "s",        # broccoli
142               "sun4u",         "s",        # broccoli
143               "9000/712",      "r",        # tuborg
144               "9000/715",      "r",        # koepi
145               "9000/778",      "r",        # jever, flens
146               "000029484600",  "p",        # salsa
147               "000328144600",  "p",        # lambada
148               "00245D29E000",  "p",        # segv
149               "00245C46E000",  "p",        # segv
150               "002012974600",  "p",        # tango
151               "0006404C4C00",  "p",        # jive
152               "2003",          "g",        # ezopen4
153               "i86pc",         "i",        # gepard
154               "i386",          "i",        # SCO_SV, NetBSD, FreeBSD
155               "i486",          "i",        # tiger
156               "i586",          "i",        # blauwal
157               "i686",          "i",
158               "prep",          "p",        # hooge
159               "ppc",           "p",        # ppc-linux
160               "alpha",         "a",        # mars
161               "RM400",         "m",        # ekberg, garbo
162               "IP22",          "m",        # voyager
163               "IP32",          "m",        # giotto
164               "Power Macintosh",           "p",            # NetBSD/arm32
165               "arm32",         "a",            # NetBSD/arm32
166               "arm64",         "r",            # macOS Apple Silicon (uname -m)
167               "aarch64",       "r"         # Linux aarch64
168               );
169
170$main::solarDef     = $osDefTable{ $s_str }.' '.$archDefTable{ $m_str };
171
172$main::solarOS      = $osTable{ $s_str };
173$main::solarMT      = $archTable{ $m_str };
174
175$main::solarArch    = $main::solarOS.$main::solarMT;
176$main::solarOldArch = $main::solarArch; # for compatibility
177
178$main::solarDOS     = 'unx'.$osDosTable{ $s_str }. $archDosTable{ $m_str };
179
180sub main::osarch
181{
182    local ( $flag ) = @_;
183
184    $perlFlag   = $flag eq 'perl';
185    $defFlag    = $flag eq 'def';
186    $oldFlag    = $flag eq 'old';
187    $dirFlag    = $flag eq 'dir';
188    $dosFlag    = $flag eq 'dos';
189
190    local( $result ) = ( '' );
191
192    if ( $perlFlag )
193    {
194        $result .= '$solarDef     = '."'$main::solarDef';\n";
195        $result .= '$solarArch    = '."'$main::solarArch';\n";
196        $result .= '$solarOldArch = '."'$main::solarOldArch';\n";
197        $result .= '$solarOS      = '."'$main::solarOS';\n";
198        $result .= '$solarMT      = '."'$main::solarMT';\n";
199        $result .= '$solarDOS     = '."'$main::solarDOS';";
200    }
201    elsif ( $defFlag )
202    {
203        $result = $main::solarDef;
204    }
205    elsif ( $dirFlag )
206    {
207        $result = "$main::solarOS-$main::solarMT";
208    }
209    elsif ( $dosFlag )
210    {
211        $result = $main::solarDOS;
212    }
213    else
214    {
215        $result = $oldFlag ? $main::solarOldArch : $main::solarArch;
216    }
217
218    return $result;
219}
220
2211;
222