depcomp revision 7ce7e03c
1f7ec340bSmacallan#! /bin/sh 2f7ec340bSmacallan# depcomp - compile a program generating dependencies as side-effects 3f7ec340bSmacallan 47ce7e03cSmrgscriptversion=2007-03-29.01 5f7ec340bSmacallan 67ce7e03cSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 77ce7e03cSmrg# Foundation, Inc. 8f7ec340bSmacallan 9f7ec340bSmacallan# This program is free software; you can redistribute it and/or modify 10f7ec340bSmacallan# it under the terms of the GNU General Public License as published by 11f7ec340bSmacallan# the Free Software Foundation; either version 2, or (at your option) 12f7ec340bSmacallan# any later version. 13f7ec340bSmacallan 14f7ec340bSmacallan# This program is distributed in the hope that it will be useful, 15f7ec340bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 16f7ec340bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17f7ec340bSmacallan# GNU General Public License for more details. 18f7ec340bSmacallan 19f7ec340bSmacallan# You should have received a copy of the GNU General Public License 20f7ec340bSmacallan# along with this program; if not, write to the Free Software 21f7ec340bSmacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22f7ec340bSmacallan# 02110-1301, USA. 23f7ec340bSmacallan 24f7ec340bSmacallan# As a special exception to the GNU General Public License, if you 25f7ec340bSmacallan# distribute this file as part of a program that contains a 26f7ec340bSmacallan# configuration script generated by Autoconf, you may include it under 27f7ec340bSmacallan# the same distribution terms that you use for the rest of that program. 28f7ec340bSmacallan 29f7ec340bSmacallan# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 30f7ec340bSmacallan 31f7ec340bSmacallancase $1 in 32f7ec340bSmacallan '') 33f7ec340bSmacallan echo "$0: No command. Try \`$0 --help' for more information." 1>&2 34f7ec340bSmacallan exit 1; 35f7ec340bSmacallan ;; 36f7ec340bSmacallan -h | --h*) 37f7ec340bSmacallan cat <<\EOF 38f7ec340bSmacallanUsage: depcomp [--help] [--version] PROGRAM [ARGS] 39f7ec340bSmacallan 40f7ec340bSmacallanRun PROGRAMS ARGS to compile a file, generating dependencies 41f7ec340bSmacallanas side-effects. 42f7ec340bSmacallan 43f7ec340bSmacallanEnvironment variables: 44f7ec340bSmacallan depmode Dependency tracking mode. 45f7ec340bSmacallan source Source file read by `PROGRAMS ARGS'. 46f7ec340bSmacallan object Object file output by `PROGRAMS ARGS'. 47f7ec340bSmacallan DEPDIR directory where to store dependencies. 48f7ec340bSmacallan depfile Dependency file to output. 49f7ec340bSmacallan tmpdepfile Temporary file to use when outputing dependencies. 50f7ec340bSmacallan libtool Whether libtool is used (yes/no). 51f7ec340bSmacallan 52f7ec340bSmacallanReport bugs to <bug-automake@gnu.org>. 53f7ec340bSmacallanEOF 54f7ec340bSmacallan exit $? 55f7ec340bSmacallan ;; 56f7ec340bSmacallan -v | --v*) 57f7ec340bSmacallan echo "depcomp $scriptversion" 58f7ec340bSmacallan exit $? 59f7ec340bSmacallan ;; 60f7ec340bSmacallanesac 61f7ec340bSmacallan 62f7ec340bSmacallanif test -z "$depmode" || test -z "$source" || test -z "$object"; then 63f7ec340bSmacallan echo "depcomp: Variables source, object and depmode must be set" 1>&2 64f7ec340bSmacallan exit 1 65f7ec340bSmacallanfi 66f7ec340bSmacallan 67f7ec340bSmacallan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 68f7ec340bSmacallandepfile=${depfile-`echo "$object" | 69f7ec340bSmacallan sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 70f7ec340bSmacallantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 71f7ec340bSmacallan 72f7ec340bSmacallanrm -f "$tmpdepfile" 73f7ec340bSmacallan 74f7ec340bSmacallan# Some modes work just like other modes, but use different flags. We 75f7ec340bSmacallan# parameterize here, but still list the modes in the big case below, 76f7ec340bSmacallan# to make depend.m4 easier to write. Note that we *cannot* use a case 77f7ec340bSmacallan# here, because this file can only contain one case statement. 78f7ec340bSmacallanif test "$depmode" = hp; then 79f7ec340bSmacallan # HP compiler uses -M and no extra arg. 80f7ec340bSmacallan gccflag=-M 81f7ec340bSmacallan depmode=gcc 82f7ec340bSmacallanfi 83f7ec340bSmacallan 84f7ec340bSmacallanif test "$depmode" = dashXmstdout; then 85f7ec340bSmacallan # This is just like dashmstdout with a different argument. 86f7ec340bSmacallan dashmflag=-xM 87f7ec340bSmacallan depmode=dashmstdout 88f7ec340bSmacallanfi 89f7ec340bSmacallan 90f7ec340bSmacallancase "$depmode" in 91f7ec340bSmacallangcc3) 92f7ec340bSmacallan## gcc 3 implements dependency tracking that does exactly what 93f7ec340bSmacallan## we want. Yay! Note: for some reason libtool 1.4 doesn't like 94f7ec340bSmacallan## it if -MD -MP comes after the -MF stuff. Hmm. 957ce7e03cSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 967ce7e03cSmrg## the command line argument order; so add the flags where they 977ce7e03cSmrg## appear in depend2.am. Note that the slowdown incurred here 987ce7e03cSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 997ce7e03cSmrg for arg 1007ce7e03cSmrg do 1017ce7e03cSmrg case $arg in 1027ce7e03cSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1037ce7e03cSmrg *) set fnord "$@" "$arg" ;; 1047ce7e03cSmrg esac 1057ce7e03cSmrg shift # fnord 1067ce7e03cSmrg shift # $arg 1077ce7e03cSmrg done 1087ce7e03cSmrg "$@" 109f7ec340bSmacallan stat=$? 110f7ec340bSmacallan if test $stat -eq 0; then : 111f7ec340bSmacallan else 112f7ec340bSmacallan rm -f "$tmpdepfile" 113f7ec340bSmacallan exit $stat 114f7ec340bSmacallan fi 115f7ec340bSmacallan mv "$tmpdepfile" "$depfile" 116f7ec340bSmacallan ;; 117f7ec340bSmacallan 118f7ec340bSmacallangcc) 119f7ec340bSmacallan## There are various ways to get dependency output from gcc. Here's 120f7ec340bSmacallan## why we pick this rather obscure method: 121f7ec340bSmacallan## - Don't want to use -MD because we'd like the dependencies to end 122f7ec340bSmacallan## up in a subdir. Having to rename by hand is ugly. 123f7ec340bSmacallan## (We might end up doing this anyway to support other compilers.) 124f7ec340bSmacallan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 125f7ec340bSmacallan## -MM, not -M (despite what the docs say). 126f7ec340bSmacallan## - Using -M directly means running the compiler twice (even worse 127f7ec340bSmacallan## than renaming). 128f7ec340bSmacallan if test -z "$gccflag"; then 129f7ec340bSmacallan gccflag=-MD, 130f7ec340bSmacallan fi 131f7ec340bSmacallan "$@" -Wp,"$gccflag$tmpdepfile" 132f7ec340bSmacallan stat=$? 133f7ec340bSmacallan if test $stat -eq 0; then : 134f7ec340bSmacallan else 135f7ec340bSmacallan rm -f "$tmpdepfile" 136f7ec340bSmacallan exit $stat 137f7ec340bSmacallan fi 138f7ec340bSmacallan rm -f "$depfile" 139f7ec340bSmacallan echo "$object : \\" > "$depfile" 140f7ec340bSmacallan alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 141f7ec340bSmacallan## The second -e expression handles DOS-style file names with drive letters. 142f7ec340bSmacallan sed -e 's/^[^:]*: / /' \ 143f7ec340bSmacallan -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 144f7ec340bSmacallan## This next piece of magic avoids the `deleted header file' problem. 145f7ec340bSmacallan## The problem is that when a header file which appears in a .P file 146f7ec340bSmacallan## is deleted, the dependency causes make to die (because there is 147f7ec340bSmacallan## typically no way to rebuild the header). We avoid this by adding 148f7ec340bSmacallan## dummy dependencies for each header file. Too bad gcc doesn't do 149f7ec340bSmacallan## this for us directly. 150f7ec340bSmacallan tr ' ' ' 151f7ec340bSmacallan' < "$tmpdepfile" | 152f7ec340bSmacallan## Some versions of gcc put a space before the `:'. On the theory 153f7ec340bSmacallan## that the space means something, we add a space to the output as 154f7ec340bSmacallan## well. 155f7ec340bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 156f7ec340bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 157f7ec340bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 158f7ec340bSmacallan rm -f "$tmpdepfile" 159f7ec340bSmacallan ;; 160f7ec340bSmacallan 161f7ec340bSmacallanhp) 162f7ec340bSmacallan # This case exists only to let depend.m4 do its work. It works by 163f7ec340bSmacallan # looking at the text of this script. This case will never be run, 164f7ec340bSmacallan # since it is checked for above. 165f7ec340bSmacallan exit 1 166f7ec340bSmacallan ;; 167f7ec340bSmacallan 168f7ec340bSmacallansgi) 169f7ec340bSmacallan if test "$libtool" = yes; then 170f7ec340bSmacallan "$@" "-Wp,-MDupdate,$tmpdepfile" 171f7ec340bSmacallan else 172f7ec340bSmacallan "$@" -MDupdate "$tmpdepfile" 173f7ec340bSmacallan fi 174f7ec340bSmacallan stat=$? 175f7ec340bSmacallan if test $stat -eq 0; then : 176f7ec340bSmacallan else 177f7ec340bSmacallan rm -f "$tmpdepfile" 178f7ec340bSmacallan exit $stat 179f7ec340bSmacallan fi 180f7ec340bSmacallan rm -f "$depfile" 181f7ec340bSmacallan 182f7ec340bSmacallan if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 183f7ec340bSmacallan echo "$object : \\" > "$depfile" 184f7ec340bSmacallan 185f7ec340bSmacallan # Clip off the initial element (the dependent). Don't try to be 186f7ec340bSmacallan # clever and replace this with sed code, as IRIX sed won't handle 187f7ec340bSmacallan # lines with more than a fixed number of characters (4096 in 188f7ec340bSmacallan # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 189f7ec340bSmacallan # the IRIX cc adds comments like `#:fec' to the end of the 190f7ec340bSmacallan # dependency line. 191f7ec340bSmacallan tr ' ' ' 192f7ec340bSmacallan' < "$tmpdepfile" \ 193f7ec340bSmacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 194f7ec340bSmacallan tr ' 195f7ec340bSmacallan' ' ' >> $depfile 196f7ec340bSmacallan echo >> $depfile 197f7ec340bSmacallan 198f7ec340bSmacallan # The second pass generates a dummy entry for each header file. 199f7ec340bSmacallan tr ' ' ' 200f7ec340bSmacallan' < "$tmpdepfile" \ 201f7ec340bSmacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 202f7ec340bSmacallan >> $depfile 203f7ec340bSmacallan else 204f7ec340bSmacallan # The sourcefile does not contain any dependencies, so just 205f7ec340bSmacallan # store a dummy comment line, to avoid errors with the Makefile 206f7ec340bSmacallan # "include basename.Plo" scheme. 207f7ec340bSmacallan echo "#dummy" > "$depfile" 208f7ec340bSmacallan fi 209f7ec340bSmacallan rm -f "$tmpdepfile" 210f7ec340bSmacallan ;; 211f7ec340bSmacallan 212f7ec340bSmacallanaix) 213f7ec340bSmacallan # The C for AIX Compiler uses -M and outputs the dependencies 214f7ec340bSmacallan # in a .u file. In older versions, this file always lives in the 215f7ec340bSmacallan # current directory. Also, the AIX compiler puts `$object:' at the 216f7ec340bSmacallan # start of each line; $object doesn't have directory information. 217f7ec340bSmacallan # Version 6 uses the directory in both cases. 2187ce7e03cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2197ce7e03cSmrg test "x$dir" = "x$object" && dir= 2207ce7e03cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 221f7ec340bSmacallan if test "$libtool" = yes; then 2227ce7e03cSmrg tmpdepfile1=$dir$base.u 2237ce7e03cSmrg tmpdepfile2=$base.u 2247ce7e03cSmrg tmpdepfile3=$dir.libs/$base.u 225f7ec340bSmacallan "$@" -Wc,-M 226f7ec340bSmacallan else 2277ce7e03cSmrg tmpdepfile1=$dir$base.u 2287ce7e03cSmrg tmpdepfile2=$dir$base.u 2297ce7e03cSmrg tmpdepfile3=$dir$base.u 230f7ec340bSmacallan "$@" -M 231f7ec340bSmacallan fi 232f7ec340bSmacallan stat=$? 233f7ec340bSmacallan 234f7ec340bSmacallan if test $stat -eq 0; then : 235f7ec340bSmacallan else 2367ce7e03cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 237f7ec340bSmacallan exit $stat 238f7ec340bSmacallan fi 239f7ec340bSmacallan 2407ce7e03cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2417ce7e03cSmrg do 2427ce7e03cSmrg test -f "$tmpdepfile" && break 2437ce7e03cSmrg done 244f7ec340bSmacallan if test -f "$tmpdepfile"; then 245f7ec340bSmacallan # Each line is of the form `foo.o: dependent.h'. 246f7ec340bSmacallan # Do two passes, one to just change these to 247f7ec340bSmacallan # `$object: dependent.h' and one to simply `dependent.h:'. 2487ce7e03cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2497ce7e03cSmrg # That's a tab and a space in the []. 2507ce7e03cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 251f7ec340bSmacallan else 252f7ec340bSmacallan # The sourcefile does not contain any dependencies, so just 253f7ec340bSmacallan # store a dummy comment line, to avoid errors with the Makefile 254f7ec340bSmacallan # "include basename.Plo" scheme. 255f7ec340bSmacallan echo "#dummy" > "$depfile" 256f7ec340bSmacallan fi 257f7ec340bSmacallan rm -f "$tmpdepfile" 258f7ec340bSmacallan ;; 259f7ec340bSmacallan 260f7ec340bSmacallanicc) 261f7ec340bSmacallan # Intel's C compiler understands `-MD -MF file'. However on 262f7ec340bSmacallan # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 263f7ec340bSmacallan # ICC 7.0 will fill foo.d with something like 264f7ec340bSmacallan # foo.o: sub/foo.c 265f7ec340bSmacallan # foo.o: sub/foo.h 266f7ec340bSmacallan # which is wrong. We want: 267f7ec340bSmacallan # sub/foo.o: sub/foo.c 268f7ec340bSmacallan # sub/foo.o: sub/foo.h 269f7ec340bSmacallan # sub/foo.c: 270f7ec340bSmacallan # sub/foo.h: 271f7ec340bSmacallan # ICC 7.1 will output 272f7ec340bSmacallan # foo.o: sub/foo.c sub/foo.h 273f7ec340bSmacallan # and will wrap long lines using \ : 274f7ec340bSmacallan # foo.o: sub/foo.c ... \ 275f7ec340bSmacallan # sub/foo.h ... \ 276f7ec340bSmacallan # ... 277f7ec340bSmacallan 278f7ec340bSmacallan "$@" -MD -MF "$tmpdepfile" 279f7ec340bSmacallan stat=$? 280f7ec340bSmacallan if test $stat -eq 0; then : 281f7ec340bSmacallan else 282f7ec340bSmacallan rm -f "$tmpdepfile" 283f7ec340bSmacallan exit $stat 284f7ec340bSmacallan fi 285f7ec340bSmacallan rm -f "$depfile" 286f7ec340bSmacallan # Each line is of the form `foo.o: dependent.h', 287f7ec340bSmacallan # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 288f7ec340bSmacallan # Do two passes, one to just change these to 289f7ec340bSmacallan # `$object: dependent.h' and one to simply `dependent.h:'. 290f7ec340bSmacallan sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 291f7ec340bSmacallan # Some versions of the HPUX 10.20 sed can't process this invocation 292f7ec340bSmacallan # correctly. Breaking it into two sed invocations is a workaround. 293f7ec340bSmacallan sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 294f7ec340bSmacallan sed -e 's/$/ :/' >> "$depfile" 295f7ec340bSmacallan rm -f "$tmpdepfile" 296f7ec340bSmacallan ;; 297f7ec340bSmacallan 2987ce7e03cSmrghp2) 2997ce7e03cSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3007ce7e03cSmrg # compilers, which have integrated preprocessors. The correct option 3017ce7e03cSmrg # to use with these is +Maked; it writes dependencies to a file named 3027ce7e03cSmrg # 'foo.d', which lands next to the object file, wherever that 3037ce7e03cSmrg # happens to be. 3047ce7e03cSmrg # Much of this is similar to the tru64 case; see comments there. 3057ce7e03cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3067ce7e03cSmrg test "x$dir" = "x$object" && dir= 3077ce7e03cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3087ce7e03cSmrg if test "$libtool" = yes; then 3097ce7e03cSmrg tmpdepfile1=$dir$base.d 3107ce7e03cSmrg tmpdepfile2=$dir.libs/$base.d 3117ce7e03cSmrg "$@" -Wc,+Maked 3127ce7e03cSmrg else 3137ce7e03cSmrg tmpdepfile1=$dir$base.d 3147ce7e03cSmrg tmpdepfile2=$dir$base.d 3157ce7e03cSmrg "$@" +Maked 3167ce7e03cSmrg fi 3177ce7e03cSmrg stat=$? 3187ce7e03cSmrg if test $stat -eq 0; then : 3197ce7e03cSmrg else 3207ce7e03cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3217ce7e03cSmrg exit $stat 3227ce7e03cSmrg fi 3237ce7e03cSmrg 3247ce7e03cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3257ce7e03cSmrg do 3267ce7e03cSmrg test -f "$tmpdepfile" && break 3277ce7e03cSmrg done 3287ce7e03cSmrg if test -f "$tmpdepfile"; then 3297ce7e03cSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3307ce7e03cSmrg # Add `dependent.h:' lines. 3317ce7e03cSmrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3327ce7e03cSmrg else 3337ce7e03cSmrg echo "#dummy" > "$depfile" 3347ce7e03cSmrg fi 3357ce7e03cSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 3367ce7e03cSmrg ;; 3377ce7e03cSmrg 338f7ec340bSmacallantru64) 339f7ec340bSmacallan # The Tru64 compiler uses -MD to generate dependencies as a side 340f7ec340bSmacallan # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 341f7ec340bSmacallan # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 342f7ec340bSmacallan # dependencies in `foo.d' instead, so we check for that too. 343f7ec340bSmacallan # Subdirectories are respected. 344f7ec340bSmacallan dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 345f7ec340bSmacallan test "x$dir" = "x$object" && dir= 346f7ec340bSmacallan base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 347f7ec340bSmacallan 348f7ec340bSmacallan if test "$libtool" = yes; then 349f7ec340bSmacallan # With Tru64 cc, shared objects can also be used to make a 3507ce7e03cSmrg # static library. This mechanism is used in libtool 1.4 series to 351f7ec340bSmacallan # handle both shared and static libraries in a single compilation. 352f7ec340bSmacallan # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 353f7ec340bSmacallan # 354f7ec340bSmacallan # With libtool 1.5 this exception was removed, and libtool now 355f7ec340bSmacallan # generates 2 separate objects for the 2 libraries. These two 3567ce7e03cSmrg # compilations output dependencies in $dir.libs/$base.o.d and 357f7ec340bSmacallan # in $dir$base.o.d. We have to check for both files, because 358f7ec340bSmacallan # one of the two compilations can be disabled. We should prefer 359f7ec340bSmacallan # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 360f7ec340bSmacallan # automatically cleaned when .libs/ is deleted, while ignoring 361f7ec340bSmacallan # the former would cause a distcleancheck panic. 362f7ec340bSmacallan tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 363f7ec340bSmacallan tmpdepfile2=$dir$base.o.d # libtool 1.5 364f7ec340bSmacallan tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 365f7ec340bSmacallan tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 366f7ec340bSmacallan "$@" -Wc,-MD 367f7ec340bSmacallan else 368f7ec340bSmacallan tmpdepfile1=$dir$base.o.d 369f7ec340bSmacallan tmpdepfile2=$dir$base.d 370f7ec340bSmacallan tmpdepfile3=$dir$base.d 371f7ec340bSmacallan tmpdepfile4=$dir$base.d 372f7ec340bSmacallan "$@" -MD 373f7ec340bSmacallan fi 374f7ec340bSmacallan 375f7ec340bSmacallan stat=$? 376f7ec340bSmacallan if test $stat -eq 0; then : 377f7ec340bSmacallan else 378f7ec340bSmacallan rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 379f7ec340bSmacallan exit $stat 380f7ec340bSmacallan fi 381f7ec340bSmacallan 382f7ec340bSmacallan for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 383f7ec340bSmacallan do 384f7ec340bSmacallan test -f "$tmpdepfile" && break 385f7ec340bSmacallan done 386f7ec340bSmacallan if test -f "$tmpdepfile"; then 387f7ec340bSmacallan sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 388f7ec340bSmacallan # That's a tab and a space in the []. 389f7ec340bSmacallan sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 390f7ec340bSmacallan else 391f7ec340bSmacallan echo "#dummy" > "$depfile" 392f7ec340bSmacallan fi 393f7ec340bSmacallan rm -f "$tmpdepfile" 394f7ec340bSmacallan ;; 395f7ec340bSmacallan 396f7ec340bSmacallan#nosideeffect) 397f7ec340bSmacallan # This comment above is used by automake to tell side-effect 398f7ec340bSmacallan # dependency tracking mechanisms from slower ones. 399f7ec340bSmacallan 400f7ec340bSmacallandashmstdout) 401f7ec340bSmacallan # Important note: in order to support this mode, a compiler *must* 402f7ec340bSmacallan # always write the preprocessed file to stdout, regardless of -o. 403f7ec340bSmacallan "$@" || exit $? 404f7ec340bSmacallan 405f7ec340bSmacallan # Remove the call to Libtool. 406f7ec340bSmacallan if test "$libtool" = yes; then 407f7ec340bSmacallan while test $1 != '--mode=compile'; do 408f7ec340bSmacallan shift 409f7ec340bSmacallan done 410f7ec340bSmacallan shift 411f7ec340bSmacallan fi 412f7ec340bSmacallan 413f7ec340bSmacallan # Remove `-o $object'. 414f7ec340bSmacallan IFS=" " 415f7ec340bSmacallan for arg 416f7ec340bSmacallan do 417f7ec340bSmacallan case $arg in 418f7ec340bSmacallan -o) 419f7ec340bSmacallan shift 420f7ec340bSmacallan ;; 421f7ec340bSmacallan $object) 422f7ec340bSmacallan shift 423f7ec340bSmacallan ;; 424f7ec340bSmacallan *) 425f7ec340bSmacallan set fnord "$@" "$arg" 426f7ec340bSmacallan shift # fnord 427f7ec340bSmacallan shift # $arg 428f7ec340bSmacallan ;; 429f7ec340bSmacallan esac 430f7ec340bSmacallan done 431f7ec340bSmacallan 432f7ec340bSmacallan test -z "$dashmflag" && dashmflag=-M 433f7ec340bSmacallan # Require at least two characters before searching for `:' 434f7ec340bSmacallan # in the target name. This is to cope with DOS-style filenames: 435f7ec340bSmacallan # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 436f7ec340bSmacallan "$@" $dashmflag | 437f7ec340bSmacallan sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 438f7ec340bSmacallan rm -f "$depfile" 439f7ec340bSmacallan cat < "$tmpdepfile" > "$depfile" 440f7ec340bSmacallan tr ' ' ' 441f7ec340bSmacallan' < "$tmpdepfile" | \ 442f7ec340bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 443f7ec340bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 444f7ec340bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 445f7ec340bSmacallan rm -f "$tmpdepfile" 446f7ec340bSmacallan ;; 447f7ec340bSmacallan 448f7ec340bSmacallandashXmstdout) 449f7ec340bSmacallan # This case only exists to satisfy depend.m4. It is never actually 450f7ec340bSmacallan # run, as this mode is specially recognized in the preamble. 451f7ec340bSmacallan exit 1 452f7ec340bSmacallan ;; 453f7ec340bSmacallan 454f7ec340bSmacallanmakedepend) 455f7ec340bSmacallan "$@" || exit $? 456f7ec340bSmacallan # Remove any Libtool call 457f7ec340bSmacallan if test "$libtool" = yes; then 458f7ec340bSmacallan while test $1 != '--mode=compile'; do 459f7ec340bSmacallan shift 460f7ec340bSmacallan done 461f7ec340bSmacallan shift 462f7ec340bSmacallan fi 463f7ec340bSmacallan # X makedepend 464f7ec340bSmacallan shift 465f7ec340bSmacallan cleared=no 466f7ec340bSmacallan for arg in "$@"; do 467f7ec340bSmacallan case $cleared in 468f7ec340bSmacallan no) 469f7ec340bSmacallan set ""; shift 470f7ec340bSmacallan cleared=yes ;; 471f7ec340bSmacallan esac 472f7ec340bSmacallan case "$arg" in 473f7ec340bSmacallan -D*|-I*) 474f7ec340bSmacallan set fnord "$@" "$arg"; shift ;; 475f7ec340bSmacallan # Strip any option that makedepend may not understand. Remove 476f7ec340bSmacallan # the object too, otherwise makedepend will parse it as a source file. 477f7ec340bSmacallan -*|$object) 478f7ec340bSmacallan ;; 479f7ec340bSmacallan *) 480f7ec340bSmacallan set fnord "$@" "$arg"; shift ;; 481f7ec340bSmacallan esac 482f7ec340bSmacallan done 483f7ec340bSmacallan obj_suffix="`echo $object | sed 's/^.*\././'`" 484f7ec340bSmacallan touch "$tmpdepfile" 485f7ec340bSmacallan ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 486f7ec340bSmacallan rm -f "$depfile" 487f7ec340bSmacallan cat < "$tmpdepfile" > "$depfile" 488f7ec340bSmacallan sed '1,2d' "$tmpdepfile" | tr ' ' ' 489f7ec340bSmacallan' | \ 490f7ec340bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 491f7ec340bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 492f7ec340bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 493f7ec340bSmacallan rm -f "$tmpdepfile" "$tmpdepfile".bak 494f7ec340bSmacallan ;; 495f7ec340bSmacallan 496f7ec340bSmacallancpp) 497f7ec340bSmacallan # Important note: in order to support this mode, a compiler *must* 498f7ec340bSmacallan # always write the preprocessed file to stdout. 499f7ec340bSmacallan "$@" || exit $? 500f7ec340bSmacallan 501f7ec340bSmacallan # Remove the call to Libtool. 502f7ec340bSmacallan if test "$libtool" = yes; then 503f7ec340bSmacallan while test $1 != '--mode=compile'; do 504f7ec340bSmacallan shift 505f7ec340bSmacallan done 506f7ec340bSmacallan shift 507f7ec340bSmacallan fi 508f7ec340bSmacallan 509f7ec340bSmacallan # Remove `-o $object'. 510f7ec340bSmacallan IFS=" " 511f7ec340bSmacallan for arg 512f7ec340bSmacallan do 513f7ec340bSmacallan case $arg in 514f7ec340bSmacallan -o) 515f7ec340bSmacallan shift 516f7ec340bSmacallan ;; 517f7ec340bSmacallan $object) 518f7ec340bSmacallan shift 519f7ec340bSmacallan ;; 520f7ec340bSmacallan *) 521f7ec340bSmacallan set fnord "$@" "$arg" 522f7ec340bSmacallan shift # fnord 523f7ec340bSmacallan shift # $arg 524f7ec340bSmacallan ;; 525f7ec340bSmacallan esac 526f7ec340bSmacallan done 527f7ec340bSmacallan 528f7ec340bSmacallan "$@" -E | 529f7ec340bSmacallan sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 530f7ec340bSmacallan -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 531f7ec340bSmacallan sed '$ s: \\$::' > "$tmpdepfile" 532f7ec340bSmacallan rm -f "$depfile" 533f7ec340bSmacallan echo "$object : \\" > "$depfile" 534f7ec340bSmacallan cat < "$tmpdepfile" >> "$depfile" 535f7ec340bSmacallan sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 536f7ec340bSmacallan rm -f "$tmpdepfile" 537f7ec340bSmacallan ;; 538f7ec340bSmacallan 539f7ec340bSmacallanmsvisualcpp) 540f7ec340bSmacallan # Important note: in order to support this mode, a compiler *must* 541f7ec340bSmacallan # always write the preprocessed file to stdout, regardless of -o, 542f7ec340bSmacallan # because we must use -o when running libtool. 543f7ec340bSmacallan "$@" || exit $? 544f7ec340bSmacallan IFS=" " 545f7ec340bSmacallan for arg 546f7ec340bSmacallan do 547f7ec340bSmacallan case "$arg" in 548f7ec340bSmacallan "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 549f7ec340bSmacallan set fnord "$@" 550f7ec340bSmacallan shift 551f7ec340bSmacallan shift 552f7ec340bSmacallan ;; 553f7ec340bSmacallan *) 554f7ec340bSmacallan set fnord "$@" "$arg" 555f7ec340bSmacallan shift 556f7ec340bSmacallan shift 557f7ec340bSmacallan ;; 558f7ec340bSmacallan esac 559f7ec340bSmacallan done 560f7ec340bSmacallan "$@" -E | 561f7ec340bSmacallan sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 562f7ec340bSmacallan rm -f "$depfile" 563f7ec340bSmacallan echo "$object : \\" > "$depfile" 564f7ec340bSmacallan . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 565f7ec340bSmacallan echo " " >> "$depfile" 566f7ec340bSmacallan . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 567f7ec340bSmacallan rm -f "$tmpdepfile" 568f7ec340bSmacallan ;; 569f7ec340bSmacallan 570f7ec340bSmacallannone) 571f7ec340bSmacallan exec "$@" 572f7ec340bSmacallan ;; 573f7ec340bSmacallan 574f7ec340bSmacallan*) 575f7ec340bSmacallan echo "Unknown depmode $depmode" 1>&2 576f7ec340bSmacallan exit 1 577f7ec340bSmacallan ;; 578f7ec340bSmacallanesac 579f7ec340bSmacallan 580f7ec340bSmacallanexit 0 581f7ec340bSmacallan 582f7ec340bSmacallan# Local Variables: 583f7ec340bSmacallan# mode: shell-script 584f7ec340bSmacallan# sh-indentation: 2 585f7ec340bSmacallan# eval: (add-hook 'write-file-hooks 'time-stamp) 586f7ec340bSmacallan# time-stamp-start: "scriptversion=" 587f7ec340bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 588f7ec340bSmacallan# time-stamp-end: "$" 589f7ec340bSmacallan# End: 590