depcomp revision 6dda92f9
1af7c02bdSmrg#! /bin/sh 2af7c02bdSmrg# depcomp - compile a program generating dependencies as side-effects 3af7c02bdSmrg 46dda92f9Smrgscriptversion=2011-12-04.11; # UTC 5af7c02bdSmrg 66dda92f9Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 76dda92f9Smrg# 2011 Free Software Foundation, Inc. 8af7c02bdSmrg 9af7c02bdSmrg# This program is free software; you can redistribute it and/or modify 10af7c02bdSmrg# it under the terms of the GNU General Public License as published by 11af7c02bdSmrg# the Free Software Foundation; either version 2, or (at your option) 12af7c02bdSmrg# any later version. 13af7c02bdSmrg 14af7c02bdSmrg# This program is distributed in the hope that it will be useful, 15af7c02bdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16af7c02bdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17af7c02bdSmrg# GNU General Public License for more details. 18af7c02bdSmrg 19af7c02bdSmrg# You should have received a copy of the GNU General Public License 2081c81b28Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21af7c02bdSmrg 22af7c02bdSmrg# As a special exception to the GNU General Public License, if you 23af7c02bdSmrg# distribute this file as part of a program that contains a 24af7c02bdSmrg# configuration script generated by Autoconf, you may include it under 25af7c02bdSmrg# the same distribution terms that you use for the rest of that program. 26af7c02bdSmrg 27af7c02bdSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28af7c02bdSmrg 29af7c02bdSmrgcase $1 in 30af7c02bdSmrg '') 31af7c02bdSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32af7c02bdSmrg exit 1; 33af7c02bdSmrg ;; 34af7c02bdSmrg -h | --h*) 35af7c02bdSmrg cat <<\EOF 36af7c02bdSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37af7c02bdSmrg 38af7c02bdSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39af7c02bdSmrgas side-effects. 40af7c02bdSmrg 41af7c02bdSmrgEnvironment variables: 42af7c02bdSmrg depmode Dependency tracking mode. 43af7c02bdSmrg source Source file read by `PROGRAMS ARGS'. 44af7c02bdSmrg object Object file output by `PROGRAMS ARGS'. 45af7c02bdSmrg DEPDIR directory where to store dependencies. 46af7c02bdSmrg depfile Dependency file to output. 476dda92f9Smrg tmpdepfile Temporary file to use when outputting dependencies. 48af7c02bdSmrg libtool Whether libtool is used (yes/no). 49af7c02bdSmrg 50af7c02bdSmrgReport bugs to <bug-automake@gnu.org>. 51af7c02bdSmrgEOF 52af7c02bdSmrg exit $? 53af7c02bdSmrg ;; 54af7c02bdSmrg -v | --v*) 55af7c02bdSmrg echo "depcomp $scriptversion" 56af7c02bdSmrg exit $? 57af7c02bdSmrg ;; 58af7c02bdSmrgesac 59af7c02bdSmrg 60af7c02bdSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61af7c02bdSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62af7c02bdSmrg exit 1 63af7c02bdSmrgfi 64af7c02bdSmrg 65af7c02bdSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66af7c02bdSmrgdepfile=${depfile-`echo "$object" | 67af7c02bdSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68af7c02bdSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69af7c02bdSmrg 70af7c02bdSmrgrm -f "$tmpdepfile" 71af7c02bdSmrg 72af7c02bdSmrg# Some modes work just like other modes, but use different flags. We 73af7c02bdSmrg# parameterize here, but still list the modes in the big case below, 74af7c02bdSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75af7c02bdSmrg# here, because this file can only contain one case statement. 76af7c02bdSmrgif test "$depmode" = hp; then 77af7c02bdSmrg # HP compiler uses -M and no extra arg. 78af7c02bdSmrg gccflag=-M 79af7c02bdSmrg depmode=gcc 80af7c02bdSmrgfi 81af7c02bdSmrg 82af7c02bdSmrgif test "$depmode" = dashXmstdout; then 83af7c02bdSmrg # This is just like dashmstdout with a different argument. 84af7c02bdSmrg dashmflag=-xM 85af7c02bdSmrg depmode=dashmstdout 86af7c02bdSmrgfi 87af7c02bdSmrg 8881c81b28Smrgcygpath_u="cygpath -u -f -" 8981c81b28Smrgif test "$depmode" = msvcmsys; then 9081c81b28Smrg # This is just like msvisualcpp but w/o cygpath translation. 9181c81b28Smrg # Just convert the backslash-escaped backslashes to single forward 9281c81b28Smrg # slashes to satisfy depend.m4 936dda92f9Smrg cygpath_u='sed s,\\\\,/,g' 9481c81b28Smrg depmode=msvisualcpp 9581c81b28Smrgfi 9681c81b28Smrg 976dda92f9Smrgif test "$depmode" = msvc7msys; then 986dda92f9Smrg # This is just like msvc7 but w/o cygpath translation. 996dda92f9Smrg # Just convert the backslash-escaped backslashes to single forward 1006dda92f9Smrg # slashes to satisfy depend.m4 1016dda92f9Smrg cygpath_u='sed s,\\\\,/,g' 1026dda92f9Smrg depmode=msvc7 1036dda92f9Smrgfi 1046dda92f9Smrg 105af7c02bdSmrgcase "$depmode" in 106af7c02bdSmrggcc3) 107af7c02bdSmrg## gcc 3 implements dependency tracking that does exactly what 108af7c02bdSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109af7c02bdSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 11081c81b28Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 11181c81b28Smrg## the command line argument order; so add the flags where they 11281c81b28Smrg## appear in depend2.am. Note that the slowdown incurred here 11381c81b28Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 11481c81b28Smrg for arg 11581c81b28Smrg do 11681c81b28Smrg case $arg in 11781c81b28Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11881c81b28Smrg *) set fnord "$@" "$arg" ;; 11981c81b28Smrg esac 12081c81b28Smrg shift # fnord 12181c81b28Smrg shift # $arg 12281c81b28Smrg done 12381c81b28Smrg "$@" 124af7c02bdSmrg stat=$? 125af7c02bdSmrg if test $stat -eq 0; then : 126af7c02bdSmrg else 127af7c02bdSmrg rm -f "$tmpdepfile" 128af7c02bdSmrg exit $stat 129af7c02bdSmrg fi 130af7c02bdSmrg mv "$tmpdepfile" "$depfile" 131af7c02bdSmrg ;; 132af7c02bdSmrg 133af7c02bdSmrggcc) 134af7c02bdSmrg## There are various ways to get dependency output from gcc. Here's 135af7c02bdSmrg## why we pick this rather obscure method: 136af7c02bdSmrg## - Don't want to use -MD because we'd like the dependencies to end 137af7c02bdSmrg## up in a subdir. Having to rename by hand is ugly. 138af7c02bdSmrg## (We might end up doing this anyway to support other compilers.) 139af7c02bdSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140af7c02bdSmrg## -MM, not -M (despite what the docs say). 141af7c02bdSmrg## - Using -M directly means running the compiler twice (even worse 142af7c02bdSmrg## than renaming). 143af7c02bdSmrg if test -z "$gccflag"; then 144af7c02bdSmrg gccflag=-MD, 145af7c02bdSmrg fi 146af7c02bdSmrg "$@" -Wp,"$gccflag$tmpdepfile" 147af7c02bdSmrg stat=$? 148af7c02bdSmrg if test $stat -eq 0; then : 149af7c02bdSmrg else 150af7c02bdSmrg rm -f "$tmpdepfile" 151af7c02bdSmrg exit $stat 152af7c02bdSmrg fi 153af7c02bdSmrg rm -f "$depfile" 154af7c02bdSmrg echo "$object : \\" > "$depfile" 155af7c02bdSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156af7c02bdSmrg## The second -e expression handles DOS-style file names with drive letters. 157af7c02bdSmrg sed -e 's/^[^:]*: / /' \ 158af7c02bdSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159af7c02bdSmrg## This next piece of magic avoids the `deleted header file' problem. 160af7c02bdSmrg## The problem is that when a header file which appears in a .P file 161af7c02bdSmrg## is deleted, the dependency causes make to die (because there is 162af7c02bdSmrg## typically no way to rebuild the header). We avoid this by adding 163af7c02bdSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 164af7c02bdSmrg## this for us directly. 165af7c02bdSmrg tr ' ' ' 166af7c02bdSmrg' < "$tmpdepfile" | 167af7c02bdSmrg## Some versions of gcc put a space before the `:'. On the theory 168af7c02bdSmrg## that the space means something, we add a space to the output as 1696dda92f9Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 1706dda92f9Smrg## to the object. Take care to not repeat it in the output. 171af7c02bdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 172af7c02bdSmrg## correctly. Breaking it into two sed invocations is a workaround. 1736dda92f9Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 1746dda92f9Smrg | sed -e 's/$/ :/' >> "$depfile" 175af7c02bdSmrg rm -f "$tmpdepfile" 176af7c02bdSmrg ;; 177af7c02bdSmrg 178af7c02bdSmrghp) 179af7c02bdSmrg # This case exists only to let depend.m4 do its work. It works by 180af7c02bdSmrg # looking at the text of this script. This case will never be run, 181af7c02bdSmrg # since it is checked for above. 182af7c02bdSmrg exit 1 183af7c02bdSmrg ;; 184af7c02bdSmrg 185af7c02bdSmrgsgi) 186af7c02bdSmrg if test "$libtool" = yes; then 187af7c02bdSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188af7c02bdSmrg else 189af7c02bdSmrg "$@" -MDupdate "$tmpdepfile" 190af7c02bdSmrg fi 191af7c02bdSmrg stat=$? 192af7c02bdSmrg if test $stat -eq 0; then : 193af7c02bdSmrg else 194af7c02bdSmrg rm -f "$tmpdepfile" 195af7c02bdSmrg exit $stat 196af7c02bdSmrg fi 197af7c02bdSmrg rm -f "$depfile" 198af7c02bdSmrg 199af7c02bdSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200af7c02bdSmrg echo "$object : \\" > "$depfile" 201af7c02bdSmrg 202af7c02bdSmrg # Clip off the initial element (the dependent). Don't try to be 203af7c02bdSmrg # clever and replace this with sed code, as IRIX sed won't handle 204af7c02bdSmrg # lines with more than a fixed number of characters (4096 in 205af7c02bdSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206af7c02bdSmrg # the IRIX cc adds comments like `#:fec' to the end of the 207af7c02bdSmrg # dependency line. 208af7c02bdSmrg tr ' ' ' 209af7c02bdSmrg' < "$tmpdepfile" \ 210af7c02bdSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211af7c02bdSmrg tr ' 21281c81b28Smrg' ' ' >> "$depfile" 21381c81b28Smrg echo >> "$depfile" 214af7c02bdSmrg 215af7c02bdSmrg # The second pass generates a dummy entry for each header file. 216af7c02bdSmrg tr ' ' ' 217af7c02bdSmrg' < "$tmpdepfile" \ 218af7c02bdSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 21981c81b28Smrg >> "$depfile" 220af7c02bdSmrg else 221af7c02bdSmrg # The sourcefile does not contain any dependencies, so just 222af7c02bdSmrg # store a dummy comment line, to avoid errors with the Makefile 223af7c02bdSmrg # "include basename.Plo" scheme. 224af7c02bdSmrg echo "#dummy" > "$depfile" 225af7c02bdSmrg fi 226af7c02bdSmrg rm -f "$tmpdepfile" 227af7c02bdSmrg ;; 228af7c02bdSmrg 229af7c02bdSmrgaix) 230af7c02bdSmrg # The C for AIX Compiler uses -M and outputs the dependencies 231af7c02bdSmrg # in a .u file. In older versions, this file always lives in the 232af7c02bdSmrg # current directory. Also, the AIX compiler puts `$object:' at the 233af7c02bdSmrg # start of each line; $object doesn't have directory information. 234af7c02bdSmrg # Version 6 uses the directory in both cases. 23581c81b28Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 23681c81b28Smrg test "x$dir" = "x$object" && dir= 23781c81b28Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238af7c02bdSmrg if test "$libtool" = yes; then 23981c81b28Smrg tmpdepfile1=$dir$base.u 24081c81b28Smrg tmpdepfile2=$base.u 24181c81b28Smrg tmpdepfile3=$dir.libs/$base.u 242af7c02bdSmrg "$@" -Wc,-M 243af7c02bdSmrg else 24481c81b28Smrg tmpdepfile1=$dir$base.u 24581c81b28Smrg tmpdepfile2=$dir$base.u 24681c81b28Smrg tmpdepfile3=$dir$base.u 247af7c02bdSmrg "$@" -M 248af7c02bdSmrg fi 249af7c02bdSmrg stat=$? 250af7c02bdSmrg 251af7c02bdSmrg if test $stat -eq 0; then : 252af7c02bdSmrg else 25381c81b28Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254af7c02bdSmrg exit $stat 255af7c02bdSmrg fi 256af7c02bdSmrg 25781c81b28Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25881c81b28Smrg do 25981c81b28Smrg test -f "$tmpdepfile" && break 26081c81b28Smrg done 261af7c02bdSmrg if test -f "$tmpdepfile"; then 262af7c02bdSmrg # Each line is of the form `foo.o: dependent.h'. 263af7c02bdSmrg # Do two passes, one to just change these to 264af7c02bdSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 26581c81b28Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 26681c81b28Smrg # That's a tab and a space in the []. 26781c81b28Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268af7c02bdSmrg else 269af7c02bdSmrg # The sourcefile does not contain any dependencies, so just 270af7c02bdSmrg # store a dummy comment line, to avoid errors with the Makefile 271af7c02bdSmrg # "include basename.Plo" scheme. 272af7c02bdSmrg echo "#dummy" > "$depfile" 273af7c02bdSmrg fi 274af7c02bdSmrg rm -f "$tmpdepfile" 275af7c02bdSmrg ;; 276af7c02bdSmrg 277af7c02bdSmrgicc) 278af7c02bdSmrg # Intel's C compiler understands `-MD -MF file'. However on 279af7c02bdSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280af7c02bdSmrg # ICC 7.0 will fill foo.d with something like 281af7c02bdSmrg # foo.o: sub/foo.c 282af7c02bdSmrg # foo.o: sub/foo.h 283af7c02bdSmrg # which is wrong. We want: 284af7c02bdSmrg # sub/foo.o: sub/foo.c 285af7c02bdSmrg # sub/foo.o: sub/foo.h 286af7c02bdSmrg # sub/foo.c: 287af7c02bdSmrg # sub/foo.h: 288af7c02bdSmrg # ICC 7.1 will output 289af7c02bdSmrg # foo.o: sub/foo.c sub/foo.h 290af7c02bdSmrg # and will wrap long lines using \ : 291af7c02bdSmrg # foo.o: sub/foo.c ... \ 292af7c02bdSmrg # sub/foo.h ... \ 293af7c02bdSmrg # ... 294af7c02bdSmrg 295af7c02bdSmrg "$@" -MD -MF "$tmpdepfile" 296af7c02bdSmrg stat=$? 297af7c02bdSmrg if test $stat -eq 0; then : 298af7c02bdSmrg else 299af7c02bdSmrg rm -f "$tmpdepfile" 300af7c02bdSmrg exit $stat 301af7c02bdSmrg fi 302af7c02bdSmrg rm -f "$depfile" 303af7c02bdSmrg # Each line is of the form `foo.o: dependent.h', 304af7c02bdSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305af7c02bdSmrg # Do two passes, one to just change these to 306af7c02bdSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 307af7c02bdSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308af7c02bdSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 309af7c02bdSmrg # correctly. Breaking it into two sed invocations is a workaround. 310af7c02bdSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311af7c02bdSmrg sed -e 's/$/ :/' >> "$depfile" 312af7c02bdSmrg rm -f "$tmpdepfile" 313af7c02bdSmrg ;; 314af7c02bdSmrg 31581c81b28Smrghp2) 31681c81b28Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 31781c81b28Smrg # compilers, which have integrated preprocessors. The correct option 31881c81b28Smrg # to use with these is +Maked; it writes dependencies to a file named 31981c81b28Smrg # 'foo.d', which lands next to the object file, wherever that 32081c81b28Smrg # happens to be. 32181c81b28Smrg # Much of this is similar to the tru64 case; see comments there. 32281c81b28Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 32381c81b28Smrg test "x$dir" = "x$object" && dir= 32481c81b28Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 32581c81b28Smrg if test "$libtool" = yes; then 32681c81b28Smrg tmpdepfile1=$dir$base.d 32781c81b28Smrg tmpdepfile2=$dir.libs/$base.d 32881c81b28Smrg "$@" -Wc,+Maked 32981c81b28Smrg else 33081c81b28Smrg tmpdepfile1=$dir$base.d 33181c81b28Smrg tmpdepfile2=$dir$base.d 33281c81b28Smrg "$@" +Maked 33381c81b28Smrg fi 33481c81b28Smrg stat=$? 33581c81b28Smrg if test $stat -eq 0; then : 33681c81b28Smrg else 33781c81b28Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 33881c81b28Smrg exit $stat 33981c81b28Smrg fi 34081c81b28Smrg 34181c81b28Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 34281c81b28Smrg do 34381c81b28Smrg test -f "$tmpdepfile" && break 34481c81b28Smrg done 34581c81b28Smrg if test -f "$tmpdepfile"; then 34681c81b28Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 34781c81b28Smrg # Add `dependent.h:' lines. 34881c81b28Smrg sed -ne '2,${ 34981c81b28Smrg s/^ *// 35081c81b28Smrg s/ \\*$// 35181c81b28Smrg s/$/:/ 35281c81b28Smrg p 35381c81b28Smrg }' "$tmpdepfile" >> "$depfile" 35481c81b28Smrg else 35581c81b28Smrg echo "#dummy" > "$depfile" 35681c81b28Smrg fi 35781c81b28Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 35881c81b28Smrg ;; 35981c81b28Smrg 360af7c02bdSmrgtru64) 361af7c02bdSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 362af7c02bdSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363af7c02bdSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364af7c02bdSmrg # dependencies in `foo.d' instead, so we check for that too. 365af7c02bdSmrg # Subdirectories are respected. 366af7c02bdSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367af7c02bdSmrg test "x$dir" = "x$object" && dir= 368af7c02bdSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369af7c02bdSmrg 370af7c02bdSmrg if test "$libtool" = yes; then 371af7c02bdSmrg # With Tru64 cc, shared objects can also be used to make a 37281c81b28Smrg # static library. This mechanism is used in libtool 1.4 series to 373af7c02bdSmrg # handle both shared and static libraries in a single compilation. 374af7c02bdSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 375af7c02bdSmrg # 376af7c02bdSmrg # With libtool 1.5 this exception was removed, and libtool now 377af7c02bdSmrg # generates 2 separate objects for the 2 libraries. These two 37881c81b28Smrg # compilations output dependencies in $dir.libs/$base.o.d and 379af7c02bdSmrg # in $dir$base.o.d. We have to check for both files, because 380af7c02bdSmrg # one of the two compilations can be disabled. We should prefer 381af7c02bdSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 382af7c02bdSmrg # automatically cleaned when .libs/ is deleted, while ignoring 383af7c02bdSmrg # the former would cause a distcleancheck panic. 384af7c02bdSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 385af7c02bdSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 386af7c02bdSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 387af7c02bdSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388af7c02bdSmrg "$@" -Wc,-MD 389af7c02bdSmrg else 390af7c02bdSmrg tmpdepfile1=$dir$base.o.d 391af7c02bdSmrg tmpdepfile2=$dir$base.d 392af7c02bdSmrg tmpdepfile3=$dir$base.d 393af7c02bdSmrg tmpdepfile4=$dir$base.d 394af7c02bdSmrg "$@" -MD 395af7c02bdSmrg fi 396af7c02bdSmrg 397af7c02bdSmrg stat=$? 398af7c02bdSmrg if test $stat -eq 0; then : 399af7c02bdSmrg else 400af7c02bdSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401af7c02bdSmrg exit $stat 402af7c02bdSmrg fi 403af7c02bdSmrg 404af7c02bdSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 405af7c02bdSmrg do 406af7c02bdSmrg test -f "$tmpdepfile" && break 407af7c02bdSmrg done 408af7c02bdSmrg if test -f "$tmpdepfile"; then 409af7c02bdSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410af7c02bdSmrg # That's a tab and a space in the []. 411af7c02bdSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412af7c02bdSmrg else 413af7c02bdSmrg echo "#dummy" > "$depfile" 414af7c02bdSmrg fi 415af7c02bdSmrg rm -f "$tmpdepfile" 416af7c02bdSmrg ;; 417af7c02bdSmrg 4186dda92f9Smrgmsvc7) 4196dda92f9Smrg if test "$libtool" = yes; then 4206dda92f9Smrg showIncludes=-Wc,-showIncludes 4216dda92f9Smrg else 4226dda92f9Smrg showIncludes=-showIncludes 4236dda92f9Smrg fi 4246dda92f9Smrg "$@" $showIncludes > "$tmpdepfile" 4256dda92f9Smrg stat=$? 4266dda92f9Smrg grep -v '^Note: including file: ' "$tmpdepfile" 4276dda92f9Smrg if test "$stat" = 0; then : 4286dda92f9Smrg else 4296dda92f9Smrg rm -f "$tmpdepfile" 4306dda92f9Smrg exit $stat 4316dda92f9Smrg fi 4326dda92f9Smrg rm -f "$depfile" 4336dda92f9Smrg echo "$object : \\" > "$depfile" 4346dda92f9Smrg # The first sed program below extracts the file names and escapes 4356dda92f9Smrg # backslashes for cygpath. The second sed program outputs the file 4366dda92f9Smrg # name when reading, but also accumulates all include files in the 4376dda92f9Smrg # hold buffer in order to output them again at the end. This only 4386dda92f9Smrg # works with sed implementations that can handle large buffers. 4396dda92f9Smrg sed < "$tmpdepfile" -n ' 4406dda92f9Smrg/^Note: including file: *\(.*\)/ { 4416dda92f9Smrg s//\1/ 4426dda92f9Smrg s/\\/\\\\/g 4436dda92f9Smrg p 4446dda92f9Smrg}' | $cygpath_u | sort -u | sed -n ' 4456dda92f9Smrgs/ /\\ /g 4466dda92f9Smrgs/\(.*\)/ \1 \\/p 4476dda92f9Smrgs/.\(.*\) \\/\1:/ 4486dda92f9SmrgH 4496dda92f9Smrg$ { 4506dda92f9Smrg s/.*/ / 4516dda92f9Smrg G 4526dda92f9Smrg p 4536dda92f9Smrg}' >> "$depfile" 4546dda92f9Smrg rm -f "$tmpdepfile" 4556dda92f9Smrg ;; 4566dda92f9Smrg 4576dda92f9Smrgmsvc7msys) 4586dda92f9Smrg # This case exists only to let depend.m4 do its work. It works by 4596dda92f9Smrg # looking at the text of this script. This case will never be run, 4606dda92f9Smrg # since it is checked for above. 4616dda92f9Smrg exit 1 4626dda92f9Smrg ;; 4636dda92f9Smrg 464af7c02bdSmrg#nosideeffect) 465af7c02bdSmrg # This comment above is used by automake to tell side-effect 466af7c02bdSmrg # dependency tracking mechanisms from slower ones. 467af7c02bdSmrg 468af7c02bdSmrgdashmstdout) 469af7c02bdSmrg # Important note: in order to support this mode, a compiler *must* 470af7c02bdSmrg # always write the preprocessed file to stdout, regardless of -o. 471af7c02bdSmrg "$@" || exit $? 472af7c02bdSmrg 473af7c02bdSmrg # Remove the call to Libtool. 474af7c02bdSmrg if test "$libtool" = yes; then 47581c81b28Smrg while test "X$1" != 'X--mode=compile'; do 476af7c02bdSmrg shift 477af7c02bdSmrg done 478af7c02bdSmrg shift 479af7c02bdSmrg fi 480af7c02bdSmrg 481af7c02bdSmrg # Remove `-o $object'. 482af7c02bdSmrg IFS=" " 483af7c02bdSmrg for arg 484af7c02bdSmrg do 485af7c02bdSmrg case $arg in 486af7c02bdSmrg -o) 487af7c02bdSmrg shift 488af7c02bdSmrg ;; 489af7c02bdSmrg $object) 490af7c02bdSmrg shift 491af7c02bdSmrg ;; 492af7c02bdSmrg *) 493af7c02bdSmrg set fnord "$@" "$arg" 494af7c02bdSmrg shift # fnord 495af7c02bdSmrg shift # $arg 496af7c02bdSmrg ;; 497af7c02bdSmrg esac 498af7c02bdSmrg done 499af7c02bdSmrg 500af7c02bdSmrg test -z "$dashmflag" && dashmflag=-M 501af7c02bdSmrg # Require at least two characters before searching for `:' 502af7c02bdSmrg # in the target name. This is to cope with DOS-style filenames: 503af7c02bdSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504af7c02bdSmrg "$@" $dashmflag | 505af7c02bdSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506af7c02bdSmrg rm -f "$depfile" 507af7c02bdSmrg cat < "$tmpdepfile" > "$depfile" 508af7c02bdSmrg tr ' ' ' 509af7c02bdSmrg' < "$tmpdepfile" | \ 510af7c02bdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 511af7c02bdSmrg## correctly. Breaking it into two sed invocations is a workaround. 512af7c02bdSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513af7c02bdSmrg rm -f "$tmpdepfile" 514af7c02bdSmrg ;; 515af7c02bdSmrg 516af7c02bdSmrgdashXmstdout) 517af7c02bdSmrg # This case only exists to satisfy depend.m4. It is never actually 518af7c02bdSmrg # run, as this mode is specially recognized in the preamble. 519af7c02bdSmrg exit 1 520af7c02bdSmrg ;; 521af7c02bdSmrg 522af7c02bdSmrgmakedepend) 523af7c02bdSmrg "$@" || exit $? 524af7c02bdSmrg # Remove any Libtool call 525af7c02bdSmrg if test "$libtool" = yes; then 52681c81b28Smrg while test "X$1" != 'X--mode=compile'; do 527af7c02bdSmrg shift 528af7c02bdSmrg done 529af7c02bdSmrg shift 530af7c02bdSmrg fi 531af7c02bdSmrg # X makedepend 532af7c02bdSmrg shift 53381c81b28Smrg cleared=no eat=no 53481c81b28Smrg for arg 53581c81b28Smrg do 536af7c02bdSmrg case $cleared in 537af7c02bdSmrg no) 538af7c02bdSmrg set ""; shift 539af7c02bdSmrg cleared=yes ;; 540af7c02bdSmrg esac 54181c81b28Smrg if test $eat = yes; then 54281c81b28Smrg eat=no 54381c81b28Smrg continue 54481c81b28Smrg fi 545af7c02bdSmrg case "$arg" in 546af7c02bdSmrg -D*|-I*) 547af7c02bdSmrg set fnord "$@" "$arg"; shift ;; 548af7c02bdSmrg # Strip any option that makedepend may not understand. Remove 549af7c02bdSmrg # the object too, otherwise makedepend will parse it as a source file. 55081c81b28Smrg -arch) 55181c81b28Smrg eat=yes ;; 552af7c02bdSmrg -*|$object) 553af7c02bdSmrg ;; 554af7c02bdSmrg *) 555af7c02bdSmrg set fnord "$@" "$arg"; shift ;; 556af7c02bdSmrg esac 557af7c02bdSmrg done 55881c81b28Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559af7c02bdSmrg touch "$tmpdepfile" 560af7c02bdSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561af7c02bdSmrg rm -f "$depfile" 5626dda92f9Smrg # makedepend may prepend the VPATH from the source file name to the object. 5636dda92f9Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 5646dda92f9Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565af7c02bdSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566af7c02bdSmrg' | \ 567af7c02bdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 568af7c02bdSmrg## correctly. Breaking it into two sed invocations is a workaround. 569af7c02bdSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570af7c02bdSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571af7c02bdSmrg ;; 572af7c02bdSmrg 573af7c02bdSmrgcpp) 574af7c02bdSmrg # Important note: in order to support this mode, a compiler *must* 575af7c02bdSmrg # always write the preprocessed file to stdout. 576af7c02bdSmrg "$@" || exit $? 577af7c02bdSmrg 578af7c02bdSmrg # Remove the call to Libtool. 579af7c02bdSmrg if test "$libtool" = yes; then 58081c81b28Smrg while test "X$1" != 'X--mode=compile'; do 581af7c02bdSmrg shift 582af7c02bdSmrg done 583af7c02bdSmrg shift 584af7c02bdSmrg fi 585af7c02bdSmrg 586af7c02bdSmrg # Remove `-o $object'. 587af7c02bdSmrg IFS=" " 588af7c02bdSmrg for arg 589af7c02bdSmrg do 590af7c02bdSmrg case $arg in 591af7c02bdSmrg -o) 592af7c02bdSmrg shift 593af7c02bdSmrg ;; 594af7c02bdSmrg $object) 595af7c02bdSmrg shift 596af7c02bdSmrg ;; 597af7c02bdSmrg *) 598af7c02bdSmrg set fnord "$@" "$arg" 599af7c02bdSmrg shift # fnord 600af7c02bdSmrg shift # $arg 601af7c02bdSmrg ;; 602af7c02bdSmrg esac 603af7c02bdSmrg done 604af7c02bdSmrg 605af7c02bdSmrg "$@" -E | 606af7c02bdSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 607af7c02bdSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608af7c02bdSmrg sed '$ s: \\$::' > "$tmpdepfile" 609af7c02bdSmrg rm -f "$depfile" 610af7c02bdSmrg echo "$object : \\" > "$depfile" 611af7c02bdSmrg cat < "$tmpdepfile" >> "$depfile" 612af7c02bdSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613af7c02bdSmrg rm -f "$tmpdepfile" 614af7c02bdSmrg ;; 615af7c02bdSmrg 616af7c02bdSmrgmsvisualcpp) 617af7c02bdSmrg # Important note: in order to support this mode, a compiler *must* 61881c81b28Smrg # always write the preprocessed file to stdout. 619af7c02bdSmrg "$@" || exit $? 62081c81b28Smrg 62181c81b28Smrg # Remove the call to Libtool. 62281c81b28Smrg if test "$libtool" = yes; then 62381c81b28Smrg while test "X$1" != 'X--mode=compile'; do 62481c81b28Smrg shift 62581c81b28Smrg done 62681c81b28Smrg shift 62781c81b28Smrg fi 62881c81b28Smrg 629af7c02bdSmrg IFS=" " 630af7c02bdSmrg for arg 631af7c02bdSmrg do 632af7c02bdSmrg case "$arg" in 63381c81b28Smrg -o) 63481c81b28Smrg shift 63581c81b28Smrg ;; 63681c81b28Smrg $object) 63781c81b28Smrg shift 63881c81b28Smrg ;; 639af7c02bdSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640af7c02bdSmrg set fnord "$@" 641af7c02bdSmrg shift 642af7c02bdSmrg shift 643af7c02bdSmrg ;; 644af7c02bdSmrg *) 645af7c02bdSmrg set fnord "$@" "$arg" 646af7c02bdSmrg shift 647af7c02bdSmrg shift 648af7c02bdSmrg ;; 649af7c02bdSmrg esac 650af7c02bdSmrg done 65181c81b28Smrg "$@" -E 2>/dev/null | 65281c81b28Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653af7c02bdSmrg rm -f "$depfile" 654af7c02bdSmrg echo "$object : \\" > "$depfile" 65581c81b28Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656af7c02bdSmrg echo " " >> "$depfile" 65781c81b28Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658af7c02bdSmrg rm -f "$tmpdepfile" 659af7c02bdSmrg ;; 660af7c02bdSmrg 66181c81b28Smrgmsvcmsys) 66281c81b28Smrg # This case exists only to let depend.m4 do its work. It works by 66381c81b28Smrg # looking at the text of this script. This case will never be run, 66481c81b28Smrg # since it is checked for above. 66581c81b28Smrg exit 1 66681c81b28Smrg ;; 66781c81b28Smrg 668af7c02bdSmrgnone) 669af7c02bdSmrg exec "$@" 670af7c02bdSmrg ;; 671af7c02bdSmrg 672af7c02bdSmrg*) 673af7c02bdSmrg echo "Unknown depmode $depmode" 1>&2 674af7c02bdSmrg exit 1 675af7c02bdSmrg ;; 676af7c02bdSmrgesac 677af7c02bdSmrg 678af7c02bdSmrgexit 0 679af7c02bdSmrg 680af7c02bdSmrg# Local Variables: 681af7c02bdSmrg# mode: shell-script 682af7c02bdSmrg# sh-indentation: 2 683af7c02bdSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 684af7c02bdSmrg# time-stamp-start: "scriptversion=" 685af7c02bdSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 68681c81b28Smrg# time-stamp-time-zone: "UTC" 68781c81b28Smrg# time-stamp-end: "; # UTC" 688af7c02bdSmrg# End: 689