: ppcc [ options ] pp-command ... cc-command ... # # preprocess with pp-command then run cc-command # # @(#)ppcc (Lucent Technologies - Bell Laboratories) 10/01/96 # # Modified by cgo - 10/30/96 # This version is for Sun's C++ - RELEASE VERSION SC4.0 18 Oct 1995 C++ 4.1 # + fix: sometimes the sed of Modeules.DB matched the wrong entry. # + fix: command line not fully parsed for oflg and dbgflg if an arg # not starting with [+-] comes before -g or -o on the compile line. # command=ppcc clobber= doti= exec=1 old= ppfile= ppld= ppstdout= src1="*.[cCsS]" src2="*.[cC][xX][xX]" src3="*.[cC][pP][pP]" src4="*.[aA][sS][mM]" src5="*.[cC][cC]" srcpp="$src4" tname=$$ in="" out="" rem=0 tmp=/tmp/pC$$ verbose= usage="Usage: $command [ -ilnv ] pp-command ... cc-command ..." while : do case $# in 0) break ;; esac case $1 in -*) case $1 in -*[!ilnvO]*) echo "$usage" >&2 exit 2 ;; esac case $1 in *i*) doti=1 ;; esac case $1 in *l*) ppld=1 ;; esac case $1 in *n*) exec= ;; esac case $1 in *v*) verbose=1 ;; esac case $1 in *O*) old=1 ;; esac ;; *) break ;; esac shift done case $# in 0) echo "$usage" >&2 exit 2 ;; esac trap ' status=$? trap "" 0 case $clobber in ?*) case $verbose in 1) echo + rm -rf $clobber ;; esac case $exec in 1) rm -rf $clobber ;; esac ;; esac exit $status ' 0 1 2 3 15 ERR case $old:$RANDOM in *:$RANDOM|1:*) # the hard way -- but it *will* be correct nfile= set '' "$@" '' "$1" while : do shift shift case $1 in [-+]*) ;; *) break ;; esac set '' "$@" "$1" done while : do arg=$1 shift case $arg in '') break ;; -o) case $1 in ?*) set '' "$@" "$arg" shift arg=$1 shift ;; esac ;; -E) ppstdout=1 doti=1 trap 0 1 2 3 15 ;; -P) ppfile=1 doti=1 trap 0 1 2 3 15 ;; [-+]*) ;; $src1|$src2|$src3|$src4|$src5) nfile=_$nfile eval input$nfile='$arg' case $ppstdout in "") case $doti in "") file=`echo $arg | sed -e "s,.*/,," -e "s,^,$tmp/,"` case $clobber in "") clobber=$tmp case $verbose in 1) print -r -- + mkdir $tmp ;; esac case $exec in 1) mkdir $tmp || exit ;; esac ;; esac ;; *) file=`echo $arg | sed -e "s,.*/,," -e "s,[.][^.]*,.i,"` clobber="$clobber $file" ;; esac eval output$nfile='$file' ;; esac ;; esac set '' "$@" "$arg" shift done # sub-shell to split pp and cc arg lists ( set '' "$@" '' "$1" while : do shift shift case $1 in [-+]*) ;; *) shift break ;; esac set '' "$@" "$1" done case $doti$ppstdout in "") set '' "$@" -D-L shift ;; esac shift while : do arg=$1 shift case $arg in '') break ;; -o) case $1 in ?*) shift ;; esac continue ;; -[DIU]*|-[a-zA-Z][a-zA-Z0-9_]*) ;; [-+]*) continue ;; $src1|$src2|$src3|$src4|$src5) break ;; esac set '' "$@" "$arg" shift done case $nfile in ?*) while : do arg=$1 shift case $arg in '') break ;; esac done n= while : do case $n in $nfile) break ;; esac n=_$n eval input='$input'$n case $ppstdout in "") eval output='$output'$n case $verbose in 1) echo + "$@" "$input" "$output" ;; esac case $exec in 1) "$@" "$input" "$output" || exit ;; esac ;; *) case $verbose in 1) echo + "$@" "$input" ;; esac case $exec in 1) "$@" "$input" || exit ;; esac ;; esac done ;; esac ) || exit case $ppfile$ppstdout in ?*) exit ;; esac while : do shift case $1 in [-+]*) ;; *) break ;; esac done set '' "$@" '' "$1" shift shift n= while : do arg=$1 shift case $arg in '') break ;; -o) case $1 in ?*) set '' "$@" "$arg" shift arg=$1 shift ;; esac ;; -[DIU]*)case $ppld in "") continue ;; esac ;; [-+]*) ;; $src1|$src2|$src3|$src4|$src5) n=_$n eval arg='$output'$n ;; esac set '' "$@" "$arg" shift done case $verbose in 1) echo + "$@" ;; esac case $exec in 1) "$@" ;; esac ;; *) integer npp=1 ncc=1 nav=1 xav=$# dbgflg=0 oflg=0 outi="" x="$@" set $x shift shift while : do arg=$1 case $arg in -g) dbgflg=1 [[ $oflg = 1 ]] && break ;; -o) oflg=1 [[ $dbgflg = 1 ]] && break ;; "") break; esac shift done set -A av $x pp[0]=${av[0]} while (( nav < xav )) do arg=${av[nav]} (( nav = nav + 1 )) case $arg in [-+]*) ;; *) break ;; esac pp[npp]=$arg (( npp = npp + 1 )) done case $doti in "") pp[npp]=-D-L (( npp = npp + 1 )) ;; esac cc[0]=$arg while (( nav < xav )) do arg=${av[nav]} (( nav = nav + 1 )) case $arg in -o) if (( nav < xav )) then cc[ncc]=$arg (( ncc = ncc + 1 )) arg=${av[nav]} (( nav = nav + 1 )) fi ;; -[DIU]*|-[a-zA-Z][a-zA-Z0-9_]*) case $arg in -PIC) ;; *) pp[npp]=$arg (( npp = npp + 1 )) ;; esac case $ppld in "") case $arg in -[DIU]*) continue ;; esac ;; esac ;; -E) ppstdout=1 doti=1 srcpp="*" trap 0 1 2 3 15 continue ;; -P) ppfile=1 doti=1 srcpp="*" trap 0 1 2 3 15 continue ;; -#*|-dryrun|--dryrun|-verbose|--verbose) verbose=1 ;; [-+]*) ;; $src1|$src2|$src3|$src4|$src5|$srcpp) case $ppstdout in "") out=${arg##*/} in=$arg case $doti in 1) out=${out%.*}.i outi=${out%.*}\\.i clobber="$clobber $out" ;; *) case $clobber in "") clobber=$tmp case $verbose in 1) print -r -- + mkdir $tmp ;; esac case $exec in 1) mkdir $tmp || exit ;; esac ;; esac out=$tmp/$out outi=$out ;; esac if [ $dbgflg = 1 ] then pp[npp+2]=$out else pp[npp+1]=$out fi ;; esac if [ $dbgflg = 1 ] then pp[npp+1]=$arg pp[npp]=-g else pp[npp]=$arg fi arg=$out case $verbose in 1) print -r -- + "${pp[@]}" ;; esac case $exec in 1) "${pp[@]}" || exit ;; esac ;; esac case $arg in -c) cc[ncc]=$arg if [ $dbgflg = 1 ] then rem=$ncc fi ;; -O) if [ $dbgflg = 0 ] then cc[ncc]=$arg fi ;; *) cc[ncc]=$arg ;; esac (( ncc = ncc + 1 )) done case $ppfile$ppstdout in "") case $verbose in 1) print -r -- + "${cc[@]}" ;; esac case $exec in 1) "${cc[@]}" if [ -f "./Templates.DB/Module.DB/${out%.*}.module" ] then sed -e s?$outi?$in?g ./Templates.DB/Module.DB/${out%.*}.module >$tname.tmp mv $tname.tmp ./Templates.DB/Module.DB/${out%.*}.module fi if [ $dbgflg = 1 ] && [ $oflg = 0 ] then cc[rem]=-S "${cc[@]}" sed -e s?$outi?$in?g ${out%.*}.s >$tname.tmp mv $tname.tmp ${out%.*}.s clobber="$clobber ${out%.*}.s" x=ncc while (( x > 0 )) do (( x = x - 1 )) if [ "${cc[x]}" = "$out" ] then cc[x]=${out%.*}.s fi if [ "${cc[x]}" = "-S" ] then cc[x]=-c fi done "${cc[@]}" fi ;; esac ;; esac esac