guile-doc-snarf.in 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this software; see the file COPYING. If not, write to
  17. # the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. # Boston, MA 02111-1307 USA
  19. # Commentary:
  20. # Usage: guile-doc-snarf -o OUTFILE INFILE [CPP-OPTIONS ...]
  21. #
  22. # Process INFILE using the C pre-processor and some other programs.
  23. # Write output to a file named OUTFILE. If there are errors during
  24. # processing, delete OUTFILE and exit with non-zero status.
  25. #
  26. # During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is
  27. # defined.
  28. #
  29. # If env var CPP is set, use its value instead of the C pre-processor
  30. # determined at Guile configure-time: "@CPP@". Likewise for AWK (default
  31. # "@AWK@").
  32. # Code:
  33. if [ ! x"$1" = x-o -o x"$3" = x ] ; then
  34. me=`basename $0`
  35. echo ${me}: ERROR: missing required args
  36. echo "Usage: $me -o OUTFILE INFILE [CPP-OPTIONS ...]"
  37. exit 1
  38. fi
  39. outfile=$2 ; fullfilename=$3 ; shift ; shift ; shift
  40. # strip path to source directory
  41. filename=`basename $fullfilename`
  42. temp="/tmp/snarf.$$"
  43. trap "rm -f $temp" 0 1 2 15
  44. ## Let the user override the preprocessor & awk autoconf found.
  45. test -n "${CPP+set}" || CPP="@CPP@"
  46. test -n "${AWK+set}" || AWK="@AWK@"
  47. ## Must run guile-func-name-check on the unpreprocessed source
  48. ${AWK} -f guile-func-name-check "$fullfilename"
  49. ## We must use a temporary file here, instead of a pipe, because we
  50. ## need to know if CPP exits with a non-zero status.
  51. rm -f $outfile
  52. ${CPP} -DSCM_MAGIC_SNARFER "$fullfilename" "$@" > ${temp} || exit $?
  53. cat ${temp} | sed 's/^\(.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}\).*/\1/g' | \
  54. ${AWK} -f `dirname $0`/guile-snarf.awk $outfile > /dev/null
  55. # guile-doc-snarf ends here