From 0a820d90f055a4b85c6171e4ef68c6378fe73410 Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Wed, 27 Jan 1999 08:45:40 +0000 Subject: [PATCH] Better handling of compiler options. Thanks to Tim Rice for the patch. git-svn-id: svn://10.0.0.236/trunk@18761 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/build/hcc | 46 +++++++++++++++++++++++++------ mozilla/build/hcpp | 67 +++++++++++++++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 26 deletions(-) diff --git a/mozilla/build/hcc b/mozilla/build/hcc index ea33953948a..952ddf21b21 100755 --- a/mozilla/build/hcc +++ b/mozilla/build/hcc @@ -23,12 +23,37 @@ CC=`echo $1 | sed -e "s|'||g" -e 's|"||g'` shift DASH_C=0 DASH_O=0 +DUMMY="XxxXxxX" +GET_OBJECT=0 +OBJ="${DUMMY}" +OBJECT="${DUMMY}" + for i in $* do [ "${CHECK_O}" = yes ] && { - OBJECT=$i - OPTS="${OPTS} -o $i" - i="" + case $i in + ./*/*.o) OBJECT="$i" + OPTS="${OPTS} -o" + DASH_O=1 + ;; + ./*.o) OBJECT="`basename $i`" + i="" + DASH_O=1 + ;; + *.o) if [ $i = `basename $i` ] + then + OBJECT="$i" + i="" + else + OPTS="${OPTS} -o" + fi + DASH_O=1 + ;; + *) OPTS="${OPTS} -o $i" + DASH_O=1 + i="" + ;; + esac CHECK_O=no } case $i in @@ -39,8 +64,15 @@ do ;; *.c) C_SRC=$i OPTS="${OPTS} $i" +# cc always creates the .o from the .c name + OBJ=`basename $C_SRC .c`.o ;; *.s) S_SRC=$i + OPTS="${OPTS} $i" +# or the .o from the .s name + OBJ=`basename $S_SRC .s`.o + ;; + *.o) OBJECT=$i OPTS="${OPTS} $i" ;; *) OPTS="${OPTS} $i" @@ -53,9 +85,7 @@ ${CC} ${OPTS} || exit $? # if there was no -c and -o we're done [ $DASH_C = 1 -a $DASH_O = 1 ] || exit 0 -# cc always creates the .o from the .c name -[ $C_SRC ] && OBJ=`basename $C_SRC .c`.o -# or the .o from the .s name -[ $S_SRC ] && OBJ=`basename $S_SRC .s`.o +# if $OBJ and $OBJECT are the same we're done +[ $OBJ = $OBJECT ] && exit 0 -[ -f $OBJECT ] || ( [ -f $OBJ ] && mv -f $OBJ $OBJECT ) +[ -f $OBJ ] && mv -f $OBJ $OBJECT diff --git a/mozilla/build/hcpp b/mozilla/build/hcpp index 61560135107..6592ac69136 100755 --- a/mozilla/build/hcpp +++ b/mozilla/build/hcpp @@ -33,36 +33,75 @@ OBJECT="${DUMMY}" for i in $* do - if [ ${GET_OBJECT} -eq 1 ]; then - OBJECT="$i" - GET_OBJECT=0 - fi + [ ${GET_OBJECT} -eq 1 ] && { + case $i in + ./*/*.o) OBJECT="$i" + OPTS="${OPTS} -o" + DASH_O=1 + ;; + ./*.o) OBJECT="`basename $i`" + i="" + DASH_O=1 + ;; + *.o) if [ $i = `basename $i` ] + then + i="" + else + OPTS="${OPTS} -o" + DASH_O=1 + fi + ;; + *) OPTS="${OPTS} -o $i" + DASH_O=1 + i="" + ;; + esac + GET_OBJECT=0 + } case $i in -c) DASH_C=1 + OPTS="${OPTS} -c" ;; -o) - DASH_O=1 GET_OBJECT=1 ;; *.c) C_SRC="$i" + OPTS="${OPTS} $i" +# cc always creates the .o from the .c name + OBJ=`basename ${C_SRC} .c`.o ;; +.*) + OPTS="${OPTS} $i" ;; *.cpp) CPP_SRC="$i" + OPTS="${OPTS} $i" +# cc always creates the .o from the .cpp name + OBJ=`basename ${CPP_SRC} .cpp`.o ;; *.cc) CC_SRC="$i" + OPTS="${OPTS} $i" +# cc always creates the .o from the .cc name + OBJ=`basename ${CC_SRC} .cc`.o ;; *.s) S_SRC="$i" + OPTS="${OPTS} $i" +# cc always creates the .o from the .s name + OBJ=`basename ${S_SRC} .s`.o + ;; + *.o) OBJECT=$i + OPTS="${OPTS} $i" + ;; + *) OPTS="${OPTS} $i" ;; esac done -${CXX} $* || exit $? +${CXX} ${OPTS} || exit $? # LAME!!! if [ -f -O ]; then @@ -72,16 +111,8 @@ fi # if there was no -c and -o we're done [ ${DASH_C} -eq 1 -a ${DASH_O} -eq 1 ] || exit 0 -# cc always creates the .o from the .c name -if [ "${C_SRC}" != "${DUMMY}" ]; then - OBJ=`basename ${C_SRC} .c`.o -elif [ "${CPP_SRC}" != "${DUMMY}" ]; then - OBJ=`basename ${CPP_SRC} .cpp`.o -elif [ "${CC_SRC}" != "${DUMMY}" ]; then - OBJ=`basename ${CC_SRC} .cc`.o -# or the .o from the .s name -elif [ "${S_SRC}" != "${DUMMY}" ]; then - OBJ=`basename ${S_SRC} .s`.o -fi +# if $OBJ and $OBJECT are the same we're done +[ $OBJ = $OBJECT ] && exit 0 + +[ -f $OBJ ] && mv -f $OBJ $OBJECT -[ -f $OBJECT ] || ( [ -f $OBJ ] && mv -f $OBJ $OBJECT )