Subversion Repositories Scribus

Rev

Rev 599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 paul 1
#! /bin/sh
2
 
3
# depcomp - compile a program generating dependencies as side-effects
4
# Copyright 1999, 2000 Free Software Foundation, Inc.
5
 
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
9
# any later version.
10
 
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
 
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
# 02111-1307, USA.
20
 
599 cbradney 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
 
3 paul 26
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
27
 
28
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
29
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
30
  exit 1
31
fi
32
# `libtool' can also be set to `yes' or `no'.
33
 
34
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
35
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
36
 
37
rm -f "$tmpdepfile"
38
 
39
# Some modes work just like other modes, but use different flags.  We
40
# parameterize here, but still list the modes in the big case below,
41
# to make depend.m4 easier to write.  Note that we *cannot* use a case
42
# here, because this file can only contain one case statement.
43
if test "$depmode" = hp; then
44
  # HP compiler uses -M and no extra arg.
45
  gccflag=-M
46
  depmode=gcc
47
fi
48
 
49
if test "$depmode" = dashXmstdout; then
50
   # This is just like dashmstdout with a different argument.
51
   dashmflag=-xM
52
   depmode=dashmstdout
53
fi
54
 
55
case "$depmode" in
56
gcc3)
57
## gcc 3 implements dependency tracking that does exactly what
599 cbradney 58
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
59
## it if -MD -MP comes after the -MF stuff.  Hmm.
60
  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
61
  stat=$?
62
  if test $stat -eq 0; then :
3 paul 63
  else
64
    rm -f "$tmpdepfile"
65
    exit $stat
66
  fi
67
  mv "$tmpdepfile" "$depfile"
68
  ;;
69
 
70
gcc)
71
## There are various ways to get dependency output from gcc.  Here's
72
## why we pick this rather obscure method:
73
## - Don't want to use -MD because we'd like the dependencies to end
74
##   up in a subdir.  Having to rename by hand is ugly.
75
##   (We might end up doing this anyway to support other compilers.)
76
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
77
##   -MM, not -M (despite what the docs say).
78
## - Using -M directly means running the compiler twice (even worse
79
##   than renaming).
80
  if test -z "$gccflag"; then
81
    gccflag=-MD,
82
  fi
599 cbradney 83
  "$@" -Wp,"$gccflag$tmpdepfile"
84
  stat=$?
85
  if test $stat -eq 0; then :
3 paul 86
  else
87
    rm -f "$tmpdepfile"
88
    exit $stat
89
  fi
90
  rm -f "$depfile"
91
  echo "$object : \\" > "$depfile"
92
  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
93
## The second -e expression handles DOS-style file names with drive letters.
94
  sed -e 's/^[^:]*: / /' \
95
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
96
## This next piece of magic avoids the `deleted header file' problem.
97
## The problem is that when a header file which appears in a .P file
98
## is deleted, the dependency causes make to die (because there is
99
## typically no way to rebuild the header).  We avoid this by adding
100
## dummy dependencies for each header file.  Too bad gcc doesn't do
101
## this for us directly.
102
  tr ' ' '
103
' < "$tmpdepfile" |
104
## Some versions of gcc put a space before the `:'.  On the theory
105
## that the space means something, we add a space to the output as
106
## well.
107
## Some versions of the HPUX 10.20 sed can't process this invocation
108
## correctly.  Breaking it into two sed invocations is a workaround.
109
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
110
  rm -f "$tmpdepfile"
111
  ;;
112
 
113
hp)
114
  # This case exists only to let depend.m4 do its work.  It works by
115
  # looking at the text of this script.  This case will never be run,
116
  # since it is checked for above.
117
  exit 1
118
  ;;
119
 
120
sgi)
121
  if test "$libtool" = yes; then
122
    "$@" "-Wp,-MDupdate,$tmpdepfile"
123
  else
124
    "$@" -MDupdate "$tmpdepfile"
125
  fi
126
  stat=$?
127
  if test $stat -eq 0; then :
128
  else
129
    rm -f "$tmpdepfile"
130
    exit $stat
131
  fi
132
  rm -f "$depfile"
133
 
134
  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
135
    echo "$object : \\" > "$depfile"
136
 
599 cbradney 137
    # Clip off the initial element (the dependent).  Don't try to be
3 paul 138
    # clever and replace this with sed code, as IRIX sed won't handle
139
    # lines with more than a fixed number of characters (4096 in
599 cbradney 140
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
141
    # the IRIX cc adds comments like `#:fec' to the end of the
142
    # dependency line.
3 paul 143
    tr ' ' '
599 cbradney 144
' < "$tmpdepfile" \
145
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
146
    tr '
3 paul 147
' ' ' >> $depfile
599 cbradney 148
    echo >> $depfile
