depcomp revision 8c9fbc29
18c9fbc29Smrg#! /bin/sh 28c9fbc29Smrg# depcomp - compile a program generating dependencies as side-effects 38c9fbc29Smrg 48c9fbc29Smrgscriptversion=2006-10-15.18 58c9fbc29Smrg 68c9fbc29Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software 78c9fbc29Smrg# Foundation, Inc. 88c9fbc29Smrg 98c9fbc29Smrg# This program is free software; you can redistribute it and/or modify 108c9fbc29Smrg# it under the terms of the GNU General Public License as published by 118c9fbc29Smrg# the Free Software Foundation; either version 2, or (at your option) 128c9fbc29Smrg# any later version. 138c9fbc29Smrg 148c9fbc29Smrg# This program is distributed in the hope that it will be useful, 158c9fbc29Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 168c9fbc29Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 178c9fbc29Smrg# GNU General Public License for more details. 188c9fbc29Smrg 198c9fbc29Smrg# You should have received a copy of the GNU General Public License 208c9fbc29Smrg# along with this program; if not, write to the Free Software 218c9fbc29Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 228c9fbc29Smrg# 02110-1301, USA. 238c9fbc29Smrg 248c9fbc29Smrg# As a special exception to the GNU General Public License, if you 258c9fbc29Smrg# distribute this file as part of a program that contains a 268c9fbc29Smrg# configuration script generated by Autoconf, you may include it under 278c9fbc29Smrg# the same distribution terms that you use for the rest of that program. 288c9fbc29Smrg 298c9fbc29Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 308c9fbc29Smrg 318c9fbc29Smrgcase $1 in 328c9fbc29Smrg '') 338c9fbc29Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 348c9fbc29Smrg exit 1; 358c9fbc29Smrg ;; 368c9fbc29Smrg -h | --h*) 378c9fbc29Smrg cat <<\EOF 388c9fbc29SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 398c9fbc29Smrg 408c9fbc29SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 418c9fbc29Smrgas side-effects. 428c9fbc29Smrg 438c9fbc29SmrgEnvironment variables: 448c9fbc29Smrg depmode Dependency tracking mode. 458c9fbc29Smrg source Source file read by `PROGRAMS ARGS'. 468c9fbc29Smrg object Object file output by `PROGRAMS ARGS'. 478c9fbc29Smrg DEPDIR directory where to store dependencies. 488c9fbc29Smrg depfile Dependency file to output. 498c9fbc29Smrg tmpdepfile Temporary file to use when outputing dependencies. 508c9fbc29Smrg libtool Whether libtool is used (yes/no). 518c9fbc29Smrg 528c9fbc29SmrgReport bugs to <bug-automake@gnu.org>. 538c9fbc29SmrgEOF 548c9fbc29Smrg exit $? 558c9fbc29Smrg ;; 568c9fbc29Smrg -v | --v*) 578c9fbc29Smrg echo "depcomp $scriptversion" 588c9fbc29Smrg exit $? 598c9fbc29Smrg ;; 608c9fbc29Smrgesac 618c9fbc29Smrg 628c9fbc29Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 638c9fbc29Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 648c9fbc29Smrg exit 1 658c9fbc29Smrgfi 668c9fbc29Smrg 678c9fbc29Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 688c9fbc29Smrgdepfile=${depfile-`echo "$object" | 698c9fbc29Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 708c9fbc29Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 718c9fbc29Smrg 728c9fbc29Smrgrm -f "$tmpdepfile" 738c9fbc29Smrg 748c9fbc29Smrg# Some modes work just like other modes, but use different flags. We 758c9fbc29Smrg# parameterize here, but still list the modes in the big case below, 768c9fbc29Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 778c9fbc29Smrg# here, because this file can only contain one case statement. 788c9fbc29Smrgif test "$depmode" = hp; then 798c9fbc29Smrg # HP compiler uses -M and no extra arg. 808c9fbc29Smrg gccflag=-M 818c9fbc29Smrg depmode=gcc 828c9fbc29Smrgfi 838c9fbc29Smrg 848c9fbc29Smrgif test "$depmode" = dashXmstdout; then 858c9fbc29Smrg # This is just like dashmstdout with a different argument. 868c9fbc29Smrg dashmflag=-xM 878c9fbc29Smrg depmode=dashmstdout 888c9fbc29Smrgfi 898c9fbc29Smrg 908c9fbc29Smrgcase "$depmode" in 918c9fbc29Smrggcc3) 928c9fbc29Smrg## gcc 3 implements dependency tracking that does exactly what 938c9fbc29Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 948c9fbc29Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 958c9fbc29Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 968c9fbc29Smrg## the command line argument order; so add the flags where they 978c9fbc29Smrg## appear in depend2.am. Note that the slowdown incurred here 988c9fbc29Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 998c9fbc29Smrg for arg 1008c9fbc29Smrg do 1018c9fbc29Smrg case $arg in 1028c9fbc29Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1038c9fbc29Smrg *) set fnord "$@" "$arg" ;; 1048c9fbc29Smrg esac 1058c9fbc29Smrg shift # fnord 1068c9fbc29Smrg shift # $arg 1078c9fbc29Smrg done 1088c9fbc29Smrg "$@" 1098c9fbc29Smrg stat=$? 1108c9fbc29Smrg if test $stat -eq 0; then : 1118c9fbc29Smrg else 1128c9fbc29Smrg rm -f "$tmpdepfile" 1138c9fbc29Smrg exit $stat 1148c9fbc29Smrg fi 1158c9fbc29Smrg mv "$tmpdepfile" "$depfile" 1168c9fbc29Smrg ;; 1178c9fbc29Smrg 1188c9fbc29Smrggcc) 1198c9fbc29Smrg## There are various ways to get dependency output from gcc. Here's 1208c9fbc29Smrg## why we pick this rather obscure method: 1218c9fbc29Smrg## - Don't want to use -MD because we'd like the dependencies to end 1228c9fbc29Smrg## up in a subdir. Having to rename by hand is ugly. 1238c9fbc29Smrg## (We might end up doing this anyway to support other compilers.) 1248c9fbc29Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1258c9fbc29Smrg## -MM, not -M (despite what the docs say). 1268c9fbc29Smrg## - Using -M directly means running the compiler twice (even worse 1278c9fbc29Smrg## than renaming). 1288c9fbc29Smrg if test -z "$gccflag"; then 1298c9fbc29Smrg gccflag=-MD, 1308c9fbc29Smrg fi 1318c9fbc29Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1328c9fbc29Smrg stat=$? 1338c9fbc29Smrg if test $stat -eq 0; then : 1348c9fbc29Smrg else 1358c9fbc29Smrg rm -f "$tmpdepfile" 1368c9fbc29Smrg exit $stat 1378c9fbc29Smrg fi 1388c9fbc29Smrg rm -f "$depfile" 1398c9fbc29Smrg echo "$object : \\" > "$depfile" 1408c9fbc29Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1418c9fbc29Smrg## The second -e expression handles DOS-style file names with drive letters. 1428c9fbc29Smrg sed -e 's/^[^:]*: / /' \ 1438c9fbc29Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1448c9fbc29Smrg## This next piece of magic avoids the `deleted header file' problem. 1458c9fbc29Smrg## The problem is that when a header file which appears in a .P file 1468c9fbc29Smrg## is deleted, the dependency causes make to die (because there is 1478c9fbc29Smrg## typically no way to rebuild the header). We avoid this by adding 1488c9fbc29Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1498c9fbc29Smrg## this for us directly. 1508c9fbc29Smrg tr ' ' ' 1518c9fbc29Smrg' < "$tmpdepfile" | 1528c9fbc29Smrg## Some versions of gcc put a space before the `:'. On the theory 1538c9fbc29Smrg## that the space means something, we add a space to the output as 1548c9fbc29Smrg## well. 1558c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1568c9fbc29Smrg## correctly. Breaking it into two sed invocations is a workaround. 1578c9fbc29Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1588c9fbc29Smrg rm -f "$tmpdepfile" 1598c9fbc29Smrg ;; 1608c9fbc29Smrg 1618c9fbc29Smrghp) 1628c9fbc29Smrg # This case exists only to let depend.m4 do its work. It works by 1638c9fbc29Smrg # looking at the text of this script. This case will never be run, 1648c9fbc29Smrg # since it is checked for above. 1658c9fbc29Smrg exit 1 1668c9fbc29Smrg ;; 1678c9fbc29Smrg 1688c9fbc29Smrgsgi) 1698c9fbc29Smrg if test "$libtool" = yes; then 1708c9fbc29Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1718c9fbc29Smrg else 1728c9fbc29Smrg "$@" -MDupdate "$tmpdepfile" 1738c9fbc29Smrg fi 1748c9fbc29Smrg stat=$? 1758c9fbc29Smrg if test $stat -eq 0; then : 1768c9fbc29Smrg else 1778c9fbc29Smrg rm -f "$tmpdepfile" 1788c9fbc29Smrg exit $stat 1798c9fbc29Smrg fi 1808c9fbc29Smrg rm -f "$depfile" 1818c9fbc29Smrg 1828c9fbc29Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1838c9fbc29Smrg echo "$object : \\" > "$depfile" 1848c9fbc29Smrg 1858c9fbc29Smrg # Clip off the initial element (the dependent). Don't try to be 1868c9fbc29Smrg # clever and replace this with sed code, as IRIX sed won't handle 1878c9fbc29Smrg # lines with more than a fixed number of characters (4096 in 1888c9fbc29Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1898c9fbc29Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1908c9fbc29Smrg # dependency line. 1918c9fbc29Smrg tr ' ' ' 1928c9fbc29Smrg' < "$tmpdepfile" \ 1938c9fbc29Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1948c9fbc29Smrg tr ' 1958c9fbc29Smrg' ' ' >> $depfile 1968c9fbc29Smrg echo >> $depfile 1978c9fbc29Smrg 1988c9fbc29Smrg # The second pass generates a dummy entry for each header file. 1998c9fbc29Smrg tr ' ' ' 2008c9fbc29Smrg' < "$tmpdepfile" \ 2018c9fbc29Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2028c9fbc29Smrg >> $depfile 2038c9fbc29Smrg else 2048c9fbc29Smrg # The sourcefile does not contain any dependencies, so just 2058c9fbc29Smrg # store a dummy comment line, to avoid errors with the Makefile 2068c9fbc29Smrg # "include basename.Plo" scheme. 2078c9fbc29Smrg echo "#dummy" > "$depfile" 2088c9fbc29Smrg fi 2098c9fbc29Smrg rm -f "$tmpdepfile" 2108c9fbc29Smrg ;; 2118c9fbc29Smrg 2128c9fbc29Smrgaix) 2138c9fbc29Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2148c9fbc29Smrg # in a .u file. In older versions, this file always lives in the 2158c9fbc29Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2168c9fbc29Smrg # start of each line; $object doesn't have directory information. 2178c9fbc29Smrg # Version 6 uses the directory in both cases. 2188c9fbc29Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 2198c9fbc29Smrg tmpdepfile="$stripped.u" 2208c9fbc29Smrg if test "$libtool" = yes; then 2218c9fbc29Smrg "$@" -Wc,-M 2228c9fbc29Smrg else 2238c9fbc29Smrg "$@" -M 2248c9fbc29Smrg fi 2258c9fbc29Smrg stat=$? 2268c9fbc29Smrg 2278c9fbc29Smrg if test -f "$tmpdepfile"; then : 2288c9fbc29Smrg else 2298c9fbc29Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 2308c9fbc29Smrg tmpdepfile="$stripped.u" 2318c9fbc29Smrg fi 2328c9fbc29Smrg 2338c9fbc29Smrg if test $stat -eq 0; then : 2348c9fbc29Smrg else 2358c9fbc29Smrg rm -f "$tmpdepfile" 2368c9fbc29Smrg exit $stat 2378c9fbc29Smrg fi 2388c9fbc29Smrg 2398c9fbc29Smrg if test -f "$tmpdepfile"; then 2408c9fbc29Smrg outname="$stripped.o" 2418c9fbc29Smrg # Each line is of the form `foo.o: dependent.h'. 2428c9fbc29Smrg # Do two passes, one to just change these to 2438c9fbc29Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2448c9fbc29Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 2458c9fbc29Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 2468c9fbc29Smrg else 2478c9fbc29Smrg # The sourcefile does not contain any dependencies, so just 2488c9fbc29Smrg # store a dummy comment line, to avoid errors with the Makefile 2498c9fbc29Smrg # "include basename.Plo" scheme. 2508c9fbc29Smrg echo "#dummy" > "$depfile" 2518c9fbc29Smrg fi 2528c9fbc29Smrg rm -f "$tmpdepfile" 2538c9fbc29Smrg ;; 2548c9fbc29Smrg 2558c9fbc29Smrgicc) 2568c9fbc29Smrg # Intel's C compiler understands `-MD -MF file'. However on 2578c9fbc29Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2588c9fbc29Smrg # ICC 7.0 will fill foo.d with something like 2598c9fbc29Smrg # foo.o: sub/foo.c 2608c9fbc29Smrg # foo.o: sub/foo.h 2618c9fbc29Smrg # which is wrong. We want: 2628c9fbc29Smrg # sub/foo.o: sub/foo.c 2638c9fbc29Smrg # sub/foo.o: sub/foo.h 2648c9fbc29Smrg # sub/foo.c: 2658c9fbc29Smrg # sub/foo.h: 2668c9fbc29Smrg # ICC 7.1 will output 2678c9fbc29Smrg # foo.o: sub/foo.c sub/foo.h 2688c9fbc29Smrg # and will wrap long lines using \ : 2698c9fbc29Smrg # foo.o: sub/foo.c ... \ 2708c9fbc29Smrg # sub/foo.h ... \ 2718c9fbc29Smrg # ... 2728c9fbc29Smrg 2738c9fbc29Smrg "$@" -MD -MF "$tmpdepfile" 2748c9fbc29Smrg stat=$? 2758c9fbc29Smrg if test $stat -eq 0; then : 2768c9fbc29Smrg else 2778c9fbc29Smrg rm -f "$tmpdepfile" 2788c9fbc29Smrg exit $stat 2798c9fbc29Smrg fi 2808c9fbc29Smrg rm -f "$depfile" 2818c9fbc29Smrg # Each line is of the form `foo.o: dependent.h', 2828c9fbc29Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2838c9fbc29Smrg # Do two passes, one to just change these to 2848c9fbc29Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2858c9fbc29Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2868c9fbc29Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2878c9fbc29Smrg # correctly. Breaking it into two sed invocations is a workaround. 2888c9fbc29Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2898c9fbc29Smrg sed -e 's/$/ :/' >> "$depfile" 2908c9fbc29Smrg rm -f "$tmpdepfile" 2918c9fbc29Smrg ;; 2928c9fbc29Smrg 2938c9fbc29Smrghp2) 2948c9fbc29Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 2958c9fbc29Smrg # compilers, which have integrated preprocessors. The correct option 2968c9fbc29Smrg # to use with these is +Maked; it writes dependencies to a file named 2978c9fbc29Smrg # 'foo.d', which lands next to the object file, wherever that 2988c9fbc29Smrg # happens to be. 2998c9fbc29Smrg # Much of this is similar to the tru64 case; see comments there. 3008c9fbc29Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3018c9fbc29Smrg test "x$dir" = "x$object" && dir= 3028c9fbc29Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3038c9fbc29Smrg if test "$libtool" = yes; then 3048c9fbc29Smrg tmpdepfile1=$dir$base.d 3058c9fbc29Smrg tmpdepfile2=$dir.libs/$base.d 3068c9fbc29Smrg "$@" -Wc,+Maked 3078c9fbc29Smrg else 3088c9fbc29Smrg tmpdepfile1=$dir$base.d 3098c9fbc29Smrg tmpdepfile2=$dir$base.d 3108c9fbc29Smrg "$@" +Maked 3118c9fbc29Smrg fi 3128c9fbc29Smrg stat=$? 3138c9fbc29Smrg if test $stat -eq 0; then : 3148c9fbc29Smrg else 3158c9fbc29Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3168c9fbc29Smrg exit $stat 3178c9fbc29Smrg fi 3188c9fbc29Smrg 3198c9fbc29Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3208c9fbc29Smrg do 3218c9fbc29Smrg test -f "$tmpdepfile" && break 3228c9fbc29Smrg done 3238c9fbc29Smrg if test -f "$tmpdepfile"; then 3248c9fbc29Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3258c9fbc29Smrg # Add `dependent.h:' lines. 3268c9fbc29Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3278c9fbc29Smrg else 3288c9fbc29Smrg echo "#dummy" > "$depfile" 3298c9fbc29Smrg fi 3308c9fbc29Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3318c9fbc29Smrg ;; 3328c9fbc29Smrg 3338c9fbc29Smrgtru64) 3348c9fbc29Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3358c9fbc29Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3368c9fbc29Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3378c9fbc29Smrg # dependencies in `foo.d' instead, so we check for that too. 3388c9fbc29Smrg # Subdirectories are respected. 3398c9fbc29Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3408c9fbc29Smrg test "x$dir" = "x$object" && dir= 3418c9fbc29Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3428c9fbc29Smrg 3438c9fbc29Smrg if test "$libtool" = yes; then 3448c9fbc29Smrg # With Tru64 cc, shared objects can also be used to make a 3458c9fbc29Smrg # static library. This mechanism is used in libtool 1.4 series to 3468c9fbc29Smrg # handle both shared and static libraries in a single compilation. 3478c9fbc29Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3488c9fbc29Smrg # 3498c9fbc29Smrg # With libtool 1.5 this exception was removed, and libtool now 3508c9fbc29Smrg # generates 2 separate objects for the 2 libraries. These two 3518c9fbc29Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3528c9fbc29Smrg # in $dir$base.o.d. We have to check for both files, because 3538c9fbc29Smrg # one of the two compilations can be disabled. We should prefer 3548c9fbc29Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3558c9fbc29Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3568c9fbc29Smrg # the former would cause a distcleancheck panic. 3578c9fbc29Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3588c9fbc29Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3598c9fbc29Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3608c9fbc29Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3618c9fbc29Smrg "$@" -Wc,-MD 3628c9fbc29Smrg else 3638c9fbc29Smrg tmpdepfile1=$dir$base.o.d 3648c9fbc29Smrg tmpdepfile2=$dir$base.d 3658c9fbc29Smrg tmpdepfile3=$dir$base.d 3668c9fbc29Smrg tmpdepfile4=$dir$base.d 3678c9fbc29Smrg "$@" -MD 3688c9fbc29Smrg fi 3698c9fbc29Smrg 3708c9fbc29Smrg stat=$? 3718c9fbc29Smrg if test $stat -eq 0; then : 3728c9fbc29Smrg else 3738c9fbc29Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3748c9fbc29Smrg exit $stat 3758c9fbc29Smrg fi 3768c9fbc29Smrg 3778c9fbc29Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3788c9fbc29Smrg do 3798c9fbc29Smrg test -f "$tmpdepfile" && break 3808c9fbc29Smrg done 3818c9fbc29Smrg if test -f "$tmpdepfile"; then 3828c9fbc29Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3838c9fbc29Smrg # That's a tab and a space in the []. 3848c9fbc29Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3858c9fbc29Smrg else 3868c9fbc29Smrg echo "#dummy" > "$depfile" 3878c9fbc29Smrg fi 3888c9fbc29Smrg rm -f "$tmpdepfile" 3898c9fbc29Smrg ;; 3908c9fbc29Smrg 3918c9fbc29Smrg#nosideeffect) 3928c9fbc29Smrg # This comment above is used by automake to tell side-effect 3938c9fbc29Smrg # dependency tracking mechanisms from slower ones. 3948c9fbc29Smrg 3958c9fbc29Smrgdashmstdout) 3968c9fbc29Smrg # Important note: in order to support this mode, a compiler *must* 3978c9fbc29Smrg # always write the preprocessed file to stdout, regardless of -o. 3988c9fbc29Smrg "$@" || exit $? 3998c9fbc29Smrg 4008c9fbc29Smrg # Remove the call to Libtool. 4018c9fbc29Smrg if test "$libtool" = yes; then 4028c9fbc29Smrg while test $1 != '--mode=compile'; do 4038c9fbc29Smrg shift 4048c9fbc29Smrg done 4058c9fbc29Smrg shift 4068c9fbc29Smrg fi 4078c9fbc29Smrg 4088c9fbc29Smrg # Remove `-o $object'. 4098c9fbc29Smrg IFS=" " 4108c9fbc29Smrg for arg 4118c9fbc29Smrg do 4128c9fbc29Smrg case $arg in 4138c9fbc29Smrg -o) 4148c9fbc29Smrg shift 4158c9fbc29Smrg ;; 4168c9fbc29Smrg $object) 4178c9fbc29Smrg shift 4188c9fbc29Smrg ;; 4198c9fbc29Smrg *) 4208c9fbc29Smrg set fnord "$@" "$arg" 4218c9fbc29Smrg shift # fnord 4228c9fbc29Smrg shift # $arg 4238c9fbc29Smrg ;; 4248c9fbc29Smrg esac 4258c9fbc29Smrg done 4268c9fbc29Smrg 4278c9fbc29Smrg test -z "$dashmflag" && dashmflag=-M 4288c9fbc29Smrg # Require at least two characters before searching for `:' 4298c9fbc29Smrg # in the target name. This is to cope with DOS-style filenames: 4308c9fbc29Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4318c9fbc29Smrg "$@" $dashmflag | 4328c9fbc29Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4338c9fbc29Smrg rm -f "$depfile" 4348c9fbc29Smrg cat < "$tmpdepfile" > "$depfile" 4358c9fbc29Smrg tr ' ' ' 4368c9fbc29Smrg' < "$tmpdepfile" | \ 4378c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4388c9fbc29Smrg## correctly. Breaking it into two sed invocations is a workaround. 4398c9fbc29Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4408c9fbc29Smrg rm -f "$tmpdepfile" 4418c9fbc29Smrg ;; 4428c9fbc29Smrg 4438c9fbc29SmrgdashXmstdout) 4448c9fbc29Smrg # This case only exists to satisfy depend.m4. It is never actually 4458c9fbc29Smrg # run, as this mode is specially recognized in the preamble. 4468c9fbc29Smrg exit 1 4478c9fbc29Smrg ;; 4488c9fbc29Smrg 4498c9fbc29Smrgmakedepend) 4508c9fbc29Smrg "$@" || exit $? 4518c9fbc29Smrg # Remove any Libtool call 4528c9fbc29Smrg if test "$libtool" = yes; then 4538c9fbc29Smrg while test $1 != '--mode=compile'; do 4548c9fbc29Smrg shift 4558c9fbc29Smrg done 4568c9fbc29Smrg shift 4578c9fbc29Smrg fi 4588c9fbc29Smrg # X makedepend 4598c9fbc29Smrg shift 4608c9fbc29Smrg cleared=no 4618c9fbc29Smrg for arg in "$@"; do 4628c9fbc29Smrg case $cleared in 4638c9fbc29Smrg no) 4648c9fbc29Smrg set ""; shift 4658c9fbc29Smrg cleared=yes ;; 4668c9fbc29Smrg esac 4678c9fbc29Smrg case "$arg" in 4688c9fbc29Smrg -D*|-I*) 4698c9fbc29Smrg set fnord "$@" "$arg"; shift ;; 4708c9fbc29Smrg # Strip any option that makedepend may not understand. Remove 4718c9fbc29Smrg # the object too, otherwise makedepend will parse it as a source file. 4728c9fbc29Smrg -*|$object) 4738c9fbc29Smrg ;; 4748c9fbc29Smrg *) 4758c9fbc29Smrg set fnord "$@" "$arg"; shift ;; 4768c9fbc29Smrg esac 4778c9fbc29Smrg done 4788c9fbc29Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 4798c9fbc29Smrg touch "$tmpdepfile" 4808c9fbc29Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4818c9fbc29Smrg rm -f "$depfile" 4828c9fbc29Smrg cat < "$tmpdepfile" > "$depfile" 4838c9fbc29Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 4848c9fbc29Smrg' | \ 4858c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4868c9fbc29Smrg## correctly. Breaking it into two sed invocations is a workaround. 4878c9fbc29Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4888c9fbc29Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 4898c9fbc29Smrg ;; 4908c9fbc29Smrg 4918c9fbc29Smrgcpp) 4928c9fbc29Smrg # Important note: in order to support this mode, a compiler *must* 4938c9fbc29Smrg # always write the preprocessed file to stdout. 4948c9fbc29Smrg "$@" || exit $? 4958c9fbc29Smrg 4968c9fbc29Smrg # Remove the call to Libtool. 4978c9fbc29Smrg if test "$libtool" = yes; then 4988c9fbc29Smrg while test $1 != '--mode=compile'; do 4998c9fbc29Smrg shift 5008c9fbc29Smrg done 5018c9fbc29Smrg shift 5028c9fbc29Smrg fi 5038c9fbc29Smrg 5048c9fbc29Smrg # Remove `-o $object'. 5058c9fbc29Smrg IFS=" " 5068c9fbc29Smrg for arg 5078c9fbc29Smrg do 5088c9fbc29Smrg case $arg in 5098c9fbc29Smrg -o) 5108c9fbc29Smrg shift 5118c9fbc29Smrg ;; 5128c9fbc29Smrg $object) 5138c9fbc29Smrg shift 5148c9fbc29Smrg ;; 5158c9fbc29Smrg *) 5168c9fbc29Smrg set fnord "$@" "$arg" 5178c9fbc29Smrg shift # fnord 5188c9fbc29Smrg shift # $arg 5198c9fbc29Smrg ;; 5208c9fbc29Smrg esac 5218c9fbc29Smrg done 5228c9fbc29Smrg 5238c9fbc29Smrg "$@" -E | 5248c9fbc29Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5258c9fbc29Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5268c9fbc29Smrg sed '$ s: \\$::' > "$tmpdepfile" 5278c9fbc29Smrg rm -f "$depfile" 5288c9fbc29Smrg echo "$object : \\" > "$depfile" 5298c9fbc29Smrg cat < "$tmpdepfile" >> "$depfile" 5308c9fbc29Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5318c9fbc29Smrg rm -f "$tmpdepfile" 5328c9fbc29Smrg ;; 5338c9fbc29Smrg 5348c9fbc29Smrgmsvisualcpp) 5358c9fbc29Smrg # Important note: in order to support this mode, a compiler *must* 5368c9fbc29Smrg # always write the preprocessed file to stdout, regardless of -o, 5378c9fbc29Smrg # because we must use -o when running libtool. 5388c9fbc29Smrg "$@" || exit $? 5398c9fbc29Smrg IFS=" " 5408c9fbc29Smrg for arg 5418c9fbc29Smrg do 5428c9fbc29Smrg case "$arg" in 5438c9fbc29Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5448c9fbc29Smrg set fnord "$@" 5458c9fbc29Smrg shift 5468c9fbc29Smrg shift 5478c9fbc29Smrg ;; 5488c9fbc29Smrg *) 5498c9fbc29Smrg set fnord "$@" "$arg" 5508c9fbc29Smrg shift 5518c9fbc29Smrg shift 5528c9fbc29Smrg ;; 5538c9fbc29Smrg esac 5548c9fbc29Smrg done 5558c9fbc29Smrg "$@" -E | 5568c9fbc29Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 5578c9fbc29Smrg rm -f "$depfile" 5588c9fbc29Smrg echo "$object : \\" > "$depfile" 5598c9fbc29Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5608c9fbc29Smrg echo " " >> "$depfile" 5618c9fbc29Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5628c9fbc29Smrg rm -f "$tmpdepfile" 5638c9fbc29Smrg ;; 5648c9fbc29Smrg 5658c9fbc29Smrgnone) 5668c9fbc29Smrg exec "$@" 5678c9fbc29Smrg ;; 5688c9fbc29Smrg 5698c9fbc29Smrg*) 5708c9fbc29Smrg echo "Unknown depmode $depmode" 1>&2 5718c9fbc29Smrg exit 1 5728c9fbc29Smrg ;; 5738c9fbc29Smrgesac 5748c9fbc29Smrg 5758c9fbc29Smrgexit 0 5768c9fbc29Smrg 5778c9fbc29Smrg# Local Variables: 5788c9fbc29Smrg# mode: shell-script 5798c9fbc29Smrg# sh-indentation: 2 5808c9fbc29Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 5818c9fbc29Smrg# time-stamp-start: "scriptversion=" 5828c9fbc29Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 5838c9fbc29Smrg# time-stamp-end: "$" 5848c9fbc29Smrg# End: 585