diff options
-rwxr-xr-x | src/makesource.sh | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/makesource.sh b/src/makesource.sh index d2c527e..0de872f 100755 --- a/src/makesource.sh +++ b/src/makesource.sh @@ -4,6 +4,14 @@ ZEXY_H=z_zexy.h ZEXY_C=z_zexy.c ZEXY_S=Make.source + +GREP=grep +AWK=awk +SED=sed + +################################# +## functions + function head_h() { echo "/* zexy-setup autogenerated header-file" echo " * generated by \"$0\"" @@ -45,6 +53,16 @@ function foot_s() { echo } +function get_setupfunctions() { + if [ -e "$1" ] + then + $GREP "^void .*_setup(void)" $i | $AWK '{print gensub("_setup.*", "_setup", "g", $2);}' + fi +} + +################################## +## body + head_h > $ZEXY_H head_c > $ZEXY_C head_s > $ZEXY_S @@ -52,13 +70,15 @@ head_s > $ZEXY_S for i in `ls *.c | grep -v zexy.c` do NAME="${i%.c}" - SETUPNAME="void ${NAME}_setup(void)" - if grep "$SETUPNAME" $i > /dev/null + SETUPNAMES=`get_setupfunctions $i` + if [ "$SETUPNAMES" ] then -# echo ${i%.c} echo " $i \\" >> $ZEXY_S - echo "$SETUPNAME;" >> $ZEXY_H - echo " ${NAME}_setup();" >> $ZEXY_C + for SETUPNAME in $SETUPNAMES + do + echo "void ${SETUPNAME}(void);" >> $ZEXY_H + echo " ${SETUPNAME}();" >> $ZEXY_C + done fi done |