source: trunk/essentials/sys-devel/automake-1.8/lib/depcomp@ 3253

Last change on this file since 3253 was 3118, checked in by bird, 19 years ago

automake 1.8.5

File size: 14.8 KB
Line 
1#! /bin/sh
2# depcomp - compile a program generating dependencies as side-effects
3
4scriptversion=2004-04-25.13
5
6# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
7
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2, or (at your option)
11# any later version.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21# 02111-1307, USA.
22
23# As a special exception to the GNU General Public License, if you
24# distribute this file as part of a program that contains a
25# configuration script generated by Autoconf, you may include it under
26# the same distribution terms that you use for the rest of that program.
27
28# Originally written by Alexandre Oliva <[email protected]>.
29
30case $1 in
31 '')
32 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
33 exit 1;
34 ;;
35 -h | --h*)
36 cat <<\EOF
37Usage: depcomp [--help] [--version] PROGRAM [ARGS]
38
39Run PROGRAMS ARGS to compile a file, generating dependencies
40as side-effects.
41
42Environment variables:
43 depmode Dependency tracking mode.
44 source Source file read by `PROGRAMS ARGS'.
45 object Object file output by `PROGRAMS ARGS'.
46 depfile Dependency file to output.
47 tmpdepfile Temporary file to use when outputing dependencies.
48 libtool Whether libtool is used (yes/no).
49
50Report bugs to <[email protected]>.
51EOF
52 exit 0
53 ;;
54 -v | --v*)
55 echo "depcomp $scriptversion"
56 exit 0
57 ;;
58esac
59
60if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 exit 1
63fi
64# `libtool' can also be set to `yes' or `no'.
65
66if test -z "$depfile"; then
67 base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
68 dir=`echo "$object" | sed 's,/.*$,/,'`
69 if test "$dir" = "$object"; then
70 dir=
71 fi
72 # FIXME: should be _deps on DOS.
73 depfile="$dir.deps/$base"
74fi
75
76tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
77
78rm -f "$tmpdepfile"
79
80# Some modes work just like other modes, but use different flags. We
81# parameterize here, but still list the modes in the big case below,
82# to make depend.m4 easier to write. Note that we *cannot* use a case
83# here, because this file can only contain one case statement.
84if test "$depmode" = hp; then
85 # HP compiler uses -M and no extra arg.
86 gccflag=-M
87 depmode=gcc
88fi
89
90if test "$depmode" = dashXmstdout; then
91 # This is just like dashmstdout with a different argument.
92 dashmflag=-xM
93 depmode=dashmstdout
94fi
95
96case "$depmode" in
97gcc3)
98## gcc 3 implements dependency tracking that does exactly what
99## we want. Yay! Note: for some reason libtool 1.4 doesn't like
100## it if -MD -MP comes after the -MF stuff. Hmm.
101 "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
102 stat=$?
103 if test $stat -eq 0; then :
104 else
105 rm -f "$tmpdepfile"
106 exit $stat
107 fi
108 mv "$tmpdepfile" "$depfile"
109 ;;
110
111gcc)
112## There are various ways to get dependency output from gcc. Here's
113## why we pick this rather obscure method:
114## - Don't want to use -MD because we'd like the dependencies to end
115## up in a subdir. Having to rename by hand is ugly.
116## (We might end up doing this anyway to support other compilers.)