depcomp revision 7a84e134
17a84e134Smrg#! /bin/sh 27a84e134Smrg# depcomp - compile a program generating dependencies as side-effects 37a84e134Smrg 47a84e134Smrgscriptversion=2006-10-15.18 57a84e134Smrg 67a84e134Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software 77a84e134Smrg# Foundation, Inc. 87a84e134Smrg 97a84e134Smrg# This program is free software; you can redistribute it and/or modify 107a84e134Smrg# it under the terms of the GNU General Public License as published by 117a84e134Smrg# the Free Software Foundation; either version 2, or (at your option) 127a84e134Smrg# any later version. 137a84e134Smrg 147a84e134Smrg# This program is distributed in the hope that it will be useful, 157a84e134Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 167a84e134Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 177a84e134Smrg# GNU General Public License for more details. 187a84e134Smrg 197a84e134Smrg# You should have received a copy of the GNU General Public License 207a84e134Smrg# along with this program; if not, write to the Free Software 217a84e134Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 227a84e134Smrg# 02110-1301, USA. 237a84e134Smrg 247a84e134Smrg# As a special exception to the GNU General Public License, if you 257a84e134Smrg# distribute this file as part of a program that contains a 267a84e134Smrg# configuration script generated by Autoconf, you may include it under 277a84e134Smrg# the same distribution terms that you use for the rest of that program. 287a84e134Smrg 297a84e134Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 307a84e134Smrg 317a84e134Smrgcase $1 in 327a84e134Smrg '') 337a84e134Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 347a84e134Smrg exit 1; 357a84e134Smrg ;; 367a84e134Smrg -h | --h*) 377a84e134Smrg cat <<\EOF 387a84e134SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 397a84e134Smrg 407a84e134SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 417a84e134Smrgas side-effects. 427a84e134Smrg 437a84e134SmrgEnvironment variables: 447a84e134Smrg depmode Dependency tracking mode. 457a84e134Smrg source Source file read by `PROGRAMS ARGS'. 467a84e134Smrg object Object file output by `PROGRAMS ARGS'. 477a84e134Smrg DEPDIR directory where to store dependencies. 487a84e134Smrg depfile Dependency file to output. 497a84e134Smrg tmpdepfile Temporary file to use when outputing dependencies. 507a84e134Smrg libtool Whether libtool is used (yes/no). 517a84e134Smrg 527a84e134SmrgReport bugs to <bug-automake@gnu.org>. 537a84e134SmrgEOF 547a84e134Smrg exit $? 557a84e134Smrg ;; 567a84e134Smrg -v | --v*) 577a84e134Smrg echo "depcomp $scriptversion" 587a84e134Smrg exit $? 597a84e134Smrg ;; 607a84e134Smrgesac 617a84e134Smrg 627a84e134Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 637a84e134Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 647a84e134Smrg exit 1 657a84e134Smrgfi 667a84e134Smrg 677a84e134Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 687a84e134Smrgdepfile=${depfile-`echo "$object" | 697a84e134Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 707a84e134Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 717a84e134Smrg 727a84e134Smrgrm -f "$tmpdepfile" 737a84e134Smrg 747a84e134Smrg# Some modes work just like other modes, but use different flags. We 757a84e134Smrg# parameterize here, but still list the modes in the big case below, 767a84e134Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 777a84e134Smrg# here, because this file can only contain one case statement. 787a84e134Smrgif test "$depmode" = hp; then 797a84e134Smrg # HP compiler uses -M and no extra arg. 807a84e134Smrg gccflag=-M 817a84e134Smrg depmode=gcc 827a84e134Smrgfi 837a84e134Smrg 847a84e134Smrgif test "$depmode" = dashXmstdout; then 857a84e134Smrg # This is just like dashmstdout with a different argument. 867a84e134Smrg dashmflag=-xM 877a84e134Smrg depmode=dashmstdout 887a84e134Smrgfi 897a84e134Smrg 907a84e134Smrgcase "$depmode" in 917a84e134Smrggcc3) 927a84e134Smrg## gcc 3 implements dependency tracking that does exactly what 937a84e134Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 947a84e134Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 957a84e134Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 967a84e134Smrg## the command line argument order; so add the flags where they 977a84e134Smrg## appear in depend2.am. Note that the slowdown incurred here 987a84e134Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 997a84e134Smrg for arg 1007a84e134Smrg do 1017a84e134Smrg case $arg in 1027a84e134Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1037a84e134Smrg *) set fnord "$@" "$arg" ;; 1047a84e134Smrg esac 1057a84e134Smrg shift # fnord 1067a84e134Smrg shift # $arg 1077a84e134Smrg done 1087a84e134Smrg "$@" 1097a84e134Smrg stat=$? 1107a84e134Smrg if test $stat -eq 0; then : 1117a84e134Smrg else 1127a84e134Smrg rm -f "$tmpdepfile" 1137a84e134Smrg exit $stat 1147a84e134Smrg fi 1157a84e134Smrg mv "$tmpdepfile" "$depfile" 1167a84e134Smrg ;; 1177a84e134Smrg 1187a84e134Smrggcc) 1197a84e134Smrg## There are various ways to get dependency output from gcc. Here's 1207a84e134Smrg## why we pick this rather obscure method: 1217a84e134Smrg## - Don't want to use -MD because we'd like the dependencies to end 1227a84e134Smrg## up in a subdir. Having to rename by hand is ugly. 1237a84e134Smrg## (We might end up doing this anyway to support other compilers.) 1247a84e134Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1257a84e134Smrg## -MM, not -M (despite what the docs say). 1267a84e134Smrg## - Using -M directly means running the compiler twice (even worse 1277a84e134Smrg## than renaming). 1287a84e134Smrg if test -z "$gccflag"; then 1297a84e134Smrg gccflag=-MD, 1307a84e134Smrg fi 1317a84e134Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1327a84e134Smrg stat=$? 1337a84e134Smrg if test $stat -eq 0; then : 1347a84e134Smrg else 1357a84e134Smrg rm -f "$tmpdepfile" 1367a84e134Smrg exit $stat 1377a84e134Smrg fi 1387a84e134Smrg rm -f "$depfile" 1397a84e134Smrg echo "$object : \\" > "$depfile" 1407a84e134Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1417a84e134Smrg## The second -e expression handles DOS-style file names with drive letters. 1427a84e134Smrg sed -e 's/^[^:]*: / /' \ 1437a84e134Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1447a84e134Smrg## This next piece of magic avoids the `deleted header file' problem. 1457a84e134Smrg## The problem is that when a header file which appears in a .P file 1467a84e134Smrg## is deleted, the dependency causes make to die (because there is 1477a84e134Smrg## typically no way to rebuild the header). We avoid this by adding 1487a84e134Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1497a84e134Smrg## this for us directly. 1507a84e134Smrg tr ' ' ' 1517a84e134Smrg' < "$tmpdepfile" | 1527a84e134Smrg## Some versions of gcc put a space before the `:'. On the theory 1537a84e134Smrg## that the space means something, we add a space to the output as 1547a84e134Smrg## well. 1557a84e134Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1567a84e134Smrg## correctly. Breaking it into two sed invocations is a workaround. 1577a84e134Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1587a84e134Smrg rm -f "$tmpdepfile" 1597a84e134Smrg ;; 1607a84e134Smrg 1617a84e134Smrghp) 1627a84e134Smrg # This case exists only to let depend.m4 do its work. It works by 1637a84e134Smrg # looking at the text of this script. This case will never be run, 1647a84e134Smrg # since it is checked for above. 1657a84e134Smrg exit 1 1667a84e134Smrg ;; 1677a84e134Smrg 1687a84e134Smrgsgi) 1697a84e134Smrg if test "$libtool" = yes; then 1707a84e134Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1717a84e134Smrg else 1727a84e134Smrg "$@" -MDupdate "$tmpdepfile" 1737a84e134Smrg fi 1747a84e134Smrg stat=$? 1757a84e134Smrg if test $stat -eq 0; then : 1767a84e134Smrg else 1777a84e134Smrg rm -f "$tmpdepfile" 1787a84e134Smrg exit $stat 1797a84e134Smrg fi 1807a84e134Smrg rm -f "$depfile" 1817a84e134Smrg 1827a84e134Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1837a84e134Smrg echo "$object : \\" > "$depfile" 1847a84e134Smrg 1857a84e134Smrg # Clip off the initial element (the dependent). Don't try to be 1867a84e134Smrg # clever and replace this with sed code, as IRIX sed won't handle 1877a84e134Smrg # lines with more than a fixed number of characters (4096 in 1887a84e134Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1897a84e134Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1907a84e134Smrg # dependency line. 1917a84e134Smrg tr ' ' ' 1927a84e134Smrg' < "$tmpdepfile" \ 1937a84e134Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1947a84e134Smrg tr ' 1957a84e134Smrg' ' ' >> $depfile 1967a84e134Smrg echo >> $depfile 1977a84e134Smrg 1987a84e134Smrg # The second pass generates a dummy entry for each header file. 1997a84e134Smrg tr ' ' ' 2007a84e134Smrg' < "$tmpdepfile" \ 2017a84e134Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2027a84e134Smrg >> $depfile 2037a84e134Smrg else 2047a84e134Smrg # The sourcefile does not contain any dependencies, so just 2057a84e134Smrg # store a dummy comment line, to avoid errors with the Makefile 2067a84e134Smrg # "include basename.Plo" scheme. 2077a84e134Smrg echo "#dummy" > "$depfile" 2087a84e134Smrg fi 2097a84e134Smrg rm -f "$tmpdepfile" 2107a84e134Smrg ;; 2117a84e134Smrg 2127a84e134Smrgaix) 2137a84e134Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2147a84e134Smrg # in a .u file. In older versions, this file always lives in the 2157a84e134Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2167a84e134Smrg # start of each line; $object doesn't have directory information. 2177a84e134Smrg # Version 6 uses the directory in both cases. 2187a84e134Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 2197a84e134Smrg tmpdepfile="$stripped.u" 2207a84e134Smrg if test "$libtool" = yes; then 2217a84e134Smrg "$@" -Wc,-M 2227a84e134Smrg else 2237a84e134Smrg "$@" -M 2247a84e134Smrg fi 2257a84e134Smrg stat=$? 2267a84e134Smrg 2277a84e134Smrg if test -f "$tmpdepfile"; then : 2287a84e134Smrg else 2297a84e134Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 2307a84e134Smrg tmpdepfile="$stripped.u" 2317a84e134Smrg fi 2327a84e134Smrg 2337a84e134Smrg if test $stat -eq 0; then : 2347a84e134Smrg else 2357a84e134Smrg rm -f "$tmpdepfile" 2367a84e134Smrg exit $stat 2377a84e134Smrg fi 2387a84e134Smrg 2397a84e134Smrg if test -f "$tmpdepfile"; then 2407a84e134Smrg outname="$stripped.o" 2417a84e134Smrg # Each line is of the form `foo.o: dependent.h'. 2427a84e134Smrg # Do two passes, one to just change these to 2437a84e134Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2447a84e134Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 2457a84e134Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 2467a84e134Smrg else 2477a84e134Smrg # The sourcefile does not contain any dependencies, so just 2487a84e134Smrg # store a dummy comment line, to avoid errors with the Makefile 2497a84e134Smrg # "include basename.Plo" scheme. 2507a84e134Smrg echo "#dummy" > "$depfile" 2517a84e134Smrg fi 2527a84e134Smrg rm -f "$tmpdepfile" 2537a84e134Smrg ;; 2547a84e134Smrg 2557a84e134Smrgicc) 2567a84e134Smrg # Intel's C compiler understands `-MD -MF file'. However on 2577a84e134Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2587a84e134Smrg # ICC 7.0 will fill foo.d with something like 2597a84e134Smrg # foo.o: sub/foo.c 2607a84e134Smrg # foo.o: sub/foo.h 2617a84e134Smrg # which is wrong. We want: 2627a84e134Smrg # sub/foo.o: sub/foo.c 2637a84e134Smrg # sub/foo.o: sub/foo.h 2647a84e134Smrg # sub/foo.c: 2657a84e134Smrg # sub/foo.h: 2667a84e134Smrg # ICC 7.1 will output 2677a84e134Smrg # foo.o: sub/foo.c sub/foo.h 2687a84e134Smrg # and will wrap long lines using \ : 2697a84e134Smrg # foo.o: sub/foo.c ... \ 2707a84e134Smrg # sub/foo.h ... \ 2717a84e134Smrg # ... 2727a84e134Smrg 2737a84e134Smrg "$@" -MD -MF "$tmpdepfile" 2747a84e134Smrg stat=$? 2757a84e134Smrg if test $stat -eq 0; then : 2767a84e134Smrg else 2777a84e134Smrg rm -f "$tmpdepfile" 2787a84e134Smrg exit $stat 2797a84e134Smrg fi 2807a84e134Smrg rm -f "$depfile" 2817a84e134Smrg # Each line is of the form `foo.o: dependent.h', 2827a84e134Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2837a84e134Smrg # Do two passes, one to just change these to 2847a84e134Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2857a84e134Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2867a84e134Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2877a84e134Smrg # correctly. Breaking it into two sed invocations is a workaround. 2887a84e134Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2897a84e134Smrg sed -e 's/$/ :/' >> "$depfile" 2907a84e134Smrg rm -f "$tmpdepfile" 2917a84e134Smrg ;; 2927a84e134Smrg 2937a84e134Smrghp2) 2947a84e134Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 2957a84e134Smrg # compilers, which have integrated preprocessors. The correct option 2967a84e134Smrg # to use with these is +Maked; it writes dependencies to a file named 2977a84e134Smrg # 'foo.d', which lands next to the object file, wherever that 2987a84e134Smrg # happens to be. 2997a84e134Smrg # Much of this is similar to the tru64 case; see comments there. 3007a84e134Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3017a84e134Smrg test "x$dir" = "x$object" && dir= 3027a84e134Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3037a84e134Smrg if test "$libtool" = yes; then 3047a84e134Smrg tmpdepfile1=$dir$base.d 3057a84e134Smrg tmpdepfile2=$dir.libs/$base.d 3067a84e134Smrg "$@" -Wc,+Maked 3077a84e134Smrg else 3087a84e134Smrg tmpdepfile1=$dir$base.d 3097a84e134Smrg tmpdepfile2=$dir$base.d 3107a84e134Smrg "$@" +Maked 3117a84e134Smrg fi 3127a84e134Smrg stat=$? 3137a84e134Smrg if test $stat -eq 0; then : 3147a84e134Smrg else 3157a84e134Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3167a84e134Smrg exit $stat 3177a84e134Smrg fi 3187a84e134Smrg 3197a84e134Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3207a84e134Smrg do 3217a84e134Smrg test -f "$tmpdepfile" && break 3227a84e134Smrg done 3237a84e134Smrg if test -f "$tmpdepfile"; then 3247a84e134Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3257a84e134Smrg # Add `dependent.h:' lines. 3267a84e134Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3277a84e134Smrg else 3287a84e134Smrg echo "#dummy" > "$depfile" 3297a84e134Smrg fi 3307a84e134Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3317a84e134Smrg ;; 3327a84e134Smrg 3337a84e134Smrgtru64) 3347a84e134Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3357a84e134Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3367a84e134Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3377a84e134Smrg # dependencies in `foo.d' instead, so we check for that too. 3387a84e134Smrg # Subdirectories are respected. 3397a84e134Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3407a84e134Smrg test "x$dir" = "x$object" && dir= 3417a84e134Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3427a84e134Smrg 3437a84e134Smrg if test "$libtool" = yes; then 3447a84e134Smrg # With Tru64 cc, shared objects can also be used to make a 3457a84e134Smrg # static library. This mechanism is used in libtool 1.4 series to 3467a84e134Smrg # handle both shared and static libraries in a single compilation. 3477a84e134Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3487a84e134Smrg # 3497a84e134Smrg # With libtool 1.5 this exception was removed, and libtool now 3507a84e134Smrg # generates 2 separate objects for the 2 libraries. These two 3517a84e134Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3527a84e134Smrg # in $dir$base.o.d. We have to check for both files, because 3537a84e134Smrg # one of the two compilations can be disabled. We should prefer 3547a84e134Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3557a84e134Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3567a84e134Smrg # the former would cause a distcleancheck panic. 3577a84e134Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3587a84e134Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3597a84e134Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3607a84e134Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3617a84e134Smrg "$@" -Wc,-MD 3627a84e134Smrg else 3637a84e134Smrg tmpdepfile1=$dir$base.o.d 3647a84e134Smrg tmpdepfile2=$dir$base.d 3657a84e134Smrg tmpdepfile3=$dir$base.d 3667a84e134Smrg tmpdepfile4=$dir$base.d 3677a84e134Smrg "$@" -MD 3687a84e134Smrg fi 3697a84e134Smrg 3707a84e134Smrg stat=$? 3717a84e134Smrg if test $stat -eq 0; then : 3727a84e134Smrg else 3737a84e134Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3747a84e134Smrg exit $stat 3757a84e134Smrg fi 3767a84e134Smrg 3777a84e134Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3787a84e134Smrg do 3797a84e134Smrg test -f "$tmpdepfile" && break 3807a84e134Smrg done 3817a84e134Smrg if test -f "$tmpdepfile"; then 3827a84e134Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3837a84e134Smrg # That's a tab and a space in the []. 3847a84e134Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3857a84e134Smrg else 3867a84e134Smrg echo "#dummy" > "$depfile" 3877a84e134Smrg fi 3887a84e134Smrg rm -f "$tmpdepfile" 3897a84e134Smrg ;; 3907a84e134Smrg 3917a84e134Smrg#nosideeffect) 3927a84e134Smrg # This comment above is used by automake to tell side-effect 3937a84e134Smrg # dependency tracking mechanisms from slower ones. 3947a84e134Smrg 3957a84e134Smrgdashmstdout) 3967a84e134Smrg # Important note: in order to support this mode, a compiler *must* 3977a84e134Smrg # always write the preprocessed file to stdout, regardless of -o. 3987a84e134Smrg "$@" || exit $? 3997a84e134Smrg 4007a84e134Smrg # Remove the call to Libtool. 4017a84e134Smrg if test "$libtool" = yes; then 4027a84e134Smrg while test $1 != '--mode=compile'; do 4037a84e134Smrg shift 4047a84e134Smrg done 4057a84e134Smrg shift 4067a84e134Smrg fi 4077a84e134Smrg 4087a84e134Smrg # Remove `-o $object'. 4097a84e134Smrg IFS=" " 4107a84e134Smrg for arg 4117a84e134Smrg do 4127a84e134Smrg case $arg in 4137a84e134Smrg -o) 4147a84e134Smrg shift 4157a84e134Smrg ;; 4167a84e134Smrg $object) 4177a84e134Smrg shift 4187a84e134Smrg ;; 4197a84e134Smrg *) 4207a84e134Smrg set fnord "$@" "$arg" 4217a84e134Smrg shift # fnord 4227a84e134Smrg shift # $arg 4237a84e134Smrg ;; 4247a84e134Smrg esac 4257a84e134Smrg done 4267a84e134Smrg 4277a84e134Smrg test -z "$dashmflag" && dashmflag=-M 4287a84e134Smrg # Require at least two characters before searching for `:' 4297a84e134Smrg # in the target name. This is to cope with DOS-style filenames: 4307a84e134Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4317a84e134Smrg "$@" $dashmflag | 4327a84e134Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4337a84e134Smrg rm -f "$depfile" 4347a84e134Smrg cat < "$tmpdepfile" > "$depfile" 4357a84e134Smrg tr ' ' ' 4367a84e134Smrg' < "$tmpdepfile" | \ 4377a84e134Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4387a84e134Smrg## correctly. Breaking it into two sed invocations is a workaround. 4397a84e134Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4407a84e134Smrg rm -f "$tmpdepfile" 4417a84e134Smrg ;; 4427a84e134Smrg 4437a84e134SmrgdashXmstdout) 4447a84e134Smrg # This case only exists to satisfy depend.m4. It is never actually 4457a84e134Smrg # run, as this mode is specially recognized in the preamble. 4467a84e134Smrg exit 1 4477a84e134Smrg ;; 4487a84e134Smrg 4497a84e134Smrgmakedepend) 4507a84e134Smrg "$@" || exit $? 4517a84e134Smrg # Remove any Libtool call 4527a84e134Smrg if test "$libtool" = yes; then 4537a84e134Smrg while test $1 != '--mode=compile'; do 4547a84e134Smrg shift 4557a84e134Smrg done 4567a84e134Smrg shift 4577a84e134Smrg fi 4587a84e134Smrg # X makedepend 4597a84e134Smrg shift 4607a84e134Smrg cleared=no 4617a84e134Smrg for arg in "$@"; do 4627a84e134Smrg case $cleared in 4637a84e134Smrg no) 4647a84e134Smrg set ""; shift 4657a84e134Smrg cleared=yes ;; 4667a84e134Smrg esac 4677a84e134Smrg case "$arg" in 4687a84e134Smrg -D*|-I*) 4697a84e134Smrg set fnord "$@" "$arg"; shift ;; 4707a84e134Smrg # Strip any option that makedepend may not understand. Remove 4717a84e134Smrg # the object too, otherwise makedepend will parse it as a source file. 4727a84e134Smrg -*|$object) 4737a84e134Smrg ;; 4747a84e134Smrg *) 4757a84e134Smrg set fnord "$@" "$arg"; shift ;; 4767a84e134Smrg esac 4777a84e134Smrg done 4787a84e134Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 4797a84e134Smrg touch "$tmpdepfile" 4807a84e134Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4817a84e134Smrg rm -f "$depfile" 4827a84e134Smrg cat < "$tmpdepfile" > "$depfile" 4837a84e134Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 4847a84e134Smrg' | \ 4857a84e134Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4867a84e134Smrg## correctly. Breaking it into two sed invocations is a workaround. 4877a84e134Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4887a84e134Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 4897a84e134Smrg ;; 4907a84e134Smrg 4917a84e134Smrgcpp) 4927a84e134Smrg # Important note: in order to support this mode, a compiler *must* 4937a84e134Smrg # always write the preprocessed file to stdout. 4947a84e134Smrg "$@" || exit $? 4957a84e134Smrg 4967a84e134Smrg # Remove the call to Libtool. 4977a84e134Smrg if test "$libtool" = yes; then 4987a84e134Smrg while test $1 != '--mode=compile'; do 4997a84e134Smrg shift 5007a84e134Smrg done 5017a84e134Smrg shift 5027a84e134Smrg fi 5037a84e134Smrg 5047a84e134Smrg # Remove `-o $object'. 5057a84e134Smrg IFS=" " 5067a84e134Smrg for arg 5077a84e134Smrg do 5087a84e134Smrg case $arg in 5097a84e134Smrg -o) 5107a84e134Smrg shift 5117a84e134Smrg ;; 5127a84e134Smrg $object) 5137a84e134Smrg shift 5147a84e134Smrg ;; 5157a84e134Smrg *) 5167a84e134Smrg set fnord "$@" "$arg" 5177a84e134Smrg shift # fnord 5187a84e134Smrg shift # $arg 5197a84e134Smrg ;; 5207a84e134Smrg esac 5217a84e134Smrg done 5227a84e134Smrg 5237a84e134Smrg "$@" -E | 5247a84e134Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5257a84e134Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5267a84e134Smrg sed '$ s: \\$::' > "$tmpdepfile" 5277a84e134Smrg rm -f "$depfile" 5287a84e134Smrg echo "$object : \\" > "$depfile" 5297a84e134Smrg cat < "$tmpdepfile" >> "$depfile" 5307a84e134Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5317a84e134Smrg rm -f "$tmpdepfile" 5327a84e134Smrg ;; 5337a84e134Smrg 5347a84e134Smrgmsvisualcpp) 5357a84e134Smrg # Important note: in order to support this mode, a compiler *must* 5367a84e134Smrg # always write the preprocessed file to stdout, regardless of -o, 5377a84e134Smrg # because we must use -o when running libtool. 5387a84e134Smrg "$@" || exit $? 5397a84e134Smrg IFS=" " 5407a84e134Smrg for arg 5417a84e134Smrg do 5427a84e134Smrg case "$arg" in 5437a84e134Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5447a84e134Smrg set fnord "$@" 5457a84e134Smrg shift 5467a84e134Smrg shift 5477a84e134Smrg ;; 5487a84e134Smrg *) 5497a84e134Smrg set fnord "$@" "$arg" 5507a84e134Smrg shift 5517a84e134Smrg shift 5527a84e134Smrg ;; 5537a84e134Smrg esac 5547a84e134Smrg done 5557a84e134Smrg "$@" -E | 5567a84e134Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 5577a84e134Smrg rm -f "$depfile" 5587a84e134Smrg echo "$object : \\" > "$depfile" 5597a84e134Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5607a84e134Smrg echo " " >> "$depfile" 5617a84e134Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5627a84e134Smrg rm -f "$tmpdepfile" 5637a84e134Smrg ;; 5647a84e134Smrg 5657a84e134Smrgnone) 5667a84e134Smrg exec "$@" 5677a84e134Smrg ;; 5687a84e134Smrg 5697a84e134Smrg*) 5707a84e134Smrg echo "Unknown depmode $depmode" 1>&2 5717a84e134Smrg exit 1 5727a84e134Smrg ;; 5737a84e134Smrgesac 5747a84e134Smrg 5757a84e134Smrgexit 0 5767a84e134Smrg 5777a84e134Smrg# Local Variables: 5787a84e134Smrg# mode: shell-script 5797a84e134Smrg# sh-indentation: 2 5807a84e134Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 5817a84e134Smrg# time-stamp-start: "scriptversion=" 5827a84e134Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 5837a84e134Smrg# time-stamp-end: "$" 5847a84e134Smrg# End: 585