2 PATH=/v/bin:/bin:/usr/bin
3 # f77-style shell script to compile and load fortran, C, and assembly codes
5 # usage: f77 [-O] [-o absfile] [-c] files [-l library]
7 # -o objfile Override default executable name a.out.
9 # -c Do not call linker, leave relocatables in *.o.
11 # -S leave assembler output on file.s
13 # -l library (passed to ld).
15 # -u complain about undeclared variables
17 # -w omit all warning messages
19 # -w66 omit Fortran 66 compatibility warning messages
21 # files FORTRAN source files ending in .f .
22 # C source files ending in .c .
23 # Assembly language files ending in .s .
24 # efl source files ending in .e .
26 # -D def passed to C compiler (for .c files)
28 # -I includepath passed to C compiler (for .c files)
30 # -Ntnnn allow nnn entries in table t
34 CC=${CC_f2c:-'/v/bin/lcc -Wfdouble=8,4,1'}
35 EFL=${EFL:-/v/bin/efl}
36 EFLFLAGS=${EFLFLAGS:-'system=portable deltastno=10'}
37 F2C=${F2C:-/v/bin/f2c}
38 F2CFLAGS=${F2CFLAGS:='-ARw8'}
40 trap "rm -f $s $t; exit \$rc" 0
44 set -- `getopt cD:gI:N:Oo:Suw6 "$@"`
45 case $? in 0);; *) exit 1;; esac
56 -D) CCFLAGS="$CCFLAGS -D$2"
60 -g) CFLAGS="$CFLAGS -g"
63 -I) CCFLAGS="$CCFLAGS -I$2"
71 -O) case $2 in -1) O=-O1;; -2) O=-O2;; -3) O=-O3;; *) O=-O;; esac
72 case $O in -O);; *) shift;; esac
77 -u) F2CFLAGS="$F2CFLAGS -u"
81 -w) F2CFLAGS="$F2CFLAGS -w"
82 case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift
83 case $2 in -6) shift;; esac;; esac
87 -N) F2CFLAGS="$F2CFLAGS $1""$2"
91 -S) CFLAGS="$CFLAGS -S"
97 echo "invalid parameter $1" 1>&2
109 case "$1" in *.f) f=".f";; *.F) f=".F";; esac
112 case $? in 0);; *) exit;; esac
113 $CC -c $CFLAGS $b.c 2>$s
115 sed '/parameter .* is not referenced/d;/warning: too many parameters/d' $s 1>&2
116 case $rc in 0);; *) exit;; esac
117 OFILES="$OFILES $b.o"
119 case $cOPT in 1) cOPT=2;; esac
124 $EFL $EFLFLAGS $1 >$b.f
125 case $? in 0);; *) exit;; esac
127 case $? in 0);; *) exit;; esac
129 case $? in 0);; *) exit;; esac
130 OFILES="$OFILES $b.o"
132 case $cOPT in 1) cOPT=2;; esac
137 OFILE=`basename $1 .s`.o
138 ${AS:-/usr/bin/as} -o $OFILE $AFLAGS $1
139 case $? in 0);; *) exit;; esac
140 OFILES="$OFILES $OFILE"
141 case $cOPT in 1) cOPT=2;; esac
146 OFILE=`basename $1 .c`.o
147 $CC -c $CFLAGS $CCFLAGS $1
148 rc=$?; case $rc in 0);; *) exit;; esac
149 OFILES="$OFILES $OFILE"
150 case $cOPT in 1) cOPT=2;; esac
155 case $cOPT in 1) cOPT=2;; esac
159 OFILES="$OFILES -l$2"
161 case $cOPT in 1) cOPT=2;; esac
166 case $cOPT in 1) cOPT=2;; esac
173 case $cOPT in 1) cOPT=2;; esac
178 case $cOPT in 2) $CC -o $OUTF -u MAIN__ $OFILES -lf2c -lm;; esac