5 # C Cross Referencing & Documentation tool. Version 1.5d.
7 # C compiler replacement to compile program and cross reference it.
9 # Written by Andrew M. Bishop
11 # This file Copyright 1997,98,2002 Andrew M. Bishop
12 # It may be distributed under the GNU Public License, version 2, or
13 # any higher version. See section COPYING of the GNU Public license
14 # for conditions under which this file may be redistributed.
17 # Print a usage statement.
21 echo 'Usage: cxref-cc filename [CC-arguments]' 1>&2
23 echo 'filename : The name of the file to compile and cross reference.' 1>&2
24 echo 'CC-arguments : Any number of arguments to the C compiler.' 1>&2
26 echo 'The C compiler is called first, and if this succeeds then cxref is called.' 1>&2
27 echo 'You require a .cxref file to contain the cxref options.' 1>&2
32 # Check for a .cxref file.
34 if [ ! -r .cxref
]; then
36 echo 'cxref-cc: Error a .cxref file is required to use cxref-cc.' 1>&2
37 echo ' If you do not need any arguments an empty file will work.' 1>&2
42 # The variables that we are going to use.
44 if [ "x$CXREFCC" = x
]; then
45 if [ "x$CC" = x
]; then
48 CXREFCC
=`echo $CC | cut -d' ' -f1`
49 if [ `basename $CXREFCC` = cxref-cc
]; then
50 echo 'cxref-cc: Warning the CC variable points to cxref-cc, set CXREFCC instead.' 1>&2
69 echo 'cxref-cc: The C compiler failed with an error status.' 1>&2
74 # Loop over the arguments and sort them out.
76 # Note: Need to be careful because "-DFOO=BAR BAR" loses its quotes on parameter
77 # expansion, but must be passed to cxref as a single word. We need to use
78 # a word separator since there are no arrays, so we use ^M.
80 while [ ! $# = 0 ]; do
84 # The arguments to keep
87 CXREFFLAGS
="$CXREFFLAGS
91 CXREFFLAGS
="$CXREFFLAGS
95 CXREFFLAGS
="$CXREFFLAGS
99 CXREFFLAGS
="$CXREFFLAGS
103 CXREFFLAGS
="$CXREFFLAGS
107 CXREFFLAGS
="$CXREFFLAGS
110 # The filename (perhaps)
113 if [ "x$FILE" = x
-a -r $1 ]; then
121 # The arguments to throw away
131 # Check that a real file was specified
133 if [ "x$FILE" = x
]; then
135 if [ "x$FILESTDIN" = xyes
]; then
136 echo 'cxref-cc: Cannot use stdin "-" as a filename with cxref-cc' 1>&2
138 echo 'cxref-cc: Warning no file specified on the command line' 1>&2
146 # Note: We are using ^M as the word separator, as detailed above.
151 $CXREF$FILE$CXREFFLAGS
153 if [ ! $?
= 0 ]; then
155 echo 'cxref-cc: Cxref exited with error status' 1>&2