~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to config/depcomp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

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=2009-04-28.21; # UTC
 
4
scriptversion=2012-03-27.16; # UTC
5
5
 
6
 
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7
 
# Software Foundation, Inc.
 
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
 
7
# 2011, 2012 Free Software Foundation, Inc.
8
8
 
9
9
# This program is free software; you can redistribute it and/or modify
10
10
# it under the terms of the GNU General Public License as published by
28
28
 
29
29
case $1 in
30
30
  '')
31
 
     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
 
31
     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
32
32
     exit 1;
33
33
     ;;
34
34
  -h | --h*)
40
40
 
41
41
Environment variables:
42
42
  depmode     Dependency tracking mode.
43
 
  source      Source file read by `PROGRAMS ARGS'.
44
 
  object      Object file output by `PROGRAMS ARGS'.
 
43
  source      Source file read by 'PROGRAMS ARGS'.
 
44
  object      Object file output by 'PROGRAMS ARGS'.
45
45
  DEPDIR      directory where to store dependencies.
46
46
  depfile     Dependency file to output.
47
 
  tmpdepfile  Temporary file to use when outputing dependencies.
 
47
  tmpdepfile  Temporary file to use when outputting dependencies.
48
48
  libtool     Whether libtool is used (yes/no).
49
49
 
50
50
Report bugs to <bug-automake@gnu.org>.
57
57
    ;;
58
58
esac
59
59
 
 
60
# A tabulation character.
 
61
tab='   '
 
62
# A newline character.
 
63
nl='
 
64
'
 
65
 
60
66
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61
67
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62
68
  exit 1
90
96
   # This is just like msvisualcpp but w/o cygpath translation.
91
97
   # Just convert the backslash-escaped backslashes to single forward
92
98
   # slashes to satisfy depend.m4
93
 
   cygpath_u="sed s,\\\\\\\\,/,g"
 
99
   cygpath_u='sed s,\\\\,/,g'
94
100
   depmode=msvisualcpp
95
101
fi
96
102
 
 
103
if test "$depmode" = msvc7msys; then
 
104
   # This is just like msvc7 but w/o cygpath translation.
 
105
   # Just convert the backslash-escaped backslashes to single forward
 
106
   # slashes to satisfy depend.m4
 
107
   cygpath_u='sed s,\\\\,/,g'
 
108
   depmode=msvc7
 
109
fi
 
110
 
 
111
if test "$depmode" = xlc; then
 
112
   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
 
113
   gccflag=-qmakedep=gcc,-MF
 
114
   depmode=gcc
 
115
fi
 
116
 
97
117
case "$depmode" in
98
118
gcc3)
99
119
## gcc 3 implements dependency tracking that does exactly what
148
168
## The second -e expression handles DOS-style file names with drive letters.
149
169
  sed -e 's/^[^:]*: / /' \
150
170
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151
 
## This next piece of magic avoids the `deleted header file' problem.
 
171
## This next piece of magic avoids the "deleted header file" problem.
152
172
## The problem is that when a header file which appears in a .P file
153
173
## is deleted, the dependency causes make to die (because there is
154
174
## typically no way to rebuild the header).  We avoid this by adding
155
175
## dummy dependencies for each header file.  Too bad gcc doesn't do
156
176
## this for us directly.
157
 
  tr ' ' '
158
 
' < "$tmpdepfile" |
159
 
## Some versions of gcc put a space before the `:'.  On the theory
 
177
  tr ' ' "$nl" < "$tmpdepfile" |
 
178
## Some versions of gcc put a space before the ':'.  On the theory
160
179
## that the space means something, we add a space to the output as
161
 
## well.
 
180
## well.  hp depmode also adds that space, but also prefixes the VPATH
 
181
## to the object.  Take care to not repeat it in the output.
162
182
## Some versions of the HPUX 10.20 sed can't process this invocation
163
183
## correctly.  Breaking it into two sed invocations is a workaround.
164
 
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
 
184
    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
 
185
      | sed -e 's/$/ :/' >> "$depfile"
165
186
  rm -f "$tmpdepfile"
166
187
  ;;
167
188
 
193
214
    # clever and replace this with sed code, as IRIX sed won't handle
194
215
    # lines with more than a fixed number of characters (4096 in
195
216
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
196
 
    # the IRIX cc adds comments like `#:fec' to the end of the
 
217
    # the IRIX cc adds comments like '#:fec' to the end of the
197
218
    # dependency line.
198
 
    tr ' ' '
199
 
' < "$tmpdepfile" \
 
219
    tr ' ' "$nl" < "$tmpdepfile" \
200
220
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201
 
    tr '
202
 
' ' ' >> "$depfile"
 
221
    tr "$nl" ' ' >> "$depfile"
203
222
    echo >> "$depfile"
204
223
 
205
224
    # The second pass generates a dummy entry for each header file.
