Chris@41: #! /bin/sh Chris@41: # depcomp - compile a program generating dependencies as side-effects Chris@41: Chris@41: scriptversion=2009-04-28.21; # UTC Chris@41: Chris@41: # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free Chris@41: # Software Foundation, Inc. Chris@41: Chris@41: # This program is free software; you can redistribute it and/or modify Chris@41: # it under the terms of the GNU General Public License as published by Chris@41: # the Free Software Foundation; either version 2, or (at your option) Chris@41: # any later version. Chris@41: Chris@41: # This program is distributed in the hope that it will be useful, Chris@41: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@41: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@41: # GNU General Public License for more details. Chris@41: Chris@41: # You should have received a copy of the GNU General Public License Chris@41: # along with this program. If not, see . Chris@41: Chris@41: # As a special exception to the GNU General Public License, if you Chris@41: # distribute this file as part of a program that contains a Chris@41: # configuration script generated by Autoconf, you may include it under Chris@41: # the same distribution terms that you use for the rest of that program. Chris@41: Chris@41: # Originally written by Alexandre Oliva . Chris@41: Chris@41: case $1 in Chris@41: '') Chris@41: echo "$0: No command. Try \`$0 --help' for more information." 1>&2 Chris@41: exit 1; Chris@41: ;; Chris@41: -h | --h*) Chris@41: cat <<\EOF Chris@41: Usage: depcomp [--help] [--version] PROGRAM [ARGS] Chris@41: Chris@41: Run PROGRAMS ARGS to compile a file, generating dependencies Chris@41: as side-effects. Chris@41: Chris@41: Environment variables: Chris@41: depmode Dependency tracking mode. Chris@41: source Source file read by `PROGRAMS ARGS'. Chris@41: object Object file output by `PROGRAMS ARGS'. Chris@41: DEPDIR directory where to store dependencies. Chris@41: depfile Dependency file to output. Chris@41: tmpdepfile Temporary file to use when outputing dependencies. Chris@41: libtool Whether libtool is used (yes/no). Chris@41: Chris@41: Report bugs to . Chris@41: EOF Chris@41: exit $? Chris@41: ;; Chris@41: -v | --v*) Chris@41: echo "depcomp $scriptversion" Chris@41: exit $? Chris@41: ;; Chris@41: esac Chris@41: Chris@41: if test -z "$depmode" || test -z "$source" || test -z "$object"; then Chris@41: echo "depcomp: Variables source, object and depmode must be set" 1>&2 Chris@41: exit 1 Chris@41: fi Chris@41: Chris@41: # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. Chris@41: depfile=${depfile-`echo "$object" | Chris@41: sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} Chris@41: tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} Chris@41: Chris@41: rm -f "$tmpdepfile" Chris@41: Chris@41: # Some modes work just like other modes, but use different flags. We Chris@41: # parameterize here, but still list the modes in the big case below, Chris@41: # to make depend.m4 easier to write. Note that we *cannot* use a case Chris@41: # here, because this file can only contain one case statement. Chris@41: if test "$depmode" = hp; then Chris@41: # HP compiler uses -M and no extra arg. Chris@41: gccflag=-M Chris@41: depmode=gcc Chris@41: fi Chris@41: Chris@41: if test "$depmode" = dashXmstdout; then Chris@41: # This is just like dashmstdout with a different argument. Chris@41: dashmflag=-xM Chris@41: depmode=dashmstdout Chris@41: fi Chris@41: Chris@41: cygpath_u="cygpath -u -f -" Chris@41: if test "$depmode" = msvcmsys; then Chris@41: # This is just like msvisualcpp but w/o cygpath translation. Chris@41: # Just convert the backslash-escaped backslashes to single forward Chris@41: # slashes to satisfy depend.m4 Chris@41: cygpath_u="sed s,\\\\\\\\,/,g" Chris@41: depmode=msvisualcpp Chris@41: fi Chris@41: Chris@41: case "$depmode" in Chris@41: gcc3) Chris@41: ## gcc 3 implements dependency tracking that does exactly what Chris@41: ## we want. Yay! Note: for some reason libtool 1.4 doesn't like Chris@41: ## it if -MD -MP comes after the -MF stuff. Hmm. Chris@41: ## Unfortunately, FreeBSD c89 acceptance of flags depends upon Chris@41: ## the command line argument order; so add the flags where they Chris@41: ## appear in depend2.am. Note that the slowdown incurred here Chris@41: ## affects only configure: in makefiles, %FASTDEP% shortcuts this. Chris@41: for arg Chris@41: do Chris@41: case $arg in Chris@41: -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; Chris@41: *) set fnord "$@" "$arg" ;; Chris@41: esac Chris@41: shift # fnord Chris@41: shift # $arg Chris@41: done Chris@41: "$@" Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile" Chris@41: exit $stat Chris@41: fi Chris@41: mv "$tmpdepfile" "$depfile" Chris@41: ;; Chris@41: Chris@41: gcc) Chris@41: ## There are various ways to get dependency output from gcc. Here's Chris@41: ## why we pick this rather obscure method: Chris@41: ## - Don't want to use -MD because we'd like the dependencies to end Chris@41: ## up in a subdir. Having to rename by hand is ugly. Chris@41: ## (We might end up doing this anyway to support other compilers.) Chris@41: ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like Chris@41: ## -MM, not -M (despite what the docs say). Chris@41: ## - Using -M directly means running the compiler twice (even worse Chris@41: ## than renaming). Chris@41: if test -z "$gccflag"; then Chris@41: gccflag=-MD, Chris@41: fi Chris@41: "$@" -Wp,"$gccflag$tmpdepfile" Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile" Chris@41: exit $stat Chris@41: fi Chris@41: rm -f "$depfile" Chris@41: echo "$object : \\" > "$depfile" Chris@41: alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz Chris@41: ## The second -e expression handles DOS-style file names with drive letters. Chris@41: sed -e 's/^[^:]*: / /' \ Chris@41: -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" Chris@41: ## This next piece of magic avoids the `deleted header file' problem. Chris@41: ## The problem is that when a header file which appears in a .P file Chris@41: ## is deleted, the dependency causes make to die (because there is Chris@41: ## typically no way to rebuild the header). We avoid this by adding Chris@41: ## dummy dependencies for each header file. Too bad gcc doesn't do Chris@41: ## this for us directly. Chris@41: tr ' ' ' Chris@41: ' < "$tmpdepfile" | Chris@41: ## Some versions of gcc put a space before the `:'. On the theory Chris@41: ## that the space means something, we add a space to the output as Chris@41: ## well. Chris@41: ## Some versions of the HPUX 10.20 sed can't process this invocation Chris@41: ## correctly. Breaking it into two sed invocations is a workaround. Chris@41: sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: hp) Chris@41: # This case exists only to let depend.m4 do its work. It works by Chris@41: # looking at the text of this script. This case will never be run, Chris@41: # since it is checked for above. Chris@41: exit 1 Chris@41: ;; Chris@41: Chris@41: sgi) Chris@41: if test "$libtool" = yes; then Chris@41: "$@" "-Wp,-MDupdate,$tmpdepfile" Chris@41: else Chris@41: "$@" -MDupdate "$tmpdepfile" Chris@41: fi Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile" Chris@41: exit $stat Chris@41: fi Chris@41: rm -f "$depfile" Chris@41: Chris@41: if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files Chris@41: echo "$object : \\" > "$depfile" Chris@41: Chris@41: # Clip off the initial element (the dependent). Don't try to be Chris@41: # clever and replace this with sed code, as IRIX sed won't handle Chris@41: # lines with more than a fixed number of characters (4096 in Chris@41: # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; Chris@41: # the IRIX cc adds comments like `#:fec' to the end of the Chris@41: # dependency line. Chris@41: tr ' ' ' Chris@41: ' < "$tmpdepfile" \ Chris@41: | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ Chris@41: tr ' Chris@41: ' ' ' >> "$depfile" Chris@41: echo >> "$depfile" Chris@41: Chris@41: # The second pass generates a dummy entry for each header file. Chris@41: tr ' ' ' Chris@41: ' < "$tmpdepfile" \ Chris@41: | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ Chris@41: >> "$depfile" Chris@41: else Chris@41: # The sourcefile does not contain any dependencies, so just Chris@41: # store a dummy comment line, to avoid errors with the Makefile Chris@41: # "include basename.Plo" scheme. Chris@41: echo "#dummy" > "$depfile" Chris@41: fi Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: aix) Chris@41: # The C for AIX Compiler uses -M and outputs the dependencies Chris@41: # in a .u file. In older versions, this file always lives in the Chris@41: # current directory. Also, the AIX compiler puts `$object:' at the Chris@41: # start of each line; $object doesn't have directory information. Chris@41: # Version 6 uses the directory in both cases. Chris@41: dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` Chris@41: test "x$dir" = "x$object" && dir= Chris@41: base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` Chris@41: if test "$libtool" = yes; then Chris@41: tmpdepfile1=$dir$base.u Chris@41: tmpdepfile2=$base.u Chris@41: tmpdepfile3=$dir.libs/$base.u Chris@41: "$@" -Wc,-M Chris@41: else Chris@41: tmpdepfile1=$dir$base.u Chris@41: tmpdepfile2=$dir$base.u Chris@41: tmpdepfile3=$dir$base.u Chris@41: "$@" -M Chris@41: fi Chris@41: stat=$? Chris@41: Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" Chris@41: exit $stat Chris@41: fi Chris@41: Chris@41: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" Chris@41: do Chris@41: test -f "$tmpdepfile" && break Chris@41: done Chris@41: if test -f "$tmpdepfile"; then Chris@41: # Each line is of the form `foo.o: dependent.h'. Chris@41: # Do two passes, one to just change these to Chris@41: # `$object: dependent.h' and one to simply `dependent.h:'. Chris@41: sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" Chris@41: # That's a tab and a space in the []. Chris@41: sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" Chris@41: else Chris@41: # The sourcefile does not contain any dependencies, so just Chris@41: # store a dummy comment line, to avoid errors with the Makefile Chris@41: # "include basename.Plo" scheme. Chris@41: echo "#dummy" > "$depfile" Chris@41: fi Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: icc) Chris@41: # Intel's C compiler understands `-MD -MF file'. However on Chris@41: # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c Chris@41: # ICC 7.0 will fill foo.d with something like Chris@41: # foo.o: sub/foo.c Chris@41: # foo.o: sub/foo.h Chris@41: # which is wrong. We want: Chris@41: # sub/foo.o: sub/foo.c Chris@41: # sub/foo.o: sub/foo.h Chris@41: # sub/foo.c: Chris@41: # sub/foo.h: Chris@41: # ICC 7.1 will output Chris@41: # foo.o: sub/foo.c sub/foo.h Chris@41: # and will wrap long lines using \ : Chris@41: # foo.o: sub/foo.c ... \ Chris@41: # sub/foo.h ... \ Chris@41: # ... Chris@41: Chris@41: "$@" -MD -MF "$tmpdepfile" Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile" Chris@41: exit $stat Chris@41: fi Chris@41: rm -f "$depfile" Chris@41: # Each line is of the form `foo.o: dependent.h', Chris@41: # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. Chris@41: # Do two passes, one to just change these to Chris@41: # `$object: dependent.h' and one to simply `dependent.h:'. Chris@41: sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" Chris@41: # Some versions of the HPUX 10.20 sed can't process this invocation Chris@41: # correctly. Breaking it into two sed invocations is a workaround. Chris@41: sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | Chris@41: sed -e 's/$/ :/' >> "$depfile" Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: hp2) Chris@41: # The "hp" stanza above does not work with aCC (C++) and HP's ia64 Chris@41: # compilers, which have integrated preprocessors. The correct option Chris@41: # to use with these is +Maked; it writes dependencies to a file named Chris@41: # 'foo.d', which lands next to the object file, wherever that Chris@41: # happens to be. Chris@41: # Much of this is similar to the tru64 case; see comments there. Chris@41: dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` Chris@41: test "x$dir" = "x$object" && dir= Chris@41: base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` Chris@41: if test "$libtool" = yes; then Chris@41: tmpdepfile1=$dir$base.d Chris@41: tmpdepfile2=$dir.libs/$base.d Chris@41: "$@" -Wc,+Maked Chris@41: else Chris@41: tmpdepfile1=$dir$base.d Chris@41: tmpdepfile2=$dir$base.d Chris@41: "$@" +Maked Chris@41: fi Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile1" "$tmpdepfile2" Chris@41: exit $stat Chris@41: fi Chris@41: Chris@41: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" Chris@41: do Chris@41: test -f "$tmpdepfile" && break Chris@41: done Chris@41: if test -f "$tmpdepfile"; then Chris@41: sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" Chris@41: # Add `dependent.h:' lines. Chris@41: sed -ne '2,${ Chris@41: s/^ *// Chris@41: s/ \\*$// Chris@41: s/$/:/ Chris@41: p Chris@41: }' "$tmpdepfile" >> "$depfile" Chris@41: else Chris@41: echo "#dummy" > "$depfile" Chris@41: fi Chris@41: rm -f "$tmpdepfile" "$tmpdepfile2" Chris@41: ;; Chris@41: Chris@41: tru64) Chris@41: # The Tru64 compiler uses -MD to generate dependencies as a side Chris@41: # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. Chris@41: # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put Chris@41: # dependencies in `foo.d' instead, so we check for that too. Chris@41: # Subdirectories are respected. Chris@41: dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` Chris@41: test "x$dir" = "x$object" && dir= Chris@41: base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` Chris@41: Chris@41: if test "$libtool" = yes; then Chris@41: # With Tru64 cc, shared objects can also be used to make a Chris@41: # static library. This mechanism is used in libtool 1.4 series to Chris@41: # handle both shared and static libraries in a single compilation. Chris@41: # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. Chris@41: # Chris@41: # With libtool 1.5 this exception was removed, and libtool now Chris@41: # generates 2 separate objects for the 2 libraries. These two Chris@41: # compilations output dependencies in $dir.libs/$base.o.d and Chris@41: # in $dir$base.o.d. We have to check for both files, because Chris@41: # one of the two compilations can be disabled. We should prefer Chris@41: # $dir$base.o.d over $dir.libs/$base.o.d because the latter is Chris@41: # automatically cleaned when .libs/ is deleted, while ignoring Chris@41: # the former would cause a distcleancheck panic. Chris@41: tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 Chris@41: tmpdepfile2=$dir$base.o.d # libtool 1.5 Chris@41: tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 Chris@41: tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 Chris@41: "$@" -Wc,-MD Chris@41: else Chris@41: tmpdepfile1=$dir$base.o.d Chris@41: tmpdepfile2=$dir$base.d Chris@41: tmpdepfile3=$dir$base.d Chris@41: tmpdepfile4=$dir$base.d Chris@41: "$@" -MD Chris@41: fi Chris@41: Chris@41: stat=$? Chris@41: if test $stat -eq 0; then : Chris@41: else Chris@41: rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" Chris@41: exit $stat Chris@41: fi Chris@41: Chris@41: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" Chris@41: do Chris@41: test -f "$tmpdepfile" && break Chris@41: done Chris@41: if test -f "$tmpdepfile"; then Chris@41: sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" Chris@41: # That's a tab and a space in the []. Chris@41: sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" Chris@41: else Chris@41: echo "#dummy" > "$depfile" Chris@41: fi Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: #nosideeffect) Chris@41: # This comment above is used by automake to tell side-effect Chris@41: # dependency tracking mechanisms from slower ones. Chris@41: Chris@41: dashmstdout) Chris@41: # Important note: in order to support this mode, a compiler *must* Chris@41: # always write the preprocessed file to stdout, regardless of -o. Chris@41: "$@" || exit $? Chris@41: Chris@41: # Remove the call to Libtool. Chris@41: if test "$libtool" = yes; then Chris@41: while test "X$1" != 'X--mode=compile'; do Chris@41: shift Chris@41: done Chris@41: shift Chris@41: fi Chris@41: Chris@41: # Remove `-o $object'. Chris@41: IFS=" " Chris@41: for arg Chris@41: do Chris@41: case $arg in Chris@41: -o) Chris@41: shift Chris@41: ;; Chris@41: $object) Chris@41: shift Chris@41: ;; Chris@41: *) Chris@41: set fnord "$@" "$arg" Chris@41: shift # fnord Chris@41: shift # $arg Chris@41: ;; Chris@41: esac Chris@41: done Chris@41: Chris@41: test -z "$dashmflag" && dashmflag=-M Chris@41: # Require at least two characters before searching for `:' Chris@41: # in the target name. This is to cope with DOS-style filenames: Chris@41: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. Chris@41: "$@" $dashmflag | Chris@41: sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" Chris@41: rm -f "$depfile" Chris@41: cat < "$tmpdepfile" > "$depfile" Chris@41: tr ' ' ' Chris@41: ' < "$tmpdepfile" | \ Chris@41: ## Some versions of the HPUX 10.20 sed can't process this invocation Chris@41: ## correctly. Breaking it into two sed invocations is a workaround. Chris@41: sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: dashXmstdout) Chris@41: # This case only exists to satisfy depend.m4. It is never actually Chris@41: # run, as this mode is specially recognized in the preamble. Chris@41: exit 1 Chris@41: ;; Chris@41: Chris@41: makedepend) Chris@41: "$@" || exit $? Chris@41: # Remove any Libtool call Chris@41: if test "$libtool" = yes; then Chris@41: while test "X$1" != 'X--mode=compile'; do Chris@41: shift Chris@41: done Chris@41: shift Chris@41: fi Chris@41: # X makedepend Chris@41: shift Chris@41: cleared=no eat=no Chris@41: for arg Chris@41: do Chris@41: case $cleared in Chris@41: no) Chris@41: set ""; shift Chris@41: cleared=yes ;; Chris@41: esac Chris@41: if test $eat = yes; then Chris@41: eat=no Chris@41: continue Chris@41: fi Chris@41: case "$arg" in Chris@41: -D*|-I*) Chris@41: set fnord "$@" "$arg"; shift ;; Chris@41: # Strip any option that makedepend may not understand. Remove Chris@41: # the object too, otherwise makedepend will parse it as a source file. Chris@41: -arch) Chris@41: eat=yes ;; Chris@41: -*|$object) Chris@41: ;; Chris@41: *) Chris@41: set fnord "$@" "$arg"; shift ;; Chris@41: esac Chris@41: done Chris@41: obj_suffix=`echo "$object" | sed 's/^.*\././'` Chris@41: touch "$tmpdepfile" Chris@41: ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" Chris@41: rm -f "$depfile" Chris@41: cat < "$tmpdepfile" > "$depfile" Chris@41: sed '1,2d' "$tmpdepfile" | tr ' ' ' Chris@41: ' | \ Chris@41: ## Some versions of the HPUX 10.20 sed can't process this invocation Chris@41: ## correctly. Breaking it into two sed invocations is a workaround. Chris@41: sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" Chris@41: rm -f "$tmpdepfile" "$tmpdepfile".bak Chris@41: ;; Chris@41: Chris@41: cpp) Chris@41: # Important note: in order to support this mode, a compiler *must* Chris@41: # always write the preprocessed file to stdout. Chris@41: "$@" || exit $? Chris@41: Chris@41: # Remove the call to Libtool. Chris@41: if test "$libtool" = yes; then Chris@41: while test "X$1" != 'X--mode=compile'; do Chris@41: shift Chris@41: done Chris@41: shift Chris@41: fi Chris@41: Chris@41: # Remove `-o $object'. Chris@41: IFS=" " Chris@41: for arg Chris@41: do Chris@41: case $arg in Chris@41: -o) Chris@41: shift Chris@41: ;; Chris@41: $object) Chris@41: shift Chris@41: ;; Chris@41: *) Chris@41: set fnord "$@" "$arg" Chris@41: shift # fnord Chris@41: shift # $arg Chris@41: ;; Chris@41: esac Chris@41: done Chris@41: Chris@41: "$@" -E | Chris@41: sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ Chris@41: -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | Chris@41: sed '$ s: \\$::' > "$tmpdepfile" Chris@41: rm -f "$depfile" Chris@41: echo "$object : \\" > "$depfile" Chris@41: cat < "$tmpdepfile" >> "$depfile" Chris@41: sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: msvisualcpp) Chris@41: # Important note: in order to support this mode, a compiler *must* Chris@41: # always write the preprocessed file to stdout. Chris@41: "$@" || exit $? Chris@41: Chris@41: # Remove the call to Libtool. Chris@41: if test "$libtool" = yes; then Chris@41: while test "X$1" != 'X--mode=compile'; do Chris@41: shift Chris@41: done Chris@41: shift Chris@41: fi Chris@41: Chris@41: IFS=" " Chris@41: for arg Chris@41: do Chris@41: case "$arg" in Chris@41: -o) Chris@41: shift Chris@41: ;; Chris@41: $object) Chris@41: shift Chris@41: ;; Chris@41: "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") Chris@41: set fnord "$@" Chris@41: shift Chris@41: shift Chris@41: ;; Chris@41: *) Chris@41: set fnord "$@" "$arg" Chris@41: shift Chris@41: shift Chris@41: ;; Chris@41: esac Chris@41: done Chris@41: "$@" -E 2>/dev/null | Chris@41: sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" Chris@41: rm -f "$depfile" Chris@41: echo "$object : \\" > "$depfile" Chris@41: sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" Chris@41: echo " " >> "$depfile" Chris@41: sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" Chris@41: rm -f "$tmpdepfile" Chris@41: ;; Chris@41: Chris@41: msvcmsys) Chris@41: # This case exists only to let depend.m4 do its work. It works by Chris@41: # looking at the text of this script. This case will never be run, Chris@41: # since it is checked for above. Chris@41: exit 1 Chris@41: ;; Chris@41: Chris@41: none) Chris@41: exec "$@" Chris@41: ;; Chris@41: Chris@41: *) Chris@41: echo "Unknown depmode $depmode" 1>&2 Chris@41: exit 1 Chris@41: ;; Chris@41: esac Chris@41: Chris@41: exit 0 Chris@41: Chris@41: # Local Variables: Chris@41: # mode: shell-script Chris@41: # sh-indentation: 2 Chris@41: # eval: (add-hook 'write-file-hooks 'time-stamp) Chris@41: # time-stamp-start: "scriptversion=" Chris@41: # time-stamp-format: "%:y-%02m-%02d.%02H" Chris@41: # time-stamp-time-zone: "UTC" Chris@41: # time-stamp-end: "; # UTC" Chris@41: # End: