depcomp revision aa9e3350
1ab47cfaaSmrg#! /bin/sh 2ab47cfaaSmrg# depcomp - compile a program generating dependencies as side-effects 3ab47cfaaSmrg 4aa9e3350Smrgscriptversion=2011-12-04.11; # UTC 5ab47cfaaSmrg 6aa9e3350Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7aa9e3350Smrg# 2011 Free Software Foundation, Inc. 8ab47cfaaSmrg 9ab47cfaaSmrg# This program is free software; you can redistribute it and/or modify 10ab47cfaaSmrg# it under the terms of the GNU General Public License as published by 11ab47cfaaSmrg# the Free Software Foundation; either version 2, or (at your option) 12ab47cfaaSmrg# any later version. 13ab47cfaaSmrg 14ab47cfaaSmrg# This program is distributed in the hope that it will be useful, 15ab47cfaaSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16ab47cfaaSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17ab47cfaaSmrg# GNU General Public License for more details. 18ab47cfaaSmrg 19ab47cfaaSmrg# You should have received a copy of the GNU General Public License 205c42550eSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21ab47cfaaSmrg 22ab47cfaaSmrg# As a special exception to the GNU General Public License, if you 23ab47cfaaSmrg# distribute this file as part of a program that contains a 24ab47cfaaSmrg# configuration script generated by Autoconf, you may include it under 25ab47cfaaSmrg# the same distribution terms that you use for the rest of that program. 26ab47cfaaSmrg 27ab47cfaaSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28ab47cfaaSmrg 29ab47cfaaSmrgcase $1 in 30ab47cfaaSmrg '') 31ab47cfaaSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32ab47cfaaSmrg exit 1; 33ab47cfaaSmrg ;; 34ab47cfaaSmrg -h | --h*) 35ab47cfaaSmrg cat <<\EOF 36ab47cfaaSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37ab47cfaaSmrg 38ab47cfaaSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39ab47cfaaSmrgas side-effects. 40ab47cfaaSmrg 41ab47cfaaSmrgEnvironment variables: 42ab47cfaaSmrg depmode Dependency tracking mode. 43ab47cfaaSmrg source Source file read by `PROGRAMS ARGS'. 44ab47cfaaSmrg object Object file output by `PROGRAMS ARGS'. 45ab47cfaaSmrg DEPDIR directory where to store dependencies. 46ab47cfaaSmrg depfile Dependency file to output. 47aa9e3350Smrg tmpdepfile Temporary file to use when outputting dependencies. 48ab47cfaaSmrg libtool Whether libtool is used (yes/no). 49ab47cfaaSmrg 50ab47cfaaSmrgReport bugs to <bug-automake@gnu.org>. 51ab47cfaaSmrgEOF 52ab47cfaaSmrg exit $? 53ab47cfaaSmrg ;; 54ab47cfaaSmrg -v | --v*) 55ab47cfaaSmrg echo "depcomp $scriptversion" 56ab47cfaaSmrg exit $? 57ab47cfaaSmrg ;; 58ab47cfaaSmrgesac 59ab47cfaaSmrg 60ab47cfaaSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61ab47cfaaSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62ab47cfaaSmrg exit 1 63ab47cfaaSmrgfi 64ab47cfaaSmrg 65ab47cfaaSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66ab47cfaaSmrgdepfile=${depfile-`echo "$object" | 67ab47cfaaSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68ab47cfaaSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69ab47cfaaSmrg 70ab47cfaaSmrgrm -f "$tmpdepfile" 71ab47cfaaSmrg 72ab47cfaaSmrg# Some modes work just like other modes, but use different flags. We 73ab47cfaaSmrg# parameterize here, but still list the modes in the big case below, 74ab47cfaaSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75ab47cfaaSmrg# here, because this file can only contain one case statement. 76ab47cfaaSmrgif test "$depmode" = hp; then 77ab47cfaaSmrg # HP compiler uses -M and no extra arg. 78ab47cfaaSmrg gccflag=-M 79ab47cfaaSmrg depmode=gcc 80ab47cfaaSmrgfi 81ab47cfaaSmrg 82ab47cfaaSmrgif test "$depmode" = dashXmstdout; then 83ab47cfaaSmrg # This is just like dashmstdout with a different argument. 84ab47cfaaSmrg dashmflag=-xM 85ab47cfaaSmrg depmode=dashmstdout 86ab47cfaaSmrgfi 87ab47cfaaSmrg 885c42550eSmrgcygpath_u="cygpath -u -f -" 895c42550eSmrgif test "$depmode" = msvcmsys; then 905c42550eSmrg # This is just like msvisualcpp but w/o cygpath translation. 915c42550eSmrg # Just convert the backslash-escaped backslashes to single forward 925c42550eSmrg # slashes to satisfy depend.m4 93aa9e3350Smrg cygpath_u='sed s,\\\\,/,g' 945c42550eSmrg depmode=msvisualcpp 955c42550eSmrgfi 965c42550eSmrg 97aa9e3350Smrgif test "$depmode" = msvc7msys; then 98aa9e3350Smrg # This is just like msvc7 but w/o cygpath translation. 99aa9e3350Smrg # Just convert the backslash-escaped backslashes to single forward 100aa9e3350Smrg # slashes to satisfy depend.m4 101aa9e3350Smrg cygpath_u='sed s,\\\\,/,g' 102aa9e3350Smrg depmode=msvc7 103aa9e3350Smrgfi 104aa9e3350Smrg 105ab47cfaaSmrgcase "$depmode" in 106ab47cfaaSmrggcc3) 107ab47cfaaSmrg## gcc 3 implements dependency tracking that does exactly what 108ab47cfaaSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109ab47cfaaSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1108697ee19Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1118697ee19Smrg## the command line argument order; so add the flags where they 1128697ee19Smrg## appear in depend2.am. Note that the slowdown incurred here 1138697ee19Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1148697ee19Smrg for arg 1158697ee19Smrg do 1168697ee19Smrg case $arg in 1178697ee19Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1188697ee19Smrg *) set fnord "$@" "$arg" ;; 1198697ee19Smrg esac 1208697ee19Smrg shift # fnord 1218697ee19Smrg shift # $arg 1228697ee19Smrg done 1238697ee19Smrg "$@" 124ab47cfaaSmrg stat=$? 125ab47cfaaSmrg if test $stat -eq 0; then : 126ab47cfaaSmrg else 127ab47cfaaSmrg rm -f "$tmpdepfile" 128ab47cfaaSmrg exit $stat 129ab47cfaaSmrg fi 130ab47cfaaSmrg mv "$tmpdepfile" "$depfile" 131ab47cfaaSmrg ;; 132ab47cfaaSmrg 133ab47cfaaSmrggcc) 134ab47cfaaSmrg## There are various ways to get dependency output from gcc. Here's 135ab47cfaaSmrg## why we pick this rather obscure method: 136ab47cfaaSmrg## - Don't want to use -MD because we'd like the dependencies to end 137ab47cfaaSmrg## up in a subdir. Having to rename by hand is ugly. 138ab47cfaaSmrg## (We might end up doing this anyway to support other compilers.) 139ab47cfaaSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140ab47cfaaSmrg## -MM, not -M (despite what the docs say). 141ab47cfaaSmrg## - Using -M directly means running the compiler twice (even worse 142ab47cfaaSmrg## than renaming). 143ab47cfaaSmrg if test -z "$gccflag"; then 144ab47cfaaSmrg gccflag=-MD, 145ab47cfaaSmrg fi 146ab47cfaaSmrg "$@" -Wp,"$gccflag$tmpdepfile" 147ab47cfaaSmrg stat=$? 148ab47cfaaSmrg if test $stat -eq 0; then : 149ab47cfaaSmrg else 150ab47cfaaSmrg rm -f "$tmpdepfile" 151ab47cfaaSmrg exit $stat 152ab47cfaaSmrg fi 153ab47cfaaSmrg rm -f "$depfile" 154ab47cfaaSmrg echo "$object : \\" > "$depfile" 155ab47cfaaSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156ab47cfaaSmrg## The second -e expression handles DOS-style file names with drive letters. 157ab47cfaaSmrg sed -e 's/^[^:]*: / /' \ 158ab47cfaaSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159ab47cfaaSmrg## This next piece of magic avoids the `deleted header file' problem. 160ab47cfaaSmrg## The problem is that when a header file which appears in a .P file 161ab47cfaaSmrg## is deleted, the dependency causes make to die (because there is 162ab47cfaaSmrg## typically no way to rebuild the header). We avoid this by adding 163ab47cfaaSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 164ab47cfaaSmrg## this for us directly. 165ab47cfaaSmrg tr ' ' ' 166ab47cfaaSmrg' < "$tmpdepfile" | 167ab47cfaaSmrg## Some versions of gcc put a space before the `:'. On the theory 168ab47cfaaSmrg## that the space means something, we add a space to the output as 169aa9e3350Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 170aa9e3350Smrg## to the object. Take care to not repeat it in the output. 171ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 172ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 173aa9e3350Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 174aa9e3350Smrg | sed -e 's/$/ :/' >> "$depfile" 175ab47cfaaSmrg rm -f "$tmpdepfile" 176ab47cfaaSmrg ;; 177ab47cfaaSmrg 178ab47cfaaSmrghp) 179ab47cfaaSmrg # This case exists only to let depend.m4 do its work. It works by 180ab47cfaaSmrg # looking at the text of this script. This case will never be run, 181ab47cfaaSmrg # since it is checked for above. 182ab47cfaaSmrg exit 1 183ab47cfaaSmrg ;; 184ab47cfaaSmrg 185ab47cfaaSmrgsgi) 186ab47cfaaSmrg if test "$libtool" = yes; then 187ab47cfaaSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188ab47cfaaSmrg else 189ab47cfaaSmrg "$@" -MDupdate "$tmpdepfile" 190ab47cfaaSmrg fi 191ab47cfaaSmrg stat=$? 192ab47cfaaSmrg if test $stat -eq 0; then : 193ab47cfaaSmrg else 194ab47cfaaSmrg rm -f "$tmpdepfile" 195ab47cfaaSmrg exit $stat 196ab47cfaaSmrg fi 197ab47cfaaSmrg rm -f "$depfile" 198ab47cfaaSmrg 199ab47cfaaSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200ab47cfaaSmrg echo "$object : \\" > "$depfile" 201ab47cfaaSmrg 202ab47cfaaSmrg # Clip off the initial element (the dependent). Don't try to be 203ab47cfaaSmrg # clever and replace this with sed code, as IRIX sed won't handle 204ab47cfaaSmrg # lines with more than a fixed number of characters (4096 in 205ab47cfaaSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206ab47cfaaSmrg # the IRIX cc adds comments like `#:fec' to the end of the 207ab47cfaaSmrg # dependency line. 208ab47cfaaSmrg tr ' ' ' 209ab47cfaaSmrg' < "$tmpdepfile" \ 210ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211ab47cfaaSmrg tr ' 2125c42550eSmrg' ' ' >> "$depfile" 2135c42550eSmrg echo >> "$depfile" 214ab47cfaaSmrg 215ab47cfaaSmrg # The second pass generates a dummy entry for each header file. 216ab47cfaaSmrg tr ' ' ' 217ab47cfaaSmrg' < "$tmpdepfile" \ 218ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2195c42550eSmrg >> "$depfile" 220ab47cfaaSmrg else 221ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 222ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 223ab47cfaaSmrg # "include basename.Plo" scheme. 224ab47cfaaSmrg echo "#dummy" > "$depfile" 225ab47cfaaSmrg fi 226ab47cfaaSmrg rm -f "$tmpdepfile" 227ab47cfaaSmrg ;; 228ab47cfaaSmrg 229ab47cfaaSmrgaix) 230ab47cfaaSmrg # The C for AIX Compiler uses -M and outputs the dependencies 231ab47cfaaSmrg # in a .u file. In older versions, this file always lives in the 232ab47cfaaSmrg # current directory. Also, the AIX compiler puts `$object:' at the 233ab47cfaaSmrg # start of each line; $object doesn't have directory information. 234ab47cfaaSmrg # Version 6 uses the directory in both cases. 2351473d951Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2361473d951Smrg test "x$dir" = "x$object" && dir= 2371473d951Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238ab47cfaaSmrg if test "$libtool" = yes; then 2391473d951Smrg tmpdepfile1=$dir$base.u 2401473d951Smrg tmpdepfile2=$base.u 2411473d951Smrg tmpdepfile3=$dir.libs/$base.u 242ab47cfaaSmrg "$@" -Wc,-M 243ab47cfaaSmrg else 2441473d951Smrg tmpdepfile1=$dir$base.u 2451473d951Smrg tmpdepfile2=$dir$base.u 2461473d951Smrg tmpdepfile3=$dir$base.u 247ab47cfaaSmrg "$@" -M 248ab47cfaaSmrg fi 249ab47cfaaSmrg stat=$? 250ab47cfaaSmrg 251ab47cfaaSmrg if test $stat -eq 0; then : 252ab47cfaaSmrg else 2531473d951Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254ab47cfaaSmrg exit $stat 255ab47cfaaSmrg fi 256ab47cfaaSmrg 2571473d951Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2581473d951Smrg do 2591473d951Smrg test -f "$tmpdepfile" && break 2601473d951Smrg done 261ab47cfaaSmrg if test -f "$tmpdepfile"; then 262ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h'. 263ab47cfaaSmrg # Do two passes, one to just change these to 264ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 2651473d951Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2661473d951Smrg # That's a tab and a space in the []. 2671473d951Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268ab47cfaaSmrg else 269ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 270ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 271ab47cfaaSmrg # "include basename.Plo" scheme. 272ab47cfaaSmrg echo "#dummy" > "$depfile" 273ab47cfaaSmrg fi 274ab47cfaaSmrg rm -f "$tmpdepfile" 275ab47cfaaSmrg ;; 276ab47cfaaSmrg 277ab47cfaaSmrgicc) 278ab47cfaaSmrg # Intel's C compiler understands `-MD -MF file'. However on 279ab47cfaaSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280ab47cfaaSmrg # ICC 7.0 will fill foo.d with something like 281ab47cfaaSmrg # foo.o: sub/foo.c 282ab47cfaaSmrg # foo.o: sub/foo.h 283ab47cfaaSmrg # which is wrong. We want: 284ab47cfaaSmrg # sub/foo.o: sub/foo.c 285ab47cfaaSmrg # sub/foo.o: sub/foo.h 286ab47cfaaSmrg # sub/foo.c: 287ab47cfaaSmrg # sub/foo.h: 288ab47cfaaSmrg # ICC 7.1 will output 289ab47cfaaSmrg # foo.o: sub/foo.c sub/foo.h 290ab47cfaaSmrg # and will wrap long lines using \ : 291ab47cfaaSmrg # foo.o: sub/foo.c ... \ 292ab47cfaaSmrg # sub/foo.h ... \ 293ab47cfaaSmrg # ... 294ab47cfaaSmrg 295ab47cfaaSmrg "$@" -MD -MF "$tmpdepfile" 296ab47cfaaSmrg stat=$? 297ab47cfaaSmrg if test $stat -eq 0; then : 298ab47cfaaSmrg else 299ab47cfaaSmrg rm -f "$tmpdepfile" 300ab47cfaaSmrg exit $stat 301ab47cfaaSmrg fi 302ab47cfaaSmrg rm -f "$depfile" 303ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h', 304ab47cfaaSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305ab47cfaaSmrg # Do two passes, one to just change these to 306ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 307ab47cfaaSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308ab47cfaaSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 309ab47cfaaSmrg # correctly. Breaking it into two sed invocations is a workaround. 310ab47cfaaSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311ab47cfaaSmrg sed -e 's/$/ :/' >> "$depfile" 312ab47cfaaSmrg rm -f "$tmpdepfile" 313ab47cfaaSmrg ;; 314ab47cfaaSmrg 3158697ee19Smrghp2) 3168697ee19Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3178697ee19Smrg # compilers, which have integrated preprocessors. The correct option 3188697ee19Smrg # to use with these is +Maked; it writes dependencies to a file named 3198697ee19Smrg # 'foo.d', which lands next to the object file, wherever that 3208697ee19Smrg # happens to be. 3218697ee19Smrg # Much of this is similar to the tru64 case; see comments there. 3228697ee19Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3238697ee19Smrg test "x$dir" = "x$object" && dir= 3248697ee19Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3258697ee19Smrg if test "$libtool" = yes; then 3268697ee19Smrg tmpdepfile1=$dir$base.d 3278697ee19Smrg tmpdepfile2=$dir.libs/$base.d 3288697ee19Smrg "$@" -Wc,+Maked 3298697ee19Smrg else 3308697ee19Smrg tmpdepfile1=$dir$base.d 3318697ee19Smrg tmpdepfile2=$dir$base.d 3328697ee19Smrg "$@" +Maked 3338697ee19Smrg fi 3348697ee19Smrg stat=$? 3358697ee19Smrg if test $stat -eq 0; then : 3368697ee19Smrg else 3378697ee19Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3388697ee19Smrg exit $stat 3398697ee19Smrg fi 3408697ee19Smrg 3418697ee19Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3428697ee19Smrg do 3438697ee19Smrg test -f "$tmpdepfile" && break 3448697ee19Smrg done 3458697ee19Smrg if test -f "$tmpdepfile"; then 3468697ee19Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3478697ee19Smrg # Add `dependent.h:' lines. 3485c42550eSmrg sed -ne '2,${ 3495c42550eSmrg s/^ *// 3505c42550eSmrg s/ \\*$// 3515c42550eSmrg s/$/:/ 3525c42550eSmrg p 3535c42550eSmrg }' "$tmpdepfile" >> "$depfile" 3548697ee19Smrg else 3558697ee19Smrg echo "#dummy" > "$depfile" 3568697ee19Smrg fi 3578697ee19Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3588697ee19Smrg ;; 3598697ee19Smrg 360ab47cfaaSmrgtru64) 361ab47cfaaSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 362ab47cfaaSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363ab47cfaaSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364ab47cfaaSmrg # dependencies in `foo.d' instead, so we check for that too. 365ab47cfaaSmrg # Subdirectories are respected. 366ab47cfaaSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367ab47cfaaSmrg test "x$dir" = "x$object" && dir= 368ab47cfaaSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369ab47cfaaSmrg 370ab47cfaaSmrg if test "$libtool" = yes; then 371ab47cfaaSmrg # With Tru64 cc, shared objects can also be used to make a 3728697ee19Smrg # static library. This mechanism is used in libtool 1.4 series to 373ab47cfaaSmrg # handle both shared and static libraries in a single compilation. 374ab47cfaaSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 375ab47cfaaSmrg # 376ab47cfaaSmrg # With libtool 1.5 this exception was removed, and libtool now 377ab47cfaaSmrg # generates 2 separate objects for the 2 libraries. These two 3788697ee19Smrg # compilations output dependencies in $dir.libs/$base.o.d and 379ab47cfaaSmrg # in $dir$base.o.d. We have to check for both files, because 380ab47cfaaSmrg # one of the two compilations can be disabled. We should prefer 381ab47cfaaSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 382ab47cfaaSmrg # automatically cleaned when .libs/ is deleted, while ignoring 383ab47cfaaSmrg # the former would cause a distcleancheck panic. 384ab47cfaaSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 385ab47cfaaSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 386ab47cfaaSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 387ab47cfaaSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388ab47cfaaSmrg "$@" -Wc,-MD 389ab47cfaaSmrg else 390ab47cfaaSmrg tmpdepfile1=$dir$base.o.d 391ab47cfaaSmrg tmpdepfile2=$dir$base.d 392ab47cfaaSmrg tmpdepfile3=$dir$base.d 393ab47cfaaSmrg tmpdepfile4=$dir$base.d 394ab47cfaaSmrg "$@" -MD 395ab47cfaaSmrg fi 396ab47cfaaSmrg 397ab47cfaaSmrg stat=$? 398ab47cfaaSmrg if test $stat -eq 0; then : 399ab47cfaaSmrg else 400ab47cfaaSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401ab47cfaaSmrg exit $stat 402ab47cfaaSmrg fi 403ab47cfaaSmrg 404ab47cfaaSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 405ab47cfaaSmrg do 406ab47cfaaSmrg test -f "$tmpdepfile" && break 407ab47cfaaSmrg done 408ab47cfaaSmrg if test -f "$tmpdepfile"; then 409ab47cfaaSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410ab47cfaaSmrg # That's a tab and a space in the []. 411ab47cfaaSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412ab47cfaaSmrg else 413ab47cfaaSmrg echo "#dummy" > "$depfile" 414ab47cfaaSmrg fi 415ab47cfaaSmrg rm -f "$tmpdepfile" 416ab47cfaaSmrg ;; 417ab47cfaaSmrg 418aa9e3350Smrgmsvc7) 419aa9e3350Smrg if test "$libtool" = yes; then 420aa9e3350Smrg showIncludes=-Wc,-showIncludes 421aa9e3350Smrg else 422aa9e3350Smrg showIncludes=-showIncludes 423aa9e3350Smrg fi 424aa9e3350Smrg "$@" $showIncludes > "$tmpdepfile" 425aa9e3350Smrg stat=$? 426aa9e3350Smrg grep -v '^Note: including file: ' "$tmpdepfile" 427aa9e3350Smrg if test "$stat" = 0; then : 428aa9e3350Smrg else 429aa9e3350Smrg rm -f "$tmpdepfile" 430aa9e3350Smrg exit $stat 431aa9e3350Smrg fi 432aa9e3350Smrg rm -f "$depfile" 433aa9e3350Smrg echo "$object : \\" > "$depfile" 434aa9e3350Smrg # The first sed program below extracts the file names and escapes 435aa9e3350Smrg # backslashes for cygpath. The second sed program outputs the file 436aa9e3350Smrg # name when reading, but also accumulates all include files in the 437aa9e3350Smrg # hold buffer in order to output them again at the end. This only 438aa9e3350Smrg # works with sed implementations that can handle large buffers. 439aa9e3350Smrg sed < "$tmpdepfile" -n ' 440aa9e3350Smrg/^Note: including file: *\(.*\)/ { 441aa9e3350Smrg s//\1/ 442aa9e3350Smrg s/\\/\\\\/g 443aa9e3350Smrg p 444aa9e3350Smrg}' | $cygpath_u | sort -u | sed -n ' 445aa9e3350Smrgs/ /\\ /g 446aa9e3350Smrgs/\(.*\)/ \1 \\/p 447aa9e3350Smrgs/.\(.*\) \\/\1:/ 448aa9e3350SmrgH 449aa9e3350Smrg$ { 450aa9e3350Smrg s/.*/ / 451aa9e3350Smrg G 452aa9e3350Smrg p 453aa9e3350Smrg}' >> "$depfile" 454aa9e3350Smrg rm -f "$tmpdepfile" 455aa9e3350Smrg ;; 456aa9e3350Smrg 457aa9e3350Smrgmsvc7msys) 458aa9e3350Smrg # This case exists only to let depend.m4 do its work. It works by 459aa9e3350Smrg # looking at the text of this script. This case will never be run, 460aa9e3350Smrg # since it is checked for above. 461aa9e3350Smrg exit 1 462aa9e3350Smrg ;; 463aa9e3350Smrg 464ab47cfaaSmrg#nosideeffect) 465ab47cfaaSmrg # This comment above is used by automake to tell side-effect 466ab47cfaaSmrg # dependency tracking mechanisms from slower ones. 467ab47cfaaSmrg 468ab47cfaaSmrgdashmstdout) 469ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 470ab47cfaaSmrg # always write the preprocessed file to stdout, regardless of -o. 471ab47cfaaSmrg "$@" || exit $? 472ab47cfaaSmrg 473ab47cfaaSmrg # Remove the call to Libtool. 474ab47cfaaSmrg if test "$libtool" = yes; then 4755c42550eSmrg while test "X$1" != 'X--mode=compile'; do 476ab47cfaaSmrg shift 477ab47cfaaSmrg done 478ab47cfaaSmrg shift 479ab47cfaaSmrg fi 480ab47cfaaSmrg 481ab47cfaaSmrg # Remove `-o $object'. 482ab47cfaaSmrg IFS=" " 483ab47cfaaSmrg for arg 484ab47cfaaSmrg do 485ab47cfaaSmrg case $arg in 486ab47cfaaSmrg -o) 487ab47cfaaSmrg shift 488ab47cfaaSmrg ;; 489ab47cfaaSmrg $object) 490ab47cfaaSmrg shift 491ab47cfaaSmrg ;; 492ab47cfaaSmrg *) 493ab47cfaaSmrg set fnord "$@" "$arg" 494ab47cfaaSmrg shift # fnord 495ab47cfaaSmrg shift # $arg 496ab47cfaaSmrg ;; 497ab47cfaaSmrg esac 498ab47cfaaSmrg done 499ab47cfaaSmrg 500ab47cfaaSmrg test -z "$dashmflag" && dashmflag=-M 501ab47cfaaSmrg # Require at least two characters before searching for `:' 502ab47cfaaSmrg # in the target name. This is to cope with DOS-style filenames: 503ab47cfaaSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504ab47cfaaSmrg "$@" $dashmflag | 505ab47cfaaSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506ab47cfaaSmrg rm -f "$depfile" 507ab47cfaaSmrg cat < "$tmpdepfile" > "$depfile" 508ab47cfaaSmrg tr ' ' ' 509ab47cfaaSmrg' < "$tmpdepfile" | \ 510ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 511ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 512ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513ab47cfaaSmrg rm -f "$tmpdepfile" 514ab47cfaaSmrg ;; 515ab47cfaaSmrg 516ab47cfaaSmrgdashXmstdout) 517ab47cfaaSmrg # This case only exists to satisfy depend.m4. It is never actually 518ab47cfaaSmrg # run, as this mode is specially recognized in the preamble. 519ab47cfaaSmrg exit 1 520ab47cfaaSmrg ;; 521ab47cfaaSmrg 522ab47cfaaSmrgmakedepend) 523ab47cfaaSmrg "$@" || exit $? 524ab47cfaaSmrg # Remove any Libtool call 525ab47cfaaSmrg if test "$libtool" = yes; then 5265c42550eSmrg while test "X$1" != 'X--mode=compile'; do 527ab47cfaaSmrg shift 528ab47cfaaSmrg done 529ab47cfaaSmrg shift 530ab47cfaaSmrg fi 531ab47cfaaSmrg # X makedepend 532ab47cfaaSmrg shift 5335c42550eSmrg cleared=no eat=no 5345c42550eSmrg for arg 5355c42550eSmrg do 536ab47cfaaSmrg case $cleared in 537ab47cfaaSmrg no) 538ab47cfaaSmrg set ""; shift 539ab47cfaaSmrg cleared=yes ;; 540ab47cfaaSmrg esac 5415c42550eSmrg if test $eat = yes; then 5425c42550eSmrg eat=no 5435c42550eSmrg continue 5445c42550eSmrg fi 545ab47cfaaSmrg case "$arg" in 546ab47cfaaSmrg -D*|-I*) 547ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 548ab47cfaaSmrg # Strip any option that makedepend may not understand. Remove 549ab47cfaaSmrg # the object too, otherwise makedepend will parse it as a source file. 5505c42550eSmrg -arch) 5515c42550eSmrg eat=yes ;; 552ab47cfaaSmrg -*|$object) 553ab47cfaaSmrg ;; 554ab47cfaaSmrg *) 555ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 556ab47cfaaSmrg esac 557ab47cfaaSmrg done 5585c42550eSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559ab47cfaaSmrg touch "$tmpdepfile" 560ab47cfaaSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561ab47cfaaSmrg rm -f "$depfile" 562aa9e3350Smrg # makedepend may prepend the VPATH from the source file name to the object. 563aa9e3350Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 564aa9e3350Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565ab47cfaaSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566ab47cfaaSmrg' | \ 567ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 568ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 569ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570ab47cfaaSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571ab47cfaaSmrg ;; 572ab47cfaaSmrg 573ab47cfaaSmrgcpp) 574ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 575ab47cfaaSmrg # always write the preprocessed file to stdout. 576ab47cfaaSmrg "$@" || exit $? 577ab47cfaaSmrg 578ab47cfaaSmrg # Remove the call to Libtool. 579ab47cfaaSmrg if test "$libtool" = yes; then 5805c42550eSmrg while test "X$1" != 'X--mode=compile'; do 581ab47cfaaSmrg shift 582ab47cfaaSmrg done 583ab47cfaaSmrg shift 584ab47cfaaSmrg fi 585ab47cfaaSmrg 586ab47cfaaSmrg # Remove `-o $object'. 587ab47cfaaSmrg IFS=" " 588ab47cfaaSmrg for arg 589ab47cfaaSmrg do 590ab47cfaaSmrg case $arg in 591ab47cfaaSmrg -o) 592ab47cfaaSmrg shift 593ab47cfaaSmrg ;; 594ab47cfaaSmrg $object) 595ab47cfaaSmrg shift 596ab47cfaaSmrg ;; 597ab47cfaaSmrg *) 598ab47cfaaSmrg set fnord "$@" "$arg" 599ab47cfaaSmrg shift # fnord 600ab47cfaaSmrg shift # $arg 601ab47cfaaSmrg ;; 602ab47cfaaSmrg esac 603ab47cfaaSmrg done 604ab47cfaaSmrg 605ab47cfaaSmrg "$@" -E | 606ab47cfaaSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 607ab47cfaaSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608ab47cfaaSmrg sed '$ s: \\$::' > "$tmpdepfile" 609ab47cfaaSmrg rm -f "$depfile" 610ab47cfaaSmrg echo "$object : \\" > "$depfile" 611ab47cfaaSmrg cat < "$tmpdepfile" >> "$depfile" 612ab47cfaaSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613ab47cfaaSmrg rm -f "$tmpdepfile" 614ab47cfaaSmrg ;; 615ab47cfaaSmrg 616ab47cfaaSmrgmsvisualcpp) 617ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 6185c42550eSmrg # always write the preprocessed file to stdout. 619ab47cfaaSmrg "$@" || exit $? 6205c42550eSmrg 6215c42550eSmrg # Remove the call to Libtool. 6225c42550eSmrg if test "$libtool" = yes; then 6235c42550eSmrg while test "X$1" != 'X--mode=compile'; do 6245c42550eSmrg shift 6255c42550eSmrg done 6265c42550eSmrg shift 6275c42550eSmrg fi 6285c42550eSmrg 629ab47cfaaSmrg IFS=" " 630ab47cfaaSmrg for arg 631ab47cfaaSmrg do 632ab47cfaaSmrg case "$arg" in 6335c42550eSmrg -o) 6345c42550eSmrg shift 6355c42550eSmrg ;; 6365c42550eSmrg $object) 6375c42550eSmrg shift 6385c42550eSmrg ;; 639ab47cfaaSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640ab47cfaaSmrg set fnord "$@" 641ab47cfaaSmrg shift 642ab47cfaaSmrg shift 643ab47cfaaSmrg ;; 644ab47cfaaSmrg *) 645ab47cfaaSmrg set fnord "$@" "$arg" 646ab47cfaaSmrg shift 647ab47cfaaSmrg shift 648ab47cfaaSmrg ;; 649ab47cfaaSmrg esac 650ab47cfaaSmrg done 6515c42550eSmrg "$@" -E 2>/dev/null | 6525c42550eSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653ab47cfaaSmrg rm -f "$depfile" 654ab47cfaaSmrg echo "$object : \\" > "$depfile" 6555c42550eSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656ab47cfaaSmrg echo " " >> "$depfile" 6575c42550eSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658ab47cfaaSmrg rm -f "$tmpdepfile" 659ab47cfaaSmrg ;; 660ab47cfaaSmrg 6615c42550eSmrgmsvcmsys) 6625c42550eSmrg # This case exists only to let depend.m4 do its work. It works by 6635c42550eSmrg # looking at the text of this script. This case will never be run, 6645c42550eSmrg # since it is checked for above. 6655c42550eSmrg exit 1 6665c42550eSmrg ;; 6675c42550eSmrg 668ab47cfaaSmrgnone) 669ab47cfaaSmrg exec "$@" 670ab47cfaaSmrg ;; 671ab47cfaaSmrg 672ab47cfaaSmrg*) 673ab47cfaaSmrg echo "Unknown depmode $depmode" 1>&2 674ab47cfaaSmrg exit 1 675ab47cfaaSmrg ;; 676ab47cfaaSmrgesac 677ab47cfaaSmrg 678ab47cfaaSmrgexit 0 679ab47cfaaSmrg 680ab47cfaaSmrg# Local Variables: 681ab47cfaaSmrg# mode: shell-script 682ab47cfaaSmrg# sh-indentation: 2 683ab47cfaaSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 684ab47cfaaSmrg# time-stamp-start: "scriptversion=" 685ab47cfaaSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6865c42550eSmrg# time-stamp-time-zone: "UTC" 6875c42550eSmrg# time-stamp-end: "; # UTC" 688ab47cfaaSmrg# End: 689