Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | #! /bin/sh |
michael@0 | 2 | # depcomp - compile a program generating dependencies as side-effects |
michael@0 | 3 | |
michael@0 | 4 | scriptversion=2012-03-27.16; # UTC |
michael@0 | 5 | |
michael@0 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, |
michael@0 | 7 | # 2011, 2012 Free Software Foundation, Inc. |
michael@0 | 8 | |
michael@0 | 9 | # This program is free software; you can redistribute it and/or modify |
michael@0 | 10 | # it under the terms of the GNU General Public License as published by |
michael@0 | 11 | # the Free Software Foundation; either version 2, or (at your option) |
michael@0 | 12 | # any later version. |
michael@0 | 13 | |
michael@0 | 14 | # This program is distributed in the hope that it will be useful, |
michael@0 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
michael@0 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
michael@0 | 17 | # GNU General Public License for more details. |
michael@0 | 18 | |
michael@0 | 19 | # You should have received a copy of the GNU General Public License |
michael@0 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
michael@0 | 21 | |
michael@0 | 22 | # As a special exception to the GNU General Public License, if you |
michael@0 | 23 | # distribute this file as part of a program that contains a |
michael@0 | 24 | # configuration script generated by Autoconf, you may include it under |
michael@0 | 25 | # the same distribution terms that you use for the rest of that program. |
michael@0 | 26 | |
michael@0 | 27 | # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. |
michael@0 | 28 | |
michael@0 | 29 | case $1 in |
michael@0 | 30 | '') |
michael@0 | 31 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 |
michael@0 | 32 | exit 1; |
michael@0 | 33 | ;; |
michael@0 | 34 | -h | --h*) |
michael@0 | 35 | cat <<\EOF |
michael@0 | 36 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] |
michael@0 | 37 | |
michael@0 | 38 | Run PROGRAMS ARGS to compile a file, generating dependencies |
michael@0 | 39 | as side-effects. |
michael@0 | 40 | |
michael@0 | 41 | Environment variables: |
michael@0 | 42 | depmode Dependency tracking mode. |
michael@0 | 43 | source Source file read by 'PROGRAMS ARGS'. |
michael@0 | 44 | object Object file output by 'PROGRAMS ARGS'. |
michael@0 | 45 | DEPDIR directory where to store dependencies. |
michael@0 | 46 | depfile Dependency file to output. |
michael@0 | 47 | tmpdepfile Temporary file to use when outputting dependencies. |
michael@0 | 48 | libtool Whether libtool is used (yes/no). |
michael@0 | 49 | |
michael@0 | 50 | Report bugs to <bug-automake@gnu.org>. |
michael@0 | 51 | EOF |
michael@0 | 52 | exit $? |
michael@0 | 53 | ;; |
michael@0 | 54 | -v | --v*) |
michael@0 | 55 | echo "depcomp $scriptversion" |
michael@0 | 56 | exit $? |
michael@0 | 57 | ;; |
michael@0 | 58 | esac |
michael@0 | 59 | |
michael@0 | 60 | # A tabulation character. |
michael@0 | 61 | tab=' ' |
michael@0 | 62 | # A newline character. |
michael@0 | 63 | nl=' |
michael@0 | 64 | ' |
michael@0 | 65 | |
michael@0 | 66 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then |
michael@0 | 67 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
michael@0 | 68 | exit 1 |
michael@0 | 69 | fi |
michael@0 | 70 | |
michael@0 | 71 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. |
michael@0 | 72 | depfile=${depfile-`echo "$object" | |
michael@0 | 73 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} |
michael@0 | 74 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} |
michael@0 | 75 | |
michael@0 | 76 | rm -f "$tmpdepfile" |
michael@0 | 77 | |
michael@0 | 78 | # Some modes work just like other modes, but use different flags. We |
michael@0 | 79 | # parameterize here, but still list the modes in the big case below, |
michael@0 | 80 | # to make depend.m4 easier to write. Note that we *cannot* use a case |
michael@0 | 81 | # here, because this file can only contain one case statement. |
michael@0 | 82 | if test "$depmode" = hp; then |
michael@0 | 83 | # HP compiler uses -M and no extra arg. |
michael@0 | 84 | gccflag=-M |
michael@0 | 85 | depmode=gcc |
michael@0 | 86 | fi |
michael@0 | 87 | |
michael@0 | 88 | if test "$depmode" = dashXmstdout; then |
michael@0 | 89 | # This is just like dashmstdout with a different argument. |
michael@0 | 90 | dashmflag=-xM |
michael@0 | 91 | depmode=dashmstdout |
michael@0 | 92 | fi |
michael@0 | 93 | |
michael@0 | 94 | cygpath_u="cygpath -u -f -" |
michael@0 | 95 | if test "$depmode" = msvcmsys; then |
michael@0 | 96 | # This is just like msvisualcpp but w/o cygpath translation. |
michael@0 | 97 | # Just convert the backslash-escaped backslashes to single forward |
michael@0 | 98 | # slashes to satisfy depend.m4 |
michael@0 | 99 | cygpath_u='sed s,\\\\,/,g' |
michael@0 | 100 | depmode=msvisualcpp |
michael@0 | 101 | fi |
michael@0 | 102 | |
michael@0 | 103 | if test "$depmode" = msvc7msys; then |
michael@0 | 104 | # This is just like msvc7 but w/o cygpath translation. |
michael@0 | 105 | # Just convert the backslash-escaped backslashes to single forward |
michael@0 | 106 | # slashes to satisfy depend.m4 |
michael@0 | 107 | cygpath_u='sed s,\\\\,/,g' |
michael@0 | 108 | depmode=msvc7 |
michael@0 | 109 | fi |
michael@0 | 110 | |
michael@0 | 111 | if test "$depmode" = xlc; then |
michael@0 | 112 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. |
michael@0 | 113 | gccflag=-qmakedep=gcc,-MF |
michael@0 | 114 | depmode=gcc |
michael@0 | 115 | fi |
michael@0 | 116 | |
michael@0 | 117 | case "$depmode" in |
michael@0 | 118 | gcc3) |
michael@0 | 119 | ## gcc 3 implements dependency tracking that does exactly what |
michael@0 | 120 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like |
michael@0 | 121 | ## it if -MD -MP comes after the -MF stuff. Hmm. |
michael@0 | 122 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon |
michael@0 | 123 | ## the command line argument order; so add the flags where they |
michael@0 | 124 | ## appear in depend2.am. Note that the slowdown incurred here |
michael@0 | 125 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. |
michael@0 | 126 | for arg |
michael@0 | 127 | do |
michael@0 | 128 | case $arg in |
michael@0 | 129 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; |
michael@0 | 130 | *) set fnord "$@" "$arg" ;; |
michael@0 | 131 | esac |
michael@0 | 132 | shift # fnord |
michael@0 | 133 | shift # $arg |
michael@0 | 134 | done |
michael@0 | 135 | "$@" |
michael@0 | 136 | stat=$? |
michael@0 | 137 | if test $stat -eq 0; then : |
michael@0 | 138 | else |
michael@0 | 139 | rm -f "$tmpdepfile" |
michael@0 | 140 | exit $stat |
michael@0 | 141 | fi |
michael@0 | 142 | mv "$tmpdepfile" "$depfile" |
michael@0 | 143 | ;; |
michael@0 | 144 | |
michael@0 | 145 | gcc) |
michael@0 | 146 | ## There are various ways to get dependency output from gcc. Here's |
michael@0 | 147 | ## why we pick this rather obscure method: |
michael@0 | 148 | ## - Don't want to use -MD because we'd like the dependencies to end |
michael@0 | 149 | ## up in a subdir. Having to rename by hand is ugly. |
michael@0 | 150 | ## (We might end up doing this anyway to support other compilers.) |
michael@0 | 151 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like |
michael@0 | 152 | ## -MM, not -M (despite what the docs say). |
michael@0 | 153 | ## - Using -M directly means running the compiler twice (even worse |
michael@0 | 154 | ## than renaming). |
michael@0 | 155 | if test -z "$gccflag"; then |
michael@0 | 156 | gccflag=-MD, |
michael@0 | 157 | fi |
michael@0 | 158 | "$@" -Wp,"$gccflag$tmpdepfile" |
michael@0 | 159 | stat=$? |
michael@0 | 160 | if test $stat -eq 0; then : |
michael@0 | 161 | else |
michael@0 | 162 | rm -f "$tmpdepfile" |
michael@0 | 163 | exit $stat |
michael@0 | 164 | fi |
michael@0 | 165 | rm -f "$depfile" |
michael@0 | 166 | echo "$object : \\" > "$depfile" |
michael@0 | 167 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz |
michael@0 | 168 | ## The second -e expression handles DOS-style file names with drive letters. |
michael@0 | 169 | sed -e 's/^[^:]*: / /' \ |
michael@0 | 170 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" |
michael@0 | 171 | ## This next piece of magic avoids the "deleted header file" problem. |
michael@0 | 172 | ## The problem is that when a header file which appears in a .P file |
michael@0 | 173 | ## is deleted, the dependency causes make to die (because there is |
michael@0 | 174 | ## typically no way to rebuild the header). We avoid this by adding |
michael@0 | 175 | ## dummy dependencies for each header file. Too bad gcc doesn't do |
michael@0 | 176 | ## this for us directly. |
michael@0 | 177 | tr ' ' "$nl" < "$tmpdepfile" | |
michael@0 | 178 | ## Some versions of gcc put a space before the ':'. On the theory |
michael@0 | 179 | ## that the space means something, we add a space to the output as |
michael@0 | 180 | ## well. hp depmode also adds that space, but also prefixes the VPATH |
michael@0 | 181 | ## to the object. Take care to not repeat it in the output. |
michael@0 | 182 | ## Some versions of the HPUX 10.20 sed can't process this invocation |
michael@0 | 183 | ## correctly. Breaking it into two sed invocations is a workaround. |
michael@0 | 184 | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ |
michael@0 | 185 | | sed -e 's/$/ :/' >> "$depfile" |
michael@0 | 186 | rm -f "$tmpdepfile" |
michael@0 | 187 | ;; |
michael@0 | 188 | |
michael@0 | 189 | hp) |
michael@0 | 190 | # This case exists only to let depend.m4 do its work. It works by |
michael@0 | 191 | # looking at the text of this script. This case will never be run, |
michael@0 | 192 | # since it is checked for above. |
michael@0 | 193 | exit 1 |
michael@0 | 194 | ;; |
michael@0 | 195 | |
michael@0 | 196 | sgi) |
michael@0 | 197 | if test "$libtool" = yes; then |
michael@0 | 198 | "$@" "-Wp,-MDupdate,$tmpdepfile" |
michael@0 | 199 | else |
michael@0 | 200 | "$@" -MDupdate "$tmpdepfile" |
michael@0 | 201 | fi |
michael@0 | 202 | stat=$? |
michael@0 | 203 | if test $stat -eq 0; then : |
michael@0 | 204 | else |
michael@0 | 205 | rm -f "$tmpdepfile" |
michael@0 | 206 | exit $stat |
michael@0 | 207 | fi |
michael@0 | 208 | rm -f "$depfile" |
michael@0 | 209 | |
michael@0 | 210 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files |
michael@0 | 211 | echo "$object : \\" > "$depfile" |
michael@0 | 212 | |
michael@0 | 213 | # Clip off the initial element (the dependent). Don't try to be |
michael@0 | 214 | # clever and replace this with sed code, as IRIX sed won't handle |
michael@0 | 215 | # lines with more than a fixed number of characters (4096 in |
michael@0 | 216 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; |
michael@0 | 217 | # the IRIX cc adds comments like '#:fec' to the end of the |
michael@0 | 218 | # dependency line. |
michael@0 | 219 | tr ' ' "$nl" < "$tmpdepfile" \ |
michael@0 | 220 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ |
michael@0 | 221 | tr "$nl" ' ' >> "$depfile" |
michael@0 | 222 | echo >> "$depfile" |
michael@0 | 223 | |
michael@0 | 224 | # The second pass generates a dummy entry for each header file. |
michael@0 | 225 | tr ' ' "$nl" < "$tmpdepfile" \ |
michael@0 | 226 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ |
michael@0 | 227 | >> "$depfile" |
michael@0 | 228 | else |
michael@0 | 229 | # The sourcefile does not contain any dependencies, so just |
michael@0 | 230 | # store a dummy comment line, to avoid errors with the Makefile |
michael@0 | 231 | # "include basename.Plo" scheme. |
michael@0 | 232 | echo "#dummy" > "$depfile" |
michael@0 | 233 | fi |
michael@0 | 234 | rm -f "$tmpdepfile" |
michael@0 | 235 | ;; |
michael@0 | 236 | |
michael@0 | 237 | xlc) |
michael@0 | 238 | # This case exists only to let depend.m4 do its work. It works by |
michael@0 | 239 | # looking at the text of this script. This case will never be run, |
michael@0 | 240 | # since it is checked for above. |
michael@0 | 241 | exit 1 |
michael@0 | 242 | ;; |
michael@0 | 243 | |
michael@0 | 244 | aix) |
michael@0 | 245 | # The C for AIX Compiler uses -M and outputs the dependencies |
michael@0 | 246 | # in a .u file. In older versions, this file always lives in the |
michael@0 | 247 | # current directory. Also, the AIX compiler puts '$object:' at the |
michael@0 | 248 | # start of each line; $object doesn't have directory information. |
michael@0 | 249 | # Version 6 uses the directory in both cases. |
michael@0 | 250 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` |
michael@0 | 251 | test "x$dir" = "x$object" && dir= |
michael@0 | 252 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` |
michael@0 | 253 | if test "$libtool" = yes; then |
michael@0 | 254 | tmpdepfile1=$dir$base.u |
michael@0 | 255 | tmpdepfile2=$base.u |
michael@0 | 256 | tmpdepfile3=$dir.libs/$base.u |
michael@0 | 257 | "$@" -Wc,-M |
michael@0 | 258 | else |
michael@0 | 259 | tmpdepfile1=$dir$base.u |
michael@0 | 260 | tmpdepfile2=$dir$base.u |
michael@0 | 261 | tmpdepfile3=$dir$base.u |
michael@0 | 262 | "$@" -M |
michael@0 | 263 | fi |
michael@0 | 264 | stat=$? |
michael@0 | 265 | |
michael@0 | 266 | if test $stat -eq 0; then : |
michael@0 | 267 | else |
michael@0 | 268 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" |
michael@0 | 269 | exit $stat |
michael@0 | 270 | fi |
michael@0 | 271 | |
michael@0 | 272 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" |
michael@0 | 273 | do |
michael@0 | 274 | test -f "$tmpdepfile" && break |
michael@0 | 275 | done |
michael@0 | 276 | if test -f "$tmpdepfile"; then |
michael@0 | 277 | # Each line is of the form 'foo.o: dependent.h'. |
michael@0 | 278 | # Do two passes, one to just change these to |
michael@0 | 279 | # '$object: dependent.h' and one to simply 'dependent.h:'. |
michael@0 | 280 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
michael@0 | 281 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
michael@0 | 282 | else |
michael@0 | 283 | # The sourcefile does not contain any dependencies, so just |
michael@0 | 284 | # store a dummy comment line, to avoid errors with the Makefile |
michael@0 | 285 | # "include basename.Plo" scheme. |
michael@0 | 286 | echo "#dummy" > "$depfile" |
michael@0 | 287 | fi |
michael@0 | 288 | rm -f "$tmpdepfile" |
michael@0 | 289 | ;; |
michael@0 | 290 | |
michael@0 | 291 | icc) |
michael@0 | 292 | # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. |
michael@0 | 293 | # However on |
michael@0 | 294 | # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c |
michael@0 | 295 | # ICC 7.0 will fill foo.d with something like |
michael@0 | 296 | # foo.o: sub/foo.c |
michael@0 | 297 | # foo.o: sub/foo.h |
michael@0 | 298 | # which is wrong. We want |
michael@0 | 299 | # sub/foo.o: sub/foo.c |
michael@0 | 300 | # sub/foo.o: sub/foo.h |
michael@0 | 301 | # sub/foo.c: |
michael@0 | 302 | # sub/foo.h: |
michael@0 | 303 | # ICC 7.1 will output |
michael@0 | 304 | # foo.o: sub/foo.c sub/foo.h |
michael@0 | 305 | # and will wrap long lines using '\': |
michael@0 | 306 | # foo.o: sub/foo.c ... \ |
michael@0 | 307 | # sub/foo.h ... \ |
michael@0 | 308 | # ... |
michael@0 | 309 | # tcc 0.9.26 (FIXME still under development at the moment of writing) |
michael@0 | 310 | # will emit a similar output, but also prepend the continuation lines |
michael@0 | 311 | # with horizontal tabulation characters. |
michael@0 | 312 | "$@" -MD -MF "$tmpdepfile" |
michael@0 | 313 | stat=$? |
michael@0 | 314 | if test $stat -eq 0; then : |
michael@0 | 315 | else |
michael@0 | 316 | rm -f "$tmpdepfile" |
michael@0 | 317 | exit $stat |
michael@0 | 318 | fi |
michael@0 | 319 | rm -f "$depfile" |
michael@0 | 320 | # Each line is of the form 'foo.o: dependent.h', |
michael@0 | 321 | # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. |
michael@0 | 322 | # Do two passes, one to just change these to |
michael@0 | 323 | # '$object: dependent.h' and one to simply 'dependent.h:'. |
michael@0 | 324 | sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ |
michael@0 | 325 | < "$tmpdepfile" > "$depfile" |
michael@0 | 326 | sed ' |
michael@0 | 327 | s/[ '"$tab"'][ '"$tab"']*/ /g |
michael@0 | 328 | s/^ *// |
michael@0 | 329 | s/ *\\*$// |
michael@0 | 330 | s/^[^:]*: *// |
michael@0 | 331 | /^$/d |
michael@0 | 332 | /:$/d |
michael@0 | 333 | s/$/ :/ |
michael@0 | 334 | ' < "$tmpdepfile" >> "$depfile" |
michael@0 | 335 | rm -f "$tmpdepfile" |
michael@0 | 336 | ;; |
michael@0 | 337 | |
michael@0 | 338 | hp2) |
michael@0 | 339 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 |
michael@0 | 340 | # compilers, which have integrated preprocessors. The correct option |
michael@0 | 341 | # to use with these is +Maked; it writes dependencies to a file named |
michael@0 | 342 | # 'foo.d', which lands next to the object file, wherever that |
michael@0 | 343 | # happens to be. |
michael@0 | 344 | # Much of this is similar to the tru64 case; see comments there. |
michael@0 | 345 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` |
michael@0 | 346 | test "x$dir" = "x$object" && dir= |
michael@0 | 347 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` |
michael@0 | 348 | if test "$libtool" = yes; then |
michael@0 | 349 | tmpdepfile1=$dir$base.d |
michael@0 | 350 | tmpdepfile2=$dir.libs/$base.d |
michael@0 | 351 | "$@" -Wc,+Maked |
michael@0 | 352 | else |
michael@0 | 353 | tmpdepfile1=$dir$base.d |
michael@0 | 354 | tmpdepfile2=$dir$base.d |
michael@0 | 355 | "$@" +Maked |
michael@0 | 356 | fi |
michael@0 | 357 | stat=$? |
michael@0 | 358 | if test $stat -eq 0; then : |
michael@0 | 359 | else |
michael@0 | 360 | rm -f "$tmpdepfile1" "$tmpdepfile2" |
michael@0 | 361 | exit $stat |
michael@0 | 362 | fi |
michael@0 | 363 | |
michael@0 | 364 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" |
michael@0 | 365 | do |
michael@0 | 366 | test -f "$tmpdepfile" && break |
michael@0 | 367 | done |
michael@0 | 368 | if test -f "$tmpdepfile"; then |
michael@0 | 369 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" |
michael@0 | 370 | # Add 'dependent.h:' lines. |
michael@0 | 371 | sed -ne '2,${ |
michael@0 | 372 | s/^ *// |
michael@0 | 373 | s/ \\*$// |
michael@0 | 374 | s/$/:/ |
michael@0 | 375 | p |
michael@0 | 376 | }' "$tmpdepfile" >> "$depfile" |
michael@0 | 377 | else |
michael@0 | 378 | echo "#dummy" > "$depfile" |
michael@0 | 379 | fi |
michael@0 | 380 | rm -f "$tmpdepfile" "$tmpdepfile2" |
michael@0 | 381 | ;; |
michael@0 | 382 | |
michael@0 | 383 | tru64) |
michael@0 | 384 | # The Tru64 compiler uses -MD to generate dependencies as a side |
michael@0 | 385 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. |
michael@0 | 386 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put |
michael@0 | 387 | # dependencies in 'foo.d' instead, so we check for that too. |
michael@0 | 388 | # Subdirectories are respected. |
michael@0 | 389 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` |
michael@0 | 390 | test "x$dir" = "x$object" && dir= |
michael@0 | 391 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` |
michael@0 | 392 | |
michael@0 | 393 | if test "$libtool" = yes; then |
michael@0 | 394 | # With Tru64 cc, shared objects can also be used to make a |
michael@0 | 395 | # static library. This mechanism is used in libtool 1.4 series to |
michael@0 | 396 | # handle both shared and static libraries in a single compilation. |
michael@0 | 397 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. |
michael@0 | 398 | # |
michael@0 | 399 | # With libtool 1.5 this exception was removed, and libtool now |
michael@0 | 400 | # generates 2 separate objects for the 2 libraries. These two |
michael@0 | 401 | # compilations output dependencies in $dir.libs/$base.o.d and |
michael@0 | 402 | # in $dir$base.o.d. We have to check for both files, because |
michael@0 | 403 | # one of the two compilations can be disabled. We should prefer |
michael@0 | 404 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is |
michael@0 | 405 | # automatically cleaned when .libs/ is deleted, while ignoring |
michael@0 | 406 | # the former would cause a distcleancheck panic. |
michael@0 | 407 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 |
michael@0 | 408 | tmpdepfile2=$dir$base.o.d # libtool 1.5 |
michael@0 | 409 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 |
michael@0 | 410 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 |
michael@0 | 411 | "$@" -Wc,-MD |
michael@0 | 412 | else |
michael@0 | 413 | tmpdepfile1=$dir$base.o.d |
michael@0 | 414 | tmpdepfile2=$dir$base.d |
michael@0 | 415 | tmpdepfile3=$dir$base.d |
michael@0 | 416 | tmpdepfile4=$dir$base.d |
michael@0 | 417 | "$@" -MD |
michael@0 | 418 | fi |
michael@0 | 419 | |
michael@0 | 420 | stat=$? |
michael@0 | 421 | if test $stat -eq 0; then : |
michael@0 | 422 | else |
michael@0 | 423 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" |
michael@0 | 424 | exit $stat |
michael@0 | 425 | fi |
michael@0 | 426 | |
michael@0 | 427 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" |
michael@0 | 428 | do |
michael@0 | 429 | test -f "$tmpdepfile" && break |
michael@0 | 430 | done |
michael@0 | 431 | if test -f "$tmpdepfile"; then |
michael@0 | 432 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
michael@0 | 433 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
michael@0 | 434 | else |
michael@0 | 435 | echo "#dummy" > "$depfile" |
michael@0 | 436 | fi |
michael@0 | 437 | rm -f "$tmpdepfile" |
michael@0 | 438 | ;; |
michael@0 | 439 | |
michael@0 | 440 | msvc7) |
michael@0 | 441 | if test "$libtool" = yes; then |
michael@0 | 442 | showIncludes=-Wc,-showIncludes |
michael@0 | 443 | else |
michael@0 | 444 | showIncludes=-showIncludes |
michael@0 | 445 | fi |
michael@0 | 446 | "$@" $showIncludes > "$tmpdepfile" |
michael@0 | 447 | stat=$? |
michael@0 | 448 | grep -v '^Note: including file: ' "$tmpdepfile" |
michael@0 | 449 | if test "$stat" = 0; then : |
michael@0 | 450 | else |
michael@0 | 451 | rm -f "$tmpdepfile" |
michael@0 | 452 | exit $stat |
michael@0 | 453 | fi |
michael@0 | 454 | rm -f "$depfile" |
michael@0 | 455 | echo "$object : \\" > "$depfile" |
michael@0 | 456 | # The first sed program below extracts the file names and escapes |
michael@0 | 457 | # backslashes for cygpath. The second sed program outputs the file |
michael@0 | 458 | # name when reading, but also accumulates all include files in the |
michael@0 | 459 | # hold buffer in order to output them again at the end. This only |
michael@0 | 460 | # works with sed implementations that can handle large buffers. |
michael@0 | 461 | sed < "$tmpdepfile" -n ' |
michael@0 | 462 | /^Note: including file: *\(.*\)/ { |
michael@0 | 463 | s//\1/ |
michael@0 | 464 | s/\\/\\\\/g |
michael@0 | 465 | p |
michael@0 | 466 | }' | $cygpath_u | sort -u | sed -n ' |
michael@0 | 467 | s/ /\\ /g |
michael@0 | 468 | s/\(.*\)/'"$tab"'\1 \\/p |
michael@0 | 469 | s/.\(.*\) \\/\1:/ |
michael@0 | 470 | H |
michael@0 | 471 | $ { |
michael@0 | 472 | s/.*/'"$tab"'/ |
michael@0 | 473 | G |
michael@0 | 474 | p |
michael@0 | 475 | }' >> "$depfile" |
michael@0 | 476 | rm -f "$tmpdepfile" |
michael@0 | 477 | ;; |
michael@0 | 478 | |
michael@0 | 479 | msvc7msys) |
michael@0 | 480 | # This case exists only to let depend.m4 do its work. It works by |
michael@0 | 481 | # looking at the text of this script. This case will never be run, |
michael@0 | 482 | # since it is checked for above. |
michael@0 | 483 | exit 1 |
michael@0 | 484 | ;; |
michael@0 | 485 | |
michael@0 | 486 | #nosideeffect) |
michael@0 | 487 | # This comment above is used by automake to tell side-effect |
michael@0 | 488 | # dependency tracking mechanisms from slower ones. |
michael@0 | 489 | |
michael@0 | 490 | dashmstdout) |
michael@0 | 491 | # Important note: in order to support this mode, a compiler *must* |
michael@0 | 492 | # always write the preprocessed file to stdout, regardless of -o. |
michael@0 | 493 | "$@" || exit $? |
michael@0 | 494 | |
michael@0 | 495 | # Remove the call to Libtool. |
michael@0 | 496 | if test "$libtool" = yes; then |
michael@0 | 497 | while test "X$1" != 'X--mode=compile'; do |
michael@0 | 498 | shift |
michael@0 | 499 | done |
michael@0 | 500 | shift |
michael@0 | 501 | fi |
michael@0 | 502 | |
michael@0 | 503 | # Remove '-o $object'. |
michael@0 | 504 | IFS=" " |
michael@0 | 505 | for arg |
michael@0 | 506 | do |
michael@0 | 507 | case $arg in |
michael@0 | 508 | -o) |
michael@0 | 509 | shift |
michael@0 | 510 | ;; |
michael@0 | 511 | $object) |
michael@0 | 512 | shift |
michael@0 | 513 | ;; |
michael@0 | 514 | *) |
michael@0 | 515 | set fnord "$@" "$arg" |
michael@0 | 516 | shift # fnord |
michael@0 | 517 | shift # $arg |
michael@0 | 518 | ;; |
michael@0 | 519 | esac |
michael@0 | 520 | done |
michael@0 | 521 | |
michael@0 | 522 | test -z "$dashmflag" && dashmflag=-M |
michael@0 | 523 | # Require at least two characters before searching for ':' |
michael@0 | 524 | # in the target name. This is to cope with DOS-style filenames: |
michael@0 | 525 | # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. |
michael@0 | 526 | "$@" $dashmflag | |
michael@0 | 527 | sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" |
michael@0 | 528 | rm -f "$depfile" |
michael@0 | 529 | cat < "$tmpdepfile" > "$depfile" |
michael@0 | 530 | tr ' ' "$nl" < "$tmpdepfile" | \ |
michael@0 | 531 | ## Some versions of the HPUX 10.20 sed can't process this invocation |
michael@0 | 532 | ## correctly. Breaking it into two sed invocations is a workaround. |
michael@0 | 533 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
michael@0 | 534 | rm -f "$tmpdepfile" |
michael@0 | 535 | ;; |
michael@0 | 536 | |
michael@0 | 537 | dashXmstdout) |
michael@0 | 538 | # This case only exists to satisfy depend.m4. It is never actually |
michael@0 | 539 | # run, as this mode is specially recognized in the preamble. |
michael@0 | 540 | exit 1 |
michael@0 | 541 | ;; |
michael@0 | 542 | |
michael@0 | 543 | makedepend) |
michael@0 | 544 | "$@" || exit $? |
michael@0 | 545 | # Remove any Libtool call |
michael@0 | 546 | if test "$libtool" = yes; then |
michael@0 | 547 | while test "X$1" != 'X--mode=compile'; do |
michael@0 | 548 | shift |
michael@0 | 549 | done |
michael@0 | 550 | shift |
michael@0 | 551 | fi |
michael@0 | 552 | # X makedepend |
michael@0 | 553 | shift |
michael@0 | 554 | cleared=no eat=no |
michael@0 | 555 | for arg |
michael@0 | 556 | do |
michael@0 | 557 | case $cleared in |
michael@0 | 558 | no) |
michael@0 | 559 | set ""; shift |
michael@0 | 560 | cleared=yes ;; |
michael@0 | 561 | esac |
michael@0 | 562 | if test $eat = yes; then |
michael@0 | 563 | eat=no |
michael@0 | 564 | continue |
michael@0 | 565 | fi |
michael@0 | 566 | case "$arg" in |
michael@0 | 567 | -D*|-I*) |
michael@0 | 568 | set fnord "$@" "$arg"; shift ;; |
michael@0 | 569 | # Strip any option that makedepend may not understand. Remove |
michael@0 | 570 | # the object too, otherwise makedepend will parse it as a source file. |
michael@0 | 571 | -arch) |
michael@0 | 572 | eat=yes ;; |
michael@0 | 573 | -*|$object) |
michael@0 | 574 | ;; |
michael@0 | 575 | *) |
michael@0 | 576 | set fnord "$@" "$arg"; shift ;; |
michael@0 | 577 | esac |
michael@0 | 578 | done |
michael@0 | 579 | obj_suffix=`echo "$object" | sed 's/^.*\././'` |
michael@0 | 580 | touch "$tmpdepfile" |
michael@0 | 581 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" |
michael@0 | 582 | rm -f "$depfile" |
michael@0 | 583 | # makedepend may prepend the VPATH from the source file name to the object. |
michael@0 | 584 | # No need to regex-escape $object, excess matching of '.' is harmless. |
michael@0 | 585 | sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" |
michael@0 | 586 | sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ |
michael@0 | 587 | ## Some versions of the HPUX 10.20 sed can't process this invocation |
michael@0 | 588 | ## correctly. Breaking it into two sed invocations is a workaround. |
michael@0 | 589 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
michael@0 | 590 | rm -f "$tmpdepfile" "$tmpdepfile".bak |
michael@0 | 591 | ;; |
michael@0 | 592 | |
michael@0 | 593 | cpp) |
michael@0 | 594 | # Important note: in order to support this mode, a compiler *must* |
michael@0 | 595 | # always write the preprocessed file to stdout. |
michael@0 | 596 | "$@" || exit $? |
michael@0 | 597 | |
michael@0 | 598 | # Remove the call to Libtool. |
michael@0 | 599 | if test "$libtool" = yes; then |
michael@0 | 600 | while test "X$1" != 'X--mode=compile'; do |
michael@0 | 601 | shift |
michael@0 | 602 | done |
michael@0 | 603 | shift |
michael@0 | 604 | fi |
michael@0 | 605 | |
michael@0 | 606 | # Remove '-o $object'. |
michael@0 | 607 | IFS=" " |
michael@0 | 608 | for arg |
michael@0 | 609 | do |
michael@0 | 610 | case $arg in |
michael@0 | 611 | -o) |
michael@0 | 612 | shift |
michael@0 | 613 | ;; |
michael@0 | 614 | $object) |
michael@0 | 615 | shift |
michael@0 | 616 | ;; |
michael@0 | 617 | *) |
michael@0 | 618 | set fnord "$@" "$arg" |
michael@0 | 619 | shift # fnord |
michael@0 | 620 | shift # $arg |
michael@0 | 621 | ;; |
michael@0 | 622 | esac |
michael@0 | 623 | done |
michael@0 | 624 | |
michael@0 | 625 | "$@" -E | |
michael@0 | 626 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ |
michael@0 | 627 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | |
michael@0 | 628 | sed '$ s: \\$::' > "$tmpdepfile" |
michael@0 | 629 | rm -f "$depfile" |
michael@0 | 630 | echo "$object : \\" > "$depfile" |
michael@0 | 631 | cat < "$tmpdepfile" >> "$depfile" |
michael@0 | 632 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" |
michael@0 | 633 | rm -f "$tmpdepfile" |
michael@0 | 634 | ;; |
michael@0 | 635 | |
michael@0 | 636 | msvisualcpp) |
michael@0 | 637 | # Important note: in order to support this mode, a compiler *must* |
michael@0 | 638 | # always write the preprocessed file to stdout. |
michael@0 | 639 | "$@" || exit $? |
michael@0 | 640 | |
michael@0 | 641 | # Remove the call to Libtool. |
michael@0 | 642 | if test "$libtool" = yes; then |
michael@0 | 643 | while test "X$1" != 'X--mode=compile'; do |
michael@0 | 644 | shift |
michael@0 | 645 | done |
michael@0 | 646 | shift |
michael@0 | 647 | fi |
michael@0 | 648 | |
michael@0 | 649 | IFS=" " |
michael@0 | 650 | for arg |
michael@0 | 651 | do |
michael@0 | 652 | case "$arg" in |
michael@0 | 653 | -o) |
michael@0 | 654 | shift |
michael@0 | 655 | ;; |
michael@0 | 656 | $object) |
michael@0 | 657 | shift |
michael@0 | 658 | ;; |
michael@0 | 659 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") |
michael@0 | 660 | set fnord "$@" |
michael@0 | 661 | shift |
michael@0 | 662 | shift |
michael@0 | 663 | ;; |
michael@0 | 664 | *) |
michael@0 | 665 | set fnord "$@" "$arg" |
michael@0 | 666 | shift |
michael@0 | 667 | shift |
michael@0 | 668 | ;; |
michael@0 | 669 | esac |
michael@0 | 670 | done |
michael@0 | 671 | "$@" -E 2>/dev/null | |
michael@0 | 672 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" |
michael@0 | 673 | rm -f "$depfile" |
michael@0 | 674 | echo "$object : \\" > "$depfile" |
michael@0 | 675 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" |
michael@0 | 676 | echo "$tab" >> "$depfile" |
michael@0 | 677 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" |
michael@0 | 678 | rm -f "$tmpdepfile" |
michael@0 | 679 | ;; |
michael@0 | 680 | |
michael@0 | 681 | msvcmsys) |
michael@0 | 682 | # This case exists only to let depend.m4 do its work. It works by |
michael@0 | 683 | # looking at the text of this script. This case will never be run, |
michael@0 | 684 | # since it is checked for above. |
michael@0 | 685 | exit 1 |
michael@0 | 686 | ;; |
michael@0 | 687 | |
michael@0 | 688 | none) |
michael@0 | 689 | exec "$@" |
michael@0 | 690 | ;; |
michael@0 | 691 | |
michael@0 | 692 | *) |
michael@0 | 693 | echo "Unknown depmode $depmode" 1>&2 |
michael@0 | 694 | exit 1 |
michael@0 | 695 | ;; |
michael@0 | 696 | esac |
michael@0 | 697 | |
michael@0 | 698 | exit 0 |
michael@0 | 699 | |
michael@0 | 700 | # Local Variables: |
michael@0 | 701 | # mode: shell-script |
michael@0 | 702 | # sh-indentation: 2 |
michael@0 | 703 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
michael@0 | 704 | # time-stamp-start: "scriptversion=" |
michael@0 | 705 | # time-stamp-format: "%:y-%02m-%02d.%02H" |
michael@0 | 706 | # time-stamp-time-zone: "UTC" |
michael@0 | 707 | # time-stamp-end: "; # UTC" |
michael@0 | 708 | # End: |