home *** CD-ROM | disk | FTP | other *** search
- head 1.5;
- access ;
- symbols ;
- locks ; strict;
- comment @# @;
-
-
- 1.5
- date 87.03.06.20.34.29; author geoff; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 87.02.28.00.56.50; author geoff; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 86.11.08.23.07.56; author geoff; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 86.11.08.22.15.24; author geoff; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 86.11.08.21.58.14; author geoff; state Exp;
- branches ;
- next ;
-
-
- desc
- @Shell script to compile long-name C programs.
- @
-
-
- 1.5
- log
- @Make -p work correctly
- @
- text
- @: Use bin/sh
- #
- # $Header: lcc.sh,v 1.4 87/02/28 00:56:50 geoff Exp $
- #
- # $Log: lcc.sh,v $
- # Revision 1.4 87/02/28 00:56:50 geoff
- # Major changes to handle things much better by running each compiler
- # pass separately. Also add the -R switch, and support for -D and
- # library files.
- #
- # Revision 1.3 86/11/08 23:07:56 geoff
- # Add error processing, not quite like cc's
- #
- # Revision 1.2 86/11/08 22:15:24 geoff
- # Remove -HP, minor cleanup of output. Working, except ignores errors
- #
- # Revision 1.1 86/11/08 21:58:14 geoff
- # Works only if -HP specified
- #
- #
- # Replacement for the 'cc' command, with support for long
- # identifiers.
- #
- # Usage:
- #
- # lcc [options] files
- #
- # As with 'cc', the files mentioned can be .c, .s, or .o files.
- #
- # All 'cc' options are support (or should be -- report bugs!).
- #
- # There are some extra options. All begin with H:
- #
- # -HD Don't preserve the encode/decode table. (Normally, it is
- # left in xxxx.t, where xxxx is the first file name encountered,
- # or the -o file name if -o is specified.)
- # -HA name The encode/decode table is put in <name>. If it exists,
- # the program will append to it.
- # -HL Only the C compiler itself is deficient; the assembler
- # and linker can handle long names. Use this facility to
- # generate long-name object files. This is incompatible
- # with -P and -S, but conflict is not checked.
- # -R name Add <name> to the reserved-word list. Useful for
- # library routines that have long names.
- #
- # Options supported:
- #
- # -I<dir> Set include path for cpp
- # -S Generate .s files
- # -c Generate .o files; don't load
- # -n Generate shared text (ld)
- # -p Generate profiled output
- # -f* Passed on to cc
- #
- TDIR=${TMPDIR:-/tmp} # Where to put temp files
- TFILE=lcc$$ # Base name for encoded source files
- TMP=$TDIR/$TFILE # Base name of cc's encoded input files
- TABLE=${TFILE}t # Where the decode file goes
- c1sw= # Switches for compiler pass 1
- ccsw= # Switches for cc
- ldsw= # Switches for ld
- suffix=o # Suffix of output "object" files: o, s, or i
- forceobj=-c # How to force "objects": -c, -P, or -S
- load=yes # Yes to invoke loader
- numsrcfiles= # If this is exactly one x, we kill objects
- ofiles= # Files to be linked
- optimize=no # -O switch specified
- optsw= # Switches for optimizer
- preprocess= # Preprocess option: null, -P, or -E
- reserved= # Reserved-word list
- rmfiles= # List of object files to remove (only one)
- verbose= # Verbose option: -v or null
- killtable=no # Yes if $TABLE is to be deleted
- tablename= # Name of the output table
- madetable=no # Yes if we added to the table
- dumbcc=no # Yes if only cc is dumb about long names
-
- if [ -x /lib/c ]
- then
- COMPILER=/lib/c
- elif [ -x /usr/lib/c ]
- then
- COMPILER=/usr/lib/c
- else
- COMPILER=c
- fi
- if [ -x /lib/c2 ]
- then
- OPTIMIZER=/lib/c2
- elif [ -x /usr/lib/c2 ]
- then
- OPTIMIZER=/usr/lib/c2
- else
- OPTIMIZER=c2
- fi
- trap '/bin/rm -f ${TFILE}.? ${TMP}* $TABLE; exit 1' 1 2 15
- # 7 is SIGEMT, a fairly obscure one
- failure=no
- trap "failure=yes" 7
- while [ $# -gt 0 ]
- do
- case "$1" in
- -HD)
- TABLE=${TMP}t # Put output table in $TMPDIR
- killtable=yes
- ;;
- -HA)
- tablename=$2
- TABLE=$2
- shift
- ;;
- -HL)
- dumbcc=yes
- ;;
- -R)
- reserved="$reserved -r $2"
- shift
- ;;
- -n)
- ldsw="$ldsw $1"
- ;;
- -v)
- verbose=-v
- ;;
- -p)
- ldsw="$ldsw $1"
- c1sw="$c1sw -Xp"
- ;;
- -f*)
- ldsw="$ldsw $1"
- c1sw="$c1sw $1"
- ;;
- -o)
- ldsw="$ldsw $1 $2"
- tablename=$2.t
- shift
- ;;
- -R)
- ldsw="$ldsw $1 $2"
- shift
- ;;
- -E|-P)
- preprocess=$1
- forceobj=$1
- suffix=i
- load=no
- ;;
- -O*)
- optimize=yes
- optsw=`echo $1 | tr -d O`
- if [ "X$optsw" = "X-" ]
- then
- optsw=
- fi
- ;;
- -C|-D*|-U*|-I*)
- ccsw="$ccsw $1"
- ;;
- -S)
- forceobj=-S
- suffix=s
- load=no
- numsrcfiles=xx
- ;;
- -c)
- load=no
- numsrcfiles=xx
- ;;
- -l*)
- ofiles="$ofiles $1"
- ;;
- *.o)
- numsrcfiles=xx
- ofiles="$ofiles $1"
- if [ "$tablename" = "" ]
- then
- tablename=`basename $1 .o`.t
- fi
- ;;
- *.s)
- if [ "$dumbcc" = "yes" -a "X$preprocess" = "X" ]
- then
- if cc $ccsw $verbose $forceobj $1
- then
- :
- else
- failure=yes
- break
- fi
- elif [ "$suffix" != "s" -a "X$preprocess" = "X" ]
- then
- hash8 $reserved encode $TABLE < $1 > ${TMP}.s
- madetable=yes
- (cc $ccsw $forceobj $verbose ${TMP}.s 2> ${TMP}.e \
- || kill -7 $$) \
- | sed "s;${TMP}.s;$1;" | hash8 decode $TABLE
- sed "s;${TMP}.s;$1;" ${TMP}.e | hash8 decode $TABLE 1>&2
- if [ "$failure" = "yes" ]
- then
- break
- fi
- obj=`basename "$1" '.s'`.$suffix
- ofiles="$ofiles $obj"
- rmfiles="$rmfiles $obj"
- mv ${TFILE}.$suffix $obj
- numsrcfiles="x$numsrcfiles"
- fi
- if [ "$tablename" = "" ]
- then
- tablename=`basename $1 .s`.t
- fi
- ;;
- *.c)
- obj=`basename "$1" '.c'`.$suffix
- ppfile=${TMP}.i
- if [ "X$verbose" = "X-v" ]
- then
- echo "${1}:"
- echo " Preprocessing" 1>&2
- fi
- if [ "X$preprocess" = "X-E" ]
- then
- if cc $ccsw $preprocess $1
- then
- :
- else
- failure=yes
- fi
- elif [ "X$preprocess" = "X-P" ]
- then
- ppfile=$obj
- fi
- if cc $ccsw -E $1 > $ppfile
- then
- :
- else
- failure=yes
- /bin/rm -f $ppfile
- break
- fi
- if [ "X$preprocess" = "X-P" ]
- then
- break
- fi
- hash8 $reserved encode $TABLE < $ppfile > ${TMP}.c
- madetable=yes
- /bin/rm -f $ppfile
- if [ "$optimize" = yes ]
- then
- unoptfile=${TMP}.s1
- else
- unoptfile=${TMP}.s
- fi
- if [ "X$verbose" = "X-v" ]
- then
- echo " Compiling" 1>&2
- fi
- if $COMPILER $c1sw < ${TMP}.c > $unoptfile 2> ${TMP}.e
- then
- /bin/rm -f ${TMP}.c
- else
- hash8 decode $TABLE < ${TMP}.e 1>&2
- /bin/rm $unoptfile ${TMP}.c ${TMP}.e
- failure=yes
- break
- fi
- if [ $optimize = yes ]
- then
- if [ "X$verbose" = "X-v" ]
- then
- echo " Optimizing" 1>&2
- fi
- if $OPTIMIZER $optsw < $unoptfile > ${TMP}.s 2> ${TMP}.e
- then
- /bin/rm -f $unoptfile
- unoptfile=${TMP}.s
- else
- hash8 decode $TABLE < ${TMP}.e 1>&2
- /bin/rm -f $unoptfile ${TMP}.s ${TMP}.e
- failure=yes
- break
- fi
- fi
- case "X$forceobj" in
- X-S)
- hash8 _decode $TABLE < $unoptfile > $obj
- /bin/rm -f $unoptfile
- ;;
- *)
- if [ "X$verbose" = "X-v" ]
- then
- echo " Assembling" 1>&2
- fi
- if [ "$dumbcc" = "yes" ]
- then
- mv $unoptfile ${TMP}.s1
- hash8 _decode $TABLE < ${TMP}.s1 > ${TMP}.s
- /bin/rm -f ${TMP}.s1
- if as -o $obj ${TMP}.s
- then
- :
- else
- /bin/rm -f ${TMP}.s $obj
- failure=yes
- break
- fi
- else
- if as -o $obj $unoptfile 2> ${TMP}.e
- then
- /bin/rm -f $unoptfile ${TMP}.e
- else
- hash8 _decode $TABLE < ${TMP}.e 1>&2
- /bin/rm -f $unoptfile ${TMP}.e $obj
- failure=yes
- break
- fi
- fi
- ofiles="$ofiles $obj"
- rmfiles="$rmfiles $obj"
- ;;
- esac
- numsrcfiles="x$numsrcfiles"
- if [ "$tablename" = "" ]
- then
- tablename=`basename $1 .c`.t
- fi
- ;;
- *)
- echo "lcc: unrecognized argument $1, passing to cc and ld" 1>&2
- echo "type 'cat $0' to learn usage"
- ccsw="$ccsw $1"
- ldsw="$ldsw $1"
- ;;
- esac
- shift
- done
- if [ "$load" = yes -a "$failure" = "no" ]
- then
- if [ "X$verbose" = "X-v" ]
- then
- echo " Loading" 1>&2
- fi
- (cc $ldsw $ofiles 2> ${TMP}.e || kill -7 $$) \
- | if [ "$madetable" = yes ]
- then
- hash8 _decode $TABLE
- hash8 _decode $TABLE < ${TMP}.e 1>&2
- elif [ -r "$tablename" ]
- then
- hash8 _decode $tablename
- hash8 _decode $tablename < ${TMP}.e 1>&2
- else
- cat
- cat ${TMP}.e 1>&2
- fi
- if [ "$numsrcfiles" = x ]
- then
- /bin/rm -f $rmfiles
- fi
- fi
- /bin/rm -f ${TFILE}.? ${TMP}*
- if [ "$killtable" = "yes" -o "$tablename" = "" ]
- then
- /bin/rm -f $TABLE
- elif [ "$madetable" = yes -a "$TABLE" != "$tablename" ]
- then
- mv $TABLE $tablename
- fi
- if [ "$failure" = "yes" ]
- then
- exit 1
- else
- exit 0
- fi
- @
-
-
- 1.4
- log
- @Major changes to handle things much better by running each compiler
- pass separately. Also add the -R switch, and support for -D and
- library files.
- @
- text
- @d3 1
- a3 1
- # $Header: lcc.sh,v 1.3 86/11/08 23:07:56 geoff Exp $
- d6 5
- d59 1
- d127 1
- a127 1
- ccsw="$ccsw $1"
- d129 4
- d156 1
- a156 1
- -f*|-C|-D*|-U*|-I*)
- d258 1
- a258 1
- if $COMPILER < ${TMP}.c > $unoptfile 2> ${TMP}.e
- @
-
-
- 1.3
- log
- @Add error processing, not quite like cc's
- @
- text
- @d3 1
- a3 1
- # $Header: lcc.sh,v 1.2 86/11/08 22:15:24 geoff Exp $
- d6 3
- d37 3
- a39 1
- # with -P and -S, but conflict is not cheked.
- d61 2
- d64 2
- d72 19
- a90 1
- trap "/bin/rm -f ${TFILE}.? ${TMP}* $TABLE; exit 1" 1 2 15
- a106 2
- forceobj=-S
- suffix=s
- d109 4
- d138 9
- a146 1
- -f*|-O*|-C|-D*|-U*|-I*)
- d159 3
- d182 1
- a182 1
- hash8 encode $TABLE < $1 > ${TMP}.s
- d194 1
- d204 32
- a235 1
- hash8 encode $TABLE < $1 > ${TMP}.c
- d237 2
- a238 4
- (cc $verbose $ccsw $forceobj ${TMP}.c 2> ${TMP}.e || kill -7 $$) \
- | sed "s;${TMP}.c;$1;" | hash8 decode $TABLE
- sed "s;${TMP}.c;$1;" ${TMP}.e | hash8 decode $TABLE 1>&2
- if [ "$failure" = "yes" ]
- d240 15
- d257 27
- a283 5
- case "X${preprocess}Y$forceobj" in
- X-P*|*Y-S)
- obj=`basename "$1" '.c'`.$suffix
- hash8 _decode $TABLE < ${TFILE}.$suffix > $obj
- /bin/rm -f ${TFILE}.$suffix
- d286 4
- a289 1
- if [ "X$verbose" = "X-v" ]
- d291 5
- a295 1
- echo " Assembling" 1>&2
- d297 2
- a298 1
- if cc $ccsw -c $obj
- d300 1
- a300 1
- :
- d302 2
- a306 2
- /bin/rm -f $obj
- obj=`basename "$1" '.c'`.o
- d309 1
- a310 7
- X-E*)
- ;;
- *)
- obj=`basename "$1" '.c'`.$suffix
- ofiles="$ofiles $obj"
- mv ${TFILE}.$suffix $obj
- ;;
- d329 5
- a333 1
- (cc $verbose $ldsw $ofiles 2> ${TMP}.e || kill -7 $$) \
- d337 1
- d341 1
- d344 2
- a345 1
- fi 1>&2
- d348 1
- a348 1
- /bin/rm -f $ofiles
- @
-
-
- 1.2
- log
- @Remove -HP, minor cleanup of output. Working, except ignores errors
- @
- text
- @d3 1
- a3 1
- # $Header: lcc.sh,v 1.1 86/11/08 21:58:14 geoff Exp $
- d6 3
- d64 3
- d133 7
- a139 1
- cc $ccsw $verbose $forceobj $1
- d144 8
- a151 3
- (cc $ccsw $forceobj $verbose ${TMP}.s 2>&1 ) \
- | sed "s;${TMP}.s;$1;" \
- | hash8 decode $TABLE 1>&2
- d165 1
- a165 1
- (cc $verbose $ccsw $forceobj ${TMP}.c 2> ${TMP}.e ) \
- d168 4
- d183 7
- a189 1
- cc $ccsw -c $obj
- d218 1
- a218 1
- if [ "$load" = yes ]
- d220 1
- a220 1
- (cc $verbose $ldsw $ofiles 2>&1) \
- d243 6
- a248 1
- exit
- @
-
-
- 1.1
- log
- @Works only if -HP specified
- @
- text
- @d3 1
- a3 1
- # $Header$
- d5 4
- a8 1
- # $Log$
- a31 3
- # -HP Hash before passing information to the preprocessor, rather
- # than after. Useful if your preprocessor is dumb. Conflicts
- # with -E and -P.
- d53 1
- a53 1
- preprocess= # Preprocess option: null, -P, -E, or dumbpp
- a77 4
- -HP)
- preprocess=dumbpp
- load=no
- ;;
- d146 1
- a146 13
- if [ "X$preprocess" = "X" ]
- then
- #
- # We preprocess before hashing so that symbols in include
- # files are picked up. The disadvantage of this is that
- # preprocessor names are not shortened, which gives trouble
- # if your preprocessor is also dumb. In this case,
- # specify the -HP switch.
- #
- cc $ccsw -E $1 | hash8 encode $TABLE > ${TMP}.c
- else
- hash8 encode $TABLE < $1 > ${TMP}.c
- fi
- d149 1
- a149 1
- | hash8 decode $TABLE
- d193 1
- a193 1
- (cc $ldsw $ofiles 2>&1) \
- @
-