3 paul 149
 
599 cbradney 150
    # The second pass generates a dummy entry for each header file.
3 paul 151
    tr ' ' '
599 cbradney 152
' < "$tmpdepfile" \
153
   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
154
   >> $depfile
3 paul 155
  else
156
    # The sourcefile does not contain any dependencies, so just
157
    # store a dummy comment line, to avoid errors with the Makefile
158
    # "include basename.Plo" scheme.
159
    echo "#dummy" > "$depfile"
160
  fi
161
  rm -f "$tmpdepfile"
162
  ;;
163
 
164
aix)
165
  # The C for AIX Compiler uses -M and outputs the dependencies
599 cbradney 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/'`
170
  tmpdepfile="$stripped.u"
171
  outname="$stripped.o"
3 paul 172
  if test "$libtool" = yes; then
173
    "$@" -Wc,-M
174
  else
175
    "$@" -M
176
  fi
177
 
178
  stat=$?
179
  if test $stat -eq 0; then :
180
  else
181
    rm -f "$tmpdepfile"
182
    exit $stat
183
  fi
184
 
185
  if test -f "$tmpdepfile"; then
599 cbradney 186
    # Each line is of the form `foo.o: dependent.h'.
187
    # Do two passes, one to just change these to
188
    # `$object: dependent.h' and one to simply `dependent.h:'.
189
    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
190
    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
3 paul 191
  else
192
    # The sourcefile does not contain any dependencies, so just
193
    # store a dummy comment line, to avoid errors with the Makefile
194
    # "include basename.Plo" scheme.
195
    echo "#dummy" > "$depfile"
196
  fi
197
  rm -f "$tmpdepfile"
198
  ;;
199
 
599 cbradney 200
icc)
201
  # Must come before tru64.
202
 
203
  # Intel's C compiler understands `-MD -MF file'.  However
204
  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
205
  # will fill foo.d with something like
206
  #    foo.o: sub/foo.c
207
  #    foo.o: sub/foo.h
208
  # which is wrong.  We want:
209
  #    sub/foo.o: sub/foo.c
210
  #    sub/foo.o: sub/foo.h
211
  #    sub/foo.c:
212
  #    sub/foo.h:
213
 
214
  "$@" -MD -MF "$tmpdepfile"
215
  stat=$?
216
  if test $stat -eq 0; then :
217
  else
218
    rm -f "$tmpdepfile"
219
    exit $stat
220
  fi
221
  rm -f "$depfile"
222
  # Each line is of the form `foo.o: dependent.h'.
223
  # Do two passes, one to just change these to
224
  # `$object: dependent.h' and one to simply `dependent.h:'.
225
  sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
226
  sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
227
  rm -f "$tmpdepfile"
228
  ;;
229
 
230
tru64)
231
   # The Tru64 AIX compiler uses -MD to generate dependencies as a side
232
   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
233
   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
234
   # dependencies in `foo.d' instead, so we check for that too.
235
   # Subdirectories are respected.
236
 
237
   tmpdepfile1="$object.d"
238
   tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
239
   if test "$libtool" = yes; then
240
      "$@" -Wc,-MD
241
   else
242
      "$@" -MD
243
   fi
244
 
245
   stat=$?
246
   if test $stat -eq 0; then :
247
   else
248
      rm -f "$tmpdepfile1" "$tmpdepfile2"
249
      exit $stat
250
   fi
251
 
252
   if test -f "$tmpdepfile1"; then
253
      tmpdepfile="$tmpdepfile1"
254
   else
255
      tmpdepfile="$tmpdepfile2"
256
   fi
257
   if test -f "$tmpdepfile"; then
258
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
259
      # That's a space and a tab in the [].
260
      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
261
   else
262
      echo "#dummy" > "$depfile"
263
   fi
264
   rm -f "$tmpdepfile"
265
   ;;
266
 
3 paul 267
#nosideeffect)
268
  # This comment above is used by automake to tell side-effect
269
  # dependency tracking mechanisms from slower ones.
270
 
271
dashmstdout)
272
  # Important note: in order to support this mode, a compiler *must*
273
  # always write the proprocessed file to stdout, regardless of -o,
274
  # because we must use -o when running libtool.
275
  test -z "$dashmflag" && dashmflag=-M
276
  ( IFS=" "
277
    case " $* " in
278
    *" --mode=compile "*) # this is libtool, let us make it quiet
279
      for arg
280
      do # cycle over the arguments
281
        case "$arg" in
282
	"--mode=compile")
283
	  # insert --quiet before "--mode=compile"
284
	  set fnord "$@" --quiet
285
	  shift # fnord
286
	  ;;
287
	esac
288
	set fnord "$@" "$arg"
289
	shift # fnord