206
 
    tr ' ' '
207
 
' < "$tmpdepfile" \
 
225
    tr ' ' "$nl" < "$tmpdepfile" \
208
226
   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209
227
   >> "$depfile"
210
228
  else
216
234
  rm -f "$tmpdepfile"
217
235
  ;;
218
236
 
 
237
xlc)
 
238
  # This case exists only to let depend.m4 do its work.  It works by
 
239
  # looking at the text of this script.  This case will never be run,
 
240
  # since it is checked for above.
 
241
  exit 1
 
242
  ;;
 
243
 
219
244
aix)
220
245
  # The C for AIX Compiler uses -M and outputs the dependencies
221
246
  # in a .u file.  In older versions, this file always lives in the
222
 
  # current directory.  Also, the AIX compiler puts `$object:' at the
 
247
  # current directory.  Also, the AIX compiler puts '$object:' at the
223
248
  # start of each line; $object doesn't have directory information.
224
249
  # Version 6 uses the directory in both cases.
225
250
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
249
274
    test -f "$tmpdepfile" && break
250
275
  done
251
276
  if test -f "$tmpdepfile"; then
252
 
    # Each line is of the form `foo.o: dependent.h'.
 
277
    # Each line is of the form 'foo.o: dependent.h'.
253
278
    # Do two passes, one to just change these to
254
 
    # `$object: dependent.h' and one to simply `dependent.h:'.
 
279
    # '$object: dependent.h' and one to simply 'dependent.h:'.
255
280
    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256
 
    # That's a tab and a space in the [].
257
 
    sed -e 's,^.*\.[a-z]*:[      ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
281
    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258
282
  else
259
283
    # The sourcefile does not contain any dependencies, so just
260
284
    # store a dummy comment line, to avoid errors with the Makefile
265
289
  ;;
266
290
 
267
291
icc)
268
 
  # Intel's C compiler understands `-MD -MF file'.  However on
269
 
  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
 
292
  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
 
293
  # However on
 
294
  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270
295
  # ICC 7.0 will fill foo.d with something like
271
296
  #    foo.o: sub/foo.c
272
297
  #    foo.o: sub/foo.h
273
 
  # which is wrong.  We want:
 
298
  # which is wrong.  We want
274
299
  #    sub/foo.o: sub/foo.c
275
300
  #    sub/foo.o: sub/foo.h
276
301
  #    sub/foo.c:
277
302
  #    sub/foo.h:
278
303
  # ICC 7.1 will output
279
304
  #    foo.o: sub/foo.c sub/foo.h
280
 
  # and will wrap long lines using \ :
 
305
  # and will wrap long lines using '\':
281
306
  #    foo.o: sub/foo.c ... \
282
307
  #     sub/foo.h ... \
283
308
  #     ...
284
 
 
 
309
  # tcc 0.9.26 (FIXME still under development at the moment of writing)
 
310
  # will emit a similar output, but also prepend the continuation lines
 
311
  # with horizontal tabulation characters.
285
312
  "$@" -MD -MF "$tmpdepfile"
286
313
  stat=$?
287
314
  if test $stat -eq 0; then :
290
317
    exit $stat
291
318
  fi
292
319
  rm -f "$depfile"
293
 
  # Each line is of the form `foo.o: dependent.h',
294
 
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
 
320
  # Each line is of the form 'foo.o: dependent.h',
 
321
  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
295
322
  # Do two passes, one to just change these to
296
 
  # `$object: dependent.h' and one to simply `dependent.h:'.
297
 
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298
 
  # Some versions of the HPUX 10.20 sed can't process this invocation
299
 
  # correctly.  Breaking it into two sed invocations is a workaround.
300
 
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301
 
    sed -e 's/$/ :/' >> "$depfile"
 
323
  # '$object: dependent.h' and one to simply 'dependent.h:'.
 
324
  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
 
325
    < "$tmpdepfile" > "$depfile"
 
326
  sed '
 
327
    s/[ '"$tab"'][ '"$tab"']*/ /g
 
328
    s/^ *//
 
329
    s/ *\\*$//
 
330
    s/^[^:]*: *//
 
331
    /^$/d
 
332
    /:$/d
 
333
    s/$/ :/
 
334
  ' < "$tmpdepfile" >> "$depfile"
302
335
  rm -f "$tmpdepfile"
303
336
  ;;
304
337
 
334
367
  done
335
368
  if test -f "$tmpdepfile"; then
336
369
    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337
 
    # Add `dependent.h:' lines.
 
370
    # Add 'dependent.h:' lines.
338
371
    sed -ne '2,${
339
372
               s/^ *//
340
373
               s/ \\*$//
349
382
 
350
383
tru64)
351
384
   # The Tru64 compiler uses -MD to generate dependencies as a side
352
 
   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
 
385
   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
353
386
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354
 
   # dependencies in `foo.d' instead, so we check for that too.
 
387
   # dependencies in 'foo.d' instead, so we check for that too.
355
388
   # Subdirectories are respected.
356
389
   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357
390
   test "x$dir" = "x$object" && dir=
397
430
   done
398
431
   if test -f "$tmpdepfile"; then
399
432
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400
 
      # That's a tab and a space in the [].
401
 
      sed -e 's,^.*\.[a-z]*:[    ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
433
      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402
434
   else
403
435
      echo "#dummy" > "$depfile"
404
436
   fi
405
437
   rm -f "$tmpdepfile"
406
438
   ;;
407
439
 
 
440
msvc7)
 
441
  if test "$libtool" = yes; then
 
442
    showIncludes=-Wc,-showIncludes
 
443
  else
 
444
    showIncludes=-showIncludes
 
445
  fi
 
446
  "$@" $showIncludes > "$tmpdepfile"
 
447
  stat=$?
 
448
  grep -v '^Note: including file: ' "$tmpdepfile"
 
449
  if test "$stat" = 0; then :
 
450
  else
 
451
    rm -f "$tmpdepfile"
 
452
    exit $stat
 
453
  fi
 
454
  rm -f "$depfile"
 
455
  echo "$object : \\" > "$depfile"
 
456
  # The first sed program below extracts the file names and escapes
 
457
  # backslashes for cygpath.  The second sed program outputs the file
 
458
  # name when reading, but also accumulates all include files in the
 
459
  # hold buffer in order to output them again at the end.  This only
 
460
  # works with sed implementations that can handle large buffers.
 
461
  sed < "$tmpdepfile" -n '
 
462
/^Note: including file:  *\(.*\)/ {
 
463
  s//\1/
 
464
  s/\\/\\\\/g
 
465
  p
 
466
}' | $cygpath_u | sort -u | sed -n '
 
467
s/ /\\ /g
 
468
s/\(.*\)/'"$tab"'\1 \\/p
 
469
s/.\(.*\) \\/\1:/
 
470
H
 
471
$ {
 
472
  s/.*/'"$tab"'/
 
473
  G
 
474
  p
 
475
}' >> "$depfile"
 
476
  rm -f "$tmpdepfile"
 
477
  ;;
 
478
 
 
479
msvc7msys)
 
480
  # This case exists only to let depend.m4 do its work.  It works by
 
481
  # looking at the text of this script.  This case will never be run,
 
482
  # since it is checked for above.
 
483
  exit 1
 
484
  ;;
 
485
 
408
486
#nosideeffect)
409
487
  # This comment above is used by automake to tell side-effect
410
488
  # dependency tracking mechanisms from slower ones.
422
500
    shift
423
501
  fi
424
502
 
425
 
  # Remove `-o $object'.
 
503
  # Remove '-o $object'.
426
504
  IFS=" "
427
505
  for arg
428
506
  do
442
520
  done
443
521
 
444
522
  test -z "$dashmflag" && dashmflag=-M
445
 
  # Require at least two characters before searching for `:'
 
523
  # Require at least two characters before searching for ':'
446
524
  # in the target name.  This is to cope with DOS-style filenames:
447
 
  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
 
525
  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
448
526
  "$@" $dashmflag |
449
 
    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
 
527
    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
450
528
  rm -f "$depfile"
451
529
  cat < "$tmpdepfile" > "$depfile"
452
 
  tr ' ' '
453
 
' < "$tmpdepfile" | \
 
530
  tr ' ' "$nl" < "$tmpdepfile" | \
454
531
## Some versions of the HPUX 10.20 sed can't process this invocation
455
532
## correctly.  Breaking it into two sed invocations is a workaround.
456
533
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
503
580
  touch "$tmpdepfile"
504
581
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505
582
  rm -f "$depfile"
506
 
  cat < "$tmpdepfile" > "$depfile"
507
 
  sed '1,2d' "$tmpdepfile" | tr ' ' '
508
 
' | \
 
583
  # makedepend may prepend the VPATH from the source file name to the object.
 
584
  # No need to regex-escape $object, excess matching of '.' is harmless.
 
585
  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
 
586
  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
509
587
## Some versions of the HPUX 10.20 sed can't process this invocation
510
588
## correctly.  Breaking it into two sed invocations is a workaround.
511
589
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
525
603
    shift
526
604
  fi
527
605
 
528
 
  # Remove `-o $object'.
 
606
  # Remove '-o $object'.
529
607
  IFS=" "
530
608
  for arg
531
609
  do
594
672
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595
673
  rm -f "$depfile"
596
674
  echo "$object : \\" > "$depfile"
597
 
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::      \1 \\:p' >> "$depfile"
598
 
  echo "        " >> "$depfile"
 
675
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
 
676
  echo "$tab" >> "$depfile"
599
677
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600
678
  rm -f "$tmpdepfile"
601
679
  ;;