depcomp revision 8b6d6341
11abf7346Smrg#! /bin/sh 21abf7346Smrg# depcomp - compile a program generating dependencies as side-effects 31abf7346Smrg 48b6d6341Smrgscriptversion=2009-04-28.21; # UTC 51abf7346Smrg 68b6d6341Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 78b6d6341Smrg# Software Foundation, Inc. 81abf7346Smrg 91abf7346Smrg# This program is free software; you can redistribute it and/or modify 101abf7346Smrg# it under the terms of the GNU General Public License as published by 111abf7346Smrg# the Free Software Foundation; either version 2, or (at your option) 121abf7346Smrg# any later version. 131abf7346Smrg 141abf7346Smrg# This program is distributed in the hope that it will be useful, 151abf7346Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161abf7346Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171abf7346Smrg# GNU General Public License for more details. 181abf7346Smrg 191abf7346Smrg# You should have received a copy of the GNU General Public License 208b6d6341Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 211abf7346Smrg 221abf7346Smrg# As a special exception to the GNU General Public License, if you 231abf7346Smrg# distribute this file as part of a program that contains a 241abf7346Smrg# configuration script generated by Autoconf, you may include it under 251abf7346Smrg# the same distribution terms that you use for the rest of that program. 261abf7346Smrg 271abf7346Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 281abf7346Smrg 291abf7346Smrgcase $1 in 301abf7346Smrg '') 311abf7346Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 321abf7346Smrg exit 1; 331abf7346Smrg ;; 341abf7346Smrg -h | --h*) 351abf7346Smrg cat <<\EOF 361abf7346SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 371abf7346Smrg 381abf7346SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 391abf7346Smrgas side-effects. 401abf7346Smrg 411abf7346SmrgEnvironment variables: 421abf7346Smrg depmode Dependency tracking mode. 431abf7346Smrg source Source file read by `PROGRAMS ARGS'. 441abf7346Smrg object Object file output by `PROGRAMS ARGS'. 451abf7346Smrg DEPDIR directory where to store dependencies. 461abf7346Smrg depfile Dependency file to output. 471abf7346Smrg tmpdepfile Temporary file to use when outputing dependencies. 481abf7346Smrg libtool Whether libtool is used (yes/no). 491abf7346Smrg 501abf7346SmrgReport bugs to <bug-automake@gnu.org>. 511abf7346SmrgEOF 521abf7346Smrg exit $? 531abf7346Smrg ;; 541abf7346Smrg -v | --v*) 551abf7346Smrg echo "depcomp $scriptversion" 561abf7346Smrg exit $? 571abf7346Smrg ;; 581abf7346Smrgesac 591abf7346Smrg 601abf7346Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 611abf7346Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 621abf7346Smrg exit 1 631abf7346Smrgfi 641abf7346Smrg 651abf7346Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 661abf7346Smrgdepfile=${depfile-`echo "$object" | 671abf7346Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 681abf7346Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 691abf7346Smrg 701abf7346Smrgrm -f "$tmpdepfile" 711abf7346Smrg 721abf7346Smrg# Some modes work just like other modes, but use different flags. We 731abf7346Smrg# parameterize here, but still list the modes in the big case below, 741abf7346Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 751abf7346Smrg# here, because this file can only contain one case statement. 761abf7346Smrgif test "$depmode" = hp; then 771abf7346Smrg # HP compiler uses -M and no extra arg. 781abf7346Smrg gccflag=-M 791abf7346Smrg depmode=gcc 801abf7346Smrgfi 811abf7346Smrg 821abf7346Smrgif test "$depmode" = dashXmstdout; then 831abf7346Smrg # This is just like dashmstdout with a different argument. 841abf7346Smrg dashmflag=-xM 851abf7346Smrg depmode=dashmstdout 861abf7346Smrgfi 871abf7346Smrg 888b6d6341Smrgcygpath_u="cygpath -u -f -" 898b6d6341Smrgif test "$depmode" = msvcmsys; then 908b6d6341Smrg # This is just like msvisualcpp but w/o cygpath translation. 918b6d6341Smrg # Just convert the backslash-escaped backslashes to single forward 928b6d6341Smrg # slashes to satisfy depend.m4 938b6d6341Smrg cygpath_u="sed s,\\\\\\\\,/,g" 948b6d6341Smrg depmode=msvisualcpp 958b6d6341Smrgfi 968b6d6341Smrg 971abf7346Smrgcase "$depmode" in 981abf7346Smrggcc3) 991abf7346Smrg## gcc 3 implements dependency tracking that does exactly what 1001abf7346Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1011abf7346Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1021abf7346Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1031abf7346Smrg## the command line argument order; so add the flags where they 1041abf7346Smrg## appear in depend2.am. Note that the slowdown incurred here 1051abf7346Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1061abf7346Smrg for arg 1071abf7346Smrg do 1081abf7346Smrg case $arg in 1091abf7346Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1101abf7346Smrg *) set fnord "$@" "$arg" ;; 1111abf7346Smrg esac 1121abf7346Smrg shift # fnord 1131abf7346Smrg shift # $arg 1141abf7346Smrg done 1151abf7346Smrg "$@" 1161abf7346Smrg stat=$? 1171abf7346Smrg if test $stat -eq 0; then : 1181abf7346Smrg else 1191abf7346Smrg rm -f "$tmpdepfile" 1201abf7346Smrg exit $stat 1211abf7346Smrg fi 1221abf7346Smrg mv "$tmpdepfile" "$depfile" 1231abf7346Smrg ;; 1241abf7346Smrg 1251abf7346Smrggcc) 1261abf7346Smrg## There are various ways to get dependency output from gcc. Here's 1271abf7346Smrg## why we pick this rather obscure method: 1281abf7346Smrg## - Don't want to use -MD because we'd like the dependencies to end 1291abf7346Smrg## up in a subdir. Having to rename by hand is ugly. 1301abf7346Smrg## (We might end up doing this anyway to support other compilers.) 1311abf7346Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1321abf7346Smrg## -MM, not -M (despite what the docs say). 1331abf7346Smrg## - Using -M directly means running the compiler twice (even worse 1341abf7346Smrg## than renaming). 1351abf7346Smrg if test -z "$gccflag"; then 1361abf7346Smrg gccflag=-MD, 1371abf7346Smrg fi 1381abf7346Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1391abf7346Smrg stat=$? 1401abf7346Smrg if test $stat -eq 0; then : 1411abf7346Smrg else 1421abf7346Smrg rm -f "$tmpdepfile" 1431abf7346Smrg exit $stat 1441abf7346Smrg fi 1451abf7346Smrg rm -f "$depfile" 1461abf7346Smrg echo "$object : \\" > "$depfile" 1471abf7346Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1481abf7346Smrg## The second -e expression handles DOS-style file names with drive letters. 1491abf7346Smrg sed -e 's/^[^:]*: / /' \ 1501abf7346Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1511abf7346Smrg## This next piece of magic avoids the `deleted header file' problem. 1521abf7346Smrg## The problem is that when a header file which appears in a .P file 1531abf7346Smrg## is deleted, the dependency causes make to die (because there is 1541abf7346Smrg## typically no way to rebuild the header). We avoid this by adding 1551abf7346Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1561abf7346Smrg## this for us directly. 1571abf7346Smrg tr ' ' ' 1581abf7346Smrg' < "$tmpdepfile" | 1591abf7346Smrg## Some versions of gcc put a space before the `:'. On the theory 1601abf7346Smrg## that the space means something, we add a space to the output as 1611abf7346Smrg## well. 1621abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1631abf7346Smrg## correctly. Breaking it into two sed invocations is a workaround. 1641abf7346Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1651abf7346Smrg rm -f "$tmpdepfile" 1661abf7346Smrg ;; 1671abf7346Smrg 1681abf7346Smrghp) 1691abf7346Smrg # This case exists only to let depend.m4 do its work. It works by 1701abf7346Smrg # looking at the text of this script. This case will never be run, 1711abf7346Smrg # since it is checked for above. 1721abf7346Smrg exit 1 1731abf7346Smrg ;; 1741abf7346Smrg 1751abf7346Smrgsgi) 1761abf7346Smrg if test "$libtool" = yes; then 1771abf7346Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1781abf7346Smrg else 1791abf7346Smrg "$@" -MDupdate "$tmpdepfile" 1801abf7346Smrg fi 1811abf7346Smrg stat=$? 1821abf7346Smrg if test $stat -eq 0; then : 1831abf7346Smrg else 1841abf7346Smrg rm -f "$tmpdepfile" 1851abf7346Smrg exit $stat 1861abf7346Smrg fi 1871abf7346Smrg rm -f "$depfile" 1881abf7346Smrg 1891abf7346Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1901abf7346Smrg echo "$object : \\" > "$depfile" 1911abf7346Smrg 1921abf7346Smrg # Clip off the initial element (the dependent). Don't try to be 1931abf7346Smrg # clever and replace this with sed code, as IRIX sed won't handle 1941abf7346Smrg # lines with more than a fixed number of characters (4096 in 1951abf7346Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1961abf7346Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1971abf7346Smrg # dependency line. 1981abf7346Smrg tr ' ' ' 1991abf7346Smrg' < "$tmpdepfile" \ 2001abf7346Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 2011abf7346Smrg tr ' 2028b6d6341Smrg' ' ' >> "$depfile" 2038b6d6341Smrg echo >> "$depfile" 2041abf7346Smrg 2051abf7346Smrg # The second pass generates a dummy entry for each header file. 2061abf7346Smrg tr ' ' ' 2071abf7346Smrg' < "$tmpdepfile" \ 2081abf7346Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2098b6d6341Smrg >> "$depfile" 2101abf7346Smrg else 2111abf7346Smrg # The sourcefile does not contain any dependencies, so just 2121abf7346Smrg # store a dummy comment line, to avoid errors with the Makefile 2131abf7346Smrg # "include basename.Plo" scheme. 2141abf7346Smrg echo "#dummy" > "$depfile" 2151abf7346Smrg fi 2161abf7346Smrg rm -f "$tmpdepfile" 2171abf7346Smrg ;; 2181abf7346Smrg 2191abf7346Smrgaix) 2201abf7346Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2211abf7346Smrg # in a .u file. In older versions, this file always lives in the 2221abf7346Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2231abf7346Smrg # start of each line; $object doesn't have directory information. 2241abf7346Smrg # Version 6 uses the directory in both cases. 2258b6d6341Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2268b6d6341Smrg test "x$dir" = "x$object" && dir= 2278b6d6341Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2281abf7346Smrg if test "$libtool" = yes; then 2298b6d6341Smrg tmpdepfile1=$dir$base.u 2308b6d6341Smrg tmpdepfile2=$base.u 2318b6d6341Smrg tmpdepfile3=$dir.libs/$base.u 2321abf7346Smrg "$@" -Wc,-M 2331abf7346Smrg else 2348b6d6341Smrg tmpdepfile1=$dir$base.u 2358b6d6341Smrg tmpdepfile2=$dir$base.u 2368b6d6341Smrg tmpdepfile3=$dir$base.u 2371abf7346Smrg "$@" -M 2381abf7346Smrg fi 2391abf7346Smrg stat=$? 2401abf7346Smrg 2411abf7346Smrg if test $stat -eq 0; then : 2421abf7346Smrg else 2438b6d6341Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2441abf7346Smrg exit $stat 2451abf7346Smrg fi 2461abf7346Smrg 2478b6d6341Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2488b6d6341Smrg do 2498b6d6341Smrg test -f "$tmpdepfile" && break 2508b6d6341Smrg done 2511abf7346Smrg if test -f "$tmpdepfile"; then 2521abf7346Smrg # Each line is of the form `foo.o: dependent.h'. 2531abf7346Smrg # Do two passes, one to just change these to 2541abf7346Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2558b6d6341Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2568b6d6341Smrg # That's a tab and a space in the []. 2578b6d6341Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2581abf7346Smrg else 2591abf7346Smrg # The sourcefile does not contain any dependencies, so just 2601abf7346Smrg # store a dummy comment line, to avoid errors with the Makefile 2611abf7346Smrg # "include basename.Plo" scheme. 2621abf7346Smrg echo "#dummy" > "$depfile" 2631abf7346Smrg fi 2641abf7346Smrg rm -f "$tmpdepfile" 2651abf7346Smrg ;; 2661abf7346Smrg 2671abf7346Smrgicc) 2681abf7346Smrg # Intel's C compiler understands `-MD -MF file'. However on 2691abf7346Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2701abf7346Smrg # ICC 7.0 will fill foo.d with something like 2711abf7346Smrg # foo.o: sub/foo.c 2721abf7346Smrg # foo.o: sub/foo.h 2731abf7346Smrg # which is wrong. We want: 2741abf7346Smrg # sub/foo.o: sub/foo.c 2751abf7346Smrg # sub/foo.o: sub/foo.h 2761abf7346Smrg # sub/foo.c: 2771abf7346Smrg # sub/foo.h: 2781abf7346Smrg # ICC 7.1 will output 2791abf7346Smrg # foo.o: sub/foo.c sub/foo.h 2801abf7346Smrg # and will wrap long lines using \ : 2811abf7346Smrg # foo.o: sub/foo.c ... \ 2821abf7346Smrg # sub/foo.h ... \ 2831abf7346Smrg # ... 2841abf7346Smrg 2851abf7346Smrg "$@" -MD -MF "$tmpdepfile" 2861abf7346Smrg stat=$? 2871abf7346Smrg if test $stat -eq 0; then : 2881abf7346Smrg else 2891abf7346Smrg rm -f "$tmpdepfile" 2901abf7346Smrg exit $stat 2911abf7346Smrg fi 2921abf7346Smrg rm -f "$depfile" 2931abf7346Smrg # Each line is of the form `foo.o: dependent.h', 2941abf7346Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2951abf7346Smrg # Do two passes, one to just change these to 2961abf7346Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2971abf7346Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2981abf7346Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2991abf7346Smrg # correctly. Breaking it into two sed invocations is a workaround. 3001abf7346Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 3011abf7346Smrg sed -e 's/$/ :/' >> "$depfile" 3021abf7346Smrg rm -f "$tmpdepfile" 3031abf7346Smrg ;; 3041abf7346Smrg 3051abf7346Smrghp2) 3061abf7346Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3071abf7346Smrg # compilers, which have integrated preprocessors. The correct option 3081abf7346Smrg # to use with these is +Maked; it writes dependencies to a file named 3091abf7346Smrg # 'foo.d', which lands next to the object file, wherever that 3101abf7346Smrg # happens to be. 3111abf7346Smrg # Much of this is similar to the tru64 case; see comments there. 3121abf7346Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3131abf7346Smrg test "x$dir" = "x$object" && dir= 3141abf7346Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3151abf7346Smrg if test "$libtool" = yes; then 3161abf7346Smrg tmpdepfile1=$dir$base.d 3171abf7346Smrg tmpdepfile2=$dir.libs/$base.d 3181abf7346Smrg "$@" -Wc,+Maked 3191abf7346Smrg else 3201abf7346Smrg tmpdepfile1=$dir$base.d 3211abf7346Smrg tmpdepfile2=$dir$base.d 3221abf7346Smrg "$@" +Maked 3231abf7346Smrg fi 3241abf7346Smrg stat=$? 3251abf7346Smrg if test $stat -eq 0; then : 3261abf7346Smrg else 3271abf7346Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3281abf7346Smrg exit $stat 3291abf7346Smrg fi 3301abf7346Smrg 3311abf7346Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3321abf7346Smrg do 3331abf7346Smrg test -f "$tmpdepfile" && break 3341abf7346Smrg done 3351abf7346Smrg if test -f "$tmpdepfile"; then 3361abf7346Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3371abf7346Smrg # Add `dependent.h:' lines. 3388b6d6341Smrg sed -ne '2,${ 3398b6d6341Smrg s/^ *// 3408b6d6341Smrg s/ \\*$// 3418b6d6341Smrg s/$/:/ 3428b6d6341Smrg p 3438b6d6341Smrg }' "$tmpdepfile" >> "$depfile" 3441abf7346Smrg else 3451abf7346Smrg echo "#dummy" > "$depfile" 3461abf7346Smrg fi 3471abf7346Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3481abf7346Smrg ;; 3491abf7346Smrg 3501abf7346Smrgtru64) 3511abf7346Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3521abf7346Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3531abf7346Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3541abf7346Smrg # dependencies in `foo.d' instead, so we check for that too. 3551abf7346Smrg # Subdirectories are respected. 3561abf7346Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3571abf7346Smrg test "x$dir" = "x$object" && dir= 3581abf7346Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3591abf7346Smrg 3601abf7346Smrg if test "$libtool" = yes; then 3611abf7346Smrg # With Tru64 cc, shared objects can also be used to make a 3621abf7346Smrg # static library. This mechanism is used in libtool 1.4 series to 3631abf7346Smrg # handle both shared and static libraries in a single compilation. 3641abf7346Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3651abf7346Smrg # 3661abf7346Smrg # With libtool 1.5 this exception was removed, and libtool now 3671abf7346Smrg # generates 2 separate objects for the 2 libraries. These two 3681abf7346Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3691abf7346Smrg # in $dir$base.o.d. We have to check for both files, because 3701abf7346Smrg # one of the two compilations can be disabled. We should prefer 3711abf7346Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3721abf7346Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3731abf7346Smrg # the former would cause a distcleancheck panic. 3741abf7346Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3751abf7346Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3761abf7346Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3771abf7346Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3781abf7346Smrg "$@" -Wc,-MD 3791abf7346Smrg else 3801abf7346Smrg tmpdepfile1=$dir$base.o.d 3811abf7346Smrg tmpdepfile2=$dir$base.d 3821abf7346Smrg tmpdepfile3=$dir$base.d 3831abf7346Smrg tmpdepfile4=$dir$base.d 3841abf7346Smrg "$@" -MD 3851abf7346Smrg fi 3861abf7346Smrg 3871abf7346Smrg stat=$? 3881abf7346Smrg if test $stat -eq 0; then : 3891abf7346Smrg else 3901abf7346Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3911abf7346Smrg exit $stat 3921abf7346Smrg fi 3931abf7346Smrg 3941abf7346Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3951abf7346Smrg do 3961abf7346Smrg test -f "$tmpdepfile" && break 3971abf7346Smrg done 3981abf7346Smrg if test -f "$tmpdepfile"; then 3991abf7346Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 4001abf7346Smrg # That's a tab and a space in the []. 4011abf7346Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 4021abf7346Smrg else 4031abf7346Smrg echo "#dummy" > "$depfile" 4041abf7346Smrg fi 4051abf7346Smrg rm -f "$tmpdepfile" 4061abf7346Smrg ;; 4071abf7346Smrg 4081abf7346Smrg#nosideeffect) 4091abf7346Smrg # This comment above is used by automake to tell side-effect 4101abf7346Smrg # dependency tracking mechanisms from slower ones. 4111abf7346Smrg 4121abf7346Smrgdashmstdout) 4131abf7346Smrg # Important note: in order to support this mode, a compiler *must* 4141abf7346Smrg # always write the preprocessed file to stdout, regardless of -o. 4151abf7346Smrg "$@" || exit $? 4161abf7346Smrg 4171abf7346Smrg # Remove the call to Libtool. 4181abf7346Smrg if test "$libtool" = yes; then 4198b6d6341Smrg while test "X$1" != 'X--mode=compile'; do 4201abf7346Smrg shift 4211abf7346Smrg done 4221abf7346Smrg shift 4231abf7346Smrg fi 4241abf7346Smrg 4251abf7346Smrg # Remove `-o $object'. 4261abf7346Smrg IFS=" " 4271abf7346Smrg for arg 4281abf7346Smrg do 4291abf7346Smrg case $arg in 4301abf7346Smrg -o) 4311abf7346Smrg shift 4321abf7346Smrg ;; 4331abf7346Smrg $object) 4341abf7346Smrg shift 4351abf7346Smrg ;; 4361abf7346Smrg *) 4371abf7346Smrg set fnord "$@" "$arg" 4381abf7346Smrg shift # fnord 4391abf7346Smrg shift # $arg 4401abf7346Smrg ;; 4411abf7346Smrg esac 4421abf7346Smrg done 4431abf7346Smrg 4441abf7346Smrg test -z "$dashmflag" && dashmflag=-M 4451abf7346Smrg # Require at least two characters before searching for `:' 4461abf7346Smrg # in the target name. This is to cope with DOS-style filenames: 4471abf7346Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4481abf7346Smrg "$@" $dashmflag | 4491abf7346Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4501abf7346Smrg rm -f "$depfile" 4511abf7346Smrg cat < "$tmpdepfile" > "$depfile" 4521abf7346Smrg tr ' ' ' 4531abf7346Smrg' < "$tmpdepfile" | \ 4541abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4551abf7346Smrg## correctly. Breaking it into two sed invocations is a workaround. 4561abf7346Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4571abf7346Smrg rm -f "$tmpdepfile" 4581abf7346Smrg ;; 4591abf7346Smrg 4601abf7346SmrgdashXmstdout) 4611abf7346Smrg # This case only exists to satisfy depend.m4. It is never actually 4621abf7346Smrg # run, as this mode is specially recognized in the preamble. 4631abf7346Smrg exit 1 4641abf7346Smrg ;; 4651abf7346Smrg 4661abf7346Smrgmakedepend) 4671abf7346Smrg "$@" || exit $? 4681abf7346Smrg # Remove any Libtool call 4691abf7346Smrg if test "$libtool" = yes; then 4708b6d6341Smrg while test "X$1" != 'X--mode=compile'; do 4711abf7346Smrg shift 4721abf7346Smrg done 4731abf7346Smrg shift 4741abf7346Smrg fi 4751abf7346Smrg # X makedepend 4761abf7346Smrg shift 4778b6d6341Smrg cleared=no eat=no 4788b6d6341Smrg for arg 4798b6d6341Smrg do 4801abf7346Smrg case $cleared in 4811abf7346Smrg no) 4821abf7346Smrg set ""; shift 4831abf7346Smrg cleared=yes ;; 4841abf7346Smrg esac 4858b6d6341Smrg if test $eat = yes; then 4868b6d6341Smrg eat=no 4878b6d6341Smrg continue 4888b6d6341Smrg fi 4891abf7346Smrg case "$arg" in 4901abf7346Smrg -D*|-I*) 4911abf7346Smrg set fnord "$@" "$arg"; shift ;; 4921abf7346Smrg # Strip any option that makedepend may not understand. Remove 4931abf7346Smrg # the object too, otherwise makedepend will parse it as a source file. 4948b6d6341Smrg -arch) 4958b6d6341Smrg eat=yes ;; 4961abf7346Smrg -*|$object) 4971abf7346Smrg ;; 4981abf7346Smrg *) 4991abf7346Smrg set fnord "$@" "$arg"; shift ;; 5001abf7346Smrg esac 5011abf7346Smrg done 5028b6d6341Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 5031abf7346Smrg touch "$tmpdepfile" 5041abf7346Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 5051abf7346Smrg rm -f "$depfile" 5061abf7346Smrg cat < "$tmpdepfile" > "$depfile" 5071abf7346Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 5081abf7346Smrg' | \ 5091abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 5101abf7346Smrg## correctly. Breaking it into two sed invocations is a workaround. 5111abf7346Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 5121abf7346Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 5131abf7346Smrg ;; 5141abf7346Smrg 5151abf7346Smrgcpp) 5161abf7346Smrg # Important note: in order to support this mode, a compiler *must* 5171abf7346Smrg # always write the preprocessed file to stdout. 5181abf7346Smrg "$@" || exit $? 5191abf7346Smrg 5201abf7346Smrg # Remove the call to Libtool. 5211abf7346Smrg if test "$libtool" = yes; then 5228b6d6341Smrg while test "X$1" != 'X--mode=compile'; do 5231abf7346Smrg shift 5241abf7346Smrg done 5251abf7346Smrg shift 5261abf7346Smrg fi 5271abf7346Smrg 5281abf7346Smrg # Remove `-o $object'. 5291abf7346Smrg IFS=" " 5301abf7346Smrg for arg 5311abf7346Smrg do 5321abf7346Smrg case $arg in 5331abf7346Smrg -o) 5341abf7346Smrg shift 5351abf7346Smrg ;; 5361abf7346Smrg $object) 5371abf7346Smrg shift 5381abf7346Smrg ;; 5391abf7346Smrg *) 5401abf7346Smrg set fnord "$@" "$arg" 5411abf7346Smrg shift # fnord 5421abf7346Smrg shift # $arg 5431abf7346Smrg ;; 5441abf7346Smrg esac 5451abf7346Smrg done 5461abf7346Smrg 5471abf7346Smrg "$@" -E | 5481abf7346Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5491abf7346Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5501abf7346Smrg sed '$ s: \\$::' > "$tmpdepfile" 5511abf7346Smrg rm -f "$depfile" 5521abf7346Smrg echo "$object : \\" > "$depfile" 5531abf7346Smrg cat < "$tmpdepfile" >> "$depfile" 5541abf7346Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5551abf7346Smrg rm -f "$tmpdepfile" 5561abf7346Smrg ;; 5571abf7346Smrg 5581abf7346Smrgmsvisualcpp) 5591abf7346Smrg # Important note: in order to support this mode, a compiler *must* 5608b6d6341Smrg # always write the preprocessed file to stdout. 5611abf7346Smrg "$@" || exit $? 5628b6d6341Smrg 5638b6d6341Smrg # Remove the call to Libtool. 5648b6d6341Smrg if test "$libtool" = yes; then 5658b6d6341Smrg while test "X$1" != 'X--mode=compile'; do 5668b6d6341Smrg shift 5678b6d6341Smrg done 5688b6d6341Smrg shift 5698b6d6341Smrg fi 5708b6d6341Smrg 5711abf7346Smrg IFS=" " 5721abf7346Smrg for arg 5731abf7346Smrg do 5741abf7346Smrg case "$arg" in 5758b6d6341Smrg -o) 5768b6d6341Smrg shift 5778b6d6341Smrg ;; 5788b6d6341Smrg $object) 5798b6d6341Smrg shift 5808b6d6341Smrg ;; 5811abf7346Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5821abf7346Smrg set fnord "$@" 5831abf7346Smrg shift 5841abf7346Smrg shift 5851abf7346Smrg ;; 5861abf7346Smrg *) 5871abf7346Smrg set fnord "$@" "$arg" 5881abf7346Smrg shift 5891abf7346Smrg shift 5901abf7346Smrg ;; 5911abf7346Smrg esac 5921abf7346Smrg done 5938b6d6341Smrg "$@" -E 2>/dev/null | 5948b6d6341Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 5951abf7346Smrg rm -f "$depfile" 5961abf7346Smrg echo "$object : \\" > "$depfile" 5978b6d6341Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5981abf7346Smrg echo " " >> "$depfile" 5998b6d6341Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 6001abf7346Smrg rm -f "$tmpdepfile" 6011abf7346Smrg ;; 6021abf7346Smrg 6038b6d6341Smrgmsvcmsys) 6048b6d6341Smrg # This case exists only to let depend.m4 do its work. It works by 6058b6d6341Smrg # looking at the text of this script. This case will never be run, 6068b6d6341Smrg # since it is checked for above. 6078b6d6341Smrg exit 1 6088b6d6341Smrg ;; 6098b6d6341Smrg 6101abf7346Smrgnone) 6111abf7346Smrg exec "$@" 6121abf7346Smrg ;; 6131abf7346Smrg 6141abf7346Smrg*) 6151abf7346Smrg echo "Unknown depmode $depmode" 1>&2 6161abf7346Smrg exit 1 6171abf7346Smrg ;; 6181abf7346Smrgesac 6191abf7346Smrg 6201abf7346Smrgexit 0 6211abf7346Smrg 6221abf7346Smrg# Local Variables: 6231abf7346Smrg# mode: shell-script 6241abf7346Smrg# sh-indentation: 2 6251abf7346Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6261abf7346Smrg# time-stamp-start: "scriptversion=" 6271abf7346Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6288b6d6341Smrg# time-stamp-time-zone: "UTC" 6298b6d6341Smrg# time-stamp-end: "; # UTC" 6301abf7346Smrg# End: 631