xref: /freebsd/contrib/file/depcomp (revision b6cee71de37d56e36dbc118e2d9b03e7cece5709)
1*b6cee71dSXin LI#! /bin/sh
2*b6cee71dSXin LI# depcomp - compile a program generating dependencies as side-effects
3*b6cee71dSXin LI
4*b6cee71dSXin LIscriptversion=2013-05-30.07; # UTC
5*b6cee71dSXin LI
6*b6cee71dSXin LI# Copyright (C) 1999-2013 Free Software Foundation, Inc.
7*b6cee71dSXin LI
8*b6cee71dSXin LI# This program is free software; you can redistribute it and/or modify
9*b6cee71dSXin LI# it under the terms of the GNU General Public License as published by
10*b6cee71dSXin LI# the Free Software Foundation; either version 2, or (at your option)
11*b6cee71dSXin LI# any later version.
12*b6cee71dSXin LI
13*b6cee71dSXin LI# This program is distributed in the hope that it will be useful,
14*b6cee71dSXin LI# but WITHOUT ANY WARRANTY; without even the implied warranty of
15*b6cee71dSXin LI# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*b6cee71dSXin LI# GNU General Public License for more details.
17*b6cee71dSXin LI
18*b6cee71dSXin LI# You should have received a copy of the GNU General Public License
19*b6cee71dSXin LI# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20*b6cee71dSXin LI
21*b6cee71dSXin LI# As a special exception to the GNU General Public License, if you
22*b6cee71dSXin LI# distribute this file as part of a program that contains a
23*b6cee71dSXin LI# configuration script generated by Autoconf, you may include it under
24*b6cee71dSXin LI# the same distribution terms that you use for the rest of that program.
25*b6cee71dSXin LI
26*b6cee71dSXin LI# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
27*b6cee71dSXin LI
28*b6cee71dSXin LIcase $1 in
29*b6cee71dSXin LI  '')
30*b6cee71dSXin LI    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
31*b6cee71dSXin LI    exit 1;
32*b6cee71dSXin LI    ;;
33*b6cee71dSXin LI  -h | --h*)
34*b6cee71dSXin LI    cat <<\EOF
35*b6cee71dSXin LIUsage: depcomp [--help] [--version] PROGRAM [ARGS]
36*b6cee71dSXin LI
37*b6cee71dSXin LIRun PROGRAMS ARGS to compile a file, generating dependencies
38*b6cee71dSXin LIas side-effects.
39*b6cee71dSXin LI
40*b6cee71dSXin LIEnvironment variables:
41*b6cee71dSXin LI  depmode     Dependency tracking mode.
42*b6cee71dSXin LI  source      Source file read by 'PROGRAMS ARGS'.
43*b6cee71dSXin LI  object      Object file output by 'PROGRAMS ARGS'.
44*b6cee71dSXin LI  DEPDIR      directory where to store dependencies.
45*b6cee71dSXin LI  depfile     Dependency file to output.
46*b6cee71dSXin LI  tmpdepfile  Temporary file to use when outputting dependencies.
47*b6cee71dSXin LI  libtool     Whether libtool is used (yes/no).
48*b6cee71dSXin LI
49*b6cee71dSXin LIReport bugs to <bug-automake@gnu.org>.
50*b6cee71dSXin LIEOF
51*b6cee71dSXin LI    exit $?
52*b6cee71dSXin LI    ;;
53*b6cee71dSXin LI  -v | --v*)
54*b6cee71dSXin LI    echo "depcomp $scriptversion"
55*b6cee71dSXin LI    exit $?
56*b6cee71dSXin LI    ;;
57*b6cee71dSXin LIesac
58*b6cee71dSXin LI
59*b6cee71dSXin LI# Get the directory component of the given path, and save it in the
60*b6cee71dSXin LI# global variables '$dir'.  Note that this directory component will
61*b6cee71dSXin LI# be either empty or ending with a '/' character.  This is deliberate.
62*b6cee71dSXin LIset_dir_from ()
63*b6cee71dSXin LI{
64*b6cee71dSXin LI  case $1 in
65*b6cee71dSXin LI    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66*b6cee71dSXin LI      *) dir=;;
67*b6cee71dSXin LI  esac
68*b6cee71dSXin LI}
69*b6cee71dSXin LI
70*b6cee71dSXin LI# Get the suffix-stripped basename of the given path, and save it the
71*b6cee71dSXin LI# global variable '$base'.
72*b6cee71dSXin LIset_base_from ()
73*b6cee71dSXin LI{
74*b6cee71dSXin LI  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
75*b6cee71dSXin LI}
76*b6cee71dSXin LI
77*b6cee71dSXin LI# If no dependency file was actually created by the compiler invocation,
78*b6cee71dSXin LI# we still have to create a dummy depfile, to avoid errors with the
79*b6cee71dSXin LI# Makefile "include basename.Plo" scheme.
80*b6cee71dSXin LImake_dummy_depfile ()
81*b6cee71dSXin LI{
82*b6cee71dSXin LI  echo "#dummy" > "$depfile"
83*b6cee71dSXin LI}
84*b6cee71dSXin LI
85*b6cee71dSXin LI# Factor out some common post-processing of the generated depfile.
86*b6cee71dSXin LI# Requires the auxiliary global variable '$tmpdepfile' to be set.
87*b6cee71dSXin LIaix_post_process_depfile ()
88*b6cee71dSXin LI{
89*b6cee71dSXin LI  # If the compiler actually managed to produce a dependency file,
90*b6cee71dSXin LI  # post-process it.
91*b6cee71dSXin LI  if test -f "$tmpdepfile"; then
92*b6cee71dSXin LI    # Each line is of the form 'foo.o: dependency.h'.
93*b6cee71dSXin LI    # Do two passes, one to just change these to
94*b6cee71dSXin LI    #   $object: dependency.h
95*b6cee71dSXin LI    # and one to simply output
96*b6cee71dSXin LI    #   dependency.h:
97*b6cee71dSXin LI    # which is needed to avoid the deleted-header problem.
98*b6cee71dSXin LI    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
99*b6cee71dSXin LI      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
100*b6cee71dSXin LI    } > "$depfile"
101*b6cee71dSXin LI    rm -f "$tmpdepfile"
102*b6cee71dSXin LI  else
103*b6cee71dSXin LI    make_dummy_depfile
104*b6cee71dSXin LI  fi
105*b6cee71dSXin LI}
106*b6cee71dSXin LI
107*b6cee71dSXin LI# A tabulation character.
108*b6cee71dSXin LItab='	'
109*b6cee71dSXin LI# A newline character.
110*b6cee71dSXin LInl='
111*b6cee71dSXin LI'
112*b6cee71dSXin LI# Character ranges might be problematic outside the C locale.
113*b6cee71dSXin LI# These definitions help.
114*b6cee71dSXin LIupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
115*b6cee71dSXin LIlower=abcdefghijklmnopqrstuvwxyz
116*b6cee71dSXin LIdigits=0123456789
117*b6cee71dSXin LIalpha=${upper}${lower}
118*b6cee71dSXin LI
119*b6cee71dSXin LIif test -z "$depmode" || test -z "$source" || test -z "$object"; then
120*b6cee71dSXin LI  echo "depcomp: Variables source, object and depmode must be set" 1>&2
121*b6cee71dSXin LI  exit 1
122*b6cee71dSXin LIfi
123*b6cee71dSXin LI
124*b6cee71dSXin LI# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
125*b6cee71dSXin LIdepfile=${depfile-`echo "$object" |
126*b6cee71dSXin LI  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
127*b6cee71dSXin LItmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
128*b6cee71dSXin LI
129*b6cee71dSXin LIrm -f "$tmpdepfile"
130*b6cee71dSXin LI
131*b6cee71dSXin LI# Avoid interferences from the environment.
132*b6cee71dSXin LIgccflag= dashmflag=
133*b6cee71dSXin LI
134*b6cee71dSXin LI# Some modes work just like other modes, but use different flags.  We
135*b6cee71dSXin LI# parameterize here, but still list the modes in the big case below,
136*b6cee71dSXin LI# to make depend.m4 easier to write.  Note that we *cannot* use a case
137*b6cee71dSXin LI# here, because this file can only contain one case statement.
138*b6cee71dSXin LIif test "$depmode" = hp; then
139*b6cee71dSXin LI  # HP compiler uses -M and no extra arg.
140*b6cee71dSXin LI  gccflag=-M
141*b6cee71dSXin LI  depmode=gcc
142*b6cee71dSXin LIfi
143*b6cee71dSXin LI
144*b6cee71dSXin LIif test "$depmode" = dashXmstdout; then
145*b6cee71dSXin LI  # This is just like dashmstdout with a different argument.
146*b6cee71dSXin LI  dashmflag=-xM
147*b6cee71dSXin LI  depmode=dashmstdout
148*b6cee71dSXin LIfi
149*b6cee71dSXin LI
150*b6cee71dSXin LIcygpath_u="cygpath -u -f -"
151*b6cee71dSXin LIif test "$depmode" = msvcmsys; then
152*b6cee71dSXin LI  # This is just like msvisualcpp but w/o cygpath translation.
153*b6cee71dSXin LI  # Just convert the backslash-escaped backslashes to single forward
154*b6cee71dSXin LI  # slashes to satisfy depend.m4
155*b6cee71dSXin LI  cygpath_u='sed s,\\\\,/,g'
156*b6cee71dSXin LI  depmode=msvisualcpp
157*b6cee71dSXin LIfi
158*b6cee71dSXin LI
159*b6cee71dSXin LIif test "$depmode" = msvc7msys; then
160*b6cee71dSXin LI  # This is just like msvc7 but w/o cygpath translation.
161*b6cee71dSXin LI  # Just convert the backslash-escaped backslashes to single forward
162*b6cee71dSXin LI  # slashes to satisfy depend.m4
163*b6cee71dSXin LI  cygpath_u='sed s,\\\\,/,g'
164*b6cee71dSXin LI  depmode=msvc7
165*b6cee71dSXin LIfi
166*b6cee71dSXin LI
167*b6cee71dSXin LIif test "$depmode" = xlc; then
168*b6cee71dSXin LI  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
169*b6cee71dSXin LI  gccflag=-qmakedep=gcc,-MF
170*b6cee71dSXin LI  depmode=gcc
171*b6cee71dSXin LIfi
172*b6cee71dSXin LI
173*b6cee71dSXin LIcase "$depmode" in
174*b6cee71dSXin LIgcc3)
175*b6cee71dSXin LI## gcc 3 implements dependency tracking that does exactly what
176*b6cee71dSXin LI## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
177*b6cee71dSXin LI## it if -MD -MP comes after the -MF stuff.  Hmm.
178*b6cee71dSXin LI## Unfortunately, FreeBSD c89 acceptance of flags depends upon
179*b6cee71dSXin LI## the command line argument order; so add the flags where they
180*b6cee71dSXin LI## appear in depend2.am.  Note that the slowdown incurred here
181*b6cee71dSXin LI## affects only configure: in makefiles, %FASTDEP% shortcuts this.
182*b6cee71dSXin LI  for arg
183*b6cee71dSXin LI  do
184*b6cee71dSXin LI    case $arg in
185*b6cee71dSXin LI    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
186*b6cee71dSXin LI    *)  set fnord "$@" "$arg" ;;
187*b6cee71dSXin LI    esac
188*b6cee71dSXin LI    shift # fnord
189*b6cee71dSXin LI    shift # $arg
190*b6cee71dSXin LI  done
191*b6cee71dSXin LI  "$@"
192*b6cee71dSXin LI  stat=$?
193*b6cee71dSXin LI  if test $stat -ne 0; then
194*b6cee71dSXin LI    rm -f "$tmpdepfile"
195*b6cee71dSXin LI    exit $stat
196*b6cee71dSXin LI  fi
197*b6cee71dSXin LI  mv "$tmpdepfile" "$depfile"
198*b6cee71dSXin LI  ;;
199*b6cee71dSXin LI
200*b6cee71dSXin LIgcc)
201*b6cee71dSXin LI## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
202*b6cee71dSXin LI## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
203*b6cee71dSXin LI## (see the conditional assignment to $gccflag above).
204*b6cee71dSXin LI## There are various ways to get dependency output from gcc.  Here's
205*b6cee71dSXin LI## why we pick this rather obscure method:
206*b6cee71dSXin LI## - Don't want to use -MD because we'd like the dependencies to end
207*b6cee71dSXin LI##   up in a subdir.  Having to rename by hand is ugly.
208*b6cee71dSXin LI##   (We might end up doing this anyway to support other compilers.)
209*b6cee71dSXin LI## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
210*b6cee71dSXin LI##   -MM, not -M (despite what the docs say).  Also, it might not be
211*b6cee71dSXin LI##   supported by the other compilers which use the 'gcc' depmode.
212*b6cee71dSXin LI## - Using -M directly means running the compiler twice (even worse
213*b6cee71dSXin LI##   than renaming).
214*b6cee71dSXin LI  if test -z "$gccflag"; then
215*b6cee71dSXin LI    gccflag=-MD,
216*b6cee71dSXin LI  fi
217*b6cee71dSXin LI  "$@" -Wp,"$gccflag$tmpdepfile"
218*b6cee71dSXin LI  stat=$?
219*b6cee71dSXin LI  if test $stat -ne 0; then
220*b6cee71dSXin LI    rm -f "$tmpdepfile"
221*b6cee71dSXin LI    exit $stat
222*b6cee71dSXin LI  fi
223*b6cee71dSXin LI  rm -f "$depfile"
224*b6cee71dSXin LI  echo "$object : \\" > "$depfile"
225*b6cee71dSXin LI  # The second -e expression handles DOS-style file names with drive
226*b6cee71dSXin LI  # letters.
227*b6cee71dSXin LI  sed -e 's/^[^:]*: / /' \
228*b6cee71dSXin LI      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
229*b6cee71dSXin LI## This next piece of magic avoids the "deleted header file" problem.
230*b6cee71dSXin LI## The problem is that when a header file which appears in a .P file
231*b6cee71dSXin LI## is deleted, the dependency causes make to die (because there is
232*b6cee71dSXin LI## typically no way to rebuild the header).  We avoid this by adding
233*b6cee71dSXin LI## dummy dependencies for each header file.  Too bad gcc doesn't do
234*b6cee71dSXin LI## this for us directly.
235*b6cee71dSXin LI## Some versions of gcc put a space before the ':'.  On the theory
236*b6cee71dSXin LI## that the space means something, we add a space to the output as
237*b6cee71dSXin LI## well.  hp depmode also adds that space, but also prefixes the VPATH
238*b6cee71dSXin LI## to the object.  Take care to not repeat it in the output.
239*b6cee71dSXin LI## Some versions of the HPUX 10.20 sed can't process this invocation
240*b6cee71dSXin LI## correctly.  Breaking it into two sed invocations is a workaround.
241*b6cee71dSXin LI  tr ' ' "$nl" < "$tmpdepfile" \
242*b6cee71dSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
243*b6cee71dSXin LI    | sed -e 's/$/ :/' >> "$depfile"
244*b6cee71dSXin LI  rm -f "$tmpdepfile"
245*b6cee71dSXin LI  ;;
246*b6cee71dSXin LI
247*b6cee71dSXin LIhp)
248*b6cee71dSXin LI  # This case exists only to let depend.m4 do its work.  It works by
249*b6cee71dSXin LI  # looking at the text of this script.  This case will never be run,
250*b6cee71dSXin LI  # since it is checked for above.
251*b6cee71dSXin LI  exit 1
252*b6cee71dSXin LI  ;;
253*b6cee71dSXin LI
254*b6cee71dSXin LIsgi)
255*b6cee71dSXin LI  if test "$libtool" = yes; then
256*b6cee71dSXin LI    "$@" "-Wp,-MDupdate,$tmpdepfile"
257*b6cee71dSXin LI  else
258*b6cee71dSXin LI    "$@" -MDupdate "$tmpdepfile"
259*b6cee71dSXin LI  fi
260*b6cee71dSXin LI  stat=$?
261*b6cee71dSXin LI  if test $stat -ne 0; then
262*b6cee71dSXin LI    rm -f "$tmpdepfile"
263*b6cee71dSXin LI    exit $stat
264*b6cee71dSXin LI  fi
265*b6cee71dSXin LI  rm -f "$depfile"
266*b6cee71dSXin LI
267*b6cee71dSXin LI  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
268*b6cee71dSXin LI    echo "$object : \\" > "$depfile"
269*b6cee71dSXin LI    # Clip off the initial element (the dependent).  Don't try to be
270*b6cee71dSXin LI    # clever and replace this with sed code, as IRIX sed won't handle
271*b6cee71dSXin LI    # lines with more than a fixed number of characters (4096 in
272*b6cee71dSXin LI    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
273*b6cee71dSXin LI    # the IRIX cc adds comments like '#:fec' to the end of the
274*b6cee71dSXin LI    # dependency line.
275*b6cee71dSXin LI    tr ' ' "$nl" < "$tmpdepfile" \
276*b6cee71dSXin LI      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
277*b6cee71dSXin LI      | tr "$nl" ' ' >> "$depfile"
278*b6cee71dSXin LI    echo >> "$depfile"
279*b6cee71dSXin LI    # The second pass generates a dummy entry for each header file.
280*b6cee71dSXin LI    tr ' ' "$nl" < "$tmpdepfile" \
281*b6cee71dSXin LI      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
282*b6cee71dSXin LI      >> "$depfile"
283*b6cee71dSXin LI  else
284*b6cee71dSXin LI    make_dummy_depfile
285*b6cee71dSXin LI  fi
286*b6cee71dSXin LI  rm -f "$tmpdepfile"
287*b6cee71dSXin LI  ;;
288*b6cee71dSXin LI
289*b6cee71dSXin LIxlc)
290*b6cee71dSXin LI  # This case exists only to let depend.m4 do its work.  It works by
291*b6cee71dSXin LI  # looking at the text of this script.  This case will never be run,
292*b6cee71dSXin LI  # since it is checked for above.
293*b6cee71dSXin LI  exit 1
294*b6cee71dSXin LI  ;;
295*b6cee71dSXin LI
296*b6cee71dSXin LIaix)
297*b6cee71dSXin LI  # The C for AIX Compiler uses -M and outputs the dependencies
298*b6cee71dSXin LI  # in a .u file.  In older versions, this file always lives in the
299*b6cee71dSXin LI  # current directory.  Also, the AIX compiler puts '$object:' at the
300*b6cee71dSXin LI  # start of each line; $object doesn't have directory information.
301*b6cee71dSXin LI  # Version 6 uses the directory in both cases.
302*b6cee71dSXin LI  set_dir_from "$object"
303*b6cee71dSXin LI  set_base_from "$object"
304*b6cee71dSXin LI  if test "$libtool" = yes; then
305*b6cee71dSXin LI    tmpdepfile1=$dir$base.u
306*b6cee71dSXin LI    tmpdepfile2=$base.u
307*b6cee71dSXin LI    tmpdepfile3=$dir.libs/$base.u
308*b6cee71dSXin LI    "$@" -Wc,-M
309*b6cee71dSXin LI  else
310*b6cee71dSXin LI    tmpdepfile1=$dir$base.u
311*b6cee71dSXin LI    tmpdepfile2=$dir$base.u
312*b6cee71dSXin LI    tmpdepfile3=$dir$base.u
313*b6cee71dSXin LI    "$@" -M
314*b6cee71dSXin LI  fi
315*b6cee71dSXin LI  stat=$?
316*b6cee71dSXin LI  if test $stat -ne 0; then
317*b6cee71dSXin LI    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
318*b6cee71dSXin LI    exit $stat
319*b6cee71dSXin LI  fi
320*b6cee71dSXin LI
321*b6cee71dSXin LI  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
322*b6cee71dSXin LI  do
323*b6cee71dSXin LI    test -f "$tmpdepfile" && break
324*b6cee71dSXin LI  done
325*b6cee71dSXin LI  aix_post_process_depfile
326*b6cee71dSXin LI  ;;
327*b6cee71dSXin LI
328*b6cee71dSXin LItcc)
329*b6cee71dSXin LI  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
330*b6cee71dSXin LI  # FIXME: That version still under development at the moment of writing.
331*b6cee71dSXin LI  #        Make that this statement remains true also for stable, released
332*b6cee71dSXin LI  #        versions.
333*b6cee71dSXin LI  # It will wrap lines (doesn't matter whether long or short) with a
334*b6cee71dSXin LI  # trailing '\', as in:
335*b6cee71dSXin LI  #
336*b6cee71dSXin LI  #   foo.o : \
337*b6cee71dSXin LI  #    foo.c \
338*b6cee71dSXin LI  #    foo.h \
339*b6cee71dSXin LI  #
340*b6cee71dSXin LI  # It will put a trailing '\' even on the last line, and will use leading
341*b6cee71dSXin LI  # spaces rather than leading tabs (at least since its commit 0394caf7
342*b6cee71dSXin LI  # "Emit spaces for -MD").
343*b6cee71dSXin LI  "$@" -MD -MF "$tmpdepfile"
344*b6cee71dSXin LI  stat=$?
345*b6cee71dSXin LI  if test $stat -ne 0; then
346*b6cee71dSXin LI    rm -f "$tmpdepfile"
347*b6cee71dSXin LI    exit $stat
348*b6cee71dSXin LI  fi
349*b6cee71dSXin LI  rm -f "$depfile"
350*b6cee71dSXin LI  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
351*b6cee71dSXin LI  # We have to change lines of the first kind to '$object: \'.
352*b6cee71dSXin LI  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
353*b6cee71dSXin LI  # And for each line of the second kind, we have to emit a 'dep.h:'
354*b6cee71dSXin LI  # dummy dependency, to avoid the deleted-header problem.
355*b6cee71dSXin LI  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
356*b6cee71dSXin LI  rm -f "$tmpdepfile"
357*b6cee71dSXin LI  ;;
358*b6cee71dSXin LI
359*b6cee71dSXin LI## The order of this option in the case statement is important, since the
360*b6cee71dSXin LI## shell code in configure will try each of these formats in the order
361*b6cee71dSXin LI## listed in this file.  A plain '-MD' option would be understood by many
362*b6cee71dSXin LI## compilers, so we must ensure this comes after the gcc and icc options.
363*b6cee71dSXin LIpgcc)
364*b6cee71dSXin LI  # Portland's C compiler understands '-MD'.
365*b6cee71dSXin LI  # Will always output deps to 'file.d' where file is the root name of the
366*b6cee71dSXin LI  # source file under compilation, even if file resides in a subdirectory.
367*b6cee71dSXin LI  # The object file name does not affect the name of the '.d' file.
368*b6cee71dSXin LI  # pgcc 10.2 will output
369*b6cee71dSXin LI  #    foo.o: sub/foo.c sub/foo.h
370*b6cee71dSXin LI  # and will wrap long lines using '\' :
371*b6cee71dSXin LI  #    foo.o: sub/foo.c ... \
372*b6cee71dSXin LI  #     sub/foo.h ... \
373*b6cee71dSXin LI  #     ...
374*b6cee71dSXin LI  set_dir_from "$object"
375*b6cee71dSXin LI  # Use the source, not the object, to determine the base name, since
376*b6cee71dSXin LI  # that's sadly what pgcc will do too.
377*b6cee71dSXin LI  set_base_from "$source"
378*b6cee71dSXin LI  tmpdepfile=$base.d
379*b6cee71dSXin LI
380*b6cee71dSXin LI  # For projects that build the same source file twice into different object
381*b6cee71dSXin LI  # files, the pgcc approach of using the *source* file root name can cause
382*b6cee71dSXin LI  # problems in parallel builds.  Use a locking strategy to avoid stomping on
383*b6cee71dSXin LI  # the same $tmpdepfile.
384*b6cee71dSXin LI  lockdir=$base.d-lock
385*b6cee71dSXin LI  trap "
386*b6cee71dSXin LI    echo '$0: caught signal, cleaning up...' >&2
387*b6cee71dSXin LI    rmdir '$lockdir'
388*b6cee71dSXin LI    exit 1
389*b6cee71dSXin LI  " 1 2 13 15
390*b6cee71dSXin LI  numtries=100
391*b6cee71dSXin LI  i=$numtries
392*b6cee71dSXin LI  while test $i -gt 0; do
393*b6cee71dSXin LI    # mkdir is a portable test-and-set.
394*b6cee71dSXin LI    if mkdir "$lockdir" 2>/dev/null; then
395*b6cee71dSXin LI      # This process acquired the lock.
396*b6cee71dSXin LI      "$@" -MD
397*b6cee71dSXin LI      stat=$?
398*b6cee71dSXin LI      # Release the lock.
399*b6cee71dSXin LI      rmdir "$lockdir"
400*b6cee71dSXin LI      break
401*b6cee71dSXin LI    else
402*b6cee71dSXin LI      # If the lock is being held by a different process, wait
403*b6cee71dSXin LI      # until the winning process is done or we timeout.
404*b6cee71dSXin LI      while test -d "$lockdir" && test $i -gt 0; do
405*b6cee71dSXin LI        sleep 1
406*b6cee71dSXin LI        i=`expr $i - 1`
407*b6cee71dSXin LI      done
408*b6cee71dSXin LI    fi
409*b6cee71dSXin LI    i=`expr $i - 1`
410*b6cee71dSXin LI  done
411*b6cee71dSXin LI  trap - 1 2 13 15
412*b6cee71dSXin LI  if test $i -le 0; then
413*b6cee71dSXin LI    echo "$0: failed to acquire lock after $numtries attempts" >&2
414*b6cee71dSXin LI    echo "$0: check lockdir '$lockdir'" >&2
415*b6cee71dSXin LI    exit 1
416*b6cee71dSXin LI  fi
417*b6cee71dSXin LI
418*b6cee71dSXin LI  if test $stat -ne 0; then
419*b6cee71dSXin LI    rm -f "$tmpdepfile"
420*b6cee71dSXin LI    exit $stat
421*b6cee71dSXin LI  fi
422*b6cee71dSXin LI  rm -f "$depfile"
423*b6cee71dSXin LI  # Each line is of the form `foo.o: dependent.h',
424*b6cee71dSXin LI  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
425*b6cee71dSXin LI  # Do two passes, one to just change these to
426*b6cee71dSXin LI  # `$object: dependent.h' and one to simply `dependent.h:'.
427*b6cee71dSXin LI  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
428*b6cee71dSXin LI  # Some versions of the HPUX 10.20 sed can't process this invocation
429*b6cee71dSXin LI  # correctly.  Breaking it into two sed invocations is a workaround.
430*b6cee71dSXin LI  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
431*b6cee71dSXin LI    | sed -e 's/$/ :/' >> "$depfile"
432*b6cee71dSXin LI  rm -f "$tmpdepfile"
433*b6cee71dSXin LI  ;;
434*b6cee71dSXin LI
435*b6cee71dSXin LIhp2)
436*b6cee71dSXin LI  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
437*b6cee71dSXin LI  # compilers, which have integrated preprocessors.  The correct option
438*b6cee71dSXin LI  # to use with these is +Maked; it writes dependencies to a file named
439*b6cee71dSXin LI  # 'foo.d', which lands next to the object file, wherever that
440*b6cee71dSXin LI  # happens to be.
441*b6cee71dSXin LI  # Much of this is similar to the tru64 case; see comments there.
442*b6cee71dSXin LI  set_dir_from  "$object"
443*b6cee71dSXin LI  set_base_from "$object"
444*b6cee71dSXin LI  if test "$libtool" = yes; then
445*b6cee71dSXin LI    tmpdepfile1=$dir$base.d
446*b6cee71dSXin LI    tmpdepfile2=$dir.libs/$base.d
447*b6cee71dSXin LI    "$@" -Wc,+Maked
448*b6cee71dSXin LI  else
449*b6cee71dSXin LI    tmpdepfile1=$dir$base.d
450*b6cee71dSXin LI    tmpdepfile2=$dir$base.d
451*b6cee71dSXin LI    "$@" +Maked
452*b6cee71dSXin LI  fi
453*b6cee71dSXin LI  stat=$?
454*b6cee71dSXin LI  if test $stat -ne 0; then
455*b6cee71dSXin LI     rm -f "$tmpdepfile1" "$tmpdepfile2"
456*b6cee71dSXin LI     exit $stat
457*b6cee71dSXin LI  fi
458*b6cee71dSXin LI
459*b6cee71dSXin LI  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
460*b6cee71dSXin LI  do
461*b6cee71dSXin LI    test -f "$tmpdepfile" && break
462*b6cee71dSXin LI  done
463*b6cee71dSXin LI  if test -f "$tmpdepfile"; then
464*b6cee71dSXin LI    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
465*b6cee71dSXin LI    # Add 'dependent.h:' lines.
466*b6cee71dSXin LI    sed -ne '2,${
467*b6cee71dSXin LI               s/^ *//
468*b6cee71dSXin LI               s/ \\*$//
469*b6cee71dSXin LI               s/$/:/
470*b6cee71dSXin LI               p
471*b6cee71dSXin LI             }' "$tmpdepfile" >> "$depfile"
472*b6cee71dSXin LI  else
473*b6cee71dSXin LI    make_dummy_depfile
474*b6cee71dSXin LI  fi
475*b6cee71dSXin LI  rm -f "$tmpdepfile" "$tmpdepfile2"
476*b6cee71dSXin LI  ;;
477*b6cee71dSXin LI
478*b6cee71dSXin LItru64)
479*b6cee71dSXin LI  # The Tru64 compiler uses -MD to generate dependencies as a side
480*b6cee71dSXin LI  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
481*b6cee71dSXin LI  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
482*b6cee71dSXin LI  # dependencies in 'foo.d' instead, so we check for that too.
483*b6cee71dSXin LI  # Subdirectories are respected.
484*b6cee71dSXin LI  set_dir_from  "$object"
485*b6cee71dSXin LI  set_base_from "$object"
486*b6cee71dSXin LI
487*b6cee71dSXin LI  if test "$libtool" = yes; then
488*b6cee71dSXin LI    # Libtool generates 2 separate objects for the 2 libraries.  These
489*b6cee71dSXin LI    # two compilations output dependencies in $dir.libs/$base.o.d and
490*b6cee71dSXin LI    # in $dir$base.o.d.  We have to check for both files, because
491*b6cee71dSXin LI    # one of the two compilations can be disabled.  We should prefer
492*b6cee71dSXin LI    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
493*b6cee71dSXin LI    # automatically cleaned when .libs/ is deleted, while ignoring
494*b6cee71dSXin LI    # the former would cause a distcleancheck panic.
495*b6cee71dSXin LI    tmpdepfile1=$dir$base.o.d          # libtool 1.5
496*b6cee71dSXin LI    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
497*b6cee71dSXin LI    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
498*b6cee71dSXin LI    "$@" -Wc,-MD
499*b6cee71dSXin LI  else
500*b6cee71dSXin LI    tmpdepfile1=$dir$base.d
501*b6cee71dSXin LI    tmpdepfile2=$dir$base.d
502*b6cee71dSXin LI    tmpdepfile3=$dir$base.d
503*b6cee71dSXin LI    "$@" -MD
504*b6cee71dSXin LI  fi
505*b6cee71dSXin LI
506*b6cee71dSXin LI  stat=$?
507*b6cee71dSXin LI  if test $stat -ne 0; then
508*b6cee71dSXin LI    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
509*b6cee71dSXin LI    exit $stat
510*b6cee71dSXin LI  fi
511*b6cee71dSXin LI
512*b6cee71dSXin LI  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
513*b6cee71dSXin LI  do
514*b6cee71dSXin LI    test -f "$tmpdepfile" && break
515*b6cee71dSXin LI  done
516*b6cee71dSXin LI  # Same post-processing that is required for AIX mode.
517*b6cee71dSXin LI  aix_post_process_depfile
518*b6cee71dSXin LI  ;;
519*b6cee71dSXin LI
520*b6cee71dSXin LImsvc7)
521*b6cee71dSXin LI  if test "$libtool" = yes; then
522*b6cee71dSXin LI    showIncludes=-Wc,-showIncludes
523*b6cee71dSXin LI  else
524*b6cee71dSXin LI    showIncludes=-showIncludes
525*b6cee71dSXin LI  fi
526*b6cee71dSXin LI  "$@" $showIncludes > "$tmpdepfile"
527*b6cee71dSXin LI  stat=$?
528*b6cee71dSXin LI  grep -v '^Note: including file: ' "$tmpdepfile"
529*b6cee71dSXin LI  if test $stat -ne 0; then
530*b6cee71dSXin LI    rm -f "$tmpdepfile"
531*b6cee71dSXin LI    exit $stat
532*b6cee71dSXin LI  fi
533*b6cee71dSXin LI  rm -f "$depfile"
534*b6cee71dSXin LI  echo "$object : \\" > "$depfile"
535*b6cee71dSXin LI  # The first sed program below extracts the file names and escapes
536*b6cee71dSXin LI  # backslashes for cygpath.  The second sed program outputs the file
537*b6cee71dSXin LI  # name when reading, but also accumulates all include files in the
538*b6cee71dSXin LI  # hold buffer in order to output them again at the end.  This only
539*b6cee71dSXin LI  # works with sed implementations that can handle large buffers.
540*b6cee71dSXin LI  sed < "$tmpdepfile" -n '
541*b6cee71dSXin LI/^Note: including file:  *\(.*\)/ {
542*b6cee71dSXin LI  s//\1/
543*b6cee71dSXin LI  s/\\/\\\\/g
544*b6cee71dSXin LI  p
545*b6cee71dSXin LI}' | $cygpath_u | sort -u | sed -n '
546*b6cee71dSXin LIs/ /\\ /g
547*b6cee71dSXin LIs/\(.*\)/'"$tab"'\1 \\/p
548*b6cee71dSXin LIs/.\(.*\) \\/\1:/
549*b6cee71dSXin LIH
550*b6cee71dSXin LI$ {
551*b6cee71dSXin LI  s/.*/'"$tab"'/
552*b6cee71dSXin LI  G
553*b6cee71dSXin LI  p
554*b6cee71dSXin LI}' >> "$depfile"
555*b6cee71dSXin LI  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
556*b6cee71dSXin LI  rm -f "$tmpdepfile"
557*b6cee71dSXin LI  ;;
558*b6cee71dSXin LI
559*b6cee71dSXin LImsvc7msys)
560*b6cee71dSXin LI  # This case exists only to let depend.m4 do its work.  It works by
561*b6cee71dSXin LI  # looking at the text of this script.  This case will never be run,
562*b6cee71dSXin LI  # since it is checked for above.
563*b6cee71dSXin LI  exit 1
564*b6cee71dSXin LI  ;;
565*b6cee71dSXin LI
566*b6cee71dSXin LI#nosideeffect)
567*b6cee71dSXin LI  # This comment above is used by automake to tell side-effect
568*b6cee71dSXin LI  # dependency tracking mechanisms from slower ones.
569*b6cee71dSXin LI
570*b6cee71dSXin LIdashmstdout)
571*b6cee71dSXin LI  # Important note: in order to support this mode, a compiler *must*
572*b6cee71dSXin LI  # always write the preprocessed file to stdout, regardless of -o.
573*b6cee71dSXin LI  "$@" || exit $?
574*b6cee71dSXin LI
575*b6cee71dSXin LI  # Remove the call to Libtool.
576*b6cee71dSXin LI  if test "$libtool" = yes; then
577*b6cee71dSXin LI    while test "X$1" != 'X--mode=compile'; do
578*b6cee71dSXin LI      shift
579*b6cee71dSXin LI    done
580*b6cee71dSXin LI    shift
581*b6cee71dSXin LI  fi
582*b6cee71dSXin LI
583*b6cee71dSXin LI  # Remove '-o $object'.
584*b6cee71dSXin LI  IFS=" "
585*b6cee71dSXin LI  for arg
586*b6cee71dSXin LI  do
587*b6cee71dSXin LI    case $arg in
588*b6cee71dSXin LI    -o)
589*b6cee71dSXin LI      shift
590*b6cee71dSXin LI      ;;
591*b6cee71dSXin LI    $object)
592*b6cee71dSXin LI      shift
593*b6cee71dSXin LI      ;;
594*b6cee71dSXin LI    *)
595*b6cee71dSXin LI      set fnord "$@" "$arg"
596*b6cee71dSXin LI      shift # fnord
597*b6cee71dSXin LI      shift # $arg
598*b6cee71dSXin LI      ;;
599*b6cee71dSXin LI    esac
600*b6cee71dSXin LI  done
601*b6cee71dSXin LI
602*b6cee71dSXin LI  test -z "$dashmflag" && dashmflag=-M
603*b6cee71dSXin LI  # Require at least two characters before searching for ':'
604*b6cee71dSXin LI  # in the target name.  This is to cope with DOS-style filenames:
605*b6cee71dSXin LI  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
606*b6cee71dSXin LI  "$@" $dashmflag |
607*b6cee71dSXin LI    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
608*b6cee71dSXin LI  rm -f "$depfile"
609*b6cee71dSXin LI  cat < "$tmpdepfile" > "$depfile"
610*b6cee71dSXin LI  # Some versions of the HPUX 10.20 sed can't process this sed invocation
611*b6cee71dSXin LI  # correctly.  Breaking it into two sed invocations is a workaround.
612*b6cee71dSXin LI  tr ' ' "$nl" < "$tmpdepfile" \
613*b6cee71dSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
614*b6cee71dSXin LI    | sed -e 's/$/ :/' >> "$depfile"
615*b6cee71dSXin LI  rm -f "$tmpdepfile"
616*b6cee71dSXin LI  ;;
617*b6cee71dSXin LI
618*b6cee71dSXin LIdashXmstdout)
619*b6cee71dSXin LI  # This case only exists to satisfy depend.m4.  It is never actually
620*b6cee71dSXin LI  # run, as this mode is specially recognized in the preamble.
621*b6cee71dSXin LI  exit 1
622*b6cee71dSXin LI  ;;
623*b6cee71dSXin LI
624*b6cee71dSXin LImakedepend)
625*b6cee71dSXin LI  "$@" || exit $?
626*b6cee71dSXin LI  # Remove any Libtool call
627*b6cee71dSXin LI  if test "$libtool" = yes; then
628*b6cee71dSXin LI    while test "X$1" != 'X--mode=compile'; do
629*b6cee71dSXin LI      shift
630*b6cee71dSXin LI    done
631*b6cee71dSXin LI    shift
632*b6cee71dSXin LI  fi
633*b6cee71dSXin LI  # X makedepend
634*b6cee71dSXin LI  shift
635*b6cee71dSXin LI  cleared=no eat=no
636*b6cee71dSXin LI  for arg
637*b6cee71dSXin LI  do
638*b6cee71dSXin LI    case $cleared in
639*b6cee71dSXin LI    no)
640*b6cee71dSXin LI      set ""; shift
641*b6cee71dSXin LI      cleared=yes ;;
642*b6cee71dSXin LI    esac
643*b6cee71dSXin LI    if test $eat = yes; then
644*b6cee71dSXin LI      eat=no
645*b6cee71dSXin LI      continue
646*b6cee71dSXin LI    fi
647*b6cee71dSXin LI    case "$arg" in
648*b6cee71dSXin LI    -D*|-I*)
649*b6cee71dSXin LI      set fnord "$@" "$arg"; shift ;;
650*b6cee71dSXin LI    # Strip any option that makedepend may not understand.  Remove
651*b6cee71dSXin LI    # the object too, otherwise makedepend will parse it as a source file.
652*b6cee71dSXin LI    -arch)
653*b6cee71dSXin LI      eat=yes ;;
654*b6cee71dSXin LI    -*|$object)
655*b6cee71dSXin LI      ;;
656*b6cee71dSXin LI    *)
657*b6cee71dSXin LI      set fnord "$@" "$arg"; shift ;;
658*b6cee71dSXin LI    esac
659*b6cee71dSXin LI  done
660*b6cee71dSXin LI  obj_suffix=`echo "$object" | sed 's/^.*\././'`
661*b6cee71dSXin LI  touch "$tmpdepfile"
662*b6cee71dSXin LI  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
663*b6cee71dSXin LI  rm -f "$depfile"
664*b6cee71dSXin LI  # makedepend may prepend the VPATH from the source file name to the object.
665*b6cee71dSXin LI  # No need to regex-escape $object, excess matching of '.' is harmless.
666*b6cee71dSXin LI  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
667*b6cee71dSXin LI  # Some versions of the HPUX 10.20 sed can't process the last invocation
668*b6cee71dSXin LI  # correctly.  Breaking it into two sed invocations is a workaround.
669*b6cee71dSXin LI  sed '1,2d' "$tmpdepfile" \
670*b6cee71dSXin LI    | tr ' ' "$nl" \
671*b6cee71dSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
672*b6cee71dSXin LI    | sed -e 's/$/ :/' >> "$depfile"
673*b6cee71dSXin LI  rm -f "$tmpdepfile" "$tmpdepfile".bak
674*b6cee71dSXin LI  ;;
675*b6cee71dSXin LI
676*b6cee71dSXin LIcpp)
677*b6cee71dSXin LI  # Important note: in order to support this mode, a compiler *must*
678*b6cee71dSXin LI  # always write the preprocessed file to stdout.
679*b6cee71dSXin LI  "$@" || exit $?
680*b6cee71dSXin LI
681*b6cee71dSXin LI  # Remove the call to Libtool.
682*b6cee71dSXin LI  if test "$libtool" = yes; then
683*b6cee71dSXin LI    while test "X$1" != 'X--mode=compile'; do
684*b6cee71dSXin LI      shift
685*b6cee71dSXin LI    done
686*b6cee71dSXin LI    shift
687*b6cee71dSXin LI  fi
688*b6cee71dSXin LI
689*b6cee71dSXin LI  # Remove '-o $object'.
690*b6cee71dSXin LI  IFS=" "
691*b6cee71dSXin LI  for arg
692*b6cee71dSXin LI  do
693*b6cee71dSXin LI    case $arg in
694*b6cee71dSXin LI    -o)
695*b6cee71dSXin LI      shift
696*b6cee71dSXin LI      ;;
697*b6cee71dSXin LI    $object)
698*b6cee71dSXin LI      shift
699*b6cee71dSXin LI      ;;
700*b6cee71dSXin LI    *)
701*b6cee71dSXin LI      set fnord "$@" "$arg"
702*b6cee71dSXin LI      shift # fnord
703*b6cee71dSXin LI      shift # $arg
704*b6cee71dSXin LI      ;;
705*b6cee71dSXin LI    esac
706*b6cee71dSXin LI  done
707*b6cee71dSXin LI
708*b6cee71dSXin LI  "$@" -E \
709*b6cee71dSXin LI    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
710*b6cee71dSXin LI             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
711*b6cee71dSXin LI    | sed '$ s: \\$::' > "$tmpdepfile"
712*b6cee71dSXin LI  rm -f "$depfile"
713*b6cee71dSXin LI  echo "$object : \\" > "$depfile"
714*b6cee71dSXin LI  cat < "$tmpdepfile" >> "$depfile"
715*b6cee71dSXin LI  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
716*b6cee71dSXin LI  rm -f "$tmpdepfile"
717*b6cee71dSXin LI  ;;
718*b6cee71dSXin LI
719*b6cee71dSXin LImsvisualcpp)
720*b6cee71dSXin LI  # Important note: in order to support this mode, a compiler *must*
721*b6cee71dSXin LI  # always write the preprocessed file to stdout.
722*b6cee71dSXin LI  "$@" || exit $?
723*b6cee71dSXin LI
724*b6cee71dSXin LI  # Remove the call to Libtool.
725*b6cee71dSXin LI  if test "$libtool" = yes; then
726*b6cee71dSXin LI    while test "X$1" != 'X--mode=compile'; do
727*b6cee71dSXin LI      shift
728*b6cee71dSXin LI    done
729*b6cee71dSXin LI    shift
730*b6cee71dSXin LI  fi
731*b6cee71dSXin LI
732*b6cee71dSXin LI  IFS=" "
733*b6cee71dSXin LI  for arg
734*b6cee71dSXin LI  do
735*b6cee71dSXin LI    case "$arg" in
736*b6cee71dSXin LI    -o)
737*b6cee71dSXin LI      shift
738*b6cee71dSXin LI      ;;
739*b6cee71dSXin LI    $object)
740*b6cee71dSXin LI      shift
741*b6cee71dSXin LI      ;;
742*b6cee71dSXin LI    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
743*b6cee71dSXin LI        set fnord "$@"
744*b6cee71dSXin LI        shift
745*b6cee71dSXin LI        shift
746*b6cee71dSXin LI        ;;
747*b6cee71dSXin LI    *)
748*b6cee71dSXin LI        set fnord "$@" "$arg"
749*b6cee71dSXin LI        shift
750*b6cee71dSXin LI        shift
751*b6cee71dSXin LI        ;;
752*b6cee71dSXin LI    esac
753*b6cee71dSXin LI  done
754*b6cee71dSXin LI  "$@" -E 2>/dev/null |
755*b6cee71dSXin LI  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
756*b6cee71dSXin LI  rm -f "$depfile"
757*b6cee71dSXin LI  echo "$object : \\" > "$depfile"
758*b6cee71dSXin LI  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
759*b6cee71dSXin LI  echo "$tab" >> "$depfile"
760*b6cee71dSXin LI  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
761*b6cee71dSXin LI  rm -f "$tmpdepfile"
762*b6cee71dSXin LI  ;;
763*b6cee71dSXin LI
764*b6cee71dSXin LImsvcmsys)
765*b6cee71dSXin LI  # This case exists only to let depend.m4 do its work.  It works by
766*b6cee71dSXin LI  # looking at the text of this script.  This case will never be run,
767*b6cee71dSXin LI  # since it is checked for above.
768*b6cee71dSXin LI  exit 1
769*b6cee71dSXin LI  ;;
770*b6cee71dSXin LI
771*b6cee71dSXin LInone)
772*b6cee71dSXin LI  exec "$@"
773*b6cee71dSXin LI  ;;
774*b6cee71dSXin LI
775*b6cee71dSXin LI*)
776*b6cee71dSXin LI  echo "Unknown depmode $depmode" 1>&2
777*b6cee71dSXin LI  exit 1
778*b6cee71dSXin LI  ;;
779*b6cee71dSXin LIesac
780*b6cee71dSXin LI
781*b6cee71dSXin LIexit 0
782*b6cee71dSXin LI
783*b6cee71dSXin LI# Local Variables:
784*b6cee71dSXin LI# mode: shell-script
785*b6cee71dSXin LI# sh-indentation: 2
786*b6cee71dSXin LI# eval: (add-hook 'write-file-hooks 'time-stamp)
787*b6cee71dSXin LI# time-stamp-start: "scriptversion="
788*b6cee71dSXin LI# time-stamp-format: "%:y-%02m-%02d.%02H"
789*b6cee71dSXin LI# time-stamp-time-zone: "UTC"
790*b6cee71dSXin LI# time-stamp-end: "; # UTC"
791*b6cee71dSXin LI# End:
792