Annotation of uae/src/od-win32/wcc.sh, revision 1.1

1.1     ! root        1: #! /bin/sh
        !             2: #
        !             3: # Somewhat horrible shell script to convert GCC style options into Watcom
        !             4: # style.
        !             5: #
        !             6: # I put this into the public domain - if you think you can use it for
        !             7: # anything, use it.
        !             8: #
        !             9: # Written 1998 Bernd Schmidt
        !            10: 
        !            11: realdirname () {
        !            12:   tmp_save_dir=`pwd`
        !            13:   cd $@
        !            14:   result=`pwd -P`
        !            15:   cd $tmp_save_dir
        !            16:   result=`echo $result |sed 's,/,\\\\,g'`
        !            17: }
        !            18: 
        !            19: realfilename () {
        !            20:   case $@ in
        !            21:   */*)
        !            22:     tmp_save_dir=`pwd`
        !            23:     cd `echo $@ | sed 's,/[^/]*$,,'`
        !            24:     result=`pwd -P`/`basename $@`
        !            25:     cd $tmp_save_dir
        !            26:     ;;
        !            27:   *)
        !            28:     result=$@
        !            29:     ;;
        !            30:   esac
        !            31:   result=`echo $result |sed 's,/,\\\\,g'`
        !            32: }
        !            33: 
        !            34: gcc_wsysinc1=`echo $INCLUDE | sed 's,;, ,g' | sed 's,.:,;\\0,g' |sed -e 's,;,//,g' -e 's,:,/,g' -e 's,\\\\,/,g'`
        !            35: for foo in $gcc_wsysinc1; do
        !            36:   gcc_wsysinc2="$gcc_wsysinc2 -I$foo"
        !            37: done
        !            38: gcc_spcdefs="-undef -U__GNUC__ -U__GNUC_MINOR__ -D_WIN32 -D__WATCOMC__ -D_STDCALL_SUPPORTED=1 -D__X86__ -D__386__=1 -DM_I386=1 -D_M_I386 -D_M_IX86=500 -D__NT__=1"
        !            39: 
        !            40: mode=link
        !            41: options=
        !            42: srcfiles=
        !            43: asmfiles=
        !            44: objfiles=
        !            45: resfiles=
        !            46: outputfile=
        !            47: libraries=
        !            48: gnudefines=
        !            49: wccdefines=
        !            50: includes=
        !            51: gnuincludes=
        !            52: 
        !            53: next_is_output=no
        !            54: next_is_include=no
        !            55: 
        !            56: for arg in $@; do
        !            57: 
        !            58: if test $next_is_output = yes; then
        !            59:   outputfile=$arg
        !            60:   next_is_output=no
        !            61: else if test $next_is_include = yes; then
        !            62:   includes="$includes $arg"
        !            63:   gnuincludes="$gnuincludes -I$arg"
        !            64:   next_is_include=no
        !            65: else
        !            66:   case $arg in
        !            67: # Passing /xxx options directly may be too risky - they could be confused for
        !            68: # file names - so use this escape.
        !            69:   --/--*)
        !            70:     options="$options `echo $arg |sed s,^--/--,/,`"
        !            71:     ;;
        !            72: 
        !            73:   -I) next_is_include=yes
        !            74:     ;;
        !            75: 
        !            76:   -I*)
        !            77:     includes="$includes `echo $arg | sed 's,^-I,,'`"
        !            78:     gnuincludes="$gnuincludes $arg"
        !            79:     ;;
        !            80: 
        !            81:   -D*=*)
        !            82:     gnudefines="$gnudefines $arg"
        !            83:     wccdefines="$wccdefines `echo $arg |sed 's,^-D,/d,'`"
        !            84:     ;;
        !            85: 
        !            86:   -D*)
        !            87:     gnudefines="$gnudefines $arg"
        !            88:     wccdefines="$wccdefines `echo $arg |sed 's,^-D,/d,'`="
        !            89:     ;;
        !            90: 
        !            91:   -c) if [ "$mode" != "link" ]; then
        !            92:         echo "Bad argument"
        !            93:         exit 10
        !            94:       fi
        !            95:       mode=compile
        !            96:     ;;
        !            97: 
        !            98:   -S) if [ "$mode" != "link" ]; then
        !            99:         echo "Bad argument"
        !           100:         exit 10
        !           101:       fi
        !           102:       mode=assemble
        !           103:     ;;
        !           104: 
        !           105:   -E) if [ "$mode" != "link" ]; then
        !           106:         echo "Bad argument"
        !           107:         exit 10
        !           108:       fi
        !           109:       mode=preprocess
        !           110:     ;;
        !           111: 
        !           112:   -g) options="$options /d2"
        !           113:     ;;
        !           114: 
        !           115:   -o) next_is_output=yes
        !           116:     if [ "x$outputfile" != "x" ]; then
        !           117:       echo "Multiple output files!"
        !           118:       exit 10
        !           119:     fi
        !           120:     ;;
        !           121: 
        !           122:   -l*) libraries="$libraries `echo $arg | sed 's,^-l,,'`"
        !           123:     ;;
        !           124: 
        !           125:   *.c)
        !           126:     srcfiles="$srcfiles $arg"
        !           127:     ;;
        !           128: 
        !           129:   *.S)
        !           130:     asmfiles="$asmfiles $arg"
        !           131:     ;;
        !           132:     
        !           133:   *.res)
        !           134:     realfilename $arg
        !           135:     resfiles="$resfiles $result"
        !           136:     ;;
        !           137: 
        !           138:   *.o)
        !           139:     realfilename $arg
        !           140:     objfiles="$objfiles $result"
        !           141:     ;;
        !           142: 
        !           143:   *) echo "Bad argument: $arg"
        !           144:     ;;
        !           145:   esac
        !           146: fi
        !           147: fi
        !           148: done
        !           149: 
        !           150: #echo "Source files: $srcfiles"
        !           151: #echo "Object files: $objfiles"
        !           152: #echo "Output files: $outputfile"
        !           153: #echo "Libraries: $libraries"
        !           154: echo "Mode: $mode"
        !           155: #echo "Options: $options"
        !           156: 
        !           157: if [ "$mode" != "link" -a "x$libraries" != "x" ]; then
        !           158:   echo "Libraries specified in non-link mode!"
        !           159:   exit 10
        !           160: fi
        !           161: 
        !           162: prefiles=
        !           163: srccount=0
        !           164: for foo in $srcfiles; do
        !           165:   bar=wccsh-tmppre$srccount.i
        !           166:   prefiles="$prefiles $bar"
        !           167:   echo "gcc -E -nostdinc $gnuincludes $gcc_wsysinc2 $gcc_spcdefs $gnudefines $foo -o $bar"
        !           168:   if gcc -E -nostdinc $gnuincludes $gcc_wsysinc2 $gcc_spcdefs $gnudefines $foo -o $bar; then
        !           169: 
        !           170:   else
        !           171:     exit 10
        !           172:   fi
        !           173:   if [ ! -f $bar ]; then
        !           174:     exit 10
        !           175:   fi
        !           176:   srccount=`expr $srccount + 1`
        !           177: done
        !           178: 
        !           179: tmpobjs=
        !           180: if test $mode = compile -o $mode = link; then
        !           181:   tmpcnt=0
        !           182:   for foo in $asmfiles; do
        !           183:     bar=wccsh-tmpobj$tmpcnt.o
        !           184:     tmpcnt=`expr $tmpcnt + 1`
        !           185:     tmpobjs="$tmpobjs $bar"
        !           186:     echo "gcc -c $foo -o $bar"
        !           187:     gcc -c $foo -o $bar
        !           188:     srccount=`expr $srccount + 1`
        !           189:   done
        !           190:   for foo in $prefiles; do
        !           191:     bar=wccsh-tmpobj$tmpcnt.o
        !           192:     tmpcnt=`expr $tmpcnt + 1`
        !           193:     tmpobjs="$tmpobjs $bar"
        !           194:     sed -e '/^# [0123456789]*/s,^# ,#line ,' -e '/^#line/s,"[^"]*$,",' <$foo> wccsh_tmpsrc.c
        !           195:     echo "wcc386 $foo $options /fo=$bar"
        !           196:     wcc386 wccsh_tmpsrc.c $options /fo=wcc_tmp.o >&2
        !           197:     mv -f wcc_tmp.o $bar
        !           198:     if [ ! -f $bar ]; then
        !           199:       rm -f $prefiles $tmpobjs
        !           200:       exit 10
        !           201:     fi
        !           202:   done
        !           203: fi
        !           204: 
        !           205: case $mode in
        !           206:   preprocess)
        !           207:     for foo in $prefiles; do
        !           208:       if [ "x$outputfile" = "x" ]; then
        !           209:         cat $foo
        !           210:       else
        !           211:         mv -f $foo $outputfile
        !           212:       fi
        !           213:     done
        !           214:     ;;
        !           215: 
        !           216:   compile)
        !           217:     if [ "$srccount" != "1" -a "x$outputfile" != "x" ]; then
        !           218:       echo "cannot specify -o and -c with multiple compilations" >&2
        !           219:       exit 10
        !           220:     fi
        !           221:     if [ "x$outputfile" != "x" ]; then
        !           222:       echo Moving "'" $tmpobjs "'" to "'" $outputfile "'"
        !           223:       if mv $tmpobjs $outputfile 2>/dev/null; then
        !           224:       fi
        !           225:     fi
        !           226:     ;;
        !           227: 
        !           228:   assemble)
        !           229:     ;;
        !           230: 
        !           231:   link)
        !           232:     if [ "x$outputfile" = "x" ]; then
        !           233:       outputfile=a.out
        !           234:     fi
        !           235:     FILES=
        !           236:     for foo in $objfiles $tmpobjs; do
        !           237:       if [ "x$FILES" = "x" ]; then
        !           238:         FILES=$foo
        !           239:       else
        !           240:         FILES="$FILES,$foo"
        !           241:       fi
        !           242:     done
        !           243:     for foo in $resfiles; do
        !           244:       FILES="$FILES op resource=$foo"
        !           245:     done
        !           246:     for foo in $libraries; do
        !           247:       FILES="$FILES LIB $foo"
        !           248:     done
        !           249: #    echo Files: $FILES
        !           250: #    echo "wlink SYSTEM nt FIL $FILES NAME $outputfile"
        !           251:     wlink SYSTEM nt FIL $FILES NAME $outputfile >wccsh-linkerror.log
        !           252:     if grep "cannot open.*No such file or" wccsh-linkerror.log; then
        !           253: #      rm wccsh-linkerror.log
        !           254:       rm $outputfile
        !           255:       exit 10
        !           256:     fi
        !           257: #    rm wccsh-linkerror.log
        !           258:     if [ ! -f $outputfile ]; then
        !           259:       rm -f $prefiles $tmpobjs
        !           260:       exit 10
        !           261:     fi
        !           262:     ;;
        !           263: esac
        !           264: 
        !           265: rm -f $prefiles $tmpobjs
        !           266: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.