~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to depcomp

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

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 Free Software Foundation, Inc.
 
4
# Copyright 1999, 2000, 2003 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
18
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
19
# 02111-1307, USA.
20
20
 
 
21
# As a special exception to the GNU General Public License, if you
 
22
# distribute this file as part of a program that contains a
 
23
# configuration script generated by Autoconf, you may include it under
 
24
# the same distribution terms that you use for the rest of that program.
 
25
 
21
26
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
22
27
 
23
28
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
26
31
fi
27
32
# `libtool' can also be set to `yes' or `no'.
28
33
 
29
 
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
 
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
 
30
44
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
31
45
 
32
46
rm -f "$tmpdepfile"
50
64
case "$depmode" in
51
65
gcc3)
52
66
## gcc 3 implements dependency tracking that does exactly what
53
 
## we want.  Yay!
54
 
  if "$@" -MT "$object" -MF "$tmpdepfile" -MD -MP; then :
 
67
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
 
68
## it if -MD -MP comes after the -MF stuff.  Hmm.
 
69
  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
 
70
  stat=$?
 
71
  if test $stat -eq 0; then :
55
72
  else
56
 
    stat=$?
57
73
    rm -f "$tmpdepfile"
58
74
    exit $stat
59
75
  fi
73
89
  if test -z "$gccflag"; then
74
90
    gccflag=-MD,
75
91
  fi
76
 
  if "$@" -Wp,"$gccflag$tmpdepfile"; then :
 
92
  "$@" -Wp,"$gccflag$tmpdepfile"
 
93
  stat=$?
 
94
  if test $stat -eq 0; then :
77
95
  else
78
 
    stat=$?
79
96
    rm -f "$tmpdepfile"
80
97
    exit $stat
81
98
  fi
126
143
  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
127
144
    echo "$object : \\" > "$depfile"
128
145
 
129
 
    # Clip off the initial element (the dependent). Don't try to be
 
146
    # Clip off the initial element (the dependent).  Don't try to be
130
147
    # clever and replace this with sed code, as IRIX sed won't handle
131
148
    # lines with more than a fixed number of characters (4096 in
132
 
    # IRIX 6.2 sed, 8192 in IRIX 6.5).
 
149
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
 
150
    # the IRIX cc adds comments like `#:fec' to the end of the
 
151
    # dependency line.
133
152
    tr ' ' '
134
 
' < "$tmpdepfile" | sed 's/^[^\.]*\.o://' | tr '
 
153
' < "$tmpdepfile" \
 
154
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
 
155
    tr '
135
156
' ' ' >> $depfile
 
157
    echo >> $depfile
136
158
 
 
159
    # The second pass generates a dummy entry for each header file.
137
160
    tr ' ' '
138
 
' < "$tmpdepfile" | \
139
 
## Some versions of the HPUX 10.20 sed can't process this invocation
140
 
## correctly.  Breaking it into two sed invocations is a workaround.
141
 
      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
 
161
' < "$tmpdepfile" \
 
162
   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
 
163
   >> $depfile
142
164
  else
143
165
    # The sourcefile does not contain any dependencies, so just
144
166
    # store a dummy comment line, to avoid errors with the Makefile
150
172
 
151
173
aix)
152
174
  # The C for AIX Compiler uses -M and outputs the dependencies
153
 
  # in a .u file.
154
 
  tmpdepfile=`echo "$object" | sed 's/\(.*\)\..*$/\1.u/'`
 
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/'`
 
180
  tmpdepfile="$stripped.u"
155
181
  if test "$libtool" = yes; then
156
182
    "$@" -Wc,-M
157
183
  else
158
184
    "$@" -M
159
185
  fi
160
 
 
161
186
  stat=$?
 
187
 
 
188
  if test -f "$tmpdepfile"; then :
 
189
  else
 
190
    stripped=`echo "$stripped" | sed 's,^.*/,,'`
 
191
    tmpdepfile="$stripped.u"
 
192
  fi
 
193
 
162
194
  if test $stat -eq 0; then :
163
195
  else
164
196
    rm -f "$tmpdepfile"
166
198
  fi
167
199
 
168
200
  if test -f "$tmpdepfile"; then
169
 
    echo "$object : \\" > "$depfile"
