depcomp revision 3a72f200
19027f4a0Smrg#! /bin/sh 29027f4a0Smrg# depcomp - compile a program generating dependencies as side-effects 39027f4a0Smrg 43a72f200Smrgscriptversion=2009-04-28.21; # UTC 59027f4a0Smrg 63a72f200Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 73a72f200Smrg# Software Foundation, Inc. 89027f4a0Smrg 99027f4a0Smrg# This program is free software; you can redistribute it and/or modify 109027f4a0Smrg# it under the terms of the GNU General Public License as published by 119027f4a0Smrg# the Free Software Foundation; either version 2, or (at your option) 129027f4a0Smrg# any later version. 139027f4a0Smrg 149027f4a0Smrg# This program is distributed in the hope that it will be useful, 159027f4a0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 169027f4a0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 179027f4a0Smrg# GNU General Public License for more details. 189027f4a0Smrg 199027f4a0Smrg# You should have received a copy of the GNU General Public License 203a72f200Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 219027f4a0Smrg 229027f4a0Smrg# As a special exception to the GNU General Public License, if you 239027f4a0Smrg# distribute this file as part of a program that contains a 249027f4a0Smrg# configuration script generated by Autoconf, you may include it under 259027f4a0Smrg# the same distribution terms that you use for the rest of that program. 269027f4a0Smrg 279027f4a0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 289027f4a0Smrg 299027f4a0Smrgcase $1 in 309027f4a0Smrg '') 319027f4a0Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 329027f4a0Smrg exit 1; 339027f4a0Smrg ;; 349027f4a0Smrg -h | --h*) 359027f4a0Smrg cat <<\EOF 369027f4a0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 379027f4a0Smrg 389027f4a0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 399027f4a0Smrgas side-effects. 409027f4a0Smrg 419027f4a0SmrgEnvironment variables: 429027f4a0Smrg depmode Dependency tracking mode. 439027f4a0Smrg source Source file read by `PROGRAMS ARGS'. 449027f4a0Smrg object Object file output by `PROGRAMS ARGS'. 459027f4a0Smrg DEPDIR directory where to store dependencies. 469027f4a0Smrg depfile Dependency file to output. 479027f4a0Smrg tmpdepfile Temporary file to use when outputing dependencies. 489027f4a0Smrg libtool Whether libtool is used (yes/no). 499027f4a0Smrg 509027f4a0SmrgReport bugs to <bug-automake@gnu.org>. 519027f4a0SmrgEOF 529027f4a0Smrg exit $? 539027f4a0Smrg ;; 549027f4a0Smrg -v | --v*) 559027f4a0Smrg echo "depcomp $scriptversion" 569027f4a0Smrg exit $? 579027f4a0Smrg ;; 589027f4a0Smrgesac 599027f4a0Smrg 609027f4a0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 619027f4a0Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 629027f4a0Smrg exit 1 639027f4a0Smrgfi 649027f4a0Smrg 659027f4a0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 669027f4a0Smrgdepfile=${depfile-`echo "$object" | 679027f4a0Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 689027f4a0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 699027f4a0Smrg 709027f4a0Smrgrm -f "$tmpdepfile" 719027f4a0Smrg 729027f4a0Smrg# Some modes work just like other modes, but use different flags. We 739027f4a0Smrg# parameterize here, but still list the modes in the big case below, 749027f4a0Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 759027f4a0Smrg# here, because this file can only contain one case statement. 769027f4a0Smrgif test "$depmode" = hp; then 779027f4a0Smrg # HP compiler uses -M and no extra arg. 789027f4a0Smrg gccflag=-M 799027f4a0Smrg depmode=gcc 809027f4a0Smrgfi 819027f4a0Smrg 829027f4a0Smrgif test "$depmode" = dashXmstdout; then 839027f4a0Smrg # This is just like dashmstdout with a different argument. 849027f4a0Smrg dashmflag=-xM 859027f4a0Smrg depmode=dashmstdout 869027f4a0Smrgfi 879027f4a0Smrg 883a72f200Smrgcygpath_u="cygpath -u -f -" 893a72f200Smrgif test "$depmode" = msvcmsys; then 903a72f200Smrg # This is just like msvisualcpp but w/o cygpath translation. 913a72f200Smrg # Just convert the backslash-escaped backslashes to single forward 923a72f200Smrg # slashes to satisfy depend.m4 933a72f200Smrg cygpath_u="sed s,\\\\\\\\,/,g" 943a72f200Smrg depmode=msvisualcpp 953a72f200Smrgfi 963a72f200Smrg 979027f4a0Smrgcase "$depmode" in 989027f4a0Smrggcc3) 999027f4a0Smrg## gcc 3 implements dependency tracking that does exactly what 1009027f4a0Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1019027f4a0Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1023a72f200Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1033a72f200Smrg## the command line argument order; so add the flags where they 1043a72f200Smrg## appear in depend2.am. Note that the slowdown incurred here 1053a72f200Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1063a72f200Smrg for arg 1073a72f200Smrg do 1083a72f200Smrg case $arg in 1093a72f200Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1103a72f200Smrg *) set fnord "$@" "$arg" ;; 1113a72f200Smrg esac 1123a72f200Smrg shift # fnord 1133a72f200Smrg shift # $arg 1143a72f200Smrg done 1153a72f200Smrg "$@" 1169027f4a0Smrg stat=$? 1179027f4a0Smrg if test $stat -eq 0; then : 1189027f4a0Smrg else 1199027f4a0Smrg rm -f "$tmpdepfile" 1209027f4a0Smrg exit $stat 1219027f4a0Smrg fi 1229027f4a0Smrg mv "$tmpdepfile" "$depfile" 1239027f4a0Smrg ;; 1249027f4a0Smrg 1259027f4a0Smrggcc) 1269027f4a0Smrg## There are various ways to get dependency output from gcc. Here's 1279027f4a0Smrg## why we pick this rather obscure method: 1289027f4a0Smrg## - Don't want to use -MD because we'd like the dependencies to end 1299027f4a0Smrg## up in a subdir. Having to rename by hand is ugly. 1309027f4a0Smrg## (We might end up doing this anyway to support other compilers.) 1319027f4a0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1329027f4a0Smrg## -MM, not -M (despite what the docs say). 1339027f4a0Smrg## - Using -M directly means running the compiler twice (even worse 1349027f4a0Smrg## than renaming). 1359027f4a0Smrg if test -z "$gccflag"; then 1369027f4a0Smrg gccflag=-MD, 1379027f4a0Smrg fi 1389027f4a0Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1399027f4a0Smrg stat=$? 1409027f4a0Smrg if test $stat -eq 0; then : 1419027f4a0Smrg else 1429027f4a0Smrg rm -f "$tmpdepfile" 1439027f4a0Smrg exit $stat 1449027f4a0Smrg fi 1459027f4a0Smrg rm -f "$depfile" 1469027f4a0Smrg echo "$object : \\" > "$depfile" 1479027f4a0Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1489027f4a0Smrg## The second -e expression handles DOS-style file names with drive letters. 1499027f4a0Smrg sed -e 's/^[^:]*: / /' \ 1509027f4a0Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1519027f4a0Smrg## This next piece of magic avoids the `deleted header file' problem. 1529027f4a0Smrg## The problem is that when a header file which appears in a .P file 1539027f4a0Smrg## is deleted, the dependency causes make to die (because there is 1549027f4a0Smrg## typically no way to rebuild the header). We avoid this by adding 1559027f4a0Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1569027f4a0Smrg## this for us directly. 1579027f4a0Smrg tr ' ' ' 1589027f4a0Smrg' < "$tmpdepfile" | 1599027f4a0Smrg## Some versions of gcc put a space before the `:'. On the theory 1609027f4a0Smrg## that the space means something, we add a space to the output as 1619027f4a0Smrg## well. 1629027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1639027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 1649027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1659027f4a0Smrg rm -f "$tmpdepfile" 1669027f4a0Smrg ;; 1679027f4a0Smrg 1689027f4a0Smrghp) 1699027f4a0Smrg # This case exists only to let depend.m4 do its work. It works by 1709027f4a0Smrg # looking at the text of this script. This case will never be run, 1719027f4a0Smrg # since it is checked for above. 1729027f4a0Smrg exit 1 1739027f4a0Smrg ;; 1749027f4a0Smrg 1759027f4a0Smrgsgi) 1769027f4a0Smrg if test "$libtool" = yes; then 1779027f4a0Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1789027f4a0Smrg else 1799027f4a0Smrg "$@" -MDupdate "$tmpdepfile" 1809027f4a0Smrg fi 1819027f4a0Smrg stat=$? 1829027f4a0Smrg if test $stat -eq 0; then : 1839027f4a0Smrg else 1849027f4a0Smrg rm -f "$tmpdepfile" 1859027f4a0Smrg exit $stat 1869027f4a0Smrg fi 1879027f4a0Smrg rm -f "$depfile" 1889027f4a0Smrg 1899027f4a0Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1909027f4a0Smrg echo "$object : \\" > "$depfile" 1919027f4a0Smrg 1929027f4a0Smrg # Clip off the initial element (the dependent). Don't try to be 1939027f4a0Smrg # clever and replace this with sed code, as IRIX sed won't handle 1949027f4a0Smrg # lines with more than a fixed number of characters (4096 in 1959027f4a0Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1969027f4a0Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1979027f4a0Smrg # dependency line. 1989027f4a0Smrg tr ' ' ' 1999027f4a0Smrg' < "$tmpdepfile" \ 2009027f4a0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 2019027f4a0Smrg tr ' 2023a72f200Smrg' ' ' >> "$depfile" 2033a72f200Smrg echo >> "$depfile" 2049027f4a0Smrg 2059027f4a0Smrg # The second pass generates a dummy entry for each header file. 2069027f4a0Smrg tr ' ' ' 2079027f4a0Smrg' < "$tmpdepfile" \ 2089027f4a0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2093a72f200Smrg >> "$depfile" 2109027f4a0Smrg else 2119027f4a0Smrg # The sourcefile does not contain any dependencies, so just 2129027f4a0Smrg # store a dummy comment line, to avoid errors with the Makefile 2139027f4a0Smrg # "include basename.Plo" scheme. 2149027f4a0Smrg echo "#dummy" > "$depfile" 2159027f4a0Smrg fi 2169027f4a0Smrg rm -f "$tmpdepfile" 2179027f4a0Smrg ;; 2189027f4a0Smrg 2199027f4a0Smrgaix) 2209027f4a0Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2219027f4a0Smrg # in a .u file. In older versions, this file always lives in the 2229027f4a0Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2239027f4a0Smrg # start of each line; $object doesn't have directory information. 2249027f4a0Smrg # Version 6 uses the directory in both cases. 2253a72f200Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2263a72f200Smrg test "x$dir" = "x$object" && dir= 2273a72f200Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2289027f4a0Smrg if test "$libtool" = yes; then 2293a72f200Smrg tmpdepfile1=$dir$base.u 2303a72f200Smrg tmpdepfile2=$base.u 2313a72f200Smrg tmpdepfile3=$dir.libs/$base.u 2329027f4a0Smrg "$@" -Wc,-M 2339027f4a0Smrg else 2343a72f200Smrg tmpdepfile1=$dir$base.u 2353a72f200Smrg tmpdepfile2=$dir$base.u 2363a72f200Smrg tmpdepfile3=$dir$base.u 2379027f4a0Smrg "$@" -M 2389027f4a0Smrg fi 2399027f4a0Smrg stat=$? 2409027f4a0Smrg 2419027f4a0Smrg if test $stat -eq 0; then : 2429027f4a0Smrg else 2433a72f200Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2449027f4a0Smrg exit $stat 2459027f4a0Smrg fi 2469027f4a0Smrg 2473a72f200Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2483a72f200Smrg do 2493a72f200Smrg test -f "$tmpdepfile" && break 2503a72f200Smrg done 2519027f4a0Smrg if test -f "$tmpdepfile"; then 2529027f4a0Smrg # Each line is of the form `foo.o: dependent.h'. 2539027f4a0Smrg # Do two passes, one to just change these to 2549027f4a0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2553a72f200Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2563a72f200Smrg # That's a tab and a space in the []. 2573a72f200Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2589027f4a0Smrg else 2599027f4a0Smrg # The sourcefile does not contain any dependencies, so just 2609027f4a0Smrg # store a dummy comment line, to avoid errors with the Makefile 2619027f4a0Smrg # "include basename.Plo" scheme. 2629027f4a0Smrg echo "#dummy" > "$depfile" 2639027f4a0Smrg fi 2649027f4a0Smrg rm -f "$tmpdepfile" 2659027f4a0Smrg ;; 2669027f4a0Smrg 2679027f4a0Smrgicc) 2689027f4a0Smrg # Intel's C compiler understands `-MD -MF file'. However on 2699027f4a0Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2709027f4a0Smrg # ICC 7.0 will fill foo.d with something like 2719027f4a0Smrg # foo.o: sub/foo.c 2729027f4a0Smrg # foo.o: sub/foo.h 2739027f4a0Smrg # which is wrong. We want: 2749027f4a0Smrg # sub/foo.o: sub/foo.c 2759027f4a0Smrg # sub/foo.o: sub/foo.h 2769027f4a0Smrg # sub/foo.c: 2779027f4a0Smrg # sub/foo.h: 2789027f4a0Smrg # ICC 7.1 will output 2799027f4a0Smrg # foo.o: sub/foo.c sub/foo.h 2809027f4a0Smrg # and will wrap long lines using \ : 2819027f4a0Smrg # foo.o: sub/foo.c ... \ 2829027f4a0Smrg # sub/foo.h ... \ 2839027f4a0Smrg # ... 2849027f4a0Smrg 2859027f4a0Smrg "$@" -MD -MF "$tmpdepfile" 2869027f4a0Smrg stat=$? 2879027f4a0Smrg if test $stat -eq 0; then : 2889027f4a0Smrg else 2899027f4a0Smrg rm -f "$tmpdepfile" 2909027f4a0Smrg exit $stat 2919027f4a0Smrg fi 2929027f4a0Smrg rm -f "$depfile" 2939027f4a0Smrg # Each line is of the form `foo.o: dependent.h', 2949027f4a0Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2959027f4a0Smrg # Do two passes, one to just change these to 2969027f4a0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2979027f4a0Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2989027f4a0Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2999027f4a0Smrg # correctly. Breaking it into two sed invocations is a workaround. 3009027f4a0Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 3019027f4a0Smrg sed -e 's/$/ :/' >> "$depfile" 3029027f4a0Smrg rm -f "$tmpdepfile" 3039027f4a0Smrg ;; 3049027f4a0Smrg 3053a72f200Smrghp2) 3063a72f200Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3073a72f200Smrg # compilers, which have integrated preprocessors. The correct option 3083a72f200Smrg # to use with these is +Maked; it writes dependencies to a file named 3093a72f200Smrg # 'foo.d', which lands next to the object file, wherever that 3103a72f200Smrg # happens to be. 3113a72f200Smrg # Much of this is similar to the tru64 case; see comments there. 3123a72f200Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3133a72f200Smrg test "x$dir" = "x$object" && dir= 3143a72f200Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3153a72f200Smrg if test "$libtool" = yes; then 3163a72f200Smrg tmpdepfile1=$dir$base.d 3173a72f200Smrg tmpdepfile2=$dir.libs/$base.d 3183a72f200Smrg "$@" -Wc,+Maked 3193a72f200Smrg else 3203a72f200Smrg tmpdepfile1=$dir$base.d 3213a72f200Smrg tmpdepfile2=$dir$base.d 3223a72f200Smrg "$@" +Maked 3233a72f200Smrg fi 3243a72f200Smrg stat=$? 3253a72f200Smrg if test $stat -eq 0; then : 3263a72f200Smrg else 3273a72f200Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3283a72f200Smrg exit $stat 3293a72f200Smrg fi 3303a72f200Smrg 3313a72f200Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3323a72f200Smrg do 3333a72f200Smrg test -f "$tmpdepfile" && break 3343a72f200Smrg done 3353a72f200Smrg if test -f "$tmpdepfile"; then 3363a72f200Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3373a72f200Smrg # Add `dependent.h:' lines. 3383a72f200Smrg sed -ne '2,${ 3393a72f200Smrg s/^ *// 3403a72f200Smrg s/ \\*$// 3413a72f200Smrg s/$/:/ 3423a72f200Smrg p 3433a72f200Smrg }' "$tmpdepfile" >> "$depfile" 3443a72f200Smrg else 3453a72f200Smrg echo "#dummy" > "$depfile" 3463a72f200Smrg fi 3473a72f200Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3483a72f200Smrg ;; 3493a72f200Smrg 3509027f4a0Smrgtru64) 3519027f4a0Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3529027f4a0Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3539027f4a0Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3549027f4a0Smrg # dependencies in `foo.d' instead, so we check for that too. 3559027f4a0Smrg # Subdirectories are respected. 3569027f4a0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3579027f4a0Smrg test "x$dir" = "x$object" && dir= 3589027f4a0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3599027f4a0Smrg 3609027f4a0Smrg if test "$libtool" = yes; then 3619027f4a0Smrg # With Tru64 cc, shared objects can also be used to make a 3623a72f200Smrg # static library. This mechanism is used in libtool 1.4 series to 3639027f4a0Smrg # handle both shared and static libraries in a single compilation. 3649027f4a0Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3659027f4a0Smrg # 3669027f4a0Smrg # With libtool 1.5 this exception was removed, and libtool now 3679027f4a0Smrg # generates 2 separate objects for the 2 libraries. These two 3683a72f200Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3699027f4a0Smrg # in $dir$base.o.d. We have to check for both files, because 3709027f4a0Smrg # one of the two compilations can be disabled. We should prefer 3719027f4a0Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3729027f4a0Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3739027f4a0Smrg # the former would cause a distcleancheck panic. 3749027f4a0Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3759027f4a0Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3769027f4a0Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3779027f4a0Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3789027f4a0Smrg "$@" -Wc,-MD 3799027f4a0Smrg else 3809027f4a0Smrg tmpdepfile1=$dir$base.o.d 3819027f4a0Smrg tmpdepfile2=$dir$base.d 3829027f4a0Smrg tmpdepfile3=$dir$base.d 3839027f4a0Smrg tmpdepfile4=$dir$base.d 3849027f4a0Smrg "$@" -MD 3859027f4a0Smrg fi 3869027f4a0Smrg 3879027f4a0Smrg stat=$? 3889027f4a0Smrg if test $stat -eq 0; then : 3899027f4a0Smrg else 3909027f4a0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3919027f4a0Smrg exit $stat 3929027f4a0Smrg fi 3939027f4a0Smrg 3949027f4a0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3959027f4a0Smrg do 3969027f4a0Smrg test -f "$tmpdepfile" && break 3979027f4a0Smrg done 3989027f4a0Smrg if test -f "$tmpdepfile"; then 3999027f4a0Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 4009027f4a0Smrg # That's a tab and a space in the []. 4019027f4a0Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 4029027f4a0Smrg else 4039027f4a0Smrg echo "#dummy" > "$depfile" 4049027f4a0Smrg fi 4059027f4a0Smrg rm -f "$tmpdepfile" 4069027f4a0Smrg ;; 4079027f4a0Smrg 4089027f4a0Smrg#nosideeffect) 4099027f4a0Smrg # This comment above is used by automake to tell side-effect 4109027f4a0Smrg # dependency tracking mechanisms from slower ones. 4119027f4a0Smrg 4129027f4a0Smrgdashmstdout) 4139027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 4149027f4a0Smrg # always write the preprocessed file to stdout, regardless of -o. 4159027f4a0Smrg "$@" || exit $? 4169027f4a0Smrg 4179027f4a0Smrg # Remove the call to Libtool. 4189027f4a0Smrg if test "$libtool" = yes; then 4193a72f200Smrg while test "X$1" != 'X--mode=compile'; do 4209027f4a0Smrg shift 4219027f4a0Smrg done 4229027f4a0Smrg shift 4239027f4a0Smrg fi 4249027f4a0Smrg 4259027f4a0Smrg # Remove `-o $object'. 4269027f4a0Smrg IFS=" " 4279027f4a0Smrg for arg 4289027f4a0Smrg do 4299027f4a0Smrg case $arg in 4309027f4a0Smrg -o) 4319027f4a0Smrg shift 4329027f4a0Smrg ;; 4339027f4a0Smrg $object) 4349027f4a0Smrg shift 4359027f4a0Smrg ;; 4369027f4a0Smrg *) 4379027f4a0Smrg set fnord "$@" "$arg" 4389027f4a0Smrg shift # fnord 4399027f4a0Smrg shift # $arg 4409027f4a0Smrg ;; 4419027f4a0Smrg esac 4429027f4a0Smrg done 4439027f4a0Smrg 4449027f4a0Smrg test -z "$dashmflag" && dashmflag=-M 4459027f4a0Smrg # Require at least two characters before searching for `:' 4469027f4a0Smrg # in the target name. This is to cope with DOS-style filenames: 4479027f4a0Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4489027f4a0Smrg "$@" $dashmflag | 4499027f4a0Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4509027f4a0Smrg rm -f "$depfile" 4519027f4a0Smrg cat < "$tmpdepfile" > "$depfile" 4529027f4a0Smrg tr ' ' ' 4539027f4a0Smrg' < "$tmpdepfile" | \ 4549027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4559027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 4569027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4579027f4a0Smrg rm -f "$tmpdepfile" 4589027f4a0Smrg ;; 4599027f4a0Smrg 4609027f4a0SmrgdashXmstdout) 4619027f4a0Smrg # This case only exists to satisfy depend.m4. It is never actually 4629027f4a0Smrg # run, as this mode is specially recognized in the preamble. 4639027f4a0Smrg exit 1 4649027f4a0Smrg ;; 4659027f4a0Smrg 4669027f4a0Smrgmakedepend) 4679027f4a0Smrg "$@" || exit $? 4689027f4a0Smrg # Remove any Libtool call 4699027f4a0Smrg if test "$libtool" = yes; then 4703a72f200Smrg while test "X$1" != 'X--mode=compile'; do 4719027f4a0Smrg shift 4729027f4a0Smrg done 4739027f4a0Smrg shift 4749027f4a0Smrg fi 4759027f4a0Smrg # X makedepend 4769027f4a0Smrg shift 4773a72f200Smrg cleared=no eat=no 4783a72f200Smrg for arg 4793a72f200Smrg do 4809027f4a0Smrg case $cleared in 4819027f4a0Smrg no) 4829027f4a0Smrg set ""; shift 4839027f4a0Smrg cleared=yes ;; 4849027f4a0Smrg esac 4853a72f200Smrg if test $eat = yes; then 4863a72f200Smrg eat=no 4873a72f200Smrg continue 4883a72f200Smrg fi 4899027f4a0Smrg case "$arg" in 4909027f4a0Smrg -D*|-I*) 4919027f4a0Smrg set fnord "$@" "$arg"; shift ;; 4929027f4a0Smrg # Strip any option that makedepend may not understand. Remove 4939027f4a0Smrg # the object too, otherwise makedepend will parse it as a source file. 4943a72f200Smrg -arch) 4953a72f200Smrg eat=yes ;; 4969027f4a0Smrg -*|$object) 4979027f4a0Smrg ;; 4989027f4a0Smrg *) 4999027f4a0Smrg set fnord "$@" "$arg"; shift ;; 5009027f4a0Smrg esac 5019027f4a0Smrg done 5023a72f200Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 5039027f4a0Smrg touch "$tmpdepfile" 5049027f4a0Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 5059027f4a0Smrg rm -f "$depfile" 5069027f4a0Smrg cat < "$tmpdepfile" > "$depfile" 5079027f4a0Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 5089027f4a0Smrg' | \ 5099027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 5109027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 5119027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 5129027f4a0Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 5139027f4a0Smrg ;; 5149027f4a0Smrg 5159027f4a0Smrgcpp) 5169027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 5179027f4a0Smrg # always write the preprocessed file to stdout. 5189027f4a0Smrg "$@" || exit $? 5199027f4a0Smrg 5209027f4a0Smrg # Remove the call to Libtool. 5219027f4a0Smrg if test "$libtool" = yes; then 5223a72f200Smrg while test "X$1" != 'X--mode=compile'; do 5239027f4a0Smrg shift 5249027f4a0Smrg done 5259027f4a0Smrg shift 5269027f4a0Smrg fi 5279027f4a0Smrg 5289027f4a0Smrg # Remove `-o $object'. 5299027f4a0Smrg IFS=" " 5309027f4a0Smrg for arg 5319027f4a0Smrg do 5329027f4a0Smrg case $arg in 5339027f4a0Smrg -o) 5349027f4a0Smrg shift 5359027f4a0Smrg ;; 5369027f4a0Smrg $object) 5379027f4a0Smrg shift 5389027f4a0Smrg ;; 5399027f4a0Smrg *) 5409027f4a0Smrg set fnord "$@" "$arg" 5419027f4a0Smrg shift # fnord 5429027f4a0Smrg shift # $arg 5439027f4a0Smrg ;; 5449027f4a0Smrg esac 5459027f4a0Smrg done 5469027f4a0Smrg 5479027f4a0Smrg "$@" -E | 5489027f4a0Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5499027f4a0Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5509027f4a0Smrg sed '$ s: \\$::' > "$tmpdepfile" 5519027f4a0Smrg rm -f "$depfile" 5529027f4a0Smrg echo "$object : \\" > "$depfile" 5539027f4a0Smrg cat < "$tmpdepfile" >> "$depfile" 5549027f4a0Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5559027f4a0Smrg rm -f "$tmpdepfile" 5569027f4a0Smrg ;; 5579027f4a0Smrg 5589027f4a0Smrgmsvisualcpp) 5599027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 5603a72f200Smrg # always write the preprocessed file to stdout. 5619027f4a0Smrg "$@" || exit $? 5623a72f200Smrg 5633a72f200Smrg # Remove the call to Libtool. 5643a72f200Smrg if test "$libtool" = yes; then 5653a72f200Smrg while test "X$1" != 'X--mode=compile'; do 5663a72f200Smrg shift 5673a72f200Smrg done 5683a72f200Smrg shift 5693a72f200Smrg fi 5703a72f200Smrg 5719027f4a0Smrg IFS=" " 5729027f4a0Smrg for arg 5739027f4a0Smrg do 5749027f4a0Smrg case "$arg" in 5753a72f200Smrg -o) 5763a72f200Smrg shift 5773a72f200Smrg ;; 5783a72f200Smrg $object) 5793a72f200Smrg shift 5803a72f200Smrg ;; 5819027f4a0Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5829027f4a0Smrg set fnord "$@" 5839027f4a0Smrg shift 5849027f4a0Smrg shift 5859027f4a0Smrg ;; 5869027f4a0Smrg *) 5879027f4a0Smrg set fnord "$@" "$arg" 5889027f4a0Smrg shift 5899027f4a0Smrg shift 5909027f4a0Smrg ;; 5919027f4a0Smrg esac 5929027f4a0Smrg done 5933a72f200Smrg "$@" -E 2>/dev/null | 5943a72f200Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 5959027f4a0Smrg rm -f "$depfile" 5969027f4a0Smrg echo "$object : \\" > "$depfile" 5973a72f200Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5989027f4a0Smrg echo " " >> "$depfile" 5993a72f200Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 6009027f4a0Smrg rm -f "$tmpdepfile" 6019027f4a0Smrg ;; 6029027f4a0Smrg 6033a72f200Smrgmsvcmsys) 6043a72f200Smrg # This case exists only to let depend.m4 do its work. It works by 6053a72f200Smrg # looking at the text of this script. This case will never be run, 6063a72f200Smrg # since it is checked for above. 6073a72f200Smrg exit 1 6083a72f200Smrg ;; 6093a72f200Smrg 6109027f4a0Smrgnone) 6119027f4a0Smrg exec "$@" 6129027f4a0Smrg ;; 6139027f4a0Smrg 6149027f4a0Smrg*) 6159027f4a0Smrg echo "Unknown depmode $depmode" 1>&2 6169027f4a0Smrg exit 1 6179027f4a0Smrg ;; 6189027f4a0Smrgesac 6199027f4a0Smrg 6209027f4a0Smrgexit 0 6219027f4a0Smrg 6229027f4a0Smrg# Local Variables: 6239027f4a0Smrg# mode: shell-script 6249027f4a0Smrg# sh-indentation: 2 6259027f4a0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6269027f4a0Smrg# time-stamp-start: "scriptversion=" 6279027f4a0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6283a72f200Smrg# time-stamp-time-zone: "UTC" 6293a72f200Smrg# time-stamp-end: "; # UTC" 6309027f4a0Smrg# End: 631