xref: /potrace-1.14/depcomp (revision 275def9c)
1189777a2SCristian Pallares#! /bin/sh
2189777a2SCristian Pallares# depcomp - compile a program generating dependencies as side-effects
3189777a2SCristian Pallares
41f13f311SSkyrpexscriptversion=2013-05-30.07; # UTC
5189777a2SCristian Pallares
6*275def9cSCristian Pallarés# Copyright (C) 1999-2014 Free Software Foundation, Inc.
7189777a2SCristian Pallares
8189777a2SCristian Pallares# This program is free software; you can redistribute it and/or modify
9189777a2SCristian Pallares# it under the terms of the GNU General Public License as published by
10189777a2SCristian Pallares# the Free Software Foundation; either version 2, or (at your option)
11189777a2SCristian Pallares# any later version.
12189777a2SCristian Pallares
13189777a2SCristian Pallares# This program is distributed in the hope that it will be useful,
14189777a2SCristian Pallares# but WITHOUT ANY WARRANTY; without even the implied warranty of
15189777a2SCristian Pallares# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16189777a2SCristian Pallares# GNU General Public License for more details.
17189777a2SCristian Pallares
18189777a2SCristian Pallares# You should have received a copy of the GNU General Public License
19189777a2SCristian Pallares# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20189777a2SCristian Pallares
21189777a2SCristian Pallares# As a special exception to the GNU General Public License, if you
22189777a2SCristian Pallares# distribute this file as part of a program that contains a
23189777a2SCristian Pallares# configuration script generated by Autoconf, you may include it under
24189777a2SCristian Pallares# the same distribution terms that you use for the rest of that program.
25189777a2SCristian Pallares
26189777a2SCristian Pallares# Originally written by Alexandre Oliva <[email protected]>.
27189777a2SCristian Pallares
28189777a2SCristian Pallarescase $1 in
29189777a2SCristian Pallares  '')
301f13f311SSkyrpex    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
31189777a2SCristian Pallares    exit 1;
32189777a2SCristian Pallares    ;;
33189777a2SCristian Pallares  -h | --h*)
34189777a2SCristian Pallares    cat <<\EOF
35189777a2SCristian PallaresUsage: depcomp [--help] [--version] PROGRAM [ARGS]
36189777a2SCristian Pallares
37189777a2SCristian PallaresRun PROGRAMS ARGS to compile a file, generating dependencies
38189777a2SCristian Pallaresas side-effects.
39189777a2SCristian Pallares
40189777a2SCristian PallaresEnvironment variables:
41189777a2SCristian Pallares  depmode     Dependency tracking mode.
421f13f311SSkyrpex  source      Source file read by 'PROGRAMS ARGS'.
431f13f311SSkyrpex  object      Object file output by 'PROGRAMS ARGS'.
44189777a2SCristian Pallares  DEPDIR      directory where to store dependencies.
45189777a2SCristian Pallares  depfile     Dependency file to output.
461f13f311SSkyrpex  tmpdepfile  Temporary file to use when outputting dependencies.
47189777a2SCristian Pallares  libtool     Whether libtool is used (yes/no).
48189777a2SCristian Pallares
49189777a2SCristian PallaresReport bugs to <bug-automake@gnu.org>.
50189777a2SCristian PallaresEOF
51189777a2SCristian Pallares    exit $?
52189777a2SCristian Pallares    ;;
53189777a2SCristian Pallares  -v | --v*)
54189777a2SCristian Pallares    echo "depcomp $scriptversion"
55189777a2SCristian Pallares    exit $?
56189777a2SCristian Pallares    ;;
57189777a2SCristian Pallaresesac
58189777a2SCristian Pallares
591f13f311SSkyrpex# Get the directory component of the given path, and save it in the
601f13f311SSkyrpex# global variables '$dir'.  Note that this directory component will
611f13f311SSkyrpex# be either empty or ending with a '/' character.  This is deliberate.
621f13f311SSkyrpexset_dir_from ()
631f13f311SSkyrpex{
641f13f311SSkyrpex  case $1 in
651f13f311SSkyrpex    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
661f13f311SSkyrpex      *) dir=;;
671f13f311SSkyrpex  esac
681f13f311SSkyrpex}
691f13f311SSkyrpex
701f13f311SSkyrpex# Get the suffix-stripped basename of the given path, and save it the
711f13f311SSkyrpex# global variable '$base'.
721f13f311SSkyrpexset_base_from ()
731f13f311SSkyrpex{
741f13f311SSkyrpex  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
751f13f311SSkyrpex}
761f13f311SSkyrpex
771f13f311SSkyrpex# If no dependency file was actually created by the compiler invocation,
781f13f311SSkyrpex# we still have to create a dummy depfile, to avoid errors with the
791f13f311SSkyrpex# Makefile "include basename.Plo" scheme.
801f13f311SSkyrpexmake_dummy_depfile ()
811f13f311SSkyrpex{
821f13f311SSkyrpex  echo "#dummy" > "$depfile"
831f13f311SSkyrpex}
841f13f311SSkyrpex
851f13f311SSkyrpex# Factor out some common post-processing of the generated depfile.
861f13f311SSkyrpex# Requires the auxiliary global variable '$tmpdepfile' to be set.
871f13f311SSkyrpexaix_post_process_depfile ()
881f13f311SSkyrpex{
891f13f311SSkyrpex  # If the compiler actually managed to produce a dependency file,
901f13f311SSkyrpex  # post-process it.
911f13f311SSkyrpex  if test -f "$tmpdepfile"; then
921f13f311SSkyrpex    # Each line is of the form 'foo.o: dependency.h'.
931f13f311SSkyrpex    # Do two passes, one to just change these to
941f13f311SSkyrpex    #   $object: dependency.h
951f13f311SSkyrpex    # and one to simply output
961f13f311SSkyrpex    #   dependency.h:
971f13f311SSkyrpex    # which is needed to avoid the deleted-header problem.
981f13f311SSkyrpex    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
991f13f311SSkyrpex      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
1001f13f311SSkyrpex    } > "$depfile"
1011f13f311SSkyrpex    rm -f "$tmpdepfile"
1021f13f311SSkyrpex  else
1031f13f311SSkyrpex    make_dummy_depfile
1041f13f311SSkyrpex  fi
1051f13f311SSkyrpex}
1061f13f311SSkyrpex
1071f13f311SSkyrpex# A tabulation character.
1081f13f311SSkyrpextab='	'
1091f13f311SSkyrpex# A newline character.
1101f13f311SSkyrpexnl='
1111f13f311SSkyrpex'
1121f13f311SSkyrpex# Character ranges might be problematic outside the C locale.
1131f13f311SSkyrpex# These definitions help.
1141f13f311SSkyrpexupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
1151f13f311SSkyrpexlower=abcdefghijklmnopqrstuvwxyz
1161f13f311SSkyrpexdigits=0123456789
1171f13f311SSkyrpexalpha=${upper}${lower}
1181f13f311SSkyrpex
119189777a2SCristian Pallaresif test -z "$depmode" || test -z "$source" || test -z "$object"; then
120189777a2SCristian Pallares  echo "depcomp: Variables source, object and depmode must be set" 1>&2
121189777a2SCristian Pallares  exit 1
122189777a2SCristian Pallaresfi
123189777a2SCristian Pallares
124189777a2SCristian Pallares# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
125189777a2SCristian Pallaresdepfile=${depfile-`echo "$object" |
126189777a2SCristian Pallares  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
127189777a2SCristian Pallarestmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
128189777a2SCristian Pallares
129189777a2SCristian Pallaresrm -f "$tmpdepfile"
130189777a2SCristian Pallares
1311f13f311SSkyrpex# Avoid interferences from the environment.
1321f13f311SSkyrpexgccflag= dashmflag=
1331f13f311SSkyrpex
134189777a2SCristian Pallares# Some modes work just like other modes, but use different flags.  We
135189777a2SCristian Pallares# parameterize here, but still list the modes in the big case below,
136189777a2SCristian Pallares# to make depend.m4 easier to write.  Note that we *cannot* use a case
137189777a2SCristian Pallares# here, because this file can only contain one case statement.
138189777a2SCristian Pallaresif test "$depmode" = hp; then
139189777a2SCristian Pallares  # HP compiler uses -M and no extra arg.
140189777a2SCristian Pallares  gccflag=-M
141189777a2SCristian Pallares  depmode=gcc
142189777a2SCristian Pallaresfi
143189777a2SCristian Pallares
144189777a2SCristian Pallaresif test "$depmode" = dashXmstdout; then
145189777a2SCristian Pallares  # This is just like dashmstdout with a different argument.
146189777a2SCristian Pallares  dashmflag=-xM
147189777a2SCristian Pallares  depmode=dashmstdout
148189777a2SCristian Pallaresfi
149189777a2SCristian Pallares
150189777a2SCristian Pallarescygpath_u="cygpath -u -f -"
151189777a2SCristian Pallaresif test "$depmode" = msvcmsys; then
152189777a2SCristian Pallares  # This is just like msvisualcpp but w/o cygpath translation.
153189777a2SCristian Pallares  # Just convert the backslash-escaped backslashes to single forward
154189777a2SCristian Pallares  # slashes to satisfy depend.m4
1551f13f311SSkyrpex  cygpath_u='sed s,\\\\,/,g'
156189777a2SCristian Pallares  depmode=msvisualcpp
157189777a2SCristian Pallaresfi
158189777a2SCristian Pallares
1591f13f311SSkyrpexif test "$depmode" = msvc7msys; then
1601f13f311SSkyrpex  # This is just like msvc7 but w/o cygpath translation.
1611f13f311SSkyrpex  # Just convert the backslash-escaped backslashes to single forward
1621f13f311SSkyrpex  # slashes to satisfy depend.m4
1631f13f311SSkyrpex  cygpath_u='sed s,\\\\,/,g'
1641f13f311SSkyrpex  depmode=msvc7
1651f13f311SSkyrpexfi
1661f13f311SSkyrpex
1671f13f311SSkyrpexif test "$depmode" = xlc; then
1681f13f311SSkyrpex  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
1691f13f311SSkyrpex  gccflag=-qmakedep=gcc,-MF
1701f13f311SSkyrpex  depmode=gcc
1711f13f311SSkyrpexfi
1721f13f311SSkyrpex
173189777a2SCristian Pallarescase "$depmode" in
174189777a2SCristian Pallaresgcc3)
175189777a2SCristian Pallares## gcc 3 implements dependency tracking that does exactly what
176189777a2SCristian Pallares## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
177189777a2SCristian Pallares## it if -MD -MP comes after the -MF stuff.  Hmm.
178189777a2SCristian Pallares## Unfortunately, FreeBSD c89 acceptance of flags depends upon
179189777a2SCristian Pallares## the command line argument order; so add the flags where they
180189777a2SCristian Pallares## appear in depend2.am.  Note that the slowdown incurred here
181189777a2SCristian Pallares## affects only configure: in makefiles, %FASTDEP% shortcuts this.
182189777a2SCristian Pallares  for arg
183189777a2SCristian Pallares  do
184189777a2SCristian Pallares    case $arg in
185189777a2SCristian Pallares    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
186189777a2SCristian Pallares    *)  set fnord "$@" "$arg" ;;
187189777a2SCristian Pallares    esac
188189777a2SCristian Pallares    shift # fnord
189189777a2SCristian Pallares    shift # $arg
190189777a2SCristian Pallares  done
191189777a2SCristian Pallares  "$@"
192189777a2SCristian Pallares  stat=$?
1931f13f311SSkyrpex  if test $stat -ne 0; then
194189777a2SCristian Pallares    rm -f "$tmpdepfile"
195189777a2SCristian Pallares    exit $stat
196189777a2SCristian Pallares  fi
197189777a2SCristian Pallares  mv "$tmpdepfile" "$depfile"
198189777a2SCristian Pallares  ;;
199189777a2SCristian Pallares
200189777a2SCristian Pallaresgcc)
2011f13f311SSkyrpex## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
2021f13f311SSkyrpex## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
2031f13f311SSkyrpex## (see the conditional assignment to $gccflag above).
204189777a2SCristian Pallares## There are various ways to get dependency output from gcc.  Here's
205189777a2SCristian Pallares## why we pick this rather obscure method:
206189777a2SCristian Pallares## - Don't want to use -MD because we'd like the dependencies to end
207189777a2SCristian Pallares##   up in a subdir.  Having to rename by hand is ugly.
208189777a2SCristian Pallares##   (We might end up doing this anyway to support other compilers.)
209189777a2SCristian Pallares## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
2101f13f311SSkyrpex##   -MM, not -M (despite what the docs say).  Also, it might not be
2111f13f311SSkyrpex##   supported by the other compilers which use the 'gcc' depmode.
212189777a2SCristian Pallares## - Using -M directly means running the compiler twice (even worse
213189777a2SCristian Pallares##   than renaming).
214189777a2SCristian Pallares  if test -z "$gccflag"; then
215189777a2SCristian Pallares    gccflag=-MD,
216189777a2SCristian Pallares  fi
217189777a2SCristian Pallares  "$@" -Wp,"$gccflag$tmpdepfile"
218189777a2SCristian Pallares  stat=$?
2191f13f311SSkyrpex  if test $stat -ne 0; then
220189777a2SCristian Pallares    rm -f "$tmpdepfile"
221189777a2SCristian Pallares    exit $stat
222189777a2SCristian Pallares  fi
223189777a2SCristian Pallares  rm -f "$depfile"
224189777a2SCristian Pallares  echo "$object : \\" > "$depfile"
2251f13f311SSkyrpex  # The second -e expression handles DOS-style file names with drive
2261f13f311SSkyrpex  # letters.
227189777a2SCristian Pallares  sed -e 's/^[^:]*: / /' \
228189777a2SCristian Pallares      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
2291f13f311SSkyrpex## This next piece of magic avoids the "deleted header file" problem.
230189777a2SCristian Pallares## The problem is that when a header file which appears in a .P file
231189777a2SCristian Pallares## is deleted, the dependency causes make to die (because there is
232189777a2SCristian Pallares## typically no way to rebuild the header).  We avoid this by adding
233189777a2SCristian Pallares## dummy dependencies for each header file.  Too bad gcc doesn't do
234189777a2SCristian Pallares## this for us directly.
2351f13f311SSkyrpex## Some versions of gcc put a space before the ':'.  On the theory
236189777a2SCristian Pallares## that the space means something, we add a space to the output as
2371f13f311SSkyrpex## well.  hp depmode also adds that space, but also prefixes the VPATH
2381f13f311SSkyrpex## to the object.  Take care to not repeat it in the output.
239189777a2SCristian Pallares## Some versions of the HPUX 10.20 sed can't process this invocation
240189777a2SCristian Pallares## correctly.  Breaking it into two sed invocations is a workaround.
2411f13f311SSkyrpex  tr ' ' "$nl" < "$tmpdepfile" \
2421f13f311SSkyrpex    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
2431f13f311SSkyrpex    | sed -e 's/$/ :/' >> "$depfile"
244189777a2SCristian Pallares  rm -f "$tmpdepfile"
245189777a2SCristian Pallares  ;;
246189777a2SCristian Pallares
247189777a2SCristian Pallareshp)
248189777a2SCristian Pallares  # This case exists only to let depend.m4 do its work.  It works by
249189777a2SCristian Pallares  # looking at the text of this script.  This case will never be run,
250189777a2SCristian Pallares  # since it is checked for above.
251189777a2SCristian Pallares  exit 1
252189777a2SCristian Pallares  ;;
253189777a2SCristian Pallares
254189777a2SCristian Pallaressgi)
255189777a2SCristian Pallares  if test "$libtool" = yes; then
256189777a2SCristian Pallares    "$@" "-Wp,-MDupdate,$tmpdepfile"
257189777a2SCristian Pallares  else
258189777a2SCristian Pallares    "$@" -MDupdate "$tmpdepfile"
259189777a2SCristian Pallares  fi
260189777a2SCristian Pallares  stat=$?
2611f13f311SSkyrpex  if test $stat -ne 0; then
262189777a2SCristian Pallares    rm -f "$tmpdepfile"
263189777a2SCristian Pallares    exit $stat
264189777a2SCristian Pallares  fi
265189777a2SCristian Pallares  rm -f "$depfile"
266189777a2SCristian Pallares
267189777a2SCristian Pallares  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
268189777a2SCristian Pallares    echo "$object : \\" > "$depfile"
269189777a2SCristian Pallares    # Clip off the initial element (the dependent).  Don't try to be
270189777a2SCristian Pallares    # clever and replace this with sed code, as IRIX sed won't handle
271189777a2SCristian Pallares    # lines with more than a fixed number of characters (4096 in
272189777a2SCristian Pallares    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
2731f13f311SSkyrpex    # the IRIX cc adds comments like '#:fec' to the end of the
274189777a2SCristian Pallares    # dependency line.
2751f13f311SSkyrpex    tr ' ' "$nl" < "$tmpdepfile" \
2761f13f311SSkyrpex      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
2771f13f311SSkyrpex      | tr "$nl" ' ' >> "$depfile"
278189777a2SCristian Pallares    echo >> "$depfile"
279189777a2SCristian Pallares    # The second pass generates a dummy entry for each header file.
2801f13f311SSkyrpex    tr ' ' "$nl" < "$tmpdepfile" \
281189777a2SCristian Pallares      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
282189777a2SCristian Pallares      >> "$depfile"
283189777a2SCristian Pallares  else
2841f13f311SSkyrpex    make_dummy_depfile
285189777a2SCristian Pallares  fi
286189777a2SCristian Pallares  rm -f "$tmpdepfile"
287189777a2SCristian Pallares  ;;
288189777a2SCristian Pallares
2891f13f311SSkyrpexxlc)
2901f13f311SSkyrpex  # This case exists only to let depend.m4 do its work.  It works by
2911f13f311SSkyrpex  # looking at the text of this script.  This case will never be run,
2921f13f311SSkyrpex  # since it is checked for above.
2931f13f311SSkyrpex  exit 1
2941f13f311SSkyrpex  ;;
2951f13f311SSkyrpex
296189777a2SCristian Pallaresaix)
297189777a2SCristian Pallares  # The C for AIX Compiler uses -M and outputs the dependencies
298189777a2SCristian Pallares  # in a .u file.  In older versions, this file always lives in the
2991f13f311SSkyrpex  # current directory.  Also, the AIX compiler puts '$object:' at the
300189777a2SCristian Pallares  # start of each line; $object doesn't have directory information.
301189777a2SCristian Pallares  # Version 6 uses the directory in both cases.
3021f13f311SSkyrpex  set_dir_from "$object"
3031f13f311SSkyrpex  set_base_from "$object"
304189777a2SCristian Pallares  if test "$libtool" = yes; then
305189777a2SCristian Pallares    tmpdepfile1=$dir$base.u
306189777a2SCristian Pallares    tmpdepfile2=$base.u
307189777a2SCristian Pallares    tmpdepfile3=$dir.libs/$base.u
308189777a2SCristian Pallares    "$@" -Wc,-M
309189777a2SCristian Pallares  else
310189777a2SCristian Pallares    tmpdepfile1=$dir$base.u
311189777a2SCristian Pallares    tmpdepfile2=$dir$base.u
312189777a2SCristian Pallares    tmpdepfile3=$dir$base.u
313189777a2SCristian Pallares    "$@" -M
314189777a2SCristian Pallares  fi
315189777a2SCristian Pallares  stat=$?
3161f13f311SSkyrpex  if test $stat -ne 0; then
317189777a2SCristian Pallares    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
318189777a2SCristian Pallares    exit $stat
319189777a2SCristian Pallares  fi
320189777a2SCristian Pallares
321189777a2SCristian Pallares  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
322189777a2SCristian Pallares  do
323189777a2SCristian Pallares    test -f "$tmpdepfile" && break
324189777a2SCristian Pallares  done
3251f13f311SSkyrpex  aix_post_process_depfile
3261f13f311SSkyrpex  ;;
3271f13f311SSkyrpex
3281f13f311SSkyrpextcc)
3291f13f311SSkyrpex  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
3301f13f311SSkyrpex  # FIXME: That version still under development at the moment of writing.
3311f13f311SSkyrpex  #        Make that this statement remains true also for stable, released
3321f13f311SSkyrpex  #        versions.
3331f13f311SSkyrpex  # It will wrap lines (doesn't matter whether long or short) with a
3341f13f311SSkyrpex  # trailing '\', as in:
3351f13f311SSkyrpex  #
3361f13f311SSkyrpex  #   foo.o : \
3371f13f311SSkyrpex  #    foo.c \
3381f13f311SSkyrpex  #    foo.h \
3391f13f311SSkyrpex  #
3401f13f311SSkyrpex  # It will put a trailing '\' even on the last line, and will use leading
3411f13f311SSkyrpex  # spaces rather than leading tabs (at least since its commit 0394caf7
3421f13f311SSkyrpex  # "Emit spaces for -MD").
3431f13f311SSkyrpex  "$@" -MD -MF "$tmpdepfile"
3441f13f311SSkyrpex  stat=$?
3451f13f311SSkyrpex  if test $stat -ne 0; then
3461f13f311SSkyrpex    rm -f "$tmpdepfile"
3471f13f311SSkyrpex    exit $stat
348189777a2SCristian Pallares  fi
3491f13f311SSkyrpex  rm -f "$depfile"
3501f13f311SSkyrpex  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
3511f13f311SSkyrpex  # We have to change lines of the first kind to '$object: \'.
3521f13f311SSkyrpex  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
3531f13f311SSkyrpex  # And for each line of the second kind, we have to emit a 'dep.h:'
3541f13f311SSkyrpex  # dummy dependency, to avoid the deleted-header problem.
3551f13f311SSkyrpex  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
356189777a2SCristian Pallares  rm -f "$tmpdepfile"
357189777a2SCristian Pallares  ;;
358189777a2SCristian Pallares
3591f13f311SSkyrpex## The order of this option in the case statement is important, since the
3601f13f311SSkyrpex## shell code in configure will try each of these formats in the order
3611f13f311SSkyrpex## listed in this file.  A plain '-MD' option would be understood by many
3621f13f311SSkyrpex## compilers, so we must ensure this comes after the gcc and icc options.
3631f13f311SSkyrpexpgcc)
3641f13f311SSkyrpex  # Portland's C compiler understands '-MD'.
3651f13f311SSkyrpex  # Will always output deps to 'file.d' where file is the root name of the
3661f13f311SSkyrpex  # source file under compilation, even if file resides in a subdirectory.
3671f13f311SSkyrpex  # The object file name does not affect the name of the '.d' file.
3681f13f311SSkyrpex  # pgcc 10.2 will output
369189777a2SCristian Pallares  #    foo.o: sub/foo.c sub/foo.h
3701f13f311SSkyrpex  # and will wrap long lines using '\' :
371189777a2SCristian Pallares  #    foo.o: sub/foo.c ... \
372189777a2SCristian Pallares  #     sub/foo.h ... \
373189777a2SCristian Pallares  #     ...
3741f13f311SSkyrpex  set_dir_from "$object"
3751f13f311SSkyrpex  # Use the source, not the object, to determine the base name, since
3761f13f311SSkyrpex  # that's sadly what pgcc will do too.
3771f13f311SSkyrpex  set_base_from "$source"
3781f13f311SSkyrpex  tmpdepfile=$base.d
379189777a2SCristian Pallares
3801f13f311SSkyrpex  # For projects that build the same source file twice into different object
3811f13f311SSkyrpex  # files, the pgcc approach of using the *source* file root name can cause
3821f13f311SSkyrpex  # problems in parallel builds.  Use a locking strategy to avoid stomping on
3831f13f311SSkyrpex  # the same $tmpdepfile.
3841f13f311SSkyrpex  lockdir=$base.d-lock
3851f13f311SSkyrpex  trap "
3861f13f311SSkyrpex    echo '$0: caught signal, cleaning up...' >&2
3871f13f311SSkyrpex    rmdir '$lockdir'
3881f13f311SSkyrpex    exit 1
3891f13f311SSkyrpex  " 1 2 13 15
3901f13f311SSkyrpex  numtries=100
3911f13f311SSkyrpex  i=$numtries
3921f13f311SSkyrpex  while test $i -gt 0; do
3931f13f311SSkyrpex    # mkdir is a portable test-and-set.
3941f13f311SSkyrpex    if mkdir "$lockdir" 2>/dev/null; then
3951f13f311SSkyrpex      # This process acquired the lock.
3961f13f311SSkyrpex      "$@" -MD
397189777a2SCristian Pallares      stat=$?
3981f13f311SSkyrpex      # Release the lock.
3991f13f311SSkyrpex      rmdir "$lockdir"
4001f13f311SSkyrpex      break
401189777a2SCristian Pallares    else
4021f13f311SSkyrpex      # If the lock is being held by a different process, wait
4031f13f311SSkyrpex      # until the winning process is done or we timeout.
4041f13f311SSkyrpex      while test -d "$lockdir" && test $i -gt 0; do
4051f13f311SSkyrpex        sleep 1
4061f13f311SSkyrpex        i=`expr $i - 1`
4071f13f311SSkyrpex      done
4081f13f311SSkyrpex    fi
4091f13f311SSkyrpex    i=`expr $i - 1`
4101f13f311SSkyrpex  done
4111f13f311SSkyrpex  trap - 1 2 13 15
4121f13f311SSkyrpex  if test $i -le 0; then
4131f13f311SSkyrpex    echo "$0: failed to acquire lock after $numtries attempts" >&2
4141f13f311SSkyrpex    echo "$0: check lockdir '$lockdir'" >&2
4151f13f311SSkyrpex    exit 1
4161f13f311SSkyrpex  fi
4171f13f311SSkyrpex
4181f13f311SSkyrpex  if test $stat -ne 0; then
419189777a2SCristian Pallares    rm -f "$tmpdepfile"
420189777a2SCristian Pallares    exit $stat
421189777a2SCristian Pallares  fi
422189777a2SCristian Pallares  rm -f "$depfile"
423189777a2SCristian Pallares  # Each line is of the form `foo.o: dependent.h',
424189777a2SCristian Pallares  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
425189777a2SCristian Pallares  # Do two passes, one to just change these to
426189777a2SCristian Pallares  # `$object: dependent.h' and one to simply `dependent.h:'.
427189777a2SCristian Pallares  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
428189777a2SCristian Pallares  # Some versions of the HPUX 10.20 sed can't process this invocation
429189777a2SCristian Pallares  # correctly.  Breaking it into two sed invocations is a workaround.
4301f13f311SSkyrpex  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
4311f13f311SSkyrpex    | sed -e 's/$/ :/' >> "$depfile"
432189777a2SCristian Pallares  rm -f "$tmpdepfile"
433189777a2SCristian Pallares  ;;
434189777a2SCristian Pallares
435189777a2SCristian Pallareshp2)
436189777a2SCristian Pallares  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
437189777a2SCristian Pallares  # compilers, which have integrated preprocessors.  The correct option
438189777a2SCristian Pallares  # to use with these is +Maked; it writes dependencies to a file named
439189777a2SCristian Pallares  # 'foo.d', which lands next to the object file, wherever that
440189777a2SCristian Pallares  # happens to be.
441189777a2SCristian Pallares  # Much of this is similar to the tru64 case; see comments there.
4421f13f311SSkyrpex  set_dir_from  "$object"
4431f13f311SSkyrpex  set_base_from "$object"
444189777a2SCristian Pallares  if test "$libtool" = yes; then
445189777a2SCristian Pallares    tmpdepfile1=$dir$base.d
446189777a2SCristian Pallares    tmpdepfile2=$dir.libs/$base.d
447189777a2SCristian Pallares    "$@" -Wc,+Maked
448189777a2SCristian Pallares  else
449189777a2SCristian Pallares    tmpdepfile1=$dir$base.d
450189777a2SCristian Pallares    tmpdepfile2=$dir$base.d
451189777a2SCristian Pallares    "$@" +Maked
452189777a2SCristian Pallares  fi
453189777a2SCristian Pallares  stat=$?
4541f13f311SSkyrpex  if test $stat -ne 0; then
455189777a2SCristian Pallares     rm -f "$tmpdepfile1" "$tmpdepfile2"
456189777a2SCristian Pallares     exit $stat
457189777a2SCristian Pallares  fi
458189777a2SCristian Pallares
459189777a2SCristian Pallares  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
460189777a2SCristian Pallares  do
461189777a2SCristian Pallares    test -f "$tmpdepfile" && break
462189777a2SCristian Pallares  done
463189777a2SCristian Pallares  if test -f "$tmpdepfile"; then
4641f13f311SSkyrpex    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
4651f13f311SSkyrpex    # Add 'dependent.h:' lines.
466189777a2SCristian Pallares    sed -ne '2,${
467189777a2SCristian Pallares               s/^ *//
468189777a2SCristian Pallares               s/ \\*$//
469189777a2SCristian Pallares               s/$/:/
470189777a2SCristian Pallares               p
471189777a2SCristian Pallares             }' "$tmpdepfile" >> "$depfile"
472189777a2SCristian Pallares  else
4731f13f311SSkyrpex    make_dummy_depfile
474189777a2SCristian Pallares  fi
475189777a2SCristian Pallares  rm -f "$tmpdepfile" "$tmpdepfile2"
476189777a2SCristian Pallares  ;;
477189777a2SCristian Pallares
478189777a2SCristian Pallarestru64)
479189777a2SCristian Pallares  # The Tru64 compiler uses -MD to generate dependencies as a side
4801f13f311SSkyrpex  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
481189777a2SCristian Pallares  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
4821f13f311SSkyrpex  # dependencies in 'foo.d' instead, so we check for that too.
483189777a2SCristian Pallares  # Subdirectories are respected.
4841f13f311SSkyrpex  set_dir_from  "$object"
4851f13f311SSkyrpex  set_base_from "$object"
486189777a2SCristian Pallares
487189777a2SCristian Pallares  if test "$libtool" = yes; then
4881f13f311SSkyrpex    # Libtool generates 2 separate objects for the 2 libraries.  These
4891f13f311SSkyrpex    # two compilations output dependencies in $dir.libs/$base.o.d and
490189777a2SCristian Pallares    # in $dir$base.o.d.  We have to check for both files, because
491189777a2SCristian Pallares    # one of the two compilations can be disabled.  We should prefer
492189777a2SCristian Pallares    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
493189777a2SCristian Pallares    # automatically cleaned when .libs/ is deleted, while ignoring
494189777a2SCristian Pallares    # the former would cause a distcleancheck panic.
4951f13f311SSkyrpex    tmpdepfile1=$dir$base.o.d          # libtool 1.5
4961f13f311SSkyrpex    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
4971f13f311SSkyrpex    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
498189777a2SCristian Pallares    "$@" -Wc,-MD
499189777a2SCristian Pallares  else
5001f13f311SSkyrpex    tmpdepfile1=$dir$base.d
501189777a2SCristian Pallares    tmpdepfile2=$dir$base.d
502189777a2SCristian Pallares    tmpdepfile3=$dir$base.d
503189777a2SCristian Pallares    "$@" -MD
504189777a2SCristian Pallares  fi
505189777a2SCristian Pallares
506189777a2SCristian Pallares  stat=$?
5071f13f311SSkyrpex  if test $stat -ne 0; then
5081f13f311SSkyrpex    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
509189777a2SCristian Pallares    exit $stat
510189777a2SCristian Pallares  fi
511189777a2SCristian Pallares
5121f13f311SSkyrpex  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
513189777a2SCristian Pallares  do
514189777a2SCristian Pallares    test -f "$tmpdepfile" && break
515189777a2SCristian Pallares  done
5161f13f311SSkyrpex  # Same post-processing that is required for AIX mode.
5171f13f311SSkyrpex  aix_post_process_depfile
5181f13f311SSkyrpex  ;;
5191f13f311SSkyrpex
5201f13f311SSkyrpexmsvc7)
5211f13f311SSkyrpex  if test "$libtool" = yes; then
5221f13f311SSkyrpex    showIncludes=-Wc,-showIncludes
523189777a2SCristian Pallares  else
5241f13f311SSkyrpex    showIncludes=-showIncludes
525189777a2SCristian Pallares  fi
5261f13f311SSkyrpex  "$@" $showIncludes > "$tmpdepfile"
5271f13f311SSkyrpex  stat=$?
5281f13f311SSkyrpex  grep -v '^Note: including file: ' "$tmpdepfile"
5291f13f311SSkyrpex  if test $stat -ne 0; then
530189777a2SCristian Pallares    rm -f "$tmpdepfile"
5311f13f311SSkyrpex    exit $stat
5321f13f311SSkyrpex  fi
5331f13f311SSkyrpex  rm -f "$depfile"
5341f13f311SSkyrpex  echo "$object : \\" > "$depfile"
5351f13f311SSkyrpex  # The first sed program below extracts the file names and escapes
5361f13f311SSkyrpex  # backslashes for cygpath.  The second sed program outputs the file
5371f13f311SSkyrpex  # name when reading, but also accumulates all include files in the
5381f13f311SSkyrpex  # hold buffer in order to output them again at the end.  This only
5391f13f311SSkyrpex  # works with sed implementations that can handle large buffers.
5401f13f311SSkyrpex  sed < "$tmpdepfile" -n '
5411f13f311SSkyrpex/^Note: including file:  *\(.*\)/ {
5421f13f311SSkyrpex  s//\1/
5431f13f311SSkyrpex  s/\\/\\\\/g
5441f13f311SSkyrpex  p
5451f13f311SSkyrpex}' | $cygpath_u | sort -u | sed -n '
5461f13f311SSkyrpexs/ /\\ /g
5471f13f311SSkyrpexs/\(.*\)/'"$tab"'\1 \\/p
5481f13f311SSkyrpexs/.\(.*\) \\/\1:/
5491f13f311SSkyrpexH
5501f13f311SSkyrpex$ {
5511f13f311SSkyrpex  s/.*/'"$tab"'/
5521f13f311SSkyrpex  G
5531f13f311SSkyrpex  p
5541f13f311SSkyrpex}' >> "$depfile"
5551f13f311SSkyrpex  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
5561f13f311SSkyrpex  rm -f "$tmpdepfile"
5571f13f311SSkyrpex  ;;
5581f13f311SSkyrpex
5591f13f311SSkyrpexmsvc7msys)
5601f13f311SSkyrpex  # This case exists only to let depend.m4 do its work.  It works by
5611f13f311SSkyrpex  # looking at the text of this script.  This case will never be run,
5621f13f311SSkyrpex  # since it is checked for above.
5631f13f311SSkyrpex  exit 1
564189777a2SCristian Pallares  ;;
565189777a2SCristian Pallares
566189777a2SCristian Pallares#nosideeffect)
567189777a2SCristian Pallares  # This comment above is used by automake to tell side-effect
568189777a2SCristian Pallares  # dependency tracking mechanisms from slower ones.
569189777a2SCristian Pallares
570189777a2SCristian Pallaresdashmstdout)
571189777a2SCristian Pallares  # Important note: in order to support this mode, a compiler *must*
572189777a2SCristian Pallares  # always write the preprocessed file to stdout, regardless of -o.
573189777a2SCristian Pallares  "$@" || exit $?
574189777a2SCristian Pallares
575189777a2SCristian Pallares  # Remove the call to Libtool.
576189777a2SCristian Pallares  if test "$libtool" = yes; then
577189777a2SCristian Pallares    while test "X$1" != 'X--mode=compile'; do
578189777a2SCristian Pallares      shift
579189777a2SCristian Pallares    done
580189777a2SCristian Pallares    shift
581189777a2SCristian Pallares  fi
582189777a2SCristian Pallares
5831f13f311SSkyrpex  # Remove '-o $object'.
584189777a2SCristian Pallares  IFS=" "
585189777a2SCristian Pallares  for arg
586189777a2SCristian Pallares  do
587189777a2SCristian Pallares    case $arg in
588189777a2SCristian Pallares    -o)
589189777a2SCristian Pallares      shift
590189777a2SCristian Pallares      ;;
591189777a2SCristian Pallares    $object)
592189777a2SCristian Pallares      shift
593189777a2SCristian Pallares      ;;
594189777a2SCristian Pallares    *)
595189777a2SCristian Pallares      set fnord "$@" "$arg"
596189777a2SCristian Pallares      shift # fnord
597189777a2SCristian Pallares      shift # $arg
598189777a2SCristian Pallares      ;;
599189777a2SCristian Pallares    esac
600189777a2SCristian Pallares  done
601189777a2SCristian Pallares
602189777a2SCristian Pallares  test -z "$dashmflag" && dashmflag=-M
6031f13f311SSkyrpex  # Require at least two characters before searching for ':'
604189777a2SCristian Pallares  # in the target name.  This is to cope with DOS-style filenames:
6051f13f311SSkyrpex  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
606189777a2SCristian Pallares  "$@" $dashmflag |
6071f13f311SSkyrpex    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
608189777a2SCristian Pallares  rm -f "$depfile"
609189777a2SCristian Pallares  cat < "$tmpdepfile" > "$depfile"
6101f13f311SSkyrpex  # Some versions of the HPUX 10.20 sed can't process this sed invocation
6111f13f311SSkyrpex  # correctly.  Breaking it into two sed invocations is a workaround.
6121f13f311SSkyrpex  tr ' ' "$nl" < "$tmpdepfile" \
6131f13f311SSkyrpex    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
6141f13f311SSkyrpex    | sed -e 's/$/ :/' >> "$depfile"
615189777a2SCristian Pallares  rm -f "$tmpdepfile"
616189777a2SCristian Pallares  ;;
617189777a2SCristian Pallares
618189777a2SCristian PallaresdashXmstdout)
619189777a2SCristian Pallares  # This case only exists to satisfy depend.m4.  It is never actually
620189777a2SCristian Pallares  # run, as this mode is specially recognized in the preamble.
621189777a2SCristian Pallares  exit 1
622189777a2SCristian Pallares  ;;
623189777a2SCristian Pallares
624189777a2SCristian Pallaresmakedepend)
625189777a2SCristian Pallares  "$@" || exit $?
626189777a2SCristian Pallares  # Remove any Libtool call
627189777a2SCristian Pallares  if test "$libtool" = yes; then
628189777a2SCristian Pallares    while test "X$1" != 'X--mode=compile'; do
629189777a2SCristian Pallares      shift
630189777a2SCristian Pallares    done
631189777a2SCristian Pallares    shift
632189777a2SCristian Pallares  fi
633189777a2SCristian Pallares  # X makedepend
634189777a2SCristian Pallares  shift
635189777a2SCristian Pallares  cleared=no eat=no
636189777a2SCristian Pallares  for arg
637189777a2SCristian Pallares  do
638189777a2SCristian Pallares    case $cleared in
639189777a2SCristian Pallares    no)
640189777a2SCristian Pallares      set ""; shift
641189777a2SCristian Pallares      cleared=yes ;;
642189777a2SCristian Pallares    esac
643189777a2SCristian Pallares    if test $eat = yes; then
644189777a2SCristian Pallares      eat=no
645189777a2SCristian Pallares      continue
646189777a2SCristian Pallares    fi
647189777a2SCristian Pallares    case "$arg" in
648189777a2SCristian Pallares    -D*|-I*)
649189777a2SCristian Pallares      set fnord "$@" "$arg"; shift ;;
650189777a2SCristian Pallares    # Strip any option that makedepend may not understand.  Remove
651189777a2SCristian Pallares    # the object too, otherwise makedepend will parse it as a source file.
652189777a2SCristian Pallares    -arch)
653189777a2SCristian Pallares      eat=yes ;;
654189777a2SCristian Pallares    -*|$object)
655189777a2SCristian Pallares      ;;
656189777a2SCristian Pallares    *)
657189777a2SCristian Pallares      set fnord "$@" "$arg"; shift ;;
658189777a2SCristian Pallares    esac
659189777a2SCristian Pallares  done
660189777a2SCristian Pallares  obj_suffix=`echo "$object" | sed 's/^.*\././'`
661189777a2SCristian Pallares  touch "$tmpdepfile"
662189777a2SCristian Pallares  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
663189777a2SCristian Pallares  rm -f "$depfile"
6641f13f311SSkyrpex  # makedepend may prepend the VPATH from the source file name to the object.
6651f13f311SSkyrpex  # No need to regex-escape $object, excess matching of '.' is harmless.
6661f13f311SSkyrpex  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
6671f13f311SSkyrpex  # Some versions of the HPUX 10.20 sed can't process the last invocation
6681f13f311SSkyrpex  # correctly.  Breaking it into two sed invocations is a workaround.
6691f13f311SSkyrpex  sed '1,2d' "$tmpdepfile" \
6701f13f311SSkyrpex    | tr ' ' "$nl" \
6711f13f311SSkyrpex    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
6721f13f311SSkyrpex    | sed -e 's/$/ :/' >> "$depfile"
673189777a2SCristian Pallares  rm -f "$tmpdepfile" "$tmpdepfile".bak
674189777a2SCristian Pallares  ;;
675189777a2SCristian Pallares
676189777a2SCristian Pallarescpp)
677189777a2SCristian Pallares  # Important note: in order to support this mode, a compiler *must*
678189777a2SCristian Pallares  # always write the preprocessed file to stdout.
679189777a2SCristian Pallares  "$@" || exit $?
680189777a2SCristian Pallares
681189777a2SCristian Pallares  # Remove the call to Libtool.
682189777a2SCristian Pallares  if test "$libtool" = yes; then
683189777a2SCristian Pallares    while test "X$1" != 'X--mode=compile'; do
684189777a2SCristian Pallares      shift
685189777a2SCristian Pallares    done
686189777a2SCristian Pallares    shift
687189777a2SCristian Pallares  fi
688189777a2SCristian Pallares
6891f13f311SSkyrpex  # Remove '-o $object'.
690189777a2SCristian Pallares  IFS=" "
691189777a2SCristian Pallares  for arg
692189777a2SCristian Pallares  do
693189777a2SCristian Pallares    case $arg in
694189777a2SCristian Pallares    -o)
695189777a2SCristian Pallares      shift
696189777a2SCristian Pallares      ;;
697189777a2SCristian Pallares    $object)
698189777a2SCristian Pallares      shift
699189777a2SCristian Pallares      ;;
700189777a2SCristian Pallares    *)
701189777a2SCristian Pallares      set fnord "$@" "$arg"
702189777a2SCristian Pallares      shift # fnord
703189777a2SCristian Pallares      shift # $arg
704189777a2SCristian Pallares      ;;
705189777a2SCristian Pallares    esac
706189777a2SCristian Pallares  done
707189777a2SCristian Pallares
7081f13f311SSkyrpex  "$@" -E \
7091f13f311SSkyrpex    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
7101f13f311SSkyrpex             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
7111f13f311SSkyrpex    | sed '$ s: \\$::' > "$tmpdepfile"
712189777a2SCristian Pallares  rm -f "$depfile"
713189777a2SCristian Pallares  echo "$object : \\" > "$depfile"
714189777a2SCristian Pallares  cat < "$tmpdepfile" >> "$depfile"
715189777a2SCristian Pallares  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
716189777a2SCristian Pallares  rm -f "$tmpdepfile"
717189777a2SCristian Pallares  ;;
718189777a2SCristian Pallares
719189777a2SCristian Pallaresmsvisualcpp)
720189777a2SCristian Pallares  # Important note: in order to support this mode, a compiler *must*
721189777a2SCristian Pallares  # always write the preprocessed file to stdout.
722189777a2SCristian Pallares  "$@" || exit $?
723189777a2SCristian Pallares
724189777a2SCristian Pallares  # Remove the call to Libtool.
725189777a2SCristian Pallares  if test "$libtool" = yes; then
726189777a2SCristian Pallares    while test "X$1" != 'X--mode=compile'; do
727189777a2SCristian Pallares      shift
728189777a2SCristian Pallares    done
729189777a2SCristian Pallares    shift
730189777a2SCristian Pallares  fi
731189777a2SCristian Pallares
732189777a2SCristian Pallares  IFS=" "
733189777a2SCristian Pallares  for arg
734189777a2SCristian Pallares  do
735189777a2SCristian Pallares    case "$arg" in
736189777a2SCristian Pallares    -o)
737189777a2SCristian Pallares      shift
738189777a2SCristian Pallares      ;;
739189777a2SCristian Pallares    $object)
740189777a2SCristian Pallares      shift
741189777a2SCristian Pallares      ;;
742189777a2SCristian Pallares    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
743189777a2SCristian Pallares        set fnord "$@"
744189777a2SCristian Pallares        shift
745189777a2SCristian Pallares        shift
746189777a2SCristian Pallares        ;;
747189777a2SCristian Pallares    *)
748189777a2SCristian Pallares        set fnord "$@" "$arg"
749189777a2SCristian Pallares        shift
750189777a2SCristian Pallares        shift
751189777a2SCristian Pallares        ;;
752189777a2SCristian Pallares    esac
753189777a2SCristian Pallares  done
754189777a2SCristian Pallares  "$@" -E 2>/dev/null |
755189777a2SCristian Pallares  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
756189777a2SCristian Pallares  rm -f "$depfile"
757189777a2SCristian Pallares  echo "$object : \\" > "$depfile"
7581f13f311SSkyrpex  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
7591f13f311SSkyrpex  echo "$tab" >> "$depfile"
760189777a2SCristian Pallares  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
761189777a2SCristian Pallares  rm -f "$tmpdepfile"
762189777a2SCristian Pallares  ;;
763189777a2SCristian Pallares
764189777a2SCristian Pallaresmsvcmsys)
765189777a2SCristian Pallares  # This case exists only to let depend.m4 do its work.  It works by
766189777a2SCristian Pallares  # looking at the text of this script.  This case will never be run,
767189777a2SCristian Pallares  # since it is checked for above.
768189777a2SCristian Pallares  exit 1
769189777a2SCristian Pallares  ;;
770189777a2SCristian Pallares
771189777a2SCristian Pallaresnone)
772189777a2SCristian Pallares  exec "$@"
773189777a2SCristian Pallares  ;;
774189777a2SCristian Pallares
775189777a2SCristian Pallares*)
776189777a2SCristian Pallares  echo "Unknown depmode $depmode" 1>&2
777189777a2SCristian Pallares  exit 1
778189777a2SCristian Pallares  ;;
779189777a2SCristian Pallaresesac
780189777a2SCristian Pallares
781189777a2SCristian Pallaresexit 0
782189777a2SCristian Pallares
783189777a2SCristian Pallares# Local Variables:
784189777a2SCristian Pallares# mode: shell-script
785189777a2SCristian Pallares# sh-indentation: 2
786189777a2SCristian Pallares# eval: (add-hook 'write-file-hooks 'time-stamp)
787189777a2SCristian Pallares# time-stamp-start: "scriptversion="
788189777a2SCristian Pallares# time-stamp-format: "%:y-%02m-%02d.%02H"
789189777a2SCristian Pallares# time-stamp-time-zone: "UTC"
790189777a2SCristian Pallares# time-stamp-end: "; # UTC"
791189777a2SCristian Pallares# End:
792