depcomp
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 15:02:56 +0300
changeset 596 4b70bfe18fb7
parent 285 b3f70e3d7246
child 611 b39ee38ead19
permissions -rwxr-xr-x
fix build against libpng-1.5.x versions.
slouken@285
     1
#! /bin/sh
slouken@285
     2
# depcomp - compile a program generating dependencies as side-effects
slouken@285
     3
slouken@285
     4
scriptversion=2006-10-15.18
slouken@285
     5
slouken@285
     6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
slouken@285
     7
# Foundation, Inc.
slouken@285
     8
slouken@285
     9
# This program is free software; you can redistribute it and/or modify
slouken@285
    10
# it under the terms of the GNU General Public License as published by
slouken@285
    11
# the Free Software Foundation; either version 2, or (at your option)
slouken@285
    12
# any later version.
slouken@285
    13
slouken@285
    14
# This program is distributed in the hope that it will be useful,
slouken@285
    15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@285
    16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
slouken@285
    17
# GNU General Public License for more details.
slouken@285
    18
slouken@285
    19
# You should have received a copy of the GNU General Public License
slouken@285
    20
# along with this program; if not, write to the Free Software
slouken@285
    21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
slouken@285
    22
# 02110-1301, USA.
slouken@285
    23
slouken@285
    24
# As a special exception to the GNU General Public License, if you
slouken@285
    25
# distribute this file as part of a program that contains a
slouken@285
    26
# configuration script generated by Autoconf, you may include it under
slouken@285
    27
# the same distribution terms that you use for the rest of that program.
slouken@285
    28
slouken@285
    29
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
slouken@285
    30
slouken@285
    31
case $1 in
slouken@285
    32
  '')
slouken@285
    33
     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
slouken@285
    34
     exit 1;
slouken@285
    35
     ;;
slouken@285
    36
  -h | --h*)
slouken@285
    37
    cat <<\EOF
slouken@285
    38
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
slouken@285
    39
slouken@285
    40
Run PROGRAMS ARGS to compile a file, generating dependencies
slouken@285
    41
as side-effects.
slouken@285
    42
slouken@285
    43
Environment variables:
slouken@285
    44
  depmode     Dependency tracking mode.
slouken@285
    45
  source      Source file read by `PROGRAMS ARGS'.
slouken@285
    46
  object      Object file output by `PROGRAMS ARGS'.
slouken@285
    47
  DEPDIR      directory where to store dependencies.
slouken@285
    48
  depfile     Dependency file to output.
slouken@285
    49
  tmpdepfile  Temporary file to use when outputing dependencies.
slouken@285
    50
  libtool     Whether libtool is used (yes/no).
slouken@285
    51
slouken@285
    52
Report bugs to <bug-automake@gnu.org>.
slouken@285
    53
EOF
slouken@285
    54
    exit $?
slouken@285
    55
    ;;
slouken@285
    56
  -v | --v*)
slouken@285
    57
    echo "depcomp $scriptversion"
slouken@285
    58
    exit $?
slouken@285
    59
    ;;
slouken@285
    60
esac
slouken@285
    61
slouken@285
    62
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
slouken@285
    63
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
slouken@285
    64
  exit 1
slouken@285
    65
fi
slouken@285
    66
slouken@285
    67
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
slouken@285
    68
