Add small too to generate headers.
authorGodzil <godzil@godzil.net>
Wed, 20 Mar 2013 08:41:59 +0000 (09:41 +0100)
committerManoël Trapier <godzil@MacBook-Pro.home>
Wed, 24 Jun 2015 22:41:47 +0000 (23:41 +0100)
(Need cproto)

makeheader.sh [new file with mode: 0755]

diff --git a/makeheader.sh b/makeheader.sh
new file mode 100755 (executable)
index 0000000..edc7828
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+file=${1%.c}
+
+INCPATH=("-Ih")
+INCPATH+=("-Imodules/h")
+INCPATH+=("-I/tmp/ack-build/pmcache")
+INCPATH+=("-I/tmp/ack-temp/headers" )
+for fil in /tmp/ack-temp/pmcache/*; do
+       if [ -d ${fil} ]; then
+               INCPATH+=("-I${fil}")
+       fi
+done
+
+
+if [ ! -f ${file}.h ]; then
+       echo "No header, building it"
+       touch ${file}.h
+       cat > ${file}.h <<EOF
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+EOF
+       HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
+       BASE=`dirname ${file}.c`
+       echo "#ifndef ${HEADERMAGIC}" >> ${file}.h
+       echo "#define ${HEADERMAGIC}" >> ${file}.h
+       echo "" >> ${file}.h
+       cproto -U__BLOCKS__ ${INCPATH[*]} ${file}.c >> ${file}.h
+       echo "" >> ${file}.h
+       echo "#endif /* ${HEADERMAGIC} */" >> ${file}.h
+       echo "" >> ${file}.h
+else
+       echo "Header existing... try to update.. (manual check should be done)"
+       cp ${file}.h ${file}.h.old
+       HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
+       BASE=`dirname ${file}.c`
+       echo "#ifndef ${HEADERMAGIC}" > ${file}.h.new
+       echo "#define ${HEADERMAGIC}" >> ${file}.h.new
+       cat ${file}.h.old >> ${file}.h.new
+       echo "" >> ${file}.h.new
+       cproto -U__BLOCKS__ ${INCPATH[*]} -I${BASE} ${file}.c >> ${file}.h.new
+       echo "" >> ${file}.h.new
+       echo "#endif /* ${HEADERMAGIC} */" >> ${file}.h.new
+       echo "" >> ${file}.h.new
+       
+       cp ${file}.h.new ${file}.h
+       #
+fi
\ No newline at end of file