aboutsummaryrefslogtreecommitdiff
path: root/unix/hlib/irafarch.csh
blob: a998aa01ae0c78f288f1221c84090450239fdead (plain) (blame)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/bin/csh -f
#
#  IRAFARCH -- Determine or set the current platform architecture parameters.
#
#  Usage:       irafarch
#		irafarch -set [<arch>] [opts]
#               irafarch [ -hsi | -nbits | -pipe | -tapecap | -tape ]
#
#	-mach		print the iraf architecture name [default]
#	-hsi		print the HSI arch
#	-nbits		print number of bits in an int (32 or 64)
#	-pipe		does platform support display fifo pipes?
#	-tapecap	does platform require tapecap changes?
#	-tape		does platform support tape drives?
#	-shlib		does platform support iraf shared libs?
#
#	-actual		print actual architecture name regardless of IRAFARCH
#	-set <arch>	manually reset the iraf 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		= "V2.16.1"
set hmach 		= "INDEF"
set nbits 		= 32
set pipes 		= 1
set shlibs 		= 0
set tapecaps 		= 0
set tapes 		= 1

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 an IRAFARCH definition in the environment to override.
if ($#argv == 1 && "$1" == "-actual") then
    setenv MNAME     $UNAME
    setenv MNAME_M   $UNAME_M
    unsetenv IRAFARCH

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 IRAFARCH  $MNAME
    goto repeat_

else
  if ($#argv == 0) then
    if ($?IRAFARCH) then
  repeat_:
	setenv MNAME     $IRAFARCH
	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 shlib		= 0			# no shared lib support
set nbits		= 32			# 32-bit architecture
set tapecaps 		= 1			# platform supports tapecaps
set tapes 		= 1			# platform support tape drives
set pipes 		= 1			# supports display fifo pipes
	
set pciraf		= 1			# PC-IRAF system
set suniraf		= 0			# SUN-IRAF system


if ($debug == 1) then				# DEBUG PRINT
    if ($?IRAFARCH) then
        echo " IRAFARCH = $IRAFARCH"
    endif
    echo "    MNAME = $MNAME"
    echo "  MNAME_M = $MNAME_M"
    echo "OSVERSION = $OSVERSION"
endif

# Determine parameters for each architecture.
switch ($MNAME) 
    case darwin: 					# Mac OS X
    case ipad:
    case macosx:
    case macintel:
        if ($?IRAFARCH) then
            set mach 		= "$IRAFARCH"
            set hmach 		= "$IRAFARCH"
	    if ("$mach" == "macintel") then
		set nbits	= 64
	    endif
	else 
            if ("$MNAME_M" == "x86_64") then		# 64-bit
                set mach 	= "macintel"
                set hmach 	= "macintel"
		set nbits	= 64
            else if ($MNAME_M == "x86" || $MNAME_M == "i386" || $MNAME_M == "ppc" || $MNAME_M == "power_macintosh") then
                set mach 	= "macosx"
                set hmach 	= "macosx"
		set nbits	= 32
            else
                set mach 	= "ipad"		# iOS Device
                set hmach 	= "ipad"
		set nbits	= 32
            endif
	endif
	set tapecaps 		= 0
	set tapes 		= 0
	set pipes 		= 0
        breaksw

    case redhat:
    case linux:
    case linux64:
        if ($?IRAFARCH) then
            set mach 		= "$IRAFARCH"
            set hmach 		= "$IRAFARCH"
	    if ("$mach" == "linux64") then
		set nbits	= 64
	    endif
	else 
            if ("$MNAME_M" == "x86_64") then		# Linux x86_64
                set mach 	= "linux64"
                set hmach 	= "linux64"
	        set nbits	= 64
            else					# Linux
                set mach 	= "linux"
                set hmach 	= "linux"
	        set nbits	= 32
            endif
        endif
        breaksw

    case ssun:
    case sparc:
    case sunos:
	set tapecaps 		= 1
        if ($UNAME_M != "86pc") then
	    set suniraf		= 1
	    set pciraf		= 0
            if ($OSVERSION == 5) then			# Sparc Solaris
                set mach  	= "ssun"
                set hmach 	= "ssol"
            else			   		# Sparc SunOS 4.x
                set mach  	= "sparc"
                set hmach 	= "sparc"
            endif
        else
            set mach 		= "sunos"	    	# Intel Solaris x86
            set hmach 		= "sunos"
	    set tapecaps 	= 0
	    set tapes 		= 0
	    set pipes 		= 0
        endif
        breaksw

    case freebsd: 					# FreeBSD
        set mach 		= "freebsd"
        set hmach 		= "freebsd"
	set tapecaps 		= 0
	set tapes 		= 0
	set pipes 		= 0
        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"
            set hmach 		= "cygwin"
	    set shlib		= 0
	    set tapecaps 	= 0
	    set tapes 		= 0
	    set pipes 		= 0
            breaksw

	else
	    echo  "Unable to configure platform IRAFARCH='$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" == "-hsi") then
	echo $hmach
    else if ("$1" == "-nbits") then
	echo $nbits
    else if ("$1" == "-pipes") then
	echo $pipes
    else if ("$1" == "-tapecap") then
	echo $tapecaps
    else if ("$1" == "-tapes") then
	echo $tapes
    else if ("$1" == "-shlib") then
	echo $shlib

    else if ("$1" == "-set") then
	if ("$2" != "") then
	    setenv IRAFARCH	   $2
	    shift ; shift
	endif
	goto repeat_
    else 
	echo "Invalid option '"$1"'"
    endif
endif

exit 0