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