~ubuntu-branches/debian/sid/mtr/sid

« back to all changes in this revision

Viewing changes to depcomp

  • Committer: Bazaar Package Importer
  • Author(s): Robert Woodcock
  • Date: 2008-09-22 07:30:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080922073021-worxo2arrx3glvtn
Tags: 0.75-2
Use rm -f in rules clean target where necessary, closes: #499789

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
 
3
3
# depcomp - compile a program generating dependencies as side-effects
4
 
# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
 
4
# Copyright 1999, 2000 Free Software Foundation, Inc.
5
5
 
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
31
31
fi
32
32
# `libtool' can also be set to `yes' or `no'.
33
33
 
34
 
if test -z "$depfile"; then
35
 
   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
36
 
   dir=`echo "$object" | sed 's,/.*$,/,'`
37
 
   if test "$dir" = "$object"; then
38
 
      dir=
39
 
   fi
40
 
   # FIXME: should be _deps on DOS.
41
 
   depfile="$dir.deps/$base"
42
 
fi
43
 
 
 
34
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
44
35
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
45
36
 
46
37
rm -f "$tmpdepfile"
172
163
 
173
164
aix)
174
165
  # The C for AIX Compiler uses -M and outputs the dependencies
175
 
  # in a .u file.  In older versions, this file always lives in the
176
 
  # current directory.  Also, the AIX compiler puts `$object:' at the
177
 
  # start of each line; $object doesn't have directory information.
178
 
  # Version 6 uses the directory in both cases.
179
 
  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
 
166
  # in a .u file.  This file always lives in the current directory.
 
167
  # Also, the AIX compiler puts `$object:' at the start of each line;
 
168
  # $object doesn't have directory information.
 
169
  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
180
170
  tmpdepfile="$stripped.u"
 
171
  outname="$stripped.o"
181
172
  if test "$libtool" = yes; then
182
173
    "$@" -Wc,-M
183
174
  else
184
175
    "$@" -M
185
176
  fi
 
177
 
186
178
  stat=$?
187
 
 
188
 
  if test -f "$tmpdepfile"; then :
189
 
  else
190
 
    stripped=`echo "$stripped" | sed 's,^.*/,,'`
191
 
    tmpdepfile="$stripped.u"
192
 
  fi
193
 
 
194
179
  if test $stat -eq 0; then :
195
180
  else
196
181
    rm -f "$tmpdepfile"
198
183
  fi
199
184
 
200
185
  if test -f "$tmpdepfile"; then
201
 
    outname="$stripped.o"
202
186
    # Each line is of the form `foo.o: dependent.h'.
203
187
    # Do two passes, one to just change these to
204
188
    # `$object: dependent.h' and one to simply `dependent.h:'.
213
197
  rm -f "$tmpdepfile"
214
198
  ;;
215
199
 
216
 
icc)
217
 
  # Intel's C compiler understands `-MD -MF file'.  However on
218
 
  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
219
 
  # ICC 7.0 will fill foo.d with something like
220
 
  #    foo.o: sub/foo.c
221
 
  #    foo.o: sub/foo.h
222
 
  # which is wrong.  We want:
223
 
  #    sub/foo.o: sub/foo.c
224
 
  #    sub/foo.o: sub/foo.h
225
 
  #    sub/foo.c:
226
 
  #    sub/foo.h:
227
 
  # ICC 7.1 will output
228
 
  #    foo.o: sub/foo.c sub/foo.h
229
 
  # and will wrap long lines using \ :
230
 
  #    foo.o: sub/foo.c ... \
231
 
  #     sub/foo.h ... \
232
 
  #     ...
233
 
 
234
 
  "$@" -MD -MF "$tmpdepfile"
235
 
  stat=$?
236
 
  if test $stat -eq 0; then :
237
 
  else
238
 
    rm -f "$tmpdepfile"
239
 
    exit $stat
240
 
  fi
241
 
  rm -f "$depfile"
242
 
  # Each line is of the form `foo.o: dependent.h',
243
 
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
244
 
  # Do two passes, one to just change these to
245
 
  # `$object: dependent.h' and one to simply `dependent.h:'.
246
 
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
247
 
  # Some versions of the HPUX 10.20 sed can't process this invocation
248
 
  # correctly.  Breaking it into two sed invocations is a workaround.
249
 
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
250
 
    sed -e 's/$/ :/' >> "$depfile"
251
 
  rm -f "$tmpdepfile"
252
 
  ;;
253
 
 
254
200
tru64)
255
 
   # The Tru64 compiler uses -MD to generate dependencies as a side
 
201
   # The Tru64 AIX compiler uses -MD to generate dependencies as a side
256
202
   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
257
 
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
 
203
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 
258
204
   # dependencies in `foo.d' instead, so we check for that too.
259
205
   # Subdirectories are respected.
260
 
   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
