~ubuntu-branches/ubuntu/saucy/gnutls26/saucy-security

« back to all changes in this revision

Viewing changes to build-aux/depcomp

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-03-07 12:47:58 UTC
  • mfrom: (12.4.33 experimental)
  • Revision ID: package-import@ubuntu.com-20130307124758-wlp31d99bw5hi0tv
Tags: 2.12.23-1ubuntu1
* Merge from debian-experimental, remaining changes:
  - Build gnutls-bin from this source package rather than from gnutls28:
    gnutls28's licensing is currently too strict for many of the free
    software packages built against it in Ubuntu main and we only want to
    support a single version.  Bump its version to achieve this.
* Drop gnulib-gets.diff: upstream.

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=2011-12-04.11; # UTC
 
4
scriptversion=2012-03-27.16; # UTC
5
5
 
6
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
7
 
# 2011 Free Software Foundation, Inc.
 
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
47
  tmpdepfile  Temporary file to use when outputting dependencies.
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
102
108
   depmode=msvc7
103
109
fi
104
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
 
105
117
case "$depmode" in
106
118
gcc3)
107
119
## gcc 3 implements dependency tracking that does exactly what
156
168
## The second -e expression handles DOS-style file names with drive letters.
157
169
  sed -e 's/^[^:]*: / /' \
158
170
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
159
 
## This next piece of magic avoids the `deleted header file' problem.
 
171
## This next piece of magic avoids the "deleted header file" problem.
160
172
## The problem is that when a header file which appears in a .P file
161
173
## is deleted, the dependency causes make to die (because there is
162
174
## typically no way to rebuild the header).  We avoid this by adding
163
175
## dummy dependencies for each header file.  Too bad gcc doesn't do
164
176
## this for us directly.
165
 
  tr ' ' '
166
 
' < "$tmpdepfile" |
167
 
## 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
168
179
## that the space means something, we add a space to the output as
169
180
## well.  hp depmode also adds that space, but also prefixes the VPATH
170
181
## to the object.  Take care to not repeat it in the output.
203
214
    # clever and replace this with sed code, as IRIX sed won't handle
204
215
    # lines with more than a fixed number of characters (4096 in
205
216
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
206
 
    # 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
207
218
    # dependency line.
208
 
    tr ' ' '
209
 
' < "$tmpdepfile" \
 
219
    tr ' ' "$nl" < "$tmpdepfile" \
210
220
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
211
 
    tr '
212
 
' ' ' >> "$depfile"
 
221
    tr "$nl" ' ' >> "$depfile"
213
222
    echo >> "$depfile"
214
223
 
215
224
    # The second pass generates a dummy entry for each header file.
216
 
    tr ' ' '
217
 
' < "$tmpdepfile" \
 
225
    tr ' ' "$nl" < "$tmpdepfile" \
218
226
   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
219
227
   >> "$depfile"
220
228
  else
226
234
  rm -f "$tmpdepfile"
227
235
  ;;
228
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
 
229
244
aix)
230
245
  # The C for AIX Compiler uses -M and outputs the dependencies
231
246
  # in a .u file.  In older versions, this file always lives in the
232
 
  # current directory.  Also, the AIX compiler puts `$object:' at the
 
247
  # current directory.  Also, the AIX compiler puts '$object:' at the
233
248
  # start of each line; $object doesn't have directory information.
234
249
  # Version 6 uses the directory in both cases.
235
250
  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
259
274
    test -f "$tmpdepfile" && break
260
275
  done
261
276
  if test -f "$tmpdepfile"; then
262
 
    # Each line is of the form `foo.o: dependent.h'.
 
277
    # Each line is of the form 'foo.o: dependent.h'.
263
278
    # Do two passes, one to just change these to
264
 
    # `$object: dependent.h' and one to simply `dependent.h:'.
 
279
    # '$object: dependent.h' and one to simply 'dependent.h:'.
265
280
    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
266
 
    # That's a tab and a space in the [].
267
 
    sed -e 's,^.*\.[a-z]*:[      ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
281
    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
268
282
  else
269
283
    # The sourcefile does not contain any dependencies, so just
270
284
    # store a dummy comment line, to avoid errors with the Makefile
275
289
  ;;
276
290
 
277
291
icc)
278
 
  # Intel's C compiler understands `-MD -MF file'.  However on
279
 
  #    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
280
295
  # ICC 7.0 will fill foo.d with something like
281
296
  #    foo.o: sub/foo.c
282
297
  #    foo.o: sub/foo.h
283
 
  # which is wrong.  We want:
 
298
  # which is wrong.  We want
284
299
  #    sub/foo.o: sub/foo.c
285
300
  #    sub/foo.o: sub/foo.h
286
301
  #    sub/foo.c:
287
302
  #    sub/foo.h:
288
303
  # ICC 7.1 will output
289
304
  #    foo.o: sub/foo.c sub/foo.h
290
 
  # and will wrap long lines using \ :
 
305
  # and will wrap long lines using '\':
291
306
  #    foo.o: sub/foo.c ... \
292
307
  #     sub/foo.h ... \
293
308
  #     ...
294
 
 
 
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.
295
312
  "$@" -MD -MF "$tmpdepfile"
296
313
  stat=$?
297
314
  if test $stat -eq 0; then :
300
317
    exit $stat
301
318
  fi
302
319
  rm -f "$depfile"
303
 
  # Each line is of the form `foo.o: dependent.h',
304
 
  # 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 \'.
305
322
  # Do two passes, one to just change these to
306
 
  # `$object: dependent.h' and one to simply `dependent.h:'.
307
 
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
308
 
  # Some versions of the HPUX 10.20 sed can't process this invocation
309
 
  # correctly.  Breaking it into two sed invocations is a workaround.
310
 
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
311
 
    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"
312
335
  rm -f "$tmpdepfile"
313
336
  ;;
314
337
 
344
367
  done
345
368
  if test -f "$tmpdepfile"; then
346
369
    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
347
 
    # Add `dependent.h:' lines.
 
370
    # Add 'dependent.h:' lines.
348
371
    sed -ne '2,${
349
372
               s/^ *//
350
373
               s/ \\*$//
359
382
 
360
383
tru64)
361
384
   # The Tru64 compiler uses -MD to generate dependencies as a side
362
 
   # 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'.
363
386
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
364
 
   # dependencies in `foo.d' instead, so we check for that too.
 
387
   # dependencies in 'foo.d' instead, so we check for that too.
365
388
   # Subdirectories are respected.
366
389
   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
367
390
   test "x$dir" = "x$object" && dir=
407
430
   done
408
431
   if test -f "$tmpdepfile"; then
409
432
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
410
 
      # That's a tab and a space in the [].
411
 
      sed -e 's,^.*\.[a-z]*:[    ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
 
433
      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
412
434
   else
413
435
      echo "#dummy" > "$depfile"
414
436
   fi
443
465
  p
444
466
}' | $cygpath_u | sort -u | sed -n '
445
467
s/ /\\ /g
446
 
s/\(.*\)/       \1 \\/p
 
468
s/\(.*\)/'"$tab"'\1 \\/p
447
469
s/.\(.*\) \\/\1:/
448
470
H
449
471
$ {
450
 
  s/.*/ /
 
472
  s/.*/'"$tab"'/
451
473
  G
452
474
  p
453
475
}' >> "$depfile"
478
500
    shift
479
501
  fi
480
502
 
481
 
  # Remove `-o $object'.
 
503
  # Remove '-o $object'.
482
504
  IFS=" "
483
505
  for arg
484
506
  do
498
520
  done
499
521
 
500
522
  test -z "$dashmflag" && dashmflag=-M
501
 
  # Require at least two characters before searching for `:'
 
523
  # Require at least two characters before searching for ':'
502
524
  # in the target name.  This is to cope with DOS-style filenames:
503
 
  # 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.
504
526
  "$@" $dashmflag |
505
 
    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
 
527
    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
506
528
  rm -f "$depfile"
507
529
  cat < "$tmpdepfile" > "$depfile"
508
 
  tr ' ' '
509
 
' < "$tmpdepfile" | \
 
530
  tr ' ' "$nl" < "$tmpdepfile" | \
510
531
## Some versions of the HPUX 10.20 sed can't process this invocation
511
532
## correctly.  Breaking it into two sed invocations is a workaround.
512
533
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
562
583
  # makedepend may prepend the VPATH from the source file name to the object.
563
584
  # No need to regex-escape $object, excess matching of '.' is harmless.
564
585
  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
565
 
  sed '1,2d' "$tmpdepfile" | tr ' ' '
566
 
' | \
 
586
  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
567
587
## Some versions of the HPUX 10.20 sed can't process this invocation
568
588
## correctly.  Breaking it into two sed invocations is a workaround.
569
589
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
583
603
    shift
584
604
  fi
585
605
 
586
 
  # Remove `-o $object'.
 
606
  # Remove '-o $object'.
587
607
  IFS=" "
588
608
  for arg
589
609
  do
652
672
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
653
673
  rm -f "$depfile"
654
674
  echo "$object : \\" > "$depfile"
655
 
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::      \1 \\:p' >> "$depfile"
656
 
  echo "        " >> "$depfile"
 
675
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
 
676
  echo "$tab" >> "$depfile"
657
677
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
658
678
  rm -f "$tmpdepfile"
659
679
  ;;