depcomp revision b4485a66
1010cdda0Smrg#! /bin/sh 2010cdda0Smrg# depcomp - compile a program generating dependencies as side-effects 3b3eb03f3Smrg 4b4485a66Smrgscriptversion=2011-12-04.11; # UTC 5b3eb03f3Smrg 6b4485a66Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7b4485a66Smrg# 2011 Free Software Foundation, Inc. 8010cdda0Smrg 9010cdda0Smrg# This program is free software; you can redistribute it and/or modify 10010cdda0Smrg# it under the terms of the GNU General Public License as published by 11010cdda0Smrg# the Free Software Foundation; either version 2, or (at your option) 12010cdda0Smrg# any later version. 13010cdda0Smrg 14010cdda0Smrg# This program is distributed in the hope that it will be useful, 15010cdda0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16010cdda0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17010cdda0Smrg# GNU General Public License for more details. 18010cdda0Smrg 19010cdda0Smrg# You should have received a copy of the GNU General Public License 20b3eb03f3Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21010cdda0Smrg 22010cdda0Smrg# As a special exception to the GNU General Public License, if you 23010cdda0Smrg# distribute this file as part of a program that contains a 24010cdda0Smrg# configuration script generated by Autoconf, you may include it under 25010cdda0Smrg# the same distribution terms that you use for the rest of that program. 26010cdda0Smrg 27010cdda0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28010cdda0Smrg 29b3eb03f3Smrgcase $1 in 30b3eb03f3Smrg '') 31b3eb03f3Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32b3eb03f3Smrg exit 1; 33b3eb03f3Smrg ;; 34b3eb03f3Smrg -h | --h*) 35b3eb03f3Smrg cat <<\EOF 36b3eb03f3SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37b3eb03f3Smrg 38b3eb03f3SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39b3eb03f3Smrgas side-effects. 40b3eb03f3Smrg 41b3eb03f3SmrgEnvironment variables: 42b3eb03f3Smrg depmode Dependency tracking mode. 43b3eb03f3Smrg source Source file read by `PROGRAMS ARGS'. 44b3eb03f3Smrg object Object file output by `PROGRAMS ARGS'. 45b3eb03f3Smrg DEPDIR directory where to store dependencies. 46b3eb03f3Smrg depfile Dependency file to output. 47b4485a66Smrg tmpdepfile Temporary file to use when outputting dependencies. 48b3eb03f3Smrg libtool Whether libtool is used (yes/no). 49b3eb03f3Smrg 50b3eb03f3SmrgReport bugs to <bug-automake@gnu.org>. 51b3eb03f3SmrgEOF 52b3eb03f3Smrg exit $? 53b3eb03f3Smrg ;; 54b3eb03f3Smrg -v | --v*) 55b3eb03f3Smrg echo "depcomp $scriptversion" 56b3eb03f3Smrg exit $? 57b3eb03f3Smrg ;; 58b3eb03f3Smrgesac 59b3eb03f3Smrg 60010cdda0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61010cdda0Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62010cdda0Smrg exit 1 63010cdda0Smrgfi 64010cdda0Smrg 65b3eb03f3Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66b3eb03f3Smrgdepfile=${depfile-`echo "$object" | 67b3eb03f3Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68010cdda0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69010cdda0Smrg 70010cdda0Smrgrm -f "$tmpdepfile" 71010cdda0Smrg 72010cdda0Smrg# Some modes work just like other modes, but use different flags. We 73010cdda0Smrg# parameterize here, but still list the modes in the big case below, 74010cdda0Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75010cdda0Smrg# here, because this file can only contain one case statement. 76010cdda0Smrgif test "$depmode" = hp; then 77010cdda0Smrg # HP compiler uses -M and no extra arg. 78010cdda0Smrg gccflag=-M 79010cdda0Smrg depmode=gcc 80010cdda0Smrgfi 81010cdda0Smrg 82010cdda0Smrgif test "$depmode" = dashXmstdout; then 83010cdda0Smrg # This is just like dashmstdout with a different argument. 84010cdda0Smrg dashmflag=-xM 85010cdda0Smrg depmode=dashmstdout 86010cdda0Smrgfi 87010cdda0Smrg 88b3eb03f3Smrgcygpath_u="cygpath -u -f -" 89b3eb03f3Smrgif test "$depmode" = msvcmsys; then 90b3eb03f3Smrg # This is just like msvisualcpp but w/o cygpath translation. 91b3eb03f3Smrg # Just convert the backslash-escaped backslashes to single forward 92b3eb03f3Smrg # slashes to satisfy depend.m4 93b4485a66Smrg cygpath_u='sed s,\\\\,/,g' 94b3eb03f3Smrg depmode=msvisualcpp 95b3eb03f3Smrgfi 96b3eb03f3Smrg 97b4485a66Smrgif test "$depmode" = msvc7msys; then 98b4485a66Smrg # This is just like msvc7 but w/o cygpath translation. 99b4485a66Smrg # Just convert the backslash-escaped backslashes to single forward 100b4485a66Smrg # slashes to satisfy depend.m4 101b4485a66Smrg cygpath_u='sed s,\\\\,/,g' 102b4485a66Smrg depmode=msvc7 103b4485a66Smrgfi 104b4485a66Smrg 105010cdda0Smrgcase "$depmode" in 106010cdda0Smrggcc3) 107010cdda0Smrg## gcc 3 implements dependency tracking that does exactly what 108010cdda0Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109010cdda0Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 110b3eb03f3Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 111b3eb03f3Smrg## the command line argument order; so add the flags where they 112b3eb03f3Smrg## appear in depend2.am. Note that the slowdown incurred here 113b3eb03f3Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 114b3eb03f3Smrg for arg 115b3eb03f3Smrg do 116b3eb03f3Smrg case $arg in 117b3eb03f3Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 118b3eb03f3Smrg *) set fnord "$@" "$arg" ;; 119b3eb03f3Smrg esac 120b3eb03f3Smrg shift # fnord 121b3eb03f3Smrg shift # $arg 122b3eb03f3Smrg done 123b3eb03f3Smrg "$@" 124010cdda0Smrg stat=$? 125010cdda0Smrg if test $stat -eq 0; then : 126010cdda0Smrg else 127010cdda0Smrg rm -f "$tmpdepfile" 128010cdda0Smrg exit $stat 129010cdda0Smrg fi 130010cdda0Smrg mv "$tmpdepfile" "$depfile" 131010cdda0Smrg ;; 132010cdda0Smrg 133010cdda0Smrggcc) 134010cdda0Smrg## There are various ways to get dependency output from gcc. Here's 135010cdda0Smrg## why we pick this rather obscure method: 136010cdda0Smrg## - Don't want to use -MD because we'd like the dependencies to end 137010cdda0Smrg## up in a subdir. Having to rename by hand is ugly. 138010cdda0Smrg## (We might end up doing this anyway to support other compilers.) 139010cdda0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140010cdda0Smrg## -MM, not -M (despite what the docs say). 141010cdda0Smrg## - Using -M directly means running the compiler twice (even worse 142010cdda0Smrg## than renaming). 143010cdda0Smrg if test -z "$gccflag"; then 144010cdda0Smrg gccflag=-MD, 145010cdda0Smrg fi 146010cdda0Smrg "$@" -Wp,"$gccflag$tmpdepfile" 147010cdda0Smrg stat=$? 148010cdda0Smrg if test $stat -eq 0; then : 149010cdda0Smrg else 150010cdda0Smrg rm -f "$tmpdepfile" 151010cdda0Smrg exit $stat 152010cdda0Smrg fi 153010cdda0Smrg rm -f "$depfile" 154010cdda0Smrg echo "$object : \\" > "$depfile" 155010cdda0Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156010cdda0Smrg## The second -e expression handles DOS-style file names with drive letters. 157010cdda0Smrg sed -e 's/^[^:]*: / /' \ 158010cdda0Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159010cdda0Smrg## This next piece of magic avoids the `deleted header file' problem. 160010cdda0Smrg## The problem is that when a header file which appears in a .P file 161010cdda0Smrg## is deleted, the dependency causes make to die (because there is 162010cdda0Smrg## typically no way to rebuild the header). We avoid this by adding 163010cdda0Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 164010cdda0Smrg## this for us directly. 165010cdda0Smrg tr ' ' ' 166010cdda0Smrg' < "$tmpdepfile" | 167010cdda0Smrg## Some versions of gcc put a space before the `:'. On the theory 168010cdda0Smrg## that the space means something, we add a space to the output as 169b4485a66Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 170b4485a66Smrg## to the object. Take care to not repeat it in the output. 171010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 172010cdda0Smrg## correctly. Breaking it into two sed invocations is a workaround. 173b4485a66Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 174b4485a66Smrg | sed -e 's/$/ :/' >> "$depfile" 175010cdda0Smrg rm -f "$tmpdepfile" 176010cdda0Smrg ;; 177010cdda0Smrg 178010cdda0Smrghp) 179010cdda0Smrg # This case exists only to let depend.m4 do its work. It works by 180010cdda0Smrg # looking at the text of this script. This case will never be run, 181010cdda0Smrg # since it is checked for above. 182010cdda0Smrg exit 1 183010cdda0Smrg ;; 184010cdda0Smrg 185010cdda0Smrgsgi) 186010cdda0Smrg if test "$libtool" = yes; then 187010cdda0Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188010cdda0Smrg else 189010cdda0Smrg "$@" -MDupdate "$tmpdepfile" 190010cdda0Smrg fi 191010cdda0Smrg stat=$? 192010cdda0Smrg if test $stat -eq 0; then : 193010cdda0Smrg else 194010cdda0Smrg rm -f "$tmpdepfile" 195010cdda0Smrg exit $stat 196010cdda0Smrg fi 197010cdda0Smrg rm -f "$depfile" 198010cdda0Smrg 199010cdda0Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200010cdda0Smrg echo "$object : \\" > "$depfile" 201010cdda0Smrg 202010cdda0Smrg # Clip off the initial element (the dependent). Don't try to be 203010cdda0Smrg # clever and replace this with sed code, as IRIX sed won't handle 204010cdda0Smrg # lines with more than a fixed number of characters (4096 in 205010cdda0Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206010cdda0Smrg # the IRIX cc adds comments like `#:fec' to the end of the 207010cdda0Smrg # dependency line. 208010cdda0Smrg tr ' ' ' 209010cdda0Smrg' < "$tmpdepfile" \ 210010cdda0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211010cdda0Smrg tr ' 212b3eb03f3Smrg' ' ' >> "$depfile" 213b3eb03f3Smrg echo >> "$depfile" 214010cdda0Smrg 215010cdda0Smrg # The second pass generates a dummy entry for each header file. 216010cdda0Smrg tr ' ' ' 217010cdda0Smrg' < "$tmpdepfile" \ 218010cdda0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 219b3eb03f3Smrg >> "$depfile" 220010cdda0Smrg else 221010cdda0Smrg # The sourcefile does not contain any dependencies, so just 222010cdda0Smrg # store a dummy comment line, to avoid errors with the Makefile 223010cdda0Smrg # "include basename.Plo" scheme. 224010cdda0Smrg echo "#dummy" > "$depfile" 225010cdda0Smrg fi 226010cdda0Smrg rm -f "$tmpdepfile" 227010cdda0Smrg ;; 228010cdda0Smrg 229010cdda0Smrgaix) 230010cdda0Smrg # The C for AIX Compiler uses -M and outputs the dependencies 231010cdda0Smrg # in a .u file. In older versions, this file always lives in the 232010cdda0Smrg # current directory. Also, the AIX compiler puts `$object:' at the 233010cdda0Smrg # start of each line; $object doesn't have directory information. 234010cdda0Smrg # Version 6 uses the directory in both cases. 235b3eb03f3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 236b3eb03f3Smrg test "x$dir" = "x$object" && dir= 237b3eb03f3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238010cdda0Smrg if test "$libtool" = yes; then 239b3eb03f3Smrg tmpdepfile1=$dir$base.u 240b3eb03f3Smrg tmpdepfile2=$base.u 241b3eb03f3Smrg tmpdepfile3=$dir.libs/$base.u 242010cdda0Smrg "$@" -Wc,-M 243010cdda0Smrg else 244b3eb03f3Smrg tmpdepfile1=$dir$base.u 245b3eb03f3Smrg tmpdepfile2=$dir$base.u 246b3eb03f3Smrg tmpdepfile3=$dir$base.u 247010cdda0Smrg "$@" -M 248010cdda0Smrg fi 249010cdda0Smrg stat=$? 250010cdda0Smrg 251010cdda0Smrg if test $stat -eq 0; then : 252010cdda0Smrg else 253b3eb03f3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254010cdda0Smrg exit $stat 255010cdda0Smrg fi 256010cdda0Smrg 257b3eb03f3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 258b3eb03f3Smrg do 259b3eb03f3Smrg test -f "$tmpdepfile" && break 260b3eb03f3Smrg done 261010cdda0Smrg if test -f "$tmpdepfile"; then 262010cdda0Smrg # Each line is of the form `foo.o: dependent.h'. 263010cdda0Smrg # Do two passes, one to just change these to 264010cdda0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 265b3eb03f3Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 266b3eb03f3Smrg # That's a tab and a space in the []. 267b3eb03f3Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268010cdda0Smrg else 269010cdda0Smrg # The sourcefile does not contain any dependencies, so just 270010cdda0Smrg # store a dummy comment line, to avoid errors with the Makefile 271010cdda0Smrg # "include basename.Plo" scheme. 272010cdda0Smrg echo "#dummy" > "$depfile" 273010cdda0Smrg fi 274010cdda0Smrg rm -f "$tmpdepfile" 275010cdda0Smrg ;; 276010cdda0Smrg 277010cdda0Smrgicc) 278010cdda0Smrg # Intel's C compiler understands `-MD -MF file'. However on 279010cdda0Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280010cdda0Smrg # ICC 7.0 will fill foo.d with something like 281010cdda0Smrg # foo.o: sub/foo.c 282010cdda0Smrg # foo.o: sub/foo.h 283010cdda0Smrg # which is wrong. We want: 284010cdda0Smrg # sub/foo.o: sub/foo.c 285010cdda0Smrg # sub/foo.o: sub/foo.h 286010cdda0Smrg # sub/foo.c: 287010cdda0Smrg # sub/foo.h: 288010cdda0Smrg # ICC 7.1 will output 289010cdda0Smrg # foo.o: sub/foo.c sub/foo.h 290010cdda0Smrg # and will wrap long lines using \ : 291010cdda0Smrg # foo.o: sub/foo.c ... \ 292010cdda0Smrg # sub/foo.h ... \ 293010cdda0Smrg # ... 294010cdda0Smrg 295010cdda0Smrg "$@" -MD -MF "$tmpdepfile" 296010cdda0Smrg stat=$? 297010cdda0Smrg if test $stat -eq 0; then : 298010cdda0Smrg else 299010cdda0Smrg rm -f "$tmpdepfile" 300010cdda0Smrg exit $stat 301010cdda0Smrg fi 302010cdda0Smrg rm -f "$depfile" 303010cdda0Smrg # Each line is of the form `foo.o: dependent.h', 304010cdda0Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305010cdda0Smrg # Do two passes, one to just change these to 306010cdda0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 307010cdda0Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308010cdda0Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 309010cdda0Smrg # correctly. Breaking it into two sed invocations is a workaround. 310010cdda0Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311010cdda0Smrg sed -e 's/$/ :/' >> "$depfile" 312010cdda0Smrg rm -f "$tmpdepfile" 313010cdda0Smrg ;; 314010cdda0Smrg 315b3eb03f3Smrghp2) 316b3eb03f3Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 317b3eb03f3Smrg # compilers, which have integrated preprocessors. The correct option 318b3eb03f3Smrg # to use with these is +Maked; it writes dependencies to a file named 319b3eb03f3Smrg # 'foo.d', which lands next to the object file, wherever that 320b3eb03f3Smrg # happens to be. 321b3eb03f3Smrg # Much of this is similar to the tru64 case; see comments there. 322b3eb03f3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 323b3eb03f3Smrg test "x$dir" = "x$object" && dir= 324b3eb03f3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 325b3eb03f3Smrg if test "$libtool" = yes; then 326b3eb03f3Smrg tmpdepfile1=$dir$base.d 327b3eb03f3Smrg tmpdepfile2=$dir.libs/$base.d 328b3eb03f3Smrg "$@" -Wc,+Maked 329b3eb03f3Smrg else 330b3eb03f3Smrg tmpdepfile1=$dir$base.d 331b3eb03f3Smrg tmpdepfile2=$dir$base.d 332b3eb03f3Smrg "$@" +Maked 333b3eb03f3Smrg fi 334b3eb03f3Smrg stat=$? 335b3eb03f3Smrg if test $stat -eq 0; then : 336b3eb03f3Smrg else 337b3eb03f3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 338b3eb03f3Smrg exit $stat 339b3eb03f3Smrg fi 340b3eb03f3Smrg 341b3eb03f3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 342b3eb03f3Smrg do 343b3eb03f3Smrg test -f "$tmpdepfile" && break 344b3eb03f3Smrg done 345b3eb03f3Smrg if test -f "$tmpdepfile"; then 346b3eb03f3Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 347b3eb03f3Smrg # Add `dependent.h:' lines. 348b3eb03f3Smrg sed -ne '2,${ 349b3eb03f3Smrg s/^ *// 350b3eb03f3Smrg s/ \\*$// 351b3eb03f3Smrg s/$/:/ 352b3eb03f3Smrg p 353b3eb03f3Smrg }' "$tmpdepfile" >> "$depfile" 354b3eb03f3Smrg else 355b3eb03f3Smrg echo "#dummy" > "$depfile" 356b3eb03f3Smrg fi 357b3eb03f3Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 358b3eb03f3Smrg ;; 359b3eb03f3Smrg 360010cdda0Smrgtru64) 361010cdda0Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 362010cdda0Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363010cdda0Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364010cdda0Smrg # dependencies in `foo.d' instead, so we check for that too. 365010cdda0Smrg # Subdirectories are respected. 366010cdda0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367010cdda0Smrg test "x$dir" = "x$object" && dir= 368010cdda0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369010cdda0Smrg 370010cdda0Smrg if test "$libtool" = yes; then 371b3eb03f3Smrg # With Tru64 cc, shared objects can also be used to make a 372b3eb03f3Smrg # static library. This mechanism is used in libtool 1.4 series to 373b3eb03f3Smrg # handle both shared and static libraries in a single compilation. 374b3eb03f3Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 375b3eb03f3Smrg # 376b3eb03f3Smrg # With libtool 1.5 this exception was removed, and libtool now 377b3eb03f3Smrg # generates 2 separate objects for the 2 libraries. These two 378b3eb03f3Smrg # compilations output dependencies in $dir.libs/$base.o.d and 379b3eb03f3Smrg # in $dir$base.o.d. We have to check for both files, because 380b3eb03f3Smrg # one of the two compilations can be disabled. We should prefer 381b3eb03f3Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 382b3eb03f3Smrg # automatically cleaned when .libs/ is deleted, while ignoring 383b3eb03f3Smrg # the former would cause a distcleancheck panic. 384b3eb03f3Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 385b3eb03f3Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 386b3eb03f3Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 387b3eb03f3Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388010cdda0Smrg "$@" -Wc,-MD 389010cdda0Smrg else 390b3eb03f3Smrg tmpdepfile1=$dir$base.o.d 391b3eb03f3Smrg tmpdepfile2=$dir$base.d 392b3eb03f3Smrg tmpdepfile3=$dir$base.d 393b3eb03f3Smrg tmpdepfile4=$dir$base.d 394010cdda0Smrg "$@" -MD 395010cdda0Smrg fi 396010cdda0Smrg 397010cdda0Smrg stat=$? 398010cdda0Smrg if test $stat -eq 0; then : 399010cdda0Smrg else 400b3eb03f3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401010cdda0Smrg exit $stat 402010cdda0Smrg fi 403010cdda0Smrg 404b3eb03f3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 405b3eb03f3Smrg do 406b3eb03f3Smrg test -f "$tmpdepfile" && break 407b3eb03f3Smrg done 408010cdda0Smrg if test -f "$tmpdepfile"; then 409010cdda0Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410010cdda0Smrg # That's a tab and a space in the []. 411010cdda0Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412010cdda0Smrg else 413010cdda0Smrg echo "#dummy" > "$depfile" 414010cdda0Smrg fi 415010cdda0Smrg rm -f "$tmpdepfile" 416010cdda0Smrg ;; 417010cdda0Smrg 418b4485a66Smrgmsvc7) 419b4485a66Smrg if test "$libtool" = yes; then 420b4485a66Smrg showIncludes=-Wc,-showIncludes 421b4485a66Smrg else 422b4485a66Smrg showIncludes=-showIncludes 423b4485a66Smrg fi 424b4485a66Smrg "$@" $showIncludes > "$tmpdepfile" 425b4485a66Smrg stat=$? 426b4485a66Smrg grep -v '^Note: including file: ' "$tmpdepfile" 427b4485a66Smrg if test "$stat" = 0; then : 428b4485a66Smrg else 429b4485a66Smrg rm -f "$tmpdepfile" 430b4485a66Smrg exit $stat 431b4485a66Smrg fi 432b4485a66Smrg rm -f "$depfile" 433b4485a66Smrg echo "$object : \\" > "$depfile" 434b4485a66Smrg # The first sed program below extracts the file names and escapes 435b4485a66Smrg # backslashes for cygpath. The second sed program outputs the file 436b4485a66Smrg # name when reading, but also accumulates all include files in the 437b4485a66Smrg # hold buffer in order to output them again at the end. This only 438b4485a66Smrg # works with sed implementations that can handle large buffers. 439b4485a66Smrg sed < "$tmpdepfile" -n ' 440b4485a66Smrg/^Note: including file: *\(.*\)/ { 441b4485a66Smrg s//\1/ 442b4485a66Smrg s/\\/\\\\/g 443b4485a66Smrg p 444b4485a66Smrg}' | $cygpath_u | sort -u | sed -n ' 445b4485a66Smrgs/ /\\ /g 446b4485a66Smrgs/\(.*\)/ \1 \\/p 447b4485a66Smrgs/.\(.*\) \\/\1:/ 448b4485a66SmrgH 449b4485a66Smrg$ { 450b4485a66Smrg s/.*/ / 451b4485a66Smrg G 452b4485a66Smrg p 453b4485a66Smrg}' >> "$depfile" 454b4485a66Smrg rm -f "$tmpdepfile" 455b4485a66Smrg ;; 456b4485a66Smrg 457b4485a66Smrgmsvc7msys) 458b4485a66Smrg # This case exists only to let depend.m4 do its work. It works by 459b4485a66Smrg # looking at the text of this script. This case will never be run, 460b4485a66Smrg # since it is checked for above. 461b4485a66Smrg exit 1 462b4485a66Smrg ;; 463b4485a66Smrg 464010cdda0Smrg#nosideeffect) 465010cdda0Smrg # This comment above is used by automake to tell side-effect 466010cdda0Smrg # dependency tracking mechanisms from slower ones. 467010cdda0Smrg 468010cdda0Smrgdashmstdout) 469010cdda0Smrg # Important note: in order to support this mode, a compiler *must* 470010cdda0Smrg # always write the preprocessed file to stdout, regardless of -o. 471010cdda0Smrg "$@" || exit $? 472010cdda0Smrg 473010cdda0Smrg # Remove the call to Libtool. 474010cdda0Smrg if test "$libtool" = yes; then 475b3eb03f3Smrg while test "X$1" != 'X--mode=compile'; do 476010cdda0Smrg shift 477010cdda0Smrg done 478010cdda0Smrg shift 479010cdda0Smrg fi 480010cdda0Smrg 481010cdda0Smrg # Remove `-o $object'. 482010cdda0Smrg IFS=" " 483010cdda0Smrg for arg 484010cdda0Smrg do 485010cdda0Smrg case $arg in 486010cdda0Smrg -o) 487010cdda0Smrg shift 488010cdda0Smrg ;; 489010cdda0Smrg $object) 490010cdda0Smrg shift 491010cdda0Smrg ;; 492010cdda0Smrg *) 493010cdda0Smrg set fnord "$@" "$arg" 494010cdda0Smrg shift # fnord 495010cdda0Smrg shift # $arg 496010cdda0Smrg ;; 497010cdda0Smrg esac 498010cdda0Smrg done 499010cdda0Smrg 500010cdda0Smrg test -z "$dashmflag" && dashmflag=-M 501010cdda0Smrg # Require at least two characters before searching for `:' 502010cdda0Smrg # in the target name. This is to cope with DOS-style filenames: 503010cdda0Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504010cdda0Smrg "$@" $dashmflag | 505010cdda0Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506010cdda0Smrg rm -f "$depfile" 507010cdda0Smrg cat < "$tmpdepfile" > "$depfile" 508010cdda0Smrg tr ' ' ' 509010cdda0Smrg' < "$tmpdepfile" | \ 510010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 511010cdda0Smrg## correctly. Breaking it into two sed invocations is a workaround. 512010cdda0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513010cdda0Smrg rm -f "$tmpdepfile" 514010cdda0Smrg ;; 515010cdda0Smrg 516010cdda0SmrgdashXmstdout) 517010cdda0Smrg # This case only exists to satisfy depend.m4. It is never actually 518010cdda0Smrg # run, as this mode is specially recognized in the preamble. 519010cdda0Smrg exit 1 520010cdda0Smrg ;; 521010cdda0Smrg 522010cdda0Smrgmakedepend) 523010cdda0Smrg "$@" || exit $? 524010cdda0Smrg # Remove any Libtool call 525010cdda0Smrg if test "$libtool" = yes; then 526b3eb03f3Smrg while test "X$1" != 'X--mode=compile'; do 527010cdda0Smrg shift 528010cdda0Smrg done 529010cdda0Smrg shift 530010cdda0Smrg fi 531010cdda0Smrg # X makedepend 532010cdda0Smrg shift 533b3eb03f3Smrg cleared=no eat=no 534b3eb03f3Smrg for arg 535b3eb03f3Smrg do 536010cdda0Smrg case $cleared in 537010cdda0Smrg no) 538010cdda0Smrg set ""; shift 539010cdda0Smrg cleared=yes ;; 540010cdda0Smrg esac 541b3eb03f3Smrg if test $eat = yes; then 542b3eb03f3Smrg eat=no 543b3eb03f3Smrg continue 544b3eb03f3Smrg fi 545010cdda0Smrg case "$arg" in 546010cdda0Smrg -D*|-I*) 547010cdda0Smrg set fnord "$@" "$arg"; shift ;; 548010cdda0Smrg # Strip any option that makedepend may not understand. Remove 549010cdda0Smrg # the object too, otherwise makedepend will parse it as a source file. 550b3eb03f3Smrg -arch) 551b3eb03f3Smrg eat=yes ;; 552010cdda0Smrg -*|$object) 553010cdda0Smrg ;; 554010cdda0Smrg *) 555010cdda0Smrg set fnord "$@" "$arg"; shift ;; 556010cdda0Smrg esac 557010cdda0Smrg done 558b3eb03f3Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559010cdda0Smrg touch "$tmpdepfile" 560010cdda0Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561010cdda0Smrg rm -f "$depfile" 562b4485a66Smrg # makedepend may prepend the VPATH from the source file name to the object. 563b4485a66Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 564b4485a66Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565010cdda0Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566010cdda0Smrg' | \ 567010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 568010cdda0Smrg## correctly. Breaking it into two sed invocations is a workaround. 569010cdda0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570010cdda0Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571010cdda0Smrg ;; 572010cdda0Smrg 573010cdda0Smrgcpp) 574010cdda0Smrg # Important note: in order to support this mode, a compiler *must* 575010cdda0Smrg # always write the preprocessed file to stdout. 576010cdda0Smrg "$@" || exit $? 577010cdda0Smrg 578010cdda0Smrg # Remove the call to Libtool. 579010cdda0Smrg if test "$libtool" = yes; then 580b3eb03f3Smrg while test "X$1" != 'X--mode=compile'; do 581010cdda0Smrg shift 582010cdda0Smrg done 583010cdda0Smrg shift 584010cdda0Smrg fi 585010cdda0Smrg 586010cdda0Smrg # Remove `-o $object'. 587010cdda0Smrg IFS=" " 588010cdda0Smrg for arg 589010cdda0Smrg do 590010cdda0Smrg case $arg in 591010cdda0Smrg -o) 592010cdda0Smrg shift 593010cdda0Smrg ;; 594010cdda0Smrg $object) 595010cdda0Smrg shift 596010cdda0Smrg ;; 597010cdda0Smrg *) 598010cdda0Smrg set fnord "$@" "$arg" 599010cdda0Smrg shift # fnord 600010cdda0Smrg shift # $arg 601010cdda0Smrg ;; 602010cdda0Smrg esac 603010cdda0Smrg done 604010cdda0Smrg 605010cdda0Smrg "$@" -E | 606b3eb03f3Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 607b3eb03f3Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608010cdda0Smrg sed '$ s: \\$::' > "$tmpdepfile" 609010cdda0Smrg rm -f "$depfile" 610010cdda0Smrg echo "$object : \\" > "$depfile" 611010cdda0Smrg cat < "$tmpdepfile" >> "$depfile" 612010cdda0Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613010cdda0Smrg rm -f "$tmpdepfile" 614010cdda0Smrg ;; 615010cdda0Smrg 616010cdda0Smrgmsvisualcpp) 617010cdda0Smrg # Important note: in order to support this mode, a compiler *must* 618b3eb03f3Smrg # always write the preprocessed file to stdout. 619010cdda0Smrg "$@" || exit $? 620b3eb03f3Smrg 621b3eb03f3Smrg # Remove the call to Libtool. 622b3eb03f3Smrg if test "$libtool" = yes; then 623b3eb03f3Smrg while test "X$1" != 'X--mode=compile'; do 624b3eb03f3Smrg shift 625b3eb03f3Smrg done 626b3eb03f3Smrg shift 627b3eb03f3Smrg fi 628b3eb03f3Smrg 629010cdda0Smrg IFS=" " 630010cdda0Smrg for arg 631010cdda0Smrg do 632010cdda0Smrg case "$arg" in 633b3eb03f3Smrg -o) 634b3eb03f3Smrg shift 635b3eb03f3Smrg ;; 636b3eb03f3Smrg $object) 637b3eb03f3Smrg shift 638b3eb03f3Smrg ;; 639010cdda0Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640010cdda0Smrg set fnord "$@" 641010cdda0Smrg shift 642010cdda0Smrg shift 643010cdda0Smrg ;; 644010cdda0Smrg *) 645010cdda0Smrg set fnord "$@" "$arg" 646010cdda0Smrg shift 647010cdda0Smrg shift 648010cdda0Smrg ;; 649010cdda0Smrg esac 650010cdda0Smrg done 651b3eb03f3Smrg "$@" -E 2>/dev/null | 652b3eb03f3Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653010cdda0Smrg rm -f "$depfile" 654010cdda0Smrg echo "$object : \\" > "$depfile" 655b3eb03f3Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656010cdda0Smrg echo " " >> "$depfile" 657b3eb03f3Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658010cdda0Smrg rm -f "$tmpdepfile" 659010cdda0Smrg ;; 660010cdda0Smrg 661b3eb03f3Smrgmsvcmsys) 662b3eb03f3Smrg # This case exists only to let depend.m4 do its work. It works by 663b3eb03f3Smrg # looking at the text of this script. This case will never be run, 664b3eb03f3Smrg # since it is checked for above. 665b3eb03f3Smrg exit 1 666b3eb03f3Smrg ;; 667b3eb03f3Smrg 668010cdda0Smrgnone) 669010cdda0Smrg exec "$@" 670010cdda0Smrg ;; 671010cdda0Smrg 672010cdda0Smrg*) 673010cdda0Smrg echo "Unknown depmode $depmode" 1>&2 674010cdda0Smrg exit 1 675010cdda0Smrg ;; 676010cdda0Smrgesac 677010cdda0Smrg 678010cdda0Smrgexit 0 679b3eb03f3Smrg 680b3eb03f3Smrg# Local Variables: 681b3eb03f3Smrg# mode: shell-script 682b3eb03f3Smrg# sh-indentation: 2 683b3eb03f3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 684b3eb03f3Smrg# time-stamp-start: "scriptversion=" 685b3eb03f3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 686b3eb03f3Smrg# time-stamp-time-zone: "UTC" 687b3eb03f3Smrg# time-stamp-end: "; # UTC" 688b3eb03f3Smrg# End: 689