depfile=${depfile-`echo "$object" |
slouken@285
    69
  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
slouken@285
    70
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
slouken@285
    71
slouken@285
    72
rm -f "$tmpdepfile"
slouken@285
    73
slouken@285
    74
# Some modes work just like other modes, but use different flags.  We
slouken@285
    75
# parameterize here, but still list the modes in the big case below,
slouken@285
    76
# to make depend.m4 easier to write.  Note that we *cannot* use a case
slouken@285
    77
# here, because this file can only contain one case statement.
slouken@285
    78
if test "$depmode" = hp; then
slouken@285
    79
  # HP compiler uses -M and no extra arg.
slouken@285
    80
  gccflag=-M
slouken@285
    81
  depmode=gcc
slouken@285
    82
fi
slouken@285
    83
slouken@285
    84
if test "$depmode" = dashXmstdout; then
slouken@285
    85
   # This is just like dashmstdout with a different argument.
slouken@285
    86
   dashmflag=-xM
slouken@285
    87
   depmode=dashmstdout
slouken@285
    88
fi
slouken@285
    89
slouken@285
    90
case "$depmode" in
slouken@285
    91
gcc3)
slouken@285
    92
## gcc 3 implements dependency tracking that does exactly what
slouken@285
    93
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
slouken@285
    94
## it if -MD -MP comes after the -MF stuff.  Hmm.
slouken@285
    95
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
slouken@285
    96
## the command line argument order; so add the flags where they
slouken@285
    97
## appear in depend2.am.  Note that the slowdown incurred here
slouken@285
    98
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
slouken@285
    99
  for arg
slouken@285
   100
  do
slouken@285
   101
    case $arg in
slouken@285
   102
    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
slouken@285
   103
    *)  set fnord "$@" "$arg" ;;
slouken@285
   104
    esac
slouken@285
   105
    shift # fnord
slouken@285
   106
    shift # $arg
slouken@285
   107
  done
slouken@285
   108
  "$@"
slouken@285
   109
  stat=$?
slouken@285
   110
  if test $stat -eq 0; then :
slouken@285
   111
  else
slouken@285
   112
    rm -f "$tmpdepfile"
slouken@285
   113
    exit $stat
slouken@285
   114
  fi
slouken@285
   115
  mv "$tmpdepfile" "$depfile"
slouken@285
   116
  ;;
slouken@285
   117
slouken@285
   118
gcc)
slouken@285
   119
## There are various ways to get dependency output from gcc.  Here's
slouken@285
   120
## why we pick this rather obscure method:
slouken@285
   121
## - Don't want to use -MD because we'd like the dependencies to end
slouken@285
   122
##   up in a subdir.  Having to rename by hand is ugly.
slouken@285
   123
##   (We might end up doing this anyway to support other compilers.)
slouken@285
   124
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
slouken@285
   125
##   -MM, not -M (despite what the docs say).
slouken@285
   126
## - Using -M directly means running the compiler twice (even worse
slouken@285
   127
##   than renaming).
slouken@285
   128
  if test -z "$gccflag"; then
slouken@285
   129
    gccflag=-MD,
slouken@285
   130
  fi
slouken@285
   131
  "$@" -Wp,"$gccflag$tmpdepfile"
slouken@285
   132
  stat=$?
slouken@285
   133
  if test $stat -eq 0; then :
slouken@285
   134
  else
slouken@285
   135
    rm -f "$tmpdepfile"
slouken@285
   136
    exit $stat
slouken@285
   137
  fi
slouken@285
   138
  rm -f "$depfile"
slouken@285
   139
  echo "$object : \\" > "$depfile"
slouken@285
   140
  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
slouken@285
   141
## The second -e expression handles DOS-style file names with drive letters.
slouken@285
   142
  sed -e 's/^[^:]*: / /' \
slouken@285
   143
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
slouken@285
   144
## This next piece of magic avoids the `deleted header file' problem.
slouken@285
   145
## The problem is that when a header file which appears in a .P file
slouken@285
   146
## is deleted, the dependency causes make to die (because there is
slouken@285
   147
## typically no way to rebuild the header).  We avoid this by adding
slouken@285
   148
## dummy dependencies for each header file.  Too bad gcc doesn't do
slouken@285
   149
## this for us directly.
slouken@285
   150
  tr ' ' '
slouken@285
   151
' < "$tmpdepfile" |
slouken@285
   152
## Some versions of gcc put a space before the `:'.  On the theory
slouken@285
   153
## that the space means something, we add a space to the output as
slouken@285
   154
## well.
slouken@285
   155
## Some versions of the HPUX 10.20 sed can't process this invocation
slouken@285
   156
## correctly.  Breaking it into two sed invocations is a workaround.
slouken@285
   157
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
slouken@285
   158
  rm -f "$tmpdepfile"
slouken@285
   159
  ;;
slouken@285
   160
slouken@285
   161
hp)
slouken@285
   162
  # This case exists only to let depend.m4 do its work.  It works by