261
 
   test "x$dir" = "x$object" && dir=
262
 
   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
263
206
 
 
207
   tmpdepfile1="$object.d"
 
208
   tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` 
264
209
   if test "$libtool" = yes; then
265
 
      tmpdepfile1="$dir.libs/$base.lo.d"
266
 
      tmpdepfile2="$dir.libs/$base.d"
267
210
      "$@" -Wc,-MD
268
211
   else
269
 
      tmpdepfile1="$dir$base.o.d"
270
 
      tmpdepfile2="$dir$base.d"
271
212
      "$@" -MD
272
213
   fi
273
214
 
285
226
   fi
286
227
   if test -f "$tmpdepfile"; then
287
228
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
288
 
      # That's a tab and a space in the [].
289
 
      sed -e 's,^.*\.[a-z]*:[    ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
229
      # That's a space and a tab in the [].
 
230
      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
290
231
   else
291
232
      echo "#dummy" > "$depfile"
292
233
   fi
299
240
 
300
241
dashmstdout)
301
242
  # Important note: in order to support this mode, a compiler *must*
302
 
  # always write the preprocessed file to stdout, regardless of -o.
303
 
  "$@" || exit $?
304
 
 
305
 
  # Remove the call to Libtool.
306
 
  if test "$libtool" = yes; then
307
 
    while test $1 != '--mode=compile'; do
308
 
      shift
309
 
    done
310
 
    shift
311
 
  fi
312
 
 
313
 
  # Remove `-o $object'.
314
 
  IFS=" "
315
 
  for arg
316
 
  do
317
 
    case $arg in
318
 
    -o)
319
 
      shift
320
 
      ;;
321
 
    $object)
322
 
      shift
323
 
      ;;
324
 
    *)
325
 
      set fnord "$@" "$arg"
326
 
      shift # fnord
327
 
      shift # $arg
328
 
      ;;
329
 
    esac
330
 
  done
331
 
 
 
243
  # always write the proprocessed file to stdout, regardless of -o,
 
244
  # because we must use -o when running libtool.
332
245
  test -z "$dashmflag" && dashmflag=-M
333
 
  # Require at least two characters before searching for `:'
334
 
  # in the target name.  This is to cope with DOS-style filenames:
335
 
  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
336
 
  "$@" $dashmflag |
337
 
    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
 
246
  ( IFS=" "
 
247
    case " $* " in
 
248
    *" --mode=compile "*) # this is libtool, let us make it quiet
 
249
      for arg
 
250
      do # cycle over the arguments
 
251
        case "$arg" in
 
252
        "--mode=compile")
 
253
          # insert --quiet before "--mode=compile"
 
254
          set fnord "$@" --quiet
 
255
          shift # fnord
 
256
          ;;
 
257
        esac
 
258
        set fnord "$@" "$arg"
 
259
        shift # fnord
 
260
        shift # "$arg"
 
261
      done
 
262
      ;;
 
263
    esac
 
264
    "$@" $dashmflag | sed 's:^[^:]*\:[  ]*:'"$object"'\: :' > "$tmpdepfile"
 
265
  ) &
 
266
  proc=$!
 
267
  "$@"
 
268
  stat=$?
 
269
  wait "$proc"
 
270
  if test "$stat" != 0; then exit $stat; fi
338
271
  rm -f "$depfile"
339
272
  cat < "$tmpdepfile" > "$depfile"
340
273
  tr ' ' '
352
285
  ;;
353
286
 
354
287
makedepend)
355
 
  "$@" || exit $?
356
 
  # Remove any Libtool call
357
 
  if test "$libtool" = yes; then
358
 
    while test $1 != '--mode=compile'; do
359
 
      shift
360
 
    done
361
 
    shift
362
 
  fi
363
288
  # X makedepend
364
 
  shift
365
 
  cleared=no
366
 
  for arg in "$@"; do
367
 
    case $cleared in
368
 
    no)
369
 
      set ""; shift
370
 
      cleared=yes ;;
371
 
    esac
372
 
    case "$arg" in
373
 
    -D*|-I*)
374
 
      set fnord "$@" "$arg"; shift ;;
375
 
    # Strip any option that makedepend may not understand.  Remove
376
 
    # the object too, otherwise makedepend will parse it as a source file.
377
 
    -*|$object)
378
 
      ;;
379
 
    *)
380
 
      set fnord "$@" "$arg"; shift ;;
381
 
    esac
382
 
  done
383
 
  obj_suffix="`echo $object | sed 's/^.*\././'`"
384
 
  touch "$tmpdepfile"
385
 
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
 
289
  (
 
290
    shift
 
291
    cleared=no
 
292
    for arg in "$@"; do
 
293
      case $cleared in no)
 
294
        set ""; shift
 
295
        cleared=yes
 
296
      esac
 
297
      case "$arg" in
 
