depcomp revision 17a48c7c
117a48c7cSmrg#! /bin/sh 217a48c7cSmrg# depcomp - compile a program generating dependencies as side-effects 317a48c7cSmrg 417a48c7cSmrgscriptversion=2005-07-09.11 517a48c7cSmrg 617a48c7cSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 717a48c7cSmrg 817a48c7cSmrg# This program is free software; you can redistribute it and/or modify 917a48c7cSmrg# it under the terms of the GNU General Public License as published by 1017a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option) 1117a48c7cSmrg# any later version. 1217a48c7cSmrg 1317a48c7cSmrg# This program is distributed in the hope that it will be useful, 1417a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1517a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1617a48c7cSmrg# GNU General Public License for more details. 1717a48c7cSmrg 1817a48c7cSmrg# You should have received a copy of the GNU General Public License 1917a48c7cSmrg# along with this program; if not, write to the Free Software 2017a48c7cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2117a48c7cSmrg# 02110-1301, USA. 2217a48c7cSmrg 2317a48c7cSmrg# As a special exception to the GNU General Public License, if you 2417a48c7cSmrg# distribute this file as part of a program that contains a 2517a48c7cSmrg# configuration script generated by Autoconf, you may include it under 2617a48c7cSmrg# the same distribution terms that you use for the rest of that program. 2717a48c7cSmrg 2817a48c7cSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2917a48c7cSmrg 3017a48c7cSmrgcase $1 in 3117a48c7cSmrg '') 3217a48c7cSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3317a48c7cSmrg exit 1; 3417a48c7cSmrg ;; 3517a48c7cSmrg -h | --h*) 3617a48c7cSmrg cat <<\EOF 3717a48c7cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3817a48c7cSmrg 3917a48c7cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 4017a48c7cSmrgas side-effects. 4117a48c7cSmrg 4217a48c7cSmrgEnvironment variables: 4317a48c7cSmrg depmode Dependency tracking mode. 4417a48c7cSmrg source Source file read by `PROGRAMS ARGS'. 4517a48c7cSmrg object Object file output by `PROGRAMS ARGS'. 4617a48c7cSmrg DEPDIR directory where to store dependencies. 4717a48c7cSmrg depfile Dependency file to output. 4817a48c7cSmrg tmpdepfile Temporary file to use when outputing dependencies. 4917a48c7cSmrg libtool Whether libtool is used (yes/no). 5017a48c7cSmrg 5117a48c7cSmrgReport bugs to <bug-automake@gnu.org>. 5217a48c7cSmrgEOF 5317a48c7cSmrg exit $? 5417a48c7cSmrg ;; 5517a48c7cSmrg -v | --v*) 5617a48c7cSmrg echo "depcomp $scriptversion" 5717a48c7cSmrg exit $? 5817a48c7cSmrg ;; 5917a48c7cSmrgesac 6017a48c7cSmrg 6117a48c7cSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6217a48c7cSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6317a48c7cSmrg exit 1 6417a48c7cSmrgfi 6517a48c7cSmrg 6617a48c7cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6717a48c7cSmrgdepfile=${depfile-`echo "$object" | 6817a48c7cSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6917a48c7cSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 7017a48c7cSmrg 7117a48c7cSmrgrm -f "$tmpdepfile" 7217a48c7cSmrg 7317a48c7cSmrg# Some modes work just like other modes, but use different flags. We 7417a48c7cSmrg# parameterize here, but still list the modes in the big case below, 7517a48c7cSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7617a48c7cSmrg# here, because this file can only contain one case statement. 7717a48c7cSmrgif test "$depmode" = hp; then 7817a48c7cSmrg # HP compiler uses -M and no extra arg. 7917a48c7cSmrg gccflag=-M 8017a48c7cSmrg depmode=gcc 8117a48c7cSmrgfi 8217a48c7cSmrg 8317a48c7cSmrgif test "$depmode" = dashXmstdout; then 8417a48c7cSmrg # This is just like dashmstdout with a different argument. 8517a48c7cSmrg dashmflag=-xM 8617a48c7cSmrg depmode=dashmstdout 8717a48c7cSmrgfi 8817a48c7cSmrg 8917a48c7cSmrgcase "$depmode" in 9017a48c7cSmrggcc3) 9117a48c7cSmrg## gcc 3 implements dependency tracking that does exactly what 9217a48c7cSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 9317a48c7cSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 9417a48c7cSmrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 9517a48c7cSmrg stat=$? 9617a48c7cSmrg if test $stat -eq 0; then : 9717a48c7cSmrg else 9817a48c7cSmrg rm -f "$tmpdepfile" 9917a48c7cSmrg exit $stat 10017a48c7cSmrg fi 10117a48c7cSmrg mv "$tmpdepfile" "$depfile" 10217a48c7cSmrg ;; 10317a48c7cSmrg 10417a48c7cSmrggcc) 10517a48c7cSmrg## There are various ways to get dependency output from gcc. Here's 10617a48c7cSmrg## why we pick this rather obscure method: 10717a48c7cSmrg## - Don't want to use -MD because we'd like the dependencies to end 10817a48c7cSmrg## up in a subdir. Having to rename by hand is ugly. 10917a48c7cSmrg## (We might end up doing this anyway to support other compilers.) 11017a48c7cSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 11117a48c7cSmrg## -MM, not -M (despite what the docs say). 11217a48c7cSmrg## - Using -M directly means running the compiler twice (even worse 11317a48c7cSmrg## than renaming). 11417a48c7cSmrg if test -z "$gccflag"; then 11517a48c7cSmrg gccflag=-MD, 11617a48c7cSmrg fi 11717a48c7cSmrg "$@" -Wp,"$gccflag$tmpdepfile" 11817a48c7cSmrg stat=$? 11917a48c7cSmrg if test $stat -eq 0; then : 12017a48c7cSmrg else 12117a48c7cSmrg rm -f "$tmpdepfile" 12217a48c7cSmrg exit $stat 12317a48c7cSmrg fi 12417a48c7cSmrg rm -f "$depfile" 12517a48c7cSmrg echo "$object : \\" > "$depfile" 12617a48c7cSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 12717a48c7cSmrg## The second -e expression handles DOS-style file names with drive letters. 12817a48c7cSmrg sed -e 's/^[^:]*: / /' \ 12917a48c7cSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 13017a48c7cSmrg## This next piece of magic avoids the `deleted header file' problem. 13117a48c7cSmrg## The problem is that when a header file which appears in a .P file 13217a48c7cSmrg## is deleted, the dependency causes make to die (because there is 13317a48c7cSmrg## typically no way to rebuild the header). We avoid this by adding 13417a48c7cSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 13517a48c7cSmrg## this for us directly. 13617a48c7cSmrg tr ' ' ' 13717a48c7cSmrg' < "$tmpdepfile" | 13817a48c7cSmrg## Some versions of gcc put a space before the `:'. On the theory 13917a48c7cSmrg## that the space means something, we add a space to the output as 14017a48c7cSmrg## well. 14117a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 14217a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 14317a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 14417a48c7cSmrg rm -f "$tmpdepfile" 14517a48c7cSmrg ;; 14617a48c7cSmrg 14717a48c7cSmrghp) 14817a48c7cSmrg # This case exists only to let depend.m4 do its work. It works by 14917a48c7cSmrg # looking at the text of this script. This case will never be run, 15017a48c7cSmrg # since it is checked for above. 15117a48c7cSmrg exit 1 15217a48c7cSmrg ;; 15317a48c7cSmrg 15417a48c7cSmrgsgi) 15517a48c7cSmrg if test "$libtool" = yes; then 15617a48c7cSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 15717a48c7cSmrg else 15817a48c7cSmrg "$@" -MDupdate "$tmpdepfile" 15917a48c7cSmrg fi 16017a48c7cSmrg stat=$? 16117a48c7cSmrg if test $stat -eq 0; then : 16217a48c7cSmrg else 16317a48c7cSmrg rm -f "$tmpdepfile" 16417a48c7cSmrg exit $stat 16517a48c7cSmrg fi 16617a48c7cSmrg rm -f "$depfile" 16717a48c7cSmrg 16817a48c7cSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 16917a48c7cSmrg echo "$object : \\" > "$depfile" 17017a48c7cSmrg 17117a48c7cSmrg # Clip off the initial element (the dependent). Don't try to be 17217a48c7cSmrg # clever and replace this with sed code, as IRIX sed won't handle 17317a48c7cSmrg # lines with more than a fixed number of characters (4096 in 17417a48c7cSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 17517a48c7cSmrg # the IRIX cc adds comments like `#:fec' to the end of the 17617a48c7cSmrg # dependency line. 17717a48c7cSmrg tr ' ' ' 17817a48c7cSmrg' < "$tmpdepfile" \ 17917a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 18017a48c7cSmrg tr ' 18117a48c7cSmrg' ' ' >> $depfile 18217a48c7cSmrg echo >> $depfile 18317a48c7cSmrg 18417a48c7cSmrg # The second pass generates a dummy entry for each header file. 18517a48c7cSmrg tr ' ' ' 18617a48c7cSmrg' < "$tmpdepfile" \ 18717a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 18817a48c7cSmrg >> $depfile 18917a48c7cSmrg else 19017a48c7cSmrg # The sourcefile does not contain any dependencies, so just 19117a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 19217a48c7cSmrg # "include basename.Plo" scheme. 19317a48c7cSmrg echo "#dummy" > "$depfile" 19417a48c7cSmrg fi 19517a48c7cSmrg rm -f "$tmpdepfile" 19617a48c7cSmrg ;; 19717a48c7cSmrg 19817a48c7cSmrgaix) 19917a48c7cSmrg # The C for AIX Compiler uses -M and outputs the dependencies 20017a48c7cSmrg # in a .u file. In older versions, this file always lives in the 20117a48c7cSmrg # current directory. Also, the AIX compiler puts `$object:' at the 20217a48c7cSmrg # start of each line; $object doesn't have directory information. 20317a48c7cSmrg # Version 6 uses the directory in both cases. 20417a48c7cSmrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 20517a48c7cSmrg tmpdepfile="$stripped.u" 20617a48c7cSmrg if test "$libtool" = yes; then 20717a48c7cSmrg "$@" -Wc,-M 20817a48c7cSmrg else 20917a48c7cSmrg "$@" -M 21017a48c7cSmrg fi 21117a48c7cSmrg stat=$? 21217a48c7cSmrg 21317a48c7cSmrg if test -f "$tmpdepfile"; then : 21417a48c7cSmrg else 21517a48c7cSmrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 21617a48c7cSmrg tmpdepfile="$stripped.u" 21717a48c7cSmrg fi 21817a48c7cSmrg 21917a48c7cSmrg if test $stat -eq 0; then : 22017a48c7cSmrg else 22117a48c7cSmrg rm -f "$tmpdepfile" 22217a48c7cSmrg exit $stat 22317a48c7cSmrg fi 22417a48c7cSmrg 22517a48c7cSmrg if test -f "$tmpdepfile"; then 22617a48c7cSmrg outname="$stripped.o" 22717a48c7cSmrg # Each line is of the form `foo.o: dependent.h'. 22817a48c7cSmrg # Do two passes, one to just change these to 22917a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 23017a48c7cSmrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 23117a48c7cSmrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 23217a48c7cSmrg else 23317a48c7cSmrg # The sourcefile does not contain any dependencies, so just 23417a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 23517a48c7cSmrg # "include basename.Plo" scheme. 23617a48c7cSmrg echo "#dummy" > "$depfile" 23717a48c7cSmrg fi 23817a48c7cSmrg rm -f "$tmpdepfile" 23917a48c7cSmrg ;; 24017a48c7cSmrg 24117a48c7cSmrgicc) 24217a48c7cSmrg # Intel's C compiler understands `-MD -MF file'. However on 24317a48c7cSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 24417a48c7cSmrg # ICC 7.0 will fill foo.d with something like 24517a48c7cSmrg # foo.o: sub/foo.c 24617a48c7cSmrg # foo.o: sub/foo.h 24717a48c7cSmrg # which is wrong. We want: 24817a48c7cSmrg # sub/foo.o: sub/foo.c 24917a48c7cSmrg # sub/foo.o: sub/foo.h 25017a48c7cSmrg # sub/foo.c: 25117a48c7cSmrg # sub/foo.h: 25217a48c7cSmrg # ICC 7.1 will output 25317a48c7cSmrg # foo.o: sub/foo.c sub/foo.h 25417a48c7cSmrg # and will wrap long lines using \ : 25517a48c7cSmrg # foo.o: sub/foo.c ... \ 25617a48c7cSmrg # sub/foo.h ... \ 25717a48c7cSmrg # ... 25817a48c7cSmrg 25917a48c7cSmrg "$@" -MD -MF "$tmpdepfile" 26017a48c7cSmrg stat=$? 26117a48c7cSmrg if test $stat -eq 0; then : 26217a48c7cSmrg else 26317a48c7cSmrg rm -f "$tmpdepfile" 26417a48c7cSmrg exit $stat 26517a48c7cSmrg fi 26617a48c7cSmrg rm -f "$depfile" 26717a48c7cSmrg # Each line is of the form `foo.o: dependent.h', 26817a48c7cSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 26917a48c7cSmrg # Do two passes, one to just change these to 27017a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 27117a48c7cSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 27217a48c7cSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 27317a48c7cSmrg # correctly. Breaking it into two sed invocations is a workaround. 27417a48c7cSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 27517a48c7cSmrg sed -e 's/$/ :/' >> "$depfile" 27617a48c7cSmrg rm -f "$tmpdepfile" 27717a48c7cSmrg ;; 27817a48c7cSmrg 27917a48c7cSmrgtru64) 28017a48c7cSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 28117a48c7cSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 28217a48c7cSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 28317a48c7cSmrg # dependencies in `foo.d' instead, so we check for that too. 28417a48c7cSmrg # Subdirectories are respected. 28517a48c7cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 28617a48c7cSmrg test "x$dir" = "x$object" && dir= 28717a48c7cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 28817a48c7cSmrg 28917a48c7cSmrg if test "$libtool" = yes; then 29017a48c7cSmrg # With Tru64 cc, shared objects can also be used to make a 29117a48c7cSmrg # static library. This mecanism is used in libtool 1.4 series to 29217a48c7cSmrg # handle both shared and static libraries in a single compilation. 29317a48c7cSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 29417a48c7cSmrg # 29517a48c7cSmrg # With libtool 1.5 this exception was removed, and libtool now 29617a48c7cSmrg # generates 2 separate objects for the 2 libraries. These two 29717a48c7cSmrg # compilations output dependencies in in $dir.libs/$base.o.d and 29817a48c7cSmrg # in $dir$base.o.d. We have to check for both files, because 29917a48c7cSmrg # one of the two compilations can be disabled. We should prefer 30017a48c7cSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 30117a48c7cSmrg # automatically cleaned when .libs/ is deleted, while ignoring 30217a48c7cSmrg # the former would cause a distcleancheck panic. 30317a48c7cSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 30417a48c7cSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 30517a48c7cSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 30617a48c7cSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 30717a48c7cSmrg "$@" -Wc,-MD 30817a48c7cSmrg else 30917a48c7cSmrg tmpdepfile1=$dir$base.o.d 31017a48c7cSmrg tmpdepfile2=$dir$base.d 31117a48c7cSmrg tmpdepfile3=$dir$base.d 31217a48c7cSmrg tmpdepfile4=$dir$base.d 31317a48c7cSmrg "$@" -MD 31417a48c7cSmrg fi 31517a48c7cSmrg 31617a48c7cSmrg stat=$? 31717a48c7cSmrg if test $stat -eq 0; then : 31817a48c7cSmrg else 31917a48c7cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32017a48c7cSmrg exit $stat 32117a48c7cSmrg fi 32217a48c7cSmrg 32317a48c7cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32417a48c7cSmrg do 32517a48c7cSmrg test -f "$tmpdepfile" && break 32617a48c7cSmrg done 32717a48c7cSmrg if test -f "$tmpdepfile"; then 32817a48c7cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 32917a48c7cSmrg # That's a tab and a space in the []. 33017a48c7cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 33117a48c7cSmrg else 33217a48c7cSmrg echo "#dummy" > "$depfile" 33317a48c7cSmrg fi 33417a48c7cSmrg rm -f "$tmpdepfile" 33517a48c7cSmrg ;; 33617a48c7cSmrg 33717a48c7cSmrg#nosideeffect) 33817a48c7cSmrg # This comment above is used by automake to tell side-effect 33917a48c7cSmrg # dependency tracking mechanisms from slower ones. 34017a48c7cSmrg 34117a48c7cSmrgdashmstdout) 34217a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 34317a48c7cSmrg # always write the preprocessed file to stdout, regardless of -o. 34417a48c7cSmrg "$@" || exit $? 34517a48c7cSmrg 34617a48c7cSmrg # Remove the call to Libtool. 34717a48c7cSmrg if test "$libtool" = yes; then 34817a48c7cSmrg while test $1 != '--mode=compile'; do 34917a48c7cSmrg shift 35017a48c7cSmrg done 35117a48c7cSmrg shift 35217a48c7cSmrg fi 35317a48c7cSmrg 35417a48c7cSmrg # Remove `-o $object'. 35517a48c7cSmrg IFS=" " 35617a48c7cSmrg for arg 35717a48c7cSmrg do 35817a48c7cSmrg case $arg in 35917a48c7cSmrg -o) 36017a48c7cSmrg shift 36117a48c7cSmrg ;; 36217a48c7cSmrg $object) 36317a48c7cSmrg shift 36417a48c7cSmrg ;; 36517a48c7cSmrg *) 36617a48c7cSmrg set fnord "$@" "$arg" 36717a48c7cSmrg shift # fnord 36817a48c7cSmrg shift # $arg 36917a48c7cSmrg ;; 37017a48c7cSmrg esac 37117a48c7cSmrg done 37217a48c7cSmrg 37317a48c7cSmrg test -z "$dashmflag" && dashmflag=-M 37417a48c7cSmrg # Require at least two characters before searching for `:' 37517a48c7cSmrg # in the target name. This is to cope with DOS-style filenames: 37617a48c7cSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 37717a48c7cSmrg "$@" $dashmflag | 37817a48c7cSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 37917a48c7cSmrg rm -f "$depfile" 38017a48c7cSmrg cat < "$tmpdepfile" > "$depfile" 38117a48c7cSmrg tr ' ' ' 38217a48c7cSmrg' < "$tmpdepfile" | \ 38317a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 38417a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 38517a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 38617a48c7cSmrg rm -f "$tmpdepfile" 38717a48c7cSmrg ;; 38817a48c7cSmrg 38917a48c7cSmrgdashXmstdout) 39017a48c7cSmrg # This case only exists to satisfy depend.m4. It is never actually 39117a48c7cSmrg # run, as this mode is specially recognized in the preamble. 39217a48c7cSmrg exit 1 39317a48c7cSmrg ;; 39417a48c7cSmrg 39517a48c7cSmrgmakedepend) 39617a48c7cSmrg "$@" || exit $? 39717a48c7cSmrg # Remove any Libtool call 39817a48c7cSmrg if test "$libtool" = yes; then 39917a48c7cSmrg while test $1 != '--mode=compile'; do 40017a48c7cSmrg shift 40117a48c7cSmrg done 40217a48c7cSmrg shift 40317a48c7cSmrg fi 40417a48c7cSmrg # X makedepend 40517a48c7cSmrg shift 40617a48c7cSmrg cleared=no 40717a48c7cSmrg for arg in "$@"; do 40817a48c7cSmrg case $cleared in 40917a48c7cSmrg no) 41017a48c7cSmrg set ""; shift 41117a48c7cSmrg cleared=yes ;; 41217a48c7cSmrg esac 41317a48c7cSmrg case "$arg" in 41417a48c7cSmrg -D*|-I*) 41517a48c7cSmrg set fnord "$@" "$arg"; shift ;; 41617a48c7cSmrg # Strip any option that makedepend may not understand. Remove 41717a48c7cSmrg # the object too, otherwise makedepend will parse it as a source file. 41817a48c7cSmrg -*|$object) 41917a48c7cSmrg ;; 42017a48c7cSmrg *) 42117a48c7cSmrg set fnord "$@" "$arg"; shift ;; 42217a48c7cSmrg esac 42317a48c7cSmrg done 42417a48c7cSmrg obj_suffix="`echo $object | sed 's/^.*\././'`" 42517a48c7cSmrg touch "$tmpdepfile" 42617a48c7cSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 42717a48c7cSmrg rm -f "$depfile" 42817a48c7cSmrg cat < "$tmpdepfile" > "$depfile" 42917a48c7cSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 43017a48c7cSmrg' | \ 43117a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 43217a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 43317a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 43417a48c7cSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 43517a48c7cSmrg ;; 43617a48c7cSmrg 43717a48c7cSmrgcpp) 43817a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 43917a48c7cSmrg # always write the preprocessed file to stdout. 44017a48c7cSmrg "$@" || exit $? 44117a48c7cSmrg 44217a48c7cSmrg # Remove the call to Libtool. 44317a48c7cSmrg if test "$libtool" = yes; then 44417a48c7cSmrg while test $1 != '--mode=compile'; do 44517a48c7cSmrg shift 44617a48c7cSmrg done 44717a48c7cSmrg shift 44817a48c7cSmrg fi 44917a48c7cSmrg 45017a48c7cSmrg # Remove `-o $object'. 45117a48c7cSmrg IFS=" " 45217a48c7cSmrg for arg 45317a48c7cSmrg do 45417a48c7cSmrg case $arg in 45517a48c7cSmrg -o) 45617a48c7cSmrg shift 45717a48c7cSmrg ;; 45817a48c7cSmrg $object) 45917a48c7cSmrg shift 46017a48c7cSmrg ;; 46117a48c7cSmrg *) 46217a48c7cSmrg set fnord "$@" "$arg" 46317a48c7cSmrg shift # fnord 46417a48c7cSmrg shift # $arg 46517a48c7cSmrg ;; 46617a48c7cSmrg esac 46717a48c7cSmrg done 46817a48c7cSmrg 46917a48c7cSmrg "$@" -E | 47017a48c7cSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 47117a48c7cSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 47217a48c7cSmrg sed '$ s: \\$::' > "$tmpdepfile" 47317a48c7cSmrg rm -f "$depfile" 47417a48c7cSmrg echo "$object : \\" > "$depfile" 47517a48c7cSmrg cat < "$tmpdepfile" >> "$depfile" 47617a48c7cSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 47717a48c7cSmrg rm -f "$tmpdepfile" 47817a48c7cSmrg ;; 47917a48c7cSmrg 48017a48c7cSmrgmsvisualcpp) 48117a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 48217a48c7cSmrg # always write the preprocessed file to stdout, regardless of -o, 48317a48c7cSmrg # because we must use -o when running libtool. 48417a48c7cSmrg "$@" || exit $? 48517a48c7cSmrg IFS=" " 48617a48c7cSmrg for arg 48717a48c7cSmrg do 48817a48c7cSmrg case "$arg" in 48917a48c7cSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 49017a48c7cSmrg set fnord "$@" 49117a48c7cSmrg shift 49217a48c7cSmrg shift 49317a48c7cSmrg ;; 49417a48c7cSmrg *) 49517a48c7cSmrg set fnord "$@" "$arg" 49617a48c7cSmrg shift 49717a48c7cSmrg shift 49817a48c7cSmrg ;; 49917a48c7cSmrg esac 50017a48c7cSmrg done 50117a48c7cSmrg "$@" -E | 50217a48c7cSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 50317a48c7cSmrg rm -f "$depfile" 50417a48c7cSmrg echo "$object : \\" > "$depfile" 50517a48c7cSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 50617a48c7cSmrg echo " " >> "$depfile" 50717a48c7cSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 50817a48c7cSmrg rm -f "$tmpdepfile" 50917a48c7cSmrg ;; 51017a48c7cSmrg 51117a48c7cSmrgnone) 51217a48c7cSmrg exec "$@" 51317a48c7cSmrg ;; 51417a48c7cSmrg 51517a48c7cSmrg*) 51617a48c7cSmrg echo "Unknown depmode $depmode" 1>&2 51717a48c7cSmrg exit 1 51817a48c7cSmrg ;; 51917a48c7cSmrgesac 52017a48c7cSmrg 52117a48c7cSmrgexit 0 52217a48c7cSmrg 52317a48c7cSmrg# Local Variables: 52417a48c7cSmrg# mode: shell-script 52517a48c7cSmrg# sh-indentation: 2 52617a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 52717a48c7cSmrg# time-stamp-start: "scriptversion=" 52817a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 52917a48c7cSmrg# time-stamp-end: "$" 53017a48c7cSmrg# End: 531