depcomp revision b62cc08c
19fe995a9Smrg#! /bin/sh 29fe995a9Smrg# depcomp - compile a program generating dependencies as side-effects 39fe995a9Smrg 4b62cc08cSmrgscriptversion=2009-04-28.21; # UTC 59fe995a9Smrg 6b62cc08cSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7b62cc08cSmrg# Software Foundation, Inc. 89fe995a9Smrg 99fe995a9Smrg# This program is free software; you can redistribute it and/or modify 109fe995a9Smrg# it under the terms of the GNU General Public License as published by 119fe995a9Smrg# the Free Software Foundation; either version 2, or (at your option) 129fe995a9Smrg# any later version. 139fe995a9Smrg 149fe995a9Smrg# This program is distributed in the hope that it will be useful, 159fe995a9Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 169fe995a9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 179fe995a9Smrg# GNU General Public License for more details. 189fe995a9Smrg 199fe995a9Smrg# You should have received a copy of the GNU General Public License 20b62cc08cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 219fe995a9Smrg 229fe995a9Smrg# As a special exception to the GNU General Public License, if you 239fe995a9Smrg# distribute this file as part of a program that contains a 249fe995a9Smrg# configuration script generated by Autoconf, you may include it under 259fe995a9Smrg# the same distribution terms that you use for the rest of that program. 269fe995a9Smrg 279fe995a9Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 289fe995a9Smrg 299fe995a9Smrgcase $1 in 309fe995a9Smrg '') 319fe995a9Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 329fe995a9Smrg exit 1; 339fe995a9Smrg ;; 349fe995a9Smrg -h | --h*) 359fe995a9Smrg cat <<\EOF 369fe995a9SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 379fe995a9Smrg 389fe995a9SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 399fe995a9Smrgas side-effects. 409fe995a9Smrg 419fe995a9SmrgEnvironment variables: 429fe995a9Smrg depmode Dependency tracking mode. 439fe995a9Smrg source Source file read by `PROGRAMS ARGS'. 449fe995a9Smrg object Object file output by `PROGRAMS ARGS'. 459fe995a9Smrg DEPDIR directory where to store dependencies. 469fe995a9Smrg depfile Dependency file to output. 479fe995a9Smrg tmpdepfile Temporary file to use when outputing dependencies. 489fe995a9Smrg libtool Whether libtool is used (yes/no). 499fe995a9Smrg 509fe995a9SmrgReport bugs to <bug-automake@gnu.org>. 519fe995a9SmrgEOF 529fe995a9Smrg exit $? 539fe995a9Smrg ;; 549fe995a9Smrg -v | --v*) 559fe995a9Smrg echo "depcomp $scriptversion" 569fe995a9Smrg exit $? 579fe995a9Smrg ;; 589fe995a9Smrgesac 599fe995a9Smrg 609fe995a9Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 619fe995a9Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 629fe995a9Smrg exit 1 639fe995a9Smrgfi 649fe995a9Smrg 659fe995a9Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 669fe995a9Smrgdepfile=${depfile-`echo "$object" | 679fe995a9Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 689fe995a9Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 699fe995a9Smrg 709fe995a9Smrgrm -f "$tmpdepfile" 719fe995a9Smrg 729fe995a9Smrg# Some modes work just like other modes, but use different flags. We 739fe995a9Smrg# parameterize here, but still list the modes in the big case below, 749fe995a9Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 759fe995a9Smrg# here, because this file can only contain one case statement. 769fe995a9Smrgif test "$depmode" = hp; then 779fe995a9Smrg # HP compiler uses -M and no extra arg. 789fe995a9Smrg gccflag=-M 799fe995a9Smrg depmode=gcc 809fe995a9Smrgfi 819fe995a9Smrg 829fe995a9Smrgif test "$depmode" = dashXmstdout; then 839fe995a9Smrg # This is just like dashmstdout with a different argument. 849fe995a9Smrg dashmflag=-xM 859fe995a9Smrg depmode=dashmstdout 869fe995a9Smrgfi 879fe995a9Smrg 88b62cc08cSmrgcygpath_u="cygpath -u -f -" 89b62cc08cSmrgif test "$depmode" = msvcmsys; then 90b62cc08cSmrg # This is just like msvisualcpp but w/o cygpath translation. 91b62cc08cSmrg # Just convert the backslash-escaped backslashes to single forward 92b62cc08cSmrg # slashes to satisfy depend.m4 93b62cc08cSmrg cygpath_u="sed s,\\\\\\\\,/,g" 94b62cc08cSmrg depmode=msvisualcpp 95b62cc08cSmrgfi 96b62cc08cSmrg 979fe995a9Smrgcase "$depmode" in 989fe995a9Smrggcc3) 999fe995a9Smrg## gcc 3 implements dependency tracking that does exactly what 1009fe995a9Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1019fe995a9Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1029fe995a9Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1039fe995a9Smrg## the command line argument order; so add the flags where they 1049fe995a9Smrg## appear in depend2.am. Note that the slowdown incurred here 1059fe995a9Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1069fe995a9Smrg for arg 1079fe995a9Smrg do 1089fe995a9Smrg case $arg in 1099fe995a9Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1109fe995a9Smrg *) set fnord "$@" "$arg" ;; 1119fe995a9Smrg esac 1129fe995a9Smrg shift # fnord 1139fe995a9Smrg shift # $arg 1149fe995a9Smrg done 1159fe995a9Smrg "$@" 1169fe995a9Smrg stat=$? 1179fe995a9Smrg if test $stat -eq 0; then : 1189fe995a9Smrg else 1199fe995a9Smrg rm -f "$tmpdepfile" 1209fe995a9Smrg exit $stat 1219fe995a9Smrg fi 1229fe995a9Smrg mv "$tmpdepfile" "$depfile" 1239fe995a9Smrg ;; 1249fe995a9Smrg 1259fe995a9Smrggcc) 1269fe995a9Smrg## There are various ways to get dependency output from gcc. Here's 1279fe995a9Smrg## why we pick this rather obscure method: 1289fe995a9Smrg## - Don't want to use -MD because we'd like the dependencies to end 1299fe995a9Smrg## up in a subdir. Having to rename by hand is ugly. 1309fe995a9Smrg## (We might end up doing this anyway to support other compilers.) 1319fe995a9Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1329fe995a9Smrg## -MM, not -M (despite what the docs say). 1339fe995a9Smrg## - Using -M directly means running the compiler twice (even worse 1349fe995a9Smrg## than renaming). 1359fe995a9Smrg if test -z "$gccflag"; then 1369fe995a9Smrg gccflag=-MD, 1379fe995a9Smrg fi 1389fe995a9Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1399fe995a9Smrg stat=$? 1409fe995a9Smrg if test $stat -eq 0; then : 1419fe995a9Smrg else 1429fe995a9Smrg rm -f "$tmpdepfile" 1439fe995a9Smrg exit $stat 1449fe995a9Smrg fi 1459fe995a9Smrg rm -f "$depfile" 1469fe995a9Smrg echo "$object : \\" > "$depfile" 1479fe995a9Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1489fe995a9Smrg## The second -e expression handles DOS-style file names with drive letters. 1499fe995a9Smrg sed -e 's/^[^:]*: / /' \ 1509fe995a9Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1519fe995a9Smrg## This next piece of magic avoids the `deleted header file' problem. 1529fe995a9Smrg## The problem is that when a header file which appears in a .P file 1539fe995a9Smrg## is deleted, the dependency causes make to die (because there is 1549fe995a9Smrg## typically no way to rebuild the header). We avoid this by adding 1559fe995a9Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1569fe995a9Smrg## this for us directly. 1579fe995a9Smrg tr ' ' ' 1589fe995a9Smrg' < "$tmpdepfile" | 1599fe995a9Smrg## Some versions of gcc put a space before the `:'. On the theory 1609fe995a9Smrg## that the space means something, we add a space to the output as 1619fe995a9Smrg## well. 1629fe995a9Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1639fe995a9Smrg## correctly. Breaking it into two sed invocations is a workaround. 1649fe995a9Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1659fe995a9Smrg rm -f "$tmpdepfile" 1669fe995a9Smrg ;; 1679fe995a9Smrg 1689fe995a9Smrghp) 1699fe995a9Smrg # This case exists only to let depend.m4 do its work. It works by 1709fe995a9Smrg # looking at the text of this script. This case will never be run, 1719fe995a9Smrg # since it is checked for above. 1729fe995a9Smrg exit 1 1739fe995a9Smrg ;; 1749fe995a9Smrg 1759fe995a9Smrgsgi) 1769fe995a9Smrg if test "$libtool" = yes; then 1779fe995a9Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1789fe995a9Smrg else 1799fe995a9Smrg "$@" -MDupdate "$tmpdepfile" 1809fe995a9Smrg fi 1819fe995a9Smrg stat=$? 1829fe995a9Smrg if test $stat -eq 0; then : 1839fe995a9Smrg else 1849fe995a9Smrg rm -f "$tmpdepfile" 1859fe995a9Smrg exit $stat 1869fe995a9Smrg fi 1879fe995a9Smrg rm -f "$depfile" 1889fe995a9Smrg 1899fe995a9Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1909fe995a9Smrg echo "$object : \\" > "$depfile" 1919fe995a9Smrg 1929fe995a9Smrg # Clip off the initial element (the dependent). Don't try to be 1939fe995a9Smrg # clever and replace this with sed code, as IRIX sed won't handle 1949fe995a9Smrg # lines with more than a fixed number of characters (4096 in 1959fe995a9Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1969fe995a9Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1979fe995a9Smrg # dependency line. 1989fe995a9Smrg tr ' ' ' 1999fe995a9Smrg' < "$tmpdepfile" \ 2009fe995a9Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 2019fe995a9Smrg tr ' 202b62cc08cSmrg' ' ' >> "$depfile" 203b62cc08cSmrg echo >> "$depfile" 2049fe995a9Smrg 2059fe995a9Smrg # The second pass generates a dummy entry for each header file. 2069fe995a9Smrg tr ' ' ' 2079fe995a9Smrg' < "$tmpdepfile" \ 2089fe995a9Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209b62cc08cSmrg >> "$depfile" 2109fe995a9Smrg else 2119fe995a9Smrg # The sourcefile does not contain any dependencies, so just 2129fe995a9Smrg # store a dummy comment line, to avoid errors with the Makefile 2139fe995a9Smrg # "include basename.Plo" scheme. 2149fe995a9Smrg echo "#dummy" > "$depfile" 2159fe995a9Smrg fi 2169fe995a9Smrg rm -f "$tmpdepfile" 2179fe995a9Smrg ;; 2189fe995a9Smrg 2199fe995a9Smrgaix) 2209fe995a9Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2219fe995a9Smrg # in a .u file. In older versions, this file always lives in the 2229fe995a9Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2239fe995a9Smrg # start of each line; $object doesn't have directory information. 2249fe995a9Smrg # Version 6 uses the directory in both cases. 225b62cc08cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226b62cc08cSmrg test "x$dir" = "x$object" && dir= 227b62cc08cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2289fe995a9Smrg if test "$libtool" = yes; then 229b62cc08cSmrg tmpdepfile1=$dir$base.u 230b62cc08cSmrg tmpdepfile2=$base.u 231b62cc08cSmrg tmpdepfile3=$dir.libs/$base.u 2329fe995a9Smrg "$@" -Wc,-M 2339fe995a9Smrg else 234b62cc08cSmrg tmpdepfile1=$dir$base.u 235b62cc08cSmrg tmpdepfile2=$dir$base.u 236b62cc08cSmrg tmpdepfile3=$dir$base.u 2379fe995a9Smrg "$@" -M 2389fe995a9Smrg fi 2399fe995a9Smrg stat=$? 2409fe995a9Smrg 2419fe995a9Smrg if test $stat -eq 0; then : 2429fe995a9Smrg else 243b62cc08cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2449fe995a9Smrg exit $stat 2459fe995a9Smrg fi 2469fe995a9Smrg 247b62cc08cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248b62cc08cSmrg do 249b62cc08cSmrg test -f "$tmpdepfile" && break 250b62cc08cSmrg done 2519fe995a9Smrg if test -f "$tmpdepfile"; then 2529fe995a9Smrg # Each line is of the form `foo.o: dependent.h'. 2539fe995a9Smrg # Do two passes, one to just change these to 2549fe995a9Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 255b62cc08cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256b62cc08cSmrg # That's a tab and a space in the []. 257b62cc08cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2589fe995a9Smrg else 2599fe995a9Smrg # The sourcefile does not contain any dependencies, so just 2609fe995a9Smrg # store a dummy comment line, to avoid errors with the Makefile 2619fe995a9Smrg # "include basename.Plo" scheme. 2629fe995a9Smrg echo "#dummy" > "$depfile" 2639fe995a9Smrg fi 2649fe995a9Smrg rm -f "$tmpdepfile" 2659fe995a9Smrg ;; 2669fe995a9Smrg 2679fe995a9Smrgicc) 2689fe995a9Smrg # Intel's C compiler understands `-MD -MF file'. However on 2699fe995a9Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2709fe995a9Smrg # ICC 7.0 will fill foo.d with something like 2719fe995a9Smrg # foo.o: sub/foo.c 2729fe995a9Smrg # foo.o: sub/foo.h 2739fe995a9Smrg # which is wrong. We want: 2749fe995a9Smrg # sub/foo.o: sub/foo.c 2759fe995a9Smrg # sub/foo.o: sub/foo.h 2769fe995a9Smrg # sub/foo.c: 2779fe995a9Smrg # sub/foo.h: 2789fe995a9Smrg # ICC 7.1 will output 2799fe995a9Smrg # foo.o: sub/foo.c sub/foo.h 2809fe995a9Smrg # and will wrap long lines using \ : 2819fe995a9Smrg # foo.o: sub/foo.c ... \ 2829fe995a9Smrg # sub/foo.h ... \ 2839fe995a9Smrg # ... 2849fe995a9Smrg 2859fe995a9Smrg "$@" -MD -MF "$tmpdepfile" 2869fe995a9Smrg stat=$? 2879fe995a9Smrg if test $stat -eq 0; then : 2889fe995a9Smrg else 2899fe995a9Smrg rm -f "$tmpdepfile" 2909fe995a9Smrg exit $stat 2919fe995a9Smrg fi 2929fe995a9Smrg rm -f "$depfile" 2939fe995a9Smrg # Each line is of the form `foo.o: dependent.h', 2949fe995a9Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2959fe995a9Smrg # Do two passes, one to just change these to 2969fe995a9Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2979fe995a9Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2989fe995a9Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2999fe995a9Smrg # correctly. Breaking it into two sed invocations is a workaround. 3009fe995a9Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 3019fe995a9Smrg sed -e 's/$/ :/' >> "$depfile" 3029fe995a9Smrg rm -f "$tmpdepfile" 3039fe995a9Smrg ;; 3049fe995a9Smrg 3059fe995a9Smrghp2) 3069fe995a9Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3079fe995a9Smrg # compilers, which have integrated preprocessors. The correct option 3089fe995a9Smrg # to use with these is +Maked; it writes dependencies to a file named 3099fe995a9Smrg # 'foo.d', which lands next to the object file, wherever that 3109fe995a9Smrg # happens to be. 3119fe995a9Smrg # Much of this is similar to the tru64 case; see comments there. 3129fe995a9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3139fe995a9Smrg test "x$dir" = "x$object" && dir= 3149fe995a9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3159fe995a9Smrg if test "$libtool" = yes; then 3169fe995a9Smrg tmpdepfile1=$dir$base.d 3179fe995a9Smrg tmpdepfile2=$dir.libs/$base.d 3189fe995a9Smrg "$@" -Wc,+Maked 3199fe995a9Smrg else 3209fe995a9Smrg tmpdepfile1=$dir$base.d 3219fe995a9Smrg tmpdepfile2=$dir$base.d 3229fe995a9Smrg "$@" +Maked 3239fe995a9Smrg fi 3249fe995a9Smrg stat=$? 3259fe995a9Smrg if test $stat -eq 0; then : 3269fe995a9Smrg else 3279fe995a9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3289fe995a9Smrg exit $stat 3299fe995a9Smrg fi 3309fe995a9Smrg 3319fe995a9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3329fe995a9Smrg do 3339fe995a9Smrg test -f "$tmpdepfile" && break 3349fe995a9Smrg done 3359fe995a9Smrg if test -f "$tmpdepfile"; then 3369fe995a9Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3379fe995a9Smrg # Add `dependent.h:' lines. 338b62cc08cSmrg sed -ne '2,${ 339b62cc08cSmrg s/^ *// 340b62cc08cSmrg s/ \\*$// 341b62cc08cSmrg s/$/:/ 342b62cc08cSmrg p 343b62cc08cSmrg }' "$tmpdepfile" >> "$depfile" 3449fe995a9Smrg else 3459fe995a9Smrg echo "#dummy" > "$depfile" 3469fe995a9Smrg fi 3479fe995a9Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3489fe995a9Smrg ;; 3499fe995a9Smrg 3509fe995a9Smrgtru64) 3519fe995a9Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3529fe995a9Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3539fe995a9Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3549fe995a9Smrg # dependencies in `foo.d' instead, so we check for that too. 3559fe995a9Smrg # Subdirectories are respected. 3569fe995a9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3579fe995a9Smrg test "x$dir" = "x$object" && dir= 3589fe995a9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3599fe995a9Smrg 3609fe995a9Smrg if test "$libtool" = yes; then 3619fe995a9Smrg # With Tru64 cc, shared objects can also be used to make a 3629fe995a9Smrg # static library. This mechanism is used in libtool 1.4 series to 3639fe995a9Smrg # handle both shared and static libraries in a single compilation. 3649fe995a9Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3659fe995a9Smrg # 3669fe995a9Smrg # With libtool 1.5 this exception was removed, and libtool now 3679fe995a9Smrg # generates 2 separate objects for the 2 libraries. These two 3689fe995a9Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3699fe995a9Smrg # in $dir$base.o.d. We have to check for both files, because 3709fe995a9Smrg # one of the two compilations can be disabled. We should prefer 3719fe995a9Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3729fe995a9Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3739fe995a9Smrg # the former would cause a distcleancheck panic. 3749fe995a9Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3759fe995a9Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3769fe995a9Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3779fe995a9Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3789fe995a9Smrg "$@" -Wc,-MD 3799fe995a9Smrg else 3809fe995a9Smrg tmpdepfile1=$dir$base.o.d 3819fe995a9Smrg tmpdepfile2=$dir$base.d 3829fe995a9Smrg tmpdepfile3=$dir$base.d 3839fe995a9Smrg tmpdepfile4=$dir$base.d 3849fe995a9Smrg "$@" -MD 3859fe995a9Smrg fi 3869fe995a9Smrg 3879fe995a9Smrg stat=$? 3889fe995a9Smrg if test $stat -eq 0; then : 3899fe995a9Smrg else 3909fe995a9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3919fe995a9Smrg exit $stat 3929fe995a9Smrg fi 3939fe995a9Smrg 3949fe995a9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3959fe995a9Smrg do 3969fe995a9Smrg test -f "$tmpdepfile" && break 3979fe995a9Smrg done 3989fe995a9Smrg if test -f "$tmpdepfile"; then 3999fe995a9Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 4009fe995a9Smrg # That's a tab and a space in the []. 4019fe995a9Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 4029fe995a9Smrg else 4039fe995a9Smrg echo "#dummy" > "$depfile" 4049fe995a9Smrg fi 4059fe995a9Smrg rm -f "$tmpdepfile" 4069fe995a9Smrg ;; 4079fe995a9Smrg 4089fe995a9Smrg#nosideeffect) 4099fe995a9Smrg # This comment above is used by automake to tell side-effect 4109fe995a9Smrg # dependency tracking mechanisms from slower ones. 4119fe995a9Smrg 4129fe995a9Smrgdashmstdout) 4139fe995a9Smrg # Important note: in order to support this mode, a compiler *must* 4149fe995a9Smrg # always write the preprocessed file to stdout, regardless of -o. 4159fe995a9Smrg "$@" || exit $? 4169fe995a9Smrg 4179fe995a9Smrg # Remove the call to Libtool. 4189fe995a9Smrg if test "$libtool" = yes; then 419b62cc08cSmrg while test "X$1" != 'X--mode=compile'; do 4209fe995a9Smrg shift 4219fe995a9Smrg done 4229fe995a9Smrg shift 4239fe995a9Smrg fi 4249fe995a9Smrg 4259fe995a9Smrg # Remove `-o $object'. 4269fe995a9Smrg IFS=" " 4279fe995a9Smrg for arg 4289fe995a9Smrg do 4299fe995a9Smrg case $arg in 4309fe995a9Smrg -o) 4319fe995a9Smrg shift 4329fe995a9Smrg ;; 4339fe995a9Smrg $object) 4349fe995a9Smrg shift 4359fe995a9Smrg ;; 4369fe995a9Smrg *) 4379fe995a9Smrg set fnord "$@" "$arg" 4389fe995a9Smrg shift # fnord 4399fe995a9Smrg shift # $arg 4409fe995a9Smrg ;; 4419fe995a9Smrg esac 4429fe995a9Smrg done 4439fe995a9Smrg 4449fe995a9Smrg test -z "$dashmflag" && dashmflag=-M 4459fe995a9Smrg # Require at least two characters before searching for `:' 4469fe995a9Smrg # in the target name. This is to cope with DOS-style filenames: 4479fe995a9Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4489fe995a9Smrg "$@" $dashmflag | 4499fe995a9Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4509fe995a9Smrg rm -f "$depfile" 4519fe995a9Smrg cat < "$tmpdepfile" > "$depfile" 4529fe995a9Smrg tr ' ' ' 4539fe995a9Smrg' < "$tmpdepfile" | \ 4549fe995a9Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4559fe995a9Smrg## correctly. Breaking it into two sed invocations is a workaround. 4569fe995a9Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4579fe995a9Smrg rm -f "$tmpdepfile" 4589fe995a9Smrg ;; 4599fe995a9Smrg 4609fe995a9SmrgdashXmstdout) 4619fe995a9Smrg # This case only exists to satisfy depend.m4. It is never actually 4629fe995a9Smrg # run, as this mode is specially recognized in the preamble. 4639fe995a9Smrg exit 1 4649fe995a9Smrg ;; 4659fe995a9Smrg 4669fe995a9Smrgmakedepend) 4679fe995a9Smrg "$@" || exit $? 4689fe995a9Smrg # Remove any Libtool call 4699fe995a9Smrg if test "$libtool" = yes; then 470b62cc08cSmrg while test "X$1" != 'X--mode=compile'; do 4719fe995a9Smrg shift 4729fe995a9Smrg done 4739fe995a9Smrg shift 4749fe995a9Smrg fi 4759fe995a9Smrg # X makedepend 4769fe995a9Smrg shift 477b62cc08cSmrg cleared=no eat=no 478b62cc08cSmrg for arg 479b62cc08cSmrg do 4809fe995a9Smrg case $cleared in 4819fe995a9Smrg no) 4829fe995a9Smrg set ""; shift 4839fe995a9Smrg cleared=yes ;; 4849fe995a9Smrg esac 485b62cc08cSmrg if test $eat = yes; then 486b62cc08cSmrg eat=no 487b62cc08cSmrg continue 488b62cc08cSmrg fi 4899fe995a9Smrg case "$arg" in 4909fe995a9Smrg -D*|-I*) 4919fe995a9Smrg set fnord "$@" "$arg"; shift ;; 4929fe995a9Smrg # Strip any option that makedepend may not understand. Remove 4939fe995a9Smrg # the object too, otherwise makedepend will parse it as a source file. 494b62cc08cSmrg -arch) 495b62cc08cSmrg eat=yes ;; 4969fe995a9Smrg -*|$object) 4979fe995a9Smrg ;; 4989fe995a9Smrg *) 4999fe995a9Smrg set fnord "$@" "$arg"; shift ;; 5009fe995a9Smrg esac 5019fe995a9Smrg done 502b62cc08cSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 5039fe995a9Smrg touch "$tmpdepfile" 5049fe995a9Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 5059fe995a9Smrg rm -f "$depfile" 5069fe995a9Smrg cat < "$tmpdepfile" > "$depfile" 5079fe995a9Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 5089fe995a9Smrg' | \ 5099fe995a9Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 5109fe995a9Smrg## correctly. Breaking it into two sed invocations is a workaround. 5119fe995a9Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 5129fe995a9Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 5139fe995a9Smrg ;; 5149fe995a9Smrg 5159fe995a9Smrgcpp) 5169fe995a9Smrg # Important note: in order to support this mode, a compiler *must* 5179fe995a9Smrg # always write the preprocessed file to stdout. 5189fe995a9Smrg "$@" || exit $? 5199fe995a9Smrg 5209fe995a9Smrg # Remove the call to Libtool. 5219fe995a9Smrg if test "$libtool" = yes; then 522b62cc08cSmrg while test "X$1" != 'X--mode=compile'; do 5239fe995a9Smrg shift 5249fe995a9Smrg done 5259fe995a9Smrg shift 5269fe995a9Smrg fi 5279fe995a9Smrg 5289fe995a9Smrg # Remove `-o $object'. 5299fe995a9Smrg IFS=" " 5309fe995a9Smrg for arg 5319fe995a9Smrg do 5329fe995a9Smrg case $arg in 5339fe995a9Smrg -o) 5349fe995a9Smrg shift 5359fe995a9Smrg ;; 5369fe995a9Smrg $object) 5379fe995a9Smrg shift 5389fe995a9Smrg ;; 5399fe995a9Smrg *) 5409fe995a9Smrg set fnord "$@" "$arg" 5419fe995a9Smrg shift # fnord 5429fe995a9Smrg shift # $arg 5439fe995a9Smrg ;; 5449fe995a9Smrg esac 5459fe995a9Smrg done 5469fe995a9Smrg 5479fe995a9Smrg "$@" -E | 5489fe995a9Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5499fe995a9Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5509fe995a9Smrg sed '$ s: \\$::' > "$tmpdepfile" 5519fe995a9Smrg rm -f "$depfile" 5529fe995a9Smrg echo "$object : \\" > "$depfile" 5539fe995a9Smrg cat < "$tmpdepfile" >> "$depfile" 5549fe995a9Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5559fe995a9Smrg rm -f "$tmpdepfile" 5569fe995a9Smrg ;; 5579fe995a9Smrg 5589fe995a9Smrgmsvisualcpp) 5599fe995a9Smrg # Important note: in order to support this mode, a compiler *must* 560b62cc08cSmrg # always write the preprocessed file to stdout. 5619fe995a9Smrg "$@" || exit $? 562b62cc08cSmrg 563b62cc08cSmrg # Remove the call to Libtool. 564b62cc08cSmrg if test "$libtool" = yes; then 565b62cc08cSmrg while test "X$1" != 'X--mode=compile'; do 566b62cc08cSmrg shift 567b62cc08cSmrg done 568b62cc08cSmrg shift 569b62cc08cSmrg fi 570b62cc08cSmrg 5719fe995a9Smrg IFS=" " 5729fe995a9Smrg for arg 5739fe995a9Smrg do 5749fe995a9Smrg case "$arg" in 575b62cc08cSmrg -o) 576b62cc08cSmrg shift 577b62cc08cSmrg ;; 578b62cc08cSmrg $object) 579b62cc08cSmrg shift 580b62cc08cSmrg ;; 5819fe995a9Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5829fe995a9Smrg set fnord "$@" 5839fe995a9Smrg shift 5849fe995a9Smrg shift 5859fe995a9Smrg ;; 5869fe995a9Smrg *) 5879fe995a9Smrg set fnord "$@" "$arg" 5889fe995a9Smrg shift 5899fe995a9Smrg shift 5909fe995a9Smrg ;; 5919fe995a9Smrg esac 5929fe995a9Smrg done 593b62cc08cSmrg "$@" -E 2>/dev/null | 594b62cc08cSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 5959fe995a9Smrg rm -f "$depfile" 5969fe995a9Smrg echo "$object : \\" > "$depfile" 597b62cc08cSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5989fe995a9Smrg echo " " >> "$depfile" 599b62cc08cSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 6009fe995a9Smrg rm -f "$tmpdepfile" 6019fe995a9Smrg ;; 6029fe995a9Smrg 603b62cc08cSmrgmsvcmsys) 604b62cc08cSmrg # This case exists only to let depend.m4 do its work. It works by 605b62cc08cSmrg # looking at the text of this script. This case will never be run, 606b62cc08cSmrg # since it is checked for above. 607b62cc08cSmrg exit 1 608b62cc08cSmrg ;; 609b62cc08cSmrg 6109fe995a9Smrgnone) 6119fe995a9Smrg exec "$@" 6129fe995a9Smrg ;; 6139fe995a9Smrg 6149fe995a9Smrg*) 6159fe995a9Smrg echo "Unknown depmode $depmode" 1>&2 6169fe995a9Smrg exit 1 6179fe995a9Smrg ;; 6189fe995a9Smrgesac 6199fe995a9Smrg 6209fe995a9Smrgexit 0 6219fe995a9Smrg 6229fe995a9Smrg# Local Variables: 6239fe995a9Smrg# mode: shell-script 6249fe995a9Smrg# sh-indentation: 2 6259fe995a9Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6269fe995a9Smrg# time-stamp-start: "scriptversion=" 6279fe995a9Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628b62cc08cSmrg# time-stamp-time-zone: "UTC" 629b62cc08cSmrg# time-stamp-end: "; # UTC" 6309fe995a9Smrg# End: 631