~ubuntu-branches/ubuntu/saucy/strace/saucy-proposed

« back to all changes in this revision

Viewing changes to depcomp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-05-05 10:21:37 UTC
  • mfrom: (0.1.6 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090505102137-ransgzeynrwa2yww
Tags: 4.5.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Add lpia as supported architecture

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=2007-03-29.01
 
4
scriptversion=2003-11-08.23
5
5
 
6
 
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
7
 
# Foundation, Inc.
 
6
# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
8
7
 
9
8
# This program is free software; you can redistribute it and/or modify
10
9
# it under the terms of the GNU General Public License as published by
18
17
 
19
18
# You should have received a copy of the GNU General Public License
20
19
# along with this program; if not, write to the Free Software
21
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
 
# 02110-1301, USA.
 
20
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
21
# 02111-1307, USA.
23
22
 
24
23
# As a special exception to the GNU General Public License, if you
25
24
# distribute this file as part of a program that contains a
44
43
  depmode     Dependency tracking mode.
45
44
  source      Source file read by `PROGRAMS ARGS'.
46
45
  object      Object file output by `PROGRAMS ARGS'.
47
 
  DEPDIR      directory where to store dependencies.
48
46
  depfile     Dependency file to output.
49
47
  tmpdepfile  Temporary file to use when outputing dependencies.
50
48
  libtool     Whether libtool is used (yes/no).
51
49
 
52
50
Report bugs to <bug-automake@gnu.org>.
53
51
EOF
54
 
    exit $?
 
52
    exit 0
55
53
    ;;
56
54
  -v | --v*)
57
55
    echo "depcomp $scriptversion"
58
 
    exit $?
 
56
    exit 0
59
57
    ;;
60
58
esac
61
59
 
63
61
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
64
62
  exit 1
65
63
fi
66
 
 
67
 
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
68
 
depfile=${depfile-`echo "$object" |
69
 
  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
 
64
# `libtool' can also be set to `yes' or `no'.
 
65
 
 
66
if test -z "$depfile"; then
 
67
   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
 
68
   dir=`echo "$object" | sed 's,/.*$,/,'`
 
69
   if test "$dir" = "$object"; then
 
70
      dir=
 
71
   fi
 
72
   # FIXME: should be _deps on DOS.
 
73
   depfile="$dir.deps/$base"
 
74
fi
 
75
 
70
76
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
71
77
 
72
78
rm -f "$tmpdepfile"
92
98
## gcc 3 implements dependency tracking that does exactly what
93
99
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
94
100
## it if -MD -MP comes after the -MF stuff.  Hmm.
95
 
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
96
 
## the command line argument order; so add the flags where they
97
 
## appear in depend2.am.  Note that the slowdown incurred here
98
 
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
99
 
  for arg
100
 
  do
101
 
    case $arg in
102
 
    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
103
 
    *)  set fnord "$@" "$arg" ;;
104
 
    esac
105
 
    shift # fnord
106
 
    shift # $arg
107
 
  done
108
 
  "$@"
 
101
  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
109
102
  stat=$?
110
103
  if test $stat -eq 0; then :
111
104
  else
215
208
  # current directory.  Also, the AIX compiler puts `$object:' at the
216
209
  # start of each line; $object doesn't have directory information.
217
210
  # Version 6 uses the directory in both cases.
218
 
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
219
 
  test "x$dir" = "x$object" && dir=
220
 
  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
 
211
  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
 
212
  tmpdepfile="$stripped.u"
221
213
  if test "$libtool" = yes; then
222
 
    tmpdepfile1=$dir$base.u
223
 
    tmpdepfile2=$base.u
224
 
    tmpdepfile3=$dir.libs/$base.u
225
214
    "$@" -Wc,-M
226
215
  else
227
 
    tmpdepfile1=$dir$base.u
228
 
    tmpdepfile2=$dir$base.u
229
 
    tmpdepfile3=$dir$base.u
230
216
    "$@" -M
231
217
  fi
232
218
  stat=$?
233
219
 
 
220
  if test -f "$tmpdepfile"; then :
 
221
  else
 
222
    stripped=`echo "$stripped" | sed 's,^.*/,,'`
 
223
    tmpdepfile="$stripped.u"
 
224
  fi
 
225
 
234
226
  if test $stat -eq 0; then :
235
227
  else
236
 
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
 
228
    rm -f "$tmpdepfile"
237
229
    exit $stat
238
230
  fi
239
231
 
240
 
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
241
 
  do
242
 
    test -f "$tmpdepfile" && break
243
 
  done
244
232
  if test -f "$tmpdepfile"; then
 
233
    outname="$stripped.o"
245
234
    # Each line is of the form `foo.o: dependent.h'.
246
235
    # Do two passes, one to just change these to
247
236
    # `$object: dependent.h' and one to simply `dependent.h:'.
248
 
    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
249
 
    # That's a tab and a space in the [].
250
 
    sed -e 's,^.*\.[a-z]*:[      ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
237
    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
 
238
    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
251
239
  else
252
240
    # The sourcefile does not contain any dependencies, so just
253
241
    # store a dummy comment line, to avoid errors with the Makefile
295
283
  rm -f "$tmpdepfile"
296
284
  ;;
297
285
 
298
 
hp2)
299
 
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
300
 
  # compilers, which have integrated preprocessors.  The correct option
