depcomp revision 690143cc
1f46a6179Smrg#! /bin/sh 2f46a6179Smrg# depcomp - compile a program generating dependencies as side-effects 3f46a6179Smrg 4690143ccSmrgscriptversion=2009-04-28.21; # UTC 5f46a6179Smrg 6690143ccSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7690143ccSmrg# Software Foundation, Inc. 8f46a6179Smrg 9f46a6179Smrg# This program is free software; you can redistribute it and/or modify 10f46a6179Smrg# it under the terms of the GNU General Public License as published by 11f46a6179Smrg# the Free Software Foundation; either version 2, or (at your option) 12f46a6179Smrg# any later version. 13f46a6179Smrg 14f46a6179Smrg# This program is distributed in the hope that it will be useful, 15f46a6179Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16f46a6179Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17f46a6179Smrg# GNU General Public License for more details. 18f46a6179Smrg 19f46a6179Smrg# You should have received a copy of the GNU General Public License 20690143ccSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21f46a6179Smrg 22f46a6179Smrg# As a special exception to the GNU General Public License, if you 23f46a6179Smrg# distribute this file as part of a program that contains a 24f46a6179Smrg# configuration script generated by Autoconf, you may include it under 25f46a6179Smrg# the same distribution terms that you use for the rest of that program. 26f46a6179Smrg 27f46a6179Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28f46a6179Smrg 29f46a6179Smrgcase $1 in 30f46a6179Smrg '') 31f46a6179Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32f46a6179Smrg exit 1; 33f46a6179Smrg ;; 34f46a6179Smrg -h | --h*) 35f46a6179Smrg cat <<\EOF 36f46a6179SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37f46a6179Smrg 38f46a6179SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39f46a6179Smrgas side-effects. 40f46a6179Smrg 41f46a6179SmrgEnvironment variables: 42f46a6179Smrg depmode Dependency tracking mode. 43f46a6179Smrg source Source file read by `PROGRAMS ARGS'. 44f46a6179Smrg object Object file output by `PROGRAMS ARGS'. 45f46a6179Smrg DEPDIR directory where to store dependencies. 46f46a6179Smrg depfile Dependency file to output. 47f46a6179Smrg tmpdepfile Temporary file to use when outputing dependencies. 48f46a6179Smrg libtool Whether libtool is used (yes/no). 49f46a6179Smrg 50f46a6179SmrgReport bugs to <bug-automake@gnu.org>. 51f46a6179SmrgEOF 52f46a6179Smrg exit $? 53f46a6179Smrg ;; 54f46a6179Smrg -v | --v*) 55f46a6179Smrg echo "depcomp $scriptversion" 56f46a6179Smrg exit $? 57f46a6179Smrg ;; 58f46a6179Smrgesac 59f46a6179Smrg 60f46a6179Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61f46a6179Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62f46a6179Smrg exit 1 63f46a6179Smrgfi 64f46a6179Smrg 65f46a6179Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66f46a6179Smrgdepfile=${depfile-`echo "$object" | 67f46a6179Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68f46a6179Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69f46a6179Smrg 70f46a6179Smrgrm -f "$tmpdepfile" 71f46a6179Smrg 72f46a6179Smrg# Some modes work just like other modes, but use different flags. We 73f46a6179Smrg# parameterize here, but still list the modes in the big case below, 74f46a6179Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75f46a6179Smrg# here, because this file can only contain one case statement. 76f46a6179Smrgif test "$depmode" = hp; then 77f46a6179Smrg # HP compiler uses -M and no extra arg. 78f46a6179Smrg gccflag=-M 79f46a6179Smrg depmode=gcc 80f46a6179Smrgfi 81f46a6179Smrg 82f46a6179Smrgif test "$depmode" = dashXmstdout; then 83f46a6179Smrg # This is just like dashmstdout with a different argument. 84f46a6179Smrg dashmflag=-xM 85f46a6179Smrg depmode=dashmstdout 86f46a6179Smrgfi 87f46a6179Smrg 88690143ccSmrgcygpath_u="cygpath -u -f -" 89690143ccSmrgif test "$depmode" = msvcmsys; then 90690143ccSmrg # This is just like msvisualcpp but w/o cygpath translation. 91690143ccSmrg # Just convert the backslash-escaped backslashes to single forward 92690143ccSmrg # slashes to satisfy depend.m4 93690143ccSmrg cygpath_u="sed s,\\\\\\\\,/,g" 94690143ccSmrg depmode=msvisualcpp 95690143ccSmrgfi 96690143ccSmrg 97f46a6179Smrgcase "$depmode" in 98f46a6179Smrggcc3) 99f46a6179Smrg## gcc 3 implements dependency tracking that does exactly what 100f46a6179Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101f46a6179Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 102f46a6179Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103f46a6179Smrg## the command line argument order; so add the flags where they 104f46a6179Smrg## appear in depend2.am. Note that the slowdown incurred here 105f46a6179Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106f46a6179Smrg for arg 107f46a6179Smrg do 108f46a6179Smrg case $arg in 109f46a6179Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110f46a6179Smrg *) set fnord "$@" "$arg" ;; 111f46a6179Smrg esac 112f46a6179Smrg shift # fnord 113f46a6179Smrg shift # $arg 114f46a6179Smrg done 115f46a6179Smrg "$@" 116f46a6179Smrg stat=$? 117f46a6179Smrg if test $stat -eq 0; then : 118f46a6179Smrg else 119f46a6179Smrg rm -f "$tmpdepfile" 120f46a6179Smrg exit $stat 121f46a6179Smrg fi 122f46a6179Smrg mv "$tmpdepfile" "$depfile" 123f46a6179Smrg ;; 124f46a6179Smrg 125f46a6179Smrggcc) 126f46a6179Smrg## There are various ways to get dependency output from gcc. Here's 127f46a6179Smrg## why we pick this rather obscure method: 128f46a6179Smrg## - Don't want to use -MD because we'd like the dependencies to end 129f46a6179Smrg## up in a subdir. Having to rename by hand is ugly. 130f46a6179Smrg## (We might end up doing this anyway to support other compilers.) 131f46a6179Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132f46a6179Smrg## -MM, not -M (despite what the docs say). 133f46a6179Smrg## - Using -M directly means running the compiler twice (even worse 134f46a6179Smrg## than renaming). 135f46a6179Smrg if test -z "$gccflag"; then 136f46a6179Smrg gccflag=-MD, 137f46a6179Smrg fi 138f46a6179Smrg "$@" -Wp,"$gccflag$tmpdepfile" 139f46a6179Smrg stat=$? 140f46a6179Smrg if test $stat -eq 0; then : 141f46a6179Smrg else 142f46a6179Smrg rm -f "$tmpdepfile" 143f46a6179Smrg exit $stat 144f46a6179Smrg fi 145f46a6179Smrg rm -f "$depfile" 146f46a6179Smrg echo "$object : \\" > "$depfile" 147f46a6179Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148f46a6179Smrg## The second -e expression handles DOS-style file names with drive letters. 149f46a6179Smrg sed -e 's/^[^:]*: / /' \ 150f46a6179Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151f46a6179Smrg## This next piece of magic avoids the `deleted header file' problem. 152f46a6179Smrg## The problem is that when a header file which appears in a .P file 153f46a6179Smrg## is deleted, the dependency causes make to die (because there is 154f46a6179Smrg## typically no way to rebuild the header). We avoid this by adding 155f46a6179Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 156f46a6179Smrg## this for us directly. 157f46a6179Smrg tr ' ' ' 158f46a6179Smrg' < "$tmpdepfile" | 159f46a6179Smrg## Some versions of gcc put a space before the `:'. On the theory 160f46a6179Smrg## that the space means something, we add a space to the output as 161f46a6179Smrg## well. 162f46a6179Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 163f46a6179Smrg## correctly. Breaking it into two sed invocations is a workaround. 164f46a6179Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165f46a6179Smrg rm -f "$tmpdepfile" 166f46a6179Smrg ;; 167f46a6179Smrg 168f46a6179Smrghp) 169f46a6179Smrg # This case exists only to let depend.m4 do its work. It works by 170f46a6179Smrg # looking at the text of this script. This case will never be run, 171f46a6179Smrg # since it is checked for above. 172f46a6179Smrg exit 1 173f46a6179Smrg ;; 174f46a6179Smrg 175f46a6179Smrgsgi) 176f46a6179Smrg if test "$libtool" = yes; then 177f46a6179Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178f46a6179Smrg else 179f46a6179Smrg "$@" -MDupdate "$tmpdepfile" 180f46a6179Smrg fi 181f46a6179Smrg stat=$? 182f46a6179Smrg if test $stat -eq 0; then : 183f46a6179Smrg else 184f46a6179Smrg rm -f "$tmpdepfile" 185f46a6179Smrg exit $stat 186f46a6179Smrg fi 187f46a6179Smrg rm -f "$depfile" 188f46a6179Smrg 189f46a6179Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190f46a6179Smrg echo "$object : \\" > "$depfile" 191f46a6179Smrg 192f46a6179Smrg # Clip off the initial element (the dependent). Don't try to be 193f46a6179Smrg # clever and replace this with sed code, as IRIX sed won't handle 194f46a6179Smrg # lines with more than a fixed number of characters (4096 in 195f46a6179Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196f46a6179Smrg # the IRIX cc adds comments like `#:fec' to the end of the 197f46a6179Smrg # dependency line. 198f46a6179Smrg tr ' ' ' 199f46a6179Smrg' < "$tmpdepfile" \ 200f46a6179Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201f46a6179Smrg tr ' 202690143ccSmrg' ' ' >> "$depfile" 203690143ccSmrg echo >> "$depfile" 204f46a6179Smrg 205f46a6179Smrg # The second pass generates a dummy entry for each header file. 206f46a6179Smrg tr ' ' ' 207f46a6179Smrg' < "$tmpdepfile" \ 208f46a6179Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209690143ccSmrg >> "$depfile" 210f46a6179Smrg else 211f46a6179Smrg # The sourcefile does not contain any dependencies, so just 212f46a6179Smrg # store a dummy comment line, to avoid errors with the Makefile 213f46a6179Smrg # "include basename.Plo" scheme. 214f46a6179Smrg echo "#dummy" > "$depfile" 215f46a6179Smrg fi 216f46a6179Smrg rm -f "$tmpdepfile" 217f46a6179Smrg ;; 218f46a6179Smrg 219f46a6179Smrgaix) 220f46a6179Smrg # The C for AIX Compiler uses -M and outputs the dependencies 221f46a6179Smrg # in a .u file. In older versions, this file always lives in the 222f46a6179Smrg # current directory. Also, the AIX compiler puts `$object:' at the 223f46a6179Smrg # start of each line; $object doesn't have directory information. 224f46a6179Smrg # Version 6 uses the directory in both cases. 225f46a6179Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226f46a6179Smrg test "x$dir" = "x$object" && dir= 227f46a6179Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228f46a6179Smrg if test "$libtool" = yes; then 229f46a6179Smrg tmpdepfile1=$dir$base.u 230f46a6179Smrg tmpdepfile2=$base.u 231f46a6179Smrg tmpdepfile3=$dir.libs/$base.u 232f46a6179Smrg "$@" -Wc,-M 233f46a6179Smrg else 234f46a6179Smrg tmpdepfile1=$dir$base.u 235f46a6179Smrg tmpdepfile2=$dir$base.u 236f46a6179Smrg tmpdepfile3=$dir$base.u 237f46a6179Smrg "$@" -M 238f46a6179Smrg fi 239f46a6179Smrg stat=$? 240f46a6179Smrg 241f46a6179Smrg if test $stat -eq 0; then : 242f46a6179Smrg else 243f46a6179Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244f46a6179Smrg exit $stat 245f46a6179Smrg fi 246f46a6179Smrg 247f46a6179Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248f46a6179Smrg do 249f46a6179Smrg test -f "$tmpdepfile" && break 250f46a6179Smrg done 251f46a6179Smrg if test -f "$tmpdepfile"; then 252f46a6179Smrg # Each line is of the form `foo.o: dependent.h'. 253f46a6179Smrg # Do two passes, one to just change these to 254f46a6179Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 255f46a6179Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256f46a6179Smrg # That's a tab and a space in the []. 257f46a6179Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258f46a6179Smrg else 259f46a6179Smrg # The sourcefile does not contain any dependencies, so just 260f46a6179Smrg # store a dummy comment line, to avoid errors with the Makefile 261f46a6179Smrg # "include basename.Plo" scheme. 262f46a6179Smrg echo "#dummy" > "$depfile" 263f46a6179Smrg fi 264f46a6179Smrg rm -f "$tmpdepfile" 265f46a6179Smrg ;; 266f46a6179Smrg 267f46a6179Smrgicc) 268f46a6179Smrg # Intel's C compiler understands `-MD -MF file'. However on 269f46a6179Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270f46a6179Smrg # ICC 7.0 will fill foo.d with something like 271f46a6179Smrg # foo.o: sub/foo.c 272f46a6179Smrg # foo.o: sub/foo.h 273f46a6179Smrg # which is wrong. We want: 274f46a6179Smrg # sub/foo.o: sub/foo.c 275f46a6179Smrg # sub/foo.o: sub/foo.h 276f46a6179Smrg # sub/foo.c: 277f46a6179Smrg # sub/foo.h: 278f46a6179Smrg # ICC 7.1 will output 279f46a6179Smrg # foo.o: sub/foo.c sub/foo.h 280f46a6179Smrg # and will wrap long lines using \ : 281f46a6179Smrg # foo.o: sub/foo.c ... \ 282f46a6179Smrg # sub/foo.h ... \ 283f46a6179Smrg # ... 284f46a6179Smrg 285f46a6179Smrg "$@" -MD -MF "$tmpdepfile" 286f46a6179Smrg stat=$? 287f46a6179Smrg if test $stat -eq 0; then : 288f46a6179Smrg else 289f46a6179Smrg rm -f "$tmpdepfile" 290f46a6179Smrg exit $stat 291f46a6179Smrg fi 292f46a6179Smrg rm -f "$depfile" 293f46a6179Smrg # Each line is of the form `foo.o: dependent.h', 294f46a6179Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295f46a6179Smrg # Do two passes, one to just change these to 296f46a6179Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 297f46a6179Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298f46a6179Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 299f46a6179Smrg # correctly. Breaking it into two sed invocations is a workaround. 300f46a6179Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301f46a6179Smrg sed -e 's/$/ :/' >> "$depfile" 302f46a6179Smrg rm -f "$tmpdepfile" 303f46a6179Smrg ;; 304f46a6179Smrg 305f46a6179Smrghp2) 306f46a6179Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307f46a6179Smrg # compilers, which have integrated preprocessors. The correct option 308f46a6179Smrg # to use with these is +Maked; it writes dependencies to a file named 309f46a6179Smrg # 'foo.d', which lands next to the object file, wherever that 310f46a6179Smrg # happens to be. 311f46a6179Smrg # Much of this is similar to the tru64 case; see comments there. 312f46a6179Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313f46a6179Smrg test "x$dir" = "x$object" && dir= 314f46a6179Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315f46a6179Smrg if test "$libtool" = yes; then 316f46a6179Smrg tmpdepfile1=$dir$base.d 317f46a6179Smrg tmpdepfile2=$dir.libs/$base.d 318f46a6179Smrg "$@" -Wc,+Maked 319f46a6179Smrg else 320f46a6179Smrg tmpdepfile1=$dir$base.d 321f46a6179Smrg tmpdepfile2=$dir$base.d 322f46a6179Smrg "$@" +Maked 323f46a6179Smrg fi 324f46a6179Smrg stat=$? 325f46a6179Smrg if test $stat -eq 0; then : 326f46a6179Smrg else 327f46a6179Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 328f46a6179Smrg exit $stat 329f46a6179Smrg fi 330f46a6179Smrg 331f46a6179Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332f46a6179Smrg do 333f46a6179Smrg test -f "$tmpdepfile" && break 334f46a6179Smrg done 335f46a6179Smrg if test -f "$tmpdepfile"; then 336f46a6179Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337f46a6179Smrg # Add `dependent.h:' lines. 338690143ccSmrg sed -ne '2,${ 339690143ccSmrg s/^ *// 340690143ccSmrg s/ \\*$// 341690143ccSmrg s/$/:/ 342690143ccSmrg p 343690143ccSmrg }' "$tmpdepfile" >> "$depfile" 344f46a6179Smrg else 345f46a6179Smrg echo "#dummy" > "$depfile" 346f46a6179Smrg fi 347f46a6179Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 348f46a6179Smrg ;; 349f46a6179Smrg 350f46a6179Smrgtru64) 351f46a6179Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 352f46a6179Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353f46a6179Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354f46a6179Smrg # dependencies in `foo.d' instead, so we check for that too. 355f46a6179Smrg # Subdirectories are respected. 356f46a6179Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357f46a6179Smrg test "x$dir" = "x$object" && dir= 358f46a6179Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359f46a6179Smrg 360f46a6179Smrg if test "$libtool" = yes; then 361f46a6179Smrg # With Tru64 cc, shared objects can also be used to make a 362f46a6179Smrg # static library. This mechanism is used in libtool 1.4 series to 363f46a6179Smrg # handle both shared and static libraries in a single compilation. 364f46a6179Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365f46a6179Smrg # 366f46a6179Smrg # With libtool 1.5 this exception was removed, and libtool now 367f46a6179Smrg # generates 2 separate objects for the 2 libraries. These two 368f46a6179Smrg # compilations output dependencies in $dir.libs/$base.o.d and 369f46a6179Smrg # in $dir$base.o.d. We have to check for both files, because 370f46a6179Smrg # one of the two compilations can be disabled. We should prefer 371f46a6179Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372f46a6179Smrg # automatically cleaned when .libs/ is deleted, while ignoring 373f46a6179Smrg # the former would cause a distcleancheck panic. 374f46a6179Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375f46a6179Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376f46a6179Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377f46a6179Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378f46a6179Smrg "$@" -Wc,-MD 379f46a6179Smrg else 380f46a6179Smrg tmpdepfile1=$dir$base.o.d 381f46a6179Smrg tmpdepfile2=$dir$base.d 382f46a6179Smrg tmpdepfile3=$dir$base.d 383f46a6179Smrg tmpdepfile4=$dir$base.d 384f46a6179Smrg "$@" -MD 385f46a6179Smrg fi 386f46a6179Smrg 387f46a6179Smrg stat=$? 388f46a6179Smrg if test $stat -eq 0; then : 389f46a6179Smrg else 390f46a6179Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391f46a6179Smrg exit $stat 392f46a6179Smrg fi 393f46a6179Smrg 394f46a6179Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395f46a6179Smrg do 396f46a6179Smrg test -f "$tmpdepfile" && break 397f46a6179Smrg done 398f46a6179Smrg if test -f "$tmpdepfile"; then 399f46a6179Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400f46a6179Smrg # That's a tab and a space in the []. 401f46a6179Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402f46a6179Smrg else 403f46a6179Smrg echo "#dummy" > "$depfile" 404f46a6179Smrg fi 405f46a6179Smrg rm -f "$tmpdepfile" 406f46a6179Smrg ;; 407f46a6179Smrg 408f46a6179Smrg#nosideeffect) 409f46a6179Smrg # This comment above is used by automake to tell side-effect 410f46a6179Smrg # dependency tracking mechanisms from slower ones. 411f46a6179Smrg 412f46a6179Smrgdashmstdout) 413f46a6179Smrg # Important note: in order to support this mode, a compiler *must* 414f46a6179Smrg # always write the preprocessed file to stdout, regardless of -o. 415f46a6179Smrg "$@" || exit $? 416f46a6179Smrg 417f46a6179Smrg # Remove the call to Libtool. 418f46a6179Smrg if test "$libtool" = yes; then 419690143ccSmrg while test "X$1" != 'X--mode=compile'; do 420f46a6179Smrg shift 421f46a6179Smrg done 422f46a6179Smrg shift 423f46a6179Smrg fi 424f46a6179Smrg 425f46a6179Smrg # Remove `-o $object'. 426f46a6179Smrg IFS=" " 427f46a6179Smrg for arg 428f46a6179Smrg do 429f46a6179Smrg case $arg in 430f46a6179Smrg -o) 431f46a6179Smrg shift 432f46a6179Smrg ;; 433f46a6179Smrg $object) 434f46a6179Smrg shift 435f46a6179Smrg ;; 436f46a6179Smrg *) 437f46a6179Smrg set fnord "$@" "$arg" 438f46a6179Smrg shift # fnord 439f46a6179Smrg shift # $arg 440f46a6179Smrg ;; 441f46a6179Smrg esac 442f46a6179Smrg done 443f46a6179Smrg 444f46a6179Smrg test -z "$dashmflag" && dashmflag=-M 445f46a6179Smrg # Require at least two characters before searching for `:' 446f46a6179Smrg # in the target name. This is to cope with DOS-style filenames: 447f46a6179Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448f46a6179Smrg "$@" $dashmflag | 449f46a6179Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450f46a6179Smrg rm -f "$depfile" 451f46a6179Smrg cat < "$tmpdepfile" > "$depfile" 452f46a6179Smrg tr ' ' ' 453f46a6179Smrg' < "$tmpdepfile" | \ 454f46a6179Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 455f46a6179Smrg## correctly. Breaking it into two sed invocations is a workaround. 456f46a6179Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457f46a6179Smrg rm -f "$tmpdepfile" 458f46a6179Smrg ;; 459f46a6179Smrg 460f46a6179SmrgdashXmstdout) 461f46a6179Smrg # This case only exists to satisfy depend.m4. It is never actually 462f46a6179Smrg # run, as this mode is specially recognized in the preamble. 463f46a6179Smrg exit 1 464f46a6179Smrg ;; 465f46a6179Smrg 466f46a6179Smrgmakedepend) 467f46a6179Smrg "$@" || exit $? 468f46a6179Smrg # Remove any Libtool call 469f46a6179Smrg if test "$libtool" = yes; then 470690143ccSmrg while test "X$1" != 'X--mode=compile'; do 471f46a6179Smrg shift 472f46a6179Smrg done 473f46a6179Smrg shift 474f46a6179Smrg fi 475f46a6179Smrg # X makedepend 476f46a6179Smrg shift 477690143ccSmrg cleared=no eat=no 478690143ccSmrg for arg 479690143ccSmrg do 480f46a6179Smrg case $cleared in 481f46a6179Smrg no) 482f46a6179Smrg set ""; shift 483f46a6179Smrg cleared=yes ;; 484f46a6179Smrg esac 485690143ccSmrg if test $eat = yes; then 486690143ccSmrg eat=no 487690143ccSmrg continue 488690143ccSmrg fi 489f46a6179Smrg case "$arg" in 490f46a6179Smrg -D*|-I*) 491f46a6179Smrg set fnord "$@" "$arg"; shift ;; 492f46a6179Smrg # Strip any option that makedepend may not understand. Remove 493f46a6179Smrg # the object too, otherwise makedepend will parse it as a source file. 494690143ccSmrg -arch) 495690143ccSmrg eat=yes ;; 496f46a6179Smrg -*|$object) 497f46a6179Smrg ;; 498f46a6179Smrg *) 499f46a6179Smrg set fnord "$@" "$arg"; shift ;; 500f46a6179Smrg esac 501f46a6179Smrg done 502690143ccSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503f46a6179Smrg touch "$tmpdepfile" 504f46a6179Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505f46a6179Smrg rm -f "$depfile" 506f46a6179Smrg cat < "$tmpdepfile" > "$depfile" 507f46a6179Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508f46a6179Smrg' | \ 509f46a6179Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 510f46a6179Smrg## correctly. Breaking it into two sed invocations is a workaround. 511f46a6179Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512f46a6179Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513f46a6179Smrg ;; 514f46a6179Smrg 515f46a6179Smrgcpp) 516f46a6179Smrg # Important note: in order to support this mode, a compiler *must* 517f46a6179Smrg # always write the preprocessed file to stdout. 518f46a6179Smrg "$@" || exit $? 519f46a6179Smrg 520f46a6179Smrg # Remove the call to Libtool. 521f46a6179Smrg if test "$libtool" = yes; then 522690143ccSmrg while test "X$1" != 'X--mode=compile'; do 523f46a6179Smrg shift 524f46a6179Smrg done 525f46a6179Smrg shift 526f46a6179Smrg fi 527f46a6179Smrg 528f46a6179Smrg # Remove `-o $object'. 529f46a6179Smrg IFS=" " 530f46a6179Smrg for arg 531f46a6179Smrg do 532f46a6179Smrg case $arg in 533f46a6179Smrg -o) 534f46a6179Smrg shift 535f46a6179Smrg ;; 536f46a6179Smrg $object) 537f46a6179Smrg shift 538f46a6179Smrg ;; 539f46a6179Smrg *) 540f46a6179Smrg set fnord "$@" "$arg" 541f46a6179Smrg shift # fnord 542f46a6179Smrg shift # $arg 543f46a6179Smrg ;; 544f46a6179Smrg esac 545f46a6179Smrg done 546f46a6179Smrg 547f46a6179Smrg "$@" -E | 548f46a6179Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549f46a6179Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550f46a6179Smrg sed '$ s: \\$::' > "$tmpdepfile" 551f46a6179Smrg rm -f "$depfile" 552f46a6179Smrg echo "$object : \\" > "$depfile" 553f46a6179Smrg cat < "$tmpdepfile" >> "$depfile" 554f46a6179Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555f46a6179Smrg rm -f "$tmpdepfile" 556f46a6179Smrg ;; 557f46a6179Smrg 558f46a6179Smrgmsvisualcpp) 559f46a6179Smrg # Important note: in order to support this mode, a compiler *must* 560690143ccSmrg # always write the preprocessed file to stdout. 561f46a6179Smrg "$@" || exit $? 562690143ccSmrg 563690143ccSmrg # Remove the call to Libtool. 564690143ccSmrg if test "$libtool" = yes; then 565690143ccSmrg while test "X$1" != 'X--mode=compile'; do 566690143ccSmrg shift 567690143ccSmrg done 568690143ccSmrg shift 569690143ccSmrg fi 570690143ccSmrg 571f46a6179Smrg IFS=" " 572f46a6179Smrg for arg 573f46a6179Smrg do 574f46a6179Smrg case "$arg" in 575690143ccSmrg -o) 576690143ccSmrg shift 577690143ccSmrg ;; 578690143ccSmrg $object) 579690143ccSmrg shift 580690143ccSmrg ;; 581f46a6179Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582f46a6179Smrg set fnord "$@" 583f46a6179Smrg shift 584f46a6179Smrg shift 585f46a6179Smrg ;; 586f46a6179Smrg *) 587f46a6179Smrg set fnord "$@" "$arg" 588f46a6179Smrg shift 589f46a6179Smrg shift 590f46a6179Smrg ;; 591f46a6179Smrg esac 592f46a6179Smrg done 593690143ccSmrg "$@" -E 2>/dev/null | 594690143ccSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595f46a6179Smrg rm -f "$depfile" 596f46a6179Smrg echo "$object : \\" > "$depfile" 597690143ccSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598f46a6179Smrg echo " " >> "$depfile" 599690143ccSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600f46a6179Smrg rm -f "$tmpdepfile" 601f46a6179Smrg ;; 602f46a6179Smrg 603690143ccSmrgmsvcmsys) 604690143ccSmrg # This case exists only to let depend.m4 do its work. It works by 605690143ccSmrg # looking at the text of this script. This case will never be run, 606690143ccSmrg # since it is checked for above. 607690143ccSmrg exit 1 608690143ccSmrg ;; 609690143ccSmrg 610f46a6179Smrgnone) 611f46a6179Smrg exec "$@" 612f46a6179Smrg ;; 613f46a6179Smrg 614f46a6179Smrg*) 615f46a6179Smrg echo "Unknown depmode $depmode" 1>&2 616f46a6179Smrg exit 1 617f46a6179Smrg ;; 618f46a6179Smrgesac 619f46a6179Smrg 620f46a6179Smrgexit 0 621f46a6179Smrg 622f46a6179Smrg# Local Variables: 623f46a6179Smrg# mode: shell-script 624f46a6179Smrg# sh-indentation: 2 625f46a6179Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626f46a6179Smrg# time-stamp-start: "scriptversion=" 627f46a6179Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628690143ccSmrg# time-stamp-time-zone: "UTC" 629690143ccSmrg# time-stamp-end: "; # UTC" 630f46a6179Smrg# End: 631