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