aboutsummaryrefslogtreecommitdiff
path: root/src/makesource.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/makesource.sh')
-rw-r--r--src/makesource.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/makesource.sh b/src/makesource.sh
new file mode 100644
index 0000000..32703b1
--- /dev/null
+++ b/src/makesource.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+IEMAMBI_H=iem_ambi_sources.h
+IEMAMBI_C=iem_ambi_sources.c
+
+EGREP=egrep
+SED=sed
+LS=ls
+
+#################################
+## functions
+
+function head_h() {
+ echo "/* iem_ambi-setup autogenerated header-file"
+ echo " * generated by \"$0\""
+ echo " * !! DO NOT MANUALLY EDIT !!"
+ echo " */"
+ echo
+ echo "#ifndef IEMAMBI_SOURCES_H__"
+ echo "#define IEMAMBI_SOURCES_H__"
+}
+
+function foot_h() {
+ echo "#endif /* IEMAMBI_SOURCES_H__ */"
+ echo ""
+}
+
+function head_c() {
+ echo "/* iem_ambi-setup autogenerated setup-file"
+ echo " * generated by \"$0\""
+ echo " * !! DO NOT MANUALLY EDIT !!"
+ echo " */"
+ echo
+ echo "#include \"$IEMAMBI_H\""
+ echo
+ echo "void iem_ambi_sources_setup(void)"
+ echo "{"
+}
+
+function foot_c() {
+ echo "}"
+ echo
+}
+
+
+##################################
+## body
+
+head_h > $IEMAMBI_H
+head_c > $IEMAMBI_C
+
+for i in $(${LS} *.c | ${EGREP} -v "iem_bin_ambi.*\.c")
+do
+## each c-file in iem_ambi needs to have an <file>_setup()-function
+## that calls all needed setup-functions
+## any non-alpha-numeric-character is replaced by "_"
+## e.g. "bla~.c" -> "bla__setup()"
+ SETUPNAME=$(echo ${i%.c} | ${SED} -e 's/[^[:alnum:]]/_/g')_setup
+ echo "void ${SETUPNAME}(void); /* $i */" >> $IEMAMBI_H
+ echo " ${SETUPNAME}(); /* $i */" >> $IEMAMBI_C
+done
+
+foot_h >> $IEMAMBI_H
+foot_c >> $IEMAMBI_C
+