depcomp revision e35d4d8e
132b578d3Smrg#! /bin/sh 232b578d3Smrg# depcomp - compile a program generating dependencies as side-effects 332b578d3Smrg 4e35d4d8eSmrgscriptversion=2011-12-04.11; # UTC 532b578d3Smrg 6e35d4d8eSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7e35d4d8eSmrg# 2011 Free Software Foundation, Inc. 832b578d3Smrg 932b578d3Smrg# This program is free software; you can redistribute it and/or modify 1032b578d3Smrg# it under the terms of the GNU General Public License as published by 1132b578d3Smrg# the Free Software Foundation; either version 2, or (at your option) 1232b578d3Smrg# any later version. 1332b578d3Smrg 1432b578d3Smrg# This program is distributed in the hope that it will be useful, 1532b578d3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1632b578d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1732b578d3Smrg# GNU General Public License for more details. 1832b578d3Smrg 1932b578d3Smrg# You should have received a copy of the GNU General Public License 202a51b5beSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2132b578d3Smrg 2232b578d3Smrg# As a special exception to the GNU General Public License, if you 2332b578d3Smrg# distribute this file as part of a program that contains a 2432b578d3Smrg# configuration script generated by Autoconf, you may include it under 2532b578d3Smrg# the same distribution terms that you use for the rest of that program. 2632b578d3Smrg 2732b578d3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2832b578d3Smrg 2932b578d3Smrgcase $1 in 3032b578d3Smrg '') 3132b578d3Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3232b578d3Smrg exit 1; 3332b578d3Smrg ;; 3432b578d3Smrg -h | --h*) 3532b578d3Smrg cat <<\EOF 3632b578d3SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3732b578d3Smrg 3832b578d3SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3932b578d3Smrgas side-effects. 4032b578d3Smrg 4132b578d3SmrgEnvironment variables: 4232b578d3Smrg depmode Dependency tracking mode. 4332b578d3Smrg source Source file read by `PROGRAMS ARGS'. 4432b578d3Smrg object Object file output by `PROGRAMS ARGS'. 4532b578d3Smrg DEPDIR directory where to store dependencies. 4632b578d3Smrg depfile Dependency file to output. 47e35d4d8eSmrg tmpdepfile Temporary file to use when outputting dependencies. 4832b578d3Smrg libtool Whether libtool is used (yes/no). 4932b578d3Smrg 5032b578d3SmrgReport bugs to <bug-automake@gnu.org>. 5132b578d3SmrgEOF 5232b578d3Smrg exit $? 5332b578d3Smrg ;; 5432b578d3Smrg -v | --v*) 5532b578d3Smrg echo "depcomp $scriptversion" 5632b578d3Smrg exit $? 5732b578d3Smrg ;; 5832b578d3Smrgesac 5932b578d3Smrg 6032b578d3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6132b578d3Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6232b578d3Smrg exit 1 6332b578d3Smrgfi 6432b578d3Smrg 6532b578d3Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6632b578d3Smrgdepfile=${depfile-`echo "$object" | 6732b578d3Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6832b578d3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6932b578d3Smrg 7032b578d3Smrgrm -f "$tmpdepfile" 7132b578d3Smrg 7232b578d3Smrg# Some modes work just like other modes, but use different flags. We 7332b578d3Smrg# parameterize here, but still list the modes in the big case below, 7432b578d3Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7532b578d3Smrg# here, because this file can only contain one case statement. 7632b578d3Smrgif test "$depmode" = hp; then 7732b578d3Smrg # HP compiler uses -M and no extra arg. 7832b578d3Smrg gccflag=-M 7932b578d3Smrg depmode=gcc 8032b578d3Smrgfi 8132b578d3Smrg 8232b578d3Smrgif test "$depmode" = dashXmstdout; then 8332b578d3Smrg # This is just like dashmstdout with a different argument. 8432b578d3Smrg dashmflag=-xM 8532b578d3Smrg depmode=dashmstdout 8632b578d3Smrgfi 8732b578d3Smrg 882a51b5beSmrgcygpath_u="cygpath -u -f -" 892a51b5beSmrgif test "$depmode" = msvcmsys; then 902a51b5beSmrg # This is just like msvisualcpp but w/o cygpath translation. 912a51b5beSmrg # Just convert the backslash-escaped backslashes to single forward 922a51b5beSmrg # slashes to satisfy depend.m4 93e35d4d8eSmrg cygpath_u='sed s,\\\\,/,g' 942a51b5beSmrg depmode=msvisualcpp 952a51b5beSmrgfi 962a51b5beSmrg 97e35d4d8eSmrgif test "$depmode" = msvc7msys; then 98e35d4d8eSmrg # This is just like msvc7 but w/o cygpath translation. 99e35d4d8eSmrg # Just convert the backslash-escaped backslashes to single forward 100e35d4d8eSmrg # slashes to satisfy depend.m4 101e35d4d8eSmrg cygpath_u='sed s,\\\\,/,g' 102e35d4d8eSmrg depmode=msvc7 103e35d4d8eSmrgfi 104e35d4d8eSmrg 10532b578d3Smrgcase "$depmode" in 10632b578d3Smrggcc3) 10732b578d3Smrg## gcc 3 implements dependency tracking that does exactly what 10832b578d3Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10932b578d3Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 11032b578d3Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 11132b578d3Smrg## the command line argument order; so add the flags where they 11232b578d3Smrg## appear in depend2.am. Note that the slowdown incurred here 11332b578d3Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 11432b578d3Smrg for arg 11532b578d3Smrg do 11632b578d3Smrg case $arg in 11732b578d3Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11832b578d3Smrg *) set fnord "$@" "$arg" ;; 11932b578d3Smrg esac 12032b578d3Smrg shift # fnord 12132b578d3Smrg shift # $arg 12232b578d3Smrg done 12332b578d3Smrg "$@" 12432b578d3Smrg stat=$? 12532b578d3Smrg if test $stat -eq 0; then : 12632b578d3Smrg else 12732b578d3Smrg rm -f "$tmpdepfile" 12832b578d3Smrg exit $stat 12932b578d3Smrg fi 13032b578d3Smrg mv "$tmpdepfile" "$depfile" 13132b578d3Smrg ;; 13232b578d3Smrg 13332b578d3Smrggcc) 13432b578d3Smrg## There are various ways to get dependency output from gcc. Here's 13532b578d3Smrg## why we pick this rather obscure method: 13632b578d3Smrg## - Don't want to use -MD because we'd like the dependencies to end 13732b578d3Smrg## up in a subdir. Having to rename by hand is ugly. 13832b578d3Smrg## (We might end up doing this anyway to support other compilers.) 13932b578d3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 14032b578d3Smrg## -MM, not -M (despite what the docs say). 14132b578d3Smrg## - Using -M directly means running the compiler twice (even worse 14232b578d3Smrg## than renaming). 14332b578d3Smrg if test -z "$gccflag"; then 14432b578d3Smrg gccflag=-MD, 14532b578d3Smrg fi 14632b578d3Smrg "$@" -Wp,"$gccflag$tmpdepfile" 14732b578d3Smrg stat=$? 14832b578d3Smrg if test $stat -eq 0; then : 14932b578d3Smrg else 15032b578d3Smrg rm -f "$tmpdepfile" 15132b578d3Smrg exit $stat 15232b578d3Smrg fi 15332b578d3Smrg rm -f "$depfile" 15432b578d3Smrg echo "$object : \\" > "$depfile" 15532b578d3Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 15632b578d3Smrg## The second -e expression handles DOS-style file names with drive letters. 15732b578d3Smrg sed -e 's/^[^:]*: / /' \ 15832b578d3Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15932b578d3Smrg## This next piece of magic avoids the `deleted header file' problem. 16032b578d3Smrg## The problem is that when a header file which appears in a .P file 16132b578d3Smrg## is deleted, the dependency causes make to die (because there is 16232b578d3Smrg## typically no way to rebuild the header). We avoid this by adding 16332b578d3Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 16432b578d3Smrg## this for us directly. 16532b578d3Smrg tr ' ' ' 16632b578d3Smrg' < "$tmpdepfile" | 16732b578d3Smrg## Some versions of gcc put a space before the `:'. On the theory 16832b578d3Smrg## that the space means something, we add a space to the output as 169e35d4d8eSmrg## well. hp depmode also adds that space, but also prefixes the VPATH 170e35d4d8eSmrg## to the object. Take care to not repeat it in the output. 17132b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 17232b578d3Smrg## correctly. Breaking it into two sed invocations is a workaround. 173e35d4d8eSmrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 174e35d4d8eSmrg | sed -e 's/$/ :/' >> "$depfile" 17532b578d3Smrg rm -f "$tmpdepfile" 17632b578d3Smrg ;; 17732b578d3Smrg 17832b578d3Smrghp) 17932b578d3Smrg # This case exists only to let depend.m4 do its work. It works by 18032b578d3Smrg # looking at the text of this script. This case will never be run, 18132b578d3Smrg # since it is checked for above. 18232b578d3Smrg exit 1 18332b578d3Smrg ;; 18432b578d3Smrg 18532b578d3Smrgsgi) 18632b578d3Smrg if test "$libtool" = yes; then 18732b578d3Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 18832b578d3Smrg else 18932b578d3Smrg "$@" -MDupdate "$tmpdepfile" 19032b578d3Smrg fi 19132b578d3Smrg stat=$? 19232b578d3Smrg if test $stat -eq 0; then : 19332b578d3Smrg else 19432b578d3Smrg rm -f "$tmpdepfile" 19532b578d3Smrg exit $stat 19632b578d3Smrg fi 19732b578d3Smrg rm -f "$depfile" 19832b578d3Smrg 19932b578d3Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 20032b578d3Smrg echo "$object : \\" > "$depfile" 20132b578d3Smrg 20232b578d3Smrg # Clip off the initial element (the dependent). Don't try to be 20332b578d3Smrg # clever and replace this with sed code, as IRIX sed won't handle 20432b578d3Smrg # lines with more than a fixed number of characters (4096 in 20532b578d3Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 20632b578d3Smrg # the IRIX cc adds comments like `#:fec' to the end of the 20732b578d3Smrg # dependency line. 20832b578d3Smrg tr ' ' ' 20932b578d3Smrg' < "$tmpdepfile" \ 21032b578d3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 21132b578d3Smrg tr ' 2122a51b5beSmrg' ' ' >> "$depfile" 2132a51b5beSmrg echo >> "$depfile" 21432b578d3Smrg 21532b578d3Smrg # The second pass generates a dummy entry for each header file. 21632b578d3Smrg tr ' ' ' 21732b578d3Smrg' < "$tmpdepfile" \ 21832b578d3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2192a51b5beSmrg >> "$depfile" 22032b578d3Smrg else 22132b578d3Smrg # The sourcefile does not contain any dependencies, so just 22232b578d3Smrg # store a dummy comment line, to avoid errors with the Makefile 22332b578d3Smrg # "include basename.Plo" scheme. 22432b578d3Smrg echo "#dummy" > "$depfile" 22532b578d3Smrg fi 22632b578d3Smrg rm -f "$tmpdepfile" 22732b578d3Smrg ;; 22832b578d3Smrg 22932b578d3Smrgaix) 23032b578d3Smrg # The C for AIX Compiler uses -M and outputs the dependencies 23132b578d3Smrg # in a .u file. In older versions, this file always lives in the 23232b578d3Smrg # current directory. Also, the AIX compiler puts `$object:' at the 23332b578d3Smrg # start of each line; $object doesn't have directory information. 23432b578d3Smrg # Version 6 uses the directory in both cases. 2352a51b5beSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2362a51b5beSmrg test "x$dir" = "x$object" && dir= 2372a51b5beSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 23832b578d3Smrg if test "$libtool" = yes; then 2392a51b5beSmrg tmpdepfile1=$dir$base.u 2402a51b5beSmrg tmpdepfile2=$base.u 2412a51b5beSmrg tmpdepfile3=$dir.libs/$base.u 24232b578d3Smrg "$@" -Wc,-M 24332b578d3Smrg else 2442a51b5beSmrg tmpdepfile1=$dir$base.u 2452a51b5beSmrg tmpdepfile2=$dir$base.u 2462a51b5beSmrg tmpdepfile3=$dir$base.u 24732b578d3Smrg "$@" -M 24832b578d3Smrg fi 24932b578d3Smrg stat=$? 25032b578d3Smrg 25132b578d3Smrg if test $stat -eq 0; then : 25232b578d3Smrg else 2532a51b5beSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25432b578d3Smrg exit $stat 25532b578d3Smrg fi 25632b578d3Smrg 2572a51b5beSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2582a51b5beSmrg do 2592a51b5beSmrg test -f "$tmpdepfile" && break 2602a51b5beSmrg done 26132b578d3Smrg if test -f "$tmpdepfile"; then 26232b578d3Smrg # Each line is of the form `foo.o: dependent.h'. 26332b578d3Smrg # Do two passes, one to just change these to 26432b578d3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2652a51b5beSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2662a51b5beSmrg # That's a tab and a space in the []. 2672a51b5beSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 26832b578d3Smrg else 26932b578d3Smrg # The sourcefile does not contain any dependencies, so just 27032b578d3Smrg # store a dummy comment line, to avoid errors with the Makefile 27132b578d3Smrg # "include basename.Plo" scheme. 27232b578d3Smrg echo "#dummy" > "$depfile" 27332b578d3Smrg fi 27432b578d3Smrg rm -f "$tmpdepfile" 27532b578d3Smrg ;; 27632b578d3Smrg 27732b578d3Smrgicc) 27832b578d3Smrg # Intel's C compiler understands `-MD -MF file'. However on 27932b578d3Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 28032b578d3Smrg # ICC 7.0 will fill foo.d with something like 28132b578d3Smrg # foo.o: sub/foo.c 28232b578d3Smrg # foo.o: sub/foo.h 28332b578d3Smrg # which is wrong. We want: 28432b578d3Smrg # sub/foo.o: sub/foo.c 28532b578d3Smrg # sub/foo.o: sub/foo.h 28632b578d3Smrg # sub/foo.c: 28732b578d3Smrg # sub/foo.h: 28832b578d3Smrg # ICC 7.1 will output 28932b578d3Smrg # foo.o: sub/foo.c sub/foo.h 29032b578d3Smrg # and will wrap long lines using \ : 29132b578d3Smrg # foo.o: sub/foo.c ... \ 29232b578d3Smrg # sub/foo.h ... \ 29332b578d3Smrg # ... 29432b578d3Smrg 29532b578d3Smrg "$@" -MD -MF "$tmpdepfile" 29632b578d3Smrg stat=$? 29732b578d3Smrg if test $stat -eq 0; then : 29832b578d3Smrg else 29932b578d3Smrg rm -f "$tmpdepfile" 30032b578d3Smrg exit $stat 30132b578d3Smrg fi 30232b578d3Smrg rm -f "$depfile" 30332b578d3Smrg # Each line is of the form `foo.o: dependent.h', 30432b578d3Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 30532b578d3Smrg # Do two passes, one to just change these to 30632b578d3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 30732b578d3Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 30832b578d3Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 30932b578d3Smrg # correctly. Breaking it into two sed invocations is a workaround. 31032b578d3Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 31132b578d3Smrg sed -e 's/$/ :/' >> "$depfile" 31232b578d3Smrg rm -f "$tmpdepfile" 31332b578d3Smrg ;; 31432b578d3Smrg 31532b578d3Smrghp2) 31632b578d3Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 31732b578d3Smrg # compilers, which have integrated preprocessors. The correct option 31832b578d3Smrg # to use with these is +Maked; it writes dependencies to a file named 31932b578d3Smrg # 'foo.d', which lands next to the object file, wherever that 32032b578d3Smrg # happens to be. 32132b578d3Smrg # Much of this is similar to the tru64 case; see comments there. 32232b578d3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 32332b578d3Smrg test "x$dir" = "x$object" && dir= 32432b578d3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 32532b578d3Smrg if test "$libtool" = yes; then 32632b578d3Smrg tmpdepfile1=$dir$base.d 32732b578d3Smrg tmpdepfile2=$dir.libs/$base.d 32832b578d3Smrg "$@" -Wc,+Maked 32932b578d3Smrg else 33032b578d3Smrg tmpdepfile1=$dir$base.d 33132b578d3Smrg tmpdepfile2=$dir$base.d 33232b578d3Smrg "$@" +Maked 33332b578d3Smrg fi 33432b578d3Smrg stat=$? 33532b578d3Smrg if test $stat -eq 0; then : 33632b578d3Smrg else 33732b578d3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 33832b578d3Smrg exit $stat 33932b578d3Smrg fi 34032b578d3Smrg 34132b578d3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 34232b578d3Smrg do 34332b578d3Smrg test -f "$tmpdepfile" && break 34432b578d3Smrg done 34532b578d3Smrg if test -f "$tmpdepfile"; then 34632b578d3Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 34732b578d3Smrg # Add `dependent.h:' lines. 3482a51b5beSmrg sed -ne '2,${ 3492a51b5beSmrg s/^ *// 3502a51b5beSmrg s/ \\*$// 3512a51b5beSmrg s/$/:/ 3522a51b5beSmrg p 3532a51b5beSmrg }' "$tmpdepfile" >> "$depfile" 35432b578d3Smrg else 35532b578d3Smrg echo "#dummy" > "$depfile" 35632b578d3Smrg fi 35732b578d3Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 35832b578d3Smrg ;; 35932b578d3Smrg 36032b578d3Smrgtru64) 36132b578d3Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 36232b578d3Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 36332b578d3Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 36432b578d3Smrg # dependencies in `foo.d' instead, so we check for that too. 36532b578d3Smrg # Subdirectories are respected. 36632b578d3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 36732b578d3Smrg test "x$dir" = "x$object" && dir= 36832b578d3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 36932b578d3Smrg 37032b578d3Smrg if test "$libtool" = yes; then 37132b578d3Smrg # With Tru64 cc, shared objects can also be used to make a 37232b578d3Smrg # static library. This mechanism is used in libtool 1.4 series to 37332b578d3Smrg # handle both shared and static libraries in a single compilation. 37432b578d3Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 37532b578d3Smrg # 37632b578d3Smrg # With libtool 1.5 this exception was removed, and libtool now 37732b578d3Smrg # generates 2 separate objects for the 2 libraries. These two 37832b578d3Smrg # compilations output dependencies in $dir.libs/$base.o.d and 37932b578d3Smrg # in $dir$base.o.d. We have to check for both files, because 38032b578d3Smrg # one of the two compilations can be disabled. We should prefer 38132b578d3Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 38232b578d3Smrg # automatically cleaned when .libs/ is deleted, while ignoring 38332b578d3Smrg # the former would cause a distcleancheck panic. 38432b578d3Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 38532b578d3Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 38632b578d3Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 38732b578d3Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 38832b578d3Smrg "$@" -Wc,-MD 38932b578d3Smrg else 39032b578d3Smrg tmpdepfile1=$dir$base.o.d 39132b578d3Smrg tmpdepfile2=$dir$base.d 39232b578d3Smrg tmpdepfile3=$dir$base.d 39332b578d3Smrg tmpdepfile4=$dir$base.d 39432b578d3Smrg "$@" -MD 39532b578d3Smrg fi 39632b578d3Smrg 39732b578d3Smrg stat=$? 39832b578d3Smrg if test $stat -eq 0; then : 39932b578d3Smrg else 40032b578d3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40132b578d3Smrg exit $stat 40232b578d3Smrg fi 40332b578d3Smrg 40432b578d3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40532b578d3Smrg do 40632b578d3Smrg test -f "$tmpdepfile" && break 40732b578d3Smrg done 40832b578d3Smrg if test -f "$tmpdepfile"; then 40932b578d3Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 41032b578d3Smrg # That's a tab and a space in the []. 41132b578d3Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 41232b578d3Smrg else 41332b578d3Smrg echo "#dummy" > "$depfile" 41432b578d3Smrg fi 41532b578d3Smrg rm -f "$tmpdepfile" 41632b578d3Smrg ;; 41732b578d3Smrg 418e35d4d8eSmrgmsvc7) 419e35d4d8eSmrg if test "$libtool" = yes; then 420e35d4d8eSmrg showIncludes=-Wc,-showIncludes 421e35d4d8eSmrg else 422e35d4d8eSmrg showIncludes=-showIncludes 423e35d4d8eSmrg fi 424e35d4d8eSmrg "$@" $showIncludes > "$tmpdepfile" 425e35d4d8eSmrg stat=$? 426e35d4d8eSmrg grep -v '^Note: including file: ' "$tmpdepfile" 427e35d4d8eSmrg if test "$stat" = 0; then : 428e35d4d8eSmrg else 429e35d4d8eSmrg rm -f "$tmpdepfile" 430e35d4d8eSmrg exit $stat 431e35d4d8eSmrg fi 432e35d4d8eSmrg rm -f "$depfile" 433e35d4d8eSmrg echo "$object : \\" > "$depfile" 434e35d4d8eSmrg # The first sed program below extracts the file names and escapes 435e35d4d8eSmrg # backslashes for cygpath. The second sed program outputs the file 436e35d4d8eSmrg # name when reading, but also accumulates all include files in the 437e35d4d8eSmrg # hold buffer in order to output them again at the end. This only 438e35d4d8eSmrg # works with sed implementations that can handle large buffers. 439e35d4d8eSmrg sed < "$tmpdepfile" -n ' 440e35d4d8eSmrg/^Note: including file: *\(.*\)/ { 441e35d4d8eSmrg s//\1/ 442e35d4d8eSmrg s/\\/\\\\/g 443e35d4d8eSmrg p 444e35d4d8eSmrg}' | $cygpath_u | sort -u | sed -n ' 445e35d4d8eSmrgs/ /\\ /g 446e35d4d8eSmrgs/\(.*\)/ \1 \\/p 447e35d4d8eSmrgs/.\(.*\) \\/\1:/ 448e35d4d8eSmrgH 449e35d4d8eSmrg$ { 450e35d4d8eSmrg s/.*/ / 451e35d4d8eSmrg G 452e35d4d8eSmrg p 453e35d4d8eSmrg}' >> "$depfile" 454e35d4d8eSmrg rm -f "$tmpdepfile" 455e35d4d8eSmrg ;; 456e35d4d8eSmrg 457e35d4d8eSmrgmsvc7msys) 458e35d4d8eSmrg # This case exists only to let depend.m4 do its work. It works by 459e35d4d8eSmrg # looking at the text of this script. This case will never be run, 460e35d4d8eSmrg # since it is checked for above. 461e35d4d8eSmrg exit 1 462e35d4d8eSmrg ;; 463e35d4d8eSmrg 46432b578d3Smrg#nosideeffect) 46532b578d3Smrg # This comment above is used by automake to tell side-effect 46632b578d3Smrg # dependency tracking mechanisms from slower ones. 46732b578d3Smrg 46832b578d3Smrgdashmstdout) 46932b578d3Smrg # Important note: in order to support this mode, a compiler *must* 47032b578d3Smrg # always write the preprocessed file to stdout, regardless of -o. 47132b578d3Smrg "$@" || exit $? 47232b578d3Smrg 47332b578d3Smrg # Remove the call to Libtool. 47432b578d3Smrg if test "$libtool" = yes; then 4752a51b5beSmrg while test "X$1" != 'X--mode=compile'; do 47632b578d3Smrg shift 47732b578d3Smrg done 47832b578d3Smrg shift 47932b578d3Smrg fi 48032b578d3Smrg 48132b578d3Smrg # Remove `-o $object'. 48232b578d3Smrg IFS=" " 48332b578d3Smrg for arg 48432b578d3Smrg do 48532b578d3Smrg case $arg in 48632b578d3Smrg -o) 48732b578d3Smrg shift 48832b578d3Smrg ;; 48932b578d3Smrg $object) 49032b578d3Smrg shift 49132b578d3Smrg ;; 49232b578d3Smrg *) 49332b578d3Smrg set fnord "$@" "$arg" 49432b578d3Smrg shift # fnord 49532b578d3Smrg shift # $arg 49632b578d3Smrg ;; 49732b578d3Smrg esac 49832b578d3Smrg done 49932b578d3Smrg 50032b578d3Smrg test -z "$dashmflag" && dashmflag=-M 50132b578d3Smrg # Require at least two characters before searching for `:' 50232b578d3Smrg # in the target name. This is to cope with DOS-style filenames: 50332b578d3Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 50432b578d3Smrg "$@" $dashmflag | 50532b578d3Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 50632b578d3Smrg rm -f "$depfile" 50732b578d3Smrg cat < "$tmpdepfile" > "$depfile" 50832b578d3Smrg tr ' ' ' 50932b578d3Smrg' < "$tmpdepfile" | \ 51032b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51132b578d3Smrg## correctly. Breaking it into two sed invocations is a workaround. 51232b578d3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51332b578d3Smrg rm -f "$tmpdepfile" 51432b578d3Smrg ;; 51532b578d3Smrg 51632b578d3SmrgdashXmstdout) 51732b578d3Smrg # This case only exists to satisfy depend.m4. It is never actually 51832b578d3Smrg # run, as this mode is specially recognized in the preamble. 51932b578d3Smrg exit 1 52032b578d3Smrg ;; 52132b578d3Smrg 52232b578d3Smrgmakedepend) 52332b578d3Smrg "$@" || exit $? 52432b578d3Smrg # Remove any Libtool call 52532b578d3Smrg if test "$libtool" = yes; then 5262a51b5beSmrg while test "X$1" != 'X--mode=compile'; do 52732b578d3Smrg shift 52832b578d3Smrg done 52932b578d3Smrg shift 53032b578d3Smrg fi 53132b578d3Smrg # X makedepend 53232b578d3Smrg shift 5332a51b5beSmrg cleared=no eat=no 5342a51b5beSmrg for arg 5352a51b5beSmrg do 53632b578d3Smrg case $cleared in 53732b578d3Smrg no) 53832b578d3Smrg set ""; shift 53932b578d3Smrg cleared=yes ;; 54032b578d3Smrg esac 5412a51b5beSmrg if test $eat = yes; then 5422a51b5beSmrg eat=no 5432a51b5beSmrg continue 5442a51b5beSmrg fi 54532b578d3Smrg case "$arg" in 54632b578d3Smrg -D*|-I*) 54732b578d3Smrg set fnord "$@" "$arg"; shift ;; 54832b578d3Smrg # Strip any option that makedepend may not understand. Remove 54932b578d3Smrg # the object too, otherwise makedepend will parse it as a source file. 5502a51b5beSmrg -arch) 5512a51b5beSmrg eat=yes ;; 55232b578d3Smrg -*|$object) 55332b578d3Smrg ;; 55432b578d3Smrg *) 55532b578d3Smrg set fnord "$@" "$arg"; shift ;; 55632b578d3Smrg esac 55732b578d3Smrg done 5582a51b5beSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 55932b578d3Smrg touch "$tmpdepfile" 56032b578d3Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 56132b578d3Smrg rm -f "$depfile" 562e35d4d8eSmrg # makedepend may prepend the VPATH from the source file name to the object. 563e35d4d8eSmrg # No need to regex-escape $object, excess matching of '.' is harmless. 564e35d4d8eSmrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 56532b578d3Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 56632b578d3Smrg' | \ 56732b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 56832b578d3Smrg## correctly. Breaking it into two sed invocations is a workaround. 56932b578d3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 57032b578d3Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 57132b578d3Smrg ;; 57232b578d3Smrg 57332b578d3Smrgcpp) 57432b578d3Smrg # Important note: in order to support this mode, a compiler *must* 57532b578d3Smrg # always write the preprocessed file to stdout. 57632b578d3Smrg "$@" || exit $? 57732b578d3Smrg 57832b578d3Smrg # Remove the call to Libtool. 57932b578d3Smrg if test "$libtool" = yes; then 5802a51b5beSmrg while test "X$1" != 'X--mode=compile'; do 58132b578d3Smrg shift 58232b578d3Smrg done 58332b578d3Smrg shift 58432b578d3Smrg fi 58532b578d3Smrg 58632b578d3Smrg # Remove `-o $object'. 58732b578d3Smrg IFS=" " 58832b578d3Smrg for arg 58932b578d3Smrg do 59032b578d3Smrg case $arg in 59132b578d3Smrg -o) 59232b578d3Smrg shift 59332b578d3Smrg ;; 59432b578d3Smrg $object) 59532b578d3Smrg shift 59632b578d3Smrg ;; 59732b578d3Smrg *) 59832b578d3Smrg set fnord "$@" "$arg" 59932b578d3Smrg shift # fnord 60032b578d3Smrg shift # $arg 60132b578d3Smrg ;; 60232b578d3Smrg esac 60332b578d3Smrg done 60432b578d3Smrg 60532b578d3Smrg "$@" -E | 60632b578d3Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 60732b578d3Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 60832b578d3Smrg sed '$ s: \\$::' > "$tmpdepfile" 60932b578d3Smrg rm -f "$depfile" 61032b578d3Smrg echo "$object : \\" > "$depfile" 61132b578d3Smrg cat < "$tmpdepfile" >> "$depfile" 61232b578d3Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 61332b578d3Smrg rm -f "$tmpdepfile" 61432b578d3Smrg ;; 61532b578d3Smrg 61632b578d3Smrgmsvisualcpp) 61732b578d3Smrg # Important note: in order to support this mode, a compiler *must* 6182a51b5beSmrg # always write the preprocessed file to stdout. 61932b578d3Smrg "$@" || exit $? 6202a51b5beSmrg 6212a51b5beSmrg # Remove the call to Libtool. 6222a51b5beSmrg if test "$libtool" = yes; then 6232a51b5beSmrg while test "X$1" != 'X--mode=compile'; do 6242a51b5beSmrg shift 6252a51b5beSmrg done 6262a51b5beSmrg shift 6272a51b5beSmrg fi 6282a51b5beSmrg 62932b578d3Smrg IFS=" " 63032b578d3Smrg for arg 63132b578d3Smrg do 63232b578d3Smrg case "$arg" in 6332a51b5beSmrg -o) 6342a51b5beSmrg shift 6352a51b5beSmrg ;; 6362a51b5beSmrg $object) 6372a51b5beSmrg shift 6382a51b5beSmrg ;; 63932b578d3Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 64032b578d3Smrg set fnord "$@" 64132b578d3Smrg shift 64232b578d3Smrg shift 64332b578d3Smrg ;; 64432b578d3Smrg *) 64532b578d3Smrg set fnord "$@" "$arg" 64632b578d3Smrg shift 64732b578d3Smrg shift 64832b578d3Smrg ;; 64932b578d3Smrg esac 65032b578d3Smrg done 6512a51b5beSmrg "$@" -E 2>/dev/null | 6522a51b5beSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 65332b578d3Smrg rm -f "$depfile" 65432b578d3Smrg echo "$object : \\" > "$depfile" 6552a51b5beSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 65632b578d3Smrg echo " " >> "$depfile" 6572a51b5beSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 65832b578d3Smrg rm -f "$tmpdepfile" 65932b578d3Smrg ;; 66032b578d3Smrg 6612a51b5beSmrgmsvcmsys) 6622a51b5beSmrg # This case exists only to let depend.m4 do its work. It works by 6632a51b5beSmrg # looking at the text of this script. This case will never be run, 6642a51b5beSmrg # since it is checked for above. 6652a51b5beSmrg exit 1 6662a51b5beSmrg ;; 6672a51b5beSmrg 66832b578d3Smrgnone) 66932b578d3Smrg exec "$@" 67032b578d3Smrg ;; 67132b578d3Smrg 67232b578d3Smrg*) 67332b578d3Smrg echo "Unknown depmode $depmode" 1>&2 67432b578d3Smrg exit 1 67532b578d3Smrg ;; 67632b578d3Smrgesac 67732b578d3Smrg 67832b578d3Smrgexit 0 67932b578d3Smrg 68032b578d3Smrg# Local Variables: 68132b578d3Smrg# mode: shell-script 68232b578d3Smrg# sh-indentation: 2 68332b578d3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 68432b578d3Smrg# time-stamp-start: "scriptversion=" 68532b578d3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6862a51b5beSmrg# time-stamp-time-zone: "UTC" 6872a51b5beSmrg# time-stamp-end: "; # UTC" 68832b578d3Smrg# End: 689