290
	shift # "$arg"
291
      done
292
      ;;
293
    esac
294
    "$@" $dashmflag | sed 's:^[^:]*\:[ 	]*:'"$object"'\: :' > "$tmpdepfile"
295
  ) &
296
  proc=$!
297
  "$@"
298
  stat=$?
299
  wait "$proc"
300
  if test "$stat" != 0; then exit $stat; fi
301
  rm -f "$depfile"
302
  cat < "$tmpdepfile" > "$depfile"
303
  tr ' ' '
304
' < "$tmpdepfile" | \
305
## Some versions of the HPUX 10.20 sed can't process this invocation
306
## correctly.  Breaking it into two sed invocations is a workaround.
307
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
308
  rm -f "$tmpdepfile"
309
  ;;
310
 
311
dashXmstdout)
312
  # This case only exists to satisfy depend.m4.  It is never actually
313
  # run, as this mode is specially recognized in the preamble.
314
  exit 1
315
  ;;
316
 
317
makedepend)
318
  # X makedepend
319
  (
320
    shift
321
    cleared=no
322
    for arg in "$@"; do
323
      case $cleared in no)
324
        set ""; shift
325
	cleared=yes
326
      esac
327
      case "$arg" in
328
        -D*|-I*)
329
	  set fnord "$@" "$arg"; shift;;
330
	-*)
331
	  ;;
332
	*)
333
	  set fnord "$@" "$arg"; shift;;
334
      esac
335
    done
336
    obj_suffix="`echo $object | sed 's/^.*\././'`"
337
    touch "$tmpdepfile"
338
    ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
339
  ) &
340
  proc=$!
341
  "$@"
342
  stat=$?
343
  wait "$proc"
344
  if test "$stat" != 0; then exit $stat; fi
345
  rm -f "$depfile"
346
  cat < "$tmpdepfile" > "$depfile"
347
  tail +3 "$tmpdepfile" | tr ' ' '
348
' | \
349
## Some versions of the HPUX 10.20 sed can't process this invocation
350
## correctly.  Breaking it into two sed invocations is a workaround.
351
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
352
  rm -f "$tmpdepfile" "$tmpdepfile".bak
353
  ;;
354
 
355
cpp)
356
  # Important note: in order to support this mode, a compiler *must*
357
  # always write the proprocessed file to stdout, regardless of -o,
358
  # because we must use -o when running libtool.
359
  ( IFS=" "
360
    case " $* " in
361
    *" --mode=compile "*)
362
      for arg
363
      do # cycle over the arguments
364
        case $arg in
365
	"--mode=compile")
366
	  # insert --quiet before "--mode=compile"
367
	  set fnord "$@" --quiet
368
	  shift # fnord
369
	  ;;
370
	esac
371
	set fnord "$@" "$arg"
372
	shift # fnord
373
	shift # "$arg"
374
      done
375
      ;;
376
    esac
377
    "$@" -E |
378
    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
379
    sed '$ s: \\$::' > "$tmpdepfile"
380
  ) &
381
  proc=$!
382
  "$@"
383
  stat=$?
384
  wait "$proc"
385
  if test "$stat" != 0; then exit $stat; fi
386
  rm -f "$depfile"
387
  echo "$object : \\" > "$depfile"
388
  cat < "$tmpdepfile" >> "$depfile"
389
  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
390
  rm -f "$tmpdepfile"
391
  ;;
392
 
393
msvisualcpp)
394
  # Important note: in order to support this mode, a compiler *must*
395
  # always write the proprocessed file to stdout, regardless of -o,
396
  # because we must use -o when running libtool.
397
  ( IFS=" "
398
    case " $* " in
399
    *" --mode=compile "*)
400
      for arg
401
      do # cycle over the arguments
402
        case $arg in
403
	"--mode=compile")
404
	  # insert --quiet before "--mode=compile"
405
	  set fnord "$@" --quiet
406
	  shift # fnord
407
	  ;;
408
	esac
409
	set fnord "$@" "$arg"
410
	shift # fnord
411
	shift # "$arg"
412
      done
413
      ;;
414
    esac
415
    "$@" -E |
416
    sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
417
  ) &
418
  proc=$!
419
  "$@"
420
  stat=$?
421
  wait "$proc"
422
  if test "$stat" != 0; then exit $stat; fi
423
  rm -f "$depfile"
424
  echo "$object : \\" > "$depfile"
425
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
426
  echo "	" >> "$depfile"
427
  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
428
  rm -f "$tmpdepfile"
429
  ;;
430
 
431
none)
432
  exec "$@"
433
  ;;
434
 
435
*)
436
  echo "Unknown depmode $depmode" 1>&2
437
  exit 1
438
  ;;
439
esac
440
 
441
exit 0