slouken@285
   163
  # looking at the text of this script.  This case will never be run,
slouken@285
   164
  # since it is checked for above.
slouken@285
   165
  exit 1
slouken@285
   166
  ;;
slouken@285
   167
slouken@285
   168
sgi)
slouken@285
   169
  if test "$libtool" = yes; then
slouken@285
   170
    "$@" "-Wp,-MDupdate,$tmpdepfile"
slouken@285
   171
  else
slouken@285
   172
    "$@" -MDupdate "$tmpdepfile"
slouken@285
   173
  fi
slouken@285
   174
  stat=$?
slouken@285
   175
  if test $stat -eq 0; then :
slouken@285
   176
  else
slouken@285
   177
    rm -f "$tmpdepfile"
slouken@285
   178
    exit $stat
slouken@285
   179
  fi
slouken@285
   180
  rm -f "$depfile"
slouken@285
   181
slouken@285
   182
  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
slouken@285
   183
    echo "$object : \\" > "$depfile"
slouken@285
   184
slouken@285
   185
    # Clip off the initial element (the dependent).  Don't try to be
slouken@285
   186
    # clever and replace this with sed code, as IRIX sed won't handle
slouken@285
   187
    # lines with more than a fixed number of characters (4096 in
slouken@285
   188
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
slouken@285
   189
    # the IRIX cc adds comments like `#:fec' to the end of the
slouken@285
   190
    # dependency line.
slouken@285
   191
    tr ' ' '
slouken@285
   192
' < "$tmpdepfile" \
slouken@285
   193
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
slouken@285
   194
    tr '
slouken@285
   195
' ' ' >> $depfile
slouken@285
   196
    echo >> $depfile
slouken@285
   197
slouken@285
   198
    # The second pass generates a dummy entry for each header file.
slouken@285
   199
    tr ' ' '
slouken@285
   200
' < "$tmpdepfile" \
slouken@285
   201
   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
slouken@285
   202
   >> $depfile
slouken@285
   203
  else
slouken@285
   204
    # The sourcefile does not contain any dependencies, so just
slouken@285
   205
    # store a dummy comment line, to avoid errors with the Makefile
slouken@285
   206
    # "include basename.Plo" scheme.
slouken@285
   207
    echo "#dummy" > "$depfile"
slouken@285
   208
  fi
slouken@285
   209
  rm -f "$tmpdepfile"
slouken@285
   210
  ;;
slouken@285
   211
slouken@285
   212
aix)
slouken@285
   213
  # The C for AIX Compiler uses -M and outputs the dependencies
slouken@285
   214
  # in a .u file.  In older versions, this file always lives in the
slouken@285
   215
  # current directory.  Also, the AIX compiler puts `$object:' at the
slouken@285
   216
  # start of each line; $object doesn't have directory information.
slouken@285
   217
  # Version 6 uses the directory in both cases.
slouken@285
   218
  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
slouken@285
   219
  tmpdepfile="$stripped.u"
slouken@285
   220
  if test "$libtool" = yes; then
slouken@285
   221
    "$@" -Wc,-M
slouken@285
   222
  else
slouken@285
   223
    "$@" -M
slouken@285
   224
  fi
slouken@285
   225
  stat=$?
slouken@285
   226
slouken@285
   227
  if test -f "$tmpdepfile"; then :
slouken@285
   228
  else
slouken@285
   229
    stripped=`echo "$stripped" | sed 's,^.*/,,'`
slouken@285
   230
    tmpdepfile="$stripped.u"
slouken@285
   231
  fi
slouken@285
   232
slouken@285
   233
  if test $stat -eq 0; then :
slouken@285
   234
  else
slouken@285
   235
    rm -f "$tmpdepfile"
slouken@285
   236
    exit $stat
slouken@285
   237
  fi
slouken@285
   238
slouken@285
   239
  if test -f "$tmpdepfile"; then
slouken@285
   240
    outname="$stripped.o"
slouken@285
   241
    # Each line is of the form `foo.o: dependent.h'.
slouken@285
   242
    # Do two passes, one to just change these to
slouken@285
   243
    # `$object: dependent.h' and one to simply `dependent.h:'.
slouken@285
   244
    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
slouken@285
   245
    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
slouken@285
   246
  else
slouken@285
   247
    # The sourcefile does not contain any dependencies, so just
slouken@285
   248
    # store a dummy comment line, to avoid errors with the Makefile
slouken@285
   249
    # "include basename.Plo" scheme.
slouken@285
   250
    echo "#dummy" > "$depfile"
slouken@285
   251
  fi
slouken@285
   252
  rm -f "$tmpdepfile"
slouken@285
   253
  ;;
slouken@285
   254
slouken@285
   255
icc)
slouken@285
   256
  # Intel's C compiler understands `-MD -MF file'.  However on
slouken@285
   257
  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
slouken@285
   258
  # ICC 7.0 will fill foo.d with something like
slouken@285
   259
  #    foo.o: sub/foo.c
slouken@285
   260
  #    foo.o: sub/foo.h
slouken@285
   261
  # which is wrong.  We want:
slouken@285
   262
  #    sub/foo.o: sub/foo.c
slouken@285
   263
  #    sub/foo.o: sub/foo.h
slouken@285
   264
  #    sub/foo.c:
slouken@285
   265
  #    sub/foo.h:
slouken@285
   266
  # ICC 7.1 will output
slouken@285
   267
  #    foo.o: sub/foo.c sub/foo.h
slouken@285
   268
  # and will wrap long lines using \ :
slouken@285
   269
  #    foo.o: sub/foo.c ... \
slouken@285
   270
  #     sub/foo.h ... \
slouken@285
   271
  #     ...
slouken@285
   272
slouken@285
   273
  "$@" -MD -MF "$tmpdepfile"
slouken@285
   274
  stat=$?
slouken@285
   275
  if test $stat -eq 0; then :
slouken@285
   276
  else
slouken@285
   277
    rm -f "$tmpdepfile"
slouken@285
   278
    exit $stat
slouken@285
   279
  fi
slouken@285
   280
  rm -f "$depfile"
slouken@285
   281
  # Each line is of the form `foo.o: dependent.h',
slouken@285
   282
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
slouken@285
   283
  # Do two passes, one to just change these to
slouken@285
   284
  # `$object: dependent.h' and one to simply `dependent.h:'.
slouken@285
   285
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
slouken@285
   286
  # Some versions of the HPUX 10.20 sed can't process this invocation
slouken@285
   287
  # correctly.  Breaking it into two sed invocations is a workaround.
slouken@285
   288
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
slouken@285
   289
    sed -e 's/$/ :/' >> "$depfile"
slouken@285
   290
  rm -f "$tmpdepfile"
slouken@285
   291
  ;;
slouken@285
   292
slouken@285
   293
hp2)
slouken@285
   294
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
slouken@285
   295
  # compilers, which have integrated preprocessors.  The correct option
slouken@285
   296
  # to use with these is +Maked; it writes dependencies to a file named
slouken@285
   297
  # 'foo.d', which lands next to the object file, wherever that
slouken@285
   298
  # happens to be.
slouken@285
   299
  # Much of this is similar to the tru64 case; see comments there.
slouken@285
   300
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
slouken@285
   301
  test "x$dir" = "x$object" && dir=
slouken@285
   302
  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
slouken@285
   303
  if test "$libtool" = yes; then
slouken@285
   304
    tmpdepfile1=$dir$base.d
slouken@285
   305
    tmpdepfile2=$dir.libs/$base.d
slouken@285
   306
    "$@" -Wc,+Maked
slouken@285
   307
  else
slouken@285
   308
    tmpdepfile1=$dir$base.d
slouken@285
   309
    tmpdepfile2=$dir$base.d
slouken@285
   310
    "$@" +Maked
slouken@285
   311
  fi
slouken@285
   312
  stat=$?
slouken@285
   313
  if test $stat -eq 0; then :
slouken@285
   314
  else
slouken@285
   315
     rm -f "$tmpdepfile1" "$tmpdepfile2"
slouken@285
   316
     exit $stat
slouken@285
   317
  fi
slouken@285
   318
slouken@285
   319
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
slouken@285
   320
  do
