| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | PATH=/bin:/usr/bin:/usr/local/binscip-shell filesystem . . `/bin:/usr/bin:/usr/local/bin`. |
| 3 | # f77-style shell script to compile and load fortran, C, and assembly codes |
| 4 | |
| 5 | # usage: f77 [-g] [-O] [-o absfile] [-c] files [-l library] |
| 6 | |
| 7 | # -o objfile Override default executable name a.out. |
| 8 | |
| 9 | # -c Do not call linker, leave relocatables in *.o. |
| 10 | |
| 11 | # -S leave assembler output on file.s |
| 12 | |
| 13 | # -l library (passed to ld). |
| 14 | |
| 15 | # -u complain about undeclared variables |
| 16 | |
| 17 | # -w omit all warning messages |
| 18 | |
| 19 | # -w66 omit Fortran 66 compatibility warning messages |
| 20 | |
| 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 . |
| 25 | |
| 26 | # -D def passed to C compiler (for .c files) |
| 27 | |
| 28 | # -I includepath passed to C compiler (for .c files) |
| 29 | |
| 30 | # -Ntnnn allow nnn entries in table t |
| 31 | |
| 32 | # CG. |
| 33 | unset CFLAGS |
| 34 | s=/tmp/stderr_$$ |
| 35 | t=/tmp/f77_$$.o |
| 36 | CC=${CC_f2c:-'gcc'} |
| 37 | F2C=${F2C:-f2c} |
| 38 | F2CFLAGS=${F2CFLAGS:='-ARw8 -Nn802'} |
| 39 | rc=0 |
| 40 | trap "rm -f $s $t; exit \$rc" 0 |
| 41 | OUTF=a.out |
| 42 | cOPT=1 |
| 43 | set -- `getoptscip-shell system . . getopt. cD:gI:N:Oo:Suw6 "$@"` |
| 44 | case $? in 0);; *) exit 1;; esac |
| 45 | CCFLAGS= |
| 46 | while |
| 47 | testscip-shell system . . test. X"$1" != X-- |
| 48 | do |
| 49 | case "$1" |
| 50 | in |
| 51 | -c) cOPT=0 |
| 52 | shift |
| 53 | ;; |
| 54 | |
| 55 | -D) CCFLAGS="$CCFLAGS -D$2" |
| 56 | shift 2 |
| 57 | ;; |
| 58 | |
| 59 | -g) CFLAGS="$CFLAGS -g" |
| 60 | CCFLAGS="$CCFLAGS -g" |
| 61 | F2CFLAGS="$F2CFLAGS -g" |
| 62 | shift;; |
| 63 | |
| 64 | -I) CCFLAGS="$CCFLAGS -I$2" |
| 65 | shift 2 |
| 66 | ;; |
| 67 | |
| 68 | -o) OUTF=$2 |
| 69 | shift 2 |
| 70 | ;; |
| 71 | |
| 72 | -O) case $2 in -1) O=-O1;; -2) O=-O2;; -3) O=-O3;; *) O=-O;; esac |
| 73 | case $O in -O);; *) shift;; esac |
| 74 | shift |
| 75 | ;; |
| 76 | |
| 77 | -u) F2CFLAGS="$F2CFLAGS -u" |
| 78 | shift |
| 79 | ;; |
| 80 | |
| 81 | -w) F2CFLAGS="$F2CFLAGS -w" |
| 82 | case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift |
| 83 | case $2 in -6) shift;; esac;; esac |
| 84 | shift |
| 85 | ;; |
| 86 | |
| 87 | -N) F2CFLAGS="$F2CFLAGS $1""$2" |
| 88 | shift 2 |
| 89 | ;; |
| 90 | |
| 91 | -S) CFLAGS="$CFLAGS -S" |
| 92 | cOPT=0 |
| 93 | shift |
| 94 | ;; |
| 95 | |
| 96 | *) |
| 97 | echoscip-shell system . . echo. "invalid parameter $1" 1>&2 |
| 98 | shift |
| 99 | ;; |
| 100 | esac |
| 101 | done |
| 102 | shift |
| 103 | while |
| 104 | testscip-shell system . . test. -n "$1" |
| 105 | do |
| 106 | case "$1" |
| 107 | in |
| 108 | *.[fF]) |
| 109 | case "$1" in *.f) f=".f";; *.F) f=".F";; esac |
| 110 | b=`basenamescip-shell system . . basename. $1 $f` |
| 111 | #echo "fff" |
| 112 | $F2C $F2CFLAGS $1 |
| 113 | case $? in 0);; *) exit;; esac |
| 114 | $CC -c $CFLAGS $b.c 2>$s |
| 115 | rc=$? |
| 116 | sedscip-shell system . . sed. '/parameter .* is not referenced/d;/warning: too many parameters/dscip-shell filesystem . . `/parameter .* is not referenced/d;/warning: too many parameters/d`.' $s 1>&2 |
| 117 | case $rc in 0);; *) exit;; esac |
| 118 | OFILES="$OFILES $b.o" |
| 119 | rmscip-shell system . . rm. $b.c |
| 120 | case $cOPT in 1) cOPT=2;; esac |
| 121 | shift |
| 122 | ;; |
| 123 | *.s) |
| 124 | echoscip-shell system . . echo. $1: 1>&2 |
| 125 | OFILE=`basenamescip-shell system . . basename. $1 .s`.o |
| 126 | ${AS:-/usr/bin/as} -o $OFILE $AFLAGS $1 |
| 127 | case $? in 0);; *) exit;; esac |
| 128 | OFILES="$OFILES $OFILE" |
| 129 | case $cOPT in 1) cOPT=2;; esac |
| 130 | shift |
| 131 | ;; |
| 132 | *.c) |
| 133 | echoscip-shell system . . echo. $1: 1>&2 |
| 134 | OFILE=`basenamescip-shell system . . basename. $1 .c`.o |
| 135 | $CC -c $CFLAGS $CCFLAGS $1 |
| 136 | rc=$?; case $rc in 0);; *) exit;; esac |
| 137 | OFILES="$OFILES $OFILE" |
| 138 | case $cOPT in 1) cOPT=2;; esac |
| 139 | shift |
| 140 | ;; |
| 141 | *.o) |
| 142 | OFILES="$OFILES $1" |
| 143 | case $cOPT in 1) cOPT=2;; esac |
| 144 | shift |
| 145 | ;; |
| 146 | -l) |
| 147 | OFILES="$OFILES -l$2" |
| 148 | shift 2 |
| 149 | case $cOPT in 1) cOPT=2;; esac |
| 150 | ;; |
| 151 | -l*) |
| 152 | OFILES="$OFILES $1" |
| 153 | shift |
| 154 | case $cOPT in 1) cOPT=2;; esac |
| 155 | ;; |
| 156 | -o) |
| 157 | OUTF=$2; shift 2;; |
| 158 | *) |
| 159 | OFILES="$OFILES $1" |
| 160 | shift |
| 161 | case $cOPT in 1) cOPT=2;; esac |
| 162 | ;; |
| 163 | esac |
| 164 | done |
| 165 | |
| 166 | case $cOPT in 2) $CC -o $OUTF $OFILES -lf2c -lm;; esac |
| 167 | rc=$? |
| 168 | exit $rc |