1357bfbb2Smrg#! /bin/sh 2357bfbb2Smrg# depcomp - compile a program generating dependencies as side-effects 3357bfbb2Smrg 483e03a40Smrgscriptversion=2009-04-28.21; # UTC 5357bfbb2Smrg 683e03a40Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 783e03a40Smrg# Software Foundation, Inc. 8357bfbb2Smrg 9357bfbb2Smrg# This program is free software; you can redistribute it and/or modify 10357bfbb2Smrg# it under the terms of the GNU General Public License as published by 11357bfbb2Smrg# the Free Software Foundation; either version 2, or (at your option) 12357bfbb2Smrg# any later version. 13357bfbb2Smrg 14357bfbb2Smrg# This program is distributed in the hope that it will be useful, 15357bfbb2Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16357bfbb2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17357bfbb2Smrg# GNU General Public License for more details. 18357bfbb2Smrg 19357bfbb2Smrg# You should have received a copy of the GNU General Public License 2083e03a40Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21357bfbb2Smrg 22357bfbb2Smrg# As a special exception to the GNU General Public License, if you 23357bfbb2Smrg# distribute this file as part of a program that contains a 24357bfbb2Smrg# configuration script generated by Autoconf, you may include it under 25357bfbb2Smrg# the same distribution terms that you use for the rest of that program. 26357bfbb2Smrg 27357bfbb2Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28357bfbb2Smrg 29357bfbb2Smrgcase $1 in 30357bfbb2Smrg '') 31357bfbb2Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32357bfbb2Smrg exit 1; 33357bfbb2Smrg ;; 34357bfbb2Smrg -h | --h*) 35357bfbb2Smrg cat <<\EOF 36357bfbb2SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37357bfbb2Smrg 38357bfbb2SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39357bfbb2Smrgas side-effects. 40357bfbb2Smrg 41357bfbb2SmrgEnvironment variables: 42357bfbb2Smrg depmode Dependency tracking mode. 43357bfbb2Smrg source Source file read by `PROGRAMS ARGS'. 44357bfbb2Smrg object Object file output by `PROGRAMS ARGS'. 45357bfbb2Smrg DEPDIR directory where to store dependencies. 46357bfbb2Smrg depfile Dependency file to output. 47357bfbb2Smrg tmpdepfile Temporary file to use when outputing dependencies. 48357bfbb2Smrg libtool Whether libtool is used (yes/no). 49357bfbb2Smrg 50357bfbb2SmrgReport bugs to <bug-automake@gnu.org>. 51357bfbb2SmrgEOF 52357bfbb2Smrg exit $? 53357bfbb2Smrg ;; 54357bfbb2Smrg -v | --v*) 55357bfbb2Smrg echo "depcomp $scriptversion" 56357bfbb2Smrg exit $? 57357bfbb2Smrg ;; 58357bfbb2Smrgesac 59357bfbb2Smrg 60357bfbb2Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61357bfbb2Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62357bfbb2Smrg exit 1 63357bfbb2Smrgfi 64357bfbb2Smrg 65357bfbb2Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66357bfbb2Smrgdepfile=${depfile-`echo "$object" | 67357bfbb2Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68357bfbb2Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69357bfbb2Smrg 70357bfbb2Smrgrm -f "$tmpdepfile" 71357bfbb2Smrg 72357bfbb2Smrg# Some modes work just like other modes, but use different flags. We 73357bfbb2Smrg# parameterize here, but still list the modes in the big case below, 74357bfbb2Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75357bfbb2Smrg# here, because this file can only contain one case statement. 76357bfbb2Smrgif test "$depmode" = hp; then 77357bfbb2Smrg # HP compiler uses -M and no extra arg. 78357bfbb2Smrg gccflag=-M 79357bfbb2Smrg depmode=gcc 80357bfbb2Smrgfi 81357bfbb2Smrg 82357bfbb2Smrgif test "$depmode" = dashXmstdout; then 83357bfbb2Smrg # This is just like dashmstdout with a different argument. 84357bfbb2Smrg dashmflag=-xM 85357bfbb2Smrg depmode=dashmstdout 86357bfbb2Smrgfi 87357bfbb2Smrg 8883e03a40Smrgcygpath_u="cygpath -u -f -" 8983e03a40Smrgif test "$depmode" = msvcmsys; then 9083e03a40Smrg # This is just like msvisualcpp but w/o cygpath translation. 9183e03a40Smrg # Just convert the backslash-escaped backslashes to single forward 9283e03a40Smrg # slashes to satisfy depend.m4 9383e03a40Smrg cygpath_u="sed s,\\\\\\\\,/,g" 9483e03a40Smrg depmode=msvisualcpp 9583e03a40Smrgfi 9683e03a40Smrg 97357bfbb2Smrgcase "$depmode" in 98357bfbb2Smrggcc3) 99357bfbb2Smrg## gcc 3 implements dependency tracking that does exactly what 100357bfbb2Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101357bfbb2Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 10283e03a40Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 10383e03a40Smrg## the command line argument order; so add the flags where they 10483e03a40Smrg## appear in depend2.am. Note that the slowdown incurred here 10583e03a40Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 10683e03a40Smrg for arg 10783e03a40Smrg do 10883e03a40Smrg case $arg in 10983e03a40Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11083e03a40Smrg *) set fnord "$@" "$arg" ;; 11183e03a40Smrg esac 11283e03a40Smrg shift # fnord 11383e03a40Smrg shift # $arg 11483e03a40Smrg done 11583e03a40Smrg "$@" 116357bfbb2Smrg stat=$? 117357bfbb2Smrg if test $stat -eq 0; then : 118357bfbb2Smrg else 119357bfbb2Smrg rm -f "$tmpdepfile" 120357bfbb2Smrg exit $stat 121357bfbb2Smrg fi 122357bfbb2Smrg mv "$tmpdepfile" "$depfile" 123357bfbb2Smrg ;; 124357bfbb2Smrg 125357bfbb2Smrggcc) 126357bfbb2Smrg## There are various ways to get dependency output from gcc. Here's 127357bfbb2Smrg## why we pick this rather obscure method: 128357bfbb2Smrg## - Don't want to use -MD because we'd like the dependencies to end 129357bfbb2Smrg## up in a subdir. Having to rename by hand is ugly. 130357bfbb2Smrg## (We might end up doing this anyway to support other compilers.) 131357bfbb2Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132357bfbb2Smrg## -MM, not -M (despite what the docs say). 133357bfbb2Smrg## - Using -M directly means running the compiler twice (even worse 134357bfbb2Smrg## than renaming). 135357bfbb2Smrg if test -z "$gccflag"; then 136357bfbb2Smrg gccflag=-MD, 137357bfbb2Smrg fi 138357bfbb2Smrg "$@" -Wp,"$gccflag$tmpdepfile" 139357bfbb2Smrg stat=$? 140357bfbb2Smrg if test $stat -eq 0; then : 141357bfbb2Smrg else 142357bfbb2Smrg rm -f "$tmpdepfile" 143357bfbb2Smrg exit $stat 144357bfbb2Smrg fi 145357bfbb2Smrg rm -f "$depfile" 146357bfbb2Smrg echo "$object : \\" > "$depfile" 147357bfbb2Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148357bfbb2Smrg## The second -e expression handles DOS-style file names with drive letters. 149357bfbb2Smrg sed -e 's/^[^:]*: / /' \ 150357bfbb2Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151357bfbb2Smrg## This next piece of magic avoids the `deleted header file' problem. 152357bfbb2Smrg## The problem is that when a header file which appears in a .P file 153357bfbb2Smrg## is deleted, the dependency causes make to die (because there is 154357bfbb2Smrg## typically no way to rebuild the header). We avoid this by adding 155357bfbb2Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 156357bfbb2Smrg## this for us directly. 157357bfbb2Smrg tr ' ' ' 158357bfbb2Smrg' < "$tmpdepfile" | 159357bfbb2Smrg## Some versions of gcc put a space before the `:'. On the theory 160357bfbb2Smrg## that the space means something, we add a space to the output as 161357bfbb2Smrg## well. 162357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 163357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 164357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165357bfbb2Smrg rm -f "$tmpdepfile" 166357bfbb2Smrg ;; 167357bfbb2Smrg 168357bfbb2Smrghp) 169357bfbb2Smrg # This case exists only to let depend.m4 do its work. It works by 170357bfbb2Smrg # looking at the text of this script. This case will never be run, 171357bfbb2Smrg # since it is checked for above. 172357bfbb2Smrg exit 1 173357bfbb2Smrg ;; 174357bfbb2Smrg 175357bfbb2Smrgsgi) 176357bfbb2Smrg if test "$libtool" = yes; then 177357bfbb2Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178357bfbb2Smrg else 179357bfbb2Smrg "$@" -MDupdate "$tmpdepfile" 180357bfbb2Smrg fi 181357bfbb2Smrg stat=$? 182357bfbb2Smrg if test $stat -eq 0; then : 183357bfbb2Smrg else 184357bfbb2Smrg rm -f "$tmpdepfile" 185357bfbb2Smrg exit $stat 186357bfbb2Smrg fi 187357bfbb2Smrg rm -f "$depfile" 188357bfbb2Smrg 189357bfbb2Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190357bfbb2Smrg echo "$object : \\" > "$depfile" 191357bfbb2Smrg 192357bfbb2Smrg # Clip off the initial element (the dependent). Don't try to be 193357bfbb2Smrg # clever and replace this with sed code, as IRIX sed won't handle 194357bfbb2Smrg # lines with more than a fixed number of characters (4096 in 195357bfbb2Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196357bfbb2Smrg # the IRIX cc adds comments like `#:fec' to the end of the 197357bfbb2Smrg # dependency line. 198357bfbb2Smrg tr ' ' ' 199357bfbb2Smrg' < "$tmpdepfile" \ 200357bfbb2Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201357bfbb2Smrg tr ' 20283e03a40Smrg' ' ' >> "$depfile" 20383e03a40Smrg echo >> "$depfile" 204357bfbb2Smrg 205357bfbb2Smrg # The second pass generates a dummy entry for each header file. 206357bfbb2Smrg tr ' ' ' 207357bfbb2Smrg' < "$tmpdepfile" \ 208357bfbb2Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20983e03a40Smrg >> "$depfile" 210357bfbb2Smrg else 211357bfbb2Smrg # The sourcefile does not contain any dependencies, so just 212357bfbb2Smrg # store a dummy comment line, to avoid errors with the Makefile 213357bfbb2Smrg # "include basename.Plo" scheme. 214357bfbb2Smrg echo "#dummy" > "$depfile" 215357bfbb2Smrg fi 216357bfbb2Smrg rm -f "$tmpdepfile" 217357bfbb2Smrg ;; 218357bfbb2Smrg 219357bfbb2Smrgaix) 220357bfbb2Smrg # The C for AIX Compiler uses -M and outputs the dependencies 221357bfbb2Smrg # in a .u file. In older versions, this file always lives in the 222357bfbb2Smrg # current directory. Also, the AIX compiler puts `$object:' at the 223357bfbb2Smrg # start of each line; $object doesn't have directory information. 224357bfbb2Smrg # Version 6 uses the directory in both cases. 22583e03a40Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 22683e03a40Smrg test "x$dir" = "x$object" && dir= 22783e03a40Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228357bfbb2Smrg if test "$libtool" = yes; then 22983e03a40Smrg tmpdepfile1=$dir$base.u 23083e03a40Smrg tmpdepfile2=$base.u 23183e03a40Smrg tmpdepfile3=$dir.libs/$base.u 232357bfbb2Smrg "$@" -Wc,-M 233357bfbb2Smrg else 23483e03a40Smrg tmpdepfile1=$dir$base.u 23583e03a40Smrg tmpdepfile2=$dir$base.u 23683e03a40Smrg tmpdepfile3=$dir$base.u 237357bfbb2Smrg "$@" -M 238357bfbb2Smrg fi 239357bfbb2Smrg stat=$? 240357bfbb2Smrg 241357bfbb2Smrg if test $stat -eq 0; then : 242357bfbb2Smrg else 24383e03a40Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244357bfbb2Smrg exit $stat 245357bfbb2Smrg fi 246357bfbb2Smrg 24783e03a40Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24883e03a40Smrg do 24983e03a40Smrg test -f "$tmpdepfile" && break 25083e03a40Smrg done 251357bfbb2Smrg if test -f "$tmpdepfile"; then 252357bfbb2Smrg # Each line is of the form `foo.o: dependent.h'. 253357bfbb2Smrg # Do two passes, one to just change these to 254357bfbb2Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 25583e03a40Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 25683e03a40Smrg # That's a tab and a space in the []. 25783e03a40Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258357bfbb2Smrg else 259357bfbb2Smrg # The sourcefile does not contain any dependencies, so just 260357bfbb2Smrg # store a dummy comment line, to avoid errors with the Makefile 261357bfbb2Smrg # "include basename.Plo" scheme. 262357bfbb2Smrg echo "#dummy" > "$depfile" 263357bfbb2Smrg fi 264357bfbb2Smrg rm -f "$tmpdepfile" 265357bfbb2Smrg ;; 266357bfbb2Smrg 267357bfbb2Smrgicc) 268357bfbb2Smrg # Intel's C compiler understands `-MD -MF file'. However on 269357bfbb2Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270357bfbb2Smrg # ICC 7.0 will fill foo.d with something like 271357bfbb2Smrg # foo.o: sub/foo.c 272357bfbb2Smrg # foo.o: sub/foo.h 273357bfbb2Smrg # which is wrong. We want: 274357bfbb2Smrg # sub/foo.o: sub/foo.c 275357bfbb2Smrg # sub/foo.o: sub/foo.h 276357bfbb2Smrg # sub/foo.c: 277357bfbb2Smrg # sub/foo.h: 278357bfbb2Smrg # ICC 7.1 will output 279357bfbb2Smrg # foo.o: sub/foo.c sub/foo.h 280357bfbb2Smrg # and will wrap long lines using \ : 281357bfbb2Smrg # foo.o: sub/foo.c ... \ 282357bfbb2Smrg # sub/foo.h ... \ 283357bfbb2Smrg # ... 284357bfbb2Smrg 285357bfbb2Smrg "$@" -MD -MF "$tmpdepfile" 286357bfbb2Smrg stat=$? 287357bfbb2Smrg if test $stat -eq 0; then : 288357bfbb2Smrg else 289357bfbb2Smrg rm -f "$tmpdepfile" 290357bfbb2Smrg exit $stat 291357bfbb2Smrg fi 292357bfbb2Smrg rm -f "$depfile" 293357bfbb2Smrg # Each line is of the form `foo.o: dependent.h', 294357bfbb2Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295357bfbb2Smrg # Do two passes, one to just change these to 296357bfbb2Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 297357bfbb2Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298357bfbb2Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 299357bfbb2Smrg # correctly. Breaking it into two sed invocations is a workaround. 300357bfbb2Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301357bfbb2Smrg sed -e 's/$/ :/' >> "$depfile" 302357bfbb2Smrg rm -f "$tmpdepfile" 303357bfbb2Smrg ;; 304357bfbb2Smrg 30583e03a40Smrghp2) 30683e03a40Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 30783e03a40Smrg # compilers, which have integrated preprocessors. The correct option 30883e03a40Smrg # to use with these is +Maked; it writes dependencies to a file named 30983e03a40Smrg # 'foo.d', which lands next to the object file, wherever that 31083e03a40Smrg # happens to be. 31183e03a40Smrg # Much of this is similar to the tru64 case; see comments there. 31283e03a40Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 31383e03a40Smrg test "x$dir" = "x$object" && dir= 31483e03a40Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 31583e03a40Smrg if test "$libtool" = yes; then 31683e03a40Smrg tmpdepfile1=$dir$base.d 31783e03a40Smrg tmpdepfile2=$dir.libs/$base.d 31883e03a40Smrg "$@" -Wc,+Maked 31983e03a40Smrg else 32083e03a40Smrg tmpdepfile1=$dir$base.d 32183e03a40Smrg tmpdepfile2=$dir$base.d 32283e03a40Smrg "$@" +Maked 32383e03a40Smrg fi 32483e03a40Smrg stat=$? 32583e03a40Smrg if test $stat -eq 0; then : 32683e03a40Smrg else 32783e03a40Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 32883e03a40Smrg exit $stat 32983e03a40Smrg fi 33083e03a40Smrg 33183e03a40Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 33283e03a40Smrg do 33383e03a40Smrg test -f "$tmpdepfile" && break 33483e03a40Smrg done 33583e03a40Smrg if test -f "$tmpdepfile"; then 33683e03a40Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 33783e03a40Smrg # Add `dependent.h:' lines. 33883e03a40Smrg sed -ne '2,${ 33983e03a40Smrg s/^ *// 34083e03a40Smrg s/ \\*$// 34183e03a40Smrg s/$/:/ 34283e03a40Smrg p 34383e03a40Smrg }' "$tmpdepfile" >> "$depfile" 34483e03a40Smrg else 34583e03a40Smrg echo "#dummy" > "$depfile" 34683e03a40Smrg fi 34783e03a40Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 34883e03a40Smrg ;; 34983e03a40Smrg 350357bfbb2Smrgtru64) 351357bfbb2Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 352357bfbb2Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353357bfbb2Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354357bfbb2Smrg # dependencies in `foo.d' instead, so we check for that too. 355357bfbb2Smrg # Subdirectories are respected. 356357bfbb2Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357357bfbb2Smrg test "x$dir" = "x$object" && dir= 358357bfbb2Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359357bfbb2Smrg 360357bfbb2Smrg if test "$libtool" = yes; then 361357bfbb2Smrg # With Tru64 cc, shared objects can also be used to make a 36283e03a40Smrg # static library. This mechanism is used in libtool 1.4 series to 363357bfbb2Smrg # handle both shared and static libraries in a single compilation. 364357bfbb2Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365357bfbb2Smrg # 366357bfbb2Smrg # With libtool 1.5 this exception was removed, and libtool now 367357bfbb2Smrg # generates 2 separate objects for the 2 libraries. These two 36883e03a40Smrg # compilations output dependencies in $dir.libs/$base.o.d and 369357bfbb2Smrg # in $dir$base.o.d. We have to check for both files, because 370357bfbb2Smrg # one of the two compilations can be disabled. We should prefer 371357bfbb2Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372357bfbb2Smrg # automatically cleaned when .libs/ is deleted, while ignoring 373357bfbb2Smrg # the former would cause a distcleancheck panic. 374357bfbb2Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375357bfbb2Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376357bfbb2Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377357bfbb2Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378357bfbb2Smrg "$@" -Wc,-MD 379357bfbb2Smrg else 380357bfbb2Smrg tmpdepfile1=$dir$base.o.d 381357bfbb2Smrg tmpdepfile2=$dir$base.d 382357bfbb2Smrg tmpdepfile3=$dir$base.d 383357bfbb2Smrg tmpdepfile4=$dir$base.d 384357bfbb2Smrg "$@" -MD 385357bfbb2Smrg fi 386357bfbb2Smrg 387357bfbb2Smrg stat=$? 388357bfbb2Smrg if test $stat -eq 0; then : 389357bfbb2Smrg else 390357bfbb2Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391357bfbb2Smrg exit $stat 392357bfbb2Smrg fi 393357bfbb2Smrg 394357bfbb2Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395357bfbb2Smrg do 396357bfbb2Smrg test -f "$tmpdepfile" && break 397357bfbb2Smrg done 398357bfbb2Smrg if test -f "$tmpdepfile"; then 399357bfbb2Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400357bfbb2Smrg # That's a tab and a space in the []. 401357bfbb2Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402357bfbb2Smrg else 403357bfbb2Smrg echo "#dummy" > "$depfile" 404357bfbb2Smrg fi 405357bfbb2Smrg rm -f "$tmpdepfile" 406357bfbb2Smrg ;; 407357bfbb2Smrg 408357bfbb2Smrg#nosideeffect) 409357bfbb2Smrg # This comment above is used by automake to tell side-effect 410357bfbb2Smrg # dependency tracking mechanisms from slower ones. 411357bfbb2Smrg 412357bfbb2Smrgdashmstdout) 413357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 414357bfbb2Smrg # always write the preprocessed file to stdout, regardless of -o. 415357bfbb2Smrg "$@" || exit $? 416357bfbb2Smrg 417357bfbb2Smrg # Remove the call to Libtool. 418357bfbb2Smrg if test "$libtool" = yes; then 41983e03a40Smrg while test "X$1" != 'X--mode=compile'; do 420357bfbb2Smrg shift 421357bfbb2Smrg done 422357bfbb2Smrg shift 423357bfbb2Smrg fi 424357bfbb2Smrg 425357bfbb2Smrg # Remove `-o $object'. 426357bfbb2Smrg IFS=" " 427357bfbb2Smrg for arg 428357bfbb2Smrg do 429357bfbb2Smrg case $arg in 430357bfbb2Smrg -o) 431357bfbb2Smrg shift 432357bfbb2Smrg ;; 433357bfbb2Smrg $object) 434357bfbb2Smrg shift 435357bfbb2Smrg ;; 436357bfbb2Smrg *) 437357bfbb2Smrg set fnord "$@" "$arg" 438357bfbb2Smrg shift # fnord 439357bfbb2Smrg shift # $arg 440357bfbb2Smrg ;; 441357bfbb2Smrg esac 442357bfbb2Smrg done 443357bfbb2Smrg 444357bfbb2Smrg test -z "$dashmflag" && dashmflag=-M 445357bfbb2Smrg # Require at least two characters before searching for `:' 446357bfbb2Smrg # in the target name. This is to cope with DOS-style filenames: 447357bfbb2Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448357bfbb2Smrg "$@" $dashmflag | 449357bfbb2Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450357bfbb2Smrg rm -f "$depfile" 451357bfbb2Smrg cat < "$tmpdepfile" > "$depfile" 452357bfbb2Smrg tr ' ' ' 453357bfbb2Smrg' < "$tmpdepfile" | \ 454357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 455357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 456357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457357bfbb2Smrg rm -f "$tmpdepfile" 458357bfbb2Smrg ;; 459357bfbb2Smrg 460357bfbb2SmrgdashXmstdout) 461357bfbb2Smrg # This case only exists to satisfy depend.m4. It is never actually 462357bfbb2Smrg # run, as this mode is specially recognized in the preamble. 463357bfbb2Smrg exit 1 464357bfbb2Smrg ;; 465357bfbb2Smrg 466357bfbb2Smrgmakedepend) 467357bfbb2Smrg "$@" || exit $? 468357bfbb2Smrg # Remove any Libtool call 469357bfbb2Smrg if test "$libtool" = yes; then 47083e03a40Smrg while test "X$1" != 'X--mode=compile'; do 471357bfbb2Smrg shift 472357bfbb2Smrg done 473357bfbb2Smrg shift 474357bfbb2Smrg fi 475357bfbb2Smrg # X makedepend 476357bfbb2Smrg shift 47783e03a40Smrg cleared=no eat=no 47883e03a40Smrg for arg 47983e03a40Smrg do 480357bfbb2Smrg case $cleared in 481357bfbb2Smrg no) 482357bfbb2Smrg set ""; shift 483357bfbb2Smrg cleared=yes ;; 484357bfbb2Smrg esac 48583e03a40Smrg if test $eat = yes; then 48683e03a40Smrg eat=no 48783e03a40Smrg continue 48883e03a40Smrg fi 489357bfbb2Smrg case "$arg" in 490357bfbb2Smrg -D*|-I*) 491357bfbb2Smrg set fnord "$@" "$arg"; shift ;; 492357bfbb2Smrg # Strip any option that makedepend may not understand. Remove 493357bfbb2Smrg # the object too, otherwise makedepend will parse it as a source file. 49483e03a40Smrg -arch) 49583e03a40Smrg eat=yes ;; 496357bfbb2Smrg -*|$object) 497357bfbb2Smrg ;; 498357bfbb2Smrg *) 499357bfbb2Smrg set fnord "$@" "$arg"; shift ;; 500357bfbb2Smrg esac 501357bfbb2Smrg done 50283e03a40Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503357bfbb2Smrg touch "$tmpdepfile" 504357bfbb2Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505357bfbb2Smrg rm -f "$depfile" 506357bfbb2Smrg cat < "$tmpdepfile" > "$depfile" 507357bfbb2Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508357bfbb2Smrg' | \ 509357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 510357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 511357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512357bfbb2Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513357bfbb2Smrg ;; 514357bfbb2Smrg 515357bfbb2Smrgcpp) 516357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 517357bfbb2Smrg # always write the preprocessed file to stdout. 518357bfbb2Smrg "$@" || exit $? 519357bfbb2Smrg 520357bfbb2Smrg # Remove the call to Libtool. 521357bfbb2Smrg if test "$libtool" = yes; then 52283e03a40Smrg while test "X$1" != 'X--mode=compile'; do 523357bfbb2Smrg shift 524357bfbb2Smrg done 525357bfbb2Smrg shift 526357bfbb2Smrg fi 527357bfbb2Smrg 528357bfbb2Smrg # Remove `-o $object'. 529357bfbb2Smrg IFS=" " 530357bfbb2Smrg for arg 531357bfbb2Smrg do 532357bfbb2Smrg case $arg in 533357bfbb2Smrg -o) 534357bfbb2Smrg shift 535357bfbb2Smrg ;; 536357bfbb2Smrg $object) 537357bfbb2Smrg shift 538357bfbb2Smrg ;; 539357bfbb2Smrg *) 540357bfbb2Smrg set fnord "$@" "$arg" 541357bfbb2Smrg shift # fnord 542357bfbb2Smrg shift # $arg 543357bfbb2Smrg ;; 544357bfbb2Smrg esac 545357bfbb2Smrg done 546357bfbb2Smrg 547357bfbb2Smrg "$@" -E | 548357bfbb2Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549357bfbb2Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550357bfbb2Smrg sed '$ s: \\$::' > "$tmpdepfile" 551357bfbb2Smrg rm -f "$depfile" 552357bfbb2Smrg echo "$object : \\" > "$depfile" 553357bfbb2Smrg cat < "$tmpdepfile" >> "$depfile" 554357bfbb2Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555357bfbb2Smrg rm -f "$tmpdepfile" 556357bfbb2Smrg ;; 557357bfbb2Smrg 558357bfbb2Smrgmsvisualcpp) 559357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 56083e03a40Smrg # always write the preprocessed file to stdout. 561357bfbb2Smrg "$@" || exit $? 56283e03a40Smrg 56383e03a40Smrg # Remove the call to Libtool. 56483e03a40Smrg if test "$libtool" = yes; then 56583e03a40Smrg while test "X$1" != 'X--mode=compile'; do 56683e03a40Smrg shift 56783e03a40Smrg done 56883e03a40Smrg shift 56983e03a40Smrg fi 57083e03a40Smrg 571357bfbb2Smrg IFS=" " 572357bfbb2Smrg for arg 573357bfbb2Smrg do 574357bfbb2Smrg case "$arg" in 57583e03a40Smrg -o) 57683e03a40Smrg shift 57783e03a40Smrg ;; 57883e03a40Smrg $object) 57983e03a40Smrg shift 58083e03a40Smrg ;; 581357bfbb2Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582357bfbb2Smrg set fnord "$@" 583357bfbb2Smrg shift 584357bfbb2Smrg shift 585357bfbb2Smrg ;; 586357bfbb2Smrg *) 587357bfbb2Smrg set fnord "$@" "$arg" 588357bfbb2Smrg shift 589357bfbb2Smrg shift 590357bfbb2Smrg ;; 591357bfbb2Smrg esac 592357bfbb2Smrg done 59383e03a40Smrg "$@" -E 2>/dev/null | 59483e03a40Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595357bfbb2Smrg rm -f "$depfile" 596357bfbb2Smrg echo "$object : \\" > "$depfile" 59783e03a40Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598357bfbb2Smrg echo " " >> "$depfile" 59983e03a40Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600357bfbb2Smrg rm -f "$tmpdepfile" 601357bfbb2Smrg ;; 602357bfbb2Smrg 60383e03a40Smrgmsvcmsys) 60483e03a40Smrg # This case exists only to let depend.m4 do its work. It works by 60583e03a40Smrg # looking at the text of this script. This case will never be run, 60683e03a40Smrg # since it is checked for above. 60783e03a40Smrg exit 1 60883e03a40Smrg ;; 60983e03a40Smrg 610357bfbb2Smrgnone) 611357bfbb2Smrg exec "$@" 612357bfbb2Smrg ;; 613357bfbb2Smrg 614357bfbb2Smrg*) 615357bfbb2Smrg echo "Unknown depmode $depmode" 1>&2 616357bfbb2Smrg exit 1 617357bfbb2Smrg ;; 618357bfbb2Smrgesac 619357bfbb2Smrg 620357bfbb2Smrgexit 0 621357bfbb2Smrg 622357bfbb2Smrg# Local Variables: 623357bfbb2Smrg# mode: shell-script 624357bfbb2Smrg# sh-indentation: 2 625357bfbb2Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626357bfbb2Smrg# time-stamp-start: "scriptversion=" 627357bfbb2Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62883e03a40Smrg# time-stamp-time-zone: "UTC" 62983e03a40Smrg# time-stamp-end: "; # UTC" 630357bfbb2Smrg# End: 631