From c8f6aa36d4df4d19349a1f22e91b9bfe14329593 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 8 Jul 2011 18:12:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D0=BD=D0=B0=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D1=82=20ssdparser.c,=20=D1=85=D0=BE=D1=82=D1=8F=20=D0=BF?= =?UTF-8?q?=D1=83=D1=82=D1=8C=20=D0=BA=20=D0=BD=D0=B5=D0=BC=D1=83=20=D1=83?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/smake/smake.sh | 49 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/bash/smake/smake.sh b/bash/smake/smake.sh index 5a3e429..227b62a 100755 --- a/bash/smake/smake.sh +++ b/bash/smake/smake.sh @@ -48,6 +48,9 @@ done cat $HELP_FILE > Makefile echo >> Makefile +# ======= Test for target ======= +[ ! -f $REP_TARGET.c ] && echo "$REP_TARGET.c doesn't exist" && exit -1 + # ======= Environment ======= sed "s~REP_CC~$REP_CC~ ; s~REP_CXX~$REP_CXX~ ; \ s~REP_LIBRARIES~$REP_LIBRARIES~ ; s~REP_TARGET~$REP_TARGET~" $ENV_FILE >> Makefile @@ -85,33 +88,41 @@ cat $RULES_FILE >> Makefile REP_INCLUDE=`echo $REP_INCLUDE | sed "s~-I~~g ; s~\\$(HOME)~${HOME}~g"` flist[0]=$REP_TARGET.c +fpath[0]=$REP_TARGET.c nfiles=1 nparsed=0 fdeplist[0]=`remove_c_comments.pl $REP_TARGET.c | grep -P '^[\t ]*#include[\t ]*"' | sed 's~[^"]*"\([^"]*\)".*~\1~' | sort -u` files_not_found= while [ $nfiles != $nparsed ]; do for f in ${fdeplist[$nparsed]}; do - already_in_list=false - for i in `seq 0 $((nparsed))`; do - if [ "${flist[$i]}" == "$f" ]; then - already_in_list=false - break; - fi - done - [ $already_in_list == true ] && continue + extension=`basename $f | sed 's~.*\.~~g'` + f=`echo $f | sed "s~.$extension$~~"` + for ext in "$extension" c cxx cpp; do + already_in_list=false + for i in `seq 0 $((nfiles))`; do + if [ "${flist[$i]}" == "$f.$ext" ]; then + already_in_list=true + break; + fi + done + [ $already_in_list == true ] && continue - found=false - for d in . $REP_INCLUDE; do - if [ -f "$d/$f" ]; then - found=true - flist[$nfiles]=$f - fdeplist[$nfiles]=`remove_c_comments.pl $d/$f | grep -P '^[\t ]*#include[\t ]*"' | sed 's~[^"]*"\([^"]*\)".*~\1~' | sort -u` - let nfiles++ - break - fi + F= + for d in . $REP_INCLUDE; do + if [ -f "$d/$f.$ext" ]; then + F="$d/$f.$ext" + fi + if [ "$F" != "" ]; then + flist[$nfiles]=$f.$ext + fpath[$nfiles]=$F + fdeplist[$nfiles]=`remove_c_comments.pl $F | grep -P '^[\t ]*#include[\t ]*"' | sed 's~[^"]*"\([^"]*\)".*~\1~' | sort -u` + let nfiles++ + break + fi + done + [[ "$F" == "" && "$ext" == "$extension" ]] && files_not_found=`echo "$files_not_found\n$f.$ext" | sort -u` + [[ "$F" != "" && "$ext" != "$extension" ]] && break done - - [ found == false ] && files_not_found=`echo "$files_not_found\n$f" | sort -u` done let nparsed++ done