depcomp revision 72b676d7
172b676d7Smrg#! /bin/sh 272b676d7Smrg# depcomp - compile a program generating dependencies as side-effects 372b676d7Smrg 472b676d7Smrgscriptversion=2005-07-09.11 572b676d7Smrg 672b676d7Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 772b676d7Smrg 872b676d7Smrg# This program is free software; you can redistribute it and/or modify 972b676d7Smrg# it under the terms of the GNU General Public License as published by 1072b676d7Smrg# the Free Software Foundation; either version 2, or (at your option) 1172b676d7Smrg# any later version. 1272b676d7Smrg 1372b676d7Smrg# This program is distributed in the hope that it will be useful, 1472b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1572b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1672b676d7Smrg# GNU General Public License for more details. 1772b676d7Smrg 1872b676d7Smrg# You should have received a copy of the GNU General Public License 1972b676d7Smrg# along with this program; if not, write to the Free Software 2072b676d7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2172b676d7Smrg# 02110-1301, USA. 2272b676d7Smrg 2372b676d7Smrg# As a special exception to the GNU General Public License, if you 2472b676d7Smrg# distribute this file as part of a program that contains a 2572b676d7Smrg# configuration script generated by Autoconf, you may include it under 2672b676d7Smrg# the same distribution terms that you use for the rest of that program. 2772b676d7Smrg 2872b676d7Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2972b676d7Smrg 3072b676d7Smrgcase $1 in 3172b676d7Smrg '') 3272b676d7Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3372b676d7Smrg exit 1; 3472b676d7Smrg ;; 3572b676d7Smrg -h | --h*) 3672b676d7Smrg cat <<\EOF 3772b676d7SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3872b676d7Smrg 3972b676d7SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 4072b676d7Smrgas side-effects. 4172b676d7Smrg 4272b676d7SmrgEnvironment variables: 4372b676d7Smrg depmode Dependency tracking mode. 4472b676d7Smrg source Source file read by `PROGRAMS ARGS'. 4572b676d7Smrg object Object file output by `PROGRAMS ARGS'. 4672b676d7Smrg DEPDIR directory where to store dependencies. 4772b676d7Smrg depfile Dependency file to output. 4872b676d7Smrg tmpdepfile Temporary file to use when outputing dependencies. 4972b676d7Smrg libtool Whether libtool is used (yes/no). 5072b676d7Smrg 5172b676d7SmrgReport bugs to <bug-automake@gnu.org>. 5272b676d7SmrgEOF 5372b676d7Smrg exit $? 5472b676d7Smrg ;; 5572b676d7Smrg -v | --v*) 5672b676d7Smrg echo "depcomp $scriptversion" 5772b676d7Smrg exit $? 5872b676d7Smrg ;; 5972b676d7Smrgesac 6072b676d7Smrg 6172b676d7Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6272b676d7Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6372b676d7Smrg exit 1 6472b676d7Smrgfi 6572b676d7Smrg 6672b676d7Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6772b676d7Smrgdepfile=${depfile-`echo "$object" | 6872b676d7Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6972b676d7Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 7072b676d7Smrg 7172b676d7Smrgrm -f "$tmpdepfile" 7272b676d7Smrg 7372b676d7Smrg# Some modes work just like other modes, but use different flags. We 7472b676d7Smrg# parameterize here, but still list the modes in the big case below, 7572b676d7Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7672b676d7Smrg# here, because this file can only contain one case statement. 7772b676d7Smrgif test "$depmode" = hp; then 7872b676d7Smrg # HP compiler uses -M and no extra arg. 7972b676d7Smrg gccflag=-M 8072b676d7Smrg depmode=gcc 8172b676d7Smrgfi 8272b676d7Smrg 8372b676d7Smrgif test "$depmode" = dashXmstdout; then 8472b676d7Smrg # This is just like dashmstdout with a different argument. 8572b676d7Smrg dashmflag=-xM 8672b676d7Smrg depmode=dashmstdout 8772b676d7Smrgfi 8872b676d7Smrg 8972b676d7Smrgcase "$depmode" in 9072b676d7Smrggcc3) 9172b676d7Smrg## gcc 3 implements dependency tracking that does exactly what 9272b676d7Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 9372b676d7Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 9472b676d7Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 9572b676d7Smrg stat=$? 9672b676d7Smrg if test $stat -eq 0; then : 9772b676d7Smrg else 9872b676d7Smrg rm -f "$tmpdepfile" 9972b676d7Smrg exit $stat 10072b676d7Smrg fi 10172b676d7Smrg mv "$tmpdepfile" "$depfile" 10272b676d7Smrg ;; 10372b676d7Smrg 10472b676d7Smrggcc) 10572b676d7Smrg## There are various ways to get dependency output from gcc. Here's 10672b676d7Smrg## why we pick this rather obscure method: 10772b676d7Smrg## - Don't want to use -MD because we'd like the dependencies to end 10872b676d7Smrg## up in a subdir. Having to rename by hand is ugly. 10972b676d7Smrg## (We might end up doing this anyway to support other compilers.) 11072b676d7Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 11172b676d7Smrg## -MM, not -M (despite what the docs say). 11272b676d7Smrg## - Using -M directly means running the compiler twice (even worse 11372b676d7Smrg## than renaming). 11472b676d7Smrg if test -z "$gccflag"; then 11572b676d7Smrg gccflag=-MD, 11672b676d7Smrg fi 11772b676d7Smrg "$@" -Wp,"$gccflag$tmpdepfile" 11872b676d7Smrg stat=$? 11972b676d7Smrg if test $stat -eq 0; then : 12072b676d7Smrg else 12172b676d7Smrg rm -f "$tmpdepfile" 12272b676d7Smrg exit $stat 12372b676d7Smrg fi 12472b676d7Smrg rm -f "$depfile" 12572b676d7Smrg echo "$object : \\" > "$depfile" 12672b676d7Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 12772b676d7Smrg## The second -e expression handles DOS-style file names with drive letters. 12872b676d7Smrg sed -e 's/^[^:]*: / /' \ 12972b676d7Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 13072b676d7Smrg## This next piece of magic avoids the `deleted header file' problem. 13172b676d7Smrg## The problem is that when a header file which appears in a .P file 13272b676d7Smrg## is deleted, the dependency causes make to die (because there is 13372b676d7Smrg## typically no way to rebuild the header). We avoid this by adding 13472b676d7Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 13572b676d7Smrg## this for us directly. 13672b676d7Smrg tr ' ' ' 13772b676d7Smrg' < "$tmpdepfile" | 13872b676d7Smrg## Some versions of gcc put a space before the `:'. On the theory 13972b676d7Smrg## that the space means something, we add a space to the output as 14072b676d7Smrg## well. 14172b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 14272b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 14372b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 14472b676d7Smrg rm -f "$tmpdepfile" 14572b676d7Smrg ;; 14672b676d7Smrg 14772b676d7Smrghp) 14872b676d7Smrg # This case exists only to let depend.m4 do its work. It works by 14972b676d7Smrg # looking at the text of this script. This case will never be run, 15072b676d7Smrg # since it is checked for above. 15172b676d7Smrg exit 1 15272b676d7Smrg ;; 15372b676d7Smrg 15472b676d7Smrgsgi) 15572b676d7Smrg if test "$libtool" = yes; then 15672b676d7Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 15772b676d7Smrg else 15872b676d7Smrg "$@" -MDupdate "$tmpdepfile" 15972b676d7Smrg fi 16072b676d7Smrg stat=$? 16172b676d7Smrg if test $stat -eq 0; then : 16272b676d7Smrg else 16372b676d7Smrg rm -f "$tmpdepfile" 16472b676d7Smrg exit $stat 16572b676d7Smrg fi 16672b676d7Smrg rm -f "$depfile" 16772b676d7Smrg 16872b676d7Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 16972b676d7Smrg echo "$object : \\" > "$depfile" 17072b676d7Smrg 17172b676d7Smrg # Clip off the initial element (the dependent). Don't try to be 17272b676d7Smrg # clever and replace this with sed code, as IRIX sed won't handle 17372b676d7Smrg # lines with more than a fixed number of characters (4096 in 17472b676d7Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 17572b676d7Smrg # the IRIX cc adds comments like `#:fec' to the end of the 17672b676d7Smrg # dependency line. 17772b676d7Smrg tr ' ' ' 17872b676d7Smrg' < "$tmpdepfile" \ 17972b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 18072b676d7Smrg tr ' 18172b676d7Smrg' ' ' >> $depfile 18272b676d7Smrg echo >> $depfile 18372b676d7Smrg 18472b676d7Smrg # The second pass generates a dummy entry for each header file. 18572b676d7Smrg tr ' ' ' 18672b676d7Smrg' < "$tmpdepfile" \ 18772b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 18872b676d7Smrg >> $depfile 18972b676d7Smrg else 19072b676d7Smrg # The sourcefile does not contain any dependencies, so just 19172b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 19272b676d7Smrg # "include basename.Plo" scheme. 19372b676d7Smrg echo "#dummy" > "$depfile" 19472b676d7Smrg fi 19572b676d7Smrg rm -f "$tmpdepfile" 19672b676d7Smrg ;; 19772b676d7Smrg 19872b676d7Smrgaix) 19972b676d7Smrg # The C for AIX Compiler uses -M and outputs the dependencies 20072b676d7Smrg # in a .u file. In older versions, this file always lives in the 20172b676d7Smrg # current directory. Also, the AIX compiler puts `$object:' at the 20272b676d7Smrg # start of each line; $object doesn't have directory information. 20372b676d7Smrg # Version 6 uses the directory in both cases. 20472b676d7Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 20572b676d7Smrg tmpdepfile="$stripped.u" 20672b676d7Smrg if test "$libtool" = yes; then 20772b676d7Smrg "$@" -Wc,-M 20872b676d7Smrg else 20972b676d7Smrg "$@" -M 21072b676d7Smrg fi 21172b676d7Smrg stat=$? 21272b676d7Smrg 21372b676d7Smrg if test -f "$tmpdepfile"; then : 21472b676d7Smrg else 21572b676d7Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 21672b676d7Smrg tmpdepfile="$stripped.u" 21772b676d7Smrg fi 21872b676d7Smrg 21972b676d7Smrg if test $stat -eq 0; then : 22072b676d7Smrg else 22172b676d7Smrg rm -f "$tmpdepfile" 22272b676d7Smrg exit $stat 22372b676d7Smrg fi 22472b676d7Smrg 22572b676d7Smrg if test -f "$tmpdepfile"; then 22672b676d7Smrg outname="$stripped.o" 22772b676d7Smrg # Each line is of the form `foo.o: dependent.h'. 22872b676d7Smrg # Do two passes, one to just change these to 22972b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 23072b676d7Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 23172b676d7Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 23272b676d7Smrg else 23372b676d7Smrg # The sourcefile does not contain any dependencies, so just 23472b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 23572b676d7Smrg # "include basename.Plo" scheme. 23672b676d7Smrg echo "#dummy" > "$depfile" 23772b676d7Smrg fi 23872b676d7Smrg rm -f "$tmpdepfile" 23972b676d7Smrg ;; 24072b676d7Smrg 24172b676d7Smrgicc) 24272b676d7Smrg # Intel's C compiler understands `-MD -MF file'. However on 24372b676d7Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 24472b676d7Smrg # ICC 7.0 will fill foo.d with something like 24572b676d7Smrg # foo.o: sub/foo.c 24672b676d7Smrg # foo.o: sub/foo.h 24772b676d7Smrg # which is wrong. We want: 24872b676d7Smrg # sub/foo.o: sub/foo.c 24972b676d7Smrg # sub/foo.o: sub/foo.h 25072b676d7Smrg # sub/foo.c: 25172b676d7Smrg # sub/foo.h: 25272b676d7Smrg # ICC 7.1 will output 25372b676d7Smrg # foo.o: sub/foo.c sub/foo.h 25472b676d7Smrg # and will wrap long lines using \ : 25572b676d7Smrg # foo.o: sub/foo.c ... \ 25672b676d7Smrg # sub/foo.h ... \ 25772b676d7Smrg # ... 25872b676d7Smrg 25972b676d7Smrg "$@" -MD -MF "$tmpdepfile" 26072b676d7Smrg stat=$? 26172b676d7Smrg if test $stat -eq 0; then : 26272b676d7Smrg else 26372b676d7Smrg rm -f "$tmpdepfile" 26472b676d7Smrg exit $stat 26572b676d7Smrg fi 26672b676d7Smrg rm -f "$depfile" 26772b676d7Smrg # Each line is of the form `foo.o: dependent.h', 26872b676d7Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 26972b676d7Smrg # Do two passes, one to just change these to 27072b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 27172b676d7Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 27272b676d7Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 27372b676d7Smrg # correctly. Breaking it into two sed invocations is a workaround. 27472b676d7Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 27572b676d7Smrg sed -e 's/$/ :/' >> "$depfile" 27672b676d7Smrg rm -f "$tmpdepfile" 27772b676d7Smrg ;; 27872b676d7Smrg 27972b676d7Smrgtru64) 28072b676d7Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 28172b676d7Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 28272b676d7Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 28372b676d7Smrg # dependencies in `foo.d' instead, so we check for that too. 28472b676d7Smrg # Subdirectories are respected. 28572b676d7Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 28672b676d7Smrg test "x$dir" = "x$object" && dir= 28772b676d7Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 28872b676d7Smrg 28972b676d7Smrg if test "$libtool" = yes; then 29072b676d7Smrg # With Tru64 cc, shared objects can also be used to make a 29172b676d7Smrg # static library. This mecanism is used in libtool 1.4 series to 29272b676d7Smrg # handle both shared and static libraries in a single compilation. 29372b676d7Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 29472b676d7Smrg # 29572b676d7Smrg # With libtool 1.5 this exception was removed, and libtool now 29672b676d7Smrg # generates 2 separate objects for the 2 libraries. These two 29772b676d7Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 29872b676d7Smrg # in $dir$base.o.d. We have to check for both files, because 29972b676d7Smrg # one of the two compilations can be disabled. We should prefer 30072b676d7Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 30172b676d7Smrg # automatically cleaned when .libs/ is deleted, while ignoring 30272b676d7Smrg # the former would cause a distcleancheck panic. 30372b676d7Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 30472b676d7Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 30572b676d7Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 30672b676d7Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 30772b676d7Smrg "$@" -Wc,-MD 30872b676d7Smrg else 30972b676d7Smrg tmpdepfile1=$dir$base.o.d 31072b676d7Smrg tmpdepfile2=$dir$base.d 31172b676d7Smrg tmpdepfile3=$dir$base.d 31272b676d7Smrg tmpdepfile4=$dir$base.d 31372b676d7Smrg "$@" -MD 31472b676d7Smrg fi 31572b676d7Smrg 31672b676d7Smrg stat=$? 31772b676d7Smrg if test $stat -eq 0; then : 31872b676d7Smrg else 31972b676d7Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32072b676d7Smrg exit $stat 32172b676d7Smrg fi 32272b676d7Smrg 32372b676d7Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32472b676d7Smrg do 32572b676d7Smrg test -f "$tmpdepfile" && break 32672b676d7Smrg done 32772b676d7Smrg if test -f "$tmpdepfile"; then 32872b676d7Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 32972b676d7Smrg # That's a tab and a space in the []. 33072b676d7Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 33172b676d7Smrg else 33272b676d7Smrg echo "#dummy" > "$depfile" 33372b676d7Smrg fi 33472b676d7Smrg rm -f "$tmpdepfile" 33572b676d7Smrg ;; 33672b676d7Smrg 33772b676d7Smrg#nosideeffect) 33872b676d7Smrg # This comment above is used by automake to tell side-effect 33972b676d7Smrg # dependency tracking mechanisms from slower ones. 34072b676d7Smrg 34172b676d7Smrgdashmstdout) 34272b676d7Smrg # Important note: in order to support this mode, a compiler *must* 34372b676d7Smrg # always write the preprocessed file to stdout, regardless of -o. 34472b676d7Smrg "$@" || exit $? 34572b676d7Smrg 34672b676d7Smrg # Remove the call to Libtool. 34772b676d7Smrg if test "$libtool" = yes; then 34872b676d7Smrg while test $1 != '--mode=compile'; do 34972b676d7Smrg shift 35072b676d7Smrg done 35172b676d7Smrg shift 35272b676d7Smrg fi 35372b676d7Smrg 35472b676d7Smrg # Remove `-o $object'. 35572b676d7Smrg IFS=" " 35672b676d7Smrg for arg 35772b676d7Smrg do 35872b676d7Smrg case $arg in 35972b676d7Smrg -o) 36072b676d7Smrg shift 36172b676d7Smrg ;; 36272b676d7Smrg $object) 36372b676d7Smrg shift 36472b676d7Smrg ;; 36572b676d7Smrg *) 36672b676d7Smrg set fnord "$@" "$arg" 36772b676d7Smrg shift # fnord 36872b676d7Smrg shift # $arg 36972b676d7Smrg ;; 37072b676d7Smrg esac 37172b676d7Smrg done 37272b676d7Smrg 37372b676d7Smrg test -z "$dashmflag" && dashmflag=-M 37472b676d7Smrg # Require at least two characters before searching for `:' 37572b676d7Smrg # in the target name. This is to cope with DOS-style filenames: 37672b676d7Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 37772b676d7Smrg "$@" $dashmflag | 37872b676d7Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 37972b676d7Smrg rm -f "$depfile" 38072b676d7Smrg cat < "$tmpdepfile" > "$depfile" 38172b676d7Smrg tr ' ' ' 38272b676d7Smrg' < "$tmpdepfile" | \ 38372b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 38472b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 38572b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 38672b676d7Smrg rm -f "$tmpdepfile" 38772b676d7Smrg ;; 38872b676d7Smrg 38972b676d7SmrgdashXmstdout) 39072b676d7Smrg # This case only exists to satisfy depend.m4. It is never actually 39172b676d7Smrg # run, as this mode is specially recognized in the preamble. 39272b676d7Smrg exit 1 39372b676d7Smrg ;; 39472b676d7Smrg 39572b676d7Smrgmakedepend) 39672b676d7Smrg "$@" || exit $? 39772b676d7Smrg # Remove any Libtool call 39872b676d7Smrg if test "$libtool" = yes; then 39972b676d7Smrg while test $1 != '--mode=compile'; do 40072b676d7Smrg shift 40172b676d7Smrg done 40272b676d7Smrg shift 40372b676d7Smrg fi 40472b676d7Smrg # X makedepend 40572b676d7Smrg shift 40672b676d7Smrg cleared=no 40772b676d7Smrg for arg in "$@"; do 40872b676d7Smrg case $cleared in 40972b676d7Smrg no) 41072b676d7Smrg set ""; shift 41172b676d7Smrg cleared=yes ;; 41272b676d7Smrg esac 41372b676d7Smrg case "$arg" in 41472b676d7Smrg -D*|-I*) 41572b676d7Smrg set fnord "$@" "$arg"; shift ;; 41672b676d7Smrg # Strip any option that makedepend may not understand. Remove 41772b676d7Smrg # the object too, otherwise makedepend will parse it as a source file. 41872b676d7Smrg -*|$object) 41972b676d7Smrg ;; 42072b676d7Smrg *) 42172b676d7Smrg set fnord "$@" "$arg"; shift ;; 42272b676d7Smrg esac 42372b676d7Smrg done 42472b676d7Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 42572b676d7Smrg touch "$tmpdepfile" 42672b676d7Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 42772b676d7Smrg rm -f "$depfile" 42872b676d7Smrg cat < "$tmpdepfile" > "$depfile" 42972b676d7Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 43072b676d7Smrg' | \ 43172b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 43272b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 43372b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 43472b676d7Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 43572b676d7Smrg ;; 43672b676d7Smrg 43772b676d7Smrgcpp) 43872b676d7Smrg # Important note: in order to support this mode, a compiler *must* 43972b676d7Smrg # always write the preprocessed file to stdout. 44072b676d7Smrg "$@" || exit $? 44172b676d7Smrg 44272b676d7Smrg # Remove the call to Libtool. 44372b676d7Smrg if test "$libtool" = yes; then 44472b676d7Smrg while test $1 != '--mode=compile'; do 44572b676d7Smrg shift 44672b676d7Smrg done 44772b676d7Smrg shift 44872b676d7Smrg fi 44972b676d7Smrg 45072b676d7Smrg # Remove `-o $object'. 45172b676d7Smrg IFS=" " 45272b676d7Smrg for arg 45372b676d7Smrg do 45472b676d7Smrg case $arg in 45572b676d7Smrg -o) 45672b676d7Smrg shift 45772b676d7Smrg ;; 45872b676d7Smrg $object) 45972b676d7Smrg shift 46072b676d7Smrg ;; 46172b676d7Smrg *) 46272b676d7Smrg set fnord "$@" "$arg" 46372b676d7Smrg shift # fnord 46472b676d7Smrg shift # $arg 46572b676d7Smrg ;; 46672b676d7Smrg esac 46772b676d7Smrg done 46872b676d7Smrg 46972b676d7Smrg "$@" -E | 47072b676d7Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 47172b676d7Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 47272b676d7Smrg sed '$ s: \\$::' > "$tmpdepfile" 47372b676d7Smrg rm -f "$depfile" 47472b676d7Smrg echo "$object : \\" > "$depfile" 47572b676d7Smrg cat < "$tmpdepfile" >> "$depfile" 47672b676d7Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 47772b676d7Smrg rm -f "$tmpdepfile" 47872b676d7Smrg ;; 47972b676d7Smrg 48072b676d7Smrgmsvisualcpp) 48172b676d7Smrg # Important note: in order to support this mode, a compiler *must* 48272b676d7Smrg # always write the preprocessed file to stdout, regardless of -o, 48372b676d7Smrg # because we must use -o when running libtool. 48472b676d7Smrg "$@" || exit $? 48572b676d7Smrg IFS=" " 48672b676d7Smrg for arg 48772b676d7Smrg do 48872b676d7Smrg case "$arg" in 48972b676d7Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 49072b676d7Smrg set fnord "$@" 49172b676d7Smrg shift 49272b676d7Smrg shift 49372b676d7Smrg ;; 49472b676d7Smrg *) 49572b676d7Smrg set fnord "$@" "$arg" 49672b676d7Smrg shift 49772b676d7Smrg shift 49872b676d7Smrg ;; 49972b676d7Smrg esac 50072b676d7Smrg done 50172b676d7Smrg "$@" -E | 50272b676d7Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 50372b676d7Smrg rm -f "$depfile" 50472b676d7Smrg echo "$object : \\" > "$depfile" 50572b676d7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 50672b676d7Smrg echo " " >> "$depfile" 50772b676d7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 50872b676d7Smrg rm -f "$tmpdepfile" 50972b676d7Smrg ;; 51072b676d7Smrg 51172b676d7Smrgnone) 51272b676d7Smrg exec "$@" 51372b676d7Smrg ;; 51472b676d7Smrg 51572b676d7Smrg*) 51672b676d7Smrg echo "Unknown depmode $depmode" 1>&2 51772b676d7Smrg exit 1 51872b676d7Smrg ;; 51972b676d7Smrgesac 52072b676d7Smrg 52172b676d7Smrgexit 0 52272b676d7Smrg 52372b676d7Smrg# Local Variables: 52472b676d7Smrg# mode: shell-script 52572b676d7Smrg# sh-indentation: 2 52672b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 52772b676d7Smrg# time-stamp-start: "scriptversion=" 52872b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 52972b676d7Smrg# time-stamp-end: "$" 53072b676d7Smrg# End: 531