aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-05-17 16:46:13 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-05-17 16:46:13 +0000
commitc3a32b31057a7f805382154403ddb6d68424a6dd (patch)
tree905deb9ba8a12db8b12a289a40daf2166cacb3d4
parentecd529a089a97bc8a937e6c979e3ebf859d74ee1 (diff)
improved (setup_functions need not have the same name as the c-file)
svn path=/trunk/externals/zexy/; revision=2997
-rwxr-xr-xsrc/makesource.sh30
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