~ubuntu-branches/ubuntu/trusty/gst-libav1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to depcomp

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-13 11:39:37 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20130713113937-46ye1u0rcmfbxs7e
Tags: 1.0.8-1
New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
# depcomp - compile a program generating dependencies as side-effects
3
3
 
4
 
scriptversion=2012-07-12.20; # UTC
 
4
scriptversion=2012-03-27.16; # UTC
5
5
 
6
 
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
 
7
# 2011, 2012 Free Software Foundation, Inc.
7
8
 
8
9
# This program is free software; you can redistribute it and/or modify
9
10
# it under the terms of the GNU General Public License as published by
74
75
 
75
76
rm -f "$tmpdepfile"
76
77
 
77
 
# Avoid interferences from the environment.
78
 
gccflag= dashmflag=
79
 
 
80
78
# Some modes work just like other modes, but use different flags.  We
81
79
# parameterize here, but still list the modes in the big case below,
82
80
# to make depend.m4 easier to write.  Note that we *cannot* use a case
111
109
fi
112
110
 
113
111
if test "$depmode" = xlc; then
114
 
   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
 
112
   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
115
113
   gccflag=-qmakedep=gcc,-MF
116
114
   depmode=gcc
117
115
fi
145
143
  ;;
146
144
 
147
145
gcc)
148
 
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
149
 
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
150
 
## (see the conditional assignment to $gccflag above).
151
146
## There are various ways to get dependency output from gcc.  Here's
152
147
## why we pick this rather obscure method:
153
148
## - Don't want to use -MD because we'd like the dependencies to end
154
149
##   up in a subdir.  Having to rename by hand is ugly.
155
150
##   (We might end up doing this anyway to support other compilers.)
156
151
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
157
 
##   -MM, not -M (despite what the docs say).  Also, it might not be
158
 
##   supported by the other compilers which use the 'gcc' depmode.
 
152
##   -MM, not -M (despite what the docs say).
159
153
## - Using -M directly means running the compiler twice (even worse
160
154
##   than renaming).
161
155
  if test -z "$gccflag"; then
341
335
  rm -f "$tmpdepfile"
342
336
  ;;
343
337
 
344
 
## The order of this option in the case statement is important, since the
345
 
## shell code in configure will try each of these formats in the order
346
 
## listed in this file.  A plain '-MD' option would be understood by many
347
 
## compilers, so we must ensure this comes after the gcc and icc options.
348
 
pgcc)
349
 
  # Portland's C compiler understands '-MD'.
350
 
  # Will always output deps to 'file.d' where file is the root name of the
351
 
  # source file under compilation, even if file resides in a subdirectory.
352
 
  # The object file name does not affect the name of the '.d' file.
353
 
  # pgcc 10.2 will output
354
 
  #    foo.o: sub/foo.c sub/foo.h
355
 
  # and will wrap long lines using '\' :
356
 
  #    foo.o: sub/foo.c ... \
357
 
  #     sub/foo.h ... \
358
 
  #     ...
359
 
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
360
 
  test "x$dir" = "x$object" && dir=
361
 
  # Use the source, not the object, to determine the base name, since
362
 
  # that's sadly what pgcc will do too.
363
 
  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
364
 
  tmpdepfile="$base.d"
365
 
 
366
 
  # For projects that build the same source file twice into different object
367
 
  # files, the pgcc approach of using the *source* file root name can cause
368
 
  # problems in parallel builds.  Use a locking strategy to avoid stomping on
369
 
  # the same $tmpdepfile.
370
 
  lockdir="$base.d-lock"
371
 
  trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15
372
 
  numtries=100
373
 
  i=$numtries
374
 
  while test $i -gt 0 ; do
375
 
    # mkdir is a portable test-and-set.
376
 
    if mkdir $lockdir 2>/dev/null; then
377
 
      # This process acquired the lock.
378
 
      "$@" -MD
379
 
      stat=$?
380
 
      # Release the lock.
381
 
      rm -rf $lockdir
382
 
      break
383
 
    else
384
 
      ## the lock is being held by a different process,
385
 
      ## wait until the winning process is done or we timeout
386
 
      while test -d $lockdir && test $i -gt 0; do
387
 
        sleep 1
388
 
        i=`expr $i - 1`
389
 
      done
390
 
    fi
391
 
    i=`expr $i - 1`
392
 
  done
393
 
  trap - 1 2 13 15
394
 
  if test $i -le 0; then
395
 
    echo "$0: failed to acquire lock after $numtries attempts" >&2
396
 
    echo "$0: check lockdir '$lockdir'" >&2
397
 
    exit 1
398
 
  fi
399
 
 
400
 
  if test $stat -ne 0; then
401
 
    rm -f "$tmpdepfile"
402
 
    exit $stat
403
 
  fi
404
 
  rm -f "$depfile"
405
 
  # Each line is of the form `foo.o: dependent.h',
406
 
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
407
 
  # Do two passes, one to just change these to
408
 
  # `$object: dependent.h' and one to simply `dependent.h:'.
409
 
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
410
 
  # Some versions of the HPUX 10.20 sed can't process this invocation
411
 
  # correctly.  Breaking it into two sed invocations is a workaround.
412
 
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
413
 
    sed -e 's/$/ :/' >> "$depfile"
414
 
  rm -f "$tmpdepfile"
415
 
  ;;
416
 
 
417
338
hp2)
418
339
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
419
340
  # compilers, which have integrated preprocessors.  The correct option