depcomp revision 5c42550e
1ab47cfaaSmrg#! /bin/sh 2ab47cfaaSmrg# depcomp - compile a program generating dependencies as side-effects 3ab47cfaaSmrg 45c42550eSmrgscriptversion=2009-04-28.21; # UTC 5ab47cfaaSmrg 65c42550eSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 75c42550eSmrg# 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. 47ab47cfaaSmrg tmpdepfile Temporary file to use when outputing 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 935c42550eSmrg cygpath_u="sed s,\\\\\\\\,/,g" 945c42550eSmrg depmode=msvisualcpp 955c42550eSmrgfi 965c42550eSmrg 97ab47cfaaSmrgcase "$depmode" in 98ab47cfaaSmrggcc3) 99ab47cfaaSmrg## gcc 3 implements dependency tracking that does exactly what 100ab47cfaaSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101ab47cfaaSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1028697ee19Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1038697ee19Smrg## the command line argument order; so add the flags where they 1048697ee19Smrg## appear in depend2.am. Note that the slowdown incurred here 1058697ee19Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1068697ee19Smrg for arg 1078697ee19Smrg do 1088697ee19Smrg case $arg in 1098697ee19Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1108697ee19Smrg *) set fnord "$@" "$arg" ;; 1118697ee19Smrg esac 1128697ee19Smrg shift # fnord 1138697ee19Smrg shift # $arg 1148697ee19Smrg done 1158697ee19Smrg "$@" 116ab47cfaaSmrg stat=$? 117ab47cfaaSmrg if test $stat -eq 0; then : 118ab47cfaaSmrg else 119ab47cfaaSmrg rm -f "$tmpdepfile" 120ab47cfaaSmrg exit $stat 121ab47cfaaSmrg fi 122ab47cfaaSmrg mv "$tmpdepfile" "$depfile" 123ab47cfaaSmrg ;; 124ab47cfaaSmrg 125ab47cfaaSmrggcc) 126ab47cfaaSmrg## There are various ways to get dependency output from gcc. Here's 127ab47cfaaSmrg## why we pick this rather obscure method: 128ab47cfaaSmrg## - Don't want to use -MD because we'd like the dependencies to end 129ab47cfaaSmrg## up in a subdir. Having to rename by hand is ugly. 130ab47cfaaSmrg## (We might end up doing this anyway to support other compilers.) 131ab47cfaaSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132ab47cfaaSmrg## -MM, not -M (despite what the docs say). 133ab47cfaaSmrg## - Using -M directly means running the compiler twice (even worse 134ab47cfaaSmrg## than renaming). 135ab47cfaaSmrg if test -z "$gccflag"; then 136ab47cfaaSmrg gccflag=-MD, 137ab47cfaaSmrg fi 138ab47cfaaSmrg "$@" -Wp,"$gccflag$tmpdepfile" 139ab47cfaaSmrg stat=$? 140ab47cfaaSmrg if test $stat -eq 0; then : 141ab47cfaaSmrg else 142ab47cfaaSmrg rm -f "$tmpdepfile" 143ab47cfaaSmrg exit $stat 144ab47cfaaSmrg fi 145ab47cfaaSmrg rm -f "$depfile" 146ab47cfaaSmrg echo "$object : \\" > "$depfile" 147ab47cfaaSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148ab47cfaaSmrg## The second -e expression handles DOS-style file names with drive letters. 149ab47cfaaSmrg sed -e 's/^[^:]*: / /' \ 150ab47cfaaSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151ab47cfaaSmrg## This next piece of magic avoids the `deleted header file' problem. 152ab47cfaaSmrg## The problem is that when a header file which appears in a .P file 153ab47cfaaSmrg## is deleted, the dependency causes make to die (because there is 154ab47cfaaSmrg## typically no way to rebuild the header). We avoid this by adding 155ab47cfaaSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 156ab47cfaaSmrg## this for us directly. 157ab47cfaaSmrg tr ' ' ' 158ab47cfaaSmrg' < "$tmpdepfile" | 159ab47cfaaSmrg## Some versions of gcc put a space before the `:'. On the theory 160ab47cfaaSmrg## that the space means something, we add a space to the output as 161ab47cfaaSmrg## well. 162ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 163ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 164ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165ab47cfaaSmrg rm -f "$tmpdepfile" 166ab47cfaaSmrg ;; 167ab47cfaaSmrg 168ab47cfaaSmrghp) 169ab47cfaaSmrg # This case exists only to let depend.m4 do its work. It works by 170ab47cfaaSmrg # looking at the text of this script. This case will never be run, 171ab47cfaaSmrg # since it is checked for above. 172ab47cfaaSmrg exit 1 173ab47cfaaSmrg ;; 174ab47cfaaSmrg 175ab47cfaaSmrgsgi) 176ab47cfaaSmrg if test "$libtool" = yes; then 177ab47cfaaSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178ab47cfaaSmrg else 179ab47cfaaSmrg "$@" -MDupdate "$tmpdepfile" 180ab47cfaaSmrg fi 181ab47cfaaSmrg stat=$? 182ab47cfaaSmrg if test $stat -eq 0; then : 183ab47cfaaSmrg else 184ab47cfaaSmrg rm -f "$tmpdepfile" 185ab47cfaaSmrg exit $stat 186ab47cfaaSmrg fi 187ab47cfaaSmrg rm -f "$depfile" 188ab47cfaaSmrg 189ab47cfaaSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190ab47cfaaSmrg echo "$object : \\" > "$depfile" 191ab47cfaaSmrg 192ab47cfaaSmrg # Clip off the initial element (the dependent). Don't try to be 193ab47cfaaSmrg # clever and replace this with sed code, as IRIX sed won't handle 194ab47cfaaSmrg # lines with more than a fixed number of characters (4096 in 195ab47cfaaSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196ab47cfaaSmrg # the IRIX cc adds comments like `#:fec' to the end of the 197ab47cfaaSmrg # dependency line. 198ab47cfaaSmrg tr ' ' ' 199ab47cfaaSmrg' < "$tmpdepfile" \ 200ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201ab47cfaaSmrg tr ' 2025c42550eSmrg' ' ' >> "$depfile" 2035c42550eSmrg echo >> "$depfile" 204ab47cfaaSmrg 205ab47cfaaSmrg # The second pass generates a dummy entry for each header file. 206ab47cfaaSmrg tr ' ' ' 207ab47cfaaSmrg' < "$tmpdepfile" \ 208ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2095c42550eSmrg >> "$depfile" 210ab47cfaaSmrg else 211ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 212ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 213ab47cfaaSmrg # "include basename.Plo" scheme. 214ab47cfaaSmrg echo "#dummy" > "$depfile" 215ab47cfaaSmrg fi 216ab47cfaaSmrg rm -f "$tmpdepfile" 217ab47cfaaSmrg ;; 218ab47cfaaSmrg 219ab47cfaaSmrgaix) 220ab47cfaaSmrg # The C for AIX Compiler uses -M and outputs the dependencies 221ab47cfaaSmrg # in a .u file. In older versions, this file always lives in the 222ab47cfaaSmrg # current directory. Also, the AIX compiler puts `$object:' at the 223ab47cfaaSmrg # start of each line; $object doesn't have directory information. 224ab47cfaaSmrg # Version 6 uses the directory in both cases. 2251473d951Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2261473d951Smrg test "x$dir" = "x$object" && dir= 2271473d951Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228ab47cfaaSmrg if test "$libtool" = yes; then 2291473d951Smrg tmpdepfile1=$dir$base.u 2301473d951Smrg tmpdepfile2=$base.u 2311473d951Smrg tmpdepfile3=$dir.libs/$base.u 232ab47cfaaSmrg "$@" -Wc,-M 233ab47cfaaSmrg else 2341473d951Smrg tmpdepfile1=$dir$base.u 2351473d951Smrg tmpdepfile2=$dir$base.u 2361473d951Smrg tmpdepfile3=$dir$base.u 237ab47cfaaSmrg "$@" -M 238ab47cfaaSmrg fi 239ab47cfaaSmrg stat=$? 240ab47cfaaSmrg 241ab47cfaaSmrg if test $stat -eq 0; then : 242ab47cfaaSmrg else 2431473d951Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244ab47cfaaSmrg exit $stat 245ab47cfaaSmrg fi 246ab47cfaaSmrg 2471473d951Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2481473d951Smrg do 2491473d951Smrg test -f "$tmpdepfile" && break 2501473d951Smrg done 251ab47cfaaSmrg if test -f "$tmpdepfile"; then 252ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h'. 253ab47cfaaSmrg # Do two passes, one to just change these to 254ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 2551473d951Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2561473d951Smrg # That's a tab and a space in the []. 2571473d951Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258ab47cfaaSmrg else 259ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 260ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 261ab47cfaaSmrg # "include basename.Plo" scheme. 262ab47cfaaSmrg echo "#dummy" > "$depfile" 263ab47cfaaSmrg fi 264ab47cfaaSmrg rm -f "$tmpdepfile" 265ab47cfaaSmrg ;; 266ab47cfaaSmrg 267ab47cfaaSmrgicc) 268ab47cfaaSmrg # Intel's C compiler understands `-MD -MF file'. However on 269ab47cfaaSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270ab47cfaaSmrg # ICC 7.0 will fill foo.d with something like 271ab47cfaaSmrg # foo.o: sub/foo.c 272ab47cfaaSmrg # foo.o: sub/foo.h 273ab47cfaaSmrg # which is wrong. We want: 274ab47cfaaSmrg # sub/foo.o: sub/foo.c 275ab47cfaaSmrg # sub/foo.o: sub/foo.h 276ab47cfaaSmrg # sub/foo.c: 277ab47cfaaSmrg # sub/foo.h: 278ab47cfaaSmrg # ICC 7.1 will output 279ab47cfaaSmrg # foo.o: sub/foo.c sub/foo.h 280ab47cfaaSmrg # and will wrap long lines using \ : 281ab47cfaaSmrg # foo.o: sub/foo.c ... \ 282ab47cfaaSmrg # sub/foo.h ... \ 283ab47cfaaSmrg # ... 284ab47cfaaSmrg 285ab47cfaaSmrg "$@" -MD -MF "$tmpdepfile" 286ab47cfaaSmrg stat=$? 287ab47cfaaSmrg if test $stat -eq 0; then : 288ab47cfaaSmrg else 289ab47cfaaSmrg rm -f "$tmpdepfile" 290ab47cfaaSmrg exit $stat 291ab47cfaaSmrg fi 292ab47cfaaSmrg rm -f "$depfile" 293ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h', 294ab47cfaaSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295ab47cfaaSmrg # Do two passes, one to just change these to 296ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 297ab47cfaaSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298ab47cfaaSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 299ab47cfaaSmrg # correctly. Breaking it into two sed invocations is a workaround. 300ab47cfaaSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301ab47cfaaSmrg sed -e 's/$/ :/' >> "$depfile" 302ab47cfaaSmrg rm -f "$tmpdepfile" 303ab47cfaaSmrg ;; 304ab47cfaaSmrg 3058697ee19Smrghp2) 3068697ee19Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3078697ee19Smrg # compilers, which have integrated preprocessors. The correct option 3088697ee19Smrg # to use with these is +Maked; it writes dependencies to a file named 3098697ee19Smrg # 'foo.d', which lands next to the object file, wherever that 3108697ee19Smrg # happens to be. 3118697ee19Smrg # Much of this is similar to the tru64 case; see comments there. 3128697ee19Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3138697ee19Smrg test "x$dir" = "x$object" && dir= 3148697ee19Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3158697ee19Smrg if test "$libtool" = yes; then 3168697ee19Smrg tmpdepfile1=$dir$base.d 3178697ee19Smrg tmpdepfile2=$dir.libs/$base.d 3188697ee19Smrg "$@" -Wc,+Maked 3198697ee19Smrg else 3208697ee19Smrg tmpdepfile1=$dir$base.d 3218697ee19Smrg tmpdepfile2=$dir$base.d 3228697ee19Smrg "$@" +Maked 3238697ee19Smrg fi 3248697ee19Smrg stat=$? 3258697ee19Smrg if test $stat -eq 0; then : 3268697ee19Smrg else 3278697ee19Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3288697ee19Smrg exit $stat 3298697ee19Smrg fi 3308697ee19Smrg 3318697ee19Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3328697ee19Smrg do 3338697ee19Smrg test -f "$tmpdepfile" && break 3348697ee19Smrg done 3358697ee19Smrg if test -f "$tmpdepfile"; then 3368697ee19Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3378697ee19Smrg # Add `dependent.h:' lines. 3385c42550eSmrg sed -ne '2,${ 3395c42550eSmrg s/^ *// 3405c42550eSmrg s/ \\*$// 3415c42550eSmrg s/$/:/ 3425c42550eSmrg p 3435c42550eSmrg }' "$tmpdepfile" >> "$depfile" 3448697ee19Smrg else 3458697ee19Smrg echo "#dummy" > "$depfile" 3468697ee19Smrg fi 3478697ee19Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3488697ee19Smrg ;; 3498697ee19Smrg 350ab47cfaaSmrgtru64) 351ab47cfaaSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 352ab47cfaaSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353ab47cfaaSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354ab47cfaaSmrg # dependencies in `foo.d' instead, so we check for that too. 355ab47cfaaSmrg # Subdirectories are respected. 356ab47cfaaSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357ab47cfaaSmrg test "x$dir" = "x$object" && dir= 358ab47cfaaSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359ab47cfaaSmrg 360ab47cfaaSmrg if test "$libtool" = yes; then 361ab47cfaaSmrg # With Tru64 cc, shared objects can also be used to make a 3628697ee19Smrg # static library. This mechanism is used in libtool 1.4 series to 363ab47cfaaSmrg # handle both shared and static libraries in a single compilation. 364ab47cfaaSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365ab47cfaaSmrg # 366ab47cfaaSmrg # With libtool 1.5 this exception was removed, and libtool now 367ab47cfaaSmrg # generates 2 separate objects for the 2 libraries. These two 3688697ee19Smrg # compilations output dependencies in $dir.libs/$base.o.d and 369ab47cfaaSmrg # in $dir$base.o.d. We have to check for both files, because 370ab47cfaaSmrg # one of the two compilations can be disabled. We should prefer 371ab47cfaaSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372ab47cfaaSmrg # automatically cleaned when .libs/ is deleted, while ignoring 373ab47cfaaSmrg # the former would cause a distcleancheck panic. 374ab47cfaaSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375ab47cfaaSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376ab47cfaaSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377ab47cfaaSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378ab47cfaaSmrg "$@" -Wc,-MD 379ab47cfaaSmrg else 380ab47cfaaSmrg tmpdepfile1=$dir$base.o.d 381ab47cfaaSmrg tmpdepfile2=$dir$base.d 382ab47cfaaSmrg tmpdepfile3=$dir$base.d 383ab47cfaaSmrg tmpdepfile4=$dir$base.d 384ab47cfaaSmrg "$@" -MD 385ab47cfaaSmrg fi 386ab47cfaaSmrg 387ab47cfaaSmrg stat=$? 388ab47cfaaSmrg if test $stat -eq 0; then : 389ab47cfaaSmrg else 390ab47cfaaSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391ab47cfaaSmrg exit $stat 392ab47cfaaSmrg fi 393ab47cfaaSmrg 394ab47cfaaSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395ab47cfaaSmrg do 396ab47cfaaSmrg test -f "$tmpdepfile" && break 397ab47cfaaSmrg done 398ab47cfaaSmrg if test -f "$tmpdepfile"; then 399ab47cfaaSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400ab47cfaaSmrg # That's a tab and a space in the []. 401ab47cfaaSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402ab47cfaaSmrg else 403ab47cfaaSmrg echo "#dummy" > "$depfile" 404ab47cfaaSmrg fi 405ab47cfaaSmrg rm -f "$tmpdepfile" 406ab47cfaaSmrg ;; 407ab47cfaaSmrg 408ab47cfaaSmrg#nosideeffect) 409ab47cfaaSmrg # This comment above is used by automake to tell side-effect 410ab47cfaaSmrg # dependency tracking mechanisms from slower ones. 411ab47cfaaSmrg 412ab47cfaaSmrgdashmstdout) 413ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 414ab47cfaaSmrg # always write the preprocessed file to stdout, regardless of -o. 415ab47cfaaSmrg "$@" || exit $? 416ab47cfaaSmrg 417ab47cfaaSmrg # Remove the call to Libtool. 418ab47cfaaSmrg if test "$libtool" = yes; then 4195c42550eSmrg while test "X$1" != 'X--mode=compile'; do 420ab47cfaaSmrg shift 421ab47cfaaSmrg done 422ab47cfaaSmrg shift 423ab47cfaaSmrg fi 424ab47cfaaSmrg 425ab47cfaaSmrg # Remove `-o $object'. 426ab47cfaaSmrg IFS=" " 427ab47cfaaSmrg for arg 428ab47cfaaSmrg do 429ab47cfaaSmrg case $arg in 430ab47cfaaSmrg -o) 431ab47cfaaSmrg shift 432ab47cfaaSmrg ;; 433ab47cfaaSmrg $object) 434ab47cfaaSmrg shift 435ab47cfaaSmrg ;; 436ab47cfaaSmrg *) 437ab47cfaaSmrg set fnord "$@" "$arg" 438ab47cfaaSmrg shift # fnord 439ab47cfaaSmrg shift # $arg 440ab47cfaaSmrg ;; 441ab47cfaaSmrg esac 442ab47cfaaSmrg done 443ab47cfaaSmrg 444ab47cfaaSmrg test -z "$dashmflag" && dashmflag=-M 445ab47cfaaSmrg # Require at least two characters before searching for `:' 446ab47cfaaSmrg # in the target name. This is to cope with DOS-style filenames: 447ab47cfaaSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448ab47cfaaSmrg "$@" $dashmflag | 449ab47cfaaSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450ab47cfaaSmrg rm -f "$depfile" 451ab47cfaaSmrg cat < "$tmpdepfile" > "$depfile" 452ab47cfaaSmrg tr ' ' ' 453ab47cfaaSmrg' < "$tmpdepfile" | \ 454ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 455ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 456ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457ab47cfaaSmrg rm -f "$tmpdepfile" 458ab47cfaaSmrg ;; 459ab47cfaaSmrg 460ab47cfaaSmrgdashXmstdout) 461ab47cfaaSmrg # This case only exists to satisfy depend.m4. It is never actually 462ab47cfaaSmrg # run, as this mode is specially recognized in the preamble. 463ab47cfaaSmrg exit 1 464ab47cfaaSmrg ;; 465ab47cfaaSmrg 466ab47cfaaSmrgmakedepend) 467ab47cfaaSmrg "$@" || exit $? 468ab47cfaaSmrg # Remove any Libtool call 469ab47cfaaSmrg if test "$libtool" = yes; then 4705c42550eSmrg while test "X$1" != 'X--mode=compile'; do 471ab47cfaaSmrg shift 472ab47cfaaSmrg done 473ab47cfaaSmrg shift 474ab47cfaaSmrg fi 475ab47cfaaSmrg # X makedepend 476ab47cfaaSmrg shift 4775c42550eSmrg cleared=no eat=no 4785c42550eSmrg for arg 4795c42550eSmrg do 480ab47cfaaSmrg case $cleared in 481ab47cfaaSmrg no) 482ab47cfaaSmrg set ""; shift 483ab47cfaaSmrg cleared=yes ;; 484ab47cfaaSmrg esac 4855c42550eSmrg if test $eat = yes; then 4865c42550eSmrg eat=no 4875c42550eSmrg continue 4885c42550eSmrg fi 489ab47cfaaSmrg case "$arg" in 490ab47cfaaSmrg -D*|-I*) 491ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 492ab47cfaaSmrg # Strip any option that makedepend may not understand. Remove 493ab47cfaaSmrg # the object too, otherwise makedepend will parse it as a source file. 4945c42550eSmrg -arch) 4955c42550eSmrg eat=yes ;; 496ab47cfaaSmrg -*|$object) 497ab47cfaaSmrg ;; 498ab47cfaaSmrg *) 499ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 500ab47cfaaSmrg esac 501ab47cfaaSmrg done 5025c42550eSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503ab47cfaaSmrg touch "$tmpdepfile" 504ab47cfaaSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505ab47cfaaSmrg rm -f "$depfile" 506ab47cfaaSmrg cat < "$tmpdepfile" > "$depfile" 507ab47cfaaSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508ab47cfaaSmrg' | \ 509ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 510ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 511ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512ab47cfaaSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513ab47cfaaSmrg ;; 514ab47cfaaSmrg 515ab47cfaaSmrgcpp) 516ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 517ab47cfaaSmrg # always write the preprocessed file to stdout. 518ab47cfaaSmrg "$@" || exit $? 519ab47cfaaSmrg 520ab47cfaaSmrg # Remove the call to Libtool. 521ab47cfaaSmrg if test "$libtool" = yes; then 5225c42550eSmrg while test "X$1" != 'X--mode=compile'; do 523ab47cfaaSmrg shift 524ab47cfaaSmrg done 525ab47cfaaSmrg shift 526ab47cfaaSmrg fi 527ab47cfaaSmrg 528ab47cfaaSmrg # Remove `-o $object'. 529ab47cfaaSmrg IFS=" " 530ab47cfaaSmrg for arg 531ab47cfaaSmrg do 532ab47cfaaSmrg case $arg in 533ab47cfaaSmrg -o) 534ab47cfaaSmrg shift 535ab47cfaaSmrg ;; 536ab47cfaaSmrg $object) 537ab47cfaaSmrg shift 538ab47cfaaSmrg ;; 539ab47cfaaSmrg *) 540ab47cfaaSmrg set fnord "$@" "$arg" 541ab47cfaaSmrg shift # fnord 542ab47cfaaSmrg shift # $arg 543ab47cfaaSmrg ;; 544ab47cfaaSmrg esac 545ab47cfaaSmrg done 546ab47cfaaSmrg 547ab47cfaaSmrg "$@" -E | 548ab47cfaaSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549ab47cfaaSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550ab47cfaaSmrg sed '$ s: \\$::' > "$tmpdepfile" 551ab47cfaaSmrg rm -f "$depfile" 552ab47cfaaSmrg echo "$object : \\" > "$depfile" 553ab47cfaaSmrg cat < "$tmpdepfile" >> "$depfile" 554ab47cfaaSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555ab47cfaaSmrg rm -f "$tmpdepfile" 556ab47cfaaSmrg ;; 557ab47cfaaSmrg 558ab47cfaaSmrgmsvisualcpp) 559ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 5605c42550eSmrg # always write the preprocessed file to stdout. 561ab47cfaaSmrg "$@" || exit $? 5625c42550eSmrg 5635c42550eSmrg # Remove the call to Libtool. 5645c42550eSmrg if test "$libtool" = yes; then 5655c42550eSmrg while test "X$1" != 'X--mode=compile'; do 5665c42550eSmrg shift 5675c42550eSmrg done 5685c42550eSmrg shift 5695c42550eSmrg fi 5705c42550eSmrg 571ab47cfaaSmrg IFS=" " 572ab47cfaaSmrg for arg 573ab47cfaaSmrg do 574ab47cfaaSmrg case "$arg" in 5755c42550eSmrg -o) 5765c42550eSmrg shift 5775c42550eSmrg ;; 5785c42550eSmrg $object) 5795c42550eSmrg shift 5805c42550eSmrg ;; 581ab47cfaaSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582ab47cfaaSmrg set fnord "$@" 583ab47cfaaSmrg shift 584ab47cfaaSmrg shift 585ab47cfaaSmrg ;; 586ab47cfaaSmrg *) 587ab47cfaaSmrg set fnord "$@" "$arg" 588ab47cfaaSmrg shift 589ab47cfaaSmrg shift 590ab47cfaaSmrg ;; 591ab47cfaaSmrg esac 592ab47cfaaSmrg done 5935c42550eSmrg "$@" -E 2>/dev/null | 5945c42550eSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595ab47cfaaSmrg rm -f "$depfile" 596ab47cfaaSmrg echo "$object : \\" > "$depfile" 5975c42550eSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598ab47cfaaSmrg echo " " >> "$depfile" 5995c42550eSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600ab47cfaaSmrg rm -f "$tmpdepfile" 601ab47cfaaSmrg ;; 602ab47cfaaSmrg 6035c42550eSmrgmsvcmsys) 6045c42550eSmrg # This case exists only to let depend.m4 do its work. It works by 6055c42550eSmrg # looking at the text of this script. This case will never be run, 6065c42550eSmrg # since it is checked for above. 6075c42550eSmrg exit 1 6085c42550eSmrg ;; 6095c42550eSmrg 610ab47cfaaSmrgnone) 611ab47cfaaSmrg exec "$@" 612ab47cfaaSmrg ;; 613ab47cfaaSmrg 614ab47cfaaSmrg*) 615ab47cfaaSmrg echo "Unknown depmode $depmode" 1>&2 616ab47cfaaSmrg exit 1 617ab47cfaaSmrg ;; 618ab47cfaaSmrgesac 619ab47cfaaSmrg 620ab47cfaaSmrgexit 0 621ab47cfaaSmrg 622ab47cfaaSmrg# Local Variables: 623ab47cfaaSmrg# mode: shell-script 624ab47cfaaSmrg# sh-indentation: 2 625ab47cfaaSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626ab47cfaaSmrg# time-stamp-start: "scriptversion=" 627ab47cfaaSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6285c42550eSmrg# time-stamp-time-zone: "UTC" 6295c42550eSmrg# time-stamp-end: "; # UTC" 630ab47cfaaSmrg# End: 631