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