6d86081997-12-22Fredrik Hübinette (Hubbe) #!/bin/sh
e3fa691997-12-28Fredrik Hübinette (Hubbe) . $NTTOOLS
6d86081997-12-22Fredrik Hübinette (Hubbe)  OPTS="" CFLAGS="" SOURCES="" OBJECTS=""
09ca251998-01-16Fredrik Hübinette (Hubbe) OUTPUT=
6d86081997-12-22Fredrik Hübinette (Hubbe) OPERATION=linking INCLUDE_PATH=
c66b501998-01-01Fredrik Hübinette (Hubbe) LDOPTS="OPTION STACK=8m"
a12f271998-01-10Fredrik Hübinette (Hubbe) LIBRARIES=""
3f93431998-01-14Fredrik Hübinette (Hubbe) NTCC=wcc386
a12f271998-01-10Fredrik Hübinette (Hubbe)  DEBUG=no OPTIMIZE=no check_linker_error() { ERROR=ok sed -e 's/\\/\\\\/g' | while read line do echo "$line" >&2 case "x$line" in *\ W1008:*) ERROR=failed ;; esac done echo $ERROR exit 0 }
6d86081997-12-22Fredrik Hübinette (Hubbe)  while test "$#" != 0; do case $1 in
e3fa691997-12-28Fredrik Hübinette (Hubbe)  -shared) ;;
6d86081997-12-22Fredrik Hübinette (Hubbe)  -E) OPERATION=preprocessing ;; -c) OPERATION=compiling ;;
a12f271998-01-10Fredrik Hübinette (Hubbe)  -g*) CFLAGS="$CFLAGS -d2 " LDOPTS="$LDOPTS DEBUG WATCOM ALL" DEBUG=yes ;; # -O*) ;; -O) CFLAGS="$CFLAGS -ox" OPTIMIZE=yes ;; -O2) CFLAGS="$CFLAGS -otexan" OPTIMIZE=yes ;;
09ca251998-01-16Fredrik Hübinette (Hubbe)  *.c | *.s | *.S) SOURCES="$SOURCES $1" ;;
e3fa691997-12-28Fredrik Hübinette (Hubbe)  *.o | *.a) OBJECTS="$OBJECTS $1" ;;
6d86081997-12-22Fredrik Hübinette (Hubbe)  -o) OUTPUT="$2" ; shift ;; -I*) if test x$1 = x-I ; then tmp="$2" shift else tmp=`echo $1 | sed -e 's/^-I//g'` fi case $tmp in /usr/include/* | /usr/local/include*) ;; *) CFLAGS="$CFLAGS -i`fixpath $tmp`" ;; esac ;; -traditional-cpp | -lc | -lm) ;; -R | -L) shift ;; -R* | -L* | -Wl*) ;;
47a5f41998-01-21Fredrik Hübinette (Hubbe)  -W) CFLAGS="$CFLAGS -w2" ;; -Wall) CFLAGS="$CFLAGS -wx" ;;
6d86081997-12-22Fredrik Hübinette (Hubbe)  -D*)
47a5f41998-01-21Fredrik Hübinette (Hubbe)  CFLAGS="$CFLAGS `echo $1 | sed -e 's/^-D/-d/g'`" ;; -U*) CFLAGS="$CFLAGS `echo $1 | sed -e 's/^-U/-u/g'`"
6d86081997-12-22Fredrik Hübinette (Hubbe)  ;;
a12f271998-01-10Fredrik Hübinette (Hubbe)  -l*) tmp=`echo $1 | sed -e 's/^-l//'` LIBRARIES="$LIBRARIES LIBRARY $tmp" ;;
6d86081997-12-22Fredrik Hübinette (Hubbe) 
09ca251998-01-16Fredrik Hübinette (Hubbe)  -*)
6d86081997-12-22Fredrik Hübinette (Hubbe)  echo "Unrecognized option $1" exit 1 ;;
09ca251998-01-16Fredrik Hübinette (Hubbe)  *) SOURCES="$SOURCES $1" ;;
6d86081997-12-22Fredrik Hübinette (Hubbe)  esac shift done
09ca251998-01-16Fredrik Hübinette (Hubbe) #if [ x$DEBUG$OPTIMIZE = xyesyes ]; then # echo Debug and optimization not supported at the same time # exit 1 #else # : #fi
a12f271998-01-10Fredrik Hübinette (Hubbe) 
6d86081997-12-22Fredrik Hübinette (Hubbe) rm $OUTPUT 2>/dev/null 1>/dev/null || : OLDIFS="$IFS" IFS=: set dummy $INCLUDE_PATH shift IFS="$OLDIFS" IPATH=. IPATHS=":.:"
0dd2b11998-01-13Fredrik Hübinette (Hubbe) for a in "$@"
6d86081997-12-22Fredrik Hübinette (Hubbe) do case $IPATHS in *:$a:*) ;; *) IPATH="$IPATH;`fixpath $a`" IPATHS="$IPATHS:$a:" ;; esac done ERRORFILE=TMP$$.err rm $ERRORFILE 2>/dev/null 1>/dev/null || :
0dd2b11998-01-13Fredrik Hübinette (Hubbe) CFLAGS="$CFLAGS -bm -zq -hw -fr$ERRORFILE"
c66b501998-01-01Fredrik Hübinette (Hubbe) 
09ca251998-01-16Fredrik Hübinette (Hubbe)  compile() { if [ "x$2" != x ]; then OFLAGS="$OFLAGS -fo$2" else OFLAGS="$OFLAGS -fo`echo $1 | sed -e 's/\.[^.]$//'`.o" fi case $1 in *.s | *.S) do_cmd wasm -fe$ERRORFILE $OFLAGS `fixpath $1` ;; *) do_cmd $NTCC $CFLAGS $OFLAGS `fixpath $1` ;; esac }
6d86081997-12-22Fredrik Hübinette (Hubbe)  case $OPERATION in compiling)
09ca251998-01-16Fredrik Hübinette (Hubbe)  compile $SOURCES $OUTPUT
6d86081997-12-22Fredrik Hübinette (Hubbe)  TARGET=$OUTPUT ;; preprocessing)
09ca251998-01-16Fredrik Hübinette (Hubbe)  silent_do_cmd $NTCC -p $CFLAGS `fixpath $SOURCES`
6d86081997-12-22Fredrik Hübinette (Hubbe)  ;; linking) for a in `fixpath $SOURCES` do
09ca251998-01-16Fredrik Hübinette (Hubbe)  BASE=`echo $a | sed -e 's/\.[^.]$//'` compile $a $BASE.obj
6d86081997-12-22Fredrik Hübinette (Hubbe)  OBJECTS="$OBJECTS $BASE.obj" done LDFILE=TMP$$.lk
09ca251998-01-16Fredrik Hübinette (Hubbe)  if [ "x$OUTPUT" = "x" ]; then OUTPUT=a.out fi
a12f271998-01-10Fredrik Hübinette (Hubbe)  echo "name $OUTPUT.exe $LDOPTS FIL `fixpath $OBJECTS | sed -e 's/ /,/g'` $LIBRARIES" >$LDFILE OK=`do_cmd wlink @$LDFILE | check_linker_error` if [ x$OK != xok ]; then exit 1 fi
6d86081997-12-22Fredrik Hübinette (Hubbe)  TARGET=$OUTPUT.exe if [ $CLEANUP = yes ]; then if [ "x$LDFILE" != x ]; then rm $LDFILE || : fi fi ;; esac if [ -f $ERRORFILE ]; then cat $ERRORFILE 1>&2 if grep -iv 'Warning' <$ERRORFILE >/dev/null 2>/dev/null; then rm $ERRORFILE exit 1 fi rm $ERRORFILE fi if [ "x$TARGET" != x ]; then if [ ! -f "$TARGET" ]; then echo "RNTCC: output file not generated" exit 1 fi fi if [ $OPERATION = linking ]; then
c66b501998-01-01Fredrik Hübinette (Hubbe)  PWD=`pwd`
6d86081997-12-22Fredrik Hübinette (Hubbe)  echo >$OUTPUT "#!/bin/sh"
e3fa691997-12-28Fredrik Hübinette (Hubbe)  echo >>$OUTPUT ". \$NTTOOLS" echo >>$OUTPUT "set -e"
c66b501998-01-01Fredrik Hübinette (Hubbe)  echo >>$OUTPUT "silent_do_cmd '`fixpath $NTDRIVE$PWD/$TARGET`' \"\$@\""
a1ad681998-01-16Fredrik Hübinette (Hubbe)  echo >>$OUTPUT "exit \$?"
6d86081997-12-22Fredrik Hübinette (Hubbe)  chmod +x $OUTPUT fi