makeheader.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. if [ ! -f ${file}.h ]; then
  13. echo "No header, building it"
  14. touch ${file}.h
  15. cat > ${file}.h <<EOF
  16. /*
  17. * The Amsterdam Compiler Kit
  18. * See the copyright notice in the ACK home directory, in the file "Copyright".
  19. */
  20. EOF
  21. HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
  22. BASE=`dirname ${file}.c`
  23. echo "#ifndef ${HEADERMAGIC}" >> ${file}.h
  24. echo "#define ${HEADERMAGIC}" >> ${file}.h
  25. echo "" >> ${file}.h
  26. cproto -U__BLOCKS__ ${INCPATH[*]} ${file}.c >> ${file}.h
  27. echo "" >> ${file}.h
  28. echo "#endif /* ${HEADERMAGIC} */" >> ${file}.h
  29. echo "" >> ${file}.h
  30. else
  31. echo "Header existing... try to update.. (manual check should be done)"
  32. cp ${file}.h ${file}.h.old
  33. HEADERMAGIC=`echo ${file}.h | tr '[.-/]' '_' | tr '[a-z]' '[A-Z]'`
  34. BASE=`dirname ${file}.c`
  35. echo "#ifndef ${HEADERMAGIC}" > ${file}.h.new
  36. echo "#define ${HEADERMAGIC}" >> ${file}.h.new
  37. cat ${file}.h.old >> ${file}.h.new
  38. echo "" >> ${file}.h.new
  39. cproto -U__BLOCKS__ ${INCPATH[*]} -I${BASE} ${file}.c >> ${file}.h.new
  40. echo "" >> ${file}.h.new
  41. echo "#endif /* ${HEADERMAGIC} */" >> ${file}.h.new
  42. echo "" >> ${file}.h.new
  43. cp ${file}.h.new ${file}.h
  44. #
  45. fi