140dd5a57Smrg#! /bin/sh 240dd5a57Smrg# depcomp - compile a program generating dependencies as side-effects 340dd5a57Smrg 440dd5a57Smrgscriptversion=2009-04-28.21; # UTC 540dd5a57Smrg 640dd5a57Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 740dd5a57Smrg# Software Foundation, Inc. 840dd5a57Smrg 940dd5a57Smrg# This program is free software; you can redistribute it and/or modify 1040dd5a57Smrg# it under the terms of the GNU General Public License as published by 1140dd5a57Smrg# the Free Software Foundation; either version 2, or (at your option) 1240dd5a57Smrg# any later version. 1340dd5a57Smrg 1440dd5a57Smrg# This program is distributed in the hope that it will be useful, 1540dd5a57Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1640dd5a57Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1740dd5a57Smrg# GNU General Public License for more details. 1840dd5a57Smrg 1940dd5a57Smrg# You should have received a copy of the GNU General Public License 2040dd5a57Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2140dd5a57Smrg 2240dd5a57Smrg# As a special exception to the GNU General Public License, if you 2340dd5a57Smrg# distribute this file as part of a program that contains a 2440dd5a57Smrg# configuration script generated by Autoconf, you may include it under 2540dd5a57Smrg# the same distribution terms that you use for the rest of that program. 2640dd5a57Smrg 2740dd5a57Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2840dd5a57Smrg 2940dd5a57Smrgcase $1 in 3040dd5a57Smrg '') 3140dd5a57Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3240dd5a57Smrg exit 1; 3340dd5a57Smrg ;; 3440dd5a57Smrg -h | --h*) 3540dd5a57Smrg cat <<\EOF 3640dd5a57SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3740dd5a57Smrg 3840dd5a57SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3940dd5a57Smrgas side-effects. 4040dd5a57Smrg 4140dd5a57SmrgEnvironment variables: 4240dd5a57Smrg depmode Dependency tracking mode. 4340dd5a57Smrg source Source file read by `PROGRAMS ARGS'. 4440dd5a57Smrg object Object file output by `PROGRAMS ARGS'. 4540dd5a57Smrg DEPDIR directory where to store dependencies. 4640dd5a57Smrg depfile Dependency file to output. 4740dd5a57Smrg tmpdepfile Temporary file to use when outputing dependencies. 4840dd5a57Smrg libtool Whether libtool is used (yes/no). 4940dd5a57Smrg 5040dd5a57SmrgReport bugs to <bug-automake@gnu.org>. 5140dd5a57SmrgEOF 5240dd5a57Smrg exit $? 5340dd5a57Smrg ;; 5440dd5a57Smrg -v | --v*) 5540dd5a57Smrg echo "depcomp $scriptversion" 5640dd5a57Smrg exit $? 5740dd5a57Smrg ;; 5840dd5a57Smrgesac 5940dd5a57Smrg 6040dd5a57Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6140dd5a57Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6240dd5a57Smrg exit 1 6340dd5a57Smrgfi 6440dd5a57Smrg 6540dd5a57Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6640dd5a57Smrgdepfile=${depfile-`echo "$object" | 6740dd5a57Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6840dd5a57Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6940dd5a57Smrg 7040dd5a57Smrgrm -f "$tmpdepfile" 7140dd5a57Smrg 7240dd5a57Smrg# Some modes work just like other modes, but use different flags. We 7340dd5a57Smrg# parameterize here, but still list the modes in the big case below, 7440dd5a57Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7540dd5a57Smrg# here, because this file can only contain one case statement. 7640dd5a57Smrgif test "$depmode" = hp; then 7740dd5a57Smrg # HP compiler uses -M and no extra arg. 7840dd5a57Smrg gccflag=-M 7940dd5a57Smrg depmode=gcc 8040dd5a57Smrgfi 8140dd5a57Smrg 8240dd5a57Smrgif test "$depmode" = dashXmstdout; then 8340dd5a57Smrg # This is just like dashmstdout with a different argument. 8440dd5a57Smrg dashmflag=-xM 8540dd5a57Smrg depmode=dashmstdout 8640dd5a57Smrgfi 8740dd5a57Smrg 8840dd5a57Smrgcygpath_u="cygpath -u -f -" 8940dd5a57Smrgif test "$depmode" = msvcmsys; then 9040dd5a57Smrg # This is just like msvisualcpp but w/o cygpath translation. 9140dd5a57Smrg # Just convert the backslash-escaped backslashes to single forward 9240dd5a57Smrg # slashes to satisfy depend.m4 9340dd5a57Smrg cygpath_u="sed s,\\\\\\\\,/,g" 9440dd5a57Smrg depmode=msvisualcpp 9540dd5a57Smrgfi 9640dd5a57Smrg 9740dd5a57Smrgcase "$depmode" in 9840dd5a57Smrggcc3) 9940dd5a57Smrg## gcc 3 implements dependency tracking that does exactly what 10040dd5a57Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10140dd5a57Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 10240dd5a57Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 10340dd5a57Smrg## the command line argument order; so add the flags where they 10440dd5a57Smrg## appear in depend2.am. Note that the slowdown incurred here 10540dd5a57Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 10640dd5a57Smrg for arg 10740dd5a57Smrg do 10840dd5a57Smrg case $arg in 10940dd5a57Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11040dd5a57Smrg *) set fnord "$@" "$arg" ;; 11140dd5a57Smrg esac 11240dd5a57Smrg shift # fnord 11340dd5a57Smrg shift # $arg 11440dd5a57Smrg done 11540dd5a57Smrg "$@" 11640dd5a57Smrg stat=$? 11740dd5a57Smrg if test $stat -eq 0; then : 11840dd5a57Smrg else 11940dd5a57Smrg rm -f "$tmpdepfile" 12040dd5a57Smrg exit $stat 12140dd5a57Smrg fi 12240dd5a57Smrg mv "$tmpdepfile" "$depfile" 12340dd5a57Smrg ;; 12440dd5a57Smrg 12540dd5a57Smrggcc) 12640dd5a57Smrg## There are various ways to get dependency output from gcc. Here's 12740dd5a57Smrg## why we pick this rather obscure method: 12840dd5a57Smrg## - Don't want to use -MD because we'd like the dependencies to end 12940dd5a57Smrg## up in a subdir. Having to rename by hand is ugly. 13040dd5a57Smrg## (We might end up doing this anyway to support other compilers.) 13140dd5a57Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 13240dd5a57Smrg## -MM, not -M (despite what the docs say). 13340dd5a57Smrg## - Using -M directly means running the compiler twice (even worse 13440dd5a57Smrg## than renaming). 13540dd5a57Smrg if test -z "$gccflag"; then 13640dd5a57Smrg gccflag=-MD, 13740dd5a57Smrg fi 13840dd5a57Smrg "$@" -Wp,"$gccflag$tmpdepfile" 13940dd5a57Smrg stat=$? 14040dd5a57Smrg if test $stat -eq 0; then : 14140dd5a57Smrg else 14240dd5a57Smrg rm -f "$tmpdepfile" 14340dd5a57Smrg exit $stat 14440dd5a57Smrg fi 14540dd5a57Smrg rm -f "$depfile" 14640dd5a57Smrg echo "$object : \\" > "$depfile" 14740dd5a57Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 14840dd5a57Smrg## The second -e expression handles DOS-style file names with drive letters. 14940dd5a57Smrg sed -e 's/^[^:]*: / /' \ 15040dd5a57Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15140dd5a57Smrg## This next piece of magic avoids the `deleted header file' problem. 15240dd5a57Smrg## The problem is that when a header file which appears in a .P file 15340dd5a57Smrg## is deleted, the dependency causes make to die (because there is 15440dd5a57Smrg## typically no way to rebuild the header). We avoid this by adding 15540dd5a57Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 15640dd5a57Smrg## this for us directly. 15740dd5a57Smrg tr ' ' ' 15840dd5a57Smrg' < "$tmpdepfile" | 15940dd5a57Smrg## Some versions of gcc put a space before the `:'. On the theory 16040dd5a57Smrg## that the space means something, we add a space to the output as 16140dd5a57Smrg## well. 16240dd5a57Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 16340dd5a57Smrg## correctly. Breaking it into two sed invocations is a workaround. 16440dd5a57Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 16540dd5a57Smrg rm -f "$tmpdepfile" 16640dd5a57Smrg ;; 16740dd5a57Smrg 16840dd5a57Smrghp) 16940dd5a57Smrg # This case exists only to let depend.m4 do its work. It works by 17040dd5a57Smrg # looking at the text of this script. This case will never be run, 17140dd5a57Smrg # since it is checked for above. 17240dd5a57Smrg exit 1 17340dd5a57Smrg ;; 17440dd5a57Smrg 17540dd5a57Smrgsgi) 17640dd5a57Smrg if test "$libtool" = yes; then 17740dd5a57Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 17840dd5a57Smrg else 17940dd5a57Smrg "$@" -MDupdate "$tmpdepfile" 18040dd5a57Smrg fi 18140dd5a57Smrg stat=$? 18240dd5a57Smrg if test $stat -eq 0; then : 18340dd5a57Smrg else 18440dd5a57Smrg rm -f "$tmpdepfile" 18540dd5a57Smrg exit $stat 18640dd5a57Smrg fi 18740dd5a57Smrg rm -f "$depfile" 18840dd5a57Smrg 18940dd5a57Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 19040dd5a57Smrg echo "$object : \\" > "$depfile" 19140dd5a57Smrg 19240dd5a57Smrg # Clip off the initial element (the dependent). Don't try to be 19340dd5a57Smrg # clever and replace this with sed code, as IRIX sed won't handle 19440dd5a57Smrg # lines with more than a fixed number of characters (4096 in 19540dd5a57Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 19640dd5a57Smrg # the IRIX cc adds comments like `#:fec' to the end of the 19740dd5a57Smrg # dependency line. 19840dd5a57Smrg tr ' ' ' 19940dd5a57Smrg' < "$tmpdepfile" \ 20040dd5a57Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 20140dd5a57Smrg tr ' 20240dd5a57Smrg' ' ' >> "$depfile" 20340dd5a57Smrg echo >> "$depfile" 20440dd5a57Smrg 20540dd5a57Smrg # The second pass generates a dummy entry for each header file. 20640dd5a57Smrg tr ' ' ' 20740dd5a57Smrg' < "$tmpdepfile" \ 20840dd5a57Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20940dd5a57Smrg >> "$depfile" 21040dd5a57Smrg else 21140dd5a57Smrg # The sourcefile does not contain any dependencies, so just 21240dd5a57Smrg # store a dummy comment line, to avoid errors with the Makefile 21340dd5a57Smrg # "include basename.Plo" scheme. 21440dd5a57Smrg echo "#dummy" > "$depfile" 21540dd5a57Smrg fi 21640dd5a57Smrg rm -f "$tmpdepfile" 21740dd5a57Smrg ;; 21840dd5a57Smrg 21940dd5a57Smrgaix) 22040dd5a57Smrg # The C for AIX Compiler uses -M and outputs the dependencies 22140dd5a57Smrg # in a .u file. In older versions, this file always lives in the 22240dd5a57Smrg # current directory. Also, the AIX compiler puts `$object:' at the 22340dd5a57Smrg # start of each line; $object doesn't have directory information. 22440dd5a57Smrg # Version 6 uses the directory in both cases. 22540dd5a57Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 22640dd5a57Smrg test "x$dir" = "x$object" && dir= 22740dd5a57Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22840dd5a57Smrg if test "$libtool" = yes; then 22940dd5a57Smrg tmpdepfile1=$dir$base.u 23040dd5a57Smrg tmpdepfile2=$base.u 23140dd5a57Smrg tmpdepfile3=$dir.libs/$base.u 23240dd5a57Smrg "$@" -Wc,-M 23340dd5a57Smrg else 23440dd5a57Smrg tmpdepfile1=$dir$base.u 23540dd5a57Smrg tmpdepfile2=$dir$base.u 23640dd5a57Smrg tmpdepfile3=$dir$base.u 23740dd5a57Smrg "$@" -M 23840dd5a57Smrg fi 23940dd5a57Smrg stat=$? 24040dd5a57Smrg 24140dd5a57Smrg if test $stat -eq 0; then : 24240dd5a57Smrg else 24340dd5a57Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24440dd5a57Smrg exit $stat 24540dd5a57Smrg fi 24640dd5a57Smrg 24740dd5a57Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24840dd5a57Smrg do 24940dd5a57Smrg test -f "$tmpdepfile" && break 25040dd5a57Smrg done 25140dd5a57Smrg if test -f "$tmpdepfile"; then 25240dd5a57Smrg # Each line is of the form `foo.o: dependent.h'. 25340dd5a57Smrg # Do two passes, one to just change these to 25440dd5a57Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 25540dd5a57Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 25640dd5a57Smrg # That's a tab and a space in the []. 25740dd5a57Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 25840dd5a57Smrg else 25940dd5a57Smrg # The sourcefile does not contain any dependencies, so just 26040dd5a57Smrg # store a dummy comment line, to avoid errors with the Makefile 26140dd5a57Smrg # "include basename.Plo" scheme. 26240dd5a57Smrg echo "#dummy" > "$depfile" 26340dd5a57Smrg fi 26440dd5a57Smrg rm -f "$tmpdepfile" 26540dd5a57Smrg ;; 26640dd5a57Smrg 26740dd5a57Smrgicc) 26840dd5a57Smrg # Intel's C compiler understands `-MD -MF file'. However on 26940dd5a57Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 27040dd5a57Smrg # ICC 7.0 will fill foo.d with something like 27140dd5a57Smrg # foo.o: sub/foo.c 27240dd5a57Smrg # foo.o: sub/foo.h 27340dd5a57Smrg # which is wrong. We want: 27440dd5a57Smrg # sub/foo.o: sub/foo.c 27540dd5a57Smrg # sub/foo.o: sub/foo.h 27640dd5a57Smrg # sub/foo.c: 27740dd5a57Smrg # sub/foo.h: 27840dd5a57Smrg # ICC 7.1 will output 27940dd5a57Smrg # foo.o: sub/foo.c sub/foo.h 28040dd5a57Smrg # and will wrap long lines using \ : 28140dd5a57Smrg # foo.o: sub/foo.c ... \ 28240dd5a57Smrg # sub/foo.h ... \ 28340dd5a57Smrg # ... 28440dd5a57Smrg 28540dd5a57Smrg "$@" -MD -MF "$tmpdepfile" 28640dd5a57Smrg stat=$? 28740dd5a57Smrg if test $stat -eq 0; then : 28840dd5a57Smrg else 28940dd5a57Smrg rm -f "$tmpdepfile" 29040dd5a57Smrg exit $stat 29140dd5a57Smrg fi 29240dd5a57Smrg rm -f "$depfile" 29340dd5a57Smrg # Each line is of the form `foo.o: dependent.h', 29440dd5a57Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 29540dd5a57Smrg # Do two passes, one to just change these to 29640dd5a57Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 29740dd5a57Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 29840dd5a57Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 29940dd5a57Smrg # correctly. Breaking it into two sed invocations is a workaround. 30040dd5a57Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 30140dd5a57Smrg sed -e 's/$/ :/' >> "$depfile" 30240dd5a57Smrg rm -f "$tmpdepfile" 30340dd5a57Smrg ;; 30440dd5a57Smrg 30540dd5a57Smrghp2) 30640dd5a57Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 30740dd5a57Smrg # compilers, which have integrated preprocessors. The correct option 30840dd5a57Smrg # to use with these is +Maked; it writes dependencies to a file named 30940dd5a57Smrg # 'foo.d', which lands next to the object file, wherever that 31040dd5a57Smrg # happens to be. 31140dd5a57Smrg # Much of this is similar to the tru64 case; see comments there. 31240dd5a57Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 31340dd5a57Smrg test "x$dir" = "x$object" && dir= 31440dd5a57Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 31540dd5a57Smrg if test "$libtool" = yes; then 31640dd5a57Smrg tmpdepfile1=$dir$base.d 31740dd5a57Smrg tmpdepfile2=$dir.libs/$base.d 31840dd5a57Smrg "$@" -Wc,+Maked 31940dd5a57Smrg else 32040dd5a57Smrg tmpdepfile1=$dir$base.d 32140dd5a57Smrg tmpdepfile2=$dir$base.d 32240dd5a57Smrg "$@" +Maked 32340dd5a57Smrg fi 32440dd5a57Smrg stat=$? 32540dd5a57Smrg if test $stat -eq 0; then : 32640dd5a57Smrg else 32740dd5a57Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 32840dd5a57Smrg exit $stat 32940dd5a57Smrg fi 33040dd5a57Smrg 33140dd5a57Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 33240dd5a57Smrg do 33340dd5a57Smrg test -f "$tmpdepfile" && break 33440dd5a57Smrg done 33540dd5a57Smrg if test -f "$tmpdepfile"; then 33640dd5a57Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 33740dd5a57Smrg # Add `dependent.h:' lines. 33840dd5a57Smrg sed -ne '2,${ 33940dd5a57Smrg s/^ *// 34040dd5a57Smrg s/ \\*$// 34140dd5a57Smrg s/$/:/ 34240dd5a57Smrg p 34340dd5a57Smrg }' "$tmpdepfile" >> "$depfile" 34440dd5a57Smrg else 34540dd5a57Smrg echo "#dummy" > "$depfile" 34640dd5a57Smrg fi 34740dd5a57Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 34840dd5a57Smrg ;; 34940dd5a57Smrg 35040dd5a57Smrgtru64) 35140dd5a57Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 35240dd5a57Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 35340dd5a57Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 35440dd5a57Smrg # dependencies in `foo.d' instead, so we check for that too. 35540dd5a57Smrg # Subdirectories are respected. 35640dd5a57Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 35740dd5a57Smrg test "x$dir" = "x$object" && dir= 35840dd5a57Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 35940dd5a57Smrg 36040dd5a57Smrg if test "$libtool" = yes; then 36140dd5a57Smrg # With Tru64 cc, shared objects can also be used to make a 36240dd5a57Smrg # static library. This mechanism is used in libtool 1.4 series to 36340dd5a57Smrg # handle both shared and static libraries in a single compilation. 36440dd5a57Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 36540dd5a57Smrg # 36640dd5a57Smrg # With libtool 1.5 this exception was removed, and libtool now 36740dd5a57Smrg # generates 2 separate objects for the 2 libraries. These two 36840dd5a57Smrg # compilations output dependencies in $dir.libs/$base.o.d and 36940dd5a57Smrg # in $dir$base.o.d. We have to check for both files, because 37040dd5a57Smrg # one of the two compilations can be disabled. We should prefer 37140dd5a57Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 37240dd5a57Smrg # automatically cleaned when .libs/ is deleted, while ignoring 37340dd5a57Smrg # the former would cause a distcleancheck panic. 37440dd5a57Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 37540dd5a57Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 37640dd5a57Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 37740dd5a57Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 37840dd5a57Smrg "$@" -Wc,-MD 37940dd5a57Smrg else 38040dd5a57Smrg tmpdepfile1=$dir$base.o.d 38140dd5a57Smrg tmpdepfile2=$dir$base.d 38240dd5a57Smrg tmpdepfile3=$dir$base.d 38340dd5a57Smrg tmpdepfile4=$dir$base.d 38440dd5a57Smrg "$@" -MD 38540dd5a57Smrg fi 38640dd5a57Smrg 38740dd5a57Smrg stat=$? 38840dd5a57Smrg if test $stat -eq 0; then : 38940dd5a57Smrg else 39040dd5a57Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39140dd5a57Smrg exit $stat 39240dd5a57Smrg fi 39340dd5a57Smrg 39440dd5a57Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39540dd5a57Smrg do 39640dd5a57Smrg test -f "$tmpdepfile" && break 39740dd5a57Smrg done 39840dd5a57Smrg if test -f "$tmpdepfile"; then 39940dd5a57Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 40040dd5a57Smrg # That's a tab and a space in the []. 40140dd5a57Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 40240dd5a57Smrg else 40340dd5a57Smrg echo "#dummy" > "$depfile" 40440dd5a57Smrg fi 40540dd5a57Smrg rm -f "$tmpdepfile" 40640dd5a57Smrg ;; 40740dd5a57Smrg 40840dd5a57Smrg#nosideeffect) 40940dd5a57Smrg # This comment above is used by automake to tell side-effect 41040dd5a57Smrg # dependency tracking mechanisms from slower ones. 41140dd5a57Smrg 41240dd5a57Smrgdashmstdout) 41340dd5a57Smrg # Important note: in order to support this mode, a compiler *must* 41440dd5a57Smrg # always write the preprocessed file to stdout, regardless of -o. 41540dd5a57Smrg "$@" || exit $? 41640dd5a57Smrg 41740dd5a57Smrg # Remove the call to Libtool. 41840dd5a57Smrg if test "$libtool" = yes; then 41940dd5a57Smrg while test "X$1" != 'X--mode=compile'; do 42040dd5a57Smrg shift 42140dd5a57Smrg done 42240dd5a57Smrg shift 42340dd5a57Smrg fi 42440dd5a57Smrg 42540dd5a57Smrg # Remove `-o $object'. 42640dd5a57Smrg IFS=" " 42740dd5a57Smrg for arg 42840dd5a57Smrg do 42940dd5a57Smrg case $arg in 43040dd5a57Smrg -o) 43140dd5a57Smrg shift 43240dd5a57Smrg ;; 43340dd5a57Smrg $object) 43440dd5a57Smrg shift 43540dd5a57Smrg ;; 43640dd5a57Smrg *) 43740dd5a57Smrg set fnord "$@" "$arg" 43840dd5a57Smrg shift # fnord 43940dd5a57Smrg shift # $arg 44040dd5a57Smrg ;; 44140dd5a57Smrg esac 44240dd5a57Smrg done 44340dd5a57Smrg 44440dd5a57Smrg test -z "$dashmflag" && dashmflag=-M 44540dd5a57Smrg # Require at least two characters before searching for `:' 44640dd5a57Smrg # in the target name. This is to cope with DOS-style filenames: 44740dd5a57Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 44840dd5a57Smrg "$@" $dashmflag | 44940dd5a57Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 45040dd5a57Smrg rm -f "$depfile" 45140dd5a57Smrg cat < "$tmpdepfile" > "$depfile" 45240dd5a57Smrg tr ' ' ' 45340dd5a57Smrg' < "$tmpdepfile" | \ 45440dd5a57Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 45540dd5a57Smrg## correctly. Breaking it into two sed invocations is a workaround. 45640dd5a57Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 45740dd5a57Smrg rm -f "$tmpdepfile" 45840dd5a57Smrg ;; 45940dd5a57Smrg 46040dd5a57SmrgdashXmstdout) 46140dd5a57Smrg # This case only exists to satisfy depend.m4. It is never actually 46240dd5a57Smrg # run, as this mode is specially recognized in the preamble. 46340dd5a57Smrg exit 1 46440dd5a57Smrg ;; 46540dd5a57Smrg 46640dd5a57Smrgmakedepend) 46740dd5a57Smrg "$@" || exit $? 46840dd5a57Smrg # Remove any Libtool call 46940dd5a57Smrg if test "$libtool" = yes; then 47040dd5a57Smrg while test "X$1" != 'X--mode=compile'; do 47140dd5a57Smrg shift 47240dd5a57Smrg done 47340dd5a57Smrg shift 47440dd5a57Smrg fi 47540dd5a57Smrg # X makedepend 47640dd5a57Smrg shift 47740dd5a57Smrg cleared=no eat=no 47840dd5a57Smrg for arg 47940dd5a57Smrg do 48040dd5a57Smrg case $cleared in 48140dd5a57Smrg no) 48240dd5a57Smrg set ""; shift 48340dd5a57Smrg cleared=yes ;; 48440dd5a57Smrg esac 48540dd5a57Smrg if test $eat = yes; then 48640dd5a57Smrg eat=no 48740dd5a57Smrg continue 48840dd5a57Smrg fi 48940dd5a57Smrg case "$arg" in 49040dd5a57Smrg -D*|-I*) 49140dd5a57Smrg set fnord "$@" "$arg"; shift ;; 49240dd5a57Smrg # Strip any option that makedepend may not understand. Remove 49340dd5a57Smrg # the object too, otherwise makedepend will parse it as a source file. 49440dd5a57Smrg -arch) 49540dd5a57Smrg eat=yes ;; 49640dd5a57Smrg -*|$object) 49740dd5a57Smrg ;; 49840dd5a57Smrg *) 49940dd5a57Smrg set fnord "$@" "$arg"; shift ;; 50040dd5a57Smrg esac 50140dd5a57Smrg done 50240dd5a57Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 50340dd5a57Smrg touch "$tmpdepfile" 50440dd5a57Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 50540dd5a57Smrg rm -f "$depfile" 50640dd5a57Smrg cat < "$tmpdepfile" > "$depfile" 50740dd5a57Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 50840dd5a57Smrg' | \ 50940dd5a57Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51040dd5a57Smrg## correctly. Breaking it into two sed invocations is a workaround. 51140dd5a57Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51240dd5a57Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 51340dd5a57Smrg ;; 51440dd5a57Smrg 51540dd5a57Smrgcpp) 51640dd5a57Smrg # Important note: in order to support this mode, a compiler *must* 51740dd5a57Smrg # always write the preprocessed file to stdout. 51840dd5a57Smrg "$@" || exit $? 51940dd5a57Smrg 52040dd5a57Smrg # Remove the call to Libtool. 52140dd5a57Smrg if test "$libtool" = yes; then 52240dd5a57Smrg while test "X$1" != 'X--mode=compile'; do 52340dd5a57Smrg shift 52440dd5a57Smrg done 52540dd5a57Smrg shift 52640dd5a57Smrg fi 52740dd5a57Smrg 52840dd5a57Smrg # Remove `-o $object'. 52940dd5a57Smrg IFS=" " 53040dd5a57Smrg for arg 53140dd5a57Smrg do 53240dd5a57Smrg case $arg in 53340dd5a57Smrg -o) 53440dd5a57Smrg shift 53540dd5a57Smrg ;; 53640dd5a57Smrg $object) 53740dd5a57Smrg shift 53840dd5a57Smrg ;; 53940dd5a57Smrg *) 54040dd5a57Smrg set fnord "$@" "$arg" 54140dd5a57Smrg shift # fnord 54240dd5a57Smrg shift # $arg 54340dd5a57Smrg ;; 54440dd5a57Smrg esac 54540dd5a57Smrg done 54640dd5a57Smrg 54740dd5a57Smrg "$@" -E | 54840dd5a57Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 54940dd5a57Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 55040dd5a57Smrg sed '$ s: \\$::' > "$tmpdepfile" 55140dd5a57Smrg rm -f "$depfile" 55240dd5a57Smrg echo "$object : \\" > "$depfile" 55340dd5a57Smrg cat < "$tmpdepfile" >> "$depfile" 55440dd5a57Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 55540dd5a57Smrg rm -f "$tmpdepfile" 55640dd5a57Smrg ;; 55740dd5a57Smrg 55840dd5a57Smrgmsvisualcpp) 55940dd5a57Smrg # Important note: in order to support this mode, a compiler *must* 56040dd5a57Smrg # always write the preprocessed file to stdout. 56140dd5a57Smrg "$@" || exit $? 56240dd5a57Smrg 56340dd5a57Smrg # Remove the call to Libtool. 56440dd5a57Smrg if test "$libtool" = yes; then 56540dd5a57Smrg while test "X$1" != 'X--mode=compile'; do 56640dd5a57Smrg shift 56740dd5a57Smrg done 56840dd5a57Smrg shift 56940dd5a57Smrg fi 57040dd5a57Smrg 57140dd5a57Smrg IFS=" " 57240dd5a57Smrg for arg 57340dd5a57Smrg do 57440dd5a57Smrg case "$arg" in 57540dd5a57Smrg -o) 57640dd5a57Smrg shift 57740dd5a57Smrg ;; 57840dd5a57Smrg $object) 57940dd5a57Smrg shift 58040dd5a57Smrg ;; 58140dd5a57Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 58240dd5a57Smrg set fnord "$@" 58340dd5a57Smrg shift 58440dd5a57Smrg shift 58540dd5a57Smrg ;; 58640dd5a57Smrg *) 58740dd5a57Smrg set fnord "$@" "$arg" 58840dd5a57Smrg shift 58940dd5a57Smrg shift 59040dd5a57Smrg ;; 59140dd5a57Smrg esac 59240dd5a57Smrg done 59340dd5a57Smrg "$@" -E 2>/dev/null | 59440dd5a57Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 59540dd5a57Smrg rm -f "$depfile" 59640dd5a57Smrg echo "$object : \\" > "$depfile" 59740dd5a57Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 59840dd5a57Smrg echo " " >> "$depfile" 59940dd5a57Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 60040dd5a57Smrg rm -f "$tmpdepfile" 60140dd5a57Smrg ;; 60240dd5a57Smrg 60340dd5a57Smrgmsvcmsys) 60440dd5a57Smrg # This case exists only to let depend.m4 do its work. It works by 60540dd5a57Smrg # looking at the text of this script. This case will never be run, 60640dd5a57Smrg # since it is checked for above. 60740dd5a57Smrg exit 1 60840dd5a57Smrg ;; 60940dd5a57Smrg 61040dd5a57Smrgnone) 61140dd5a57Smrg exec "$@" 61240dd5a57Smrg ;; 61340dd5a57Smrg 61440dd5a57Smrg*) 61540dd5a57Smrg echo "Unknown depmode $depmode" 1>&2 61640dd5a57Smrg exit 1 61740dd5a57Smrg ;; 61840dd5a57Smrgesac 61940dd5a57Smrg 62040dd5a57Smrgexit 0 62140dd5a57Smrg 62240dd5a57Smrg# Local Variables: 62340dd5a57Smrg# mode: shell-script 62440dd5a57Smrg# sh-indentation: 2 62540dd5a57Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 62640dd5a57Smrg# time-stamp-start: "scriptversion=" 62740dd5a57Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62840dd5a57Smrg# time-stamp-time-zone: "UTC" 62940dd5a57Smrg# time-stamp-end: "; # UTC" 63040dd5a57Smrg# End: 631