-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetarch
executable file
·210 lines (177 loc) · 5.16 KB
/
getarch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/csh -f
#
# GETARCH -- Determine or set the current platform architecture parameters.
#
# Usage: getarch
# getarch -set [<arch>] [opts]
#
# -mach print the architecture name [default]
# -current print the currently configured arch
# -nbits print number of bits in an int (32 or 64)
#
# -actual print actual architecture name regardless of VOCARCH
# -set <arch> manually reset the environment architecture
#
# ----------------------------------------------------------------------------
unset noclobber
onintr cleanup_
unalias cd cp cmp echo ln mv rm sed set grep ls chmod chown pwd touch sort which
setenv path "(/sbin /usr/sbin /bin /usr/bin /usr/5bin /usr/ucb /etc /usr/etc $path /usr/local/bin /opt/local/bin /local/bin /home/local/bin /usr/openwin/bin /usr/X11R6/bin /usr/X11/bin)"
# set echo
##############################################################################
# START OF MACHDEP DEFINITIONS.
##############################################################################
set VERSION = "V1.0"
set nbits = 32
set debug = 0
#----------------------------------
# Determine platform architecture.
#----------------------------------
if (-e /usr/bin/uname) then
set uname_cmd = /usr/bin/uname
else if (-e /bin/uname) then
set uname_cmd = /bin/uname
else
WARNING "No 'uname' command found to determine architecture."
exit 1
endif
setenv UNAME `$uname_cmd | tr '[A-Z]' '[a-z]'`
if ($UNAME == "sunos") then
setenv UNAME_M `$uname_cmd -m | cut -c2- | tr '[A-Z]' '[a-z]'`
else
setenv UNAME_M `$uname_cmd -m | tr '[A-Z]' '[a-z]' | tr ' ' '_'`
endif
setenv OSVERSION `$uname_cmd -r | cut -c1`
# Allow a VOCARCH definition in the environment to override.
if ($#argv == 1 && "$1" == "-actual") then
setenv MNAME $UNAME
setenv MNAME_M $UNAME_M
unsetenv VOCARCH
else if ($#argv == 1 && "$1" == "-current") then
setenv MNAME `/bin/ls -lad $iraf/bin | \
awk '{ printf ("%s\n", $11) }' | \
sed -e 's/bin.//g'`
setenv MNAME_M $UNAME_M
setenv VOCARCH $MNAME
goto repeat_
else
if ($?IRAFARCH) then # Let IRAFARCH set arch
if (! $?VOCARCH) then
setenv VOCARCH $IRAFARCH
endif
endif
if ($#argv == 0) then
if ($?VOCARCH) then
repeat_:
setenv MNAME $VOCARCH
setenv MNAME_M $UNAME_M
else
setenv MNAME $UNAME
setenv MNAME_M $UNAME_M
endif
else
if ($#argv != 0 && "$1" == "-set") then
setenv MNAME $2
setenv MNAME_M $2
else
setenv MNAME $UNAME
setenv MNAME_M $UNAME_M
endif
endif
endif
# Set some common defaults for most platforms
set nbits = 32 # 32-bit architecture
# Determine parameters for each architecture.
switch ($MNAME)
case darwin: # Mac OS X
case ipad:
case macosx:
case macintel:
if ($?VOCARCH) then
set mach = "$VOCARCH"
if ($mach == "macintel") then
set nbits = 64
endif
else
if ($MNAME_M == "x86_64") then # 64-bit
set mach = "macintel"
set nbits = 64
else if ($MNAME_M == "x86" || $MNAME_M == "i386" || $MNAME_M == "ppc" || $MNAME_M == "power_macintosh") then
set mach = "macosx"
set nbits = 32
else
set mach = "ipad" # iOS Device
set nbits = 32
endif
endif
breaksw
case redhat:
case linux:
case linux64:
if ($?VOCARCH) then
set mach = "$VOCARCH"
if ($mach == "linux64") then
set nbits = 64
endif
else
if ($MNAME_M == "x86_64") then # Linux x86_64
set mach = "linux64"
set nbits = 64
else # Linux
set mach = "linux"
set nbits = 32
endif
endif
breaksw
case ssun:
case sparc:
case sunos:
if ($UNAME_M != "86pc") then
if ($OSVERSION == 5) then # Sparc Solaris
set mach = "ssun"
else # Sparc SunOS 4.x
set mach = "sparc"
endif
else
set mach = "sunos" # Intel Solaris x86
endif
breaksw
case freebsd: # FreeBSD
set mach = "freebsd"
breaksw
default:
# We don't want to be limited by the CYGWIN version numbering so
# look for a truncated match here before punting.
set os_mach = `echo $UNAME | cut -c1-6`
if ("$os_mach" == "cygwin") then
set mach = "cygwin"
breaksw
else
echo "Unable to determine platform architecture for ($MNAME)."
exit 1
endif
endsw
##############################################################################
# END OF MACHDEP DEFINITIONS.
##############################################################################
if ($#argv == 0) then
echo $mach
else
if ("$1" == "-mach") then
echo $mach
else if ("$1" == "-actual") then
echo $mach
else if ("$1" == "-current") then
echo $mach
else if ("$1" == "-nbits") then
echo $nbits
else if ("$1" == "-set") then
if ("$2" != "") then
setenv VOCARCH $2
shift ; shift
endif
goto repeat_
else
echo "Invalid option '"$1"'"
endif
endif