slouken@285
   321
    test -f "$tmpdepfile" && break
slouken@285
   322
  done
slouken@285
   323
  if test -f "$tmpdepfile"; then
slouken@285
   324
    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
slouken@285
   325
    # Add `dependent.h:' lines.
slouken@285
   326
    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
slouken@285
   327
  else
slouken@285
   328
    echo "#dummy" > "$depfile"
slouken@285
   329
  fi
slouken@285
   330
  rm -f "$tmpdepfile" "$tmpdepfile2"
slouken@285
   331
  ;;
slouken@285
   332
slouken@285
   333
tru64)
slouken@285
   334
   # The Tru64 compiler uses -MD to generate dependencies as a side
slouken@285
   335
   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
slouken@285
   336
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
slouken@285
   337
   # dependencies in `foo.d' instead, so we check for that too.
slouken@285
   338
   # Subdirectories are respected.
slouken@285
   339
   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
slouken@285
   340
   test "x$dir" = "x$object" && dir=
slouken@285
   341
   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
slouken@285
   342
slouken@285
   343
   if test "$libtool" = yes; then
slouken@285
   344
      # With Tru64 cc, shared objects can also be used to make a
slouken@285
   345
      # static library.  This mechanism is used in libtool 1.4 series to
slouken@285
   346
      # handle both shared and static libraries in a single compilation.
slouken@285
   347
      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
slouken@285
   348
      #
slouken@285
   349
      # With libtool 1.5 this exception was removed, and libtool now
slouken@285
   350
      # generates 2 separate objects for the 2 libraries.  These two
slouken@285
   351
      # compilations output dependencies in $dir.libs/$base.o.d and
slouken@285
   352
      # in $dir$base.o.d.  We have to check for both files, because
slouken@285
   353
      # one of the two compilations can be disabled.  We should prefer
slouken@285
   354
      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
slouken@285
   355
      # automatically cleaned when .libs/ is deleted, while ignoring
slouken@285
   356
      # the former would cause a distcleancheck panic.
slouken@285
   357
      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
slouken@285
   358
      tmpdepfile2=$dir$base.o.d          # libtool 1.5
slouken@285
   359
      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
slouken@285
   360
      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
slouken@285
   361
      "$@" -Wc,-MD
slouken@285
   362
   else
slouken@285
   363
      tmpdepfile1=$dir$base.o.d
slouken@285
   364
      tmpdepfile2=$dir$base.d
slouken@285
   365
      tmpdepfile3=$dir$base.d
slouken@285
   366
      tmpdepfile4=$dir$base.d
slouken@285
   367
      "$@" -MD
slouken@285
   368
   fi
slouken@285
   369
slouken@285
   370
   stat=$?
slouken@285
   371
   if test $stat -eq 0; then :
slouken@285
   372
   else
slouken@285
   373
      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
slouken@285
   374
      exit $stat
slouken@285
   375
   fi
slouken@285
   376
slouken@285
   377
   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
slouken@285
   378
   do
slouken@285
   379
     test -f "$tmpdepfile" && break
slouken@285
   380
   done
slouken@285
   381
   if test -f "$tmpdepfile"; then
slouken@285
   382
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
slouken@285
   383
      # That's a tab and a space in the [].
slouken@285
   384
      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
slouken@285
   385
   else
slouken@285
   386
      echo "#dummy" > "$depfile"
slouken@285
   387
   fi
slouken@285
   388
   rm -f "$tmpdepfile"
slouken@285
   389
   ;;
slouken@285
   390
slouken@285
   391
#nosideeffect)
slouken@285
   392
  # This comment above is used by automake to tell side-effect
slouken@285
   393
  # dependency tracking mechanisms from slower ones.
slouken@285
   394
slouken@285
   395
dashmstdout)
slouken@285
   396
  # Important note: in order to support this mode, a compiler *must*
slouken@285
   397
  # always write the preprocessed file to stdout, regardless of -o.
slouken@285
   398
  "$@" || exit $?
slouken@285
   399
slouken@285
   400
  # Remove the call to Libtool.
slouken@285
   401
  if test "$libtool" = yes; then
slouken@285
   402
    while test $1 != '--mode=compile'; do
