diff --git a/bash/smake/smake.sh b/bash/smake/smake.sh index eb50d03..c6e4319 100755 --- a/bash/smake/smake.sh +++ b/bash/smake/smake.sh @@ -129,6 +129,7 @@ echo "target_objs = \\" >> Makefile for to in $target_obj_lst; do echo -e "\t$to \\" >> Makefile done +echo >> Makefile echo '$(TARGET): $(target_objs)' >> Makefile echo -e '\t$(CC) $(LDFLAGS) -o $@ $(target_objs)' >> Makefile @@ -145,13 +146,14 @@ for cf in `echo "$target_dep_lst" | grep -P '.c$'`; do fi done if [ "$CF" == "" ]; then - files_not_dound="$files_not_found\n$cf" + files_not_found="$files_not_found\n$cf" continue fi to=`basename "$cf" | sed 's~.c$~.o~'` target_dep_lst="$CF "`remove_c_comments.pl $CF | grep -P '^[\t ]*#include[\t ]*"' | sed 's~[^"]*"\([^"]*\)".*~\1~' | sort -u` + old_target_dep_lst= files_not_found= while [[ "$target_dep_lst" != "$old_target_dep_lst" ]]; do old_target_dep_lst=$target_dep_lst @@ -174,9 +176,25 @@ for cf in `echo "$target_dep_lst" | grep -P '.c$'`; do done done - echo "$to: " >> Makefile + target_dep_lst= + for f in $old_target_dep_lst; do + F="" + for d in . $REP_INCLUDE; do + if [ -f "$d/$f" ]; then + F="$d/$f" + break + fi + done + if [ "$F" == "" ]; then + files_not_found="$files_not_found\n$f" + continue + fi + target_dep_lst=`echo "$F $target_dep_lst" | sed 's~ ~\n~g' | sort -u` + done + + echo "$to: \\" >> Makefile for td in $target_dep_lst; do - td=`echo "$td" | sed "s~^\./~~ ; s~${HOME}~$\(HOME\)~"` + td=`echo "$td" | sed "s~^\./~~ ; s~^\./~~ ; s~${HOME}~$\(HOME\)~"` echo -e "\t$td \\" >> Makefile done echo >> Makefile