170
 
 
171
 
    # Clip off the initial element (the dependent). Don't try to be
172
 
    # clever and replace this with sed code, as IRIX sed won't handle
173
 
    # lines with more than a fixed number of characters (4096 in
174
 
    # IRIX 6.2 sed, 8192 in IRIX 6.5).
175
 
    tr ' ' '
176
 
' < "$tmpdepfile" | sed 's/^[^\.]*\.o://' | tr '
177
 
' ' ' >> $depfile
178
 
 
179
 
    tr ' ' '
180
 
' < "$tmpdepfile" | \
181
 
## Some versions of the HPUX 10.20 sed can't process this invocation
182
 
## correctly.  Breaking it into two sed invocations is a workaround.
183
 
      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
 
201
    outname="$stripped.o"
 
202
    # Each line is of the form `foo.o: dependent.h'.
 
203
    # Do two passes, one to just change these to
 
204
    # `$object: dependent.h' and one to simply `dependent.h:'.
 
205
    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
 
206
    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
184
207
  else
185
208
    # The sourcefile does not contain any dependencies, so just
186
209
    # store a dummy comment line, to avoid errors with the Makefile
190
213
  rm -f "$tmpdepfile"
191
214
  ;;
192
215
 
 
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
tru64)
 
255
   # The Tru64 compiler uses -MD to generate dependencies as a side
 
256
   # 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
 
258
   # dependencies in `foo.d' instead, so we check for that too.
 
259
   # 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
 
 
264
   if test "$libtool" = yes; then
 
265
      tmpdepfile1="$dir.libs/$base.lo.d"
 
266
      tmpdepfile2="$dir.libs/$base.d"
 
267
      "$@" -Wc,-MD
 
268
   else
 
269
      tmpdepfile1="$dir$base.o.d"
 
270
      tmpdepfile2="$dir$base.d"
 
271
      "$@" -MD
 
272
   fi
 
273
 
 
274
   stat=$?
 
275
   if test $stat -eq 0; then :
 
276
   else
 
277
      rm -f "$tmpdepfile1" "$tmpdepfile2"
 
278
      exit $stat
 
279
   fi
 
280
 
 
281
   if test -f "$tmpdepfile1"; then
 
282
      tmpdepfile="$tmpdepfile1"
 
283
   else
 
284
      tmpdepfile="$tmpdepfile2"
 
285
   fi
 
286
   if test -f "$tmpdepfile"; then
 
287
      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"
 
290
   else
 
291
      echo "#dummy" > "$depfile"
 
292
   fi
 
293
   rm -f "$tmpdepfile"
 
294
   ;;
 
295
 
193
296
#nosideeffect)
194
297
  # This comment above is used by automake to tell side-effect
195
298
  # dependency tracking mechanisms from slower ones.
196
299
 
197
300
dashmstdout)
198
301
  # Important note: in order to support this mode, a compiler *must*
199
 
  # always write the proprocessed file to stdout, regardless of -o,
200
 
  # because we must use -o when running libtool.
 
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
 
201
332
  test -z "$dashmflag" && dashmflag=-M
202
 
  ( IFS=" "
203
 
    case " $* " in
204
 
    *" --mode=compile "*) # this is libtool, let us make it quiet
205
 
      for arg
206
 
      do # cycle over the arguments
207
 
        case "$arg" in
208
 
        "--mode=compile")
209
 
          # insert --quiet before "--mode=compile"
210
 
          set fnord "$@" --quiet
211
 
          shift # fnord
212
 
          ;;
213
 
        esac
214
 
        set fnord "$@" "$arg"
215
 
        shift # fnord
216
 
        shift # "$arg"
217
 
      done
218
 
      ;;
219
 
    esac
220
 
    "$@" $dashmflag | sed 's:^[^:]*\:[  ]*:'"$object"'\: :' > "$tmpdepfile"
221
 
  ) &
222
 
  proc=$!
223
 
  "$@"
224
 
  stat=$?
225
 
  wait "$proc"
226
 
  if test "$stat" != 0; then exit $stat; fi
 
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"
227
338
  rm -f "$depfile"
228
339
  cat < "$tmpdepfile" > "$depfile"
229
340
  tr ' ' '
