1a7c91847Schristos#! /bin/sh 2a7c91847Schristos# depcomp - compile a program generating dependencies as side-effects 3a7c91847Schristos 4*75e57c56Schristosscriptversion=2009-04-28.21; # UTC 5a7c91847Schristos 6*75e57c56Schristos# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7*75e57c56Schristos# Software Foundation, Inc. 8a7c91847Schristos 9a7c91847Schristos# This program is free software; you can redistribute it and/or modify 10a7c91847Schristos# it under the terms of the GNU General Public License as published by 11a7c91847Schristos# the Free Software Foundation; either version 2, or (at your option) 12a7c91847Schristos# any later version. 13a7c91847Schristos 14a7c91847Schristos# This program is distributed in the hope that it will be useful, 15a7c91847Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 16a7c91847Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17a7c91847Schristos# GNU General Public License for more details. 18a7c91847Schristos 19a7c91847Schristos# You should have received a copy of the GNU General Public License 20*75e57c56Schristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 21a7c91847Schristos 22a7c91847Schristos# As a special exception to the GNU General Public License, if you 23a7c91847Schristos# distribute this file as part of a program that contains a 24a7c91847Schristos# configuration script generated by Autoconf, you may include it under 25a7c91847Schristos# the same distribution terms that you use for the rest of that program. 26a7c91847Schristos 27a7c91847Schristos# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28a7c91847Schristos 29a7c91847Schristoscase $1 in 30a7c91847Schristos '') 31a7c91847Schristos echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32a7c91847Schristos exit 1; 33a7c91847Schristos ;; 34a7c91847Schristos -h | --h*) 35a7c91847Schristos cat <<\EOF 36a7c91847SchristosUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37a7c91847Schristos 38a7c91847SchristosRun PROGRAMS ARGS to compile a file, generating dependencies 39a7c91847Schristosas side-effects. 40a7c91847Schristos 41a7c91847SchristosEnvironment variables: 42a7c91847Schristos depmode Dependency tracking mode. 43a7c91847Schristos source Source file read by `PROGRAMS ARGS'. 44a7c91847Schristos object Object file output by `PROGRAMS ARGS'. 45a7c91847Schristos DEPDIR directory where to store dependencies. 46a7c91847Schristos depfile Dependency file to output. 47a7c91847Schristos tmpdepfile Temporary file to use when outputing dependencies. 48a7c91847Schristos libtool Whether libtool is used (yes/no). 49a7c91847Schristos 50a7c91847SchristosReport bugs to <bug-automake@gnu.org>. 51a7c91847SchristosEOF 52a7c91847Schristos exit $? 53a7c91847Schristos ;; 54a7c91847Schristos -v | --v*) 55a7c91847Schristos echo "depcomp $scriptversion" 56a7c91847Schristos exit $? 57a7c91847Schristos ;; 58a7c91847Schristosesac 59a7c91847Schristos 60a7c91847Schristosif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61a7c91847Schristos echo "depcomp: Variables source, object and depmode must be set" 1>&2 62a7c91847Schristos exit 1 63a7c91847Schristosfi 64a7c91847Schristos 65a7c91847Schristos# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66a7c91847Schristosdepfile=${depfile-`echo "$object" | 67a7c91847Schristos sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68a7c91847Schristostmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69a7c91847Schristos 70a7c91847Schristosrm -f "$tmpdepfile" 71a7c91847Schristos 72a7c91847Schristos# Some modes work just like other modes, but use different flags. We 73a7c91847Schristos# parameterize here, but still list the modes in the big case below, 74a7c91847Schristos# to make depend.m4 easier to write. Note that we *cannot* use a case 75a7c91847Schristos# here, because this file can only contain one case statement. 76a7c91847Schristosif test "$depmode" = hp; then 77a7c91847Schristos # HP compiler uses -M and no extra arg. 78a7c91847Schristos gccflag=-M 79a7c91847Schristos depmode=gcc 80a7c91847Schristosfi 81a7c91847Schristos 82a7c91847Schristosif test "$depmode" = dashXmstdout; then 83a7c91847Schristos # This is just like dashmstdout with a different argument. 84a7c91847Schristos dashmflag=-xM 85a7c91847Schristos depmode=dashmstdout 86a7c91847Schristosfi 87a7c91847Schristos 88*75e57c56Schristoscygpath_u="cygpath -u -f -" 89*75e57c56Schristosif test "$depmode" = msvcmsys; then 90*75e57c56Schristos # This is just like msvisualcpp but w/o cygpath translation. 91*75e57c56Schristos # Just convert the backslash-escaped backslashes to single forward 92*75e57c56Schristos # slashes to satisfy depend.m4 93*75e57c56Schristos cygpath_u="sed s,\\\\\\\\,/,g" 94*75e57c56Schristos depmode=msvisualcpp 95*75e57c56Schristosfi 96*75e57c56Schristos 97a7c91847Schristoscase "$depmode" in 98a7c91847Schristosgcc3) 99a7c91847Schristos## gcc 3 implements dependency tracking that does exactly what 100a7c91847Schristos## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101a7c91847Schristos## it if -MD -MP comes after the -MF stuff. Hmm. 102889c434eSchristos## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103889c434eSchristos## the command line argument order; so add the flags where they 104889c434eSchristos## appear in depend2.am. Note that the slowdown incurred here 105889c434eSchristos## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106889c434eSchristos for arg 107889c434eSchristos do 108889c434eSchristos case $arg in 109889c434eSchristos -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110889c434eSchristos *) set fnord "$@" "$arg" ;; 111889c434eSchristos esac 112889c434eSchristos shift # fnord 113889c434eSchristos shift # $arg 114889c434eSchristos done 115889c434eSchristos "$@" 116a7c91847Schristos stat=$? 117a7c91847Schristos if test $stat -eq 0; then : 118a7c91847Schristos else 119a7c91847Schristos rm -f "$tmpdepfile" 120a7c91847Schristos exit $stat 121a7c91847Schristos fi 122a7c91847Schristos mv "$tmpdepfile" "$depfile" 123a7c91847Schristos ;; 124a7c91847Schristos 125a7c91847Schristosgcc) 126a7c91847Schristos## There are various ways to get dependency output from gcc. Here's 127a7c91847Schristos## why we pick this rather obscure method: 128a7c91847Schristos## - Don't want to use -MD because we'd like the dependencies to end 129a7c91847Schristos## up in a subdir. Having to rename by hand is ugly. 130a7c91847Schristos## (We might end up doing this anyway to support other compilers.) 131a7c91847Schristos## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132a7c91847Schristos## -MM, not -M (despite what the docs say). 133a7c91847Schristos## - Using -M directly means running the compiler twice (even worse 134a7c91847Schristos## than renaming). 135a7c91847Schristos if test -z "$gccflag"; then 136a7c91847Schristos gccflag=-MD, 137a7c91847Schristos fi 138a7c91847Schristos "$@" -Wp,"$gccflag$tmpdepfile" 139a7c91847Schristos stat=$? 140a7c91847Schristos if test $stat -eq 0; then : 141a7c91847Schristos else 142a7c91847Schristos rm -f "$tmpdepfile" 143a7c91847Schristos exit $stat 144a7c91847Schristos fi 145a7c91847Schristos rm -f "$depfile" 146a7c91847Schristos echo "$object : \\" > "$depfile" 147a7c91847Schristos alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148a7c91847Schristos## The second -e expression handles DOS-style file names with drive letters. 149a7c91847Schristos sed -e 's/^[^:]*: / /' \ 150a7c91847Schristos -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151a7c91847Schristos## This next piece of magic avoids the `deleted header file' problem. 152a7c91847Schristos## The problem is that when a header file which appears in a .P file 153a7c91847Schristos## is deleted, the dependency causes make to die (because there is 154a7c91847Schristos## typically no way to rebuild the header). We avoid this by adding 155a7c91847Schristos## dummy dependencies for each header file. Too bad gcc doesn't do 156a7c91847Schristos## this for us directly. 157a7c91847Schristos tr ' ' ' 158a7c91847Schristos' < "$tmpdepfile" | 159a7c91847Schristos## Some versions of gcc put a space before the `:'. On the theory 160a7c91847Schristos## that the space means something, we add a space to the output as 161a7c91847Schristos## well. 162a7c91847Schristos## Some versions of the HPUX 10.20 sed can't process this invocation 163a7c91847Schristos## correctly. Breaking it into two sed invocations is a workaround. 164a7c91847Schristos sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165a7c91847Schristos rm -f "$tmpdepfile" 166a7c91847Schristos ;; 167a7c91847Schristos 168a7c91847Schristoshp) 169a7c91847Schristos # This case exists only to let depend.m4 do its work. It works by 170a7c91847Schristos # looking at the text of this script. This case will never be run, 171a7c91847Schristos # since it is checked for above. 172a7c91847Schristos exit 1 173a7c91847Schristos ;; 174a7c91847Schristos 175a7c91847Schristossgi) 176a7c91847Schristos if test "$libtool" = yes; then 177a7c91847Schristos "$@" "-Wp,-MDupdate,$tmpdepfile" 178a7c91847Schristos else 179a7c91847Schristos "$@" -MDupdate "$tmpdepfile" 180a7c91847Schristos fi 181a7c91847Schristos stat=$? 182a7c91847Schristos if test $stat -eq 0; then : 183a7c91847Schristos else 184a7c91847Schristos rm -f "$tmpdepfile" 185a7c91847Schristos exit $stat 186a7c91847Schristos fi 187a7c91847Schristos rm -f "$depfile" 188a7c91847Schristos 189a7c91847Schristos if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190a7c91847Schristos echo "$object : \\" > "$depfile" 191a7c91847Schristos 192a7c91847Schristos # Clip off the initial element (the dependent). Don't try to be 193a7c91847Schristos # clever and replace this with sed code, as IRIX sed won't handle 194a7c91847Schristos # lines with more than a fixed number of characters (4096 in 195a7c91847Schristos # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196a7c91847Schristos # the IRIX cc adds comments like `#:fec' to the end of the 197a7c91847Schristos # dependency line. 198a7c91847Schristos tr ' ' ' 199a7c91847Schristos' < "$tmpdepfile" \ 200a7c91847Schristos | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201a7c91847Schristos tr ' 202*75e57c56Schristos' ' ' >> "$depfile" 203*75e57c56Schristos echo >> "$depfile" 204a7c91847Schristos 205a7c91847Schristos # The second pass generates a dummy entry for each header file. 206a7c91847Schristos tr ' ' ' 207a7c91847Schristos' < "$tmpdepfile" \ 208a7c91847Schristos | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209*75e57c56Schristos >> "$depfile" 210a7c91847Schristos else 211a7c91847Schristos # The sourcefile does not contain any dependencies, so just 212a7c91847Schristos # store a dummy comment line, to avoid errors with the Makefile 213a7c91847Schristos # "include basename.Plo" scheme. 214a7c91847Schristos echo "#dummy" > "$depfile" 215a7c91847Schristos fi 216a7c91847Schristos rm -f "$tmpdepfile" 217a7c91847Schristos ;; 218a7c91847Schristos 219a7c91847Schristosaix) 220a7c91847Schristos # The C for AIX Compiler uses -M and outputs the dependencies 221a7c91847Schristos # in a .u file. In older versions, this file always lives in the 222a7c91847Schristos # current directory. Also, the AIX compiler puts `$object:' at the 223a7c91847Schristos # start of each line; $object doesn't have directory information. 224a7c91847Schristos # Version 6 uses the directory in both cases. 225889c434eSchristos dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226889c434eSchristos test "x$dir" = "x$object" && dir= 227889c434eSchristos base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228a7c91847Schristos if test "$libtool" = yes; then 229889c434eSchristos tmpdepfile1=$dir$base.u 230889c434eSchristos tmpdepfile2=$base.u 231889c434eSchristos tmpdepfile3=$dir.libs/$base.u 232a7c91847Schristos "$@" -Wc,-M 233a7c91847Schristos else 234889c434eSchristos tmpdepfile1=$dir$base.u 235889c434eSchristos tmpdepfile2=$dir$base.u 236889c434eSchristos tmpdepfile3=$dir$base.u 237a7c91847Schristos "$@" -M 238a7c91847Schristos fi 239a7c91847Schristos stat=$? 240a7c91847Schristos 241a7c91847Schristos if test $stat -eq 0; then : 242a7c91847Schristos else 243889c434eSchristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244a7c91847Schristos exit $stat 245a7c91847Schristos fi 246a7c91847Schristos 247889c434eSchristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248889c434eSchristos do 249889c434eSchristos test -f "$tmpdepfile" && break 250889c434eSchristos done 251a7c91847Schristos if test -f "$tmpdepfile"; then 252a7c91847Schristos # Each line is of the form `foo.o: dependent.h'. 253a7c91847Schristos # Do two passes, one to just change these to 254a7c91847Schristos # `$object: dependent.h' and one to simply `dependent.h:'. 255889c434eSchristos sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256889c434eSchristos # That's a tab and a space in the []. 257889c434eSchristos sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258a7c91847Schristos else 259a7c91847Schristos # The sourcefile does not contain any dependencies, so just 260a7c91847Schristos # store a dummy comment line, to avoid errors with the Makefile 261a7c91847Schristos # "include basename.Plo" scheme. 262a7c91847Schristos echo "#dummy" > "$depfile" 263a7c91847Schristos fi 264a7c91847Schristos rm -f "$tmpdepfile" 265a7c91847Schristos ;; 266a7c91847Schristos 267a7c91847Schristosicc) 268a7c91847Schristos # Intel's C compiler understands `-MD -MF file'. However on 269a7c91847Schristos # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270a7c91847Schristos # ICC 7.0 will fill foo.d with something like 271a7c91847Schristos # foo.o: sub/foo.c 272a7c91847Schristos # foo.o: sub/foo.h 273a7c91847Schristos # which is wrong. We want: 274a7c91847Schristos # sub/foo.o: sub/foo.c 275a7c91847Schristos # sub/foo.o: sub/foo.h 276a7c91847Schristos # sub/foo.c: 277a7c91847Schristos # sub/foo.h: 278a7c91847Schristos # ICC 7.1 will output 279a7c91847Schristos # foo.o: sub/foo.c sub/foo.h 280a7c91847Schristos # and will wrap long lines using \ : 281a7c91847Schristos # foo.o: sub/foo.c ... \ 282a7c91847Schristos # sub/foo.h ... \ 283a7c91847Schristos # ... 284a7c91847Schristos 285a7c91847Schristos "$@" -MD -MF "$tmpdepfile" 286a7c91847Schristos stat=$? 287a7c91847Schristos if test $stat -eq 0; then : 288a7c91847Schristos else 289a7c91847Schristos rm -f "$tmpdepfile" 290a7c91847Schristos exit $stat 291a7c91847Schristos fi 292a7c91847Schristos rm -f "$depfile" 293a7c91847Schristos # Each line is of the form `foo.o: dependent.h', 294a7c91847Schristos # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295a7c91847Schristos # Do two passes, one to just change these to 296a7c91847Schristos # `$object: dependent.h' and one to simply `dependent.h:'. 297a7c91847Schristos sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298a7c91847Schristos # Some versions of the HPUX 10.20 sed can't process this invocation 299a7c91847Schristos # correctly. Breaking it into two sed invocations is a workaround. 300a7c91847Schristos sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301a7c91847Schristos sed -e 's/$/ :/' >> "$depfile" 302a7c91847Schristos rm -f "$tmpdepfile" 303a7c91847Schristos ;; 304a7c91847Schristos 305889c434eSchristoshp2) 306889c434eSchristos # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307889c434eSchristos # compilers, which have integrated preprocessors. The correct option 308889c434eSchristos # to use with these is +Maked; it writes dependencies to a file named 309889c434eSchristos # 'foo.d', which lands next to the object file, wherever that 310889c434eSchristos # happens to be. 311889c434eSchristos # Much of this is similar to the tru64 case; see comments there. 312889c434eSchristos dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313889c434eSchristos test "x$dir" = "x$object" && dir= 314889c434eSchristos base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315889c434eSchristos if test "$libtool" = yes; then 316889c434eSchristos tmpdepfile1=$dir$base.d 317889c434eSchristos tmpdepfile2=$dir.libs/$base.d 318889c434eSchristos "$@" -Wc,+Maked 319889c434eSchristos else 320889c434eSchristos tmpdepfile1=$dir$base.d 321889c434eSchristos tmpdepfile2=$dir$base.d 322889c434eSchristos "$@" +Maked 323889c434eSchristos fi 324889c434eSchristos stat=$? 325889c434eSchristos if test $stat -eq 0; then : 326889c434eSchristos else 327889c434eSchristos rm -f "$tmpdepfile1" "$tmpdepfile2" 328889c434eSchristos exit $stat 329889c434eSchristos fi 330889c434eSchristos 331889c434eSchristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332889c434eSchristos do 333889c434eSchristos test -f "$tmpdepfile" && break 334889c434eSchristos done 335889c434eSchristos if test -f "$tmpdepfile"; then 336889c434eSchristos sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337889c434eSchristos # Add `dependent.h:' lines. 338*75e57c56Schristos sed -ne '2,${ 339*75e57c56Schristos s/^ *// 340*75e57c56Schristos s/ \\*$// 341*75e57c56Schristos s/$/:/ 342*75e57c56Schristos p 343*75e57c56Schristos }' "$tmpdepfile" >> "$depfile" 344889c434eSchristos else 345889c434eSchristos echo "#dummy" > "$depfile" 346889c434eSchristos fi 347889c434eSchristos rm -f "$tmpdepfile" "$tmpdepfile2" 348889c434eSchristos ;; 349889c434eSchristos 350a7c91847Schristostru64) 351a7c91847Schristos # The Tru64 compiler uses -MD to generate dependencies as a side 352a7c91847Schristos # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353a7c91847Schristos # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354a7c91847Schristos # dependencies in `foo.d' instead, so we check for that too. 355a7c91847Schristos # Subdirectories are respected. 356a7c91847Schristos dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357a7c91847Schristos test "x$dir" = "x$object" && dir= 358a7c91847Schristos base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359a7c91847Schristos 360a7c91847Schristos if test "$libtool" = yes; then 361a7c91847Schristos # With Tru64 cc, shared objects can also be used to make a 362889c434eSchristos # static library. This mechanism is used in libtool 1.4 series to 363a7c91847Schristos # handle both shared and static libraries in a single compilation. 364a7c91847Schristos # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365a7c91847Schristos # 366a7c91847Schristos # With libtool 1.5 this exception was removed, and libtool now 367a7c91847Schristos # generates 2 separate objects for the 2 libraries. These two 368889c434eSchristos # compilations output dependencies in $dir.libs/$base.o.d and 369a7c91847Schristos # in $dir$base.o.d. We have to check for both files, because 370a7c91847Schristos # one of the two compilations can be disabled. We should prefer 371a7c91847Schristos # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372a7c91847Schristos # automatically cleaned when .libs/ is deleted, while ignoring 373a7c91847Schristos # the former would cause a distcleancheck panic. 374a7c91847Schristos tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375a7c91847Schristos tmpdepfile2=$dir$base.o.d # libtool 1.5 376a7c91847Schristos tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377a7c91847Schristos tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378a7c91847Schristos "$@" -Wc,-MD 379a7c91847Schristos else 380a7c91847Schristos tmpdepfile1=$dir$base.o.d 381a7c91847Schristos tmpdepfile2=$dir$base.d 382a7c91847Schristos tmpdepfile3=$dir$base.d 383a7c91847Schristos tmpdepfile4=$dir$base.d 384a7c91847Schristos "$@" -MD 385a7c91847Schristos fi 386a7c91847Schristos 387a7c91847Schristos stat=$? 388a7c91847Schristos if test $stat -eq 0; then : 389a7c91847Schristos else 390a7c91847Schristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391a7c91847Schristos exit $stat 392a7c91847Schristos fi 393a7c91847Schristos 394a7c91847Schristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395a7c91847Schristos do 396a7c91847Schristos test -f "$tmpdepfile" && break 397a7c91847Schristos done 398a7c91847Schristos if test -f "$tmpdepfile"; then 399a7c91847Schristos sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400a7c91847Schristos # That's a tab and a space in the []. 401a7c91847Schristos sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402a7c91847Schristos else 403a7c91847Schristos echo "#dummy" > "$depfile" 404a7c91847Schristos fi 405a7c91847Schristos rm -f "$tmpdepfile" 406a7c91847Schristos ;; 407a7c91847Schristos 408a7c91847Schristos#nosideeffect) 409a7c91847Schristos # This comment above is used by automake to tell side-effect 410a7c91847Schristos # dependency tracking mechanisms from slower ones. 411a7c91847Schristos 412a7c91847Schristosdashmstdout) 413a7c91847Schristos # Important note: in order to support this mode, a compiler *must* 414a7c91847Schristos # always write the preprocessed file to stdout, regardless of -o. 415a7c91847Schristos "$@" || exit $? 416a7c91847Schristos 417a7c91847Schristos # Remove the call to Libtool. 418a7c91847Schristos if test "$libtool" = yes; then 419*75e57c56Schristos while test "X$1" != 'X--mode=compile'; do 420a7c91847Schristos shift 421a7c91847Schristos done 422a7c91847Schristos shift 423a7c91847Schristos fi 424a7c91847Schristos 425a7c91847Schristos # Remove `-o $object'. 426a7c91847Schristos IFS=" " 427a7c91847Schristos for arg 428a7c91847Schristos do 429a7c91847Schristos case $arg in 430a7c91847Schristos -o) 431a7c91847Schristos shift 432a7c91847Schristos ;; 433a7c91847Schristos $object) 434a7c91847Schristos shift 435a7c91847Schristos ;; 436a7c91847Schristos *) 437a7c91847Schristos set fnord "$@" "$arg" 438a7c91847Schristos shift # fnord 439a7c91847Schristos shift # $arg 440a7c91847Schristos ;; 441a7c91847Schristos esac 442a7c91847Schristos done 443a7c91847Schristos 444a7c91847Schristos test -z "$dashmflag" && dashmflag=-M 445a7c91847Schristos # Require at least two characters before searching for `:' 446a7c91847Schristos # in the target name. This is to cope with DOS-style filenames: 447a7c91847Schristos # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448a7c91847Schristos "$@" $dashmflag | 449a7c91847Schristos sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450a7c91847Schristos rm -f "$depfile" 451a7c91847Schristos cat < "$tmpdepfile" > "$depfile" 452a7c91847Schristos tr ' ' ' 453a7c91847Schristos' < "$tmpdepfile" | \ 454a7c91847Schristos## Some versions of the HPUX 10.20 sed can't process this invocation 455a7c91847Schristos## correctly. Breaking it into two sed invocations is a workaround. 456a7c91847Schristos sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457a7c91847Schristos rm -f "$tmpdepfile" 458a7c91847Schristos ;; 459a7c91847Schristos 460a7c91847SchristosdashXmstdout) 461a7c91847Schristos # This case only exists to satisfy depend.m4. It is never actually 462a7c91847Schristos # run, as this mode is specially recognized in the preamble. 463a7c91847Schristos exit 1 464a7c91847Schristos ;; 465a7c91847Schristos 466a7c91847Schristosmakedepend) 467a7c91847Schristos "$@" || exit $? 468a7c91847Schristos # Remove any Libtool call 469a7c91847Schristos if test "$libtool" = yes; then 470*75e57c56Schristos while test "X$1" != 'X--mode=compile'; do 471a7c91847Schristos shift 472a7c91847Schristos done 473a7c91847Schristos shift 474a7c91847Schristos fi 475a7c91847Schristos # X makedepend 476a7c91847Schristos shift 477*75e57c56Schristos cleared=no eat=no 478*75e57c56Schristos for arg 479*75e57c56Schristos do 480a7c91847Schristos case $cleared in 481a7c91847Schristos no) 482a7c91847Schristos set ""; shift 483a7c91847Schristos cleared=yes ;; 484a7c91847Schristos esac 485*75e57c56Schristos if test $eat = yes; then 486*75e57c56Schristos eat=no 487*75e57c56Schristos continue 488*75e57c56Schristos fi 489a7c91847Schristos case "$arg" in 490a7c91847Schristos -D*|-I*) 491a7c91847Schristos set fnord "$@" "$arg"; shift ;; 492a7c91847Schristos # Strip any option that makedepend may not understand. Remove 493a7c91847Schristos # the object too, otherwise makedepend will parse it as a source file. 494*75e57c56Schristos -arch) 495*75e57c56Schristos eat=yes ;; 496a7c91847Schristos -*|$object) 497a7c91847Schristos ;; 498a7c91847Schristos *) 499a7c91847Schristos set fnord "$@" "$arg"; shift ;; 500a7c91847Schristos esac 501a7c91847Schristos done 502*75e57c56Schristos obj_suffix=`echo "$object" | sed 's/^.*\././'` 503a7c91847Schristos touch "$tmpdepfile" 504a7c91847Schristos ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505a7c91847Schristos rm -f "$depfile" 506a7c91847Schristos cat < "$tmpdepfile" > "$depfile" 507a7c91847Schristos sed '1,2d' "$tmpdepfile" | tr ' ' ' 508a7c91847Schristos' | \ 509a7c91847Schristos## Some versions of the HPUX 10.20 sed can't process this invocation 510a7c91847Schristos## correctly. Breaking it into two sed invocations is a workaround. 511a7c91847Schristos sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512a7c91847Schristos rm -f "$tmpdepfile" "$tmpdepfile".bak 513a7c91847Schristos ;; 514a7c91847Schristos 515a7c91847Schristoscpp) 516a7c91847Schristos # Important note: in order to support this mode, a compiler *must* 517a7c91847Schristos # always write the preprocessed file to stdout. 518a7c91847Schristos "$@" || exit $? 519a7c91847Schristos 520a7c91847Schristos # Remove the call to Libtool. 521a7c91847Schristos if test "$libtool" = yes; then 522*75e57c56Schristos while test "X$1" != 'X--mode=compile'; do 523a7c91847Schristos shift 524a7c91847Schristos done 525a7c91847Schristos shift 526a7c91847Schristos fi 527a7c91847Schristos 528a7c91847Schristos # Remove `-o $object'. 529a7c91847Schristos IFS=" " 530a7c91847Schristos for arg 531a7c91847Schristos do 532a7c91847Schristos case $arg in 533a7c91847Schristos -o) 534a7c91847Schristos shift 535a7c91847Schristos ;; 536a7c91847Schristos $object) 537a7c91847Schristos shift 538a7c91847Schristos ;; 539a7c91847Schristos *) 540a7c91847Schristos set fnord "$@" "$arg" 541a7c91847Schristos shift # fnord 542a7c91847Schristos shift # $arg 543a7c91847Schristos ;; 544a7c91847Schristos esac 545a7c91847Schristos done 546a7c91847Schristos 547a7c91847Schristos "$@" -E | 548889c434eSchristos sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549889c434eSchristos -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550a7c91847Schristos sed '$ s: \\$::' > "$tmpdepfile" 551a7c91847Schristos rm -f "$depfile" 552a7c91847Schristos echo "$object : \\" > "$depfile" 553a7c91847Schristos cat < "$tmpdepfile" >> "$depfile" 554a7c91847Schristos sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555a7c91847Schristos rm -f "$tmpdepfile" 556a7c91847Schristos ;; 557a7c91847Schristos 558a7c91847Schristosmsvisualcpp) 559a7c91847Schristos # Important note: in order to support this mode, a compiler *must* 560*75e57c56Schristos # always write the preprocessed file to stdout. 561a7c91847Schristos "$@" || exit $? 562*75e57c56Schristos 563*75e57c56Schristos # Remove the call to Libtool. 564*75e57c56Schristos if test "$libtool" = yes; then 565*75e57c56Schristos while test "X$1" != 'X--mode=compile'; do 566*75e57c56Schristos shift 567*75e57c56Schristos done 568*75e57c56Schristos shift 569*75e57c56Schristos fi 570*75e57c56Schristos 571a7c91847Schristos IFS=" " 572a7c91847Schristos for arg 573a7c91847Schristos do 574a7c91847Schristos case "$arg" in 575*75e57c56Schristos -o) 576*75e57c56Schristos shift 577*75e57c56Schristos ;; 578*75e57c56Schristos $object) 579*75e57c56Schristos shift 580*75e57c56Schristos ;; 581a7c91847Schristos "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582a7c91847Schristos set fnord "$@" 583a7c91847Schristos shift 584a7c91847Schristos shift 585a7c91847Schristos ;; 586a7c91847Schristos *) 587a7c91847Schristos set fnord "$@" "$arg" 588a7c91847Schristos shift 589a7c91847Schristos shift 590a7c91847Schristos ;; 591a7c91847Schristos esac 592a7c91847Schristos done 593*75e57c56Schristos "$@" -E 2>/dev/null | 594*75e57c56Schristos sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595a7c91847Schristos rm -f "$depfile" 596a7c91847Schristos echo "$object : \\" > "$depfile" 597*75e57c56Schristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598a7c91847Schristos echo " " >> "$depfile" 599*75e57c56Schristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600a7c91847Schristos rm -f "$tmpdepfile" 601a7c91847Schristos ;; 602a7c91847Schristos 603*75e57c56Schristosmsvcmsys) 604*75e57c56Schristos # This case exists only to let depend.m4 do its work. It works by 605*75e57c56Schristos # looking at the text of this script. This case will never be run, 606*75e57c56Schristos # since it is checked for above. 607*75e57c56Schristos exit 1 608*75e57c56Schristos ;; 609*75e57c56Schristos 610a7c91847Schristosnone) 611a7c91847Schristos exec "$@" 612a7c91847Schristos ;; 613a7c91847Schristos 614a7c91847Schristos*) 615a7c91847Schristos echo "Unknown depmode $depmode" 1>&2 616a7c91847Schristos exit 1 617a7c91847Schristos ;; 618a7c91847Schristosesac 619a7c91847Schristos 620a7c91847Schristosexit 0 621a7c91847Schristos 622a7c91847Schristos# Local Variables: 623a7c91847Schristos# mode: shell-script 624a7c91847Schristos# sh-indentation: 2 625a7c91847Schristos# eval: (add-hook 'write-file-hooks 'time-stamp) 626a7c91847Schristos# time-stamp-start: "scriptversion=" 627a7c91847Schristos# time-stamp-format: "%:y-%02m-%02d.%02H" 628*75e57c56Schristos# time-stamp-time-zone: "UTC" 629*75e57c56Schristos# time-stamp-end: "; # UTC" 630a7c91847Schristos# End: 631