depcomp revision 74c14cd6
172b676d7Smrg#! /bin/sh 272b676d7Smrg# depcomp - compile a program generating dependencies as side-effects 372b676d7Smrg 474c14cd6Smrgscriptversion=2011-12-04.11; # UTC 572b676d7Smrg 674c14cd6Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 774c14cd6Smrg# 2011 Free Software Foundation, Inc. 872b676d7Smrg 972b676d7Smrg# This program is free software; you can redistribute it and/or modify 1072b676d7Smrg# it under the terms of the GNU General Public License as published by 1172b676d7Smrg# the Free Software Foundation; either version 2, or (at your option) 1272b676d7Smrg# any later version. 1372b676d7Smrg 1472b676d7Smrg# This program is distributed in the hope that it will be useful, 1572b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1672b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1772b676d7Smrg# GNU General Public License for more details. 1872b676d7Smrg 1972b676d7Smrg# You should have received a copy of the GNU General Public License 2074c14cd6Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2172b676d7Smrg 2272b676d7Smrg# As a special exception to the GNU General Public License, if you 2372b676d7Smrg# distribute this file as part of a program that contains a 2472b676d7Smrg# configuration script generated by Autoconf, you may include it under 2572b676d7Smrg# the same distribution terms that you use for the rest of that program. 2672b676d7Smrg 2772b676d7Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2872b676d7Smrg 2972b676d7Smrgcase $1 in 3072b676d7Smrg '') 3172b676d7Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3272b676d7Smrg exit 1; 3372b676d7Smrg ;; 3472b676d7Smrg -h | --h*) 3572b676d7Smrg cat <<\EOF 3672b676d7SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3772b676d7Smrg 3872b676d7SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3972b676d7Smrgas side-effects. 4072b676d7Smrg 4172b676d7SmrgEnvironment variables: 4272b676d7Smrg depmode Dependency tracking mode. 4372b676d7Smrg source Source file read by `PROGRAMS ARGS'. 4472b676d7Smrg object Object file output by `PROGRAMS ARGS'. 4572b676d7Smrg DEPDIR directory where to store dependencies. 4672b676d7Smrg depfile Dependency file to output. 4774c14cd6Smrg tmpdepfile Temporary file to use when outputting dependencies. 4872b676d7Smrg libtool Whether libtool is used (yes/no). 4972b676d7Smrg 5072b676d7SmrgReport bugs to <bug-automake@gnu.org>. 5172b676d7SmrgEOF 5272b676d7Smrg exit $? 5372b676d7Smrg ;; 5472b676d7Smrg -v | --v*) 5572b676d7Smrg echo "depcomp $scriptversion" 5672b676d7Smrg exit $? 5772b676d7Smrg ;; 5872b676d7Smrgesac 5972b676d7Smrg 6072b676d7Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6172b676d7Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6272b676d7Smrg exit 1 6372b676d7Smrgfi 6472b676d7Smrg 6572b676d7Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6672b676d7Smrgdepfile=${depfile-`echo "$object" | 6772b676d7Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6872b676d7Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6972b676d7Smrg 7072b676d7Smrgrm -f "$tmpdepfile" 7172b676d7Smrg 7272b676d7Smrg# Some modes work just like other modes, but use different flags. We 7372b676d7Smrg# parameterize here, but still list the modes in the big case below, 7472b676d7Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7572b676d7Smrg# here, because this file can only contain one case statement. 7672b676d7Smrgif test "$depmode" = hp; then 7772b676d7Smrg # HP compiler uses -M and no extra arg. 7872b676d7Smrg gccflag=-M 7972b676d7Smrg depmode=gcc 8072b676d7Smrgfi 8172b676d7Smrg 8272b676d7Smrgif test "$depmode" = dashXmstdout; then 8372b676d7Smrg # This is just like dashmstdout with a different argument. 8472b676d7Smrg dashmflag=-xM 8572b676d7Smrg depmode=dashmstdout 8672b676d7Smrgfi 8772b676d7Smrg 8874c14cd6Smrgcygpath_u="cygpath -u -f -" 8974c14cd6Smrgif test "$depmode" = msvcmsys; then 9074c14cd6Smrg # This is just like msvisualcpp but w/o cygpath translation. 9174c14cd6Smrg # Just convert the backslash-escaped backslashes to single forward 9274c14cd6Smrg # slashes to satisfy depend.m4 9374c14cd6Smrg cygpath_u='sed s,\\\\,/,g' 9474c14cd6Smrg depmode=msvisualcpp 9574c14cd6Smrgfi 9674c14cd6Smrg 9774c14cd6Smrgif test "$depmode" = msvc7msys; then 9874c14cd6Smrg # This is just like msvc7 but w/o cygpath translation. 9974c14cd6Smrg # Just convert the backslash-escaped backslashes to single forward 10074c14cd6Smrg # slashes to satisfy depend.m4 10174c14cd6Smrg cygpath_u='sed s,\\\\,/,g' 10274c14cd6Smrg depmode=msvc7 10374c14cd6Smrgfi 10474c14cd6Smrg 10572b676d7Smrgcase "$depmode" in 10672b676d7Smrggcc3) 10772b676d7Smrg## gcc 3 implements dependency tracking that does exactly what 10872b676d7Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10972b676d7Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1101fd23544Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1111fd23544Smrg## the command line argument order; so add the flags where they 1121fd23544Smrg## appear in depend2.am. Note that the slowdown incurred here 1131fd23544Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1141fd23544Smrg for arg 1151fd23544Smrg do 1161fd23544Smrg case $arg in 1171fd23544Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1181fd23544Smrg *) set fnord "$@" "$arg" ;; 1191fd23544Smrg esac 1201fd23544Smrg shift # fnord 1211fd23544Smrg shift # $arg 1221fd23544Smrg done 1231fd23544Smrg "$@" 12472b676d7Smrg stat=$? 12572b676d7Smrg if test $stat -eq 0; then : 12672b676d7Smrg else 12772b676d7Smrg rm -f "$tmpdepfile" 12872b676d7Smrg exit $stat 12972b676d7Smrg fi 13072b676d7Smrg mv "$tmpdepfile" "$depfile" 13172b676d7Smrg ;; 13272b676d7Smrg 13372b676d7Smrggcc) 13472b676d7Smrg## There are various ways to get dependency output from gcc. Here's 13572b676d7Smrg## why we pick this rather obscure method: 13672b676d7Smrg## - Don't want to use -MD because we'd like the dependencies to end 13772b676d7Smrg## up in a subdir. Having to rename by hand is ugly. 13872b676d7Smrg## (We might end up doing this anyway to support other compilers.) 13972b676d7Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 14072b676d7Smrg## -MM, not -M (despite what the docs say). 14172b676d7Smrg## - Using -M directly means running the compiler twice (even worse 14272b676d7Smrg## than renaming). 14372b676d7Smrg if test -z "$gccflag"; then 14472b676d7Smrg gccflag=-MD, 14572b676d7Smrg fi 14672b676d7Smrg "$@" -Wp,"$gccflag$tmpdepfile" 14772b676d7Smrg stat=$? 14872b676d7Smrg if test $stat -eq 0; then : 14972b676d7Smrg else 15072b676d7Smrg rm -f "$tmpdepfile" 15172b676d7Smrg exit $stat 15272b676d7Smrg fi 15372b676d7Smrg rm -f "$depfile" 15472b676d7Smrg echo "$object : \\" > "$depfile" 15572b676d7Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 15672b676d7Smrg## The second -e expression handles DOS-style file names with drive letters. 15772b676d7Smrg sed -e 's/^[^:]*: / /' \ 15872b676d7Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15972b676d7Smrg## This next piece of magic avoids the `deleted header file' problem. 16072b676d7Smrg## The problem is that when a header file which appears in a .P file 16172b676d7Smrg## is deleted, the dependency causes make to die (because there is 16272b676d7Smrg## typically no way to rebuild the header). We avoid this by adding 16372b676d7Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 16472b676d7Smrg## this for us directly. 16572b676d7Smrg tr ' ' ' 16672b676d7Smrg' < "$tmpdepfile" | 16772b676d7Smrg## Some versions of gcc put a space before the `:'. On the theory 16872b676d7Smrg## that the space means something, we add a space to the output as 16974c14cd6Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 17074c14cd6Smrg## to the object. Take care to not repeat it in the output. 17172b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 17272b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 17374c14cd6Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 17474c14cd6Smrg | sed -e 's/$/ :/' >> "$depfile" 17572b676d7Smrg rm -f "$tmpdepfile" 17672b676d7Smrg ;; 17772b676d7Smrg 17872b676d7Smrghp) 17972b676d7Smrg # This case exists only to let depend.m4 do its work. It works by 18072b676d7Smrg # looking at the text of this script. This case will never be run, 18172b676d7Smrg # since it is checked for above. 18272b676d7Smrg exit 1 18372b676d7Smrg ;; 18472b676d7Smrg 18572b676d7Smrgsgi) 18672b676d7Smrg if test "$libtool" = yes; then 18772b676d7Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 18872b676d7Smrg else 18972b676d7Smrg "$@" -MDupdate "$tmpdepfile" 19072b676d7Smrg fi 19172b676d7Smrg stat=$? 19272b676d7Smrg if test $stat -eq 0; then : 19372b676d7Smrg else 19472b676d7Smrg rm -f "$tmpdepfile" 19572b676d7Smrg exit $stat 19672b676d7Smrg fi 19772b676d7Smrg rm -f "$depfile" 19872b676d7Smrg 19972b676d7Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 20072b676d7Smrg echo "$object : \\" > "$depfile" 20172b676d7Smrg 20272b676d7Smrg # Clip off the initial element (the dependent). Don't try to be 20372b676d7Smrg # clever and replace this with sed code, as IRIX sed won't handle 20472b676d7Smrg # lines with more than a fixed number of characters (4096 in 20572b676d7Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 20672b676d7Smrg # the IRIX cc adds comments like `#:fec' to the end of the 20772b676d7Smrg # dependency line. 20872b676d7Smrg tr ' ' ' 20972b676d7Smrg' < "$tmpdepfile" \ 21072b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 21172b676d7Smrg tr ' 21274c14cd6Smrg' ' ' >> "$depfile" 21374c14cd6Smrg echo >> "$depfile" 21472b676d7Smrg 21572b676d7Smrg # The second pass generates a dummy entry for each header file. 21672b676d7Smrg tr ' ' ' 21772b676d7Smrg' < "$tmpdepfile" \ 21872b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 21974c14cd6Smrg >> "$depfile" 22072b676d7Smrg else 22172b676d7Smrg # The sourcefile does not contain any dependencies, so just 22272b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 22372b676d7Smrg # "include basename.Plo" scheme. 22472b676d7Smrg echo "#dummy" > "$depfile" 22572b676d7Smrg fi 22672b676d7Smrg rm -f "$tmpdepfile" 22772b676d7Smrg ;; 22872b676d7Smrg 22972b676d7Smrgaix) 23072b676d7Smrg # The C for AIX Compiler uses -M and outputs the dependencies 23172b676d7Smrg # in a .u file. In older versions, this file always lives in the 23272b676d7Smrg # current directory. Also, the AIX compiler puts `$object:' at the 23372b676d7Smrg # start of each line; $object doesn't have directory information. 23472b676d7Smrg # Version 6 uses the directory in both cases. 2351fd23544Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2361fd23544Smrg test "x$dir" = "x$object" && dir= 2371fd23544Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 23872b676d7Smrg if test "$libtool" = yes; then 2391fd23544Smrg tmpdepfile1=$dir$base.u 2401fd23544Smrg tmpdepfile2=$base.u 2411fd23544Smrg tmpdepfile3=$dir.libs/$base.u 24272b676d7Smrg "$@" -Wc,-M 24372b676d7Smrg else 2441fd23544Smrg tmpdepfile1=$dir$base.u 2451fd23544Smrg tmpdepfile2=$dir$base.u 2461fd23544Smrg tmpdepfile3=$dir$base.u 24772b676d7Smrg "$@" -M 24872b676d7Smrg fi 24972b676d7Smrg stat=$? 25072b676d7Smrg 25172b676d7Smrg if test $stat -eq 0; then : 25272b676d7Smrg else 2531fd23544Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25472b676d7Smrg exit $stat 25572b676d7Smrg fi 25672b676d7Smrg 2571fd23544Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2581fd23544Smrg do 2591fd23544Smrg test -f "$tmpdepfile" && break 2601fd23544Smrg done 26172b676d7Smrg if test -f "$tmpdepfile"; then 26272b676d7Smrg # Each line is of the form `foo.o: dependent.h'. 26372b676d7Smrg # Do two passes, one to just change these to 26472b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2651fd23544Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2661fd23544Smrg # That's a tab and a space in the []. 2671fd23544Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 26872b676d7Smrg else 26972b676d7Smrg # The sourcefile does not contain any dependencies, so just 27072b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 27172b676d7Smrg # "include basename.Plo" scheme. 27272b676d7Smrg echo "#dummy" > "$depfile" 27372b676d7Smrg fi 27472b676d7Smrg rm -f "$tmpdepfile" 27572b676d7Smrg ;; 27672b676d7Smrg 27772b676d7Smrgicc) 27872b676d7Smrg # Intel's C compiler understands `-MD -MF file'. However on 27972b676d7Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 28072b676d7Smrg # ICC 7.0 will fill foo.d with something like 28172b676d7Smrg # foo.o: sub/foo.c 28272b676d7Smrg # foo.o: sub/foo.h 28372b676d7Smrg # which is wrong. We want: 28472b676d7Smrg # sub/foo.o: sub/foo.c 28572b676d7Smrg # sub/foo.o: sub/foo.h 28672b676d7Smrg # sub/foo.c: 28772b676d7Smrg # sub/foo.h: 28872b676d7Smrg # ICC 7.1 will output 28972b676d7Smrg # foo.o: sub/foo.c sub/foo.h 29072b676d7Smrg # and will wrap long lines using \ : 29172b676d7Smrg # foo.o: sub/foo.c ... \ 29272b676d7Smrg # sub/foo.h ... \ 29372b676d7Smrg # ... 29472b676d7Smrg 29572b676d7Smrg "$@" -MD -MF "$tmpdepfile" 29672b676d7Smrg stat=$? 29772b676d7Smrg if test $stat -eq 0; then : 29872b676d7Smrg else 29972b676d7Smrg rm -f "$tmpdepfile" 30072b676d7Smrg exit $stat 30172b676d7Smrg fi 30272b676d7Smrg rm -f "$depfile" 30372b676d7Smrg # Each line is of the form `foo.o: dependent.h', 30472b676d7Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 30572b676d7Smrg # Do two passes, one to just change these to 30672b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 30772b676d7Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 30872b676d7Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 30972b676d7Smrg # correctly. Breaking it into two sed invocations is a workaround. 31072b676d7Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 31172b676d7Smrg sed -e 's/$/ :/' >> "$depfile" 31272b676d7Smrg rm -f "$tmpdepfile" 31372b676d7Smrg ;; 31472b676d7Smrg 3151fd23544Smrghp2) 3161fd23544Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3171fd23544Smrg # compilers, which have integrated preprocessors. The correct option 3181fd23544Smrg # to use with these is +Maked; it writes dependencies to a file named 3191fd23544Smrg # 'foo.d', which lands next to the object file, wherever that 3201fd23544Smrg # happens to be. 3211fd23544Smrg # Much of this is similar to the tru64 case; see comments there. 3221fd23544Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3231fd23544Smrg test "x$dir" = "x$object" && dir= 3241fd23544Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3251fd23544Smrg if test "$libtool" = yes; then 3261fd23544Smrg tmpdepfile1=$dir$base.d 3271fd23544Smrg tmpdepfile2=$dir.libs/$base.d 3281fd23544Smrg "$@" -Wc,+Maked 3291fd23544Smrg else 3301fd23544Smrg tmpdepfile1=$dir$base.d 3311fd23544Smrg tmpdepfile2=$dir$base.d 3321fd23544Smrg "$@" +Maked 3331fd23544Smrg fi 3341fd23544Smrg stat=$? 3351fd23544Smrg if test $stat -eq 0; then : 3361fd23544Smrg else 3371fd23544Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3381fd23544Smrg exit $stat 3391fd23544Smrg fi 3401fd23544Smrg 3411fd23544Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3421fd23544Smrg do 3431fd23544Smrg test -f "$tmpdepfile" && break 3441fd23544Smrg done 3451fd23544Smrg if test -f "$tmpdepfile"; then 3461fd23544Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3471fd23544Smrg # Add `dependent.h:' lines. 34874c14cd6Smrg sed -ne '2,${ 34974c14cd6Smrg s/^ *// 35074c14cd6Smrg s/ \\*$// 35174c14cd6Smrg s/$/:/ 35274c14cd6Smrg p 35374c14cd6Smrg }' "$tmpdepfile" >> "$depfile" 3541fd23544Smrg else 3551fd23544Smrg echo "#dummy" > "$depfile" 3561fd23544Smrg fi 3571fd23544Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3581fd23544Smrg ;; 3591fd23544Smrg 36072b676d7Smrgtru64) 36172b676d7Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 36272b676d7Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 36372b676d7Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 36472b676d7Smrg # dependencies in `foo.d' instead, so we check for that too. 36572b676d7Smrg # Subdirectories are respected. 36672b676d7Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 36772b676d7Smrg test "x$dir" = "x$object" && dir= 36872b676d7Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 36972b676d7Smrg 37072b676d7Smrg if test "$libtool" = yes; then 37172b676d7Smrg # With Tru64 cc, shared objects can also be used to make a 3721fd23544Smrg # static library. This mechanism is used in libtool 1.4 series to 37372b676d7Smrg # handle both shared and static libraries in a single compilation. 37472b676d7Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 37572b676d7Smrg # 37672b676d7Smrg # With libtool 1.5 this exception was removed, and libtool now 37772b676d7Smrg # generates 2 separate objects for the 2 libraries. These two 3781fd23544Smrg # compilations output dependencies in $dir.libs/$base.o.d and 37972b676d7Smrg # in $dir$base.o.d. We have to check for both files, because 38072b676d7Smrg # one of the two compilations can be disabled. We should prefer 38172b676d7Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 38272b676d7Smrg # automatically cleaned when .libs/ is deleted, while ignoring 38372b676d7Smrg # the former would cause a distcleancheck panic. 38472b676d7Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 38572b676d7Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 38672b676d7Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 38772b676d7Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 38872b676d7Smrg "$@" -Wc,-MD 38972b676d7Smrg else 39072b676d7Smrg tmpdepfile1=$dir$base.o.d 39172b676d7Smrg tmpdepfile2=$dir$base.d 39272b676d7Smrg tmpdepfile3=$dir$base.d 39372b676d7Smrg tmpdepfile4=$dir$base.d 39472b676d7Smrg "$@" -MD 39572b676d7Smrg fi 39672b676d7Smrg 39772b676d7Smrg stat=$? 39872b676d7Smrg if test $stat -eq 0; then : 39972b676d7Smrg else 40072b676d7Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40172b676d7Smrg exit $stat 40272b676d7Smrg fi 40372b676d7Smrg 40472b676d7Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40572b676d7Smrg do 40672b676d7Smrg test -f "$tmpdepfile" && break 40772b676d7Smrg done 40872b676d7Smrg if test -f "$tmpdepfile"; then 40972b676d7Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 41072b676d7Smrg # That's a tab and a space in the []. 41172b676d7Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 41272b676d7Smrg else 41372b676d7Smrg echo "#dummy" > "$depfile" 41472b676d7Smrg fi 41572b676d7Smrg rm -f "$tmpdepfile" 41672b676d7Smrg ;; 41772b676d7Smrg 41874c14cd6Smrgmsvc7) 41974c14cd6Smrg if test "$libtool" = yes; then 42074c14cd6Smrg showIncludes=-Wc,-showIncludes 42174c14cd6Smrg else 42274c14cd6Smrg showIncludes=-showIncludes 42374c14cd6Smrg fi 42474c14cd6Smrg "$@" $showIncludes > "$tmpdepfile" 42574c14cd6Smrg stat=$? 42674c14cd6Smrg grep -v '^Note: including file: ' "$tmpdepfile" 42774c14cd6Smrg if test "$stat" = 0; then : 42874c14cd6Smrg else 42974c14cd6Smrg rm -f "$tmpdepfile" 43074c14cd6Smrg exit $stat 43174c14cd6Smrg fi 43274c14cd6Smrg rm -f "$depfile" 43374c14cd6Smrg echo "$object : \\" > "$depfile" 43474c14cd6Smrg # The first sed program below extracts the file names and escapes 43574c14cd6Smrg # backslashes for cygpath. The second sed program outputs the file 43674c14cd6Smrg # name when reading, but also accumulates all include files in the 43774c14cd6Smrg # hold buffer in order to output them again at the end. This only 43874c14cd6Smrg # works with sed implementations that can handle large buffers. 43974c14cd6Smrg sed < "$tmpdepfile" -n ' 44074c14cd6Smrg/^Note: including file: *\(.*\)/ { 44174c14cd6Smrg s//\1/ 44274c14cd6Smrg s/\\/\\\\/g 44374c14cd6Smrg p 44474c14cd6Smrg}' | $cygpath_u | sort -u | sed -n ' 44574c14cd6Smrgs/ /\\ /g 44674c14cd6Smrgs/\(.*\)/ \1 \\/p 44774c14cd6Smrgs/.\(.*\) \\/\1:/ 44874c14cd6SmrgH 44974c14cd6Smrg$ { 45074c14cd6Smrg s/.*/ / 45174c14cd6Smrg G 45274c14cd6Smrg p 45374c14cd6Smrg}' >> "$depfile" 45474c14cd6Smrg rm -f "$tmpdepfile" 45574c14cd6Smrg ;; 45674c14cd6Smrg 45774c14cd6Smrgmsvc7msys) 45874c14cd6Smrg # This case exists only to let depend.m4 do its work. It works by 45974c14cd6Smrg # looking at the text of this script. This case will never be run, 46074c14cd6Smrg # since it is checked for above. 46174c14cd6Smrg exit 1 46274c14cd6Smrg ;; 46374c14cd6Smrg 46472b676d7Smrg#nosideeffect) 46572b676d7Smrg # This comment above is used by automake to tell side-effect 46672b676d7Smrg # dependency tracking mechanisms from slower ones. 46772b676d7Smrg 46872b676d7Smrgdashmstdout) 46972b676d7Smrg # Important note: in order to support this mode, a compiler *must* 47072b676d7Smrg # always write the preprocessed file to stdout, regardless of -o. 47172b676d7Smrg "$@" || exit $? 47272b676d7Smrg 47372b676d7Smrg # Remove the call to Libtool. 47472b676d7Smrg if test "$libtool" = yes; then 47574c14cd6Smrg while test "X$1" != 'X--mode=compile'; do 47672b676d7Smrg shift 47772b676d7Smrg done 47872b676d7Smrg shift 47972b676d7Smrg fi 48072b676d7Smrg 48172b676d7Smrg # Remove `-o $object'. 48272b676d7Smrg IFS=" " 48372b676d7Smrg for arg 48472b676d7Smrg do 48572b676d7Smrg case $arg in 48672b676d7Smrg -o) 48772b676d7Smrg shift 48872b676d7Smrg ;; 48972b676d7Smrg $object) 49072b676d7Smrg shift 49172b676d7Smrg ;; 49272b676d7Smrg *) 49372b676d7Smrg set fnord "$@" "$arg" 49472b676d7Smrg shift # fnord 49572b676d7Smrg shift # $arg 49672b676d7Smrg ;; 49772b676d7Smrg esac 49872b676d7Smrg done 49972b676d7Smrg 50072b676d7Smrg test -z "$dashmflag" && dashmflag=-M 50172b676d7Smrg # Require at least two characters before searching for `:' 50272b676d7Smrg # in the target name. This is to cope with DOS-style filenames: 50372b676d7Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 50472b676d7Smrg "$@" $dashmflag | 50572b676d7Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 50672b676d7Smrg rm -f "$depfile" 50772b676d7Smrg cat < "$tmpdepfile" > "$depfile" 50872b676d7Smrg tr ' ' ' 50972b676d7Smrg' < "$tmpdepfile" | \ 51072b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51172b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 51272b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51372b676d7Smrg rm -f "$tmpdepfile" 51472b676d7Smrg ;; 51572b676d7Smrg 51672b676d7SmrgdashXmstdout) 51772b676d7Smrg # This case only exists to satisfy depend.m4. It is never actually 51872b676d7Smrg # run, as this mode is specially recognized in the preamble. 51972b676d7Smrg exit 1 52072b676d7Smrg ;; 52172b676d7Smrg 52272b676d7Smrgmakedepend) 52372b676d7Smrg "$@" || exit $? 52472b676d7Smrg # Remove any Libtool call 52572b676d7Smrg if test "$libtool" = yes; then 52674c14cd6Smrg while test "X$1" != 'X--mode=compile'; do 52772b676d7Smrg shift 52872b676d7Smrg done 52972b676d7Smrg shift 53072b676d7Smrg fi 53172b676d7Smrg # X makedepend 53272b676d7Smrg shift 53374c14cd6Smrg cleared=no eat=no 53474c14cd6Smrg for arg 53574c14cd6Smrg do 53672b676d7Smrg case $cleared in 53772b676d7Smrg no) 53872b676d7Smrg set ""; shift 53972b676d7Smrg cleared=yes ;; 54072b676d7Smrg esac 54174c14cd6Smrg if test $eat = yes; then 54274c14cd6Smrg eat=no 54374c14cd6Smrg continue 54474c14cd6Smrg fi 54572b676d7Smrg case "$arg" in 54672b676d7Smrg -D*|-I*) 54772b676d7Smrg set fnord "$@" "$arg"; shift ;; 54872b676d7Smrg # Strip any option that makedepend may not understand. Remove 54972b676d7Smrg # the object too, otherwise makedepend will parse it as a source file. 55074c14cd6Smrg -arch) 55174c14cd6Smrg eat=yes ;; 55272b676d7Smrg -*|$object) 55372b676d7Smrg ;; 55472b676d7Smrg *) 55572b676d7Smrg set fnord "$@" "$arg"; shift ;; 55672b676d7Smrg esac 55772b676d7Smrg done 55874c14cd6Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 55972b676d7Smrg touch "$tmpdepfile" 56072b676d7Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 56172b676d7Smrg rm -f "$depfile" 56274c14cd6Smrg # makedepend may prepend the VPATH from the source file name to the object. 56374c14cd6Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 56474c14cd6Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 56572b676d7Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 56672b676d7Smrg' | \ 56772b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 56872b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 56972b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 57072b676d7Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 57172b676d7Smrg ;; 57272b676d7Smrg 57372b676d7Smrgcpp) 57472b676d7Smrg # Important note: in order to support this mode, a compiler *must* 57572b676d7Smrg # always write the preprocessed file to stdout. 57672b676d7Smrg "$@" || exit $? 57772b676d7Smrg 57872b676d7Smrg # Remove the call to Libtool. 57972b676d7Smrg if test "$libtool" = yes; then 58074c14cd6Smrg while test "X$1" != 'X--mode=compile'; do 58172b676d7Smrg shift 58272b676d7Smrg done 58372b676d7Smrg shift 58472b676d7Smrg fi 58572b676d7Smrg 58672b676d7Smrg # Remove `-o $object'. 58772b676d7Smrg IFS=" " 58872b676d7Smrg for arg 58972b676d7Smrg do 59072b676d7Smrg case $arg in 59172b676d7Smrg -o) 59272b676d7Smrg shift 59372b676d7Smrg ;; 59472b676d7Smrg $object) 59572b676d7Smrg shift 59672b676d7Smrg ;; 59772b676d7Smrg *) 59872b676d7Smrg set fnord "$@" "$arg" 59972b676d7Smrg shift # fnord 60072b676d7Smrg shift # $arg 60172b676d7Smrg ;; 60272b676d7Smrg esac 60372b676d7Smrg done 60472b676d7Smrg 60572b676d7Smrg "$@" -E | 60672b676d7Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 60772b676d7Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 60872b676d7Smrg sed '$ s: \\$::' > "$tmpdepfile" 60972b676d7Smrg rm -f "$depfile" 61072b676d7Smrg echo "$object : \\" > "$depfile" 61172b676d7Smrg cat < "$tmpdepfile" >> "$depfile" 61272b676d7Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 61372b676d7Smrg rm -f "$tmpdepfile" 61472b676d7Smrg ;; 61572b676d7Smrg 61672b676d7Smrgmsvisualcpp) 61772b676d7Smrg # Important note: in order to support this mode, a compiler *must* 61874c14cd6Smrg # always write the preprocessed file to stdout. 61972b676d7Smrg "$@" || exit $? 62074c14cd6Smrg 62174c14cd6Smrg # Remove the call to Libtool. 62274c14cd6Smrg if test "$libtool" = yes; then 62374c14cd6Smrg while test "X$1" != 'X--mode=compile'; do 62474c14cd6Smrg shift 62574c14cd6Smrg done 62674c14cd6Smrg shift 62774c14cd6Smrg fi 62874c14cd6Smrg 62972b676d7Smrg IFS=" " 63072b676d7Smrg for arg 63172b676d7Smrg do 63272b676d7Smrg case "$arg" in 63374c14cd6Smrg -o) 63474c14cd6Smrg shift 63574c14cd6Smrg ;; 63674c14cd6Smrg $object) 63774c14cd6Smrg shift 63874c14cd6Smrg ;; 63972b676d7Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 64072b676d7Smrg set fnord "$@" 64172b676d7Smrg shift 64272b676d7Smrg shift 64372b676d7Smrg ;; 64472b676d7Smrg *) 64572b676d7Smrg set fnord "$@" "$arg" 64672b676d7Smrg shift 64772b676d7Smrg shift 64872b676d7Smrg ;; 64972b676d7Smrg esac 65072b676d7Smrg done 65174c14cd6Smrg "$@" -E 2>/dev/null | 65274c14cd6Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 65372b676d7Smrg rm -f "$depfile" 65472b676d7Smrg echo "$object : \\" > "$depfile" 65574c14cd6Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 65672b676d7Smrg echo " " >> "$depfile" 65774c14cd6Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 65872b676d7Smrg rm -f "$tmpdepfile" 65972b676d7Smrg ;; 66072b676d7Smrg 66174c14cd6Smrgmsvcmsys) 66274c14cd6Smrg # This case exists only to let depend.m4 do its work. It works by 66374c14cd6Smrg # looking at the text of this script. This case will never be run, 66474c14cd6Smrg # since it is checked for above. 66574c14cd6Smrg exit 1 66674c14cd6Smrg ;; 66774c14cd6Smrg 66872b676d7Smrgnone) 66972b676d7Smrg exec "$@" 67072b676d7Smrg ;; 67172b676d7Smrg 67272b676d7Smrg*) 67372b676d7Smrg echo "Unknown depmode $depmode" 1>&2 67472b676d7Smrg exit 1 67572b676d7Smrg ;; 67672b676d7Smrgesac 67772b676d7Smrg 67872b676d7Smrgexit 0 67972b676d7Smrg 68072b676d7Smrg# Local Variables: 68172b676d7Smrg# mode: shell-script 68272b676d7Smrg# sh-indentation: 2 68372b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 68472b676d7Smrg# time-stamp-start: "scriptversion=" 68572b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 68674c14cd6Smrg# time-stamp-time-zone: "UTC" 68774c14cd6Smrg# time-stamp-end: "; # UTC" 68872b676d7Smrg# End: 689