File indexing completed on 2024-12-22 04:04:18

0001 #! /bin/sh
0002 # depcomp - compile a program generating dependencies as side-effects
0003 
0004 scriptversion=2018-03-07.03; # UTC
0005 
0006 # Copyright (C) 1999-2018 Free Software Foundation, Inc.
0007 
0008 # This program is free software; you can redistribute it and/or modify
0009 # it under the terms of the GNU General Public License as published by
0010 # the Free Software Foundation; either version 2, or (at your option)
0011 # any later version.
0012 
0013 # This program is distributed in the hope that it will be useful,
0014 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 # GNU General Public License for more details.
0017 
0018 # You should have received a copy of the GNU General Public License
0019 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
0020 
0021 # As a special exception to the GNU General Public License, if you
0022 # distribute this file as part of a program that contains a
0023 # configuration script generated by Autoconf, you may include it under
0024 # the same distribution terms that you use for the rest of that program.
0025 
0026 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
0027 
0028 case $1 in
0029   '')
0030     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
0031     exit 1;
0032     ;;
0033   -h | --h*)
0034     cat <<\EOF
0035 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
0036 
0037 Run PROGRAMS ARGS to compile a file, generating dependencies
0038 as side-effects.
0039 
0040 Environment variables:
0041   depmode     Dependency tracking mode.
0042   source      Source file read by 'PROGRAMS ARGS'.
0043   object      Object file output by 'PROGRAMS ARGS'.
0044   DEPDIR      directory where to store dependencies.
0045   depfile     Dependency file to output.
0046   tmpdepfile  Temporary file to use when outputting dependencies.
0047   libtool     Whether libtool is used (yes/no).
0048 
0049 Report bugs to <bug-automake@gnu.org>.
0050 EOF
0051     exit $?
0052     ;;
0053   -v | --v*)
0054     echo "depcomp $scriptversion"
0055     exit $?
0056     ;;
0057 esac
0058 
0059 # Get the directory component of the given path, and save it in the
0060 # global variables '$dir'.  Note that this directory component will
0061 # be either empty or ending with a '/' character.  This is deliberate.
0062 set_dir_from ()
0063 {
0064   case $1 in
0065     */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
0066       *) dir=;;
0067   esac
0068 }
0069 
0070 # Get the suffix-stripped basename of the given path, and save it the
0071 # global variable '$base'.
0072 set_base_from ()
0073 {
0074   base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
0075 }
0076 
0077 # If no dependency file was actually created by the compiler invocation,
0078 # we still have to create a dummy depfile, to avoid errors with the
0079 # Makefile "include basename.Plo" scheme.
0080 make_dummy_depfile ()
0081 {
0082   echo "#dummy" > "$depfile"
0083 }
0084 
0085 # Factor out some common post-processing of the generated depfile.
0086 # Requires the auxiliary global variable '$tmpdepfile' to be set.
0087 aix_post_process_depfile ()
0088 {
0089   # If the compiler actually managed to produce a dependency file,
0090   # post-process it.
0091   if test -f "$tmpdepfile"; then
0092     # Each line is of the form 'foo.o: dependency.h'.
0093     # Do two passes, one to just change these to
0094     #   $object: dependency.h
0095     # and one to simply output
0096     #   dependency.h:
0097     # which is needed to avoid the deleted-header problem.
0098     { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
0099       sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
0100     } > "$depfile"
0101     rm -f "$tmpdepfile"
0102   else
0103     make_dummy_depfile
0104   fi
0105 }
0106 
0107 # A tabulation character.
0108 tab='   '
0109 # A newline character.
0110 nl='
0111 '
0112 # Character ranges might be problematic outside the C locale.
0113 # These definitions help.
0114 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
0115 lower=abcdefghijklmnopqrstuvwxyz
0116 digits=0123456789
0117 alpha=${upper}${lower}
0118 
0119 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
0120   echo "depcomp: Variables source, object and depmode must be set" 1>&2
0121   exit 1
0122 fi
0123 
0124 # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
0125 depfile=${depfile-`echo "$object" |
0126   sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
0127 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
0128 
0129 rm -f "$tmpdepfile"
0130 
0131 # Avoid interferences from the environment.
0132 gccflag= dashmflag=
0133 
0134 # Some modes work just like other modes, but use different flags.  We
0135 # parameterize here, but still list the modes in the big case below,
0136 # to make depend.m4 easier to write.  Note that we *cannot* use a case
0137 # here, because this file can only contain one case statement.
0138 if test "$depmode" = hp; then
0139   # HP compiler uses -M and no extra arg.
0140   gccflag=-M
0141   depmode=gcc
0142 fi
0143 
0144 if test "$depmode" = dashXmstdout; then
0145   # This is just like dashmstdout with a different argument.
0146   dashmflag=-xM
0147   depmode=dashmstdout
0148 fi
0149 
0150 cygpath_u="cygpath -u -f -"
0151 if test "$depmode" = msvcmsys; then
0152   # This is just like msvisualcpp but w/o cygpath translation.
0153   # Just convert the backslash-escaped backslashes to single forward
0154   # slashes to satisfy depend.m4
0155   cygpath_u='sed s,\\\\,/,g'
0156   depmode=msvisualcpp
0157 fi
0158 
0159 if test "$depmode" = msvc7msys; then
0160   # This is just like msvc7 but w/o cygpath translation.
0161   # Just convert the backslash-escaped backslashes to single forward
0162   # slashes to satisfy depend.m4
0163   cygpath_u='sed s,\\\\,/,g'
0164   depmode=msvc7
0165 fi
0166 
0167 if test "$depmode" = xlc; then
0168   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
0169   gccflag=-qmakedep=gcc,-MF
0170   depmode=gcc
0171 fi
0172 
0173 case "$depmode" in
0174 gcc3)
0175 ## gcc 3 implements dependency tracking that does exactly what
0176 ## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
0177 ## it if -MD -MP comes after the -MF stuff.  Hmm.
0178 ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
0179 ## the command line argument order; so add the flags where they
0180 ## appear in depend2.am.  Note that the slowdown incurred here
0181 ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
0182   for arg
0183   do
0184     case $arg in
0185     -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
0186     *)  set fnord "$@" "$arg" ;;
0187     esac
0188     shift # fnord
0189     shift # $arg
0190   done
0191   "$@"
0192   stat=$?
0193   if test $stat -ne 0; then
0194     rm -f "$tmpdepfile"
0195     exit $stat
0196   fi
0197   mv "$tmpdepfile" "$depfile"
0198   ;;
0199 
0200 gcc)
0201 ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
0202 ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
0203 ## (see the conditional assignment to $gccflag above).
0204 ## There are various ways to get dependency output from gcc.  Here's
0205 ## why we pick this rather obscure method:
0206 ## - Don't want to use -MD because we'd like the dependencies to end
0207 ##   up in a subdir.  Having to rename by hand is ugly.
0208 ##   (We might end up doing this anyway to support other compilers.)
0209 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
0210 ##   -MM, not -M (despite what the docs say).  Also, it might not be
0211 ##   supported by the other compilers which use the 'gcc' depmode.
0212 ## - Using -M directly means running the compiler twice (even worse
0213 ##   than renaming).
0214   if test -z "$gccflag"; then
0215     gccflag=-MD,
0216   fi
0217   "$@" -Wp,"$gccflag$tmpdepfile"
0218   stat=$?
0219   if test $stat -ne 0; then
0220     rm -f "$tmpdepfile"
0221     exit $stat
0222   fi
0223   rm -f "$depfile"
0224   echo "$object : \\" > "$depfile"
0225   # The second -e expression handles DOS-style file names with drive
0226   # letters.
0227   sed -e 's/^[^:]*: / /' \
0228       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
0229 ## This next piece of magic avoids the "deleted header file" problem.
0230 ## The problem is that when a header file which appears in a .P file
0231 ## is deleted, the dependency causes make to die (because there is
0232 ## typically no way to rebuild the header).  We avoid this by adding
0233 ## dummy dependencies for each header file.  Too bad gcc doesn't do
0234 ## this for us directly.
0235 ## Some versions of gcc put a space before the ':'.  On the theory
0236 ## that the space means something, we add a space to the output as
0237 ## well.  hp depmode also adds that space, but also prefixes the VPATH
0238 ## to the object.  Take care to not repeat it in the output.
0239 ## Some versions of the HPUX 10.20 sed can't process this invocation
0240 ## correctly.  Breaking it into two sed invocations is a workaround.
0241   tr ' ' "$nl" < "$tmpdepfile" \
0242     | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
0243     | sed -e 's/$/ :/' >> "$depfile"
0244   rm -f "$tmpdepfile"
0245   ;;
0246 
0247 hp)
0248   # This case exists only to let depend.m4 do its work.  It works by
0249   # looking at the text of this script.  This case will never be run,
0250   # since it is checked for above.
0251   exit 1
0252   ;;
0253 
0254 sgi)
0255   if test "$libtool" = yes; then
0256     "$@" "-Wp,-MDupdate,$tmpdepfile"
0257   else
0258     "$@" -MDupdate "$tmpdepfile"
0259   fi
0260   stat=$?
0261   if test $stat -ne 0; then
0262     rm -f "$tmpdepfile"
0263     exit $stat
0264   fi
0265   rm -f "$depfile"
0266 
0267   if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
0268     echo "$object : \\" > "$depfile"
0269     # Clip off the initial element (the dependent).  Don't try to be
0270     # clever and replace this with sed code, as IRIX sed won't handle
0271     # lines with more than a fixed number of characters (4096 in
0272     # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
0273     # the IRIX cc adds comments like '#:fec' to the end of the
0274     # dependency line.
0275     tr ' ' "$nl" < "$tmpdepfile" \
0276       | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
0277       | tr "$nl" ' ' >> "$depfile"
0278     echo >> "$depfile"
0279     # The second pass generates a dummy entry for each header file.
0280     tr ' ' "$nl" < "$tmpdepfile" \
0281       | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
0282       >> "$depfile"
0283   else
0284     make_dummy_depfile
0285   fi
0286   rm -f "$tmpdepfile"
0287   ;;
0288 
0289 xlc)
0290   # This case exists only to let depend.m4 do its work.  It works by
0291   # looking at the text of this script.  This case will never be run,
0292   # since it is checked for above.
0293   exit 1
0294   ;;
0295 
0296 aix)
0297   # The C for AIX Compiler uses -M and outputs the dependencies
0298   # in a .u file.  In older versions, this file always lives in the
0299   # current directory.  Also, the AIX compiler puts '$object:' at the
0300   # start of each line; $object doesn't have directory information.
0301   # Version 6 uses the directory in both cases.
0302   set_dir_from "$object"
0303   set_base_from "$object"
0304   if test "$libtool" = yes; then
0305     tmpdepfile1=$dir$base.u
0306     tmpdepfile2=$base.u
0307     tmpdepfile3=$dir.libs/$base.u
0308     "$@" -Wc,-M
0309   else
0310     tmpdepfile1=$dir$base.u
0311     tmpdepfile2=$dir$base.u
0312     tmpdepfile3=$dir$base.u
0313     "$@" -M
0314   fi
0315   stat=$?
0316   if test $stat -ne 0; then
0317     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
0318     exit $stat
0319   fi
0320 
0321   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
0322   do
0323     test -f "$tmpdepfile" && break
0324   done
0325   aix_post_process_depfile
0326   ;;
0327 
0328 tcc)
0329   # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
0330   # FIXME: That version still under development at the moment of writing.
0331   #        Make that this statement remains true also for stable, released
0332   #        versions.
0333   # It will wrap lines (doesn't matter whether long or short) with a
0334   # trailing '\', as in:
0335   #
0336   #   foo.o : \
0337   #    foo.c \
0338   #    foo.h \
0339   #
0340   # It will put a trailing '\' even on the last line, and will use leading
0341   # spaces rather than leading tabs (at least since its commit 0394caf7
0342   # "Emit spaces for -MD").
0343   "$@" -MD -MF "$tmpdepfile"
0344   stat=$?
0345   if test $stat -ne 0; then
0346     rm -f "$tmpdepfile"
0347     exit $stat
0348   fi
0349   rm -f "$depfile"
0350   # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
0351   # We have to change lines of the first kind to '$object: \'.
0352   sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
0353   # And for each line of the second kind, we have to emit a 'dep.h:'
0354   # dummy dependency, to avoid the deleted-header problem.
0355   sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
0356   rm -f "$tmpdepfile"
0357   ;;
0358 
0359 ## The order of this option in the case statement is important, since the
0360 ## shell code in configure will try each of these formats in the order
0361 ## listed in this file.  A plain '-MD' option would be understood by many
0362 ## compilers, so we must ensure this comes after the gcc and icc options.
0363 pgcc)
0364   # Portland's C compiler understands '-MD'.
0365   # Will always output deps to 'file.d' where file is the root name of the
0366   # source file under compilation, even if file resides in a subdirectory.
0367   # The object file name does not affect the name of the '.d' file.
0368   # pgcc 10.2 will output
0369   #    foo.o: sub/foo.c sub/foo.h
0370   # and will wrap long lines using '\' :
0371   #    foo.o: sub/foo.c ... \
0372   #     sub/foo.h ... \
0373   #     ...
0374   set_dir_from "$object"
0375   # Use the source, not the object, to determine the base name, since
0376   # that's sadly what pgcc will do too.
0377   set_base_from "$source"
0378   tmpdepfile=$base.d
0379 
0380   # For projects that build the same source file twice into different object
0381   # files, the pgcc approach of using the *source* file root name can cause
0382   # problems in parallel builds.  Use a locking strategy to avoid stomping on
0383   # the same $tmpdepfile.
0384   lockdir=$base.d-lock
0385   trap "
0386     echo '$0: caught signal, cleaning up...' >&2
0387     rmdir '$lockdir'
0388     exit 1
0389   " 1 2 13 15
0390   numtries=100
0391   i=$numtries
0392   while test $i -gt 0; do
0393     # mkdir is a portable test-and-set.
0394     if mkdir "$lockdir" 2>/dev/null; then
0395       # This process acquired the lock.
0396       "$@" -MD
0397       stat=$?
0398       # Release the lock.
0399       rmdir "$lockdir"
0400       break
0401     else
0402       # If the lock is being held by a different process, wait
0403       # until the winning process is done or we timeout.
0404       while test -d "$lockdir" && test $i -gt 0; do
0405         sleep 1
0406         i=`expr $i - 1`
0407       done
0408     fi
0409     i=`expr $i - 1`
0410   done
0411   trap - 1 2 13 15
0412   if test $i -le 0; then
0413     echo "$0: failed to acquire lock after $numtries attempts" >&2
0414     echo "$0: check lockdir '$lockdir'" >&2
0415     exit 1
0416   fi
0417 
0418   if test $stat -ne 0; then
0419     rm -f "$tmpdepfile"
0420     exit $stat
0421   fi
0422   rm -f "$depfile"
0423   # Each line is of the form `foo.o: dependent.h',
0424   # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
0425   # Do two passes, one to just change these to
0426   # `$object: dependent.h' and one to simply `dependent.h:'.
0427   sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
0428   # Some versions of the HPUX 10.20 sed can't process this invocation
0429   # correctly.  Breaking it into two sed invocations is a workaround.
0430   sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
0431     | sed -e 's/$/ :/' >> "$depfile"
0432   rm -f "$tmpdepfile"
0433   ;;
0434 
0435 hp2)
0436   # The "hp" stanza above does not work with aCC (C++) and HP's ia64
0437   # compilers, which have integrated preprocessors.  The correct option
0438   # to use with these is +Maked; it writes dependencies to a file named
0439   # 'foo.d', which lands next to the object file, wherever that
0440   # happens to be.
0441   # Much of this is similar to the tru64 case; see comments there.
0442   set_dir_from  "$object"
0443   set_base_from "$object"
0444   if test "$libtool" = yes; then
0445     tmpdepfile1=$dir$base.d
0446     tmpdepfile2=$dir.libs/$base.d
0447     "$@" -Wc,+Maked
0448   else
0449     tmpdepfile1=$dir$base.d
0450     tmpdepfile2=$dir$base.d
0451     "$@" +Maked
0452   fi
0453   stat=$?
0454   if test $stat -ne 0; then
0455      rm -f "$tmpdepfile1" "$tmpdepfile2"
0456      exit $stat
0457   fi
0458 
0459   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
0460   do
0461     test -f "$tmpdepfile" && break
0462   done
0463   if test -f "$tmpdepfile"; then
0464     sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
0465     # Add 'dependent.h:' lines.
0466     sed -ne '2,${
0467                s/^ *//
0468                s/ \\*$//
0469                s/$/:/
0470                p
0471              }' "$tmpdepfile" >> "$depfile"
0472   else
0473     make_dummy_depfile
0474   fi
0475   rm -f "$tmpdepfile" "$tmpdepfile2"
0476   ;;
0477 
0478 tru64)
0479   # The Tru64 compiler uses -MD to generate dependencies as a side
0480   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
0481   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
0482   # dependencies in 'foo.d' instead, so we check for that too.
0483   # Subdirectories are respected.
0484   set_dir_from  "$object"
0485   set_base_from "$object"
0486 
0487   if test "$libtool" = yes; then
0488     # Libtool generates 2 separate objects for the 2 libraries.  These
0489     # two compilations output dependencies in $dir.libs/$base.o.d and
0490     # in $dir$base.o.d.  We have to check for both files, because
0491     # one of the two compilations can be disabled.  We should prefer
0492     # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
0493     # automatically cleaned when .libs/ is deleted, while ignoring
0494     # the former would cause a distcleancheck panic.
0495     tmpdepfile1=$dir$base.o.d          # libtool 1.5
0496     tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
0497     tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
0498     "$@" -Wc,-MD
0499   else
0500     tmpdepfile1=$dir$base.d
0501     tmpdepfile2=$dir$base.d
0502     tmpdepfile3=$dir$base.d
0503     "$@" -MD
0504   fi
0505 
0506   stat=$?
0507   if test $stat -ne 0; then
0508     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
0509     exit $stat
0510   fi
0511 
0512   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
0513   do
0514     test -f "$tmpdepfile" && break
0515   done
0516   # Same post-processing that is required for AIX mode.
0517   aix_post_process_depfile
0518   ;;
0519 
0520 msvc7)
0521   if test "$libtool" = yes; then
0522     showIncludes=-Wc,-showIncludes
0523   else
0524     showIncludes=-showIncludes
0525   fi
0526   "$@" $showIncludes > "$tmpdepfile"
0527   stat=$?
0528   grep -v '^Note: including file: ' "$tmpdepfile"
0529   if test $stat -ne 0; then
0530     rm -f "$tmpdepfile"
0531     exit $stat
0532   fi
0533   rm -f "$depfile"
0534   echo "$object : \\" > "$depfile"
0535   # The first sed program below extracts the file names and escapes
0536   # backslashes for cygpath.  The second sed program outputs the file
0537   # name when reading, but also accumulates all include files in the
0538   # hold buffer in order to output them again at the end.  This only
0539   # works with sed implementations that can handle large buffers.
0540   sed < "$tmpdepfile" -n '
0541 /^Note: including file:  *\(.*\)/ {
0542   s//\1/
0543   s/\\/\\\\/g
0544   p
0545 }' | $cygpath_u | sort -u | sed -n '
0546 s/ /\\ /g
0547 s/\(.*\)/'"$tab"'\1 \\/p
0548 s/.\(.*\) \\/\1:/
0549 H
0550 $ {
0551   s/.*/'"$tab"'/
0552   G
0553   p
0554 }' >> "$depfile"
0555   echo >> "$depfile" # make sure the fragment doesn't end with a backslash
0556   rm -f "$tmpdepfile"
0557   ;;
0558 
0559 msvc7msys)
0560   # This case exists only to let depend.m4 do its work.  It works by
0561   # looking at the text of this script.  This case will never be run,
0562   # since it is checked for above.
0563   exit 1
0564   ;;
0565 
0566 #nosideeffect)
0567   # This comment above is used by automake to tell side-effect
0568   # dependency tracking mechanisms from slower ones.
0569 
0570 dashmstdout)
0571   # Important note: in order to support this mode, a compiler *must*
0572   # always write the preprocessed file to stdout, regardless of -o.
0573   "$@" || exit $?
0574 
0575   # Remove the call to Libtool.
0576   if test "$libtool" = yes; then
0577     while test "X$1" != 'X--mode=compile'; do
0578       shift
0579     done
0580     shift
0581   fi
0582 
0583   # Remove '-o $object'.
0584   IFS=" "
0585   for arg
0586   do
0587     case $arg in
0588     -o)
0589       shift
0590       ;;
0591     $object)
0592       shift
0593       ;;
0594     *)
0595       set fnord "$@" "$arg"
0596       shift # fnord
0597       shift # $arg
0598       ;;
0599     esac
0600   done
0601 
0602   test -z "$dashmflag" && dashmflag=-M
0603   # Require at least two characters before searching for ':'
0604   # in the target name.  This is to cope with DOS-style filenames:
0605   # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
0606   "$@" $dashmflag |
0607     sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
0608   rm -f "$depfile"
0609   cat < "$tmpdepfile" > "$depfile"
0610   # Some versions of the HPUX 10.20 sed can't process this sed invocation
0611   # correctly.  Breaking it into two sed invocations is a workaround.
0612   tr ' ' "$nl" < "$tmpdepfile" \
0613     | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
0614     | sed -e 's/$/ :/' >> "$depfile"
0615   rm -f "$tmpdepfile"
0616   ;;
0617 
0618 dashXmstdout)
0619   # This case only exists to satisfy depend.m4.  It is never actually
0620   # run, as this mode is specially recognized in the preamble.
0621   exit 1
0622   ;;
0623 
0624 makedepend)
0625   "$@" || exit $?
0626   # Remove any Libtool call
0627   if test "$libtool" = yes; then
0628     while test "X$1" != 'X--mode=compile'; do
0629       shift
0630     done
0631     shift
0632   fi
0633   # X makedepend
0634   shift
0635   cleared=no eat=no
0636   for arg
0637   do
0638     case $cleared in
0639     no)
0640       set ""; shift
0641       cleared=yes ;;
0642     esac
0643     if test $eat = yes; then
0644       eat=no
0645       continue
0646     fi
0647     case "$arg" in
0648     -D*|-I*)
0649       set fnord "$@" "$arg"; shift ;;
0650     # Strip any option that makedepend may not understand.  Remove
0651     # the object too, otherwise makedepend will parse it as a source file.
0652     -arch)
0653       eat=yes ;;
0654     -*|$object)
0655       ;;
0656     *)
0657       set fnord "$@" "$arg"; shift ;;
0658     esac
0659   done
0660   obj_suffix=`echo "$object" | sed 's/^.*\././'`
0661   touch "$tmpdepfile"
0662   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
0663   rm -f "$depfile"
0664   # makedepend may prepend the VPATH from the source file name to the object.
0665   # No need to regex-escape $object, excess matching of '.' is harmless.
0666   sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
0667   # Some versions of the HPUX 10.20 sed can't process the last invocation
0668   # correctly.  Breaking it into two sed invocations is a workaround.
0669   sed '1,2d' "$tmpdepfile" \
0670     | tr ' ' "$nl" \
0671     | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
0672     | sed -e 's/$/ :/' >> "$depfile"
0673   rm -f "$tmpdepfile" "$tmpdepfile".bak
0674   ;;
0675 
0676 cpp)
0677   # Important note: in order to support this mode, a compiler *must*
0678   # always write the preprocessed file to stdout.
0679   "$@" || exit $?
0680 
0681   # Remove the call to Libtool.
0682   if test "$libtool" = yes; then
0683     while test "X$1" != 'X--mode=compile'; do
0684       shift
0685     done
0686     shift
0687   fi
0688 
0689   # Remove '-o $object'.
0690   IFS=" "
0691   for arg
0692   do
0693     case $arg in
0694     -o)
0695       shift
0696       ;;
0697     $object)
0698       shift
0699       ;;
0700     *)
0701       set fnord "$@" "$arg"
0702       shift # fnord
0703       shift # $arg
0704       ;;
0705     esac
0706   done
0707 
0708   "$@" -E \
0709     | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
0710              -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
0711     | sed '$ s: \\$::' > "$tmpdepfile"
0712   rm -f "$depfile"
0713   echo "$object : \\" > "$depfile"
0714   cat < "$tmpdepfile" >> "$depfile"
0715   sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
0716   rm -f "$tmpdepfile"
0717   ;;
0718 
0719 msvisualcpp)
0720   # Important note: in order to support this mode, a compiler *must*
0721   # always write the preprocessed file to stdout.
0722   "$@" || exit $?
0723 
0724   # Remove the call to Libtool.
0725   if test "$libtool" = yes; then
0726     while test "X$1" != 'X--mode=compile'; do
0727       shift
0728     done
0729     shift
0730   fi
0731 
0732   IFS=" "
0733   for arg
0734   do
0735     case "$arg" in
0736     -o)
0737       shift
0738       ;;
0739     $object)
0740       shift
0741       ;;
0742     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
0743         set fnord "$@"
0744         shift
0745         shift
0746         ;;
0747     *)
0748         set fnord "$@" "$arg"
0749         shift
0750         shift
0751         ;;
0752     esac
0753   done
0754   "$@" -E 2>/dev/null |
0755   sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
0756   rm -f "$depfile"
0757   echo "$object : \\" > "$depfile"
0758   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
0759   echo "$tab" >> "$depfile"
0760   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
0761   rm -f "$tmpdepfile"
0762   ;;
0763 
0764 msvcmsys)
0765   # This case exists only to let depend.m4 do its work.  It works by
0766   # looking at the text of this script.  This case will never be run,
0767   # since it is checked for above.
0768   exit 1
0769   ;;
0770 
0771 none)
0772   exec "$@"
0773   ;;
0774 
0775 *)
0776   echo "Unknown depmode $depmode" 1>&2
0777   exit 1
0778   ;;
0779 esac
0780 
0781 exit 0
0782 
0783 # Local Variables:
0784 # mode: shell-script
0785 # sh-indentation: 2
0786 # eval: (add-hook 'before-save-hook 'time-stamp)
0787 # time-stamp-start: "scriptversion="
0788 # time-stamp-format: "%:y-%02m-%02d.%02H"
0789 # time-stamp-time-zone: "UTC0"
0790 # time-stamp-end: "; # UTC"
0791 # End: