21 |
# Commentary: |
# Commentary: |
22 |
|
|
23 |
# Usage: guile-snarf [-o OUTFILE] INFILE [CPP-OPTIONS ...] |
# Usage: guile-snarf [-o OUTFILE] INFILE [CPP-OPTIONS ...] |
24 |
# |
# |
25 |
# Process INFILE using the C pre-processor and some other programs. |
# Process INFILE using the C pre-processor and some other programs. |
26 |
# Write output to a file named OUTFILE or to the standard output when no |
# Write output to a file named OUTFILE or to the standard output when no |
27 |
# OUTFILE has been specified or when OUTFILE is "-". When writing |
# OUTFILE has been specified or when OUTFILE is "-". |
28 |
# to a file, ignore lines from the input matching the following grep(1) |
# |
|
# regular expression: |
|
|
# |
|
|
# ^#include ".*OUTFILE" |
|
|
# |
|
29 |
# If there are errors during processing, delete OUTFILE and exit with |
# If there are errors during processing, delete OUTFILE and exit with |
30 |
# non-zero status. |
# non-zero status. |
31 |
# |
# |
32 |
# During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is |
# During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is |
33 |
# defined. |
# defined. You can use this to avoid including snarfer output files |
34 |
# |
# that don't yet exist by writing code like this: |
35 |
|
# |
36 |
|
# #ifndef SCM_MAGIC_SNARFER |
37 |
|
# #include "foo.x" |
38 |
|
# #endif |
39 |
|
# |
40 |
# If env var CPP is set, use its value instead of the C pre-processor |
# If env var CPP is set, use its value instead of the C pre-processor |
41 |
# determined at Guile configure-time: "@CPP@". |
# determined at Guile configure-time: "@CPP@". |
42 |
|
|
78 |
trap "rm -f $temp" 0 1 2 15 |
trap "rm -f $temp" 0 1 2 15 |
79 |
|
|
80 |
if [ ! "$outfile" = "-" ] ; then |
if [ ! "$outfile" = "-" ] ; then |
81 |
self_blind_regexp='^#include ".*'`basename $outfile`'"' |
modern_snarf "$@" $infile > $outfile |
|
clean_infile=$infile.clean.c # temp file in same dir as infile |
|
|
# so that #include "foo" works |
|
|
# (e.g., see libguile/eval.c). |
|
|
# use .c to satisfy cpp heuristics. |
|
|
# clean input file |
|
|
trap "rm -f $cleanfile" 0 1 2 15 |
|
|
grep -v "$self_blind_regexp" $infile > $clean_infile |
|
|
modern_snarf "$@" $clean_infile > $outfile |
|
82 |
else |
else |
83 |
modern_snarf "$@" $infile |
modern_snarf "$@" $infile |
84 |
fi |
fi |