depcomp revision a85aecdf
1fd7d9bd3Smrg#! /bin/sh 2fd7d9bd3Smrg# depcomp - compile a program generating dependencies as side-effects 3350952b9Smrg 4a85aecdfSmrgscriptversion=2011-12-04.11; # UTC 5350952b9Smrg 6a85aecdfSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7a85aecdfSmrg# 2011 Free Software Foundation, Inc. 8fd7d9bd3Smrg 9fd7d9bd3Smrg# This program is free software; you can redistribute it and/or modify 10fd7d9bd3Smrg# it under the terms of the GNU General Public License as published by 11fd7d9bd3Smrg# the Free Software Foundation; either version 2, or (at your option) 12fd7d9bd3Smrg# any later version. 13fd7d9bd3Smrg 14fd7d9bd3Smrg# This program is distributed in the hope that it will be useful, 15fd7d9bd3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fd7d9bd3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fd7d9bd3Smrg# GNU General Public License for more details. 18fd7d9bd3Smrg 19fd7d9bd3Smrg# You should have received a copy of the GNU General Public License 20350952b9Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21fd7d9bd3Smrg 22fd7d9bd3Smrg# As a special exception to the GNU General Public License, if you 23fd7d9bd3Smrg# distribute this file as part of a program that contains a 24fd7d9bd3Smrg# configuration script generated by Autoconf, you may include it under 25fd7d9bd3Smrg# the same distribution terms that you use for the rest of that program. 26fd7d9bd3Smrg 27fd7d9bd3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28fd7d9bd3Smrg 29350952b9Smrgcase $1 in 30350952b9Smrg '') 31350952b9Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32350952b9Smrg exit 1; 33350952b9Smrg ;; 34350952b9Smrg -h | --h*) 35350952b9Smrg cat <<\EOF 36350952b9SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37350952b9Smrg 38350952b9SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39350952b9Smrgas side-effects. 40350952b9Smrg 41350952b9SmrgEnvironment variables: 42350952b9Smrg depmode Dependency tracking mode. 43350952b9Smrg source Source file read by `PROGRAMS ARGS'. 44350952b9Smrg object Object file output by `PROGRAMS ARGS'. 45350952b9Smrg DEPDIR directory where to store dependencies. 46350952b9Smrg depfile Dependency file to output. 47a85aecdfSmrg tmpdepfile Temporary file to use when outputting dependencies. 48350952b9Smrg libtool Whether libtool is used (yes/no). 49350952b9Smrg 50350952b9SmrgReport bugs to <bug-automake@gnu.org>. 51350952b9SmrgEOF 52350952b9Smrg exit $? 53350952b9Smrg ;; 54350952b9Smrg -v | --v*) 55350952b9Smrg echo "depcomp $scriptversion" 56350952b9Smrg exit $? 57350952b9Smrg ;; 58350952b9Smrgesac 59350952b9Smrg 60fd7d9bd3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61fd7d9bd3Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62fd7d9bd3Smrg exit 1 63fd7d9bd3Smrgfi 64fd7d9bd3Smrg 65350952b9Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66350952b9Smrgdepfile=${depfile-`echo "$object" | 67350952b9Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68fd7d9bd3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69fd7d9bd3Smrg 70fd7d9bd3Smrgrm -f "$tmpdepfile" 71fd7d9bd3Smrg 72fd7d9bd3Smrg# Some modes work just like other modes, but use different flags. We 73fd7d9bd3Smrg# parameterize here, but still list the modes in the big case below, 74fd7d9bd3Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75fd7d9bd3Smrg# here, because this file can only contain one case statement. 76fd7d9bd3Smrgif test "$depmode" = hp; then 77fd7d9bd3Smrg # HP compiler uses -M and no extra arg. 78fd7d9bd3Smrg gccflag=-M 79fd7d9bd3Smrg depmode=gcc 80fd7d9bd3Smrgfi 81fd7d9bd3Smrg 82fd7d9bd3Smrgif test "$depmode" = dashXmstdout; then 83fd7d9bd3Smrg # This is just like dashmstdout with a different argument. 84fd7d9bd3Smrg dashmflag=-xM 85fd7d9bd3Smrg depmode=dashmstdout 86fd7d9bd3Smrgfi 87fd7d9bd3Smrg 88350952b9Smrgcygpath_u="cygpath -u -f -" 89350952b9Smrgif test "$depmode" = msvcmsys; then 90350952b9Smrg # This is just like msvisualcpp but w/o cygpath translation. 91350952b9Smrg # Just convert the backslash-escaped backslashes to single forward 92350952b9Smrg # slashes to satisfy depend.m4 93a85aecdfSmrg cygpath_u='sed s,\\\\,/,g' 94350952b9Smrg depmode=msvisualcpp 95350952b9Smrgfi 96350952b9Smrg 97a85aecdfSmrgif test "$depmode" = msvc7msys; then 98a85aecdfSmrg # This is just like msvc7 but w/o cygpath translation. 99a85aecdfSmrg # Just convert the backslash-escaped backslashes to single forward 100a85aecdfSmrg # slashes to satisfy depend.m4 101a85aecdfSmrg cygpath_u='sed s,\\\\,/,g' 102a85aecdfSmrg depmode=msvc7 103a85aecdfSmrgfi 104a85aecdfSmrg 105fd7d9bd3Smrgcase "$depmode" in 106fd7d9bd3Smrggcc3) 107fd7d9bd3Smrg## gcc 3 implements dependency tracking that does exactly what 108fd7d9bd3Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109fd7d9bd3Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 110350952b9Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 111350952b9Smrg## the command line argument order; so add the flags where they 112350952b9Smrg## appear in depend2.am. Note that the slowdown incurred here 113350952b9Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 114350952b9Smrg for arg 115350952b9Smrg do 116350952b9Smrg case $arg in 117350952b9Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 118350952b9Smrg *) set fnord "$@" "$arg" ;; 119350952b9Smrg esac 120350952b9Smrg shift # fnord 121350952b9Smrg shift # $arg 122350952b9Smrg done 123350952b9Smrg "$@" 124fd7d9bd3Smrg stat=$? 125fd7d9bd3Smrg if test $stat -eq 0; then : 126fd7d9bd3Smrg else 127fd7d9bd3Smrg rm -f "$tmpdepfile" 128fd7d9bd3Smrg exit $stat 129fd7d9bd3Smrg fi 130fd7d9bd3Smrg mv "$tmpdepfile" "$depfile" 131fd7d9bd3Smrg ;; 132fd7d9bd3Smrg 133fd7d9bd3Smrggcc) 134fd7d9bd3Smrg## There are various ways to get dependency output from gcc. Here's 135fd7d9bd3Smrg## why we pick this rather obscure method: 136fd7d9bd3Smrg## - Don't want to use -MD because we'd like the dependencies to end 137fd7d9bd3Smrg## up in a subdir. Having to rename by hand is ugly. 138fd7d9bd3Smrg## (We might end up doing this anyway to support other compilers.) 139fd7d9bd3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140fd7d9bd3Smrg## -MM, not -M (despite what the docs say). 141fd7d9bd3Smrg## - Using -M directly means running the compiler twice (even worse 142fd7d9bd3Smrg## than renaming). 143fd7d9bd3Smrg if test -z "$gccflag"; then 144fd7d9bd3Smrg gccflag=-MD, 145fd7d9bd3Smrg fi 146fd7d9bd3Smrg "$@" -Wp,"$gccflag$tmpdepfile" 147fd7d9bd3Smrg stat=$? 148fd7d9bd3Smrg if test $stat -eq 0; then : 149fd7d9bd3Smrg else 150fd7d9bd3Smrg rm -f "$tmpdepfile" 151fd7d9bd3Smrg exit $stat 152fd7d9bd3Smrg fi 153fd7d9bd3Smrg rm -f "$depfile" 154fd7d9bd3Smrg echo "$object : \\" > "$depfile" 155fd7d9bd3Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156fd7d9bd3Smrg## The second -e expression handles DOS-style file names with drive letters. 157fd7d9bd3Smrg sed -e 's/^[^:]*: / /' \ 158fd7d9bd3Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159fd7d9bd3Smrg## This next piece of magic avoids the `deleted header file' problem. 160fd7d9bd3Smrg## The problem is that when a header file which appears in a .P file 161fd7d9bd3Smrg## is deleted, the dependency causes make to die (because there is 162fd7d9bd3Smrg## typically no way to rebuild the header). We avoid this by adding 163fd7d9bd3Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 164fd7d9bd3Smrg## this for us directly. 165fd7d9bd3Smrg tr ' ' ' 166fd7d9bd3Smrg' < "$tmpdepfile" | 167fd7d9bd3Smrg## Some versions of gcc put a space before the `:'. On the theory 168fd7d9bd3Smrg## that the space means something, we add a space to the output as 169a85aecdfSmrg## well. hp depmode also adds that space, but also prefixes the VPATH 170a85aecdfSmrg## to the object. Take care to not repeat it in the output. 171fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 172fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 173a85aecdfSmrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 174a85aecdfSmrg | sed -e 's/$/ :/' >> "$depfile" 175fd7d9bd3Smrg rm -f "$tmpdepfile" 176fd7d9bd3Smrg ;; 177fd7d9bd3Smrg 178fd7d9bd3Smrghp) 179fd7d9bd3Smrg # This case exists only to let depend.m4 do its work. It works by 180fd7d9bd3Smrg # looking at the text of this script. This case will never be run, 181fd7d9bd3Smrg # since it is checked for above. 182fd7d9bd3Smrg exit 1 183fd7d9bd3Smrg ;; 184fd7d9bd3Smrg 185fd7d9bd3Smrgsgi) 186fd7d9bd3Smrg if test "$libtool" = yes; then 187fd7d9bd3Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188fd7d9bd3Smrg else 189fd7d9bd3Smrg "$@" -MDupdate "$tmpdepfile" 190fd7d9bd3Smrg fi 191fd7d9bd3Smrg stat=$? 192fd7d9bd3Smrg if test $stat -eq 0; then : 193fd7d9bd3Smrg else 194fd7d9bd3Smrg rm -f "$tmpdepfile" 195fd7d9bd3Smrg exit $stat 196fd7d9bd3Smrg fi 197fd7d9bd3Smrg rm -f "$depfile" 198fd7d9bd3Smrg 199fd7d9bd3Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200fd7d9bd3Smrg echo "$object : \\" > "$depfile" 201fd7d9bd3Smrg 202fd7d9bd3Smrg # Clip off the initial element (the dependent). Don't try to be 203fd7d9bd3Smrg # clever and replace this with sed code, as IRIX sed won't handle 204fd7d9bd3Smrg # lines with more than a fixed number of characters (4096 in 205fd7d9bd3Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206fd7d9bd3Smrg # the IRIX cc adds comments like `#:fec' to the end of the 207fd7d9bd3Smrg # dependency line. 208fd7d9bd3Smrg tr ' ' ' 209fd7d9bd3Smrg' < "$tmpdepfile" \ 210fd7d9bd3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211fd7d9bd3Smrg tr ' 212350952b9Smrg' ' ' >> "$depfile" 213350952b9Smrg echo >> "$depfile" 214fd7d9bd3Smrg 215fd7d9bd3Smrg # The second pass generates a dummy entry for each header file. 216fd7d9bd3Smrg tr ' ' ' 217fd7d9bd3Smrg' < "$tmpdepfile" \ 218fd7d9bd3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 219350952b9Smrg >> "$depfile" 220fd7d9bd3Smrg else 221fd7d9bd3Smrg # The sourcefile does not contain any dependencies, so just 222fd7d9bd3Smrg # store a dummy comment line, to avoid errors with the Makefile 223fd7d9bd3Smrg # "include basename.Plo" scheme. 224fd7d9bd3Smrg echo "#dummy" > "$depfile" 225fd7d9bd3Smrg fi 226fd7d9bd3Smrg rm -f "$tmpdepfile" 227fd7d9bd3Smrg ;; 228fd7d9bd3Smrg 229fd7d9bd3Smrgaix) 230fd7d9bd3Smrg # The C for AIX Compiler uses -M and outputs the dependencies 231fd7d9bd3Smrg # in a .u file. In older versions, this file always lives in the 232fd7d9bd3Smrg # current directory. Also, the AIX compiler puts `$object:' at the 233fd7d9bd3Smrg # start of each line; $object doesn't have directory information. 234fd7d9bd3Smrg # Version 6 uses the directory in both cases. 235350952b9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 236350952b9Smrg test "x$dir" = "x$object" && dir= 237350952b9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238fd7d9bd3Smrg if test "$libtool" = yes; then 239350952b9Smrg tmpdepfile1=$dir$base.u 240350952b9Smrg tmpdepfile2=$base.u 241350952b9Smrg tmpdepfile3=$dir.libs/$base.u 242fd7d9bd3Smrg "$@" -Wc,-M 243fd7d9bd3Smrg else 244350952b9Smrg tmpdepfile1=$dir$base.u 245350952b9Smrg tmpdepfile2=$dir$base.u 246350952b9Smrg tmpdepfile3=$dir$base.u 247fd7d9bd3Smrg "$@" -M 248fd7d9bd3Smrg fi 249fd7d9bd3Smrg stat=$? 250fd7d9bd3Smrg 251fd7d9bd3Smrg if test $stat -eq 0; then : 252fd7d9bd3Smrg else 253350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254fd7d9bd3Smrg exit $stat 255fd7d9bd3Smrg fi 256fd7d9bd3Smrg 257350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 258350952b9Smrg do 259350952b9Smrg test -f "$tmpdepfile" && break 260350952b9Smrg done 261fd7d9bd3Smrg if test -f "$tmpdepfile"; then 262fd7d9bd3Smrg # Each line is of the form `foo.o: dependent.h'. 263fd7d9bd3Smrg # Do two passes, one to just change these to 264fd7d9bd3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 265350952b9Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 266350952b9Smrg # That's a tab and a space in the []. 267350952b9Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268fd7d9bd3Smrg else 269fd7d9bd3Smrg # The sourcefile does not contain any dependencies, so just 270fd7d9bd3Smrg # store a dummy comment line, to avoid errors with the Makefile 271fd7d9bd3Smrg # "include basename.Plo" scheme. 272fd7d9bd3Smrg echo "#dummy" > "$depfile" 273fd7d9bd3Smrg fi 274fd7d9bd3Smrg rm -f "$tmpdepfile" 275fd7d9bd3Smrg ;; 276fd7d9bd3Smrg 277fd7d9bd3Smrgicc) 278fd7d9bd3Smrg # Intel's C compiler understands `-MD -MF file'. However on 279fd7d9bd3Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280fd7d9bd3Smrg # ICC 7.0 will fill foo.d with something like 281fd7d9bd3Smrg # foo.o: sub/foo.c 282fd7d9bd3Smrg # foo.o: sub/foo.h 283fd7d9bd3Smrg # which is wrong. We want: 284fd7d9bd3Smrg # sub/foo.o: sub/foo.c 285fd7d9bd3Smrg # sub/foo.o: sub/foo.h 286fd7d9bd3Smrg # sub/foo.c: 287fd7d9bd3Smrg # sub/foo.h: 288fd7d9bd3Smrg # ICC 7.1 will output 289fd7d9bd3Smrg # foo.o: sub/foo.c sub/foo.h 290fd7d9bd3Smrg # and will wrap long lines using \ : 291fd7d9bd3Smrg # foo.o: sub/foo.c ... \ 292fd7d9bd3Smrg # sub/foo.h ... \ 293fd7d9bd3Smrg # ... 294fd7d9bd3Smrg 295fd7d9bd3Smrg "$@" -MD -MF "$tmpdepfile" 296fd7d9bd3Smrg stat=$? 297fd7d9bd3Smrg if test $stat -eq 0; then : 298fd7d9bd3Smrg else 299fd7d9bd3Smrg rm -f "$tmpdepfile" 300fd7d9bd3Smrg exit $stat 301fd7d9bd3Smrg fi 302fd7d9bd3Smrg rm -f "$depfile" 303fd7d9bd3Smrg # Each line is of the form `foo.o: dependent.h', 304fd7d9bd3Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305fd7d9bd3Smrg # Do two passes, one to just change these to 306fd7d9bd3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 307fd7d9bd3Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308fd7d9bd3Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 309fd7d9bd3Smrg # correctly. Breaking it into two sed invocations is a workaround. 310fd7d9bd3Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311fd7d9bd3Smrg sed -e 's/$/ :/' >> "$depfile" 312fd7d9bd3Smrg rm -f "$tmpdepfile" 313fd7d9bd3Smrg ;; 314fd7d9bd3Smrg 315350952b9Smrghp2) 316350952b9Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 317350952b9Smrg # compilers, which have integrated preprocessors. The correct option 318350952b9Smrg # to use with these is +Maked; it writes dependencies to a file named 319350952b9Smrg # 'foo.d', which lands next to the object file, wherever that 320350952b9Smrg # happens to be. 321350952b9Smrg # Much of this is similar to the tru64 case; see comments there. 322350952b9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 323350952b9Smrg test "x$dir" = "x$object" && dir= 324350952b9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 325350952b9Smrg if test "$libtool" = yes; then 326350952b9Smrg tmpdepfile1=$dir$base.d 327350952b9Smrg tmpdepfile2=$dir.libs/$base.d 328350952b9Smrg "$@" -Wc,+Maked 329350952b9Smrg else 330350952b9Smrg tmpdepfile1=$dir$base.d 331350952b9Smrg tmpdepfile2=$dir$base.d 332350952b9Smrg "$@" +Maked 333350952b9Smrg fi 334350952b9Smrg stat=$? 335350952b9Smrg if test $stat -eq 0; then : 336350952b9Smrg else 337350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 338350952b9Smrg exit $stat 339350952b9Smrg fi 340350952b9Smrg 341350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 342350952b9Smrg do 343350952b9Smrg test -f "$tmpdepfile" && break 344350952b9Smrg done 345350952b9Smrg if test -f "$tmpdepfile"; then 346350952b9Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 347350952b9Smrg # Add `dependent.h:' lines. 348350952b9Smrg sed -ne '2,${ 349350952b9Smrg s/^ *// 350350952b9Smrg s/ \\*$// 351350952b9Smrg s/$/:/ 352350952b9Smrg p 353350952b9Smrg }' "$tmpdepfile" >> "$depfile" 354350952b9Smrg else 355350952b9Smrg echo "#dummy" > "$depfile" 356350952b9Smrg fi 357350952b9Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 358350952b9Smrg ;; 359350952b9Smrg 360fd7d9bd3Smrgtru64) 361fd7d9bd3Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 362fd7d9bd3Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363fd7d9bd3Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364fd7d9bd3Smrg # dependencies in `foo.d' instead, so we check for that too. 365fd7d9bd3Smrg # Subdirectories are respected. 366fd7d9bd3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367fd7d9bd3Smrg test "x$dir" = "x$object" && dir= 368fd7d9bd3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369fd7d9bd3Smrg 370fd7d9bd3Smrg if test "$libtool" = yes; then 371350952b9Smrg # With Tru64 cc, shared objects can also be used to make a 372350952b9Smrg # static library. This mechanism is used in libtool 1.4 series to 373350952b9Smrg # handle both shared and static libraries in a single compilation. 374350952b9Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 375350952b9Smrg # 376350952b9Smrg # With libtool 1.5 this exception was removed, and libtool now 377350952b9Smrg # generates 2 separate objects for the 2 libraries. These two 378350952b9Smrg # compilations output dependencies in $dir.libs/$base.o.d and 379350952b9Smrg # in $dir$base.o.d. We have to check for both files, because 380350952b9Smrg # one of the two compilations can be disabled. We should prefer 381350952b9Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 382350952b9Smrg # automatically cleaned when .libs/ is deleted, while ignoring 383350952b9Smrg # the former would cause a distcleancheck panic. 384350952b9Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 385350952b9Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 386350952b9Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 387350952b9Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388fd7d9bd3Smrg "$@" -Wc,-MD 389fd7d9bd3Smrg else 390350952b9Smrg tmpdepfile1=$dir$base.o.d 391350952b9Smrg tmpdepfile2=$dir$base.d 392350952b9Smrg tmpdepfile3=$dir$base.d 393350952b9Smrg tmpdepfile4=$dir$base.d 394fd7d9bd3Smrg "$@" -MD 395fd7d9bd3Smrg fi 396fd7d9bd3Smrg 397fd7d9bd3Smrg stat=$? 398fd7d9bd3Smrg if test $stat -eq 0; then : 399fd7d9bd3Smrg else 400350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401fd7d9bd3Smrg exit $stat 402fd7d9bd3Smrg fi 403fd7d9bd3Smrg 404350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 405350952b9Smrg do 406350952b9Smrg test -f "$tmpdepfile" && break 407350952b9Smrg done 408fd7d9bd3Smrg if test -f "$tmpdepfile"; then 409fd7d9bd3Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410fd7d9bd3Smrg # That's a tab and a space in the []. 411fd7d9bd3Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412fd7d9bd3Smrg else 413fd7d9bd3Smrg echo "#dummy" > "$depfile" 414fd7d9bd3Smrg fi 415fd7d9bd3Smrg rm -f "$tmpdepfile" 416fd7d9bd3Smrg ;; 417fd7d9bd3Smrg 418a85aecdfSmrgmsvc7) 419a85aecdfSmrg if test "$libtool" = yes; then 420a85aecdfSmrg showIncludes=-Wc,-showIncludes 421a85aecdfSmrg else 422a85aecdfSmrg showIncludes=-showIncludes 423a85aecdfSmrg fi 424a85aecdfSmrg "$@" $showIncludes > "$tmpdepfile" 425a85aecdfSmrg stat=$? 426a85aecdfSmrg grep -v '^Note: including file: ' "$tmpdepfile" 427a85aecdfSmrg if test "$stat" = 0; then : 428a85aecdfSmrg else 429a85aecdfSmrg rm -f "$tmpdepfile" 430a85aecdfSmrg exit $stat 431a85aecdfSmrg fi 432a85aecdfSmrg rm -f "$depfile" 433a85aecdfSmrg echo "$object : \\" > "$depfile" 434a85aecdfSmrg # The first sed program below extracts the file names and escapes 435a85aecdfSmrg # backslashes for cygpath. The second sed program outputs the file 436a85aecdfSmrg # name when reading, but also accumulates all include files in the 437a85aecdfSmrg # hold buffer in order to output them again at the end. This only 438a85aecdfSmrg # works with sed implementations that can handle large buffers. 439a85aecdfSmrg sed < "$tmpdepfile" -n ' 440a85aecdfSmrg/^Note: including file: *\(.*\)/ { 441a85aecdfSmrg s//\1/ 442a85aecdfSmrg s/\\/\\\\/g 443a85aecdfSmrg p 444a85aecdfSmrg}' | $cygpath_u | sort -u | sed -n ' 445a85aecdfSmrgs/ /\\ /g 446a85aecdfSmrgs/\(.*\)/ \1 \\/p 447a85aecdfSmrgs/.\(.*\) \\/\1:/ 448a85aecdfSmrgH 449a85aecdfSmrg$ { 450a85aecdfSmrg s/.*/ / 451a85aecdfSmrg G 452a85aecdfSmrg p 453a85aecdfSmrg}' >> "$depfile" 454a85aecdfSmrg rm -f "$tmpdepfile" 455a85aecdfSmrg ;; 456a85aecdfSmrg 457a85aecdfSmrgmsvc7msys) 458a85aecdfSmrg # This case exists only to let depend.m4 do its work. It works by 459a85aecdfSmrg # looking at the text of this script. This case will never be run, 460a85aecdfSmrg # since it is checked for above. 461a85aecdfSmrg exit 1 462a85aecdfSmrg ;; 463a85aecdfSmrg 464fd7d9bd3Smrg#nosideeffect) 465fd7d9bd3Smrg # This comment above is used by automake to tell side-effect 466fd7d9bd3Smrg # dependency tracking mechanisms from slower ones. 467fd7d9bd3Smrg 468fd7d9bd3Smrgdashmstdout) 469fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 470fd7d9bd3Smrg # always write the preprocessed file to stdout, regardless of -o. 471fd7d9bd3Smrg "$@" || exit $? 472fd7d9bd3Smrg 473fd7d9bd3Smrg # Remove the call to Libtool. 474fd7d9bd3Smrg if test "$libtool" = yes; then 475350952b9Smrg while test "X$1" != 'X--mode=compile'; do 476fd7d9bd3Smrg shift 477fd7d9bd3Smrg done 478fd7d9bd3Smrg shift 479fd7d9bd3Smrg fi 480fd7d9bd3Smrg 481fd7d9bd3Smrg # Remove `-o $object'. 482fd7d9bd3Smrg IFS=" " 483fd7d9bd3Smrg for arg 484fd7d9bd3Smrg do 485fd7d9bd3Smrg case $arg in 486fd7d9bd3Smrg -o) 487fd7d9bd3Smrg shift 488fd7d9bd3Smrg ;; 489fd7d9bd3Smrg $object) 490fd7d9bd3Smrg shift 491fd7d9bd3Smrg ;; 492fd7d9bd3Smrg *) 493fd7d9bd3Smrg set fnord "$@" "$arg" 494fd7d9bd3Smrg shift # fnord 495fd7d9bd3Smrg shift # $arg 496fd7d9bd3Smrg ;; 497fd7d9bd3Smrg esac 498fd7d9bd3Smrg done 499fd7d9bd3Smrg 500fd7d9bd3Smrg test -z "$dashmflag" && dashmflag=-M 501fd7d9bd3Smrg # Require at least two characters before searching for `:' 502fd7d9bd3Smrg # in the target name. This is to cope with DOS-style filenames: 503fd7d9bd3Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504fd7d9bd3Smrg "$@" $dashmflag | 505fd7d9bd3Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506fd7d9bd3Smrg rm -f "$depfile" 507fd7d9bd3Smrg cat < "$tmpdepfile" > "$depfile" 508fd7d9bd3Smrg tr ' ' ' 509fd7d9bd3Smrg' < "$tmpdepfile" | \ 510fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 511fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 512fd7d9bd3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513fd7d9bd3Smrg rm -f "$tmpdepfile" 514fd7d9bd3Smrg ;; 515fd7d9bd3Smrg 516fd7d9bd3SmrgdashXmstdout) 517fd7d9bd3Smrg # This case only exists to satisfy depend.m4. It is never actually 518fd7d9bd3Smrg # run, as this mode is specially recognized in the preamble. 519fd7d9bd3Smrg exit 1 520fd7d9bd3Smrg ;; 521fd7d9bd3Smrg 522fd7d9bd3Smrgmakedepend) 523fd7d9bd3Smrg "$@" || exit $? 524fd7d9bd3Smrg # Remove any Libtool call 525fd7d9bd3Smrg if test "$libtool" = yes; then 526350952b9Smrg while test "X$1" != 'X--mode=compile'; do 527fd7d9bd3Smrg shift 528fd7d9bd3Smrg done 529fd7d9bd3Smrg shift 530fd7d9bd3Smrg fi 531fd7d9bd3Smrg # X makedepend 532fd7d9bd3Smrg shift 533350952b9Smrg cleared=no eat=no 534350952b9Smrg for arg 535350952b9Smrg do 536fd7d9bd3Smrg case $cleared in 537fd7d9bd3Smrg no) 538fd7d9bd3Smrg set ""; shift 539fd7d9bd3Smrg cleared=yes ;; 540fd7d9bd3Smrg esac 541350952b9Smrg if test $eat = yes; then 542350952b9Smrg eat=no 543350952b9Smrg continue 544350952b9Smrg fi 545fd7d9bd3Smrg case "$arg" in 546fd7d9bd3Smrg -D*|-I*) 547fd7d9bd3Smrg set fnord "$@" "$arg"; shift ;; 548fd7d9bd3Smrg # Strip any option that makedepend may not understand. Remove 549fd7d9bd3Smrg # the object too, otherwise makedepend will parse it as a source file. 550350952b9Smrg -arch) 551350952b9Smrg eat=yes ;; 552fd7d9bd3Smrg -*|$object) 553fd7d9bd3Smrg ;; 554fd7d9bd3Smrg *) 555fd7d9bd3Smrg set fnord "$@" "$arg"; shift ;; 556fd7d9bd3Smrg esac 557fd7d9bd3Smrg done 558350952b9Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559fd7d9bd3Smrg touch "$tmpdepfile" 560fd7d9bd3Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561fd7d9bd3Smrg rm -f "$depfile" 562a85aecdfSmrg # makedepend may prepend the VPATH from the source file name to the object. 563a85aecdfSmrg # No need to regex-escape $object, excess matching of '.' is harmless. 564a85aecdfSmrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565fd7d9bd3Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566fd7d9bd3Smrg' | \ 567fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 568fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 569fd7d9bd3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570fd7d9bd3Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571fd7d9bd3Smrg ;; 572fd7d9bd3Smrg 573fd7d9bd3Smrgcpp) 574fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 575fd7d9bd3Smrg # always write the preprocessed file to stdout. 576fd7d9bd3Smrg "$@" || exit $? 577fd7d9bd3Smrg 578fd7d9bd3Smrg # Remove the call to Libtool. 579fd7d9bd3Smrg if test "$libtool" = yes; then 580350952b9Smrg while test "X$1" != 'X--mode=compile'; do 581fd7d9bd3Smrg shift 582fd7d9bd3Smrg done 583fd7d9bd3Smrg shift 584fd7d9bd3Smrg fi 585fd7d9bd3Smrg 586fd7d9bd3Smrg # Remove `-o $object'. 587fd7d9bd3Smrg IFS=" " 588fd7d9bd3Smrg for arg 589fd7d9bd3Smrg do 590fd7d9bd3Smrg case $arg in 591fd7d9bd3Smrg -o) 592fd7d9bd3Smrg shift 593fd7d9bd3Smrg ;; 594fd7d9bd3Smrg $object) 595fd7d9bd3Smrg shift 596fd7d9bd3Smrg ;; 597fd7d9bd3Smrg *) 598fd7d9bd3Smrg set fnord "$@" "$arg" 599fd7d9bd3Smrg shift # fnord 600fd7d9bd3Smrg shift # $arg 601fd7d9bd3Smrg ;; 602fd7d9bd3Smrg esac 603fd7d9bd3Smrg done 604fd7d9bd3Smrg 605fd7d9bd3Smrg "$@" -E | 606350952b9Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 607350952b9Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608fd7d9bd3Smrg sed '$ s: \\$::' > "$tmpdepfile" 609fd7d9bd3Smrg rm -f "$depfile" 610fd7d9bd3Smrg echo "$object : \\" > "$depfile" 611fd7d9bd3Smrg cat < "$tmpdepfile" >> "$depfile" 612fd7d9bd3Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613fd7d9bd3Smrg rm -f "$tmpdepfile" 614fd7d9bd3Smrg ;; 615fd7d9bd3Smrg 616fd7d9bd3Smrgmsvisualcpp) 617fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 618350952b9Smrg # always write the preprocessed file to stdout. 619fd7d9bd3Smrg "$@" || exit $? 620350952b9Smrg 621350952b9Smrg # Remove the call to Libtool. 622350952b9Smrg if test "$libtool" = yes; then 623350952b9Smrg while test "X$1" != 'X--mode=compile'; do 624350952b9Smrg shift 625350952b9Smrg done 626350952b9Smrg shift 627350952b9Smrg fi 628350952b9Smrg 629fd7d9bd3Smrg IFS=" " 630fd7d9bd3Smrg for arg 631fd7d9bd3Smrg do 632fd7d9bd3Smrg case "$arg" in 633350952b9Smrg -o) 634350952b9Smrg shift 635350952b9Smrg ;; 636350952b9Smrg $object) 637350952b9Smrg shift 638350952b9Smrg ;; 639fd7d9bd3Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640fd7d9bd3Smrg set fnord "$@" 641fd7d9bd3Smrg shift 642fd7d9bd3Smrg shift 643fd7d9bd3Smrg ;; 644fd7d9bd3Smrg *) 645fd7d9bd3Smrg set fnord "$@" "$arg" 646fd7d9bd3Smrg shift 647fd7d9bd3Smrg shift 648fd7d9bd3Smrg ;; 649fd7d9bd3Smrg esac 650fd7d9bd3Smrg done 651350952b9Smrg "$@" -E 2>/dev/null | 652350952b9Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653fd7d9bd3Smrg rm -f "$depfile" 654fd7d9bd3Smrg echo "$object : \\" > "$depfile" 655350952b9Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656fd7d9bd3Smrg echo " " >> "$depfile" 657350952b9Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658fd7d9bd3Smrg rm -f "$tmpdepfile" 659fd7d9bd3Smrg ;; 660fd7d9bd3Smrg 661350952b9Smrgmsvcmsys) 662350952b9Smrg # This case exists only to let depend.m4 do its work. It works by 663350952b9Smrg # looking at the text of this script. This case will never be run, 664350952b9Smrg # since it is checked for above. 665350952b9Smrg exit 1 666350952b9Smrg ;; 667350952b9Smrg 668fd7d9bd3Smrgnone) 669fd7d9bd3Smrg exec "$@" 670fd7d9bd3Smrg ;; 671fd7d9bd3Smrg 672fd7d9bd3Smrg*) 673fd7d9bd3Smrg echo "Unknown depmode $depmode" 1>&2 674fd7d9bd3Smrg exit 1 675fd7d9bd3Smrg ;; 676fd7d9bd3Smrgesac 677fd7d9bd3Smrg 678fd7d9bd3Smrgexit 0 679350952b9Smrg 680350952b9Smrg# Local Variables: 681350952b9Smrg# mode: shell-script 682350952b9Smrg# sh-indentation: 2 683350952b9Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 684350952b9Smrg# time-stamp-start: "scriptversion=" 685350952b9Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 686350952b9Smrg# time-stamp-time-zone: "UTC" 687350952b9Smrg# time-stamp-end: "; # UTC" 688350952b9Smrg# End: 689