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