makeheader.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. file=${1%.c}
  3. INCPATH=("-Ih")
  4. INCPATH+=("-Imodules/h")
  5. INCPATH+=("-I/tmp/ack-build/pmcache")
  6. INCPATH+=("-I/tmp/ack-temp/headers" )
  7. for fil in /tmp/ack-temp/pmcache/*; do
  8. if [ -d ${fil} ]; then
  9. INCPATH+=("-I${fil}")
  10. fi
  11. done
  12. POSTFIX=".h"
  13. if [ -f ${file}.str ]; then
  14. POSTFIX="_loc.h"
  15. fi
  16. if [ ! -f ${file}${POSTFIX} ]; then
  17. echo "No header, building it"
  18. # Be carefull if a ${file}.str file exist use _loc.h postfix.
  19. HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
  20. BASE=`dirname ${file}.c`
  21. touch ${file}${POSTFIX}
  22. cat > ${file}${POSTFIX} <<EOF
  23. /*
  24. * The Amsterdam Compiler Kit
  25. * See the copyright notice in the ACK home directory, in the file "Copyright".
  26. */
  27. EOF
  28. echo "#ifndef ${HEADERMAGIC}" >> ${file}${POSTFIX}
  29. echo "#define ${HEADERMAGIC}" >> ${file}${POSTFIX}
  30. echo "" >> ${file}${POSTFIX}
  31. cproto -U__BLOCKS__ ${INCPATH[*]} ${file}.c >> ${file}${POSTFIX}
  32. echo "" >> ${file}${POSTFIX}
  33. echo "#endif /* ${HEADERMAGIC} */" >> ${file}${POSTFIX}
  34. echo "" >> ${file}${POSTFIX}
  35. else
  36. echo "Header existing... try to update.. (manual check should be done)"
  37. cp ${file}.h ${file}.h.old
  38. HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
  39. BASE=`dirname ${file}.c`
  40. echo "#ifndef ${HEADERMAGIC}" > ${file}.h.new
  41. echo "#define ${HEADERMAGIC}" >> ${file}.h.new
  42. cat ${file}.h.old >> ${file}.h.new
  43. echo "" >> ${file}.h.new
  44. cproto -U__BLOCKS__ ${INCPATH[*]} -I${BASE} ${file}.c >> ${file}.h.new
  45. echo "" >> ${file}.h.new
  46. echo "#endif /* ${HEADERMAGIC} */" >> ${file}.h.new
  47. echo "" >> ${file}.h.new
  48. cp ${file}.h.new ${file}.h
  49. rm ${file}.h.new
  50. #
  51. fi