176404edcSAsim Jamshed#! /bin/sh
276404edcSAsim Jamshed# depcomp - compile a program generating dependencies as side-effects
376404edcSAsim Jamshed
4d270d183SAsim Jamshedscriptversion=2013-05-30.07; # UTC
576404edcSAsim Jamshed
6d270d183SAsim Jamshed# Copyright (C) 1999-2014 Free Software Foundation, Inc.
776404edcSAsim Jamshed
876404edcSAsim Jamshed# This program is free software; you can redistribute it and/or modify
976404edcSAsim Jamshed# it under the terms of the GNU General Public License as published by
1076404edcSAsim Jamshed# the Free Software Foundation; either version 2, or (at your option)
1176404edcSAsim Jamshed# any later version.
1276404edcSAsim Jamshed
1376404edcSAsim Jamshed# This program is distributed in the hope that it will be useful,
1476404edcSAsim Jamshed# but WITHOUT ANY WARRANTY; without even the implied warranty of
1576404edcSAsim Jamshed# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1676404edcSAsim Jamshed# GNU General Public License for more details.
1776404edcSAsim Jamshed
1876404edcSAsim Jamshed# You should have received a copy of the GNU General Public License
1976404edcSAsim Jamshed# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2076404edcSAsim Jamshed
2176404edcSAsim Jamshed# As a special exception to the GNU General Public License, if you
2276404edcSAsim Jamshed# distribute this file as part of a program that contains a
2376404edcSAsim Jamshed# configuration script generated by Autoconf, you may include it under
2476404edcSAsim Jamshed# the same distribution terms that you use for the rest of that program.
2576404edcSAsim Jamshed
2676404edcSAsim Jamshed# Originally written by Alexandre Oliva <[email protected]>.
2776404edcSAsim Jamshed
2876404edcSAsim Jamshedcase $1 in
2976404edcSAsim Jamshed  '')
3076404edcSAsim Jamshed    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
3176404edcSAsim Jamshed    exit 1;
3276404edcSAsim Jamshed    ;;
3376404edcSAsim Jamshed  -h | --h*)
3476404edcSAsim Jamshed    cat <<\EOF
3576404edcSAsim JamshedUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3676404edcSAsim Jamshed
3776404edcSAsim JamshedRun PROGRAMS ARGS to compile a file, generating dependencies
3876404edcSAsim Jamshedas side-effects.
3976404edcSAsim Jamshed
4076404edcSAsim JamshedEnvironment variables:
4176404edcSAsim Jamshed  depmode     Dependency tracking mode.
4276404edcSAsim Jamshed  source      Source file read by 'PROGRAMS ARGS'.
4376404edcSAsim Jamshed  object      Object file output by 'PROGRAMS ARGS'.
4476404edcSAsim Jamshed  DEPDIR      directory where to store dependencies.
4576404edcSAsim Jamshed  depfile     Dependency file to output.
4676404edcSAsim Jamshed  tmpdepfile  Temporary file to use when outputting dependencies.
4776404edcSAsim Jamshed  libtool     Whether libtool is used (yes/no).
4876404edcSAsim Jamshed
4976404edcSAsim JamshedReport bugs to <bug-automake@gnu.org>.
5076404edcSAsim JamshedEOF
5176404edcSAsim Jamshed    exit $?
5276404edcSAsim Jamshed    ;;
5376404edcSAsim Jamshed  -v | --v*)
5476404edcSAsim Jamshed    echo "depcomp $scriptversion"
5576404edcSAsim Jamshed    exit $?
5676404edcSAsim Jamshed    ;;
5776404edcSAsim Jamshedesac
5876404edcSAsim Jamshed
59d270d183SAsim Jamshed# Get the directory component of the given path, and save it in the
60d270d183SAsim Jamshed# global variables '$dir'.  Note that this directory component will
61d270d183SAsim Jamshed# be either empty or ending with a '/' character.  This is deliberate.
62d270d183SAsim Jamshedset_dir_from ()
63d270d183SAsim Jamshed{
64d270d183SAsim Jamshed  case $1 in
65d270d183SAsim Jamshed    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66d270d183SAsim Jamshed      *) dir=;;
67d270d183SAsim Jamshed  esac
68d270d183SAsim Jamshed}
69d270d183SAsim Jamshed
70d270d183SAsim Jamshed# Get the suffix-stripped basename of the given path, and save it the
71d270d183SAsim Jamshed# global variable '$base'.
72d270d183SAsim Jamshedset_base_from ()
73d270d183SAsim Jamshed{
74d270d183SAsim Jamshed  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
75d270d183SAsim Jamshed}
76d270d183SAsim Jamshed
77d270d183SAsim Jamshed# If no dependency file was actually created by the compiler invocation,
78d270d183SAsim Jamshed# we still have to create a dummy depfile, to avoid errors with the
79d270d183SAsim Jamshed# Makefile "include basename.Plo" scheme.
80d270d183SAsim Jamshedmake_dummy_depfile ()
81d270d183SAsim Jamshed{
82d270d183SAsim Jamshed  echo "#dummy" > "$depfile"
83d270d183SAsim Jamshed}
84d270d183SAsim Jamshed
85d270d183SAsim Jamshed# Factor out some common post-processing of the generated depfile.
86d270d183SAsim Jamshed# Requires the auxiliary global variable '$tmpdepfile' to be set.
87d270d183SAsim Jamshedaix_post_process_depfile ()
88d270d183SAsim Jamshed{
89d270d183SAsim Jamshed  # If the compiler actually managed to produce a dependency file,
90d270d183SAsim Jamshed  # post-process it.
91d270d183SAsim Jamshed  if test -f "$tmpdepfile"; then
92d270d183SAsim Jamshed    # Each line is of the form 'foo.o: dependency.h'.
93d270d183SAsim Jamshed    # Do two passes, one to just change these to
94d270d183SAsim Jamshed    #   $object: dependency.h
95d270d183SAsim Jamshed    # and one to simply output
96d270d183SAsim Jamshed    #   dependency.h:
97d270d183SAsim Jamshed    # which is needed to avoid the deleted-header problem.
98d270d183SAsim Jamshed    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
99d270d183SAsim Jamshed      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
100d270d183SAsim Jamshed    } > "$depfile"
101d270d183SAsim Jamshed    rm -f "$tmpdepfile"
102d270d183SAsim Jamshed  else
103d270d183SAsim Jamshed    make_dummy_depfile
104d270d183SAsim Jamshed  fi
105d270d183SAsim Jamshed}
106d270d183SAsim Jamshed
10776404edcSAsim Jamshed# A tabulation character.
10876404edcSAsim Jamshedtab='	'
10976404edcSAsim Jamshed# A newline character.
11076404edcSAsim Jamshednl='
11176404edcSAsim Jamshed'
112d270d183SAsim Jamshed# Character ranges might be problematic outside the C locale.
113d270d183SAsim Jamshed# These definitions help.
114d270d183SAsim Jamshedupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
115d270d183SAsim Jamshedlower=abcdefghijklmnopqrstuvwxyz
116d270d183SAsim Jamsheddigits=0123456789
117d270d183SAsim Jamshedalpha=${upper}${lower}
11876404edcSAsim Jamshed
11976404edcSAsim Jamshedif test -z "$depmode" || test -z "$source" || test -z "$object"; then
12076404edcSAsim Jamshed  echo "depcomp: Variables source, object and depmode must be set" 1>&2
12176404edcSAsim Jamshed  exit 1
12276404edcSAsim Jamshedfi
12376404edcSAsim Jamshed
12476404edcSAsim Jamshed# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
12576404edcSAsim Jamsheddepfile=${depfile-`echo "$object" |
12676404edcSAsim Jamshed  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
12776404edcSAsim Jamshedtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
12876404edcSAsim Jamshed
12976404edcSAsim Jamshedrm -f "$tmpdepfile"
13076404edcSAsim Jamshed
131d270d183SAsim Jamshed# Avoid interferences from the environment.
132d270d183SAsim Jamshedgccflag= dashmflag=
133d270d183SAsim Jamshed
13476404edcSAsim Jamshed# Some modes work just like other modes, but use different flags.  We
13576404edcSAsim Jamshed# parameterize here, but still list the modes in the big case below,
13676404edcSAsim Jamshed# to make depend.m4 easier to write.  Note that we *cannot* use a case
13776404edcSAsim Jamshed# here, because this file can only contain one case statement.
13876404edcSAsim Jamshedif test "$depmode" = hp; then
13976404edcSAsim Jamshed  # HP compiler uses -M and no extra arg.
14076404edcSAsim Jamshed  gccflag=-M
14176404edcSAsim Jamshed  depmode=gcc
14276404edcSAsim Jamshedfi
14376404edcSAsim Jamshed
14476404edcSAsim Jamshedif test "$depmode" = dashXmstdout; then
14576404edcSAsim Jamshed  # This is just like dashmstdout with a different argument.
14676404edcSAsim Jamshed  dashmflag=-xM
14776404edcSAsim Jamshed  depmode=dashmstdout
14876404edcSAsim Jamshedfi
14976404edcSAsim Jamshed
15076404edcSAsim Jamshedcygpath_u="cygpath -u -f -"
15176404edcSAsim Jamshedif test "$depmode" = msvcmsys; then
15276404edcSAsim Jamshed  # This is just like msvisualcpp but w/o cygpath translation.
15376404edcSAsim Jamshed  # Just convert the backslash-escaped backslashes to single forward
15476404edcSAsim Jamshed  # slashes to satisfy depend.m4
15576404edcSAsim Jamshed  cygpath_u='sed s,\\\\,/,g'
15676404edcSAsim Jamshed  depmode=msvisualcpp
15776404edcSAsim Jamshedfi
15876404edcSAsim Jamshed
15976404edcSAsim Jamshedif test "$depmode" = msvc7msys; then
16076404edcSAsim Jamshed  # This is just like msvc7 but w/o cygpath translation.
16176404edcSAsim Jamshed  # Just convert the backslash-escaped backslashes to single forward
16276404edcSAsim Jamshed  # slashes to satisfy depend.m4
16376404edcSAsim Jamshed  cygpath_u='sed s,\\\\,/,g'
16476404edcSAsim Jamshed  depmode=msvc7
16576404edcSAsim Jamshedfi
16676404edcSAsim Jamshed
16776404edcSAsim Jamshedif test "$depmode" = xlc; then
168d270d183SAsim Jamshed  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
16976404edcSAsim Jamshed  gccflag=-qmakedep=gcc,-MF
17076404edcSAsim Jamshed  depmode=gcc
17176404edcSAsim Jamshedfi
17276404edcSAsim Jamshed
17376404edcSAsim Jamshedcase "$depmode" in
17476404edcSAsim Jamshedgcc3)
17576404edcSAsim Jamshed## gcc 3 implements dependency tracking that does exactly what
17676404edcSAsim Jamshed## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
17776404edcSAsim Jamshed## it if -MD -MP comes after the -MF stuff.  Hmm.
17876404edcSAsim Jamshed## Unfortunately, FreeBSD c89 acceptance of flags depends upon
17976404edcSAsim Jamshed## the command line argument order; so add the flags where they
18076404edcSAsim Jamshed## appear in depend2.am.  Note that the slowdown incurred here
18176404edcSAsim Jamshed## affects only configure: in makefiles, %FASTDEP% shortcuts this.
18276404edcSAsim Jamshed  for arg
18376404edcSAsim Jamshed  do
18476404edcSAsim Jamshed    case $arg in
18576404edcSAsim Jamshed    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
18676404edcSAsim Jamshed    *)  set fnord "$@" "$arg" ;;
18776404edcSAsim Jamshed    esac
18876404edcSAsim Jamshed    shift # fnord
18976404edcSAsim Jamshed    shift # $arg
19076404edcSAsim Jamshed  done
19176404edcSAsim Jamshed  "$@"
19276404edcSAsim Jamshed  stat=$?
193d270d183SAsim Jamshed  if test $stat -ne 0; then
19476404edcSAsim Jamshed    rm -f "$tmpdepfile"
19576404edcSAsim Jamshed    exit $stat
19676404edcSAsim Jamshed  fi
19776404edcSAsim Jamshed  mv "$tmpdepfile" "$depfile"
19876404edcSAsim Jamshed  ;;
19976404edcSAsim Jamshed
20076404edcSAsim Jamshedgcc)
201d270d183SAsim Jamshed## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
202d270d183SAsim Jamshed## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
203d270d183SAsim Jamshed## (see the conditional assignment to $gccflag above).
20476404edcSAsim Jamshed## There are various ways to get dependency output from gcc.  Here's
20576404edcSAsim Jamshed## why we pick this rather obscure method:
20676404edcSAsim Jamshed## - Don't want to use -MD because we'd like the dependencies to end
20776404edcSAsim Jamshed##   up in a subdir.  Having to rename by hand is ugly.
20876404edcSAsim Jamshed##   (We might end up doing this anyway to support other compilers.)
20976404edcSAsim Jamshed## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
210d270d183SAsim Jamshed##   -MM, not -M (despite what the docs say).  Also, it might not be
211d270d183SAsim Jamshed##   supported by the other compilers which use the 'gcc' depmode.
21276404edcSAsim Jamshed## - Using -M directly means running the compiler twice (even worse
21376404edcSAsim Jamshed##   than renaming).
21476404edcSAsim Jamshed  if test -z "$gccflag"; then
21576404edcSAsim Jamshed    gccflag=-MD,
21676404edcSAsim Jamshed  fi
21776404edcSAsim Jamshed  "$@" -Wp,"$gccflag$tmpdepfile"
21876404edcSAsim Jamshed  stat=$?
219d270d183SAsim Jamshed  if test $stat -ne 0; then
22076404edcSAsim Jamshed    rm -f "$tmpdepfile"
22176404edcSAsim Jamshed    exit $stat
22276404edcSAsim Jamshed  fi
22376404edcSAsim Jamshed  rm -f "$depfile"
22476404edcSAsim Jamshed  echo "$object : \\" > "$depfile"
225d270d183SAsim Jamshed  # The second -e expression handles DOS-style file names with drive
226d270d183SAsim Jamshed  # letters.
22776404edcSAsim Jamshed  sed -e 's/^[^:]*: / /' \
22876404edcSAsim Jamshed      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
22976404edcSAsim Jamshed## This next piece of magic avoids the "deleted header file" problem.
23076404edcSAsim Jamshed## The problem is that when a header file which appears in a .P file
23176404edcSAsim Jamshed## is deleted, the dependency causes make to die (because there is
23276404edcSAsim Jamshed## typically no way to rebuild the header).  We avoid this by adding
23376404edcSAsim Jamshed## dummy dependencies for each header file.  Too bad gcc doesn't do
23476404edcSAsim Jamshed## this for us directly.
23576404edcSAsim Jamshed## Some versions of gcc put a space before the ':'.  On the theory
23676404edcSAsim Jamshed## that the space means something, we add a space to the output as
23776404edcSAsim Jamshed## well.  hp depmode also adds that space, but also prefixes the VPATH
23876404edcSAsim Jamshed## to the object.  Take care to not repeat it in the output.
23976404edcSAsim Jamshed## Some versions of the HPUX 10.20 sed can't process this invocation
24076404edcSAsim Jamshed## correctly.  Breaking it into two sed invocations is a workaround.
241d270d183SAsim Jamshed  tr ' ' "$nl" < "$tmpdepfile" \
242d270d183SAsim Jamshed    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
24376404edcSAsim Jamshed    | sed -e 's/$/ :/' >> "$depfile"
24476404edcSAsim Jamshed  rm -f "$tmpdepfile"
24576404edcSAsim Jamshed  ;;
24676404edcSAsim Jamshed
24776404edcSAsim Jamshedhp)
24876404edcSAsim Jamshed  # This case exists only to let depend.m4 do its work.  It works by
24976404edcSAsim Jamshed  # looking at the text of this script.  This case will never be run,
25076404edcSAsim Jamshed  # since it is checked for above.
25176404edcSAsim Jamshed  exit 1
25276404edcSAsim Jamshed  ;;
25376404edcSAsim Jamshed
25476404edcSAsim Jamshedsgi)
25576404edcSAsim Jamshed  if test "$libtool" = yes; then
25676404edcSAsim Jamshed    "$@" "-Wp,-MDupdate,$tmpdepfile"
25776404edcSAsim Jamshed  else
25876404edcSAsim Jamshed    "$@" -MDupdate "$tmpdepfile"
25976404edcSAsim Jamshed  fi
26076404edcSAsim Jamshed  stat=$?
261d270d183SAsim Jamshed  if test $stat -ne 0; then
26276404edcSAsim Jamshed    rm -f "$tmpdepfile"
26376404edcSAsim Jamshed    exit $stat
26476404edcSAsim Jamshed  fi
26576404edcSAsim Jamshed  rm -f "$depfile"
26676404edcSAsim Jamshed
26776404edcSAsim Jamshed  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
26876404edcSAsim Jamshed    echo "$object : \\" > "$depfile"
26976404edcSAsim Jamshed    # Clip off the initial element (the dependent).  Don't try to be
27076404edcSAsim Jamshed    # clever and replace this with sed code, as IRIX sed won't handle
27176404edcSAsim Jamshed    # lines with more than a fixed number of characters (4096 in
27276404edcSAsim Jamshed    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
27376404edcSAsim Jamshed    # the IRIX cc adds comments like '#:fec' to the end of the
27476404edcSAsim Jamshed    # dependency line.
27576404edcSAsim Jamshed    tr ' ' "$nl" < "$tmpdepfile" \
276d270d183SAsim Jamshed      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
277d270d183SAsim Jamshed      | tr "$nl" ' ' >> "$depfile"
27876404edcSAsim Jamshed    echo >> "$depfile"
27976404edcSAsim Jamshed    # The second pass generates a dummy entry for each header file.
28076404edcSAsim Jamshed    tr ' ' "$nl" < "$tmpdepfile" \
28176404edcSAsim Jamshed      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
28276404edcSAsim Jamshed      >> "$depfile"
28376404edcSAsim Jamshed  else
284d270d183SAsim Jamshed    make_dummy_depfile
28576404edcSAsim Jamshed  fi
28676404edcSAsim Jamshed  rm -f "$tmpdepfile"
28776404edcSAsim Jamshed  ;;
28876404edcSAsim Jamshed
28976404edcSAsim Jamshedxlc)
29076404edcSAsim Jamshed  # This case exists only to let depend.m4 do its work.  It works by
29176404edcSAsim Jamshed  # looking at the text of this script.  This case will never be run,
29276404edcSAsim Jamshed  # since it is checked for above.
29376404edcSAsim Jamshed  exit 1
29476404edcSAsim Jamshed  ;;
29576404edcSAsim Jamshed
29676404edcSAsim Jamshedaix)
29776404edcSAsim Jamshed  # The C for AIX Compiler uses -M and outputs the dependencies
29876404edcSAsim Jamshed  # in a .u file.  In older versions, this file always lives in the
29976404edcSAsim Jamshed  # current directory.  Also, the AIX compiler puts '$object:' at the
30076404edcSAsim Jamshed  # start of each line; $object doesn't have directory information.
30176404edcSAsim Jamshed  # Version 6 uses the directory in both cases.
302d270d183SAsim Jamshed  set_dir_from "$object"
303d270d183SAsim Jamshed  set_base_from "$object"
30476404edcSAsim Jamshed  if test "$libtool" = yes; then
30576404edcSAsim Jamshed    tmpdepfile1=$dir$base.u
30676404edcSAsim Jamshed    tmpdepfile2=$base.u
30776404edcSAsim Jamshed    tmpdepfile3=$dir.libs/$base.u
30876404edcSAsim Jamshed    "$@" -Wc,-M
30976404edcSAsim Jamshed  else
31076404edcSAsim Jamshed    tmpdepfile1=$dir$base.u
31176404edcSAsim Jamshed    tmpdepfile2=$dir$base.u
31276404edcSAsim Jamshed    tmpdepfile3=$dir$base.u
31376404edcSAsim Jamshed    "$@" -M
31476404edcSAsim Jamshed  fi
31576404edcSAsim Jamshed  stat=$?
316d270d183SAsim Jamshed  if test $stat -ne 0; then
31776404edcSAsim Jamshed    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
31876404edcSAsim Jamshed    exit $stat
31976404edcSAsim Jamshed  fi
32076404edcSAsim Jamshed
32176404edcSAsim Jamshed  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
32276404edcSAsim Jamshed  do
32376404edcSAsim Jamshed    test -f "$tmpdepfile" && break
32476404edcSAsim Jamshed  done
325d270d183SAsim Jamshed  aix_post_process_depfile
326d270d183SAsim Jamshed  ;;
327d270d183SAsim Jamshed
328d270d183SAsim Jamshedtcc)
329d270d183SAsim Jamshed  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
330d270d183SAsim Jamshed  # FIXME: That version still under development at the moment of writing.
331d270d183SAsim Jamshed  #        Make that this statement remains true also for stable, released
332d270d183SAsim Jamshed  #        versions.
333d270d183SAsim Jamshed  # It will wrap lines (doesn't matter whether long or short) with a
334d270d183SAsim Jamshed  # trailing '\', as in:
335d270d183SAsim Jamshed  #
336d270d183SAsim Jamshed  #   foo.o : \
337d270d183SAsim Jamshed  #    foo.c \
338d270d183SAsim Jamshed  #    foo.h \
339d270d183SAsim Jamshed  #
340d270d183SAsim Jamshed  # It will put a trailing '\' even on the last line, and will use leading
341d270d183SAsim Jamshed  # spaces rather than leading tabs (at least since its commit 0394caf7
342d270d183SAsim Jamshed  # "Emit spaces for -MD").
343d270d183SAsim Jamshed  "$@" -MD -MF "$tmpdepfile"
344d270d183SAsim Jamshed  stat=$?
345d270d183SAsim Jamshed  if test $stat -ne 0; then
346d270d183SAsim Jamshed    rm -f "$tmpdepfile"
347d270d183SAsim Jamshed    exit $stat
34876404edcSAsim Jamshed  fi
349d270d183SAsim Jamshed  rm -f "$depfile"
350d270d183SAsim Jamshed  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
351d270d183SAsim Jamshed  # We have to change lines of the first kind to '$object: \'.
352d270d183SAsim Jamshed  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
353d270d183SAsim Jamshed  # And for each line of the second kind, we have to emit a 'dep.h:'
354d270d183SAsim Jamshed  # dummy dependency, to avoid the deleted-header problem.
355d270d183SAsim Jamshed  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
35676404edcSAsim Jamshed  rm -f "$tmpdepfile"
35776404edcSAsim Jamshed  ;;
35876404edcSAsim Jamshed
359d270d183SAsim Jamshed## The order of this option in the case statement is important, since the
360d270d183SAsim Jamshed## shell code in configure will try each of these formats in the order
361d270d183SAsim Jamshed## listed in this file.  A plain '-MD' option would be understood by many
362d270d183SAsim Jamshed## compilers, so we must ensure this comes after the gcc and icc options.
363d270d183SAsim Jamshedpgcc)
364d270d183SAsim Jamshed  # Portland's C compiler understands '-MD'.
365d270d183SAsim Jamshed  # Will always output deps to 'file.d' where file is the root name of the
366d270d183SAsim Jamshed  # source file under compilation, even if file resides in a subdirectory.
367d270d183SAsim Jamshed  # The object file name does not affect the name of the '.d' file.
368d270d183SAsim Jamshed  # pgcc 10.2 will output
36976404edcSAsim Jamshed  #    foo.o: sub/foo.c sub/foo.h
37076404edcSAsim Jamshed  # and will wrap long lines using '\' :
37176404edcSAsim Jamshed  #    foo.o: sub/foo.c ... \
37276404edcSAsim Jamshed  #     sub/foo.h ... \
37376404edcSAsim Jamshed  #     ...
374d270d183SAsim Jamshed  set_dir_from "$object"
375d270d183SAsim Jamshed  # Use the source, not the object, to determine the base name, since
376d270d183SAsim Jamshed  # that's sadly what pgcc will do too.
377d270d183SAsim Jamshed  set_base_from "$source"
378d270d183SAsim Jamshed  tmpdepfile=$base.d
379d270d183SAsim Jamshed
380d270d183SAsim Jamshed  # For projects that build the same source file twice into different object
381d270d183SAsim Jamshed  # files, the pgcc approach of using the *source* file root name can cause
382d270d183SAsim Jamshed  # problems in parallel builds.  Use a locking strategy to avoid stomping on
383d270d183SAsim Jamshed  # the same $tmpdepfile.
384d270d183SAsim Jamshed  lockdir=$base.d-lock
385d270d183SAsim Jamshed  trap "
386d270d183SAsim Jamshed    echo '$0: caught signal, cleaning up...' >&2
387d270d183SAsim Jamshed    rmdir '$lockdir'
388d270d183SAsim Jamshed    exit 1
389d270d183SAsim Jamshed  " 1 2 13 15
390d270d183SAsim Jamshed  numtries=100
391d270d183SAsim Jamshed  i=$numtries
392d270d183SAsim Jamshed  while test $i -gt 0; do
393d270d183SAsim Jamshed    # mkdir is a portable test-and-set.
394d270d183SAsim Jamshed    if mkdir "$lockdir" 2>/dev/null; then
395d270d183SAsim Jamshed      # This process acquired the lock.
396d270d183SAsim Jamshed      "$@" -MD
39776404edcSAsim Jamshed      stat=$?
398d270d183SAsim Jamshed      # Release the lock.
399d270d183SAsim Jamshed      rmdir "$lockdir"
400d270d183SAsim Jamshed      break
40176404edcSAsim Jamshed    else
402d270d183SAsim Jamshed      # If the lock is being held by a different process, wait
403d270d183SAsim Jamshed      # until the winning process is done or we timeout.
404d270d183SAsim Jamshed      while test -d "$lockdir" && test $i -gt 0; do
405d270d183SAsim Jamshed        sleep 1
406d270d183SAsim Jamshed        i=`expr $i - 1`
407d270d183SAsim Jamshed      done
408d270d183SAsim Jamshed    fi
409d270d183SAsim Jamshed    i=`expr $i - 1`
410d270d183SAsim Jamshed  done
411d270d183SAsim Jamshed  trap - 1 2 13 15
412d270d183SAsim Jamshed  if test $i -le 0; then
413d270d183SAsim Jamshed    echo "$0: failed to acquire lock after $numtries attempts" >&2
414d270d183SAsim Jamshed    echo "$0: check lockdir '$lockdir'" >&2
415d270d183SAsim Jamshed    exit 1
416d270d183SAsim Jamshed  fi
417d270d183SAsim Jamshed
418d270d183SAsim Jamshed  if test $stat -ne 0; then
41976404edcSAsim Jamshed    rm -f "$tmpdepfile"
42076404edcSAsim Jamshed    exit $stat
42176404edcSAsim Jamshed  fi
42276404edcSAsim Jamshed  rm -f "$depfile"
423d270d183SAsim Jamshed  # Each line is of the form `foo.o: dependent.h',
424d270d183SAsim Jamshed  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
42576404edcSAsim Jamshed  # Do two passes, one to just change these to
426d270d183SAsim Jamshed  # `$object: dependent.h' and one to simply `dependent.h:'.
427d270d183SAsim Jamshed  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
428d270d183SAsim Jamshed  # Some versions of the HPUX 10.20 sed can't process this invocation
429d270d183SAsim Jamshed  # correctly.  Breaking it into two sed invocations is a workaround.
430d270d183SAsim Jamshed  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
431d270d183SAsim Jamshed    | sed -e 's/$/ :/' >> "$depfile"
43276404edcSAsim Jamshed  rm -f "$tmpdepfile"
43376404edcSAsim Jamshed  ;;
43476404edcSAsim Jamshed
43576404edcSAsim Jamshedhp2)
43676404edcSAsim Jamshed  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
43776404edcSAsim Jamshed  # compilers, which have integrated preprocessors.  The correct option
43876404edcSAsim Jamshed  # to use with these is +Maked; it writes dependencies to a file named
43976404edcSAsim Jamshed  # 'foo.d', which lands next to the object file, wherever that
44076404edcSAsim Jamshed  # happens to be.
44176404edcSAsim Jamshed  # Much of this is similar to the tru64 case; see comments there.
442d270d183SAsim Jamshed  set_dir_from  "$object"
443d270d183SAsim Jamshed  set_base_from "$object"
44476404edcSAsim Jamshed  if test "$libtool" = yes; then
44576404edcSAsim Jamshed    tmpdepfile1=$dir$base.d
44676404edcSAsim Jamshed    tmpdepfile2=$dir.libs/$base.d
44776404edcSAsim Jamshed    "$@" -Wc,+Maked
44876404edcSAsim Jamshed  else
44976404edcSAsim Jamshed    tmpdepfile1=$dir$base.d
45076404edcSAsim Jamshed    tmpdepfile2=$dir$base.d
45176404edcSAsim Jamshed    "$@" +Maked
45276404edcSAsim Jamshed  fi
45376404edcSAsim Jamshed  stat=$?
454d270d183SAsim Jamshed  if test $stat -ne 0; then
45576404edcSAsim Jamshed     rm -f "$tmpdepfile1" "$tmpdepfile2"
45676404edcSAsim Jamshed     exit $stat
45776404edcSAsim Jamshed  fi
45876404edcSAsim Jamshed
45976404edcSAsim Jamshed  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
46076404edcSAsim Jamshed  do
46176404edcSAsim Jamshed    test -f "$tmpdepfile" && break
46276404edcSAsim Jamshed  done
46376404edcSAsim Jamshed  if test -f "$tmpdepfile"; then
464d270d183SAsim Jamshed    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
46576404edcSAsim Jamshed    # Add 'dependent.h:' lines.
46676404edcSAsim Jamshed    sed -ne '2,${
46776404edcSAsim Jamshed               s/^ *//
46876404edcSAsim Jamshed               s/ \\*$//
46976404edcSAsim Jamshed               s/$/:/
47076404edcSAsim Jamshed               p
47176404edcSAsim Jamshed             }' "$tmpdepfile" >> "$depfile"
47276404edcSAsim Jamshed  else
473d270d183SAsim Jamshed    make_dummy_depfile
47476404edcSAsim Jamshed  fi
47576404edcSAsim Jamshed  rm -f "$tmpdepfile" "$tmpdepfile2"
47676404edcSAsim Jamshed  ;;
47776404edcSAsim Jamshed
47876404edcSAsim Jamshedtru64)
47976404edcSAsim Jamshed  # The Tru64 compiler uses -MD to generate dependencies as a side
48076404edcSAsim Jamshed  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
48176404edcSAsim Jamshed  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
48276404edcSAsim Jamshed  # dependencies in 'foo.d' instead, so we check for that too.
48376404edcSAsim Jamshed  # Subdirectories are respected.
484d270d183SAsim Jamshed  set_dir_from  "$object"
485d270d183SAsim Jamshed  set_base_from "$object"
48676404edcSAsim Jamshed
48776404edcSAsim Jamshed  if test "$libtool" = yes; then
488d270d183SAsim Jamshed    # Libtool generates 2 separate objects for the 2 libraries.  These
489d270d183SAsim Jamshed    # two compilations output dependencies in $dir.libs/$base.o.d and
49076404edcSAsim Jamshed    # in $dir$base.o.d.  We have to check for both files, because
49176404edcSAsim Jamshed    # one of the two compilations can be disabled.  We should prefer
49276404edcSAsim Jamshed    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
49376404edcSAsim Jamshed    # automatically cleaned when .libs/ is deleted, while ignoring
49476404edcSAsim Jamshed    # the former would cause a distcleancheck panic.
495d270d183SAsim Jamshed    tmpdepfile1=$dir$base.o.d          # libtool 1.5
496d270d183SAsim Jamshed    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
497d270d183SAsim Jamshed    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
49876404edcSAsim Jamshed    "$@" -Wc,-MD
49976404edcSAsim Jamshed  else
500d270d183SAsim Jamshed    tmpdepfile1=$dir$base.d
50176404edcSAsim Jamshed    tmpdepfile2=$dir$base.d
50276404edcSAsim Jamshed    tmpdepfile3=$dir$base.d
50376404edcSAsim Jamshed    "$@" -MD
50476404edcSAsim Jamshed  fi
50576404edcSAsim Jamshed
50676404edcSAsim Jamshed  stat=$?
507d270d183SAsim Jamshed  if test $stat -ne 0; then
508d270d183SAsim Jamshed    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
50976404edcSAsim Jamshed    exit $stat
51076404edcSAsim Jamshed  fi
51176404edcSAsim Jamshed
512d270d183SAsim Jamshed  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
51376404edcSAsim Jamshed  do
51476404edcSAsim Jamshed    test -f "$tmpdepfile" && break
51576404edcSAsim Jamshed  done
516d270d183SAsim Jamshed  # Same post-processing that is required for AIX mode.
517d270d183SAsim Jamshed  aix_post_process_depfile
51876404edcSAsim Jamshed  ;;
51976404edcSAsim Jamshed
52076404edcSAsim Jamshedmsvc7)
52176404edcSAsim Jamshed  if test "$libtool" = yes; then
52276404edcSAsim Jamshed    showIncludes=-Wc,-showIncludes
52376404edcSAsim Jamshed  else
52476404edcSAsim Jamshed    showIncludes=-showIncludes
52576404edcSAsim Jamshed  fi
52676404edcSAsim Jamshed  "$@" $showIncludes > "$tmpdepfile"
52776404edcSAsim Jamshed  stat=$?
52876404edcSAsim Jamshed  grep -v '^Note: including file: ' "$tmpdepfile"
529d270d183SAsim Jamshed  if test $stat -ne 0; then
53076404edcSAsim Jamshed    rm -f "$tmpdepfile"
53176404edcSAsim Jamshed    exit $stat
53276404edcSAsim Jamshed  fi
53376404edcSAsim Jamshed  rm -f "$depfile"
53476404edcSAsim Jamshed  echo "$object : \\" > "$depfile"
53576404edcSAsim Jamshed  # The first sed program below extracts the file names and escapes
53676404edcSAsim Jamshed  # backslashes for cygpath.  The second sed program outputs the file
53776404edcSAsim Jamshed  # name when reading, but also accumulates all include files in the
53876404edcSAsim Jamshed  # hold buffer in order to output them again at the end.  This only
53976404edcSAsim Jamshed  # works with sed implementations that can handle large buffers.
54076404edcSAsim Jamshed  sed < "$tmpdepfile" -n '
54176404edcSAsim Jamshed/^Note: including file:  *\(.*\)/ {
54276404edcSAsim Jamshed  s//\1/
54376404edcSAsim Jamshed  s/\\/\\\\/g
54476404edcSAsim Jamshed  p
54576404edcSAsim Jamshed}' | $cygpath_u | sort -u | sed -n '
54676404edcSAsim Jamsheds/ /\\ /g
54776404edcSAsim Jamsheds/\(.*\)/'"$tab"'\1 \\/p
54876404edcSAsim Jamsheds/.\(.*\) \\/\1:/
54976404edcSAsim JamshedH
55076404edcSAsim Jamshed$ {
55176404edcSAsim Jamshed  s/.*/'"$tab"'/
55276404edcSAsim Jamshed  G
55376404edcSAsim Jamshed  p
55476404edcSAsim Jamshed}' >> "$depfile"
555d270d183SAsim Jamshed  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
55676404edcSAsim Jamshed  rm -f "$tmpdepfile"
55776404edcSAsim Jamshed  ;;
55876404edcSAsim Jamshed
55976404edcSAsim Jamshedmsvc7msys)
56076404edcSAsim Jamshed  # This case exists only to let depend.m4 do its work.  It works by
56176404edcSAsim Jamshed  # looking at the text of this script.  This case will never be run,
56276404edcSAsim Jamshed  # since it is checked for above.
56376404edcSAsim Jamshed  exit 1
56476404edcSAsim Jamshed  ;;
56576404edcSAsim Jamshed
56676404edcSAsim Jamshed#nosideeffect)
56776404edcSAsim Jamshed  # This comment above is used by automake to tell side-effect
56876404edcSAsim Jamshed  # dependency tracking mechanisms from slower ones.
56976404edcSAsim Jamshed
57076404edcSAsim Jamsheddashmstdout)
57176404edcSAsim Jamshed  # Important note: in order to support this mode, a compiler *must*
57276404edcSAsim Jamshed  # always write the preprocessed file to stdout, regardless of -o.
57376404edcSAsim Jamshed  "$@" || exit $?
57476404edcSAsim Jamshed
57576404edcSAsim Jamshed  # Remove the call to Libtool.
57676404edcSAsim Jamshed  if test "$libtool" = yes; then
57776404edcSAsim Jamshed    while test "X$1" != 'X--mode=compile'; do
57876404edcSAsim Jamshed      shift
57976404edcSAsim Jamshed    done
58076404edcSAsim Jamshed    shift
58176404edcSAsim Jamshed  fi
58276404edcSAsim Jamshed
58376404edcSAsim Jamshed  # Remove '-o $object'.
58476404edcSAsim Jamshed  IFS=" "
58576404edcSAsim Jamshed  for arg
58676404edcSAsim Jamshed  do
58776404edcSAsim Jamshed    case $arg in
58876404edcSAsim Jamshed    -o)
58976404edcSAsim Jamshed      shift
59076404edcSAsim Jamshed      ;;
59176404edcSAsim Jamshed    $object)
59276404edcSAsim Jamshed      shift
59376404edcSAsim Jamshed      ;;
59476404edcSAsim Jamshed    *)
59576404edcSAsim Jamshed      set fnord "$@" "$arg"
59676404edcSAsim Jamshed      shift # fnord
59776404edcSAsim Jamshed      shift # $arg
59876404edcSAsim Jamshed      ;;
59976404edcSAsim Jamshed    esac
60076404edcSAsim Jamshed  done
60176404edcSAsim Jamshed
60276404edcSAsim Jamshed  test -z "$dashmflag" && dashmflag=-M
60376404edcSAsim Jamshed  # Require at least two characters before searching for ':'
60476404edcSAsim Jamshed  # in the target name.  This is to cope with DOS-style filenames:
60576404edcSAsim Jamshed  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
60676404edcSAsim Jamshed  "$@" $dashmflag |
607d270d183SAsim Jamshed    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
60876404edcSAsim Jamshed  rm -f "$depfile"
60976404edcSAsim Jamshed  cat < "$tmpdepfile" > "$depfile"
610d270d183SAsim Jamshed  # Some versions of the HPUX 10.20 sed can't process this sed invocation
611d270d183SAsim Jamshed  # correctly.  Breaking it into two sed invocations is a workaround.
612d270d183SAsim Jamshed  tr ' ' "$nl" < "$tmpdepfile" \
613d270d183SAsim Jamshed    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
614d270d183SAsim Jamshed    | sed -e 's/$/ :/' >> "$depfile"
61576404edcSAsim Jamshed  rm -f "$tmpdepfile"
61676404edcSAsim Jamshed  ;;
61776404edcSAsim Jamshed
61876404edcSAsim JamsheddashXmstdout)
61976404edcSAsim Jamshed  # This case only exists to satisfy depend.m4.  It is never actually
62076404edcSAsim Jamshed  # run, as this mode is specially recognized in the preamble.
62176404edcSAsim Jamshed  exit 1
62276404edcSAsim Jamshed  ;;
62376404edcSAsim Jamshed
62476404edcSAsim Jamshedmakedepend)
62576404edcSAsim Jamshed  "$@" || exit $?
62676404edcSAsim Jamshed  # Remove any Libtool call
62776404edcSAsim Jamshed  if test "$libtool" = yes; then
62876404edcSAsim Jamshed    while test "X$1" != 'X--mode=compile'; do
62976404edcSAsim Jamshed      shift
63076404edcSAsim Jamshed    done
63176404edcSAsim Jamshed    shift
63276404edcSAsim Jamshed  fi
63376404edcSAsim Jamshed  # X makedepend
63476404edcSAsim Jamshed  shift
63576404edcSAsim Jamshed  cleared=no eat=no
63676404edcSAsim Jamshed  for arg
63776404edcSAsim Jamshed  do
63876404edcSAsim Jamshed    case $cleared in
63976404edcSAsim Jamshed    no)
64076404edcSAsim Jamshed      set ""; shift
64176404edcSAsim Jamshed      cleared=yes ;;
64276404edcSAsim Jamshed    esac
64376404edcSAsim Jamshed    if test $eat = yes; then
64476404edcSAsim Jamshed      eat=no
64576404edcSAsim Jamshed      continue
64676404edcSAsim Jamshed    fi
64776404edcSAsim Jamshed    case "$arg" in
64876404edcSAsim Jamshed    -D*|-I*)
64976404edcSAsim Jamshed      set fnord "$@" "$arg"; shift ;;
65076404edcSAsim Jamshed    # Strip any option that makedepend may not understand.  Remove
65176404edcSAsim Jamshed    # the object too, otherwise makedepend will parse it as a source file.
65276404edcSAsim Jamshed    -arch)
65376404edcSAsim Jamshed      eat=yes ;;
65476404edcSAsim Jamshed    -*|$object)
65576404edcSAsim Jamshed      ;;
65676404edcSAsim Jamshed    *)
65776404edcSAsim Jamshed      set fnord "$@" "$arg"; shift ;;
65876404edcSAsim Jamshed    esac
65976404edcSAsim Jamshed  done
66076404edcSAsim Jamshed  obj_suffix=`echo "$object" | sed 's/^.*\././'`
66176404edcSAsim Jamshed  touch "$tmpdepfile"
66276404edcSAsim Jamshed  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
66376404edcSAsim Jamshed  rm -f "$depfile"
66476404edcSAsim Jamshed  # makedepend may prepend the VPATH from the source file name to the object.
66576404edcSAsim Jamshed  # No need to regex-escape $object, excess matching of '.' is harmless.
66676404edcSAsim Jamshed  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
667d270d183SAsim Jamshed  # Some versions of the HPUX 10.20 sed can't process the last invocation
668d270d183SAsim Jamshed  # correctly.  Breaking it into two sed invocations is a workaround.
669d270d183SAsim Jamshed  sed '1,2d' "$tmpdepfile" \
670d270d183SAsim Jamshed    | tr ' ' "$nl" \
671d270d183SAsim Jamshed    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
672d270d183SAsim Jamshed    | sed -e 's/$/ :/' >> "$depfile"
67376404edcSAsim Jamshed  rm -f "$tmpdepfile" "$tmpdepfile".bak
67476404edcSAsim Jamshed  ;;
67576404edcSAsim Jamshed
67676404edcSAsim Jamshedcpp)
67776404edcSAsim Jamshed  # Important note: in order to support this mode, a compiler *must*
67876404edcSAsim Jamshed  # always write the preprocessed file to stdout.
67976404edcSAsim Jamshed  "$@" || exit $?
68076404edcSAsim Jamshed
68176404edcSAsim Jamshed  # Remove the call to Libtool.
68276404edcSAsim Jamshed  if test "$libtool" = yes; then
68376404edcSAsim Jamshed    while test "X$1" != 'X--mode=compile'; do
68476404edcSAsim Jamshed      shift
68576404edcSAsim Jamshed    done
68676404edcSAsim Jamshed    shift
68776404edcSAsim Jamshed  fi
68876404edcSAsim Jamshed
68976404edcSAsim Jamshed  # Remove '-o $object'.
69076404edcSAsim Jamshed  IFS=" "
69176404edcSAsim Jamshed  for arg
69276404edcSAsim Jamshed  do
69376404edcSAsim Jamshed    case $arg in
69476404edcSAsim Jamshed    -o)
69576404edcSAsim Jamshed      shift
69676404edcSAsim Jamshed      ;;
69776404edcSAsim Jamshed    $object)
69876404edcSAsim Jamshed      shift
69976404edcSAsim Jamshed      ;;
70076404edcSAsim Jamshed    *)
70176404edcSAsim Jamshed      set fnord "$@" "$arg"
70276404edcSAsim Jamshed      shift # fnord
70376404edcSAsim Jamshed      shift # $arg
70476404edcSAsim Jamshed      ;;
70576404edcSAsim Jamshed    esac
70676404edcSAsim Jamshed  done
70776404edcSAsim Jamshed
708d270d183SAsim Jamshed  "$@" -E \
709d270d183SAsim Jamshed    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
710d270d183SAsim Jamshed             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
711d270d183SAsim Jamshed    | sed '$ s: \\$::' > "$tmpdepfile"
71276404edcSAsim Jamshed  rm -f "$depfile"
71376404edcSAsim Jamshed  echo "$object : \\" > "$depfile"
71476404edcSAsim Jamshed  cat < "$tmpdepfile" >> "$depfile"
71576404edcSAsim Jamshed  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
71676404edcSAsim Jamshed  rm -f "$tmpdepfile"
71776404edcSAsim Jamshed  ;;
71876404edcSAsim Jamshed
71976404edcSAsim Jamshedmsvisualcpp)
72076404edcSAsim Jamshed  # Important note: in order to support this mode, a compiler *must*
72176404edcSAsim Jamshed  # always write the preprocessed file to stdout.
72276404edcSAsim Jamshed  "$@" || exit $?
72376404edcSAsim Jamshed
72476404edcSAsim Jamshed  # Remove the call to Libtool.
72576404edcSAsim Jamshed  if test "$libtool" = yes; then
72676404edcSAsim Jamshed    while test "X$1" != 'X--mode=compile'; do
72776404edcSAsim Jamshed      shift
72876404edcSAsim Jamshed    done
72976404edcSAsim Jamshed    shift
73076404edcSAsim Jamshed  fi
73176404edcSAsim Jamshed
73276404edcSAsim Jamshed  IFS=" "
73376404edcSAsim Jamshed  for arg
73476404edcSAsim Jamshed  do
73576404edcSAsim Jamshed    case "$arg" in
73676404edcSAsim Jamshed    -o)
73776404edcSAsim Jamshed      shift
73876404edcSAsim Jamshed      ;;
73976404edcSAsim Jamshed    $object)
74076404edcSAsim Jamshed      shift
74176404edcSAsim Jamshed      ;;
74276404edcSAsim Jamshed    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
74376404edcSAsim Jamshed        set fnord "$@"
74476404edcSAsim Jamshed        shift
74576404edcSAsim Jamshed        shift
74676404edcSAsim Jamshed        ;;
74776404edcSAsim Jamshed    *)
74876404edcSAsim Jamshed        set fnord "$@" "$arg"
74976404edcSAsim Jamshed        shift
75076404edcSAsim Jamshed        shift
75176404edcSAsim Jamshed        ;;
75276404edcSAsim Jamshed    esac
75376404edcSAsim Jamshed  done
75476404edcSAsim Jamshed  "$@" -E 2>/dev/null |
75576404edcSAsim Jamshed  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
75676404edcSAsim Jamshed  rm -f "$depfile"
75776404edcSAsim Jamshed  echo "$object : \\" > "$depfile"
75876404edcSAsim Jamshed  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
75976404edcSAsim Jamshed  echo "$tab" >> "$depfile"
76076404edcSAsim Jamshed  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
76176404edcSAsim Jamshed  rm -f "$tmpdepfile"
76276404edcSAsim Jamshed  ;;
76376404edcSAsim Jamshed
76476404edcSAsim Jamshedmsvcmsys)
76576404edcSAsim Jamshed  # This case exists only to let depend.m4 do its work.  It works by
76676404edcSAsim Jamshed  # looking at the text of this script.  This case will never be run,
76776404edcSAsim Jamshed  # since it is checked for above.
76876404edcSAsim Jamshed  exit 1
76976404edcSAsim Jamshed  ;;
77076404edcSAsim Jamshed
77176404edcSAsim Jamshednone)
77276404edcSAsim Jamshed  exec "$@"
77376404edcSAsim Jamshed  ;;
77476404edcSAsim Jamshed
77576404edcSAsim Jamshed*)
77676404edcSAsim Jamshed  echo "Unknown depmode $depmode" 1>&2
77776404edcSAsim Jamshed  exit 1
77876404edcSAsim Jamshed  ;;
77976404edcSAsim Jamshedesac
78076404edcSAsim Jamshed
78176404edcSAsim Jamshedexit 0
78276404edcSAsim Jamshed
78376404edcSAsim Jamshed# Local Variables:
78476404edcSAsim Jamshed# mode: shell-script
78576404edcSAsim Jamshed# sh-indentation: 2
78676404edcSAsim Jamshed# eval: (add-hook 'write-file-hooks 'time-stamp)
78776404edcSAsim Jamshed# time-stamp-start: "scriptversion="
78876404edcSAsim Jamshed# time-stamp-format: "%:y-%02m-%02d.%02H"
78976404edcSAsim Jamshed# time-stamp-time-zone: "UTC"
79076404edcSAsim Jamshed# time-stamp-end: "; # UTC"
79176404edcSAsim Jamshed# End:
792