301
 
  # to use with these is +Maked; it writes dependencies to a file named
302
 
  # 'foo.d', which lands next to the object file, wherever that
303
 
  # happens to be.
304
 
  # Much of this is similar to the tru64 case; see comments there.
305
 
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
306
 
  test "x$dir" = "x$object" && dir=
307
 
  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
308
 
  if test "$libtool" = yes; then
309
 
    tmpdepfile1=$dir$base.d
310
 
    tmpdepfile2=$dir.libs/$base.d
311
 
    "$@" -Wc,+Maked
312
 
  else
313
 
    tmpdepfile1=$dir$base.d
314
 
    tmpdepfile2=$dir$base.d
315
 
    "$@" +Maked
316
 
  fi
317
 
  stat=$?
318
 
  if test $stat -eq 0; then :
319
 
  else
320
 
     rm -f "$tmpdepfile1" "$tmpdepfile2"
321
 
     exit $stat
322
 
  fi
323
 
 
324
 
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
325
 
  do
326
 
    test -f "$tmpdepfile" && break
327
 
  done
328
 
  if test -f "$tmpdepfile"; then
329
 
    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
330
 
    # Add `dependent.h:' lines.
331
 
    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
332
 
  else
333
 
    echo "#dummy" > "$depfile"
334
 
  fi
335
 
  rm -f "$tmpdepfile" "$tmpdepfile2"
336
 
  ;;
337
 
 
338
286
tru64)
339
287
   # The Tru64 compiler uses -MD to generate dependencies as a side
340
288
   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
346
294
   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
347
295
 
348
296
   if test "$libtool" = yes; then
349
 
      # With Tru64 cc, shared objects can also be used to make a
350
 
      # static library.  This mechanism is used in libtool 1.4 series to
351
 
      # handle both shared and static libraries in a single compilation.
352
 
      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
353
 
      #
354
 
      # With libtool 1.5 this exception was removed, and libtool now
355
 
      # generates 2 separate objects for the 2 libraries.  These two
356
 
      # compilations output dependencies in $dir.libs/$base.o.d and
357
 
      # in $dir$base.o.d.  We have to check for both files, because
358
 
      # one of the two compilations can be disabled.  We should prefer
359
 
      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
360
 
      # automatically cleaned when .libs/ is deleted, while ignoring
361
 
      # the former would cause a distcleancheck panic.
362
 
      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
363
 
      tmpdepfile2=$dir$base.o.d          # libtool 1.5
364
 
      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
365
 
      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
 
297
      tmpdepfile1="$dir.libs/$base.lo.d"
 
298
      tmpdepfile2="$dir.libs/$base.d"
366
299
      "$@" -Wc,-MD
367
300
   else
368
 
      tmpdepfile1=$dir$base.o.d
369
 
      tmpdepfile2=$dir$base.d
370
 
      tmpdepfile3=$dir$base.d
371
 
      tmpdepfile4=$dir$base.d
 
301
      tmpdepfile1="$dir$base.o.d"
 
302
      tmpdepfile2="$dir$base.d"
372
303
      "$@" -MD
373
304
   fi
374
305
 
375
306
   stat=$?
376
307
   if test $stat -eq 0; then :
377
308
   else
378
 
      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
 
309
      rm -f "$tmpdepfile1" "$tmpdepfile2"
379
310
      exit $stat
380
311
   fi
381
312
 
382
 
   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
383
 
   do
384
 
     test -f "$tmpdepfile" && break
385
 
   done
 
313
   if test -f "$tmpdepfile1"; then
 
314
      tmpdepfile="$tmpdepfile1"
 
315
   else
 
316
      tmpdepfile="$tmpdepfile2"
 
317
   fi
386
318
   if test -f "$tmpdepfile"; then
387
319
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
388
320
      # That's a tab and a space in the [].
526
458
  done
527
459
 
528
460
  "$@" -E |
529
 
    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
530
 
       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
 
461
    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
531
462
    sed '$ s: \\$::' > "$tmpdepfile"
532
463
  rm -f "$depfile"
533
464
  echo "$object : \\" > "$depfile"