xref: /iperf/config/depcomp (revision 76bd67f6)
1e34c20c8SJon Dugan#! /bin/sh
2e34c20c8SJon Dugan# depcomp - compile a program generating dependencies as side-effects
3e34c20c8SJon Dugan
46e9d8525SBruce A. Mahscriptversion=2018-03-07.03; # UTC
5e34c20c8SJon Dugan
6*76bd67f6SSarah Larsen# Copyright (C) 1999-2021 Free Software Foundation, Inc.
7e34c20c8SJon Dugan
8e34c20c8SJon Dugan# This program is free software; you can redistribute it and/or modify
9e34c20c8SJon Dugan# it under the terms of the GNU General Public License as published by
10e34c20c8SJon Dugan# the Free Software Foundation; either version 2, or (at your option)
11e34c20c8SJon Dugan# any later version.
12e34c20c8SJon Dugan
13e34c20c8SJon Dugan# This program is distributed in the hope that it will be useful,
14e34c20c8SJon Dugan# but WITHOUT ANY WARRANTY; without even the implied warranty of
15e34c20c8SJon Dugan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16e34c20c8SJon Dugan# GNU General Public License for more details.
17e34c20c8SJon Dugan
18e34c20c8SJon Dugan# You should have received a copy of the GNU General Public License
19ff1ea4e5SBruce A. Mah# along with this program.  If not, see <https://www.gnu.org/licenses/>.
20e34c20c8SJon Dugan
21e34c20c8SJon Dugan# As a special exception to the GNU General Public License, if you
22e34c20c8SJon Dugan# distribute this file as part of a program that contains a
23e34c20c8SJon Dugan# configuration script generated by Autoconf, you may include it under
24e34c20c8SJon Dugan# the same distribution terms that you use for the rest of that program.
25e34c20c8SJon Dugan
26e34c20c8SJon Dugan# Originally written by Alexandre Oliva <[email protected]>.
27e34c20c8SJon Dugan
28e34c20c8SJon Dugancase $1 in
29e34c20c8SJon Dugan  '')
30487ee810SBruce A. Mah    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
31e34c20c8SJon Dugan    exit 1;
32e34c20c8SJon Dugan    ;;
33e34c20c8SJon Dugan  -h | --h*)
34e34c20c8SJon Dugan    cat <<\EOF
35e34c20c8SJon DuganUsage: depcomp [--help] [--version] PROGRAM [ARGS]
36e34c20c8SJon Dugan
37e34c20c8SJon DuganRun PROGRAMS ARGS to compile a file, generating dependencies
38e34c20c8SJon Duganas side-effects.
39e34c20c8SJon Dugan
40e34c20c8SJon DuganEnvironment variables:
41e34c20c8SJon Dugan  depmode     Dependency tracking mode.
42487ee810SBruce A. Mah  source      Source file read by 'PROGRAMS ARGS'.
43487ee810SBruce A. Mah  object      Object file output by 'PROGRAMS ARGS'.
44e34c20c8SJon Dugan  DEPDIR      directory where to store dependencies.
45e34c20c8SJon Dugan  depfile     Dependency file to output.
46487ee810SBruce A. Mah  tmpdepfile  Temporary file to use when outputting dependencies.
47e34c20c8SJon Dugan  libtool     Whether libtool is used (yes/no).
48e34c20c8SJon Dugan
49e34c20c8SJon DuganReport bugs to <bug-automake@gnu.org>.
50e34c20c8SJon DuganEOF
51e34c20c8SJon Dugan    exit $?
52e34c20c8SJon Dugan    ;;
53e34c20c8SJon Dugan  -v | --v*)
54e34c20c8SJon Dugan    echo "depcomp $scriptversion"
55e34c20c8SJon Dugan    exit $?
56e34c20c8SJon Dugan    ;;
57e34c20c8SJon Duganesac
58e34c20c8SJon Dugan
59487ee810SBruce A. Mah# Get the directory component of the given path, and save it in the
60487ee810SBruce A. Mah# global variables '$dir'.  Note that this directory component will
61487ee810SBruce A. Mah# be either empty or ending with a '/' character.  This is deliberate.
62487ee810SBruce A. Mahset_dir_from ()
63487ee810SBruce A. Mah{
64487ee810SBruce A. Mah  case $1 in
65487ee810SBruce A. Mah    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66487ee810SBruce A. Mah      *) dir=;;
67487ee810SBruce A. Mah  esac
68487ee810SBruce A. Mah}
69487ee810SBruce A. Mah
70487ee810SBruce A. Mah# Get the suffix-stripped basename of the given path, and save it the
71487ee810SBruce A. Mah# global variable '$base'.
72487ee810SBruce A. Mahset_base_from ()
73487ee810SBruce A. Mah{
74487ee810SBruce A. Mah  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
75487ee810SBruce A. Mah}
76487ee810SBruce A. Mah
77487ee810SBruce A. Mah# If no dependency file was actually created by the compiler invocation,
78487ee810SBruce A. Mah# we still have to create a dummy depfile, to avoid errors with the
79487ee810SBruce A. Mah# Makefile "include basename.Plo" scheme.
80487ee810SBruce A. Mahmake_dummy_depfile ()
81487ee810SBruce A. Mah{
82487ee810SBruce A. Mah  echo "#dummy" > "$depfile"
83487ee810SBruce A. Mah}
84487ee810SBruce A. Mah
85487ee810SBruce A. Mah# Factor out some common post-processing of the generated depfile.
86487ee810SBruce A. Mah# Requires the auxiliary global variable '$tmpdepfile' to be set.
87487ee810SBruce A. Mahaix_post_process_depfile ()
88487ee810SBruce A. Mah{
89487ee810SBruce A. Mah  # If the compiler actually managed to produce a dependency file,
90487ee810SBruce A. Mah  # post-process it.
91487ee810SBruce A. Mah  if test -f "$tmpdepfile"; then
92487ee810SBruce A. Mah    # Each line is of the form 'foo.o: dependency.h'.
93487ee810SBruce A. Mah    # Do two passes, one to just change these to
94487ee810SBruce A. Mah    #   $object: dependency.h
95487ee810SBruce A. Mah    # and one to simply output
96487ee810SBruce A. Mah    #   dependency.h:
97487ee810SBruce A. Mah    # which is needed to avoid the deleted-header problem.
98487ee810SBruce A. Mah    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
99487ee810SBruce A. Mah      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
100487ee810SBruce A. Mah    } > "$depfile"
101487ee810SBruce A. Mah    rm -f "$tmpdepfile"
102487ee810SBruce A. Mah  else
103487ee810SBruce A. Mah    make_dummy_depfile
104487ee810SBruce A. Mah  fi
105487ee810SBruce A. Mah}
106487ee810SBruce A. Mah
107487ee810SBruce A. Mah# A tabulation character.
108487ee810SBruce A. Mahtab='	'
109487ee810SBruce A. Mah# A newline character.
110487ee810SBruce A. Mahnl='
111487ee810SBruce A. Mah'
112487ee810SBruce A. Mah# Character ranges might be problematic outside the C locale.
113487ee810SBruce A. Mah# These definitions help.
114487ee810SBruce A. Mahupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
115487ee810SBruce A. Mahlower=abcdefghijklmnopqrstuvwxyz
116487ee810SBruce A. Mahdigits=0123456789
117487ee810SBruce A. Mahalpha=${upper}${lower}
118487ee810SBruce A. Mah
119e34c20c8SJon Duganif test -z "$depmode" || test -z "$source" || test -z "$object"; then
120e34c20c8SJon Dugan  echo "depcomp: Variables source, object and depmode must be set" 1>&2
121e34c20c8SJon Dugan  exit 1
122e34c20c8SJon Duganfi
123e34c20c8SJon Dugan
124e34c20c8SJon Dugan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
125e34c20c8SJon Dugandepfile=${depfile-`echo "$object" |
126e34c20c8SJon Dugan  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
127e34c20c8SJon Dugantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
128e34c20c8SJon Dugan
129e34c20c8SJon Duganrm -f "$tmpdepfile"
130e34c20c8SJon Dugan
131487ee810SBruce A. Mah# Avoid interferences from the environment.
132487ee810SBruce A. Mahgccflag= dashmflag=
133487ee810SBruce A. Mah
134e34c20c8SJon Dugan# Some modes work just like other modes, but use different flags.  We
135e34c20c8SJon Dugan# parameterize here, but still list the modes in the big case below,
136e34c20c8SJon Dugan# to make depend.m4 easier to write.  Note that we *cannot* use a case
137e34c20c8SJon Dugan# here, because this file can only contain one case statement.
138e34c20c8SJon Duganif test "$depmode" = hp; then
139e34c20c8SJon Dugan  # HP compiler uses -M and no extra arg.
140e34c20c8SJon Dugan  gccflag=-M
141e34c20c8SJon Dugan  depmode=gcc
142e34c20c8SJon Duganfi
143e34c20c8SJon Dugan
144e34c20c8SJon Duganif test "$depmode" = dashXmstdout; then
145e34c20c8SJon Dugan  # This is just like dashmstdout with a different argument.
146e34c20c8SJon Dugan  dashmflag=-xM
147e34c20c8SJon Dugan  depmode=dashmstdout
148e34c20c8SJon Duganfi
149e34c20c8SJon Dugan
150487ee810SBruce A. Mahcygpath_u="cygpath -u -f -"
151487ee810SBruce A. Mahif test "$depmode" = msvcmsys; then
152487ee810SBruce A. Mah  # This is just like msvisualcpp but w/o cygpath translation.
153487ee810SBruce A. Mah  # Just convert the backslash-escaped backslashes to single forward
154487ee810SBruce A. Mah  # slashes to satisfy depend.m4
155487ee810SBruce A. Mah  cygpath_u='sed s,\\\\,/,g'
156487ee810SBruce A. Mah  depmode=msvisualcpp
157487ee810SBruce A. Mahfi
158487ee810SBruce A. Mah
159487ee810SBruce A. Mahif test "$depmode" = msvc7msys; then
160487ee810SBruce A. Mah  # This is just like msvc7 but w/o cygpath translation.
161487ee810SBruce A. Mah  # Just convert the backslash-escaped backslashes to single forward
162487ee810SBruce A. Mah  # slashes to satisfy depend.m4
163487ee810SBruce A. Mah  cygpath_u='sed s,\\\\,/,g'
164487ee810SBruce A. Mah  depmode=msvc7
165487ee810SBruce A. Mahfi
166487ee810SBruce A. Mah
167487ee810SBruce A. Mahif test "$depmode" = xlc; then
168487ee810SBruce A. Mah  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
169487ee810SBruce A. Mah  gccflag=-qmakedep=gcc,-MF
170487ee810SBruce A. Mah  depmode=gcc
171487ee810SBruce A. Mahfi
172487ee810SBruce A. Mah
173e34c20c8SJon Dugancase "$depmode" in
174e34c20c8SJon Dugangcc3)
175e34c20c8SJon Dugan## gcc 3 implements dependency tracking that does exactly what
176e34c20c8SJon Dugan## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
177e34c20c8SJon Dugan## it if -MD -MP comes after the -MF stuff.  Hmm.
178487ee810SBruce A. Mah## Unfortunately, FreeBSD c89 acceptance of flags depends upon
179487ee810SBruce A. Mah## the command line argument order; so add the flags where they
180487ee810SBruce A. Mah## appear in depend2.am.  Note that the slowdown incurred here
181487ee810SBruce A. Mah## affects only configure: in makefiles, %FASTDEP% shortcuts this.
182487ee810SBruce A. Mah  for arg
183487ee810SBruce A. Mah  do
184487ee810SBruce A. Mah    case $arg in
185487ee810SBruce A. Mah    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
186487ee810SBruce A. Mah    *)  set fnord "$@" "$arg" ;;
187487ee810SBruce A. Mah    esac
188487ee810SBruce A. Mah    shift # fnord
189487ee810SBruce A. Mah    shift # $arg
190487ee810SBruce A. Mah  done
191487ee810SBruce A. Mah  "$@"
192e34c20c8SJon Dugan  stat=$?
193487ee810SBruce A. Mah  if test $stat -ne 0; then
194e34c20c8SJon Dugan    rm -f "$tmpdepfile"
195e34c20c8SJon Dugan    exit $stat
196e34c20c8SJon Dugan  fi
197e34c20c8SJon Dugan  mv "$tmpdepfile" "$depfile"
198e34c20c8SJon Dugan  ;;
199e34c20c8SJon Dugan
200e34c20c8SJon Dugangcc)
201487ee810SBruce A. Mah## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
202487ee810SBruce A. Mah## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
203487ee810SBruce A. Mah## (see the conditional assignment to $gccflag above).
204e34c20c8SJon Dugan## There are various ways to get dependency output from gcc.  Here's
205e34c20c8SJon Dugan## why we pick this rather obscure method:
206e34c20c8SJon Dugan## - Don't want to use -MD because we'd like the dependencies to end
207e34c20c8SJon Dugan##   up in a subdir.  Having to rename by hand is ugly.
208e34c20c8SJon Dugan##   (We might end up doing this anyway to support other compilers.)
209e34c20c8SJon Dugan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
210487ee810SBruce A. Mah##   -MM, not -M (despite what the docs say).  Also, it might not be
211487ee810SBruce A. Mah##   supported by the other compilers which use the 'gcc' depmode.
212e34c20c8SJon Dugan## - Using -M directly means running the compiler twice (even worse
213e34c20c8SJon Dugan##   than renaming).
214e34c20c8SJon Dugan  if test -z "$gccflag"; then
215e34c20c8SJon Dugan    gccflag=-MD,
216e34c20c8SJon Dugan  fi
217e34c20c8SJon Dugan  "$@" -Wp,"$gccflag$tmpdepfile"
218e34c20c8SJon Dugan  stat=$?
219487ee810SBruce A. Mah  if test $stat -ne 0; then
220e34c20c8SJon Dugan    rm -f "$tmpdepfile"
221e34c20c8SJon Dugan    exit $stat
222e34c20c8SJon Dugan  fi
223e34c20c8SJon Dugan  rm -f "$depfile"
224e34c20c8SJon Dugan  echo "$object : \\" > "$depfile"
225487ee810SBruce A. Mah  # The second -e expression handles DOS-style file names with drive
226487ee810SBruce A. Mah  # letters.
227e34c20c8SJon Dugan  sed -e 's/^[^:]*: / /' \
228e34c20c8SJon Dugan      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
229487ee810SBruce A. Mah## This next piece of magic avoids the "deleted header file" problem.
230e34c20c8SJon Dugan## The problem is that when a header file which appears in a .P file
231e34c20c8SJon Dugan## is deleted, the dependency causes make to die (because there is
232e34c20c8SJon Dugan## typically no way to rebuild the header).  We avoid this by adding
233e34c20c8SJon Dugan## dummy dependencies for each header file.  Too bad gcc doesn't do
234e34c20c8SJon Dugan## this for us directly.
235487ee810SBruce A. Mah## Some versions of gcc put a space before the ':'.  On the theory
236e34c20c8SJon Dugan## that the space means something, we add a space to the output as
237487ee810SBruce A. Mah## well.  hp depmode also adds that space, but also prefixes the VPATH
238487ee810SBruce A. Mah## to the object.  Take care to not repeat it in the output.
239e34c20c8SJon Dugan## Some versions of the HPUX 10.20 sed can't process this invocation
240e34c20c8SJon Dugan## correctly.  Breaking it into two sed invocations is a workaround.
241487ee810SBruce A. Mah  tr ' ' "$nl" < "$tmpdepfile" \
242487ee810SBruce A. Mah    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
243487ee810SBruce A. Mah    | sed -e 's/$/ :/' >> "$depfile"
244e34c20c8SJon Dugan  rm -f "$tmpdepfile"
245e34c20c8SJon Dugan  ;;
246e34c20c8SJon Dugan
247e34c20c8SJon Duganhp)
248e34c20c8SJon Dugan  # This case exists only to let depend.m4 do its work.  It works by
249e34c20c8SJon Dugan  # looking at the text of this script.  This case will never be run,
250e34c20c8SJon Dugan  # since it is checked for above.
251e34c20c8SJon Dugan  exit 1
252e34c20c8SJon Dugan  ;;
253e34c20c8SJon Dugan
254e34c20c8SJon Dugansgi)
255e34c20c8SJon Dugan  if test "$libtool" = yes; then
256e34c20c8SJon Dugan    "$@" "-Wp,-MDupdate,$tmpdepfile"
257e34c20c8SJon Dugan  else
258e34c20c8SJon Dugan    "$@" -MDupdate "$tmpdepfile"
259e34c20c8SJon Dugan  fi
260e34c20c8SJon Dugan  stat=$?
261487ee810SBruce A. Mah  if test $stat -ne 0; then
262e34c20c8SJon Dugan    rm -f "$tmpdepfile"
263e34c20c8SJon Dugan    exit $stat
264e34c20c8SJon Dugan  fi
265e34c20c8SJon Dugan  rm -f "$depfile"
266e34c20c8SJon Dugan
267e34c20c8SJon Dugan  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
268e34c20c8SJon Dugan    echo "$object : \\" > "$depfile"
269e34c20c8SJon Dugan    # Clip off the initial element (the dependent).  Don't try to be
270e34c20c8SJon Dugan    # clever and replace this with sed code, as IRIX sed won't handle
271e34c20c8SJon Dugan    # lines with more than a fixed number of characters (4096 in
272e34c20c8SJon Dugan    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
273487ee810SBruce A. Mah    # the IRIX cc adds comments like '#:fec' to the end of the
274e34c20c8SJon Dugan    # dependency line.
275487ee810SBruce A. Mah    tr ' ' "$nl" < "$tmpdepfile" \
276487ee810SBruce A. Mah      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
277487ee810SBruce A. Mah      | tr "$nl" ' ' >> "$depfile"
278487ee810SBruce A. Mah    echo >> "$depfile"
279e34c20c8SJon Dugan    # The second pass generates a dummy entry for each header file.
280487ee810SBruce A. Mah    tr ' ' "$nl" < "$tmpdepfile" \
281e34c20c8SJon Dugan      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
282487ee810SBruce A. Mah      >> "$depfile"
283e34c20c8SJon Dugan  else
284487ee810SBruce A. Mah    make_dummy_depfile
285e34c20c8SJon Dugan  fi
286e34c20c8SJon Dugan  rm -f "$tmpdepfile"
287e34c20c8SJon Dugan  ;;
288e34c20c8SJon Dugan
289487ee810SBruce A. Mahxlc)
290487ee810SBruce A. Mah  # This case exists only to let depend.m4 do its work.  It works by
291487ee810SBruce A. Mah  # looking at the text of this script.  This case will never be run,
292487ee810SBruce A. Mah  # since it is checked for above.
293487ee810SBruce A. Mah  exit 1
294487ee810SBruce A. Mah  ;;
295487ee810SBruce A. Mah
296e34c20c8SJon Duganaix)
297e34c20c8SJon Dugan  # The C for AIX Compiler uses -M and outputs the dependencies
298e34c20c8SJon Dugan  # in a .u file.  In older versions, this file always lives in the
299487ee810SBruce A. Mah  # current directory.  Also, the AIX compiler puts '$object:' at the
300e34c20c8SJon Dugan  # start of each line; $object doesn't have directory information.
301e34c20c8SJon Dugan  # Version 6 uses the directory in both cases.
302487ee810SBruce A. Mah  set_dir_from "$object"
303487ee810SBruce A. Mah  set_base_from "$object"
304e34c20c8SJon Dugan  if test "$libtool" = yes; then
305487ee810SBruce A. Mah    tmpdepfile1=$dir$base.u
306487ee810SBruce A. Mah    tmpdepfile2=$base.u
307487ee810SBruce A. Mah    tmpdepfile3=$dir.libs/$base.u
308e34c20c8SJon Dugan    "$@" -Wc,-M
309e34c20c8SJon Dugan  else
310487ee810SBruce A. Mah    tmpdepfile1=$dir$base.u
311487ee810SBruce A. Mah    tmpdepfile2=$dir$base.u
312487ee810SBruce A. Mah    tmpdepfile3=$dir$base.u
313e34c20c8SJon Dugan    "$@" -M
314e34c20c8SJon Dugan  fi
315e34c20c8SJon Dugan  stat=$?
316487ee810SBruce A. Mah  if test $stat -ne 0; then
317487ee810SBruce A. Mah    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
318e34c20c8SJon Dugan    exit $stat
319e34c20c8SJon Dugan  fi
320e34c20c8SJon Dugan
321487ee810SBruce A. Mah  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
322487ee810SBruce A. Mah  do
323487ee810SBruce A. Mah    test -f "$tmpdepfile" && break
324487ee810SBruce A. Mah  done
325487ee810SBruce A. Mah  aix_post_process_depfile
326487ee810SBruce A. Mah  ;;
327487ee810SBruce A. Mah
328487ee810SBruce A. Mahtcc)
329487ee810SBruce A. Mah  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
330487ee810SBruce A. Mah  # FIXME: That version still under development at the moment of writing.
331487ee810SBruce A. Mah  #        Make that this statement remains true also for stable, released
332487ee810SBruce A. Mah  #        versions.
333487ee810SBruce A. Mah  # It will wrap lines (doesn't matter whether long or short) with a
334487ee810SBruce A. Mah  # trailing '\', as in:
335487ee810SBruce A. Mah  #
336487ee810SBruce A. Mah  #   foo.o : \
337487ee810SBruce A. Mah  #    foo.c \
338487ee810SBruce A. Mah  #    foo.h \
339487ee810SBruce A. Mah  #
340487ee810SBruce A. Mah  # It will put a trailing '\' even on the last line, and will use leading
341487ee810SBruce A. Mah  # spaces rather than leading tabs (at least since its commit 0394caf7
342487ee810SBruce A. Mah  # "Emit spaces for -MD").
343487ee810SBruce A. Mah  "$@" -MD -MF "$tmpdepfile"
344487ee810SBruce A. Mah  stat=$?
345487ee810SBruce A. Mah  if test $stat -ne 0; then
346487ee810SBruce A. Mah    rm -f "$tmpdepfile"
347487ee810SBruce A. Mah    exit $stat
348e34c20c8SJon Dugan  fi
349487ee810SBruce A. Mah  rm -f "$depfile"
350487ee810SBruce A. Mah  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
351487ee810SBruce A. Mah  # We have to change lines of the first kind to '$object: \'.
352487ee810SBruce A. Mah  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
353487ee810SBruce A. Mah  # And for each line of the second kind, we have to emit a 'dep.h:'
354487ee810SBruce A. Mah  # dummy dependency, to avoid the deleted-header problem.
355487ee810SBruce A. Mah  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
356e34c20c8SJon Dugan  rm -f "$tmpdepfile"
357e34c20c8SJon Dugan  ;;
358e34c20c8SJon Dugan
359487ee810SBruce A. Mah## The order of this option in the case statement is important, since the
360487ee810SBruce A. Mah## shell code in configure will try each of these formats in the order
361487ee810SBruce A. Mah## listed in this file.  A plain '-MD' option would be understood by many
362487ee810SBruce A. Mah## compilers, so we must ensure this comes after the gcc and icc options.
363487ee810SBruce A. Mahpgcc)
364487ee810SBruce A. Mah  # Portland's C compiler understands '-MD'.
365487ee810SBruce A. Mah  # Will always output deps to 'file.d' where file is the root name of the
366487ee810SBruce A. Mah  # source file under compilation, even if file resides in a subdirectory.
367487ee810SBruce A. Mah  # The object file name does not affect the name of the '.d' file.
368487ee810SBruce A. Mah  # pgcc 10.2 will output
369e34c20c8SJon Dugan  #    foo.o: sub/foo.c sub/foo.h
370487ee810SBruce A. Mah  # and will wrap long lines using '\' :
371e34c20c8SJon Dugan  #    foo.o: sub/foo.c ... \
372e34c20c8SJon Dugan  #     sub/foo.h ... \
373e34c20c8SJon Dugan  #     ...
374487ee810SBruce A. Mah  set_dir_from "$object"
375487ee810SBruce A. Mah  # Use the source, not the object, to determine the base name, since
376487ee810SBruce A. Mah  # that's sadly what pgcc will do too.
377487ee810SBruce A. Mah  set_base_from "$source"
378487ee810SBruce A. Mah  tmpdepfile=$base.d
379e34c20c8SJon Dugan
380487ee810SBruce A. Mah  # For projects that build the same source file twice into different object
381487ee810SBruce A. Mah  # files, the pgcc approach of using the *source* file root name can cause
382487ee810SBruce A. Mah  # problems in parallel builds.  Use a locking strategy to avoid stomping on
383487ee810SBruce A. Mah  # the same $tmpdepfile.
384487ee810SBruce A. Mah  lockdir=$base.d-lock
385487ee810SBruce A. Mah  trap "
386487ee810SBruce A. Mah    echo '$0: caught signal, cleaning up...' >&2
387487ee810SBruce A. Mah    rmdir '$lockdir'
388487ee810SBruce A. Mah    exit 1
389487ee810SBruce A. Mah  " 1 2 13 15
390487ee810SBruce A. Mah  numtries=100
391487ee810SBruce A. Mah  i=$numtries
392487ee810SBruce A. Mah  while test $i -gt 0; do
393487ee810SBruce A. Mah    # mkdir is a portable test-and-set.
394487ee810SBruce A. Mah    if mkdir "$lockdir" 2>/dev/null; then
395487ee810SBruce A. Mah      # This process acquired the lock.
396487ee810SBruce A. Mah      "$@" -MD
397e34c20c8SJon Dugan      stat=$?
398487ee810SBruce A. Mah      # Release the lock.
399487ee810SBruce A. Mah      rmdir "$lockdir"
400487ee810SBruce A. Mah      break
401e34c20c8SJon Dugan    else
402487ee810SBruce A. Mah      # If the lock is being held by a different process, wait
403487ee810SBruce A. Mah      # until the winning process is done or we timeout.
404487ee810SBruce A. Mah      while test -d "$lockdir" && test $i -gt 0; do
405487ee810SBruce A. Mah        sleep 1
406487ee810SBruce A. Mah        i=`expr $i - 1`
407487ee810SBruce A. Mah      done
408487ee810SBruce A. Mah    fi
409487ee810SBruce A. Mah    i=`expr $i - 1`
410487ee810SBruce A. Mah  done
411487ee810SBruce A. Mah  trap - 1 2 13 15
412487ee810SBruce A. Mah  if test $i -le 0; then
413487ee810SBruce A. Mah    echo "$0: failed to acquire lock after $numtries attempts" >&2
414487ee810SBruce A. Mah    echo "$0: check lockdir '$lockdir'" >&2
415487ee810SBruce A. Mah    exit 1
416487ee810SBruce A. Mah  fi
417487ee810SBruce A. Mah
418487ee810SBruce A. Mah  if test $stat -ne 0; then
419e34c20c8SJon Dugan    rm -f "$tmpdepfile"
420e34c20c8SJon Dugan    exit $stat
421e34c20c8SJon Dugan  fi
422e34c20c8SJon Dugan  rm -f "$depfile"
423e34c20c8SJon Dugan  # Each line is of the form `foo.o: dependent.h',
424e34c20c8SJon Dugan  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
425e34c20c8SJon Dugan  # Do two passes, one to just change these to
426e34c20c8SJon Dugan  # `$object: dependent.h' and one to simply `dependent.h:'.
427e34c20c8SJon Dugan  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
428e34c20c8SJon Dugan  # Some versions of the HPUX 10.20 sed can't process this invocation
429e34c20c8SJon Dugan  # correctly.  Breaking it into two sed invocations is a workaround.
430487ee810SBruce A. Mah  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
431487ee810SBruce A. Mah    | sed -e 's/$/ :/' >> "$depfile"
432e34c20c8SJon Dugan  rm -f "$tmpdepfile"
433e34c20c8SJon Dugan  ;;
434e34c20c8SJon Dugan
435487ee810SBruce A. Mahhp2)
436487ee810SBruce A. Mah  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
437487ee810SBruce A. Mah  # compilers, which have integrated preprocessors.  The correct option
438487ee810SBruce A. Mah  # to use with these is +Maked; it writes dependencies to a file named
439487ee810SBruce A. Mah  # 'foo.d', which lands next to the object file, wherever that
440487ee810SBruce A. Mah  # happens to be.
441487ee810SBruce A. Mah  # Much of this is similar to the tru64 case; see comments there.
442487ee810SBruce A. Mah  set_dir_from  "$object"
443487ee810SBruce A. Mah  set_base_from "$object"
444487ee810SBruce A. Mah  if test "$libtool" = yes; then
445487ee810SBruce A. Mah    tmpdepfile1=$dir$base.d
446487ee810SBruce A. Mah    tmpdepfile2=$dir.libs/$base.d
447487ee810SBruce A. Mah    "$@" -Wc,+Maked
448487ee810SBruce A. Mah  else
449487ee810SBruce A. Mah    tmpdepfile1=$dir$base.d
450487ee810SBruce A. Mah    tmpdepfile2=$dir$base.d
451487ee810SBruce A. Mah    "$@" +Maked
452487ee810SBruce A. Mah  fi
453487ee810SBruce A. Mah  stat=$?
454487ee810SBruce A. Mah  if test $stat -ne 0; then
455487ee810SBruce A. Mah     rm -f "$tmpdepfile1" "$tmpdepfile2"
456487ee810SBruce A. Mah     exit $stat
457487ee810SBruce A. Mah  fi
458487ee810SBruce A. Mah
459487ee810SBruce A. Mah  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
460487ee810SBruce A. Mah  do
461487ee810SBruce A. Mah    test -f "$tmpdepfile" && break
462487ee810SBruce A. Mah  done
463487ee810SBruce A. Mah  if test -f "$tmpdepfile"; then
464487ee810SBruce A. Mah    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
465487ee810SBruce A. Mah    # Add 'dependent.h:' lines.
466487ee810SBruce A. Mah    sed -ne '2,${
467487ee810SBruce A. Mah               s/^ *//
468487ee810SBruce A. Mah               s/ \\*$//
469487ee810SBruce A. Mah               s/$/:/
470487ee810SBruce A. Mah               p
471487ee810SBruce A. Mah             }' "$tmpdepfile" >> "$depfile"
472487ee810SBruce A. Mah  else
473487ee810SBruce A. Mah    make_dummy_depfile
474487ee810SBruce A. Mah  fi
475487ee810SBruce A. Mah  rm -f "$tmpdepfile" "$tmpdepfile2"
476487ee810SBruce A. Mah  ;;
477487ee810SBruce A. Mah
478e34c20c8SJon Dugantru64)
479e34c20c8SJon Dugan  # The Tru64 compiler uses -MD to generate dependencies as a side
480487ee810SBruce A. Mah  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
481e34c20c8SJon Dugan  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
482487ee810SBruce A. Mah  # dependencies in 'foo.d' instead, so we check for that too.
483e34c20c8SJon Dugan  # Subdirectories are respected.
484487ee810SBruce A. Mah  set_dir_from  "$object"
485487ee810SBruce A. Mah  set_base_from "$object"
486e34c20c8SJon Dugan
487e34c20c8SJon Dugan  if test "$libtool" = yes; then
488487ee810SBruce A. Mah    # Libtool generates 2 separate objects for the 2 libraries.  These
489487ee810SBruce A. Mah    # two compilations output dependencies in $dir.libs/$base.o.d and
490e34c20c8SJon Dugan    # in $dir$base.o.d.  We have to check for both files, because
491e34c20c8SJon Dugan    # one of the two compilations can be disabled.  We should prefer
492e34c20c8SJon Dugan    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
493e34c20c8SJon Dugan    # automatically cleaned when .libs/ is deleted, while ignoring
494e34c20c8SJon Dugan    # the former would cause a distcleancheck panic.
495487ee810SBruce A. Mah    tmpdepfile1=$dir$base.o.d          # libtool 1.5
496487ee810SBruce A. Mah    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
497487ee810SBruce A. Mah    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
498e34c20c8SJon Dugan    "$@" -Wc,-MD
499e34c20c8SJon Dugan  else
500487ee810SBruce A. Mah    tmpdepfile1=$dir$base.d
501e34c20c8SJon Dugan    tmpdepfile2=$dir$base.d
502e34c20c8SJon Dugan    tmpdepfile3=$dir$base.d
503e34c20c8SJon Dugan    "$@" -MD
504e34c20c8SJon Dugan  fi
505e34c20c8SJon Dugan
506e34c20c8SJon Dugan  stat=$?
507487ee810SBruce A. Mah  if test $stat -ne 0; then
508487ee810SBruce A. Mah    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
509e34c20c8SJon Dugan    exit $stat
510e34c20c8SJon Dugan  fi
511e34c20c8SJon Dugan
512487ee810SBruce A. Mah  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
513e34c20c8SJon Dugan  do
514e34c20c8SJon Dugan    test -f "$tmpdepfile" && break
515e34c20c8SJon Dugan  done
516487ee810SBruce A. Mah  # Same post-processing that is required for AIX mode.
517487ee810SBruce A. Mah  aix_post_process_depfile
518487ee810SBruce A. Mah  ;;
519487ee810SBruce A. Mah
520487ee810SBruce A. Mahmsvc7)
521487ee810SBruce A. Mah  if test "$libtool" = yes; then
522487ee810SBruce A. Mah    showIncludes=-Wc,-showIncludes
523e34c20c8SJon Dugan  else
524487ee810SBruce A. Mah    showIncludes=-showIncludes
525e34c20c8SJon Dugan  fi
526487ee810SBruce A. Mah  "$@" $showIncludes > "$tmpdepfile"
527487ee810SBruce A. Mah  stat=$?
528487ee810SBruce A. Mah  grep -v '^Note: including file: ' "$tmpdepfile"
529487ee810SBruce A. Mah  if test $stat -ne 0; then
530e34c20c8SJon Dugan    rm -f "$tmpdepfile"
531487ee810SBruce A. Mah    exit $stat
532487ee810SBruce A. Mah  fi
533487ee810SBruce A. Mah  rm -f "$depfile"
534487ee810SBruce A. Mah  echo "$object : \\" > "$depfile"
535487ee810SBruce A. Mah  # The first sed program below extracts the file names and escapes
536487ee810SBruce A. Mah  # backslashes for cygpath.  The second sed program outputs the file
537487ee810SBruce A. Mah  # name when reading, but also accumulates all include files in the
538487ee810SBruce A. Mah  # hold buffer in order to output them again at the end.  This only
539487ee810SBruce A. Mah  # works with sed implementations that can handle large buffers.
540487ee810SBruce A. Mah  sed < "$tmpdepfile" -n '
541487ee810SBruce A. Mah/^Note: including file:  *\(.*\)/ {
542487ee810SBruce A. Mah  s//\1/
543487ee810SBruce A. Mah  s/\\/\\\\/g
544487ee810SBruce A. Mah  p
545487ee810SBruce A. Mah}' | $cygpath_u | sort -u | sed -n '
546487ee810SBruce A. Mahs/ /\\ /g
547487ee810SBruce A. Mahs/\(.*\)/'"$tab"'\1 \\/p
548487ee810SBruce A. Mahs/.\(.*\) \\/\1:/
549487ee810SBruce A. MahH
550487ee810SBruce A. Mah$ {
551487ee810SBruce A. Mah  s/.*/'"$tab"'/
552487ee810SBruce A. Mah  G
553487ee810SBruce A. Mah  p
554487ee810SBruce A. Mah}' >> "$depfile"
555487ee810SBruce A. Mah  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
556487ee810SBruce A. Mah  rm -f "$tmpdepfile"
557487ee810SBruce A. Mah  ;;
558487ee810SBruce A. Mah
559487ee810SBruce A. Mahmsvc7msys)
560487ee810SBruce A. Mah  # This case exists only to let depend.m4 do its work.  It works by
561487ee810SBruce A. Mah  # looking at the text of this script.  This case will never be run,
562487ee810SBruce A. Mah  # since it is checked for above.
563487ee810SBruce A. Mah  exit 1
564e34c20c8SJon Dugan  ;;
565e34c20c8SJon Dugan
566e34c20c8SJon Dugan#nosideeffect)
567e34c20c8SJon Dugan  # This comment above is used by automake to tell side-effect
568e34c20c8SJon Dugan  # dependency tracking mechanisms from slower ones.
569e34c20c8SJon Dugan
570e34c20c8SJon Dugandashmstdout)
571e34c20c8SJon Dugan  # Important note: in order to support this mode, a compiler *must*
572e34c20c8SJon Dugan  # always write the preprocessed file to stdout, regardless of -o.
573e34c20c8SJon Dugan  "$@" || exit $?
574e34c20c8SJon Dugan
575e34c20c8SJon Dugan  # Remove the call to Libtool.
576e34c20c8SJon Dugan  if test "$libtool" = yes; then
577487ee810SBruce A. Mah    while test "X$1" != 'X--mode=compile'; do
578e34c20c8SJon Dugan      shift
579e34c20c8SJon Dugan    done
580e34c20c8SJon Dugan    shift
581e34c20c8SJon Dugan  fi
582e34c20c8SJon Dugan
583487ee810SBruce A. Mah  # Remove '-o $object'.
584e34c20c8SJon Dugan  IFS=" "
585e34c20c8SJon Dugan  for arg
586e34c20c8SJon Dugan  do
587e34c20c8SJon Dugan    case $arg in
588e34c20c8SJon Dugan    -o)
589e34c20c8SJon Dugan      shift
590e34c20c8SJon Dugan      ;;
591e34c20c8SJon Dugan    $object)
592e34c20c8SJon Dugan      shift
593e34c20c8SJon Dugan      ;;
594e34c20c8SJon Dugan    *)
595e34c20c8SJon Dugan      set fnord "$@" "$arg"
596e34c20c8SJon Dugan      shift # fnord
597e34c20c8SJon Dugan      shift # $arg
598e34c20c8SJon Dugan      ;;
599e34c20c8SJon Dugan    esac
600e34c20c8SJon Dugan  done
601e34c20c8SJon Dugan
602e34c20c8SJon Dugan  test -z "$dashmflag" && dashmflag=-M
603487ee810SBruce A. Mah  # Require at least two characters before searching for ':'
604e34c20c8SJon Dugan  # in the target name.  This is to cope with DOS-style filenames:
605487ee810SBruce A. Mah  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
606e34c20c8SJon Dugan  "$@" $dashmflag |
607487ee810SBruce A. Mah    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
608e34c20c8SJon Dugan  rm -f "$depfile"
609e34c20c8SJon Dugan  cat < "$tmpdepfile" > "$depfile"
610487ee810SBruce A. Mah  # Some versions of the HPUX 10.20 sed can't process this sed invocation
611487ee810SBruce A. Mah  # correctly.  Breaking it into two sed invocations is a workaround.
612487ee810SBruce A. Mah  tr ' ' "$nl" < "$tmpdepfile" \
613487ee810SBruce A. Mah    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
614487ee810SBruce A. Mah    | sed -e 's/$/ :/' >> "$depfile"
615e34c20c8SJon Dugan  rm -f "$tmpdepfile"
616e34c20c8SJon Dugan  ;;
617e34c20c8SJon Dugan
618e34c20c8SJon DugandashXmstdout)
619e34c20c8SJon Dugan  # This case only exists to satisfy depend.m4.  It is never actually
620e34c20c8SJon Dugan  # run, as this mode is specially recognized in the preamble.
621e34c20c8SJon Dugan  exit 1
622e34c20c8SJon Dugan  ;;
623e34c20c8SJon Dugan
624e34c20c8SJon Duganmakedepend)
625e34c20c8SJon Dugan  "$@" || exit $?
626e34c20c8SJon Dugan  # Remove any Libtool call
627e34c20c8SJon Dugan  if test "$libtool" = yes; then
628487ee810SBruce A. Mah    while test "X$1" != 'X--mode=compile'; do
629e34c20c8SJon Dugan      shift
630e34c20c8SJon Dugan    done
631e34c20c8SJon Dugan    shift
632e34c20c8SJon Dugan  fi
633e34c20c8SJon Dugan  # X makedepend
634e34c20c8SJon Dugan  shift
635487ee810SBruce A. Mah  cleared=no eat=no
636487ee810SBruce A. Mah  for arg
637487ee810SBruce A. Mah  do
638e34c20c8SJon Dugan    case $cleared in
639e34c20c8SJon Dugan    no)
640e34c20c8SJon Dugan      set ""; shift
641e34c20c8SJon Dugan      cleared=yes ;;
642e34c20c8SJon Dugan    esac
643487ee810SBruce A. Mah    if test $eat = yes; then
644487ee810SBruce A. Mah      eat=no
645487ee810SBruce A. Mah      continue
646487ee810SBruce A. Mah    fi
647e34c20c8SJon Dugan    case "$arg" in
648e34c20c8SJon Dugan    -D*|-I*)
649e34c20c8SJon Dugan      set fnord "$@" "$arg"; shift ;;
650e34c20c8SJon Dugan    # Strip any option that makedepend may not understand.  Remove
651e34c20c8SJon Dugan    # the object too, otherwise makedepend will parse it as a source file.
652487ee810SBruce A. Mah    -arch)
653487ee810SBruce A. Mah      eat=yes ;;
654e34c20c8SJon Dugan    -*|$object)
655e34c20c8SJon Dugan      ;;
656e34c20c8SJon Dugan    *)
657e34c20c8SJon Dugan      set fnord "$@" "$arg"; shift ;;
658e34c20c8SJon Dugan    esac
659e34c20c8SJon Dugan  done
660487ee810SBruce A. Mah  obj_suffix=`echo "$object" | sed 's/^.*\././'`
661e34c20c8SJon Dugan  touch "$tmpdepfile"
662e34c20c8SJon Dugan  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
663e34c20c8SJon Dugan  rm -f "$depfile"
664487ee810SBruce A. Mah  # makedepend may prepend the VPATH from the source file name to the object.
665487ee810SBruce A. Mah  # No need to regex-escape $object, excess matching of '.' is harmless.
666487ee810SBruce A. Mah  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
667487ee810SBruce A. Mah  # Some versions of the HPUX 10.20 sed can't process the last invocation
668487ee810SBruce A. Mah  # correctly.  Breaking it into two sed invocations is a workaround.
669487ee810SBruce A. Mah  sed '1,2d' "$tmpdepfile" \
670487ee810SBruce A. Mah    | tr ' ' "$nl" \
671487ee810SBruce A. Mah    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
672487ee810SBruce A. Mah    | sed -e 's/$/ :/' >> "$depfile"
673e34c20c8SJon Dugan  rm -f "$tmpdepfile" "$tmpdepfile".bak
674e34c20c8SJon Dugan  ;;
675e34c20c8SJon Dugan
676e34c20c8SJon Dugancpp)
677e34c20c8SJon Dugan  # Important note: in order to support this mode, a compiler *must*
678e34c20c8SJon Dugan  # always write the preprocessed file to stdout.
679e34c20c8SJon Dugan  "$@" || exit $?
680e34c20c8SJon Dugan
681e34c20c8SJon Dugan  # Remove the call to Libtool.
682e34c20c8SJon Dugan  if test "$libtool" = yes; then
683487ee810SBruce A. Mah    while test "X$1" != 'X--mode=compile'; do
684e34c20c8SJon Dugan      shift
685e34c20c8SJon Dugan    done
686e34c20c8SJon Dugan    shift
687e34c20c8SJon Dugan  fi
688e34c20c8SJon Dugan
689487ee810SBruce A. Mah  # Remove '-o $object'.
690e34c20c8SJon Dugan  IFS=" "
691e34c20c8SJon Dugan  for arg
692e34c20c8SJon Dugan  do
693e34c20c8SJon Dugan    case $arg in
694e34c20c8SJon Dugan    -o)
695e34c20c8SJon Dugan      shift
696e34c20c8SJon Dugan      ;;
697e34c20c8SJon Dugan    $object)
698e34c20c8SJon Dugan      shift
699e34c20c8SJon Dugan      ;;
700e34c20c8SJon Dugan    *)
701e34c20c8SJon Dugan      set fnord "$@" "$arg"
702e34c20c8SJon Dugan      shift # fnord
703e34c20c8SJon Dugan      shift # $arg
704e34c20c8SJon Dugan      ;;
705e34c20c8SJon Dugan    esac
706e34c20c8SJon Dugan  done
707e34c20c8SJon Dugan
708487ee810SBruce A. Mah  "$@" -E \
709487ee810SBruce A. Mah    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
710487ee810SBruce A. Mah             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
711487ee810SBruce A. Mah    | sed '$ s: \\$::' > "$tmpdepfile"
712e34c20c8SJon Dugan  rm -f "$depfile"
713e34c20c8SJon Dugan  echo "$object : \\" > "$depfile"
714e34c20c8SJon Dugan  cat < "$tmpdepfile" >> "$depfile"
715e34c20c8SJon Dugan  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
716e34c20c8SJon Dugan  rm -f "$tmpdepfile"
717e34c20c8SJon Dugan  ;;
718e34c20c8SJon Dugan
719e34c20c8SJon Duganmsvisualcpp)
720e34c20c8SJon Dugan  # Important note: in order to support this mode, a compiler *must*
721487ee810SBruce A. Mah  # always write the preprocessed file to stdout.
722e34c20c8SJon Dugan  "$@" || exit $?
723487ee810SBruce A. Mah
724487ee810SBruce A. Mah  # Remove the call to Libtool.
725487ee810SBruce A. Mah  if test "$libtool" = yes; then
726487ee810SBruce A. Mah    while test "X$1" != 'X--mode=compile'; do
727487ee810SBruce A. Mah      shift
728487ee810SBruce A. Mah    done
729487ee810SBruce A. Mah    shift
730487ee810SBruce A. Mah  fi
731487ee810SBruce A. Mah
732e34c20c8SJon Dugan  IFS=" "
733e34c20c8SJon Dugan  for arg
734e34c20c8SJon Dugan  do
735e34c20c8SJon Dugan    case "$arg" in
736487ee810SBruce A. Mah    -o)
737487ee810SBruce A. Mah      shift
738487ee810SBruce A. Mah      ;;
739487ee810SBruce A. Mah    $object)
740487ee810SBruce A. Mah      shift
741487ee810SBruce A. Mah      ;;
742e34c20c8SJon Dugan    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
743e34c20c8SJon Dugan        set fnord "$@"
744e34c20c8SJon Dugan        shift
745e34c20c8SJon Dugan        shift
746e34c20c8SJon Dugan        ;;
747e34c20c8SJon Dugan    *)
748e34c20c8SJon Dugan        set fnord "$@" "$arg"
749e34c20c8SJon Dugan        shift
750e34c20c8SJon Dugan        shift
751e34c20c8SJon Dugan        ;;
752e34c20c8SJon Dugan    esac
753e34c20c8SJon Dugan  done
754487ee810SBruce A. Mah  "$@" -E 2>/dev/null |
755487ee810SBruce A. Mah  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
756e34c20c8SJon Dugan  rm -f "$depfile"
757e34c20c8SJon Dugan  echo "$object : \\" > "$depfile"
758487ee810SBruce A. Mah  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
759487ee810SBruce A. Mah  echo "$tab" >> "$depfile"
760487ee810SBruce A. Mah  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
761e34c20c8SJon Dugan  rm -f "$tmpdepfile"
762e34c20c8SJon Dugan  ;;
763e34c20c8SJon Dugan
764487ee810SBruce A. Mahmsvcmsys)
765487ee810SBruce A. Mah  # This case exists only to let depend.m4 do its work.  It works by
766487ee810SBruce A. Mah  # looking at the text of this script.  This case will never be run,
767487ee810SBruce A. Mah  # since it is checked for above.
768487ee810SBruce A. Mah  exit 1
769487ee810SBruce A. Mah  ;;
770487ee810SBruce A. Mah
771e34c20c8SJon Dugannone)
772e34c20c8SJon Dugan  exec "$@"
773e34c20c8SJon Dugan  ;;
774e34c20c8SJon Dugan
775e34c20c8SJon Dugan*)
776e34c20c8SJon Dugan  echo "Unknown depmode $depmode" 1>&2
777e34c20c8SJon Dugan  exit 1
778e34c20c8SJon Dugan  ;;
779e34c20c8SJon Duganesac
780e34c20c8SJon Dugan
781e34c20c8SJon Duganexit 0
782e34c20c8SJon Dugan
783e34c20c8SJon Dugan# Local Variables:
784e34c20c8SJon Dugan# mode: shell-script
785e34c20c8SJon Dugan# sh-indentation: 2
7866e9d8525SBruce A. Mah# eval: (add-hook 'before-save-hook 'time-stamp)
787e34c20c8SJon Dugan# time-stamp-start: "scriptversion="
788e34c20c8SJon Dugan# time-stamp-format: "%:y-%02m-%02d.%02H"
7897cf95d20SBruce A. Mah# time-stamp-time-zone: "UTC0"
790487ee810SBruce A. Mah# time-stamp-end: "; # UTC"
791e34c20c8SJon Dugan# End:
792