slouken@285
   403
      shift
slouken@285
   404
    done
slouken@285
   405
    shift
slouken@285
   406
  fi
slouken@285
   407
slouken@285
   408
  # Remove `-o $object'.
slouken@285
   409
  IFS=" "
slouken@285
   410
  for arg
slouken@285
   411
  do
slouken@285
   412
    case $arg in
slouken@285
   413
    -o)
slouken@285
   414
      shift
slouken@285
   415
      ;;
slouken@285
   416
    $object)
slouken@285
   417
      shift
slouken@285
   418
      ;;
slouken@285
   419
    *)
slouken@285
   420
      set fnord "$@" "$arg"
slouken@285
   421
      shift # fnord
slouken@285
   422
      shift # $arg
slouken@285
   423
      ;;
slouken@285
   424
    esac
slouken@285
   425
  done
slouken@285
   426
slouken@285
   427
  test -z "$dashmflag" && dashmflag=-M
slouken@285
   428
  # Require at least two characters before searching for `:'
slouken@285
   429
  # in the target name.  This is to cope with DOS-style filenames:
slouken@285
   430
  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
slouken@285
   431
  "$@" $dashmflag |
slouken@285
   432
    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
slouken@285
   433
  rm -f "$depfile"
slouken@285
   434
  cat < "$tmpdepfile" > "$depfile"
slouken@285
   435
  tr ' ' '
slouken@285
   436
' < "$tmpdepfile" | \
slouken@285
   437
## Some versions of the HPUX 10.20 sed can't process this invocation
slouken@285
   438
## correctly.  Breaking it into two sed invocations is a workaround.
slouken@285
   439
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
slouken@285
   440
  rm -f "$tmpdepfile"
slouken@285
   441
  ;;
slouken@285
   442
slouken@285
   443
dashXmstdout)
slouken@285
   444
  # This case only exists to satisfy depend.m4.  It is never actually
slouken@285
   445
  # run, as this mode is specially recognized in the preamble.
slouken@285
   446
  exit 1
slouken@285
   447
  ;;
slouken@285
   448
slouken@285
   449
makedepend)
slouken@285
   450
  "$@" || exit $?
slouken@285
   451
  # Remove any Libtool call
slouken@285
   452
  if test "$libtool" = yes; then
slouken@285
   453
    while test $1 != '--mode=compile'; do
slouken@285
   454
      shift
slouken@285
   455
    done
slouken@285
   456
    shift
slouken@285
   457
  fi
slouken@285
   458
  # X makedepend
slouken@285
   459
  shift
slouken@285
   460
  cleared=no
slouken@285
   461
  for arg in "$@"; do
slouken@285
   462
    case $cleared in
slouken@285
   463
    no)
slouken@285
   464
      set ""; shift
slouken@285
   465
      cleared=yes ;;
slouken@285
   466
    esac
slouken@285
   467
    case "$arg" in
slouken@285
   468
    -D*|-I*)
slouken@285
   469
      set fnord "$@" "$arg"; shift ;;
slouken@285
   470
    # Strip any option that makedepend may not understand.  Remove
slouken@285
   471
    # the object too, otherwise makedepend will parse it as a source file.
slouken@285
   472
    -*|$object)
slouken@285
   473
      ;;
slouken@285
   474
    *)
slouken@285
   475
      set fnord "$@" "$arg"; shift ;;
slouken@285
   476
    esac
slouken@285
   477
  done
slouken@285
   478
  obj_suffix="`echo $object | sed 's/^.*\././'`"
slouken@285
   479
  touch "$tmpdepfile"
slouken@285
   480
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
slouken@285
   481
  rm -f "$depfile"
slouken@285
   482
  cat < "$tmpdepfile" > "$depfile"
slouken@285
   483
  sed '1,2d' "$tmpdepfile" | tr ' ' '
slouken@285
   484
' | \
slouken@285
   485
## Some versions of the HPUX 10.20 sed can't process this invocation
slouken@285
   486
## correctly.  Breaking it into two sed invocations is a workaround.
slouken@285
   487
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
slouken@285
   488
  rm -f "$tmpdepfile" "$tmpdepfile".bak
