blob: 9e5beb812c9d6259fa0e633acf7638b19ca5e358 (
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
|
#!/bin/sh
# This fc1 script invoke f2c and pass the output to cc
# it includes the undocumented -Nn option of f2c
# adapted from the netlib distribution 'fc' by G. Masini 04-18-00
#
# f77-style shell script to compile and load fortran, C, and assembly codes
# usage: f77 [options] files [-l library]
# Options:
# -o objfile Override default executable name a.out.
# -c Do not call linker, leave relocatables in *.o.
# -C Check that subscripts are in bounds.
# -S leave assembler output on file.s
# -L libdir (passed to ld)
# -l library (passed to ld)
# -u complain about undeclared variables
# -w omit all warning messages
# -w66 omit Fortran 66 compatibility warning messages
# files FORTRAN source files ending in .f .
# Object files ending in .o .
# f2c prototype files ending in .P ; such
# files only affect subsequent files.
# -D def passed to C compiler (for .f files)
# -I includepath passed to C compiler (for .c files)
# and to f2c
# -Ntnnn allow nnn entries in table t
# -P emit .P files
# -U def passed to C compiler (for .c files)
# to remove def
s=/tmp/stderr_$$
t=/tmp/f77_$$.o
CC=${CC_f2c:-'cc'}
F2C=${F2C:-/usr/local/bin/f2c}
F2CFLAGS=${F2CFLAGS:='-ARw8 -Nn802 -Nq300 -Nx400'}
rc=0
trap "rm -f $s $t; exit \$rc" 0
OUTF=a.out
OUTO=
cOPT=1
set -- `getopt cCD:gI:L:N:OU:o:Suw6 "$@"`
case $? in 0);; *) rc=$?; exit;; esac
CFLAGSF2C=${CFLAGSF2C:-'-I/usr/local/include'}
OFILES=
while
test X"$1" != X--
do
case "$1"
in
-C) F2CFLAGS="$F2CFLAGS -C"
shift;;
-c) cOPT=0
shift
;;
-D) CFLAGS="$CFLAGS -D$2"
shift 2
;;
-g) CFLAGS="$CFLAGS -g"
F2CFLAGS="$F2CFLAGS -g"
shift;;
-I) F2CFLAGS="$F2CFLAGS -I$2"
shift 2
;;
-o) OUTF=$2
OUTO=$2
shift 2
;;
-O) case $2 in -1) O=-O1;; -2) O=-O2;; -3) O=-O3;; *) O=-O;; esac
case $O in -O);; *) shift;; esac
CFLAGS="$CFLAGS $O -O"
shift
;;
-u) F2CFLAGS="$F2CFLAGS -u"
shift
;;
-w) F2CFLAGS="$F2CFLAGS -w"
case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift
case $2 in -6) shift;; esac;; esac
shift
;;
-L) OFILES="$OFILES $1$2"
shift 2
case $cOPT in 1) cOPT=2;; esac
;;
-L*) OFILES="$OFILES $1"
shift
case $cOPT in 1) cOPT=2;; esac
;;
-N) F2CFLAGS="$F2CFLAGS $1""$2"
shift 2
;;
-P) F2CFLAGS="$F2CFLAGS $1"
shift
;;
-S) CFLAGS="$CFLAGS -S"
cOPT=0
shift
;;
*)
echo "invalid parameter $1" 1>&2
shift
;;
esac
done
shift
case $cOPT in 0) case $OUTO in '');; *) CFLAGS="$CFLAGS -o $OUTO";; esac;; esac
while
test -n "$1"
do
case "$1"
in
*.[f])
f=".f"
b=`basename $1 .f`
$F2C $F2CFLAGS $1
rc=$?
case $rc in 0);; *) exit;; esac
$CC -c $CFLAGSF2C $CFLAGS $b.c 2>$s
rc=$?
sed '/parameter .* is not referenced/d;/warning: too many parameters/d' $s 1>&2
case $rc in 0);; *) exit;; esac
OFILES="$OFILES $b.o"
rm $b.c
case $cOPT in 1) cOPT=2;; esac
shift
;;
-o)
case $cOPT in 0) CFLAGS="$CFLAGS -o $2";; *) OUTF=$2;; esac
shift 2;;
*)
OFILES="$OFILES $1"
shift
case $cOPT in 1) cOPT=2;; esac
;;
esac
done
case $cOPT in 2) $CC -o $OUTF -u MAIN__ -L/usr/local/lib $OFILES -lf2c -lm;; esac
rc=$?
exit $rc
|