4 # cc-wrapper cc /path/to/cc -c -o foo.o foo.c
5 # cc-wrapper ld /path/to/ld -o foo foo.o
7 # This wraps running the compiler or linker, so we can tweak the files
8 # generated. Currently, this just involves running ctfconvert or ctfmerge on
9 # the relevant files, if available.
13 CTFCONVERT
=@CTFCONVERT@
20 # First, run the command that we're wrapping.
23 # If we've reached here, the compiler/linker finished successfully, so now we
24 # can run ctfconvert/ctfmerge, if we're configured to. If we're not going to
25 # process ctf stuff, we can just exit immediately.
26 if [ x
"$CTFCONVERT" = x
] ||
[ x
"$CTFMERGE" = x
] ; then
30 # Look for our target file (indicated by '-o target'), and if debugging is
31 # turned on (indicated by '-g')
36 if [ x
"$target_next" = x1
] ; then
50 if [ x
"$OPENAFS_CC_WRAPPER_DEBUG_FLAG" != x
] ; then
51 # Normally we try to determine if debugging is turned on by searching $@
52 # for "-g". But sometimes we link something with debugging info and don't
53 # pass -g (the Solaris kernel module, for example). In this case, the
54 # caller can specify whether that debugging is turned on by setting the env
55 # var OPENAFS_CC_WRAPPER_DEBUG_FLAG to a nonempty string.
59 if [ x
"$debug" = x
] ; then
60 # Don't run ctfconvert/ctfmerge if debugging isn't turned on.
64 if [ x
"$target" = x
] ; then
65 echo "$0: error: cannot extract target from args" >&2
70 if [ x
"$V" != x0
] ; then
78 # It looks like we compiled a single object. For that, we just need to run
79 # 'ctfconvert' against the target .o.
80 echo_run
"$CTFCONVERT" -g -l $ctf_label "$target"
84 # It looks like we're linking an executable. For that, we need to give
85 # 'ctfmerge' every .o and .a that we're linking against.
91 merge_objs
="$merge_objs $arg"
96 if [ x
"$merge_objs" = x
] ; then
97 # If we can't find any .o or .a files that we're linking into the
98 # target executable, our caller is probably compiling/linking directly
99 # from foo.c into foo (skipping foo.o). For that, we just need to run
100 # ctfconvert/ctfmerge on the executable itself.
101 echo_run
"$CTFCONVERT" -g -l $ctf_label "$target"
105 echo_run
"$CTFMERGE" -g -l $ctf_label -o "$target" $merge_objs
109 echo "$0: Unknown mode '$mode'" >&2