xref: /freebsd/contrib/ntp/sntp/libevent/build-aux/depcomp (revision e43d33d286a1aa41b6fc6a209f28a18e8cd7437a)
12b15cb3dSCy Schubert#! /bin/sh
22b15cb3dSCy Schubert# depcomp - compile a program generating dependencies as side-effects
32b15cb3dSCy Schubert
4*2d4e511cSCy Schubertscriptversion=2013-05-30.07; # UTC
52b15cb3dSCy Schubert
6*2d4e511cSCy Schubert# Copyright (C) 1999-2014 Free Software Foundation, Inc.
72b15cb3dSCy Schubert
82b15cb3dSCy Schubert# This program is free software; you can redistribute it and/or modify
92b15cb3dSCy Schubert# it under the terms of the GNU General Public License as published by
102b15cb3dSCy Schubert# the Free Software Foundation; either version 2, or (at your option)
112b15cb3dSCy Schubert# any later version.
122b15cb3dSCy Schubert
132b15cb3dSCy Schubert# This program is distributed in the hope that it will be useful,
142b15cb3dSCy Schubert# but WITHOUT ANY WARRANTY; without even the implied warranty of
152b15cb3dSCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
162b15cb3dSCy Schubert# GNU General Public License for more details.
172b15cb3dSCy Schubert
182b15cb3dSCy Schubert# You should have received a copy of the GNU General Public License
192b15cb3dSCy Schubert# along with this program.  If not, see <http://www.gnu.org/licenses/>.
202b15cb3dSCy Schubert
212b15cb3dSCy Schubert# As a special exception to the GNU General Public License, if you
222b15cb3dSCy Schubert# distribute this file as part of a program that contains a
232b15cb3dSCy Schubert# configuration script generated by Autoconf, you may include it under
242b15cb3dSCy Schubert# the same distribution terms that you use for the rest of that program.
252b15cb3dSCy Schubert
262b15cb3dSCy Schubert# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
272b15cb3dSCy Schubert
282b15cb3dSCy Schubertcase $1 in
292b15cb3dSCy Schubert  '')
30f0574f5cSXin LI    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
312b15cb3dSCy Schubert    exit 1;
322b15cb3dSCy Schubert    ;;
332b15cb3dSCy Schubert  -h | --h*)
342b15cb3dSCy Schubert    cat <<\EOF
352b15cb3dSCy SchubertUsage: depcomp [--help] [--version] PROGRAM [ARGS]
362b15cb3dSCy Schubert
372b15cb3dSCy SchubertRun PROGRAMS ARGS to compile a file, generating dependencies
382b15cb3dSCy Schubertas side-effects.
392b15cb3dSCy Schubert
402b15cb3dSCy SchubertEnvironment variables:
412b15cb3dSCy Schubert  depmode     Dependency tracking mode.
42f0574f5cSXin LI  source      Source file read by 'PROGRAMS ARGS'.
43f0574f5cSXin LI  object      Object file output by 'PROGRAMS ARGS'.
442b15cb3dSCy Schubert  DEPDIR      directory where to store dependencies.
452b15cb3dSCy Schubert  depfile     Dependency file to output.
46f0574f5cSXin LI  tmpdepfile  Temporary file to use when outputting dependencies.
472b15cb3dSCy Schubert  libtool     Whether libtool is used (yes/no).
482b15cb3dSCy Schubert
492b15cb3dSCy SchubertReport bugs to <bug-automake@gnu.org>.
502b15cb3dSCy SchubertEOF
512b15cb3dSCy Schubert    exit $?
522b15cb3dSCy Schubert    ;;
532b15cb3dSCy Schubert  -v | --v*)
542b15cb3dSCy Schubert    echo "depcomp $scriptversion"
552b15cb3dSCy Schubert    exit $?
562b15cb3dSCy Schubert    ;;
572b15cb3dSCy Schubertesac
582b15cb3dSCy Schubert
59f0574f5cSXin LI# Get the directory component of the given path, and save it in the
60f0574f5cSXin LI# global variables '$dir'.  Note that this directory component will
61f0574f5cSXin LI# be either empty or ending with a '/' character.  This is deliberate.
62f0574f5cSXin LIset_dir_from ()
63f0574f5cSXin LI{
64f0574f5cSXin LI  case $1 in
65f0574f5cSXin LI    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66f0574f5cSXin LI      *) dir=;;
67f0574f5cSXin LI  esac
68f0574f5cSXin LI}
69f0574f5cSXin LI
70f0574f5cSXin LI# Get the suffix-stripped basename of the given path, and save it the
71f0574f5cSXin LI# global variable '$base'.
72f0574f5cSXin LIset_base_from ()
73f0574f5cSXin LI{
74f0574f5cSXin LI  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
75f0574f5cSXin LI}
76f0574f5cSXin LI
77f0574f5cSXin LI# If no dependency file was actually created by the compiler invocation,
78f0574f5cSXin LI# we still have to create a dummy depfile, to avoid errors with the
79f0574f5cSXin LI# Makefile "include basename.Plo" scheme.
80f0574f5cSXin LImake_dummy_depfile ()
81f0574f5cSXin LI{
82f0574f5cSXin LI  echo "#dummy" > "$depfile"
83f0574f5cSXin LI}
84f0574f5cSXin LI
85f0574f5cSXin LI# Factor out some common post-processing of the generated depfile.
86f0574f5cSXin LI# Requires the auxiliary global variable '$tmpdepfile' to be set.
87f0574f5cSXin LIaix_post_process_depfile ()
88f0574f5cSXin LI{
89f0574f5cSXin LI  # If the compiler actually managed to produce a dependency file,
90f0574f5cSXin LI  # post-process it.
91f0574f5cSXin LI  if test -f "$tmpdepfile"; then
92f0574f5cSXin LI    # Each line is of the form 'foo.o: dependency.h'.
93f0574f5cSXin LI    # Do two passes, one to just change these to
94f0574f5cSXin LI    #   $object: dependency.h
95f0574f5cSXin LI    # and one to simply output
96f0574f5cSXin LI    #   dependency.h:
97f0574f5cSXin LI    # which is needed to avoid the deleted-header problem.
98f0574f5cSXin LI    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
99f0574f5cSXin LI      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
100f0574f5cSXin LI    } > "$depfile"
101f0574f5cSXin LI    rm -f "$tmpdepfile"
102f0574f5cSXin LI  else
103f0574f5cSXin LI    make_dummy_depfile
104f0574f5cSXin LI  fi
105f0574f5cSXin LI}
106f0574f5cSXin LI
107f0574f5cSXin LI# A tabulation character.
108f0574f5cSXin LItab='	'
109f0574f5cSXin LI# A newline character.
110f0574f5cSXin LInl='
111f0574f5cSXin LI'
112f0574f5cSXin LI# Character ranges might be problematic outside the C locale.
113f0574f5cSXin LI# These definitions help.
114f0574f5cSXin LIupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
115f0574f5cSXin LIlower=abcdefghijklmnopqrstuvwxyz
116f0574f5cSXin LIdigits=0123456789
117f0574f5cSXin LIalpha=${upper}${lower}
118f0574f5cSXin LI
1192b15cb3dSCy Schubertif test -z "$depmode" || test -z "$source" || test -z "$object"; then
1202b15cb3dSCy Schubert  echo "depcomp: Variables source, object and depmode must be set" 1>&2
1212b15cb3dSCy Schubert  exit 1
1222b15cb3dSCy Schubertfi
1232b15cb3dSCy Schubert
1242b15cb3dSCy Schubert# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
1252b15cb3dSCy Schubertdepfile=${depfile-`echo "$object" |
1262b15cb3dSCy Schubert  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
1272b15cb3dSCy Schuberttmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
1282b15cb3dSCy Schubert
1292b15cb3dSCy Schubertrm -f "$tmpdepfile"
1302b15cb3dSCy Schubert
131f0574f5cSXin LI# Avoid interferences from the environment.
132f0574f5cSXin LIgccflag= dashmflag=
133f0574f5cSXin LI
1342b15cb3dSCy Schubert# Some modes work just like other modes, but use different flags.  We
1352b15cb3dSCy Schubert# parameterize here, but still list the modes in the big case below,
1362b15cb3dSCy Schubert# to make depend.m4 easier to write.  Note that we *cannot* use a case
1372b15cb3dSCy Schubert# here, because this file can only contain one case statement.
1382b15cb3dSCy Schubertif test "$depmode" = hp; then
1392b15cb3dSCy Schubert  # HP compiler uses -M and no extra arg.
1402b15cb3dSCy Schubert  gccflag=-M
1412b15cb3dSCy Schubert  depmode=gcc
1422b15cb3dSCy Schubertfi
1432b15cb3dSCy Schubert
1442b15cb3dSCy Schubertif test "$depmode" = dashXmstdout; then
1452b15cb3dSCy Schubert  # This is just like dashmstdout with a different argument.
1462b15cb3dSCy Schubert  dashmflag=-xM
1472b15cb3dSCy Schubert  depmode=dashmstdout
1482b15cb3dSCy Schubertfi
1492b15cb3dSCy Schubert
1502b15cb3dSCy Schubertcygpath_u="cygpath -u -f -"
1512b15cb3dSCy Schubertif test "$depmode" = msvcmsys; then
1522b15cb3dSCy Schubert  # This is just like msvisualcpp but w/o cygpath translation.
1532b15cb3dSCy Schubert  # Just convert the backslash-escaped backslashes to single forward
1542b15cb3dSCy Schubert  # slashes to satisfy depend.m4
155f0574f5cSXin LI  cygpath_u='sed s,\\\\,/,g'
1562b15cb3dSCy Schubert  depmode=msvisualcpp
1572b15cb3dSCy Schubertfi
1582b15cb3dSCy Schubert
159f0574f5cSXin LIif test "$depmode" = msvc7msys; then
160f0574f5cSXin LI  # This is just like msvc7 but w/o cygpath translation.
161f0574f5cSXin LI  # Just convert the backslash-escaped backslashes to single forward
162f0574f5cSXin LI  # slashes to satisfy depend.m4
163f0574f5cSXin LI  cygpath_u='sed s,\\\\,/,g'
164f0574f5cSXin LI  depmode=msvc7
165f0574f5cSXin LIfi
166f0574f5cSXin LI
167f0574f5cSXin LIif test "$depmode" = xlc; then
168f0574f5cSXin LI  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
169f0574f5cSXin LI  gccflag=-qmakedep=gcc,-MF
170f0574f5cSXin LI  depmode=gcc
171f0574f5cSXin LIfi
172f0574f5cSXin LI
1732b15cb3dSCy Schubertcase "$depmode" in
1742b15cb3dSCy Schubertgcc3)
1752b15cb3dSCy Schubert## gcc 3 implements dependency tracking that does exactly what
1762b15cb3dSCy Schubert## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
1772b15cb3dSCy Schubert## it if -MD -MP comes after the -MF stuff.  Hmm.
1782b15cb3dSCy Schubert## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1792b15cb3dSCy Schubert## the command line argument order; so add the flags where they
1802b15cb3dSCy Schubert## appear in depend2.am.  Note that the slowdown incurred here
1812b15cb3dSCy Schubert## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1822b15cb3dSCy Schubert  for arg
1832b15cb3dSCy Schubert  do
1842b15cb3dSCy Schubert    case $arg in
1852b15cb3dSCy Schubert    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1862b15cb3dSCy Schubert    *)  set fnord "$@" "$arg" ;;
1872b15cb3dSCy Schubert    esac
1882b15cb3dSCy Schubert    shift # fnord
1892b15cb3dSCy Schubert    shift # $arg
1902b15cb3dSCy Schubert  done
1912b15cb3dSCy Schubert  "$@"
1922b15cb3dSCy Schubert  stat=$?
193f0574f5cSXin LI  if test $stat -ne 0; then
1942b15cb3dSCy Schubert    rm -f "$tmpdepfile"
1952b15cb3dSCy Schubert    exit $stat
1962b15cb3dSCy Schubert  fi
1972b15cb3dSCy Schubert  mv "$tmpdepfile" "$depfile"
1982b15cb3dSCy Schubert  ;;
1992b15cb3dSCy Schubert
2002b15cb3dSCy Schubertgcc)
201f0574f5cSXin LI## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
202f0574f5cSXin LI## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
203f0574f5cSXin LI## (see the conditional assignment to $gccflag above).
2042b15cb3dSCy Schubert## There are various ways to get dependency output from gcc.  Here's
2052b15cb3dSCy Schubert## why we pick this rather obscure method:
2062b15cb3dSCy Schubert## - Don't want to use -MD because we'd like the dependencies to end
2072b15cb3dSCy Schubert##   up in a subdir.  Having to rename by hand is ugly.
2082b15cb3dSCy Schubert##   (We might end up doing this anyway to support other compilers.)
2092b15cb3dSCy Schubert## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
210f0574f5cSXin LI##   -MM, not -M (despite what the docs say).  Also, it might not be
211f0574f5cSXin LI##   supported by the other compilers which use the 'gcc' depmode.
2122b15cb3dSCy Schubert## - Using -M directly means running the compiler twice (even worse
2132b15cb3dSCy Schubert##   than renaming).
2142b15cb3dSCy Schubert  if test -z "$gccflag"; then
2152b15cb3dSCy Schubert    gccflag=-MD,
2162b15cb3dSCy Schubert  fi
2172b15cb3dSCy Schubert  "$@" -Wp,"$gccflag$tmpdepfile"
2182b15cb3dSCy Schubert  stat=$?
219f0574f5cSXin LI  if test $stat -ne 0; then
2202b15cb3dSCy Schubert    rm -f "$tmpdepfile"
2212b15cb3dSCy Schubert    exit $stat
2222b15cb3dSCy Schubert  fi
2232b15cb3dSCy Schubert  rm -f "$depfile"
2242b15cb3dSCy Schubert  echo "$object : \\" > "$depfile"
225f0574f5cSXin LI  # The second -e expression handles DOS-style file names with drive
226f0574f5cSXin LI  # letters.
2272b15cb3dSCy Schubert  sed -e 's/^[^:]*: / /' \
2282b15cb3dSCy Schubert      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
229f0574f5cSXin LI## This next piece of magic avoids the "deleted header file" problem.
2302b15cb3dSCy Schubert## The problem is that when a header file which appears in a .P file
2312b15cb3dSCy Schubert## is deleted, the dependency causes make to die (because there is
2322b15cb3dSCy Schubert## typically no way to rebuild the header).  We avoid this by adding
2332b15cb3dSCy Schubert## dummy dependencies for each header file.  Too bad gcc doesn't do
2342b15cb3dSCy Schubert## this for us directly.
235f0574f5cSXin LI## Some versions of gcc put a space before the ':'.  On the theory
2362b15cb3dSCy Schubert## that the space means something, we add a space to the output as
237f0574f5cSXin LI## well.  hp depmode also adds that space, but also prefixes the VPATH
238f0574f5cSXin LI## to the object.  Take care to not repeat it in the output.
2392b15cb3dSCy Schubert## Some versions of the HPUX 10.20 sed can't process this invocation
2402b15cb3dSCy Schubert## correctly.  Breaking it into two sed invocations is a workaround.
241f0574f5cSXin LI  tr ' ' "$nl" < "$tmpdepfile" \
242f0574f5cSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
243f0574f5cSXin LI    | sed -e 's/$/ :/' >> "$depfile"
2442b15cb3dSCy Schubert  rm -f "$tmpdepfile"
2452b15cb3dSCy Schubert  ;;
2462b15cb3dSCy Schubert
2472b15cb3dSCy Schuberthp)
2482b15cb3dSCy Schubert  # This case exists only to let depend.m4 do its work.  It works by
2492b15cb3dSCy Schubert  # looking at the text of this script.  This case will never be run,
2502b15cb3dSCy Schubert  # since it is checked for above.
2512b15cb3dSCy Schubert  exit 1
2522b15cb3dSCy Schubert  ;;
2532b15cb3dSCy Schubert
2542b15cb3dSCy Schubertsgi)
2552b15cb3dSCy Schubert  if test "$libtool" = yes; then
2562b15cb3dSCy Schubert    "$@" "-Wp,-MDupdate,$tmpdepfile"
2572b15cb3dSCy Schubert  else
2582b15cb3dSCy Schubert    "$@" -MDupdate "$tmpdepfile"
2592b15cb3dSCy Schubert  fi
2602b15cb3dSCy Schubert  stat=$?
261f0574f5cSXin LI  if test $stat -ne 0; then
2622b15cb3dSCy Schubert    rm -f "$tmpdepfile"
2632b15cb3dSCy Schubert    exit $stat
2642b15cb3dSCy Schubert  fi
2652b15cb3dSCy Schubert  rm -f "$depfile"
2662b15cb3dSCy Schubert
2672b15cb3dSCy Schubert  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
2682b15cb3dSCy Schubert    echo "$object : \\" > "$depfile"
2692b15cb3dSCy Schubert    # Clip off the initial element (the dependent).  Don't try to be
2702b15cb3dSCy Schubert    # clever and replace this with sed code, as IRIX sed won't handle
2712b15cb3dSCy Schubert    # lines with more than a fixed number of characters (4096 in
2722b15cb3dSCy Schubert    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
273f0574f5cSXin LI    # the IRIX cc adds comments like '#:fec' to the end of the
2742b15cb3dSCy Schubert    # dependency line.
275f0574f5cSXin LI    tr ' ' "$nl" < "$tmpdepfile" \
276f0574f5cSXin LI      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
277f0574f5cSXin LI      | tr "$nl" ' ' >> "$depfile"
2782b15cb3dSCy Schubert    echo >> "$depfile"
2792b15cb3dSCy Schubert    # The second pass generates a dummy entry for each header file.
280f0574f5cSXin LI    tr ' ' "$nl" < "$tmpdepfile" \
2812b15cb3dSCy Schubert      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2822b15cb3dSCy Schubert      >> "$depfile"
2832b15cb3dSCy Schubert  else
284f0574f5cSXin LI    make_dummy_depfile
2852b15cb3dSCy Schubert  fi
2862b15cb3dSCy Schubert  rm -f "$tmpdepfile"
2872b15cb3dSCy Schubert  ;;
2882b15cb3dSCy Schubert
289f0574f5cSXin LIxlc)
290f0574f5cSXin LI  # This case exists only to let depend.m4 do its work.  It works by
291f0574f5cSXin LI  # looking at the text of this script.  This case will never be run,
292f0574f5cSXin LI  # since it is checked for above.
293f0574f5cSXin LI  exit 1
294f0574f5cSXin LI  ;;
295f0574f5cSXin LI
2962b15cb3dSCy Schubertaix)
2972b15cb3dSCy Schubert  # The C for AIX Compiler uses -M and outputs the dependencies
2982b15cb3dSCy Schubert  # in a .u file.  In older versions, this file always lives in the
299f0574f5cSXin LI  # current directory.  Also, the AIX compiler puts '$object:' at the
3002b15cb3dSCy Schubert  # start of each line; $object doesn't have directory information.
3012b15cb3dSCy Schubert  # Version 6 uses the directory in both cases.
302f0574f5cSXin LI  set_dir_from "$object"
303f0574f5cSXin LI  set_base_from "$object"
3042b15cb3dSCy Schubert  if test "$libtool" = yes; then
3052b15cb3dSCy Schubert    tmpdepfile1=$dir$base.u
3062b15cb3dSCy Schubert    tmpdepfile2=$base.u
3072b15cb3dSCy Schubert    tmpdepfile3=$dir.libs/$base.u
3082b15cb3dSCy Schubert    "$@" -Wc,-M
3092b15cb3dSCy Schubert  else
3102b15cb3dSCy Schubert    tmpdepfile1=$dir$base.u
3112b15cb3dSCy Schubert    tmpdepfile2=$dir$base.u
3122b15cb3dSCy Schubert    tmpdepfile3=$dir$base.u
3132b15cb3dSCy Schubert    "$@" -M
3142b15cb3dSCy Schubert  fi
3152b15cb3dSCy Schubert  stat=$?
316f0574f5cSXin LI  if test $stat -ne 0; then
3172b15cb3dSCy Schubert    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
3182b15cb3dSCy Schubert    exit $stat
3192b15cb3dSCy Schubert  fi
3202b15cb3dSCy Schubert
3212b15cb3dSCy Schubert  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
3222b15cb3dSCy Schubert  do
3232b15cb3dSCy Schubert    test -f "$tmpdepfile" && break
3242b15cb3dSCy Schubert  done
325f0574f5cSXin LI  aix_post_process_depfile
326f0574f5cSXin LI  ;;
327f0574f5cSXin LI
328f0574f5cSXin LItcc)
329f0574f5cSXin LI  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
330f0574f5cSXin LI  # FIXME: That version still under development at the moment of writing.
331f0574f5cSXin LI  #        Make that this statement remains true also for stable, released
332f0574f5cSXin LI  #        versions.
333f0574f5cSXin LI  # It will wrap lines (doesn't matter whether long or short) with a
334f0574f5cSXin LI  # trailing '\', as in:
335f0574f5cSXin LI  #
336f0574f5cSXin LI  #   foo.o : \
337f0574f5cSXin LI  #    foo.c \
338f0574f5cSXin LI  #    foo.h \
339f0574f5cSXin LI  #
340f0574f5cSXin LI  # It will put a trailing '\' even on the last line, and will use leading
341f0574f5cSXin LI  # spaces rather than leading tabs (at least since its commit 0394caf7
342f0574f5cSXin LI  # "Emit spaces for -MD").
343f0574f5cSXin LI  "$@" -MD -MF "$tmpdepfile"
344f0574f5cSXin LI  stat=$?
345f0574f5cSXin LI  if test $stat -ne 0; then
346f0574f5cSXin LI    rm -f "$tmpdepfile"
347f0574f5cSXin LI    exit $stat
3482b15cb3dSCy Schubert  fi
349f0574f5cSXin LI  rm -f "$depfile"
350f0574f5cSXin LI  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
351f0574f5cSXin LI  # We have to change lines of the first kind to '$object: \'.
352f0574f5cSXin LI  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
353f0574f5cSXin LI  # And for each line of the second kind, we have to emit a 'dep.h:'
354f0574f5cSXin LI  # dummy dependency, to avoid the deleted-header problem.
355f0574f5cSXin LI  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
3562b15cb3dSCy Schubert  rm -f "$tmpdepfile"
3572b15cb3dSCy Schubert  ;;
3582b15cb3dSCy Schubert
359f0574f5cSXin LI## The order of this option in the case statement is important, since the
360f0574f5cSXin LI## shell code in configure will try each of these formats in the order
361f0574f5cSXin LI## listed in this file.  A plain '-MD' option would be understood by many
362f0574f5cSXin LI## compilers, so we must ensure this comes after the gcc and icc options.
363f0574f5cSXin LIpgcc)
364f0574f5cSXin LI  # Portland's C compiler understands '-MD'.
365f0574f5cSXin LI  # Will always output deps to 'file.d' where file is the root name of the
366f0574f5cSXin LI  # source file under compilation, even if file resides in a subdirectory.
367f0574f5cSXin LI  # The object file name does not affect the name of the '.d' file.
368f0574f5cSXin LI  # pgcc 10.2 will output
3692b15cb3dSCy Schubert  #    foo.o: sub/foo.c sub/foo.h
370f0574f5cSXin LI  # and will wrap long lines using '\' :
3712b15cb3dSCy Schubert  #    foo.o: sub/foo.c ... \
3722b15cb3dSCy Schubert  #     sub/foo.h ... \
3732b15cb3dSCy Schubert  #     ...
374f0574f5cSXin LI  set_dir_from "$object"
375f0574f5cSXin LI  # Use the source, not the object, to determine the base name, since
376f0574f5cSXin LI  # that's sadly what pgcc will do too.
377f0574f5cSXin LI  set_base_from "$source"
378f0574f5cSXin LI  tmpdepfile=$base.d
3792b15cb3dSCy Schubert
380f0574f5cSXin LI  # For projects that build the same source file twice into different object
381f0574f5cSXin LI  # files, the pgcc approach of using the *source* file root name can cause
382f0574f5cSXin LI  # problems in parallel builds.  Use a locking strategy to avoid stomping on
383f0574f5cSXin LI  # the same $tmpdepfile.
384f0574f5cSXin LI  lockdir=$base.d-lock
385f0574f5cSXin LI  trap "
386f0574f5cSXin LI    echo '$0: caught signal, cleaning up...' >&2
387f0574f5cSXin LI    rmdir '$lockdir'
388f0574f5cSXin LI    exit 1
389f0574f5cSXin LI  " 1 2 13 15
390f0574f5cSXin LI  numtries=100
391f0574f5cSXin LI  i=$numtries
392f0574f5cSXin LI  while test $i -gt 0; do
393f0574f5cSXin LI    # mkdir is a portable test-and-set.
394f0574f5cSXin LI    if mkdir "$lockdir" 2>/dev/null; then
395f0574f5cSXin LI      # This process acquired the lock.
396f0574f5cSXin LI      "$@" -MD
3972b15cb3dSCy Schubert      stat=$?
398f0574f5cSXin LI      # Release the lock.
399f0574f5cSXin LI      rmdir "$lockdir"
400f0574f5cSXin LI      break
4012b15cb3dSCy Schubert    else
402f0574f5cSXin LI      # If the lock is being held by a different process, wait
403f0574f5cSXin LI      # until the winning process is done or we timeout.
404f0574f5cSXin LI      while test -d "$lockdir" && test $i -gt 0; do
405f0574f5cSXin LI        sleep 1
406f0574f5cSXin LI        i=`expr $i - 1`
407f0574f5cSXin LI      done
408f0574f5cSXin LI    fi
409f0574f5cSXin LI    i=`expr $i - 1`
410f0574f5cSXin LI  done
411f0574f5cSXin LI  trap - 1 2 13 15
412f0574f5cSXin LI  if test $i -le 0; then
413f0574f5cSXin LI    echo "$0: failed to acquire lock after $numtries attempts" >&2
414f0574f5cSXin LI    echo "$0: check lockdir '$lockdir'" >&2
415f0574f5cSXin LI    exit 1
416f0574f5cSXin LI  fi
417f0574f5cSXin LI
418f0574f5cSXin LI  if test $stat -ne 0; then
4192b15cb3dSCy Schubert    rm -f "$tmpdepfile"
4202b15cb3dSCy Schubert    exit $stat
4212b15cb3dSCy Schubert  fi
4222b15cb3dSCy Schubert  rm -f "$depfile"
4232b15cb3dSCy Schubert  # Each line is of the form `foo.o: dependent.h',
4242b15cb3dSCy Schubert  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
4252b15cb3dSCy Schubert  # Do two passes, one to just change these to
4262b15cb3dSCy Schubert  # `$object: dependent.h' and one to simply `dependent.h:'.
4272b15cb3dSCy Schubert  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
4282b15cb3dSCy Schubert  # Some versions of the HPUX 10.20 sed can't process this invocation
4292b15cb3dSCy Schubert  # correctly.  Breaking it into two sed invocations is a workaround.
430f0574f5cSXin LI  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
431f0574f5cSXin LI    | sed -e 's/$/ :/' >> "$depfile"
4322b15cb3dSCy Schubert  rm -f "$tmpdepfile"
4332b15cb3dSCy Schubert  ;;
4342b15cb3dSCy Schubert
4352b15cb3dSCy Schuberthp2)
4362b15cb3dSCy Schubert  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
4372b15cb3dSCy Schubert  # compilers, which have integrated preprocessors.  The correct option
4382b15cb3dSCy Schubert  # to use with these is +Maked; it writes dependencies to a file named
4392b15cb3dSCy Schubert  # 'foo.d', which lands next to the object file, wherever that
4402b15cb3dSCy Schubert  # happens to be.
4412b15cb3dSCy Schubert  # Much of this is similar to the tru64 case; see comments there.
442f0574f5cSXin LI  set_dir_from  "$object"
443f0574f5cSXin LI  set_base_from "$object"
4442b15cb3dSCy Schubert  if test "$libtool" = yes; then
4452b15cb3dSCy Schubert    tmpdepfile1=$dir$base.d
4462b15cb3dSCy Schubert    tmpdepfile2=$dir.libs/$base.d
4472b15cb3dSCy Schubert    "$@" -Wc,+Maked
4482b15cb3dSCy Schubert  else
4492b15cb3dSCy Schubert    tmpdepfile1=$dir$base.d
4502b15cb3dSCy Schubert    tmpdepfile2=$dir$base.d
4512b15cb3dSCy Schubert    "$@" +Maked
4522b15cb3dSCy Schubert  fi
4532b15cb3dSCy Schubert  stat=$?
454f0574f5cSXin LI  if test $stat -ne 0; then
4552b15cb3dSCy Schubert     rm -f "$tmpdepfile1" "$tmpdepfile2"
4562b15cb3dSCy Schubert     exit $stat
4572b15cb3dSCy Schubert  fi
4582b15cb3dSCy Schubert
4592b15cb3dSCy Schubert  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
4602b15cb3dSCy Schubert  do
4612b15cb3dSCy Schubert    test -f "$tmpdepfile" && break
4622b15cb3dSCy Schubert  done
4632b15cb3dSCy Schubert  if test -f "$tmpdepfile"; then
464f0574f5cSXin LI    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
465f0574f5cSXin LI    # Add 'dependent.h:' lines.
4662b15cb3dSCy Schubert    sed -ne '2,${
4672b15cb3dSCy Schubert               s/^ *//
4682b15cb3dSCy Schubert               s/ \\*$//
4692b15cb3dSCy Schubert               s/$/:/
4702b15cb3dSCy Schubert               p
4712b15cb3dSCy Schubert             }' "$tmpdepfile" >> "$depfile"
4722b15cb3dSCy Schubert  else
473f0574f5cSXin LI    make_dummy_depfile
4742b15cb3dSCy Schubert  fi
4752b15cb3dSCy Schubert  rm -f "$tmpdepfile" "$tmpdepfile2"
4762b15cb3dSCy Schubert  ;;
4772b15cb3dSCy Schubert
4782b15cb3dSCy Schuberttru64)
4792b15cb3dSCy Schubert  # The Tru64 compiler uses -MD to generate dependencies as a side
480f0574f5cSXin LI  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
4812b15cb3dSCy Schubert  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
482f0574f5cSXin LI  # dependencies in 'foo.d' instead, so we check for that too.
4832b15cb3dSCy Schubert  # Subdirectories are respected.
484f0574f5cSXin LI  set_dir_from  "$object"
485f0574f5cSXin LI  set_base_from "$object"
4862b15cb3dSCy Schubert
4872b15cb3dSCy Schubert  if test "$libtool" = yes; then
488f0574f5cSXin LI    # Libtool generates 2 separate objects for the 2 libraries.  These
489f0574f5cSXin LI    # two compilations output dependencies in $dir.libs/$base.o.d and
4902b15cb3dSCy Schubert    # in $dir$base.o.d.  We have to check for both files, because
4912b15cb3dSCy Schubert    # one of the two compilations can be disabled.  We should prefer
4922b15cb3dSCy Schubert    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
4932b15cb3dSCy Schubert    # automatically cleaned when .libs/ is deleted, while ignoring
4942b15cb3dSCy Schubert    # the former would cause a distcleancheck panic.
495f0574f5cSXin LI    tmpdepfile1=$dir$base.o.d          # libtool 1.5
496f0574f5cSXin LI    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
497f0574f5cSXin LI    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
4982b15cb3dSCy Schubert    "$@" -Wc,-MD
4992b15cb3dSCy Schubert  else
500f0574f5cSXin LI    tmpdepfile1=$dir$base.d
5012b15cb3dSCy Schubert    tmpdepfile2=$dir$base.d
5022b15cb3dSCy Schubert    tmpdepfile3=$dir$base.d
5032b15cb3dSCy Schubert    "$@" -MD
5042b15cb3dSCy Schubert  fi
5052b15cb3dSCy Schubert
5062b15cb3dSCy Schubert  stat=$?
507f0574f5cSXin LI  if test $stat -ne 0; then
508f0574f5cSXin LI    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
5092b15cb3dSCy Schubert    exit $stat
5102b15cb3dSCy Schubert  fi
5112b15cb3dSCy Schubert
512f0574f5cSXin LI  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
5132b15cb3dSCy Schubert  do
5142b15cb3dSCy Schubert    test -f "$tmpdepfile" && break
5152b15cb3dSCy Schubert  done
516f0574f5cSXin LI  # Same post-processing that is required for AIX mode.
517f0574f5cSXin LI  aix_post_process_depfile
518f0574f5cSXin LI  ;;
519f0574f5cSXin LI
520f0574f5cSXin LImsvc7)
521f0574f5cSXin LI  if test "$libtool" = yes; then
522f0574f5cSXin LI    showIncludes=-Wc,-showIncludes
5232b15cb3dSCy Schubert  else
524f0574f5cSXin LI    showIncludes=-showIncludes
5252b15cb3dSCy Schubert  fi
526f0574f5cSXin LI  "$@" $showIncludes > "$tmpdepfile"
527f0574f5cSXin LI  stat=$?
528f0574f5cSXin LI  grep -v '^Note: including file: ' "$tmpdepfile"
529f0574f5cSXin LI  if test $stat -ne 0; then
5302b15cb3dSCy Schubert    rm -f "$tmpdepfile"
531f0574f5cSXin LI    exit $stat
532f0574f5cSXin LI  fi
533f0574f5cSXin LI  rm -f "$depfile"
534f0574f5cSXin LI  echo "$object : \\" > "$depfile"
535f0574f5cSXin LI  # The first sed program below extracts the file names and escapes
536f0574f5cSXin LI  # backslashes for cygpath.  The second sed program outputs the file
537f0574f5cSXin LI  # name when reading, but also accumulates all include files in the
538f0574f5cSXin LI  # hold buffer in order to output them again at the end.  This only
539f0574f5cSXin LI  # works with sed implementations that can handle large buffers.
540f0574f5cSXin LI  sed < "$tmpdepfile" -n '
541f0574f5cSXin LI/^Note: including file:  *\(.*\)/ {
542f0574f5cSXin LI  s//\1/
543f0574f5cSXin LI  s/\\/\\\\/g
544f0574f5cSXin LI  p
545f0574f5cSXin LI}' | $cygpath_u | sort -u | sed -n '
546f0574f5cSXin LIs/ /\\ /g
547f0574f5cSXin LIs/\(.*\)/'"$tab"'\1 \\/p
548f0574f5cSXin LIs/.\(.*\) \\/\1:/
549f0574f5cSXin LIH
550f0574f5cSXin LI$ {
551f0574f5cSXin LI  s/.*/'"$tab"'/
552f0574f5cSXin LI  G
553f0574f5cSXin LI  p
554f0574f5cSXin LI}' >> "$depfile"
555f0574f5cSXin LI  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
556f0574f5cSXin LI  rm -f "$tmpdepfile"
557f0574f5cSXin LI  ;;
558f0574f5cSXin LI
559f0574f5cSXin LImsvc7msys)
560f0574f5cSXin LI  # This case exists only to let depend.m4 do its work.  It works by
561f0574f5cSXin LI  # looking at the text of this script.  This case will never be run,
562f0574f5cSXin LI  # since it is checked for above.
563f0574f5cSXin LI  exit 1
5642b15cb3dSCy Schubert  ;;
5652b15cb3dSCy Schubert
5662b15cb3dSCy Schubert#nosideeffect)
5672b15cb3dSCy Schubert  # This comment above is used by automake to tell side-effect
5682b15cb3dSCy Schubert  # dependency tracking mechanisms from slower ones.
5692b15cb3dSCy Schubert
5702b15cb3dSCy Schubertdashmstdout)
5712b15cb3dSCy Schubert  # Important note: in order to support this mode, a compiler *must*
5722b15cb3dSCy Schubert  # always write the preprocessed file to stdout, regardless of -o.
5732b15cb3dSCy Schubert  "$@" || exit $?
5742b15cb3dSCy Schubert
5752b15cb3dSCy Schubert  # Remove the call to Libtool.
5762b15cb3dSCy Schubert  if test "$libtool" = yes; then
5772b15cb3dSCy Schubert    while test "X$1" != 'X--mode=compile'; do
5782b15cb3dSCy Schubert      shift
5792b15cb3dSCy Schubert    done
5802b15cb3dSCy Schubert    shift
5812b15cb3dSCy Schubert  fi
5822b15cb3dSCy Schubert
583f0574f5cSXin LI  # Remove '-o $object'.
5842b15cb3dSCy Schubert  IFS=" "
5852b15cb3dSCy Schubert  for arg
5862b15cb3dSCy Schubert  do
5872b15cb3dSCy Schubert    case $arg in
5882b15cb3dSCy Schubert    -o)
5892b15cb3dSCy Schubert      shift
5902b15cb3dSCy Schubert      ;;
5912b15cb3dSCy Schubert    $object)
5922b15cb3dSCy Schubert      shift
5932b15cb3dSCy Schubert      ;;
5942b15cb3dSCy Schubert    *)
5952b15cb3dSCy Schubert      set fnord "$@" "$arg"
5962b15cb3dSCy Schubert      shift # fnord
5972b15cb3dSCy Schubert      shift # $arg
5982b15cb3dSCy Schubert      ;;
5992b15cb3dSCy Schubert    esac
6002b15cb3dSCy Schubert  done
6012b15cb3dSCy Schubert
6022b15cb3dSCy Schubert  test -z "$dashmflag" && dashmflag=-M
603f0574f5cSXin LI  # Require at least two characters before searching for ':'
6042b15cb3dSCy Schubert  # in the target name.  This is to cope with DOS-style filenames:
605f0574f5cSXin LI  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
6062b15cb3dSCy Schubert  "$@" $dashmflag |
607f0574f5cSXin LI    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
6082b15cb3dSCy Schubert  rm -f "$depfile"
6092b15cb3dSCy Schubert  cat < "$tmpdepfile" > "$depfile"
610f0574f5cSXin LI  # Some versions of the HPUX 10.20 sed can't process this sed invocation
611f0574f5cSXin LI  # correctly.  Breaking it into two sed invocations is a workaround.
612f0574f5cSXin LI  tr ' ' "$nl" < "$tmpdepfile" \
613f0574f5cSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
614f0574f5cSXin LI    | sed -e 's/$/ :/' >> "$depfile"
6152b15cb3dSCy Schubert  rm -f "$tmpdepfile"
6162b15cb3dSCy Schubert  ;;
6172b15cb3dSCy Schubert
6182b15cb3dSCy SchubertdashXmstdout)
6192b15cb3dSCy Schubert  # This case only exists to satisfy depend.m4.  It is never actually
6202b15cb3dSCy Schubert  # run, as this mode is specially recognized in the preamble.
6212b15cb3dSCy Schubert  exit 1
6222b15cb3dSCy Schubert  ;;
6232b15cb3dSCy Schubert
6242b15cb3dSCy Schubertmakedepend)
6252b15cb3dSCy Schubert  "$@" || exit $?
6262b15cb3dSCy Schubert  # Remove any Libtool call
6272b15cb3dSCy Schubert  if test "$libtool" = yes; then
6282b15cb3dSCy Schubert    while test "X$1" != 'X--mode=compile'; do
6292b15cb3dSCy Schubert      shift
6302b15cb3dSCy Schubert    done
6312b15cb3dSCy Schubert    shift
6322b15cb3dSCy Schubert  fi
6332b15cb3dSCy Schubert  # X makedepend
6342b15cb3dSCy Schubert  shift
6352b15cb3dSCy Schubert  cleared=no eat=no
6362b15cb3dSCy Schubert  for arg
6372b15cb3dSCy Schubert  do
6382b15cb3dSCy Schubert    case $cleared in
6392b15cb3dSCy Schubert    no)
6402b15cb3dSCy Schubert      set ""; shift
6412b15cb3dSCy Schubert      cleared=yes ;;
6422b15cb3dSCy Schubert    esac
6432b15cb3dSCy Schubert    if test $eat = yes; then
6442b15cb3dSCy Schubert      eat=no
6452b15cb3dSCy Schubert      continue
6462b15cb3dSCy Schubert    fi
6472b15cb3dSCy Schubert    case "$arg" in
6482b15cb3dSCy Schubert    -D*|-I*)
6492b15cb3dSCy Schubert      set fnord "$@" "$arg"; shift ;;
6502b15cb3dSCy Schubert    # Strip any option that makedepend may not understand.  Remove
6512b15cb3dSCy Schubert    # the object too, otherwise makedepend will parse it as a source file.
6522b15cb3dSCy Schubert    -arch)
6532b15cb3dSCy Schubert      eat=yes ;;
6542b15cb3dSCy Schubert    -*|$object)
6552b15cb3dSCy Schubert      ;;
6562b15cb3dSCy Schubert    *)
6572b15cb3dSCy Schubert      set fnord "$@" "$arg"; shift ;;
6582b15cb3dSCy Schubert    esac
6592b15cb3dSCy Schubert  done
6602b15cb3dSCy Schubert  obj_suffix=`echo "$object" | sed 's/^.*\././'`
6612b15cb3dSCy Schubert  touch "$tmpdepfile"
6622b15cb3dSCy Schubert  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
6632b15cb3dSCy Schubert  rm -f "$depfile"
664f0574f5cSXin LI  # makedepend may prepend the VPATH from the source file name to the object.
665f0574f5cSXin LI  # No need to regex-escape $object, excess matching of '.' is harmless.
666f0574f5cSXin LI  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
667f0574f5cSXin LI  # Some versions of the HPUX 10.20 sed can't process the last invocation
668f0574f5cSXin LI  # correctly.  Breaking it into two sed invocations is a workaround.
669f0574f5cSXin LI  sed '1,2d' "$tmpdepfile" \
670f0574f5cSXin LI    | tr ' ' "$nl" \
671f0574f5cSXin LI    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
672f0574f5cSXin LI    | sed -e 's/$/ :/' >> "$depfile"
6732b15cb3dSCy Schubert  rm -f "$tmpdepfile" "$tmpdepfile".bak
6742b15cb3dSCy Schubert  ;;
6752b15cb3dSCy Schubert
6762b15cb3dSCy Schubertcpp)
6772b15cb3dSCy Schubert  # Important note: in order to support this mode, a compiler *must*
6782b15cb3dSCy Schubert  # always write the preprocessed file to stdout.
6792b15cb3dSCy Schubert  "$@" || exit $?
6802b15cb3dSCy Schubert
6812b15cb3dSCy Schubert  # Remove the call to Libtool.
6822b15cb3dSCy Schubert  if test "$libtool" = yes; then
6832b15cb3dSCy Schubert    while test "X$1" != 'X--mode=compile'; do
6842b15cb3dSCy Schubert      shift
6852b15cb3dSCy Schubert    done
6862b15cb3dSCy Schubert    shift
6872b15cb3dSCy Schubert  fi
6882b15cb3dSCy Schubert
689f0574f5cSXin LI  # Remove '-o $object'.
6902b15cb3dSCy Schubert  IFS=" "
6912b15cb3dSCy Schubert  for arg
6922b15cb3dSCy Schubert  do
6932b15cb3dSCy Schubert    case $arg in
6942b15cb3dSCy Schubert    -o)
6952b15cb3dSCy Schubert      shift
6962b15cb3dSCy Schubert      ;;
6972b15cb3dSCy Schubert    $object)
6982b15cb3dSCy Schubert      shift
6992b15cb3dSCy Schubert      ;;
7002b15cb3dSCy Schubert    *)
7012b15cb3dSCy Schubert      set fnord "$@" "$arg"
7022b15cb3dSCy Schubert      shift # fnord
7032b15cb3dSCy Schubert      shift # $arg
7042b15cb3dSCy Schubert      ;;
7052b15cb3dSCy Schubert    esac
7062b15cb3dSCy Schubert  done
7072b15cb3dSCy Schubert
708f0574f5cSXin LI  "$@" -E \
709f0574f5cSXin LI    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
710f0574f5cSXin LI             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
711f0574f5cSXin LI    | sed '$ s: \\$::' > "$tmpdepfile"
7122b15cb3dSCy Schubert  rm -f "$depfile"
7132b15cb3dSCy Schubert  echo "$object : \\" > "$depfile"
7142b15cb3dSCy Schubert  cat < "$tmpdepfile" >> "$depfile"
7152b15cb3dSCy Schubert  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
7162b15cb3dSCy Schubert  rm -f "$tmpdepfile"
7172b15cb3dSCy Schubert  ;;
7182b15cb3dSCy Schubert
7192b15cb3dSCy Schubertmsvisualcpp)
7202b15cb3dSCy Schubert  # Important note: in order to support this mode, a compiler *must*
7212b15cb3dSCy Schubert  # always write the preprocessed file to stdout.
7222b15cb3dSCy Schubert  "$@" || exit $?
7232b15cb3dSCy Schubert
7242b15cb3dSCy Schubert  # Remove the call to Libtool.
7252b15cb3dSCy Schubert  if test "$libtool" = yes; then
7262b15cb3dSCy Schubert    while test "X$1" != 'X--mode=compile'; do
7272b15cb3dSCy Schubert      shift
7282b15cb3dSCy Schubert    done
7292b15cb3dSCy Schubert    shift
7302b15cb3dSCy Schubert  fi
7312b15cb3dSCy Schubert
7322b15cb3dSCy Schubert  IFS=" "
7332b15cb3dSCy Schubert  for arg
7342b15cb3dSCy Schubert  do
7352b15cb3dSCy Schubert    case "$arg" in
7362b15cb3dSCy Schubert    -o)
7372b15cb3dSCy Schubert      shift
7382b15cb3dSCy Schubert      ;;
7392b15cb3dSCy Schubert    $object)
7402b15cb3dSCy Schubert      shift
7412b15cb3dSCy Schubert      ;;
7422b15cb3dSCy Schubert    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
7432b15cb3dSCy Schubert        set fnord "$@"
7442b15cb3dSCy Schubert        shift
7452b15cb3dSCy Schubert        shift
7462b15cb3dSCy Schubert        ;;
7472b15cb3dSCy Schubert    *)
7482b15cb3dSCy Schubert        set fnord "$@" "$arg"
7492b15cb3dSCy Schubert        shift
7502b15cb3dSCy Schubert        shift
7512b15cb3dSCy Schubert        ;;
7522b15cb3dSCy Schubert    esac
7532b15cb3dSCy Schubert  done
7542b15cb3dSCy Schubert  "$@" -E 2>/dev/null |
7552b15cb3dSCy Schubert  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
7562b15cb3dSCy Schubert  rm -f "$depfile"
7572b15cb3dSCy Schubert  echo "$object : \\" > "$depfile"
758f0574f5cSXin LI  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
759f0574f5cSXin LI  echo "$tab" >> "$depfile"
7602b15cb3dSCy Schubert  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
7612b15cb3dSCy Schubert  rm -f "$tmpdepfile"
7622b15cb3dSCy Schubert  ;;
7632b15cb3dSCy Schubert
7642b15cb3dSCy Schubertmsvcmsys)
7652b15cb3dSCy Schubert  # This case exists only to let depend.m4 do its work.  It works by
7662b15cb3dSCy Schubert  # looking at the text of this script.  This case will never be run,
7672b15cb3dSCy Schubert  # since it is checked for above.
7682b15cb3dSCy Schubert  exit 1
7692b15cb3dSCy Schubert  ;;
7702b15cb3dSCy Schubert
7712b15cb3dSCy Schubertnone)
7722b15cb3dSCy Schubert  exec "$@"
7732b15cb3dSCy Schubert  ;;
7742b15cb3dSCy Schubert
7752b15cb3dSCy Schubert*)
7762b15cb3dSCy Schubert  echo "Unknown depmode $depmode" 1>&2
7772b15cb3dSCy Schubert  exit 1
7782b15cb3dSCy Schubert  ;;
7792b15cb3dSCy Schubertesac
7802b15cb3dSCy Schubert
7812b15cb3dSCy Schubertexit 0
7822b15cb3dSCy Schubert
7832b15cb3dSCy Schubert# Local Variables:
7842b15cb3dSCy Schubert# mode: shell-script
7852b15cb3dSCy Schubert# sh-indentation: 2
7862b15cb3dSCy Schubert# eval: (add-hook 'write-file-hooks 'time-stamp)
7872b15cb3dSCy Schubert# time-stamp-start: "scriptversion="
7882b15cb3dSCy Schubert# time-stamp-format: "%:y-%02m-%02d.%02H"
789*2d4e511cSCy Schubert# time-stamp-time-zone: "UTC"
7902b15cb3dSCy Schubert# time-stamp-end: "; # UTC"
7912b15cb3dSCy Schubert# End:
792