depcomp revision f220fa62
1f220fa62Smrg#! /bin/sh 2f220fa62Smrg# depcomp - compile a program generating dependencies as side-effects 3f220fa62Smrg 4f220fa62Smrgscriptversion=2012-03-27.16; # UTC 5f220fa62Smrg 6f220fa62Smrg# Copyright (C) 1999-2012 Free Software Foundation, Inc. 7f220fa62Smrg 8f220fa62Smrg# This program is free software; you can redistribute it and/or modify 9f220fa62Smrg# it under the terms of the GNU General Public License as published by 10f220fa62Smrg# the Free Software Foundation; either version 2, or (at your option) 11f220fa62Smrg# any later version. 12f220fa62Smrg 13f220fa62Smrg# This program is distributed in the hope that it will be useful, 14f220fa62Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15f220fa62Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16f220fa62Smrg# GNU General Public License for more details. 17f220fa62Smrg 18f220fa62Smrg# You should have received a copy of the GNU General Public License 19f220fa62Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 20f220fa62Smrg 21f220fa62Smrg# As a special exception to the GNU General Public License, if you 22f220fa62Smrg# distribute this file as part of a program that contains a 23f220fa62Smrg# configuration script generated by Autoconf, you may include it under 24f220fa62Smrg# the same distribution terms that you use for the rest of that program. 25f220fa62Smrg 26f220fa62Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 27f220fa62Smrg 28f220fa62Smrgcase $1 in 29f220fa62Smrg '') 30f220fa62Smrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 31f220fa62Smrg exit 1; 32f220fa62Smrg ;; 33f220fa62Smrg -h | --h*) 34f220fa62Smrg cat <<\EOF 35f220fa62SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 36f220fa62Smrg 37f220fa62SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 38f220fa62Smrgas side-effects. 39f220fa62Smrg 40f220fa62SmrgEnvironment variables: 41f220fa62Smrg depmode Dependency tracking mode. 42f220fa62Smrg source Source file read by 'PROGRAMS ARGS'. 43f220fa62Smrg object Object file output by 'PROGRAMS ARGS'. 44f220fa62Smrg DEPDIR directory where to store dependencies. 45f220fa62Smrg depfile Dependency file to output. 46f220fa62Smrg tmpdepfile Temporary file to use when outputting dependencies. 47f220fa62Smrg libtool Whether libtool is used (yes/no). 48f220fa62Smrg 49f220fa62SmrgReport bugs to <bug-automake@gnu.org>. 50f220fa62SmrgEOF 51f220fa62Smrg exit $? 52f220fa62Smrg ;; 53f220fa62Smrg -v | --v*) 54f220fa62Smrg echo "depcomp $scriptversion" 55f220fa62Smrg exit $? 56f220fa62Smrg ;; 57f220fa62Smrgesac 58f220fa62Smrg 59f220fa62Smrg# A tabulation character. 60f220fa62Smrgtab=' ' 61f220fa62Smrg# A newline character. 62f220fa62Smrgnl=' 63f220fa62Smrg' 64f220fa62Smrg 65f220fa62Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 66f220fa62Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 67f220fa62Smrg exit 1 68f220fa62Smrgfi 69f220fa62Smrg 70f220fa62Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 71f220fa62Smrgdepfile=${depfile-`echo "$object" | 72f220fa62Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 73f220fa62Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 74f220fa62Smrg 75f220fa62Smrgrm -f "$tmpdepfile" 76f220fa62Smrg 77f220fa62Smrg# Some modes work just like other modes, but use different flags. We 78f220fa62Smrg# parameterize here, but still list the modes in the big case below, 79f220fa62Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 80f220fa62Smrg# here, because this file can only contain one case statement. 81f220fa62Smrgif test "$depmode" = hp; then 82f220fa62Smrg # HP compiler uses -M and no extra arg. 83f220fa62Smrg gccflag=-M 84f220fa62Smrg depmode=gcc 85f220fa62Smrgfi 86f220fa62Smrg 87f220fa62Smrgif test "$depmode" = dashXmstdout; then 88f220fa62Smrg # This is just like dashmstdout with a different argument. 89f220fa62Smrg dashmflag=-xM 90f220fa62Smrg depmode=dashmstdout 91f220fa62Smrgfi 92f220fa62Smrg 93f220fa62Smrgcygpath_u="cygpath -u -f -" 94f220fa62Smrgif test "$depmode" = msvcmsys; then 95f220fa62Smrg # This is just like msvisualcpp but w/o cygpath translation. 96f220fa62Smrg # Just convert the backslash-escaped backslashes to single forward 97f220fa62Smrg # slashes to satisfy depend.m4 98f220fa62Smrg cygpath_u='sed s,\\\\,/,g' 99f220fa62Smrg depmode=msvisualcpp 100f220fa62Smrgfi 101f220fa62Smrg 102f220fa62Smrgif test "$depmode" = msvc7msys; then 103f220fa62Smrg # This is just like msvc7 but w/o cygpath translation. 104f220fa62Smrg # Just convert the backslash-escaped backslashes to single forward 105f220fa62Smrg # slashes to satisfy depend.m4 106f220fa62Smrg cygpath_u='sed s,\\\\,/,g' 107f220fa62Smrg depmode=msvc7 108f220fa62Smrgfi 109f220fa62Smrg 110f220fa62Smrgif test "$depmode" = xlc; then 111f220fa62Smrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. 112f220fa62Smrg gccflag=-qmakedep=gcc,-MF 113f220fa62Smrg depmode=gcc 114f220fa62Smrgfi 115f220fa62Smrg 116f220fa62Smrgcase "$depmode" in 117f220fa62Smrggcc3) 118f220fa62Smrg## gcc 3 implements dependency tracking that does exactly what 119f220fa62Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 120f220fa62Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 121f220fa62Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 122f220fa62Smrg## the command line argument order; so add the flags where they 123f220fa62Smrg## appear in depend2.am. Note that the slowdown incurred here 124f220fa62Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 125f220fa62Smrg for arg 126f220fa62Smrg do 127f220fa62Smrg case $arg in 128f220fa62Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 129f220fa62Smrg *) set fnord "$@" "$arg" ;; 130f220fa62Smrg esac 131f220fa62Smrg shift # fnord 132f220fa62Smrg shift # $arg 133f220fa62Smrg done 134f220fa62Smrg "$@" 135f220fa62Smrg stat=$? 136f220fa62Smrg if test $stat -eq 0; then : 137f220fa62Smrg else 138f220fa62Smrg rm -f "$tmpdepfile" 139f220fa62Smrg exit $stat 140f220fa62Smrg fi 141f220fa62Smrg mv "$tmpdepfile" "$depfile" 142f220fa62Smrg ;; 143f220fa62Smrg 144f220fa62Smrggcc) 145f220fa62Smrg## There are various ways to get dependency output from gcc. Here's 146f220fa62Smrg## why we pick this rather obscure method: 147f220fa62Smrg## - Don't want to use -MD because we'd like the dependencies to end 148f220fa62Smrg## up in a subdir. Having to rename by hand is ugly. 149f220fa62Smrg## (We might end up doing this anyway to support other compilers.) 150f220fa62Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 151f220fa62Smrg## -MM, not -M (despite what the docs say). 152f220fa62Smrg## - Using -M directly means running the compiler twice (even worse 153f220fa62Smrg## than renaming). 154f220fa62Smrg if test -z "$gccflag"; then 155f220fa62Smrg gccflag=-MD, 156f220fa62Smrg fi 157f220fa62Smrg "$@" -Wp,"$gccflag$tmpdepfile" 158f220fa62Smrg stat=$? 159f220fa62Smrg if test $stat -eq 0; then : 160f220fa62Smrg else 161f220fa62Smrg rm -f "$tmpdepfile" 162f220fa62Smrg exit $stat 163f220fa62Smrg fi 164f220fa62Smrg rm -f "$depfile" 165f220fa62Smrg echo "$object : \\" > "$depfile" 166f220fa62Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 167f220fa62Smrg## The second -e expression handles DOS-style file names with drive letters. 168f220fa62Smrg sed -e 's/^[^:]*: / /' \ 169f220fa62Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 170f220fa62Smrg## This next piece of magic avoids the "deleted header file" problem. 171f220fa62Smrg## The problem is that when a header file which appears in a .P file 172f220fa62Smrg## is deleted, the dependency causes make to die (because there is 173f220fa62Smrg## typically no way to rebuild the header). We avoid this by adding 174f220fa62Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 175f220fa62Smrg## this for us directly. 176f220fa62Smrg tr ' ' "$nl" < "$tmpdepfile" | 177f220fa62Smrg## Some versions of gcc put a space before the ':'. On the theory 178f220fa62Smrg## that the space means something, we add a space to the output as 179f220fa62Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 180f220fa62Smrg## to the object. Take care to not repeat it in the output. 181f220fa62Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 182f220fa62Smrg## correctly. Breaking it into two sed invocations is a workaround. 183f220fa62Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 184f220fa62Smrg | sed -e 's/$/ :/' >> "$depfile" 185f220fa62Smrg rm -f "$tmpdepfile" 186f220fa62Smrg ;; 187f220fa62Smrg 188f220fa62Smrghp) 189f220fa62Smrg # This case exists only to let depend.m4 do its work. It works by 190f220fa62Smrg # looking at the text of this script. This case will never be run, 191f220fa62Smrg # since it is checked for above. 192f220fa62Smrg exit 1 193f220fa62Smrg ;; 194f220fa62Smrg 195f220fa62Smrgsgi) 196f220fa62Smrg if test "$libtool" = yes; then 197f220fa62Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 198f220fa62Smrg else 199f220fa62Smrg "$@" -MDupdate "$tmpdepfile" 200f220fa62Smrg fi 201f220fa62Smrg stat=$? 202f220fa62Smrg if test $stat -eq 0; then : 203f220fa62Smrg else 204f220fa62Smrg rm -f "$tmpdepfile" 205f220fa62Smrg exit $stat 206f220fa62Smrg fi 207f220fa62Smrg rm -f "$depfile" 208f220fa62Smrg 209f220fa62Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 210f220fa62Smrg echo "$object : \\" > "$depfile" 211f220fa62Smrg 212f220fa62Smrg # Clip off the initial element (the dependent). Don't try to be 213f220fa62Smrg # clever and replace this with sed code, as IRIX sed won't handle 214f220fa62Smrg # lines with more than a fixed number of characters (4096 in 215f220fa62Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 216f220fa62Smrg # the IRIX cc adds comments like '#:fec' to the end of the 217f220fa62Smrg # dependency line. 218f220fa62Smrg tr ' ' "$nl" < "$tmpdepfile" \ 219f220fa62Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 220f220fa62Smrg tr "$nl" ' ' >> "$depfile" 221f220fa62Smrg echo >> "$depfile" 222f220fa62Smrg 223f220fa62Smrg # The second pass generates a dummy entry for each header file. 224f220fa62Smrg tr ' ' "$nl" < "$tmpdepfile" \ 225f220fa62Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 226f220fa62Smrg >> "$depfile" 227f220fa62Smrg else 228f220fa62Smrg # The sourcefile does not contain any dependencies, so just 229f220fa62Smrg # store a dummy comment line, to avoid errors with the Makefile 230f220fa62Smrg # "include basename.Plo" scheme. 231f220fa62Smrg echo "#dummy" > "$depfile" 232f220fa62Smrg fi 233f220fa62Smrg rm -f "$tmpdepfile" 234f220fa62Smrg ;; 235f220fa62Smrg 236f220fa62Smrgxlc) 237f220fa62Smrg # This case exists only to let depend.m4 do its work. It works by 238f220fa62Smrg # looking at the text of this script. This case will never be run, 239f220fa62Smrg # since it is checked for above. 240f220fa62Smrg exit 1 241f220fa62Smrg ;; 242f220fa62Smrg 243f220fa62Smrgaix) 244f220fa62Smrg # The C for AIX Compiler uses -M and outputs the dependencies 245f220fa62Smrg # in a .u file. In older versions, this file always lives in the 246f220fa62Smrg # current directory. Also, the AIX compiler puts '$object:' at the 247f220fa62Smrg # start of each line; $object doesn't have directory information. 248f220fa62Smrg # Version 6 uses the directory in both cases. 249f220fa62Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 250f220fa62Smrg test "x$dir" = "x$object" && dir= 251f220fa62Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 252f220fa62Smrg if test "$libtool" = yes; then 253f220fa62Smrg tmpdepfile1=$dir$base.u 254f220fa62Smrg tmpdepfile2=$base.u 255f220fa62Smrg tmpdepfile3=$dir.libs/$base.u 256f220fa62Smrg "$@" -Wc,-M 257f220fa62Smrg else 258f220fa62Smrg tmpdepfile1=$dir$base.u 259f220fa62Smrg tmpdepfile2=$dir$base.u 260f220fa62Smrg tmpdepfile3=$dir$base.u 261f220fa62Smrg "$@" -M 262f220fa62Smrg fi 263f220fa62Smrg stat=$? 264f220fa62Smrg 265f220fa62Smrg if test $stat -eq 0; then : 266f220fa62Smrg else 267f220fa62Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 268f220fa62Smrg exit $stat 269f220fa62Smrg fi 270f220fa62Smrg 271f220fa62Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 272f220fa62Smrg do 273f220fa62Smrg test -f "$tmpdepfile" && break 274f220fa62Smrg done 275f220fa62Smrg if test -f "$tmpdepfile"; then 276f220fa62Smrg # Each line is of the form 'foo.o: dependent.h'. 277f220fa62Smrg # Do two passes, one to just change these to 278f220fa62Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 279f220fa62Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 280f220fa62Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 281f220fa62Smrg else 282f220fa62Smrg # The sourcefile does not contain any dependencies, so just 283f220fa62Smrg # store a dummy comment line, to avoid errors with the Makefile 284f220fa62Smrg # "include basename.Plo" scheme. 285f220fa62Smrg echo "#dummy" > "$depfile" 286f220fa62Smrg fi 287f220fa62Smrg rm -f "$tmpdepfile" 288f220fa62Smrg ;; 289f220fa62Smrg 290f220fa62Smrgicc) 291f220fa62Smrg # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. 292f220fa62Smrg # However on 293f220fa62Smrg # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c 294f220fa62Smrg # ICC 7.0 will fill foo.d with something like 295f220fa62Smrg # foo.o: sub/foo.c 296f220fa62Smrg # foo.o: sub/foo.h 297f220fa62Smrg # which is wrong. We want 298f220fa62Smrg # sub/foo.o: sub/foo.c 299f220fa62Smrg # sub/foo.o: sub/foo.h 300f220fa62Smrg # sub/foo.c: 301f220fa62Smrg # sub/foo.h: 302f220fa62Smrg # ICC 7.1 will output 303f220fa62Smrg # foo.o: sub/foo.c sub/foo.h 304f220fa62Smrg # and will wrap long lines using '\': 305f220fa62Smrg # foo.o: sub/foo.c ... \ 306f220fa62Smrg # sub/foo.h ... \ 307f220fa62Smrg # ... 308f220fa62Smrg # tcc 0.9.26 (FIXME still under development at the moment of writing) 309f220fa62Smrg # will emit a similar output, but also prepend the continuation lines 310f220fa62Smrg # with horizontal tabulation characters. 311f220fa62Smrg "$@" -MD -MF "$tmpdepfile" 312f220fa62Smrg stat=$? 313f220fa62Smrg if test $stat -eq 0; then : 314f220fa62Smrg else 315f220fa62Smrg rm -f "$tmpdepfile" 316f220fa62Smrg exit $stat 317f220fa62Smrg fi 318f220fa62Smrg rm -f "$depfile" 319f220fa62Smrg # Each line is of the form 'foo.o: dependent.h', 320f220fa62Smrg # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. 321f220fa62Smrg # Do two passes, one to just change these to 322f220fa62Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 323f220fa62Smrg sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ 324f220fa62Smrg < "$tmpdepfile" > "$depfile" 325f220fa62Smrg sed ' 326f220fa62Smrg s/[ '"$tab"'][ '"$tab"']*/ /g 327f220fa62Smrg s/^ *// 328f220fa62Smrg s/ *\\*$// 329f220fa62Smrg s/^[^:]*: *// 330f220fa62Smrg /^$/d 331f220fa62Smrg /:$/d 332f220fa62Smrg s/$/ :/ 333f220fa62Smrg ' < "$tmpdepfile" >> "$depfile" 334f220fa62Smrg rm -f "$tmpdepfile" 335f220fa62Smrg ;; 336f220fa62Smrg 337f220fa62Smrghp2) 338f220fa62Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 339f220fa62Smrg # compilers, which have integrated preprocessors. The correct option 340f220fa62Smrg # to use with these is +Maked; it writes dependencies to a file named 341f220fa62Smrg # 'foo.d', which lands next to the object file, wherever that 342f220fa62Smrg # happens to be. 343f220fa62Smrg # Much of this is similar to the tru64 case; see comments there. 344f220fa62Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 345f220fa62Smrg test "x$dir" = "x$object" && dir= 346f220fa62Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 347f220fa62Smrg if test "$libtool" = yes; then 348f220fa62Smrg tmpdepfile1=$dir$base.d 349f220fa62Smrg tmpdepfile2=$dir.libs/$base.d 350f220fa62Smrg "$@" -Wc,+Maked 351f220fa62Smrg else 352f220fa62Smrg tmpdepfile1=$dir$base.d 353f220fa62Smrg tmpdepfile2=$dir$base.d 354f220fa62Smrg "$@" +Maked 355f220fa62Smrg fi 356f220fa62Smrg stat=$? 357f220fa62Smrg if test $stat -eq 0; then : 358f220fa62Smrg else 359f220fa62Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 360f220fa62Smrg exit $stat 361f220fa62Smrg fi 362f220fa62Smrg 363f220fa62Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 364f220fa62Smrg do 365f220fa62Smrg test -f "$tmpdepfile" && break 366f220fa62Smrg done 367f220fa62Smrg if test -f "$tmpdepfile"; then 368f220fa62Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 369f220fa62Smrg # Add 'dependent.h:' lines. 370f220fa62Smrg sed -ne '2,${ 371f220fa62Smrg s/^ *// 372f220fa62Smrg s/ \\*$// 373f220fa62Smrg s/$/:/ 374f220fa62Smrg p 375f220fa62Smrg }' "$tmpdepfile" >> "$depfile" 376f220fa62Smrg else 377f220fa62Smrg echo "#dummy" > "$depfile" 378f220fa62Smrg fi 379f220fa62Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 380f220fa62Smrg ;; 381f220fa62Smrg 382f220fa62Smrgtru64) 383f220fa62Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 384f220fa62Smrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 385f220fa62Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 386f220fa62Smrg # dependencies in 'foo.d' instead, so we check for that too. 387f220fa62Smrg # Subdirectories are respected. 388f220fa62Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 389f220fa62Smrg test "x$dir" = "x$object" && dir= 390f220fa62Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 391f220fa62Smrg 392f220fa62Smrg if test "$libtool" = yes; then 393f220fa62Smrg # With Tru64 cc, shared objects can also be used to make a 394f220fa62Smrg # static library. This mechanism is used in libtool 1.4 series to 395f220fa62Smrg # handle both shared and static libraries in a single compilation. 396f220fa62Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 397f220fa62Smrg # 398f220fa62Smrg # With libtool 1.5 this exception was removed, and libtool now 399f220fa62Smrg # generates 2 separate objects for the 2 libraries. These two 400f220fa62Smrg # compilations output dependencies in $dir.libs/$base.o.d and 401f220fa62Smrg # in $dir$base.o.d. We have to check for both files, because 402f220fa62Smrg # one of the two compilations can be disabled. We should prefer 403f220fa62Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 404f220fa62Smrg # automatically cleaned when .libs/ is deleted, while ignoring 405f220fa62Smrg # the former would cause a distcleancheck panic. 406f220fa62Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 407f220fa62Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 408f220fa62Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 409f220fa62Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 410f220fa62Smrg "$@" -Wc,-MD 411f220fa62Smrg else 412f220fa62Smrg tmpdepfile1=$dir$base.o.d 413f220fa62Smrg tmpdepfile2=$dir$base.d 414f220fa62Smrg tmpdepfile3=$dir$base.d 415f220fa62Smrg tmpdepfile4=$dir$base.d 416f220fa62Smrg "$@" -MD 417f220fa62Smrg fi 418f220fa62Smrg 419f220fa62Smrg stat=$? 420f220fa62Smrg if test $stat -eq 0; then : 421f220fa62Smrg else 422f220fa62Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 423f220fa62Smrg exit $stat 424f220fa62Smrg fi 425f220fa62Smrg 426f220fa62Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 427f220fa62Smrg do 428f220fa62Smrg test -f "$tmpdepfile" && break 429f220fa62Smrg done 430f220fa62Smrg if test -f "$tmpdepfile"; then 431f220fa62Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 432f220fa62Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 433f220fa62Smrg else 434f220fa62Smrg echo "#dummy" > "$depfile" 435f220fa62Smrg fi 436f220fa62Smrg rm -f "$tmpdepfile" 437f220fa62Smrg ;; 438f220fa62Smrg 439f220fa62Smrgmsvc7) 440f220fa62Smrg if test "$libtool" = yes; then 441f220fa62Smrg showIncludes=-Wc,-showIncludes 442f220fa62Smrg else 443f220fa62Smrg showIncludes=-showIncludes 444f220fa62Smrg fi 445f220fa62Smrg "$@" $showIncludes > "$tmpdepfile" 446f220fa62Smrg stat=$? 447f220fa62Smrg grep -v '^Note: including file: ' "$tmpdepfile" 448f220fa62Smrg if test "$stat" = 0; then : 449f220fa62Smrg else 450f220fa62Smrg rm -f "$tmpdepfile" 451f220fa62Smrg exit $stat 452f220fa62Smrg fi 453f220fa62Smrg rm -f "$depfile" 454f220fa62Smrg echo "$object : \\" > "$depfile" 455f220fa62Smrg # The first sed program below extracts the file names and escapes 456f220fa62Smrg # backslashes for cygpath. The second sed program outputs the file 457f220fa62Smrg # name when reading, but also accumulates all include files in the 458f220fa62Smrg # hold buffer in order to output them again at the end. This only 459f220fa62Smrg # works with sed implementations that can handle large buffers. 460f220fa62Smrg sed < "$tmpdepfile" -n ' 461f220fa62Smrg/^Note: including file: *\(.*\)/ { 462f220fa62Smrg s//\1/ 463f220fa62Smrg s/\\/\\\\/g 464f220fa62Smrg p 465f220fa62Smrg}' | $cygpath_u | sort -u | sed -n ' 466f220fa62Smrgs/ /\\ /g 467f220fa62Smrgs/\(.*\)/'"$tab"'\1 \\/p 468f220fa62Smrgs/.\(.*\) \\/\1:/ 469f220fa62SmrgH 470f220fa62Smrg$ { 471f220fa62Smrg s/.*/'"$tab"'/ 472f220fa62Smrg G 473f220fa62Smrg p 474f220fa62Smrg}' >> "$depfile" 475f220fa62Smrg rm -f "$tmpdepfile" 476f220fa62Smrg ;; 477f220fa62Smrg 478f220fa62Smrgmsvc7msys) 479f220fa62Smrg # This case exists only to let depend.m4 do its work. It works by 480f220fa62Smrg # looking at the text of this script. This case will never be run, 481f220fa62Smrg # since it is checked for above. 482f220fa62Smrg exit 1 483f220fa62Smrg ;; 484f220fa62Smrg 485f220fa62Smrg#nosideeffect) 486f220fa62Smrg # This comment above is used by automake to tell side-effect 487f220fa62Smrg # dependency tracking mechanisms from slower ones. 488f220fa62Smrg 489f220fa62Smrgdashmstdout) 490f220fa62Smrg # Important note: in order to support this mode, a compiler *must* 491f220fa62Smrg # always write the preprocessed file to stdout, regardless of -o. 492f220fa62Smrg "$@" || exit $? 493f220fa62Smrg 494f220fa62Smrg # Remove the call to Libtool. 495f220fa62Smrg if test "$libtool" = yes; then 496f220fa62Smrg while test "X$1" != 'X--mode=compile'; do 497f220fa62Smrg shift 498f220fa62Smrg done 499f220fa62Smrg shift 500f220fa62Smrg fi 501f220fa62Smrg 502f220fa62Smrg # Remove '-o $object'. 503f220fa62Smrg IFS=" " 504f220fa62Smrg for arg 505f220fa62Smrg do 506f220fa62Smrg case $arg in 507f220fa62Smrg -o) 508f220fa62Smrg shift 509f220fa62Smrg ;; 510f220fa62Smrg $object) 511f220fa62Smrg shift 512f220fa62Smrg ;; 513f220fa62Smrg *) 514f220fa62Smrg set fnord "$@" "$arg" 515f220fa62Smrg shift # fnord 516f220fa62Smrg shift # $arg 517f220fa62Smrg ;; 518f220fa62Smrg esac 519f220fa62Smrg done 520f220fa62Smrg 521f220fa62Smrg test -z "$dashmflag" && dashmflag=-M 522f220fa62Smrg # Require at least two characters before searching for ':' 523f220fa62Smrg # in the target name. This is to cope with DOS-style filenames: 524f220fa62Smrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 525f220fa62Smrg "$@" $dashmflag | 526f220fa62Smrg sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" 527f220fa62Smrg rm -f "$depfile" 528f220fa62Smrg cat < "$tmpdepfile" > "$depfile" 529f220fa62Smrg tr ' ' "$nl" < "$tmpdepfile" | \ 530f220fa62Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 531f220fa62Smrg## correctly. Breaking it into two sed invocations is a workaround. 532f220fa62Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 533f220fa62Smrg rm -f "$tmpdepfile" 534f220fa62Smrg ;; 535f220fa62Smrg 536f220fa62SmrgdashXmstdout) 537f220fa62Smrg # This case only exists to satisfy depend.m4. It is never actually 538f220fa62Smrg # run, as this mode is specially recognized in the preamble. 539f220fa62Smrg exit 1 540f220fa62Smrg ;; 541f220fa62Smrg 542f220fa62Smrgmakedepend) 543f220fa62Smrg "$@" || exit $? 544f220fa62Smrg # Remove any Libtool call 545f220fa62Smrg if test "$libtool" = yes; then 546f220fa62Smrg while test "X$1" != 'X--mode=compile'; do 547f220fa62Smrg shift 548f220fa62Smrg done 549f220fa62Smrg shift 550f220fa62Smrg fi 551f220fa62Smrg # X makedepend 552f220fa62Smrg shift 553f220fa62Smrg cleared=no eat=no 554f220fa62Smrg for arg 555f220fa62Smrg do 556f220fa62Smrg case $cleared in 557f220fa62Smrg no) 558f220fa62Smrg set ""; shift 559f220fa62Smrg cleared=yes ;; 560f220fa62Smrg esac 561f220fa62Smrg if test $eat = yes; then 562f220fa62Smrg eat=no 563f220fa62Smrg continue 564f220fa62Smrg fi 565f220fa62Smrg case "$arg" in 566f220fa62Smrg -D*|-I*) 567f220fa62Smrg set fnord "$@" "$arg"; shift ;; 568f220fa62Smrg # Strip any option that makedepend may not understand. Remove 569f220fa62Smrg # the object too, otherwise makedepend will parse it as a source file. 570f220fa62Smrg -arch) 571f220fa62Smrg eat=yes ;; 572f220fa62Smrg -*|$object) 573f220fa62Smrg ;; 574f220fa62Smrg *) 575f220fa62Smrg set fnord "$@" "$arg"; shift ;; 576f220fa62Smrg esac 577f220fa62Smrg done 578f220fa62Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 579f220fa62Smrg touch "$tmpdepfile" 580f220fa62Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 581f220fa62Smrg rm -f "$depfile" 582f220fa62Smrg # makedepend may prepend the VPATH from the source file name to the object. 583f220fa62Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 584f220fa62Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 585f220fa62Smrg sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ 586f220fa62Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 587f220fa62Smrg## correctly. Breaking it into two sed invocations is a workaround. 588f220fa62Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 589f220fa62Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 590f220fa62Smrg ;; 591f220fa62Smrg 592f220fa62Smrgcpp) 593f220fa62Smrg # Important note: in order to support this mode, a compiler *must* 594f220fa62Smrg # always write the preprocessed file to stdout. 595f220fa62Smrg "$@" || exit $? 596f220fa62Smrg 597f220fa62Smrg # Remove the call to Libtool. 598f220fa62Smrg if test "$libtool" = yes; then 599f220fa62Smrg while test "X$1" != 'X--mode=compile'; do 600f220fa62Smrg shift 601f220fa62Smrg done 602f220fa62Smrg shift 603f220fa62Smrg fi 604f220fa62Smrg 605f220fa62Smrg # Remove '-o $object'. 606f220fa62Smrg IFS=" " 607f220fa62Smrg for arg 608f220fa62Smrg do 609f220fa62Smrg case $arg in 610f220fa62Smrg -o) 611f220fa62Smrg shift 612f220fa62Smrg ;; 613f220fa62Smrg $object) 614f220fa62Smrg shift 615f220fa62Smrg ;; 616f220fa62Smrg *) 617f220fa62Smrg set fnord "$@" "$arg" 618f220fa62Smrg shift # fnord 619f220fa62Smrg shift # $arg 620f220fa62Smrg ;; 621f220fa62Smrg esac 622f220fa62Smrg done 623f220fa62Smrg 624f220fa62Smrg "$@" -E | 625f220fa62Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 626f220fa62Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 627f220fa62Smrg sed '$ s: \\$::' > "$tmpdepfile" 628f220fa62Smrg rm -f "$depfile" 629f220fa62Smrg echo "$object : \\" > "$depfile" 630f220fa62Smrg cat < "$tmpdepfile" >> "$depfile" 631f220fa62Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 632f220fa62Smrg rm -f "$tmpdepfile" 633f220fa62Smrg ;; 634f220fa62Smrg 635f220fa62Smrgmsvisualcpp) 636f220fa62Smrg # Important note: in order to support this mode, a compiler *must* 637f220fa62Smrg # always write the preprocessed file to stdout. 638f220fa62Smrg "$@" || exit $? 639f220fa62Smrg 640f220fa62Smrg # Remove the call to Libtool. 641f220fa62Smrg if test "$libtool" = yes; then 642f220fa62Smrg while test "X$1" != 'X--mode=compile'; do 643f220fa62Smrg shift 644f220fa62Smrg done 645f220fa62Smrg shift 646f220fa62Smrg fi 647f220fa62Smrg 648f220fa62Smrg IFS=" " 649f220fa62Smrg for arg 650f220fa62Smrg do 651f220fa62Smrg case "$arg" in 652f220fa62Smrg -o) 653f220fa62Smrg shift 654f220fa62Smrg ;; 655f220fa62Smrg $object) 656f220fa62Smrg shift 657f220fa62Smrg ;; 658f220fa62Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 659f220fa62Smrg set fnord "$@" 660f220fa62Smrg shift 661f220fa62Smrg shift 662f220fa62Smrg ;; 663f220fa62Smrg *) 664f220fa62Smrg set fnord "$@" "$arg" 665f220fa62Smrg shift 666f220fa62Smrg shift 667f220fa62Smrg ;; 668f220fa62Smrg esac 669f220fa62Smrg done 670f220fa62Smrg "$@" -E 2>/dev/null | 671f220fa62Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 672f220fa62Smrg rm -f "$depfile" 673f220fa62Smrg echo "$object : \\" > "$depfile" 674f220fa62Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 675f220fa62Smrg echo "$tab" >> "$depfile" 676f220fa62Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 677f220fa62Smrg rm -f "$tmpdepfile" 678f220fa62Smrg ;; 679f220fa62Smrg 680f220fa62Smrgmsvcmsys) 681f220fa62Smrg # This case exists only to let depend.m4 do its work. It works by 682f220fa62Smrg # looking at the text of this script. This case will never be run, 683f220fa62Smrg # since it is checked for above. 684f220fa62Smrg exit 1 685f220fa62Smrg ;; 686f220fa62Smrg 687f220fa62Smrgnone) 688f220fa62Smrg exec "$@" 689f220fa62Smrg ;; 690f220fa62Smrg 691f220fa62Smrg*) 692f220fa62Smrg echo "Unknown depmode $depmode" 1>&2 693f220fa62Smrg exit 1 694f220fa62Smrg ;; 695f220fa62Smrgesac 696f220fa62Smrg 697f220fa62Smrgexit 0 698f220fa62Smrg 699f220fa62Smrg# Local Variables: 700f220fa62Smrg# mode: shell-script 701f220fa62Smrg# sh-indentation: 2 702f220fa62Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 703f220fa62Smrg# time-stamp-start: "scriptversion=" 704f220fa62Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 705f220fa62Smrg# time-stamp-time-zone: "UTC" 706f220fa62Smrg# time-stamp-end: "; # UTC" 707f220fa62Smrg# End: 708