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