Commit | Line | Data |
---|---|---|
a7868768 BA |
1 | #!/usr/bin/bash |
2 | ||
3 | subfolder=$1 | |
4 | ||
5 | cd $subfolder | |
6 | cat Makefile.base > Makefile | |
7 | printf "\n" >> Makefile | |
8 | for folder in `find . -path ./obj -prune -o -type d -print`; do | |
9 | mkdir -p obj/$folder | |
10 | done | |
11 | ||
12 | sources=`find . -type f -name \*.c` | |
13 | objects="" | |
14 | for file in $sources; do | |
15 | objects+="obj/${file%?}o " | |
16 | done | |
17 | printf "obj/\$(TARGET): $objects\n" >> Makefile | |
18 | printf '\t$(CC) $(LDFLAGS) -o $@ $^\n\n' >> Makefile | |
19 | ||
20 | for file in $sources; do | |
21 | deps=`grep '#include "' $file | cut -d ' ' -f 2 | sed 's/^"\(.*\)"$/..\/\1/g' | tr '\n' ' '` | |
22 | fileDotO="obj/${file%?}o" | |
23 | printf "$fileDotO: $file $deps\n" >> Makefile | |
24 | printf '\t$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<\n\n' >> Makefile | |
25 | done | |
26 | ||
27 | cd .. |