#!/bin/sh |
|
. $NTTOOLS |
|
set -e |
|
OPTS="" |
CFLAGS="" |
SOURCES="" |
OBJECTS="" |
OUTPUT=a.out |
OPERATION=linking |
INCLUDE_PATH= |
LDOPTS="OPTION STACK=8m" |
LIBRARIES="" |
|
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 |
} |
|
while test "$#" != 0; do |
case $1 in |
-shared) ;; |
-E) OPERATION=preprocessing ;; |
-c) OPERATION=compiling ;; |
-g*) |
CFLAGS="$CFLAGS -d2 " |
LDOPTS="$LDOPTS DEBUG WATCOM ALL" |
DEBUG=yes |
;; |
# -O*) ;; |
-O) |
CFLAGS="$CFLAGS -ox" |
OPTIMIZE=yes |
;; |
-O2) |
CFLAGS="$CFLAGS -otexan" |
OPTIMIZE=yes |
;; |
*.c) SOURCES="$SOURCES $1" ;; |
*.o | *.a) OBJECTS="$OBJECTS $1" ;; |
-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*) ;; |
|
-D*) |
CFLAGS="$CFLAGS `echo $1 | sed -e 's/^-I/-d/g'`" |
;; |
|
-l*) |
tmp=`echo $1 | sed -e 's/^-l//'` |
LIBRARIES="$LIBRARIES LIBRARY $tmp" |
;; |
|
*) |
echo "Unrecognized option $1" |
exit 1 |
;; |
esac |
shift |
done |
|
if [ x$DEBUG$OPTIMIZE = xyesyes ]; then |
echo Debug and optimization not supported at the same time |
exit 1 |
else |
: |
fi |
|
rm $OUTPUT 2>/dev/null 1>/dev/null || : |
|
OLDIFS="$IFS" |
IFS=: |
set dummy $INCLUDE_PATH |
shift |
IFS="$OLDIFS" |
|
IPATH=. |
IPATHS=":.:" |
|
for a in $* |
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 || : |
|
CFLAGS="$CFLAGS -zq -hw -fr$ERRORFILE" |
|
if [ "x$OUTPUT" != x ]; then |
OFLAGS="$OFLAGS -fo$OUTPUT" |
else |
OFLAGS= |
fi |
|
case $OPERATION in |
compiling) |
do_cmd wcc386 $CFLAGS $OFLAGS `fixpath $SOURCES $OBJECTS` |
TARGET=$OUTPUT |
;; |
|
preprocessing) |
do_cmd wcc386 -p $CFLAGS `fixpath $SOURCES` |
;; |
|
linking) |
for a in `fixpath $SOURCES` |
do |
BASE=`echo $a | sed -e 's/\.c//'` |
do_cmd wcc386 -i$IPATH $CFLAGS -fo=$BASE.obj $a |
OBJECTS="$OBJECTS $BASE.obj" |
done |
|
LDFILE=TMP$$.lk |
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 |
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 |
PWD=`pwd` |
echo >$OUTPUT "#!/bin/sh" |
echo >>$OUTPUT ". \$NTTOOLS" |
echo >>$OUTPUT "set -e" |
echo >>$OUTPUT "silent_do_cmd '`fixpath $NTDRIVE$PWD/$TARGET`' \"\$@\"" |
chmod +x $OUTPUT |
fi |
|