slouken@285
   489
  ;;
slouken@285
   490
slouken@285
   491
cpp)
slouken@285
   492
  # Important note: in order to support this mode, a compiler *must*
slouken@285
   493
  # always write the preprocessed file to stdout.
slouken@285
   494
  "$@" || exit $?
slouken@285
   495
slouken@285
   496
  # Remove the call to Libtool.
slouken@285
   497
  if test "$libtool" = yes; then
slouken@285
   498
    while test $1 != '--mode=compile'; do
slouken@285
   499
      shift
slouken@285
   500
    done
slouken@285
   501
    shift
slouken@285
   502
  fi
slouken@285
   503
slouken@285
   504
  # Remove `-o $object'.
slouken@285
   505
  IFS=" "
slouken@285
   506
  for arg
slouken@285
   507
  do
slouken@285
   508
    case $arg in
slouken@285
   509
    -o)
slouken@285
   510
      shift
slouken@285
   511
      ;;
slouken@285
   512
    $object)
slouken@285
   513
      shift
slouken@285
   514
      ;;
slouken@285
   515
    *)
slouken@285
   516
      set fnord "$@" "$arg"
slouken@285
   517
      shift # fnord
slouken@285
   518
      shift # $arg
slouken@285
   519
      ;;
slouken@285
   520
    esac
slouken@285
   521
  done
slouken@285
   522
slouken@285
   523
  "$@" -E |
slouken@285
   524
    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
slouken@285
   525
       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
slouken@285
   526
    sed '$ s: \\$::' > "$tmpdepfile"
slouken@285
   527
  rm -f "$depfile"
slouken@285
   528
  echo "$object : \\" > "$depfile"
slouken@285
   529
  cat < "$tmpdepfile" >> "$depfile"
slouken@285
   530
  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
slouken@285
   531
  rm -f "$tmpdepfile"
slouken@285
   532
  ;;
slouken@285
   533
slouken@285
   534
msvisualcpp)
slouken@285
   535
  # Important note: in order to support this mode, a compiler *must*
slouken@285
   536
  # always write the preprocessed file to stdout, regardless of -o,
slouken@285
   537
  # because we must use -o when running libtool.
slouken@285
   538
  "$@" || exit $?
slouken@285
   539
  IFS=" "
slouken@285
   540
  for arg
slouken@285
   541
  do
slouken@285
   542
    case "$arg" in
slouken@285
   543
    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
slouken@285
   544
	set fnord "$@"
slouken@285
   545
	shift
slouken@285
   546
	shift
slouken@285
   547
	;;
slouken@285
   548
    *)
slouken@285
   549
	set fnord "$@" "$arg"
slouken@285
   550
	shift
slouken@285
   551
	shift
slouken@285
   552
	;;
slouken@285
   553
    esac
slouken@285
   554
  done
slouken@285
   555
  "$@" -E |
slouken@285
   556
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
slouken@285
   557
  rm -f "$depfile"
slouken@285
   558
  echo "$object : \\" > "$depfile"
slouken@285
   559
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
slouken@285
   560
  echo "	" >> "$depfile"
slouken@285
   561
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
slouken@285
   562
  rm -f "$tmpdepfile"
slouken@285
   563
  ;;
slouken@285
   564
slouken@285
   565
none)
slouken@285
   566
  exec "$@"
slouken@285
   567
  ;;
slouken@285
   568
slouken@285
   569
*)
slouken@285
   570
  echo "Unknown depmode $depmode" 1>&2
slouken@285
   571
  exit 1
slouken@285
   572
  ;;
slouken@285
   573
esac
slouken@285
   574
slouken@285
   575
exit 0
slouken@285
   576
slouken@285
   577
# Local Variables:
slouken@285
   578
# mode: shell-script
slouken@285
   579
# sh-indentation: 2
slouken@285
   580
# eval: (add-hook 'write-file-hooks 'time-stamp)
slouken@285
   581
# time-stamp-start: "scriptversion="
slouken@285
   582
# time-stamp-format: "%:y-%02m-%02d.%02H"
slouken@285
   583
# time-stamp-end: "$"
slouken@285
   584
# End: