~ubuntu-branches/ubuntu/utopic/cloog/utopic

« back to all changes in this revision

Viewing changes to autoconf/depcomp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-26 14:21:11 UTC
  • mfrom: (3.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20140226142111-vsbb1isby30uundd
Tags: 0.18.2-1
New upstream version.

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