depcomp revision 54569438
1692f60a7Smrg#! /bin/sh 2692f60a7Smrg# depcomp - compile a program generating dependencies as side-effects 3692f60a7Smrg 454569438Smrgscriptversion=2007-03-29.01 5692f60a7Smrg 654569438Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 754569438Smrg# Foundation, Inc. 8692f60a7Smrg 9692f60a7Smrg# This program is free software; you can redistribute it and/or modify 10692f60a7Smrg# it under the terms of the GNU General Public License as published by 11692f60a7Smrg# the Free Software Foundation; either version 2, or (at your option) 12692f60a7Smrg# any later version. 13692f60a7Smrg 14692f60a7Smrg# This program is distributed in the hope that it will be useful, 15692f60a7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17692f60a7Smrg# GNU General Public License for more details. 18692f60a7Smrg 19692f60a7Smrg# You should have received a copy of the GNU General Public License 20692f60a7Smrg# along with this program; if not, write to the Free Software 21692f60a7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22692f60a7Smrg# 02110-1301, USA. 23692f60a7Smrg 24692f60a7Smrg# As a special exception to the GNU General Public License, if you 25692f60a7Smrg# distribute this file as part of a program that contains a 26692f60a7Smrg# configuration script generated by Autoconf, you may include it under 27692f60a7Smrg# the same distribution terms that you use for the rest of that program. 28692f60a7Smrg 29692f60a7Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 30692f60a7Smrg 31692f60a7Smrgcase $1 in 32692f60a7Smrg '') 33692f60a7Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 34692f60a7Smrg exit 1; 35692f60a7Smrg ;; 36692f60a7Smrg -h | --h*) 37692f60a7Smrg cat <<\EOF 38692f60a7SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 39692f60a7Smrg 40692f60a7SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 41692f60a7Smrgas side-effects. 42692f60a7Smrg 43692f60a7SmrgEnvironment variables: 44692f60a7Smrg depmode Dependency tracking mode. 45692f60a7Smrg source Source file read by `PROGRAMS ARGS'. 46692f60a7Smrg object Object file output by `PROGRAMS ARGS'. 47692f60a7Smrg DEPDIR directory where to store dependencies. 48692f60a7Smrg depfile Dependency file to output. 49692f60a7Smrg tmpdepfile Temporary file to use when outputing dependencies. 50692f60a7Smrg libtool Whether libtool is used (yes/no). 51692f60a7Smrg 52692f60a7SmrgReport bugs to <bug-automake@gnu.org>. 53692f60a7SmrgEOF 54692f60a7Smrg exit $? 55692f60a7Smrg ;; 56692f60a7Smrg -v | --v*) 57692f60a7Smrg echo "depcomp $scriptversion" 58692f60a7Smrg exit $? 59692f60a7Smrg ;; 60692f60a7Smrgesac 61692f60a7Smrg 62692f60a7Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 63692f60a7Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 64692f60a7Smrg exit 1 65692f60a7Smrgfi 66692f60a7Smrg 67692f60a7Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 68692f60a7Smrgdepfile=${depfile-`echo "$object" | 69692f60a7Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 70692f60a7Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 71692f60a7Smrg 72692f60a7Smrgrm -f "$tmpdepfile" 73692f60a7Smrg 74692f60a7Smrg# Some modes work just like other modes, but use different flags. We 75692f60a7Smrg# parameterize here, but still list the modes in the big case below, 76692f60a7Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 77692f60a7Smrg# here, because this file can only contain one case statement. 78692f60a7Smrgif test "$depmode" = hp; then 79692f60a7Smrg # HP compiler uses -M and no extra arg. 80692f60a7Smrg gccflag=-M 81692f60a7Smrg depmode=gcc 82692f60a7Smrgfi 83692f60a7Smrg 84692f60a7Smrgif test "$depmode" = dashXmstdout; then 85692f60a7Smrg # This is just like dashmstdout with a different argument. 86692f60a7Smrg dashmflag=-xM 87692f60a7Smrg depmode=dashmstdout 88692f60a7Smrgfi 89692f60a7Smrg 90692f60a7Smrgcase "$depmode" in 91692f60a7Smrggcc3) 92692f60a7Smrg## gcc 3 implements dependency tracking that does exactly what 93692f60a7Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 94692f60a7Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 9554569438Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 9654569438Smrg## the command line argument order; so add the flags where they 9754569438Smrg## appear in depend2.am. Note that the slowdown incurred here 9854569438Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 9954569438Smrg for arg 10054569438Smrg do 10154569438Smrg case $arg in 10254569438Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 10354569438Smrg *) set fnord "$@" "$arg" ;; 10454569438Smrg esac 10554569438Smrg shift # fnord 10654569438Smrg shift # $arg 10754569438Smrg done 10854569438Smrg "$@" 109692f60a7Smrg stat=$? 110692f60a7Smrg if test $stat -eq 0; then : 111692f60a7Smrg else 112692f60a7Smrg rm -f "$tmpdepfile" 113692f60a7Smrg exit $stat 114692f60a7Smrg fi 115692f60a7Smrg mv "$tmpdepfile" "$depfile" 116692f60a7Smrg ;; 117692f60a7Smrg 118692f60a7Smrggcc) 119692f60a7Smrg## There are various ways to get dependency output from gcc. Here's 120692f60a7Smrg## why we pick this rather obscure method: 121692f60a7Smrg## - Don't want to use -MD because we'd like the dependencies to end 122692f60a7Smrg## up in a subdir. Having to rename by hand is ugly. 123692f60a7Smrg## (We might end up doing this anyway to support other compilers.) 124692f60a7Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 125692f60a7Smrg## -MM, not -M (despite what the docs say). 126692f60a7Smrg## - Using -M directly means running the compiler twice (even worse 127692f60a7Smrg## than renaming). 128692f60a7Smrg if test -z "$gccflag"; then 129692f60a7Smrg gccflag=-MD, 130692f60a7Smrg fi 131692f60a7Smrg "$@" -Wp,"$gccflag$tmpdepfile" 132692f60a7Smrg stat=$? 133692f60a7Smrg if test $stat -eq 0; then : 134692f60a7Smrg else 135692f60a7Smrg rm -f "$tmpdepfile" 136692f60a7Smrg exit $stat 137692f60a7Smrg fi 138692f60a7Smrg rm -f "$depfile" 139692f60a7Smrg echo "$object : \\" > "$depfile" 140692f60a7Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 141692f60a7Smrg## The second -e expression handles DOS-style file names with drive letters. 142692f60a7Smrg sed -e 's/^[^:]*: / /' \ 143692f60a7Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 144692f60a7Smrg## This next piece of magic avoids the `deleted header file' problem. 145692f60a7Smrg## The problem is that when a header file which appears in a .P file 146692f60a7Smrg## is deleted, the dependency causes make to die (because there is 147692f60a7Smrg## typically no way to rebuild the header). We avoid this by adding 148692f60a7Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 149692f60a7Smrg## this for us directly. 150692f60a7Smrg tr ' ' ' 151692f60a7Smrg' < "$tmpdepfile" | 152692f60a7Smrg## Some versions of gcc put a space before the `:'. On the theory 153692f60a7Smrg## that the space means something, we add a space to the output as 154692f60a7Smrg## well. 155692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 156692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 157692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 158692f60a7Smrg rm -f "$tmpdepfile" 159692f60a7Smrg ;; 160692f60a7Smrg 161692f60a7Smrghp) 162692f60a7Smrg # This case exists only to let depend.m4 do its work. It works by 163692f60a7Smrg # looking at the text of this script. This case will never be run, 164692f60a7Smrg # since it is checked for above. 165692f60a7Smrg exit 1 166692f60a7Smrg ;; 167692f60a7Smrg 168692f60a7Smrgsgi) 169692f60a7Smrg if test "$libtool" = yes; then 170692f60a7Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 171692f60a7Smrg else 172692f60a7Smrg "$@" -MDupdate "$tmpdepfile" 173692f60a7Smrg fi 174692f60a7Smrg stat=$? 175692f60a7Smrg if test $stat -eq 0; then : 176692f60a7Smrg else 177692f60a7Smrg rm -f "$tmpdepfile" 178692f60a7Smrg exit $stat 179692f60a7Smrg fi 180692f60a7Smrg rm -f "$depfile" 181692f60a7Smrg 182692f60a7Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 183692f60a7Smrg echo "$object : \\" > "$depfile" 184692f60a7Smrg 185692f60a7Smrg # Clip off the initial element (the dependent). Don't try to be 186692f60a7Smrg # clever and replace this with sed code, as IRIX sed won't handle 187692f60a7Smrg # lines with more than a fixed number of characters (4096 in 188692f60a7Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 189692f60a7Smrg # the IRIX cc adds comments like `#:fec' to the end of the 190692f60a7Smrg # dependency line. 191692f60a7Smrg tr ' ' ' 192692f60a7Smrg' < "$tmpdepfile" \ 193692f60a7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 194692f60a7Smrg tr ' 195692f60a7Smrg' ' ' >> $depfile 196692f60a7Smrg echo >> $depfile 197692f60a7Smrg 198692f60a7Smrg # The second pass generates a dummy entry for each header file. 199692f60a7Smrg tr ' ' ' 200692f60a7Smrg' < "$tmpdepfile" \ 201692f60a7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 202692f60a7Smrg >> $depfile 203692f60a7Smrg else 204692f60a7Smrg # The sourcefile does not contain any dependencies, so just 205692f60a7Smrg # store a dummy comment line, to avoid errors with the Makefile 206692f60a7Smrg # "include basename.Plo" scheme. 207692f60a7Smrg echo "#dummy" > "$depfile" 208692f60a7Smrg fi 209692f60a7Smrg rm -f "$tmpdepfile" 210692f60a7Smrg ;; 211692f60a7Smrg 212692f60a7Smrgaix) 213692f60a7Smrg # The C for AIX Compiler uses -M and outputs the dependencies 214692f60a7Smrg # in a .u file. In older versions, this file always lives in the 215692f60a7Smrg # current directory. Also, the AIX compiler puts `$object:' at the 216692f60a7Smrg # start of each line; $object doesn't have directory information. 217692f60a7Smrg # Version 6 uses the directory in both cases. 21854569438Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 21954569438Smrg test "x$dir" = "x$object" && dir= 22054569438Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 221692f60a7Smrg if test "$libtool" = yes; then 22254569438Smrg tmpdepfile1=$dir$base.u 22354569438Smrg tmpdepfile2=$base.u 22454569438Smrg tmpdepfile3=$dir.libs/$base.u 225692f60a7Smrg "$@" -Wc,-M 226692f60a7Smrg else 22754569438Smrg tmpdepfile1=$dir$base.u 22854569438Smrg tmpdepfile2=$dir$base.u 22954569438Smrg tmpdepfile3=$dir$base.u 230692f60a7Smrg "$@" -M 231692f60a7Smrg fi 232692f60a7Smrg stat=$? 233692f60a7Smrg 234692f60a7Smrg if test $stat -eq 0; then : 235692f60a7Smrg else 23654569438Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 237692f60a7Smrg exit $stat 238692f60a7Smrg fi 239692f60a7Smrg 24054569438Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24154569438Smrg do 24254569438Smrg test -f "$tmpdepfile" && break 24354569438Smrg done 244692f60a7Smrg if test -f "$tmpdepfile"; then 245692f60a7Smrg # Each line is of the form `foo.o: dependent.h'. 246692f60a7Smrg # Do two passes, one to just change these to 247692f60a7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 24854569438Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 24954569438Smrg # That's a tab and a space in the []. 25054569438Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 251692f60a7Smrg else 252692f60a7Smrg # The sourcefile does not contain any dependencies, so just 253692f60a7Smrg # store a dummy comment line, to avoid errors with the Makefile 254692f60a7Smrg # "include basename.Plo" scheme. 255692f60a7Smrg echo "#dummy" > "$depfile" 256692f60a7Smrg fi 257692f60a7Smrg rm -f "$tmpdepfile" 258692f60a7Smrg ;; 259692f60a7Smrg 260692f60a7Smrgicc) 261692f60a7Smrg # Intel's C compiler understands `-MD -MF file'. However on 262692f60a7Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 263692f60a7Smrg # ICC 7.0 will fill foo.d with something like 264692f60a7Smrg # foo.o: sub/foo.c 265692f60a7Smrg # foo.o: sub/foo.h 266692f60a7Smrg # which is wrong. We want: 267692f60a7Smrg # sub/foo.o: sub/foo.c 268692f60a7Smrg # sub/foo.o: sub/foo.h 269692f60a7Smrg # sub/foo.c: 270692f60a7Smrg # sub/foo.h: 271692f60a7Smrg # ICC 7.1 will output 272692f60a7Smrg # foo.o: sub/foo.c sub/foo.h 273692f60a7Smrg # and will wrap long lines using \ : 274692f60a7Smrg # foo.o: sub/foo.c ... \ 275692f60a7Smrg # sub/foo.h ... \ 276692f60a7Smrg # ... 277692f60a7Smrg 278692f60a7Smrg "$@" -MD -MF "$tmpdepfile" 279692f60a7Smrg stat=$? 280692f60a7Smrg if test $stat -eq 0; then : 281692f60a7Smrg else 282692f60a7Smrg rm -f "$tmpdepfile" 283692f60a7Smrg exit $stat 284692f60a7Smrg fi 285692f60a7Smrg rm -f "$depfile" 286692f60a7Smrg # Each line is of the form `foo.o: dependent.h', 287692f60a7Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 288692f60a7Smrg # Do two passes, one to just change these to 289692f60a7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 290692f60a7Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 291692f60a7Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 292692f60a7Smrg # correctly. Breaking it into two sed invocations is a workaround. 293692f60a7Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 294692f60a7Smrg sed -e 's/$/ :/' >> "$depfile" 295692f60a7Smrg rm -f "$tmpdepfile" 296692f60a7Smrg ;; 297692f60a7Smrg 29854569438Smrghp2) 29954569438Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 30054569438Smrg # compilers, which have integrated preprocessors. The correct option 30154569438Smrg # to use with these is +Maked; it writes dependencies to a file named 30254569438Smrg # 'foo.d', which lands next to the object file, wherever that 30354569438Smrg # happens to be. 30454569438Smrg # Much of this is similar to the tru64 case; see comments there. 30554569438Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 30654569438Smrg test "x$dir" = "x$object" && dir= 30754569438Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 30854569438Smrg if test "$libtool" = yes; then 30954569438Smrg tmpdepfile1=$dir$base.d 31054569438Smrg tmpdepfile2=$dir.libs/$base.d 31154569438Smrg "$@" -Wc,+Maked 31254569438Smrg else 31354569438Smrg tmpdepfile1=$dir$base.d 31454569438Smrg tmpdepfile2=$dir$base.d 31554569438Smrg "$@" +Maked 31654569438Smrg fi 31754569438Smrg stat=$? 31854569438Smrg if test $stat -eq 0; then : 31954569438Smrg else 32054569438Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 32154569438Smrg exit $stat 32254569438Smrg fi 32354569438Smrg 32454569438Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 32554569438Smrg do 32654569438Smrg test -f "$tmpdepfile" && break 32754569438Smrg done 32854569438Smrg if test -f "$tmpdepfile"; then 32954569438Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 33054569438Smrg # Add `dependent.h:' lines. 33154569438Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 33254569438Smrg else 33354569438Smrg echo "#dummy" > "$depfile" 33454569438Smrg fi 33554569438Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 33654569438Smrg ;; 33754569438Smrg 338692f60a7Smrgtru64) 339692f60a7Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 340692f60a7Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 341692f60a7Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 342692f60a7Smrg # dependencies in `foo.d' instead, so we check for that too. 343692f60a7Smrg # Subdirectories are respected. 344692f60a7Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 345692f60a7Smrg test "x$dir" = "x$object" && dir= 346692f60a7Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 347692f60a7Smrg 348692f60a7Smrg if test "$libtool" = yes; then 349692f60a7Smrg # With Tru64 cc, shared objects can also be used to make a 35054569438Smrg # static library. This mechanism is used in libtool 1.4 series to 351692f60a7Smrg # handle both shared and static libraries in a single compilation. 352692f60a7Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 353692f60a7Smrg # 354692f60a7Smrg # With libtool 1.5 this exception was removed, and libtool now 355692f60a7Smrg # generates 2 separate objects for the 2 libraries. These two 35654569438Smrg # compilations output dependencies in $dir.libs/$base.o.d and 357692f60a7Smrg # in $dir$base.o.d. We have to check for both files, because 358692f60a7Smrg # one of the two compilations can be disabled. We should prefer 359692f60a7Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 360692f60a7Smrg # automatically cleaned when .libs/ is deleted, while ignoring 361692f60a7Smrg # the former would cause a distcleancheck panic. 362692f60a7Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 363692f60a7Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 364692f60a7Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 365692f60a7Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 366692f60a7Smrg "$@" -Wc,-MD 367692f60a7Smrg else 368692f60a7Smrg tmpdepfile1=$dir$base.o.d 369692f60a7Smrg tmpdepfile2=$dir$base.d 370692f60a7Smrg tmpdepfile3=$dir$base.d 371692f60a7Smrg tmpdepfile4=$dir$base.d 372692f60a7Smrg "$@" -MD 373692f60a7Smrg fi 374692f60a7Smrg 375692f60a7Smrg stat=$? 376692f60a7Smrg if test $stat -eq 0; then : 377692f60a7Smrg else 378692f60a7Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 379692f60a7Smrg exit $stat 380692f60a7Smrg fi 381692f60a7Smrg 382692f60a7Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 383692f60a7Smrg do 384692f60a7Smrg test -f "$tmpdepfile" && break 385692f60a7Smrg done 386692f60a7Smrg if test -f "$tmpdepfile"; then 387692f60a7Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 388692f60a7Smrg # That's a tab and a space in the []. 389692f60a7Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 390692f60a7Smrg else 391692f60a7Smrg echo "#dummy" > "$depfile" 392692f60a7Smrg fi 393692f60a7Smrg rm -f "$tmpdepfile" 394692f60a7Smrg ;; 395692f60a7Smrg 396692f60a7Smrg#nosideeffect) 397692f60a7Smrg # This comment above is used by automake to tell side-effect 398692f60a7Smrg # dependency tracking mechanisms from slower ones. 399692f60a7Smrg 400692f60a7Smrgdashmstdout) 401692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 402692f60a7Smrg # always write the preprocessed file to stdout, regardless of -o. 403692f60a7Smrg "$@" || exit $? 404692f60a7Smrg 405692f60a7Smrg # Remove the call to Libtool. 406692f60a7Smrg if test "$libtool" = yes; then 407692f60a7Smrg while test $1 != '--mode=compile'; do 408692f60a7Smrg shift 409692f60a7Smrg done 410692f60a7Smrg shift 411692f60a7Smrg fi 412692f60a7Smrg 413692f60a7Smrg # Remove `-o $object'. 414692f60a7Smrg IFS=" " 415692f60a7Smrg for arg 416692f60a7Smrg do 417692f60a7Smrg case $arg in 418692f60a7Smrg -o) 419692f60a7Smrg shift 420692f60a7Smrg ;; 421692f60a7Smrg $object) 422692f60a7Smrg shift 423692f60a7Smrg ;; 424692f60a7Smrg *) 425692f60a7Smrg set fnord "$@" "$arg" 426692f60a7Smrg shift # fnord 427692f60a7Smrg shift # $arg 428692f60a7Smrg ;; 429692f60a7Smrg esac 430692f60a7Smrg done 431692f60a7Smrg 432692f60a7Smrg test -z "$dashmflag" && dashmflag=-M 433692f60a7Smrg # Require at least two characters before searching for `:' 434692f60a7Smrg # in the target name. This is to cope with DOS-style filenames: 435692f60a7Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 436692f60a7Smrg "$@" $dashmflag | 437692f60a7Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 438692f60a7Smrg rm -f "$depfile" 439692f60a7Smrg cat < "$tmpdepfile" > "$depfile" 440692f60a7Smrg tr ' ' ' 441692f60a7Smrg' < "$tmpdepfile" | \ 442692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 443692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 444692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 445692f60a7Smrg rm -f "$tmpdepfile" 446692f60a7Smrg ;; 447692f60a7Smrg 448692f60a7SmrgdashXmstdout) 449692f60a7Smrg # This case only exists to satisfy depend.m4. It is never actually 450692f60a7Smrg # run, as this mode is specially recognized in the preamble. 451692f60a7Smrg exit 1 452692f60a7Smrg ;; 453692f60a7Smrg 454692f60a7Smrgmakedepend) 455692f60a7Smrg "$@" || exit $? 456692f60a7Smrg # Remove any Libtool call 457692f60a7Smrg if test "$libtool" = yes; then 458692f60a7Smrg while test $1 != '--mode=compile'; do 459692f60a7Smrg shift 460692f60a7Smrg done 461692f60a7Smrg shift 462692f60a7Smrg fi 463692f60a7Smrg # X makedepend 464692f60a7Smrg shift 465692f60a7Smrg cleared=no 466692f60a7Smrg for arg in "$@"; do 467692f60a7Smrg case $cleared in 468692f60a7Smrg no) 469692f60a7Smrg set ""; shift 470692f60a7Smrg cleared=yes ;; 471692f60a7Smrg esac 472692f60a7Smrg case "$arg" in 473692f60a7Smrg -D*|-I*) 474692f60a7Smrg set fnord "$@" "$arg"; shift ;; 475692f60a7Smrg # Strip any option that makedepend may not understand. Remove 476692f60a7Smrg # the object too, otherwise makedepend will parse it as a source file. 477692f60a7Smrg -*|$object) 478692f60a7Smrg ;; 479692f60a7Smrg *) 480692f60a7Smrg set fnord "$@" "$arg"; shift ;; 481692f60a7Smrg esac 482692f60a7Smrg done 483692f60a7Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 484692f60a7Smrg touch "$tmpdepfile" 485692f60a7Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 486692f60a7Smrg rm -f "$depfile" 487692f60a7Smrg cat < "$tmpdepfile" > "$depfile" 488692f60a7Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 489692f60a7Smrg' | \ 490692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 491692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 492692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 493692f60a7Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 494692f60a7Smrg ;; 495692f60a7Smrg 496692f60a7Smrgcpp) 497692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 498692f60a7Smrg # always write the preprocessed file to stdout. 499692f60a7Smrg "$@" || exit $? 500692f60a7Smrg 501692f60a7Smrg # Remove the call to Libtool. 502692f60a7Smrg if test "$libtool" = yes; then 503692f60a7Smrg while test $1 != '--mode=compile'; do 504692f60a7Smrg shift 505692f60a7Smrg done 506692f60a7Smrg shift 507692f60a7Smrg fi 508692f60a7Smrg 509692f60a7Smrg # Remove `-o $object'. 510692f60a7Smrg IFS=" " 511692f60a7Smrg for arg 512692f60a7Smrg do 513692f60a7Smrg case $arg in 514692f60a7Smrg -o) 515692f60a7Smrg shift 516692f60a7Smrg ;; 517692f60a7Smrg $object) 518692f60a7Smrg shift 519692f60a7Smrg ;; 520692f60a7Smrg *) 521692f60a7Smrg set fnord "$@" "$arg" 522692f60a7Smrg shift # fnord 523692f60a7Smrg shift # $arg 524692f60a7Smrg ;; 525692f60a7Smrg esac 526692f60a7Smrg done 527692f60a7Smrg 528692f60a7Smrg "$@" -E | 529692f60a7Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 530692f60a7Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 531692f60a7Smrg sed '$ s: \\$::' > "$tmpdepfile" 532692f60a7Smrg rm -f "$depfile" 533692f60a7Smrg echo "$object : \\" > "$depfile" 534692f60a7Smrg cat < "$tmpdepfile" >> "$depfile" 535692f60a7Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 536692f60a7Smrg rm -f "$tmpdepfile" 537692f60a7Smrg ;; 538692f60a7Smrg 539692f60a7Smrgmsvisualcpp) 540692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 541692f60a7Smrg # always write the preprocessed file to stdout, regardless of -o, 542692f60a7Smrg # because we must use -o when running libtool. 543692f60a7Smrg "$@" || exit $? 544692f60a7Smrg IFS=" " 545692f60a7Smrg for arg 546692f60a7Smrg do 547692f60a7Smrg case "$arg" in 548692f60a7Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 549692f60a7Smrg set fnord "$@" 550692f60a7Smrg shift 551692f60a7Smrg shift 552692f60a7Smrg ;; 553692f60a7Smrg *) 554692f60a7Smrg set fnord "$@" "$arg" 555692f60a7Smrg shift 556692f60a7Smrg shift 557692f60a7Smrg ;; 558692f60a7Smrg esac 559692f60a7Smrg done 560692f60a7Smrg "$@" -E | 561692f60a7Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 562692f60a7Smrg rm -f "$depfile" 563692f60a7Smrg echo "$object : \\" > "$depfile" 564692f60a7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 565692f60a7Smrg echo " " >> "$depfile" 566692f60a7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 567692f60a7Smrg rm -f "$tmpdepfile" 568692f60a7Smrg ;; 569692f60a7Smrg 570692f60a7Smrgnone) 571692f60a7Smrg exec "$@" 572692f60a7Smrg ;; 573692f60a7Smrg 574692f60a7Smrg*) 575692f60a7Smrg echo "Unknown depmode $depmode" 1>&2 576692f60a7Smrg exit 1 577692f60a7Smrg ;; 578692f60a7Smrgesac 579692f60a7Smrg 580692f60a7Smrgexit 0 581692f60a7Smrg 582692f60a7Smrg# Local Variables: 583692f60a7Smrg# mode: shell-script 584692f60a7Smrg# sh-indentation: 2 585692f60a7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 586692f60a7Smrg# time-stamp-start: "scriptversion=" 587692f60a7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 588692f60a7Smrg# time-stamp-end: "$" 589692f60a7Smrg# End: 590