298
        -D*|-I*)
 
299
          set fnord "$@" "$arg"; shift;;
 
300
        -*)
 
301
          ;;
 
302
        *)
 
303
          set fnord "$@" "$arg"; shift;;
 
304
      esac
 
305
    done
 
306
    obj_suffix="`echo $object | sed 's/^.*\././'`"
 
307
    touch "$tmpdepfile"
 
308
    ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
 
309
  ) &
 
310
  proc=$!
 
311
  "$@"
 
312
  stat=$?
 
313
  wait "$proc"
 
314
  if test "$stat" != 0; then exit $stat; fi
386
315
  rm -f "$depfile"
387
316
  cat < "$tmpdepfile" > "$depfile"
388
 
  sed '1,2d' "$tmpdepfile" | tr ' ' '
 
317
  tail +3 "$tmpdepfile" | tr ' ' '
389
318
' | \
390
319
## Some versions of the HPUX 10.20 sed can't process this invocation
391
320
## correctly.  Breaking it into two sed invocations is a workaround.
395
324
 
396
325
cpp)
397
326
  # Important note: in order to support this mode, a compiler *must*
398
 
  # always write the preprocessed file to stdout.
399
 
  "$@" || exit $?
400
 
 
401
 
  # Remove the call to Libtool.
402
 
  if test "$libtool" = yes; then
403
 
    while test $1 != '--mode=compile'; do
404
 
      shift
405
 
    done
406
 
    shift
407
 
  fi
408
 
 
409
 
  # Remove `-o $object'.
410
 
  IFS=" "
411
 
  for arg
412
 
  do
413
 
    case $arg in
414
 
    -o)
415
 
      shift
416
 
      ;;
417
 
    $object)
418
 
      shift
419
 
      ;;
420
 
    *)
421
 
      set fnord "$@" "$arg"
422
 
      shift # fnord
423
 
      shift # $arg
 
327
  # always write the proprocessed file to stdout, regardless of -o,
 
328
  # because we must use -o when running libtool.
 
329
  ( IFS=" "
 
330
    case " $* " in
 
331
    *" --mode=compile "*)
 
332
      for arg
 
333
      do # cycle over the arguments
 
334
        case $arg in
 
335
        "--mode=compile")
 
336
          # insert --quiet before "--mode=compile"
 
337
          set fnord "$@" --quiet
 
338
          shift # fnord
 
339
          ;;
 
340
        esac
 
341
        set fnord "$@" "$arg"
 
342
        shift # fnord
 
343
        shift # "$arg"
 
344
      done
424
345
      ;;
425
346
    esac
426
 
  done
427
 
 
428
 
  "$@" -E |
 
347
    "$@" -E |
429
348
    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
430
349
    sed '$ s: \\$::' > "$tmpdepfile"
 
350
  ) &
 
351
  proc=$!
 
352
  "$@"
 
353
  stat=$?
 
354
  wait "$proc"
 
355
  if test "$stat" != 0; then exit $stat; fi
431
356
  rm -f "$depfile"
432
357
  echo "$object : \\" > "$depfile"
433
358
  cat < "$tmpdepfile" >> "$depfile"
437
362
 
438
363
msvisualcpp)
439
364
  # Important note: in order to support this mode, a compiler *must*
440
 
  # always write the preprocessed file to stdout, regardless of -o,
 
365
  # always write the proprocessed file to stdout, regardless of -o,
441
366
  # because we must use -o when running libtool.
442
 
  "$@" || exit $?
443
 
  IFS=" "
444
 
  for arg
445
 
  do
446
 
    case "$arg" in
447
 
    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
448
 
        set fnord "$@"
449
 
        shift
450
 
        shift
451
 
        ;;
452
 
    *)
 
367
  ( IFS=" "
 
368
    case " $* " in
 
369
    *" --mode=compile "*)
 
370
      for arg
 
371
      do # cycle over the arguments
 
372
        case $arg in
 
373
        "--mode=compile")
 
374
          # insert --quiet before "--mode=compile"
 
375
          set fnord "$@" --quiet
 
376
          shift # fnord
 
377
          ;;
 
378
        esac
453
379
        set fnord "$@" "$arg"
454
 
        shift
455
 
        shift
456
 
        ;;
 
380
        shift # fnord
 
381
        shift # "$arg"
 
382
      done
 
383
      ;;
457
384
    esac
458
 
  done
459
 
  "$@" -E |
460
 
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
 
385
    "$@" -E |
 
386
    sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
 
387
  ) &
 
388
  proc=$!
 
389
  "$@"
 
390
  stat=$?
 
391
  wait "$proc"
 
392
  if test "$stat" != 0; then exit $stat; fi
461
393
  rm -f "$depfile"
462
394
  echo "$object : \\" > "$depfile"
463
395
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::    \1 \\:p' >> "$depfile"