241
352
  ;;
242
353
 
243
354
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
244
363
  # X makedepend
245
 
  (
246
 
    shift
247
 
    cleared=no
248
 
    for arg in "$@"; do
249
 
      case $cleared in no)
250
 
        set ""; shift
251
 
        cleared=yes
252
 
      esac
253
 
      case "$arg" in
254
 
        -D*|-I*)
255
 
          set fnord "$@" "$arg"; shift;;
256
 
        -*)
257
 
          ;;
258
 
        *)
259
 
          set fnord "$@" "$arg"; shift;;
260
 
      esac
261
 
    done
262
 
    obj_suffix="`echo $object | sed 's/^.*\././'`"
263
 
    touch "$tmpdepfile"
264
 
    ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
265
 
  ) &
266
 
  proc=$!
267
 
  "$@"
268
 
  stat=$?
269
 
  wait "$proc"
270
 
  if test "$stat" != 0; then exit $stat; fi
 
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" "$@"
271
386
  rm -f "$depfile"
272
387
  cat < "$tmpdepfile" > "$depfile"
273
 
  tail +3 "$tmpdepfile" | tr ' ' '
 
388
  sed '1,2d' "$tmpdepfile" | tr ' ' '
274
389
' | \
275
390
## Some versions of the HPUX 10.20 sed can't process this invocation
276
391
## correctly.  Breaking it into two sed invocations is a workaround.
280
395
 
281
396
cpp)
282
397
  # Important note: in order to support this mode, a compiler *must*
283
 
  # always write the proprocessed file to stdout, regardless of -o,
284
 
  # because we must use -o when running libtool.
285
 
  ( IFS=" "
286
 
    case " $* " in
287
 
    *" --mode=compile "*)
288
 
      for arg
289
 
      do # cycle over the arguments
290
 
        case $arg in
291
 
        "--mode=compile")
292
 
          # insert --quiet before "--mode=compile"
293
 
          set fnord "$@" --quiet
294
 
          shift # fnord
295
 
          ;;
296
 
        esac
297
 
        set fnord "$@" "$arg"
298
 
        shift # fnord
299
 
        shift # "$arg"
300
 
      done
 
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
301
424
      ;;
302
425
    esac
303
 
    "$@" -E |
 
426
  done
 
427
 
 
428
  "$@" -E |
304
429
    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
305
430
    sed '$ s: \\$::' > "$tmpdepfile"
306
 
  ) &
307
 
  proc=$!
308
 
  "$@"
309
 
  stat=$?
310
 
  wait "$proc"
311
 
  if test "$stat" != 0; then exit $stat; fi
312
431
  rm -f "$depfile"
313
432
  echo "$object : \\" > "$depfile"
314
433
  cat < "$tmpdepfile" >> "$depfile"
318
437
 
319
438
msvisualcpp)
320
439
  # Important note: in order to support this mode, a compiler *must*
321
 
  # always write the proprocessed file to stdout, regardless of -o,
 
440
  # always write the preprocessed file to stdout, regardless of -o,
322
441
  # because we must use -o when running libtool.
323
 
  ( IFS=" "
324
 
    case " $* " in
325
 
    *" --mode=compile "*)
326
 
      for arg
327
 
      do # cycle over the arguments
328
 
        case $arg in
329
 
        "--mode=compile")
330
 
          # insert --quiet before "--mode=compile"
331
 
          set fnord "$@" --quiet
332
 
          shift # fnord
333
 
          ;;
334
 
        esac
 
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
    *)
335
453
        set fnord "$@" "$arg"
336
 
        shift # fnord
337
 
        shift # "$arg"
338
 
      done
339
 
      ;;
 
454
        shift
 
455
        shift
 
456
        ;;
340
457
    esac
341
 
    "$@" -E |
342
 
    sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
343
 
  ) &
344
 
  proc=$!
345
 
  "$@"
346
 
  stat=$?
347
 
  wait "$proc"
348
 
  if test "$stat" != 0; then exit $stat; fi
 
458
  done
 
459
  "$@" -E |
 
460
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
349
461
  rm -f "$depfile"
350
462
  echo "$object : \\" > "$depfile"
351
463
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::    \1 \\:p' >> "$depfile"