aboutsummaryrefslogtreecommitdiff
path: root/unix/hlib/cl.csh.ORIG
blob: bab64f9dd4f73652d93a3a04caa0ca0539f8bb99 (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
#!/bin/csh -f
#
# CL.CSH -- Startup the version of the CL executable compiled for the
# architecture or floating point hardware appropriate for the current
# machine.  This script can be used to invoke a number of CL flavors 
# depending on how it is called.  The install script will create a 'cl'
# and 'ecl' command link to this script with the intent that a different
# binary would be started for each command.  


# Determine CL binary to run based on how we were called.

set cl_binary		= "ecl.e"

if (`echo $0 | egrep ecl` != "") then
    set cl_binary	= "ecl.e"

else if (`echo $0 | egrep vo` != "") then
    set cl_binary	= "vocl.e"

else if ($#argv > 0) then
    if ("$argv[1]" == "-old" || "$argv[1]" == "-o") then
        set cl_binary	= "cl.e"
    else if ("$argv[1]" == "-vo" || "$argv[1]" == "-o") then
        set cl_binary	= "vocl.e"
    else if ("$argv[1]:e" == "c") then
	# Workaround for autoconf scripts attempting to use this command as
	# a valid compiler option.  On some systems (mostly Debian) a valid
	# CC command can't be found and eventually the 'cl' (lisp) compiler
	# is tried.  It will always apparently have the conftest.c test file,
	# so simply exit with a code to tell autoconf it won't work.
	exit 1
    endif
endif


# Determine IRAF root directory (value set in install script).
set d_iraf = "/iraf/iraf/"
if ($?iraf) then
    if (! -e $iraf) then
        echo "Warning: iraf=$iraf does not exist (check .cshrc or .login)"
        echo "Session will default to iraf=$d_iraf"
        unsetenv iraf ; sleep 3
    endif
endif
if ($?iraf == 0) then
    setenv iraf "$d_iraf"
endif


# Check for a version query.
if ($#argv > 0) then
    if ("$argv[1]" == "-v" || "$argv[1]" == "-version" || \
	"$argv[1]" == "-V" || "$argv[1]" == "--version") then
            head -1 $iraf/unix/hlib/motd
	    exit 0
    endif
endif


# Determine platform architecture.
if ($?IRAFARCH) then
    if (-e $iraf/bin.${IRAFARCH}/${cl_binary}) then
	set MACH = $IRAFARCH
    endif
endif

if (! $?MACH) then

    # SUN-IRAF
    setenv OSNAME `uname`
    if ($OSNAME == 'SunOS') then
        setenv OSVERSION `uname -r | cut -c1`
        if ($OSVERSION == 5) then
            set MACH = `uname -p`
            switch ($MACH)
            case sparc:
                set MACH = ssol
                breaksw
            endsw
        else
            set MACH = `mach`
        endif

    else

        # PC-IRAF
        set os_mach = `uname -s | tr '[A-Z]' '[a-z]' | cut -c1-6`
        if (-f /etc/redhat-release) then
	    if (`uname -m` == "ppc") then
	        setenv mach linuxppc
	    else
	        setenv mach redhat
	    endif
        else
	    set mach = `uname -s | tr '[A-Z]' '[a-z]'`
        endif

        if ($mach == "darwin") then
            if ("`uname -m`" == "i386") then
                setenv mach macintel
            else
                setenv mach macosx
            endif
        else if ($os_mach == "cygwin") then
            setenv mach cygwin
        endif


        if (-e $iraf/bin.$mach/$cl_binary) then
	    set MACH = $mach
        else if (-e $iraf/bin.freebsd/$cl_binary) then
	    set MACH = freebsd
        else if (-e $iraf/bin.macosx/$cl_binary) then
	    set MACH = macosx
        else if (-e $iraf/bin.macintel/$cl_binary) then
	    set MACH = macintel
        else if (-e $iraf/bin.cygwin/$cl_binary) then
	    set MACH = cygwin
        else if (-e $iraf/bin.linux/$cl_binary) then
	    set MACH = linux
        else if (-e $iraf/bin.redhat/$cl_binary) then
	    set MACH = redhat
        else if (-e $iraf/bin.linuxppc/$cl_binary) then
	    set MACH = linuxppc
        else if (-e $iraf/bin.sunos/$cl_binary) then
	    set MACH = sunos
        else if (-e $iraf/bin.linuz/$cl_binary) then
	    set MACH = linuz
        else
	    echo "cannot find $iraf/bin.xxx/$cl_binary"
	    exit 1
        endif

    endif

endif

# Check for obsolete IRAFBIN definition.
if ($?IRAFBIN && !($?IRAFARCH)) then
    echo "Use IRAFARCH rather than IRAFBIN to specify the machine architecture"
    echo "IRAFARCH, if defined, should be one of ffpa,f68881,i386,sparc, etc."
endif

# Just run the CL if IRAFARCH already defined.
if ($?IRAFARCH) then
    if ($IRAFARCH == "") then
	setenv arch ""
    else
	setenv arch ".$IRAFARCH"
    endif

    # Recent linux systems display a problem in how pointer addresses 
    # interact with the stack and can result in a segfault.  Remove the
    # stacksize limit for IRAF processes until this is better understood.
    if ("$IRAFARCH" == "redhat" || \
        "$IRAFARCH" == "linux" || \
        "$IRAFARCH" == "linuxppc") then
	    limit stacksize unlimited
    endif

    setenv IRAFBIN ${iraf}bin$arch/
    set file = ${IRAFBIN}$cl_binary
    if (-e $file) then
	exec $file
    else
	echo "$file not found"
    endif
endif


# Determine the architecture to be used.
if ("$MACH" == "freebsd") then			# PC-IRAF
    setenv IRAFARCH "freebsd"
else if ("$MACH" == "linux") then
    setenv IRAFARCH "linux"
else if ("$MACH" == "redhat") then
    setenv IRAFARCH "redhat"
else if ("$MACH" == "linuxppc") then
    setenv IRAFARCH "linuxppc"
else if ("$MACH" == "macosx") then
    setenv IRAFARCH "macosx"
else if ("$MACH" == "macintel") then
    setenv IRAFARCH "macintel"
else if ("$MACH" == "cygwin") then
    setenv IRAFARCH "cygwin"
else if ("$MACH" == "sunos") then
    setenv IRAFARCH "sunos"
else if ("$MACH" == "linuz") then
    setenv IRAFARCH "linuz"

else if ("$MACH" == "ssol") then		# SUN-IRAF
    setenv IRAFARCH "ssun"
else if ("$MACH" == "sparc") then
    setenv IRAFARCH "sparc"
endif

# Recent linux systems display a problem in how pointer addresses 
# interact with the stack and can result in a segfault.  Remove the
# stacksize limit for IRAF processes until this is better understood.
if ("$IRAFARCH" == "redhat" || \
    "$IRAFARCH" == "linux" || \
    "$IRAFARCH" == "linuxppc") then
	limit stacksize unlimited
endif

setenv arch .$IRAFARCH
setenv IRAFBIN ${iraf}bin$arch/
set file = ${IRAFBIN}$cl_binary

# Run the desired CL.
exec $file