]>
Dogcows Code - chaz/yoink/blob - build/compile.sh
75aec0ab4c944ab8212b4c40c73d36334392c006
3 # CCDEPS-GCC (C) 2002 Emile van Bergen. Distribution of this file is allowed
4 # under the conditions detailed in the GNU General Public License (GPL). See
5 # the file COPYING for more information.
7 # This script compiles and/or links one or more source or object files into a
8 # object file or executable target, and outputs all extra dependencies found
9 # while doing so in a file named target.d, which can be used by GNU Make.
11 # The script should be invoked the same way as your C compiler, that is,
12 # specifying the target using a -o option and the source or object files as
13 # non-option arguments. It will generate dependencies in the form
15 # target target.d: dir/file1.c dir/file2.c header1.h header2.h
16 # dir/file1.c dir/file2.c header1.h header2.h:
18 # This version is intended for GCC, which can do compilation and dependency
19 # generation in one step. The name of the GCC version (default gcc) can be
20 # overridden using the CC environment variable.
24 # 2003/1/8: EvB: adapted for gcc 3.2, still handles 2.95 as well.
26 # This was necessary because gcc 3.2 handles -MD differently than gcc 2.95:
27 # where the old version generated a .d file for each source, in the current
28 # directory, the new one does almost completely what this script intended to
29 # do: generate one .d file in the same directory and with the same file name
32 # The only fixups 3.2's .d files still need are:
34 # - changing the file name; gcc 3.2 strips the suffix of the target before
35 # appending the .d, so targets x and x.o will both produce x.d, which is
38 # - adding the implicit dependencies as prerequisiteless targets, so that
39 # make will just consider the target out of date if one does not exist
42 # - adding the .d file as depending on the same prerequisites as our real
43 # target so that it will be considered out of date if one of the files
44 # mentioned in it are updated or missing.
46 # Basically, this version does all that by simply including the file
47 # <strippedtarget>.d file in the list of .d files we look for. We may end
48 # up generating the same file name, but that already was handled correctly.
49 # Otherwise we perform the normal routine, so that we /know/ the targets will
50 # be correct, directories and all, regardless of variations in gcc behaviour.
52 test -x "functions.sh" && .
"functions.sh"
53 test -x "build/functions.sh" && .
"build/functions.sh"
60 # After having passed the arguments, they have already been parsed once by
61 # the shell, so they needed to be re-quoted.
64 arg
="$(quote_string "$arg")"
65 cmdline
="$cmdline $arg"
72 -o) tgt
="$2" ; shift ;; # target specifier option
73 -x|-u|-b|-V) shift ;; # options with arg after space
74 -*) ;; # standard options
75 *) fil
="$fil $1" ;; # source or object files
86 # If we're not processing any .c files (link only), run gcc as-is and we're done
88 expr "$fil" : ".*\.c" >/dev
/null
|| exec $CC $cmdline
90 # Otherwise, run the gcc with the -MD option, which generates a .d file
91 # in the current directory for each .c or .cc source file processed.
93 # These files are post-processed (replacing the incorrectly named target
94 # with the real target specified with -o, and adding the .d file), concatenated
95 # into one .d file that is named based on the target name, and put in the
96 # correct directory. Further, all prerequisites are added as bare targets,
97 # preventing errors when files are missing due to renaming or restructuring
98 # headers, but causing the files dependent on them to be considered out of
99 # date. (GNU Make feature).
101 # Makefiles must include the .d files like this: -include $(OBJS_$(d):.o=.d)
102 # or, when compiling and linking in one step: -include $(TGTS_$(d):%=%.d)
107 #echo $CC -MD $cmdline
108 eval "$CC -MD $cmdline"
111 dgcc3
=`echo $tgt | sed -e 's/\.[^.]*$//'`.d
112 dgcc
=`echo $fil | sed -e 's/[^ ]*\.[^c]//' -e 's/\.cpp/\.d/g' -e 's/\.cc/\.d/g' -e 's/\.c/\.d/g' -e 's%.*/%%g'`
114 for tf
in $dgcc3 $dgcc
116 if [ -f $tf ] && mv $tf $dep.tmp
118 sed -e "s%.*:%$tgt $dep:%" < $dep.tmp
>> $dep
119 sed -e 's%^.*:%%' -e 's%^ *%%' -e 's% *\\$%%' -e 's%$%:%' \
126 [ x
"$found" = x
"1" ] && exit $res
128 echo ERROR
: $0: Cannot
find any compiler
-generated dependency files\
!
This page took 0.042119 seconds and 4 git commands to generate.