Browse Source

Add small too to generate headers.

(Need cproto)
Godzil 11 years ago
parent
commit
b2d6e23b5f
1 changed files with 49 additions and 0 deletions
  1. 49 0
      makeheader.sh

+ 49 - 0
makeheader.sh

@@ -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