diff --git a/bash/smake/smake.sh b/bash/smake/smake.sh index c6e4319..5a3e429 100755 --- a/bash/smake/smake.sh +++ b/bash/smake/smake.sh @@ -83,6 +83,57 @@ echo >> Makefile # ======= Rules ======= cat $RULES_FILE >> Makefile +REP_INCLUDE=`echo $REP_INCLUDE | sed "s~-I~~g ; s~\\$(HOME)~${HOME}~g"` +flist[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 + + 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 + done + + [ found == false ] && files_not_found=`echo "$files_not_found\n$f" | sort -u` + done + let nparsed++ +done + +for i in `seq 0 $((nfiles-1))`; do + echo ${flist[$i]}:${fdeplist[$i]} +done + +# ======= Warning ======= +files_not_found=`echo -e "$files_not_found" | sort -u` +if [ "$files_not_found" != "" ]; then + echo WARNING: Include files not found: $files_not_found +fi + +##################################################################################### +##################################################################################### +##################################################################################### +##################################################################################### +##################################################################################### +exit 0 +cat $RULES_FILE >> Makefile + REP_INCLUDE=`echo $REP_INCLUDE | sed "s~-I~~g ; s~\\$(HOME)~${HOME}~"` # --- Target deplist ---