depcomp revision a73597f9
1659607e0Smrg#! /bin/sh 2659607e0Smrg# depcomp - compile a program generating dependencies as side-effects 3659607e0Smrg 4a73597f9Smrgscriptversion=2012-03-27.16; # UTC 5659607e0Smrg 6a73597f9Smrg# Copyright (C) 1999-2012 Free Software Foundation, Inc. 7659607e0Smrg 8659607e0Smrg# This program is free software; you can redistribute it and/or modify 9659607e0Smrg# it under the terms of the GNU General Public License as published by 10659607e0Smrg# the Free Software Foundation; either version 2, or (at your option) 11659607e0Smrg# any later version. 12659607e0Smrg 13659607e0Smrg# This program is distributed in the hope that it will be useful, 14659607e0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16659607e0Smrg# GNU General Public License for more details. 17659607e0Smrg 18659607e0Smrg# You should have received a copy of the GNU General Public License 19b73be646Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 20659607e0Smrg 21659607e0Smrg# As a special exception to the GNU General Public License, if you 22659607e0Smrg# distribute this file as part of a program that contains a 23659607e0Smrg# configuration script generated by Autoconf, you may include it under 24659607e0Smrg# the same distribution terms that you use for the rest of that program. 25659607e0Smrg 26659607e0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 27659607e0Smrg 28659607e0Smrgcase $1 in 29659607e0Smrg '') 30a73597f9Smrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 31659607e0Smrg exit 1; 32659607e0Smrg ;; 33659607e0Smrg -h | --h*) 34659607e0Smrg cat <<\EOF 35659607e0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 36659607e0Smrg 37659607e0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 38659607e0Smrgas side-effects. 39659607e0Smrg 40659607e0SmrgEnvironment variables: 41659607e0Smrg depmode Dependency tracking mode. 42a73597f9Smrg source Source file read by 'PROGRAMS ARGS'. 43a73597f9Smrg object Object file output by 'PROGRAMS ARGS'. 44659607e0Smrg DEPDIR directory where to store dependencies. 45659607e0Smrg depfile Dependency file to output. 46a73597f9Smrg tmpdepfile Temporary file to use when outputting dependencies. 47659607e0Smrg libtool Whether libtool is used (yes/no). 48659607e0Smrg 49659607e0SmrgReport bugs to <bug-automake@gnu.org>. 50659607e0SmrgEOF 51659607e0Smrg exit $? 52659607e0Smrg ;; 53659607e0Smrg -v | --v*) 54659607e0Smrg echo "depcomp $scriptversion" 55659607e0Smrg exit $? 56659607e0Smrg ;; 57659607e0Smrgesac 58659607e0Smrg 59a73597f9Smrg# A tabulation character. 60a73597f9Smrgtab=' ' 61a73597f9Smrg# A newline character. 62a73597f9Smrgnl=' 63a73597f9Smrg' 64a73597f9Smrg 65659607e0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 66659607e0Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 67659607e0Smrg exit 1 68659607e0Smrgfi 69659607e0Smrg 70659607e0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 71659607e0Smrgdepfile=${depfile-`echo "$object" | 72659607e0Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 73659607e0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 74659607e0Smrg 75659607e0Smrgrm -f "$tmpdepfile" 76659607e0Smrg 77659607e0Smrg# Some modes work just like other modes, but use different flags. We 78659607e0Smrg# parameterize here, but still list the modes in the big case below, 79659607e0Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 80659607e0Smrg# here, because this file can only contain one case statement. 81659607e0Smrgif test "$depmode" = hp; then 82659607e0Smrg # HP compiler uses -M and no extra arg. 83659607e0Smrg gccflag=-M 84659607e0Smrg depmode=gcc 85659607e0Smrgfi 86659607e0Smrg 87659607e0Smrgif test "$depmode" = dashXmstdout; then 88659607e0Smrg # This is just like dashmstdout with a different argument. 89659607e0Smrg dashmflag=-xM 90659607e0Smrg depmode=dashmstdout 91659607e0Smrgfi 92659607e0Smrg 93b73be646Smrgcygpath_u="cygpath -u -f -" 94b73be646Smrgif test "$depmode" = msvcmsys; then 95b73be646Smrg # This is just like msvisualcpp but w/o cygpath translation. 96b73be646Smrg # Just convert the backslash-escaped backslashes to single forward 97b73be646Smrg # slashes to satisfy depend.m4 98a73597f9Smrg cygpath_u='sed s,\\\\,/,g' 99b73be646Smrg depmode=msvisualcpp 100b73be646Smrgfi 101b73be646Smrg 102a73597f9Smrgif test "$depmode" = msvc7msys; then 103a73597f9Smrg # This is just like msvc7 but w/o cygpath translation. 104a73597f9Smrg # Just convert the backslash-escaped backslashes to single forward 105a73597f9Smrg # slashes to satisfy depend.m4 106a73597f9Smrg cygpath_u='sed s,\\\\,/,g' 107a73597f9Smrg depmode=msvc7 108a73597f9Smrgfi 109a73597f9Smrg 110a73597f9Smrgif test "$depmode" = xlc; then 111a73597f9Smrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. 112a73597f9Smrg gccflag=-qmakedep=gcc,-MF 113a73597f9Smrg depmode=gcc 114a73597f9Smrgfi 115a73597f9Smrg 116659607e0Smrgcase "$depmode" in 117659607e0Smrggcc3) 118659607e0Smrg## gcc 3 implements dependency tracking that does exactly what 119659607e0Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 120659607e0Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 121659607e0Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 122659607e0Smrg## the command line argument order; so add the flags where they 123659607e0Smrg## appear in depend2.am. Note that the slowdown incurred here 124659607e0Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 125659607e0Smrg for arg 126659607e0Smrg do 127659607e0Smrg case $arg in 128659607e0Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 129659607e0Smrg *) set fnord "$@" "$arg" ;; 130659607e0Smrg esac 131659607e0Smrg shift # fnord 132659607e0Smrg shift # $arg 133659607e0Smrg done 134659607e0Smrg "$@" 135659607e0Smrg stat=$? 136659607e0Smrg if test $stat -eq 0; then : 137659607e0Smrg else 138659607e0Smrg rm -f "$tmpdepfile" 139659607e0Smrg exit $stat 140659607e0Smrg fi 141659607e0Smrg mv "$tmpdepfile" "$depfile" 142659607e0Smrg ;; 143659607e0Smrg 144659607e0Smrggcc) 145659607e0Smrg## There are various ways to get dependency output from gcc. Here's 146659607e0Smrg## why we pick this rather obscure method: 147659607e0Smrg## - Don't want to use -MD because we'd like the dependencies to end 148659607e0Smrg## up in a subdir. Having to rename by hand is ugly. 149659607e0Smrg## (We might end up doing this anyway to support other compilers.) 150659607e0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 151659607e0Smrg## -MM, not -M (despite what the docs say). 152659607e0Smrg## - Using -M directly means running the compiler twice (even worse 153659607e0Smrg## than renaming). 154659607e0Smrg if test -z "$gccflag"; then 155659607e0Smrg gccflag=-MD, 156659607e0Smrg fi 157659607e0Smrg "$@" -Wp,"$gccflag$tmpdepfile" 158659607e0Smrg stat=$? 159659607e0Smrg if test $stat -eq 0; then : 160659607e0Smrg else 161659607e0Smrg rm -f "$tmpdepfile" 162659607e0Smrg exit $stat 163659607e0Smrg fi 164659607e0Smrg rm -f "$depfile" 165659607e0Smrg echo "$object : \\" > "$depfile" 166659607e0Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 167659607e0Smrg## The second -e expression handles DOS-style file names with drive letters. 168659607e0Smrg sed -e 's/^[^:]*: / /' \ 169659607e0Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 170a73597f9Smrg## This next piece of magic avoids the "deleted header file" problem. 171659607e0Smrg## The problem is that when a header file which appears in a .P file 172659607e0Smrg## is deleted, the dependency causes make to die (because there is 173659607e0Smrg## typically no way to rebuild the header). We avoid this by adding 174659607e0Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 175659607e0Smrg## this for us directly. 176a73597f9Smrg tr ' ' "$nl" < "$tmpdepfile" | 177a73597f9Smrg## Some versions of gcc put a space before the ':'. On the theory 178659607e0Smrg## that the space means something, we add a space to the output as 179a73597f9Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 180a73597f9Smrg## to the object. Take care to not repeat it in the output. 181659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 182659607e0Smrg## correctly. Breaking it into two sed invocations is a workaround. 183a73597f9Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 184a73597f9Smrg | sed -e 's/$/ :/' >> "$depfile" 185659607e0Smrg rm -f "$tmpdepfile" 186659607e0Smrg ;; 187659607e0Smrg 188659607e0Smrghp) 189659607e0Smrg # This case exists only to let depend.m4 do its work. It works by 190659607e0Smrg # looking at the text of this script. This case will never be run, 191659607e0Smrg # since it is checked for above. 192659607e0Smrg exit 1 193659607e0Smrg ;; 194659607e0Smrg 195659607e0Smrgsgi) 196659607e0Smrg if test "$libtool" = yes; then 197659607e0Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 198659607e0Smrg else 199659607e0Smrg "$@" -MDupdate "$tmpdepfile" 200659607e0Smrg fi 201659607e0Smrg stat=$? 202659607e0Smrg if test $stat -eq 0; then : 203659607e0Smrg else 204659607e0Smrg rm -f "$tmpdepfile" 205659607e0Smrg exit $stat 206659607e0Smrg fi 207659607e0Smrg rm -f "$depfile" 208659607e0Smrg 209659607e0Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 210659607e0Smrg echo "$object : \\" > "$depfile" 211659607e0Smrg 212659607e0Smrg # Clip off the initial element (the dependent). Don't try to be 213659607e0Smrg # clever and replace this with sed code, as IRIX sed won't handle 214659607e0Smrg # lines with more than a fixed number of characters (4096 in 215659607e0Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 216a73597f9Smrg # the IRIX cc adds comments like '#:fec' to the end of the 217659607e0Smrg # dependency line. 218a73597f9Smrg tr ' ' "$nl" < "$tmpdepfile" \ 219659607e0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 220a73597f9Smrg tr "$nl" ' ' >> "$depfile" 221b73be646Smrg echo >> "$depfile" 222659607e0Smrg 223659607e0Smrg # The second pass generates a dummy entry for each header file. 224a73597f9Smrg tr ' ' "$nl" < "$tmpdepfile" \ 225659607e0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 226b73be646Smrg >> "$depfile" 227659607e0Smrg else 228659607e0Smrg # The sourcefile does not contain any dependencies, so just 229659607e0Smrg # store a dummy comment line, to avoid errors with the Makefile 230659607e0Smrg # "include basename.Plo" scheme. 231659607e0Smrg echo "#dummy" > "$depfile" 232659607e0Smrg fi 233659607e0Smrg rm -f "$tmpdepfile" 234659607e0Smrg ;; 235659607e0Smrg 236a73597f9Smrgxlc) 237a73597f9Smrg # This case exists only to let depend.m4 do its work. It works by 238a73597f9Smrg # looking at the text of this script. This case will never be run, 239a73597f9Smrg # since it is checked for above. 240a73597f9Smrg exit 1 241a73597f9Smrg ;; 242a73597f9Smrg 243659607e0Smrgaix) 244659607e0Smrg # The C for AIX Compiler uses -M and outputs the dependencies 245659607e0Smrg # in a .u file. In older versions, this file always lives in the 246a73597f9Smrg # current directory. Also, the AIX compiler puts '$object:' at the 247659607e0Smrg # start of each line; $object doesn't have directory information. 248659607e0Smrg # Version 6 uses the directory in both cases. 249fc27e79cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 250fc27e79cSmrg test "x$dir" = "x$object" && dir= 251fc27e79cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 252659607e0Smrg if test "$libtool" = yes; then 253fc27e79cSmrg tmpdepfile1=$dir$base.u 254fc27e79cSmrg tmpdepfile2=$base.u 255fc27e79cSmrg tmpdepfile3=$dir.libs/$base.u 256659607e0Smrg "$@" -Wc,-M 257659607e0Smrg else 258fc27e79cSmrg tmpdepfile1=$dir$base.u 259fc27e79cSmrg tmpdepfile2=$dir$base.u 260fc27e79cSmrg tmpdepfile3=$dir$base.u 261659607e0Smrg "$@" -M 262659607e0Smrg fi 263659607e0Smrg stat=$? 264659607e0Smrg 265659607e0Smrg if test $stat -eq 0; then : 266659607e0Smrg else 267fc27e79cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 268659607e0Smrg exit $stat 269659607e0Smrg fi 270659607e0Smrg 271fc27e79cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 272fc27e79cSmrg do 273fc27e79cSmrg test -f "$tmpdepfile" && break 274fc27e79cSmrg done 275659607e0Smrg if test -f "$tmpdepfile"; then 276a73597f9Smrg # Each line is of the form 'foo.o: dependent.h'. 277659607e0Smrg # Do two passes, one to just change these to 278a73597f9Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 279fc27e79cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 280a73597f9Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 281659607e0Smrg else 282659607e0Smrg # The sourcefile does not contain any dependencies, so just 283659607e0Smrg # store a dummy comment line, to avoid errors with the Makefile 284659607e0Smrg # "include basename.Plo" scheme. 285659607e0Smrg echo "#dummy" > "$depfile" 286659607e0Smrg fi 287659607e0Smrg rm -f "$tmpdepfile" 288659607e0Smrg ;; 289659607e0Smrg 290659607e0Smrgicc) 291a73597f9Smrg # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. 292a73597f9Smrg # However on 293a73597f9Smrg # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c 294659607e0Smrg # ICC 7.0 will fill foo.d with something like 295659607e0Smrg # foo.o: sub/foo.c 296659607e0Smrg # foo.o: sub/foo.h 297a73597f9Smrg # which is wrong. We want 298659607e0Smrg # sub/foo.o: sub/foo.c 299659607e0Smrg # sub/foo.o: sub/foo.h 300659607e0Smrg # sub/foo.c: 301659607e0Smrg # sub/foo.h: 302659607e0Smrg # ICC 7.1 will output 303659607e0Smrg # foo.o: sub/foo.c sub/foo.h 304a73597f9Smrg # and will wrap long lines using '\': 305659607e0Smrg # foo.o: sub/foo.c ... \ 306659607e0Smrg # sub/foo.h ... \ 307659607e0Smrg # ... 308a73597f9Smrg # tcc 0.9.26 (FIXME still under development at the moment of writing) 309a73597f9Smrg # will emit a similar output, but also prepend the continuation lines 310a73597f9Smrg # with horizontal tabulation characters. 311659607e0Smrg "$@" -MD -MF "$tmpdepfile" 312659607e0Smrg stat=$? 313659607e0Smrg if test $stat -eq 0; then : 314659607e0Smrg else 315659607e0Smrg rm -f "$tmpdepfile" 316659607e0Smrg exit $stat 317659607e0Smrg fi 318659607e0Smrg rm -f "$depfile" 319a73597f9Smrg # Each line is of the form 'foo.o: dependent.h', 320a73597f9Smrg # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. 321659607e0Smrg # Do two passes, one to just change these to 322a73597f9Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 323a73597f9Smrg sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ 324a73597f9Smrg < "$tmpdepfile" > "$depfile" 325a73597f9Smrg sed ' 326a73597f9Smrg s/[ '"$tab"'][ '"$tab"']*/ /g 327a73597f9Smrg s/^ *// 328a73597f9Smrg s/ *\\*$// 329a73597f9Smrg s/^[^:]*: *// 330a73597f9Smrg /^$/d 331a73597f9Smrg /:$/d 332a73597f9Smrg s/$/ :/ 333a73597f9Smrg ' < "$tmpdepfile" >> "$depfile" 334659607e0Smrg rm -f "$tmpdepfile" 335659607e0Smrg ;; 336659607e0Smrg 337659607e0Smrghp2) 338659607e0Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 339659607e0Smrg # compilers, which have integrated preprocessors. The correct option 340659607e0Smrg # to use with these is +Maked; it writes dependencies to a file named 341659607e0Smrg # 'foo.d', which lands next to the object file, wherever that 342659607e0Smrg # happens to be. 343659607e0Smrg # Much of this is similar to the tru64 case; see comments there. 344659607e0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 345659607e0Smrg test "x$dir" = "x$object" && dir= 346659607e0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 347659607e0Smrg if test "$libtool" = yes; then 348659607e0Smrg tmpdepfile1=$dir$base.d 349659607e0Smrg tmpdepfile2=$dir.libs/$base.d 350659607e0Smrg "$@" -Wc,+Maked 351659607e0Smrg else 352659607e0Smrg tmpdepfile1=$dir$base.d 353659607e0Smrg tmpdepfile2=$dir$base.d 354659607e0Smrg "$@" +Maked 355659607e0Smrg fi 356659607e0Smrg stat=$? 357659607e0Smrg if test $stat -eq 0; then : 358659607e0Smrg else 359659607e0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 360659607e0Smrg exit $stat 361659607e0Smrg fi 362659607e0Smrg 363659607e0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 364659607e0Smrg do 365659607e0Smrg test -f "$tmpdepfile" && break 366659607e0Smrg done 367659607e0Smrg if test -f "$tmpdepfile"; then 368659607e0Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 369a73597f9Smrg # Add 'dependent.h:' lines. 370b73be646Smrg sed -ne '2,${ 371b73be646Smrg s/^ *// 372b73be646Smrg s/ \\*$// 373b73be646Smrg s/$/:/ 374b73be646Smrg p 375b73be646Smrg }' "$tmpdepfile" >> "$depfile" 376659607e0Smrg else 377659607e0Smrg echo "#dummy" > "$depfile" 378659607e0Smrg fi 379659607e0Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 380659607e0Smrg ;; 381659607e0Smrg 382659607e0Smrgtru64) 383659607e0Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 384a73597f9Smrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 385659607e0Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 386a73597f9Smrg # dependencies in 'foo.d' instead, so we check for that too. 387659607e0Smrg # Subdirectories are respected. 388659607e0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 389659607e0Smrg test "x$dir" = "x$object" && dir= 390659607e0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 391659607e0Smrg 392659607e0Smrg if test "$libtool" = yes; then 393659607e0Smrg # With Tru64 cc, shared objects can also be used to make a 394659607e0Smrg # static library. This mechanism is used in libtool 1.4 series to 395659607e0Smrg # handle both shared and static libraries in a single compilation. 396659607e0Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 397659607e0Smrg # 398659607e0Smrg # With libtool 1.5 this exception was removed, and libtool now 399659607e0Smrg # generates 2 separate objects for the 2 libraries. These two 400659607e0Smrg # compilations output dependencies in $dir.libs/$base.o.d and 401659607e0Smrg # in $dir$base.o.d. We have to check for both files, because 402659607e0Smrg # one of the two compilations can be disabled. We should prefer 403659607e0Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 404659607e0Smrg # automatically cleaned when .libs/ is deleted, while ignoring 405659607e0Smrg # the former would cause a distcleancheck panic. 406659607e0Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 407659607e0Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 408659607e0Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 409659607e0Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 410659607e0Smrg "$@" -Wc,-MD 411659607e0Smrg else 412659607e0Smrg tmpdepfile1=$dir$base.o.d 413659607e0Smrg tmpdepfile2=$dir$base.d 414659607e0Smrg tmpdepfile3=$dir$base.d 415659607e0Smrg tmpdepfile4=$dir$base.d 416659607e0Smrg "$@" -MD 417659607e0Smrg fi 418659607e0Smrg 419659607e0Smrg stat=$? 420659607e0Smrg if test $stat -eq 0; then : 421659607e0Smrg else 422659607e0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 423659607e0Smrg exit $stat 424659607e0Smrg fi 425659607e0Smrg 426659607e0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 427659607e0Smrg do 428659607e0Smrg test -f "$tmpdepfile" && break 429659607e0Smrg done 430659607e0Smrg if test -f "$tmpdepfile"; then 431659607e0Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 432a73597f9Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 433659607e0Smrg else 434659607e0Smrg echo "#dummy" > "$depfile" 435659607e0Smrg fi 436659607e0Smrg rm -f "$tmpdepfile" 437659607e0Smrg ;; 438659607e0Smrg 439a73597f9Smrgmsvc7) 440a73597f9Smrg if test "$libtool" = yes; then 441a73597f9Smrg showIncludes=-Wc,-showIncludes 442a73597f9Smrg else 443a73597f9Smrg showIncludes=-showIncludes 444a73597f9Smrg fi 445a73597f9Smrg "$@" $showIncludes > "$tmpdepfile" 446a73597f9Smrg stat=$? 447a73597f9Smrg grep -v '^Note: including file: ' "$tmpdepfile" 448a73597f9Smrg if test "$stat" = 0; then : 449a73597f9Smrg else 450a73597f9Smrg rm -f "$tmpdepfile" 451a73597f9Smrg exit $stat 452a73597f9Smrg fi 453a73597f9Smrg rm -f "$depfile" 454a73597f9Smrg echo "$object : \\" > "$depfile" 455a73597f9Smrg # The first sed program below extracts the file names and escapes 456a73597f9Smrg # backslashes for cygpath. The second sed program outputs the file 457a73597f9Smrg # name when reading, but also accumulates all include files in the 458a73597f9Smrg # hold buffer in order to output them again at the end. This only 459a73597f9Smrg # works with sed implementations that can handle large buffers. 460a73597f9Smrg sed < "$tmpdepfile" -n ' 461a73597f9Smrg/^Note: including file: *\(.*\)/ { 462a73597f9Smrg s//\1/ 463a73597f9Smrg s/\\/\\\\/g 464a73597f9Smrg p 465a73597f9Smrg}' | $cygpath_u | sort -u | sed -n ' 466a73597f9Smrgs/ /\\ /g 467a73597f9Smrgs/\(.*\)/'"$tab"'\1 \\/p 468a73597f9Smrgs/.\(.*\) \\/\1:/ 469a73597f9SmrgH 470a73597f9Smrg$ { 471a73597f9Smrg s/.*/'"$tab"'/ 472a73597f9Smrg G 473a73597f9Smrg p 474a73597f9Smrg}' >> "$depfile" 475a73597f9Smrg rm -f "$tmpdepfile" 476a73597f9Smrg ;; 477a73597f9Smrg 478a73597f9Smrgmsvc7msys) 479a73597f9Smrg # This case exists only to let depend.m4 do its work. It works by 480a73597f9Smrg # looking at the text of this script. This case will never be run, 481a73597f9Smrg # since it is checked for above. 482a73597f9Smrg exit 1 483a73597f9Smrg ;; 484a73597f9Smrg 485659607e0Smrg#nosideeffect) 486659607e0Smrg # This comment above is used by automake to tell side-effect 487659607e0Smrg # dependency tracking mechanisms from slower ones. 488659607e0Smrg 489659607e0Smrgdashmstdout) 490659607e0Smrg # Important note: in order to support this mode, a compiler *must* 491659607e0Smrg # always write the preprocessed file to stdout, regardless of -o. 492659607e0Smrg "$@" || exit $? 493659607e0Smrg 494659607e0Smrg # Remove the call to Libtool. 495659607e0Smrg if test "$libtool" = yes; then 496b73be646Smrg while test "X$1" != 'X--mode=compile'; do 497659607e0Smrg shift 498659607e0Smrg done 499659607e0Smrg shift 500659607e0Smrg fi 501659607e0Smrg 502a73597f9Smrg # Remove '-o $object'. 503659607e0Smrg IFS=" " 504659607e0Smrg for arg 505659607e0Smrg do 506659607e0Smrg case $arg in 507659607e0Smrg -o) 508659607e0Smrg shift 509659607e0Smrg ;; 510659607e0Smrg $object) 511659607e0Smrg shift 512659607e0Smrg ;; 513659607e0Smrg *) 514659607e0Smrg set fnord "$@" "$arg" 515659607e0Smrg shift # fnord 516659607e0Smrg shift # $arg 517659607e0Smrg ;; 518659607e0Smrg esac 519659607e0Smrg done 520659607e0Smrg 521659607e0Smrg test -z "$dashmflag" && dashmflag=-M 522a73597f9Smrg # Require at least two characters before searching for ':' 523659607e0Smrg # in the target name. This is to cope with DOS-style filenames: 524a73597f9Smrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 525659607e0Smrg "$@" $dashmflag | 526a73597f9Smrg sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" 527659607e0Smrg rm -f "$depfile" 528659607e0Smrg cat < "$tmpdepfile" > "$depfile" 529a73597f9Smrg tr ' ' "$nl" < "$tmpdepfile" | \ 530659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 531659607e0Smrg## correctly. Breaking it into two sed invocations is a workaround. 532659607e0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 533659607e0Smrg rm -f "$tmpdepfile" 534659607e0Smrg ;; 535659607e0Smrg 536659607e0SmrgdashXmstdout) 537659607e0Smrg # This case only exists to satisfy depend.m4. It is never actually 538659607e0Smrg # run, as this mode is specially recognized in the preamble. 539659607e0Smrg exit 1 540659607e0Smrg ;; 541659607e0Smrg 542659607e0Smrgmakedepend) 543659607e0Smrg "$@" || exit $? 544659607e0Smrg # Remove any Libtool call 545659607e0Smrg if test "$libtool" = yes; then 546b73be646Smrg while test "X$1" != 'X--mode=compile'; do 547659607e0Smrg shift 548659607e0Smrg done 549659607e0Smrg shift 550659607e0Smrg fi 551659607e0Smrg # X makedepend 552659607e0Smrg shift 553b73be646Smrg cleared=no eat=no 554b73be646Smrg for arg 555b73be646Smrg do 556659607e0Smrg case $cleared in 557659607e0Smrg no) 558659607e0Smrg set ""; shift 559659607e0Smrg cleared=yes ;; 560659607e0Smrg esac 561b73be646Smrg if test $eat = yes; then 562b73be646Smrg eat=no 563b73be646Smrg continue 564b73be646Smrg fi 565659607e0Smrg case "$arg" in 566659607e0Smrg -D*|-I*) 567659607e0Smrg set fnord "$@" "$arg"; shift ;; 568659607e0Smrg # Strip any option that makedepend may not understand. Remove 569659607e0Smrg # the object too, otherwise makedepend will parse it as a source file. 570b73be646Smrg -arch) 571b73be646Smrg eat=yes ;; 572659607e0Smrg -*|$object) 573659607e0Smrg ;; 574659607e0Smrg *) 575659607e0Smrg set fnord "$@" "$arg"; shift ;; 576659607e0Smrg esac 577659607e0Smrg done 578b73be646Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 579659607e0Smrg touch "$tmpdepfile" 580659607e0Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 581659607e0Smrg rm -f "$depfile" 582a73597f9Smrg # makedepend may prepend the VPATH from the source file name to the object. 583a73597f9Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 584a73597f9Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 585a73597f9Smrg sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ 586659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 587659607e0Smrg## correctly. Breaking it into two sed invocations is a workaround. 588659607e0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 589659607e0Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 590659607e0Smrg ;; 591659607e0Smrg 592659607e0Smrgcpp) 593659607e0Smrg # Important note: in order to support this mode, a compiler *must* 594659607e0Smrg # always write the preprocessed file to stdout. 595659607e0Smrg "$@" || exit $? 596659607e0Smrg 597659607e0Smrg # Remove the call to Libtool. 598659607e0Smrg if test "$libtool" = yes; then 599b73be646Smrg while test "X$1" != 'X--mode=compile'; do 600659607e0Smrg shift 601659607e0Smrg done 602659607e0Smrg shift 603659607e0Smrg fi 604659607e0Smrg 605a73597f9Smrg # Remove '-o $object'. 606659607e0Smrg IFS=" " 607659607e0Smrg for arg 608659607e0Smrg do 609659607e0Smrg case $arg in 610659607e0Smrg -o) 611659607e0Smrg shift 612659607e0Smrg ;; 613659607e0Smrg $object) 614659607e0Smrg shift 615659607e0Smrg ;; 616659607e0Smrg *) 617659607e0Smrg set fnord "$@" "$arg" 618659607e0Smrg shift # fnord 619659607e0Smrg shift # $arg 620659607e0Smrg ;; 621659607e0Smrg esac 622659607e0Smrg done 623659607e0Smrg 624659607e0Smrg "$@" -E | 625659607e0Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 626659607e0Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 627659607e0Smrg sed '$ s: \\$::' > "$tmpdepfile" 628659607e0Smrg rm -f "$depfile" 629659607e0Smrg echo "$object : \\" > "$depfile" 630659607e0Smrg cat < "$tmpdepfile" >> "$depfile" 631659607e0Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 632659607e0Smrg rm -f "$tmpdepfile" 633659607e0Smrg ;; 634659607e0Smrg 635659607e0Smrgmsvisualcpp) 636659607e0Smrg # Important note: in order to support this mode, a compiler *must* 637b73be646Smrg # always write the preprocessed file to stdout. 638659607e0Smrg "$@" || exit $? 639b73be646Smrg 640b73be646Smrg # Remove the call to Libtool. 641b73be646Smrg if test "$libtool" = yes; then 642b73be646Smrg while test "X$1" != 'X--mode=compile'; do 643b73be646Smrg shift 644b73be646Smrg done 645b73be646Smrg shift 646b73be646Smrg fi 647b73be646Smrg 648659607e0Smrg IFS=" " 649659607e0Smrg for arg 650659607e0Smrg do 651659607e0Smrg case "$arg" in 652b73be646Smrg -o) 653b73be646Smrg shift 654b73be646Smrg ;; 655b73be646Smrg $object) 656b73be646Smrg shift 657b73be646Smrg ;; 658659607e0Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 659659607e0Smrg set fnord "$@" 660659607e0Smrg shift 661659607e0Smrg shift 662659607e0Smrg ;; 663659607e0Smrg *) 664659607e0Smrg set fnord "$@" "$arg" 665659607e0Smrg shift 666659607e0Smrg shift 667659607e0Smrg ;; 668659607e0Smrg esac 669659607e0Smrg done 670b73be646Smrg "$@" -E 2>/dev/null | 671b73be646Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 672659607e0Smrg rm -f "$depfile" 673659607e0Smrg echo "$object : \\" > "$depfile" 674a73597f9Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 675a73597f9Smrg echo "$tab" >> "$depfile" 676b73be646Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 677659607e0Smrg rm -f "$tmpdepfile" 678659607e0Smrg ;; 679659607e0Smrg 680b73be646Smrgmsvcmsys) 681b73be646Smrg # This case exists only to let depend.m4 do its work. It works by 682b73be646Smrg # looking at the text of this script. This case will never be run, 683b73be646Smrg # since it is checked for above. 684b73be646Smrg exit 1 685b73be646Smrg ;; 686b73be646Smrg 687659607e0Smrgnone) 688659607e0Smrg exec "$@" 689659607e0Smrg ;; 690659607e0Smrg 691659607e0Smrg*) 692659607e0Smrg echo "Unknown depmode $depmode" 1>&2 693659607e0Smrg exit 1 694659607e0Smrg ;; 695659607e0Smrgesac 696659607e0Smrg 697659607e0Smrgexit 0 698659607e0Smrg 699659607e0Smrg# Local Variables: 700659607e0Smrg# mode: shell-script 701659607e0Smrg# sh-indentation: 2 702659607e0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 703659607e0Smrg# time-stamp-start: "scriptversion=" 704659607e0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 705b73be646Smrg# time-stamp-time-zone: "UTC" 706b73be646Smrg# time-stamp-end: "; # UTC" 707659607e0Smrg# End: 708