2 # Extract the initialization actions from source files.
4 # Copyright (C) 1996, 97, 98, 99, 2000, 2001, 2002, 2004, 2006, 2008,
5 # 2009, 2014 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as
9 # published by the Free Software Foundation; either version 3, or (at
10 # your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this software; see the file COPYING.LESSER. If
19 # not, write to the Free Software Foundation, Inc., 51 Franklin
20 # Street, Fifth Floor, Boston, MA 02110-1301 USA
24 # Usage: guile-snarf [-o OUTFILE] [CPP-ARGS ...]
26 # Initialization actions are extracted to OUTFILE or to standard
27 # output when no OUTFILE has been specified or when OUTFILE is "-".
28 # The C preprocessor is called with CPP-ARGS (which usually include a
29 # input file) and the output is filtered for the actions.
31 # If there are errors during processing, OUTFILE is deleted and the
32 # program exits with non-zero status.
34 # During snarfing, the pre-processor macro SCM_MAGIC_SNARFER is
35 # defined. You can use this to avoid including snarfer output files
36 # that don't yet exist by writing code like this:
38 # #ifndef SCM_MAGIC_SNARFER
42 # If the environment variable CPP is set, use its value instead of the
43 # C pre-processor determined at Guile configure-time: "@CPP@".
49 modern_snarf
() # writes stdout
51 ## Apparently, AIX's preprocessor is unhappy if you try to #include an
53 echo "/* cpp arguments: $@ */" ;
54 ${cpp} -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp} && cpp_ok_p
=true
55 sed -ne 's/ *\^ *\^ */\
75 # process command line
76 if [ x
"$1" = x--help
] ; then
77 @AWK@
'/^#.Commentary:/,/^#.Code:/' $0 |
grep -v Code
: \
78 |
sed -e 1,2d
-e 's/^. *//g'
82 then outfile
="$2" ; shift ; shift ;
86 # set vars and handler -- handle CPP override
89 if [ x
"$TMPDIR" = x
]; then TMPDIR
="/tmp" ; else : ; fi
90 tempdir
="$TMPDIR/guile-snarf.$$"
91 (umask 077 && mkdir
$tempdir) ||
exit 1
94 if [ x
"$CPP" = x
] ; then cpp
="@CPP@" ; else cpp
="$CPP" ; fi
96 trap "rm -rf $tempdir" 0 1 2 15
98 if [ ! "$outfile" = "-" ] ; then
99 modern_snarf
"$@" > $outfile
104 # zonk outfile if errors occurred
108 [ ! "$outfile" = "-" ] && rm -f $outfile
112 # guile-snarf ends here