depcomp revision 1.1
11.1Spooka#! /bin/sh 21.1Spooka# depcomp - compile a program generating dependencies as side-effects 31.1Spooka 41.1Spookascriptversion=2013-05-30.07; # UTC 51.1Spooka 61.1Spooka# Copyright (C) 1999-2013 Free Software Foundation, Inc. 71.1Spooka 81.1Spooka# This program is free software; you can redistribute it and/or modify 91.1Spooka# it under the terms of the GNU General Public License as published by 101.1Spooka# the Free Software Foundation; either version 2, or (at your option) 111.1Spooka# any later version. 121.1Spooka 131.1Spooka# This program is distributed in the hope that it will be useful, 141.1Spooka# but WITHOUT ANY WARRANTY; without even the implied warranty of 151.1Spooka# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 161.1Spooka# GNU General Public License for more details. 171.1Spooka 181.1Spooka# You should have received a copy of the GNU General Public License 191.1Spooka# along with this program. If not, see <http://www.gnu.org/licenses/>. 201.1Spooka 211.1Spooka# As a special exception to the GNU General Public License, if you 221.1Spooka# distribute this file as part of a program that contains a 231.1Spooka# configuration script generated by Autoconf, you may include it under 241.1Spooka# the same distribution terms that you use for the rest of that program. 251.1Spooka 261.1Spooka# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 271.1Spooka 281.1Spookacase $1 in 291.1Spooka '') 301.1Spooka echo "$0: No command. Try '$0 --help' for more information." 1>&2 311.1Spooka exit 1; 321.1Spooka ;; 331.1Spooka -h | --h*) 341.1Spooka cat <<\EOF 351.1SpookaUsage: depcomp [--help] [--version] PROGRAM [ARGS] 361.1Spooka 371.1SpookaRun PROGRAMS ARGS to compile a file, generating dependencies 381.1Spookaas side-effects. 391.1Spooka 401.1SpookaEnvironment variables: 411.1Spooka depmode Dependency tracking mode. 421.1Spooka source Source file read by 'PROGRAMS ARGS'. 431.1Spooka object Object file output by 'PROGRAMS ARGS'. 441.1Spooka DEPDIR directory where to store dependencies. 451.1Spooka depfile Dependency file to output. 461.1Spooka tmpdepfile Temporary file to use when outputting dependencies. 471.1Spooka libtool Whether libtool is used (yes/no). 481.1Spooka 491.1SpookaReport bugs to <bug-automake@gnu.org>. 501.1SpookaEOF 511.1Spooka exit $? 521.1Spooka ;; 531.1Spooka -v | --v*) 541.1Spooka echo "depcomp $scriptversion" 551.1Spooka exit $? 561.1Spooka ;; 571.1Spookaesac 581.1Spooka 591.1Spooka# Get the directory component of the given path, and save it in the 601.1Spooka# global variables '$dir'. Note that this directory component will 611.1Spooka# be either empty or ending with a '/' character. This is deliberate. 621.1Spookaset_dir_from () 631.1Spooka{ 641.1Spooka case $1 in 651.1Spooka */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 661.1Spooka *) dir=;; 671.1Spooka esac 681.1Spooka} 691.1Spooka 701.1Spooka# Get the suffix-stripped basename of the given path, and save it the 711.1Spooka# global variable '$base'. 721.1Spookaset_base_from () 731.1Spooka{ 741.1Spooka base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 751.1Spooka} 761.1Spooka 771.1Spooka# If no dependency file was actually created by the compiler invocation, 781.1Spooka# we still have to create a dummy depfile, to avoid errors with the 791.1Spooka# Makefile "include basename.Plo" scheme. 801.1Spookamake_dummy_depfile () 811.1Spooka{ 821.1Spooka echo "#dummy" > "$depfile" 831.1Spooka} 841.1Spooka 851.1Spooka# Factor out some common post-processing of the generated depfile. 861.1Spooka# Requires the auxiliary global variable '$tmpdepfile' to be set. 871.1Spookaaix_post_process_depfile () 881.1Spooka{ 891.1Spooka # If the compiler actually managed to produce a dependency file, 901.1Spooka # post-process it. 911.1Spooka if test -f "$tmpdepfile"; then 921.1Spooka # Each line is of the form 'foo.o: dependency.h'. 931.1Spooka # Do two passes, one to just change these to 941.1Spooka # $object: dependency.h 951.1Spooka # and one to simply output 961.1Spooka # dependency.h: 971.1Spooka # which is needed to avoid the deleted-header problem. 981.1Spooka { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 991.1Spooka sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 1001.1Spooka } > "$depfile" 1011.1Spooka rm -f "$tmpdepfile" 1021.1Spooka else 1031.1Spooka make_dummy_depfile 1041.1Spooka fi 1051.1Spooka} 1061.1Spooka 1071.1Spooka# A tabulation character. 1081.1Spookatab=' ' 1091.1Spooka# A newline character. 1101.1Spookanl=' 1111.1Spooka' 1121.1Spooka# Character ranges might be problematic outside the C locale. 1131.1Spooka# These definitions help. 1141.1Spookaupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 1151.1Spookalower=abcdefghijklmnopqrstuvwxyz 1161.1Spookadigits=0123456789 1171.1Spookaalpha=${upper}${lower} 1181.1Spooka 1191.1Spookaif test -z "$depmode" || test -z "$source" || test -z "$object"; then 1201.1Spooka echo "depcomp: Variables source, object and depmode must be set" 1>&2 1211.1Spooka exit 1 1221.1Spookafi 1231.1Spooka 1241.1Spooka# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 1251.1Spookadepfile=${depfile-`echo "$object" | 1261.1Spooka sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 1271.1Spookatmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 1281.1Spooka 1291.1Spookarm -f "$tmpdepfile" 1301.1Spooka 1311.1Spooka# Avoid interferences from the environment. 1321.1Spookagccflag= dashmflag= 1331.1Spooka 1341.1Spooka# Some modes work just like other modes, but use different flags. We 1351.1Spooka# parameterize here, but still list the modes in the big case below, 1361.1Spooka# to make depend.m4 easier to write. Note that we *cannot* use a case 1371.1Spooka# here, because this file can only contain one case statement. 1381.1Spookaif test "$depmode" = hp; then 1391.1Spooka # HP compiler uses -M and no extra arg. 1401.1Spooka gccflag=-M 1411.1Spooka depmode=gcc 1421.1Spookafi 1431.1Spooka 1441.1Spookaif test "$depmode" = dashXmstdout; then 1451.1Spooka # This is just like dashmstdout with a different argument. 1461.1Spooka dashmflag=-xM 1471.1Spooka depmode=dashmstdout 1481.1Spookafi 1491.1Spooka 1501.1Spookacygpath_u="cygpath -u -f -" 1511.1Spookaif test "$depmode" = msvcmsys; then 1521.1Spooka # This is just like msvisualcpp but w/o cygpath translation. 1531.1Spooka # Just convert the backslash-escaped backslashes to single forward 1541.1Spooka # slashes to satisfy depend.m4 1551.1Spooka cygpath_u='sed s,\\\\,/,g' 1561.1Spooka depmode=msvisualcpp 1571.1Spookafi 1581.1Spooka 1591.1Spookaif test "$depmode" = msvc7msys; then 1601.1Spooka # This is just like msvc7 but w/o cygpath translation. 1611.1Spooka # Just convert the backslash-escaped backslashes to single forward 1621.1Spooka # slashes to satisfy depend.m4 1631.1Spooka cygpath_u='sed s,\\\\,/,g' 1641.1Spooka depmode=msvc7 1651.1Spookafi 1661.1Spooka 1671.1Spookaif test "$depmode" = xlc; then 1681.1Spooka # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 1691.1Spooka gccflag=-qmakedep=gcc,-MF 1701.1Spooka depmode=gcc 1711.1Spookafi 1721.1Spooka 1731.1Spookacase "$depmode" in 1741.1Spookagcc3) 1751.1Spooka## gcc 3 implements dependency tracking that does exactly what 1761.1Spooka## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1771.1Spooka## it if -MD -MP comes after the -MF stuff. Hmm. 1781.1Spooka## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1791.1Spooka## the command line argument order; so add the flags where they 1801.1Spooka## appear in depend2.am. Note that the slowdown incurred here 1811.1Spooka## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1821.1Spooka for arg 1831.1Spooka do 1841.1Spooka case $arg in 1851.1Spooka -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1861.1Spooka *) set fnord "$@" "$arg" ;; 1871.1Spooka esac 1881.1Spooka shift # fnord 1891.1Spooka shift # $arg 1901.1Spooka done 1911.1Spooka "$@" 1921.1Spooka stat=$? 1931.1Spooka if test $stat -ne 0; then 1941.1Spooka rm -f "$tmpdepfile" 1951.1Spooka exit $stat 1961.1Spooka fi 1971.1Spooka mv "$tmpdepfile" "$depfile" 1981.1Spooka ;; 1991.1Spooka 2001.1Spookagcc) 2011.1Spooka## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 2021.1Spooka## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 2031.1Spooka## (see the conditional assignment to $gccflag above). 2041.1Spooka## There are various ways to get dependency output from gcc. Here's 2051.1Spooka## why we pick this rather obscure method: 2061.1Spooka## - Don't want to use -MD because we'd like the dependencies to end 2071.1Spooka## up in a subdir. Having to rename by hand is ugly. 2081.1Spooka## (We might end up doing this anyway to support other compilers.) 2091.1Spooka## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 2101.1Spooka## -MM, not -M (despite what the docs say). Also, it might not be 2111.1Spooka## supported by the other compilers which use the 'gcc' depmode. 2121.1Spooka## - Using -M directly means running the compiler twice (even worse 2131.1Spooka## than renaming). 2141.1Spooka if test -z "$gccflag"; then 2151.1Spooka gccflag=-MD, 2161.1Spooka fi 2171.1Spooka "$@" -Wp,"$gccflag$tmpdepfile" 2181.1Spooka stat=$? 2191.1Spooka if test $stat -ne 0; then 2201.1Spooka rm -f "$tmpdepfile" 2211.1Spooka exit $stat 2221.1Spooka fi 2231.1Spooka rm -f "$depfile" 2241.1Spooka echo "$object : \\" > "$depfile" 2251.1Spooka # The second -e expression handles DOS-style file names with drive 2261.1Spooka # letters. 2271.1Spooka sed -e 's/^[^:]*: / /' \ 2281.1Spooka -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 2291.1Spooka## This next piece of magic avoids the "deleted header file" problem. 2301.1Spooka## The problem is that when a header file which appears in a .P file 2311.1Spooka## is deleted, the dependency causes make to die (because there is 2321.1Spooka## typically no way to rebuild the header). We avoid this by adding 2331.1Spooka## dummy dependencies for each header file. Too bad gcc doesn't do 2341.1Spooka## this for us directly. 2351.1Spooka## Some versions of gcc put a space before the ':'. On the theory 2361.1Spooka## that the space means something, we add a space to the output as 2371.1Spooka## well. hp depmode also adds that space, but also prefixes the VPATH 2381.1Spooka## to the object. Take care to not repeat it in the output. 2391.1Spooka## Some versions of the HPUX 10.20 sed can't process this invocation 2401.1Spooka## correctly. Breaking it into two sed invocations is a workaround. 2411.1Spooka tr ' ' "$nl" < "$tmpdepfile" \ 2421.1Spooka | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 2431.1Spooka | sed -e 's/$/ :/' >> "$depfile" 2441.1Spooka rm -f "$tmpdepfile" 2451.1Spooka ;; 2461.1Spooka 2471.1Spookahp) 2481.1Spooka # This case exists only to let depend.m4 do its work. It works by 2491.1Spooka # looking at the text of this script. This case will never be run, 2501.1Spooka # since it is checked for above. 2511.1Spooka exit 1 2521.1Spooka ;; 2531.1Spooka 2541.1Spookasgi) 2551.1Spooka if test "$libtool" = yes; then 2561.1Spooka "$@" "-Wp,-MDupdate,$tmpdepfile" 2571.1Spooka else 2581.1Spooka "$@" -MDupdate "$tmpdepfile" 2591.1Spooka fi 2601.1Spooka stat=$? 2611.1Spooka if test $stat -ne 0; then 2621.1Spooka rm -f "$tmpdepfile" 2631.1Spooka exit $stat 2641.1Spooka fi 2651.1Spooka rm -f "$depfile" 2661.1Spooka 2671.1Spooka if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 2681.1Spooka echo "$object : \\" > "$depfile" 2691.1Spooka # Clip off the initial element (the dependent). Don't try to be 2701.1Spooka # clever and replace this with sed code, as IRIX sed won't handle 2711.1Spooka # lines with more than a fixed number of characters (4096 in 2721.1Spooka # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 2731.1Spooka # the IRIX cc adds comments like '#:fec' to the end of the 2741.1Spooka # dependency line. 2751.1Spooka tr ' ' "$nl" < "$tmpdepfile" \ 2761.1Spooka | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 2771.1Spooka | tr "$nl" ' ' >> "$depfile" 2781.1Spooka echo >> "$depfile" 2791.1Spooka # The second pass generates a dummy entry for each header file. 2801.1Spooka tr ' ' "$nl" < "$tmpdepfile" \ 2811.1Spooka | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2821.1Spooka >> "$depfile" 2831.1Spooka else 2841.1Spooka make_dummy_depfile 2851.1Spooka fi 2861.1Spooka rm -f "$tmpdepfile" 2871.1Spooka ;; 2881.1Spooka 2891.1Spookaxlc) 2901.1Spooka # This case exists only to let depend.m4 do its work. It works by 2911.1Spooka # looking at the text of this script. This case will never be run, 2921.1Spooka # since it is checked for above. 2931.1Spooka exit 1 2941.1Spooka ;; 2951.1Spooka 2961.1Spookaaix) 2971.1Spooka # The C for AIX Compiler uses -M and outputs the dependencies 2981.1Spooka # in a .u file. In older versions, this file always lives in the 2991.1Spooka # current directory. Also, the AIX compiler puts '$object:' at the 3001.1Spooka # start of each line; $object doesn't have directory information. 3011.1Spooka # Version 6 uses the directory in both cases. 3021.1Spooka set_dir_from "$object" 3031.1Spooka set_base_from "$object" 3041.1Spooka if test "$libtool" = yes; then 3051.1Spooka tmpdepfile1=$dir$base.u 3061.1Spooka tmpdepfile2=$base.u 3071.1Spooka tmpdepfile3=$dir.libs/$base.u 3081.1Spooka "$@" -Wc,-M 3091.1Spooka else 3101.1Spooka tmpdepfile1=$dir$base.u 3111.1Spooka tmpdepfile2=$dir$base.u 3121.1Spooka tmpdepfile3=$dir$base.u 3131.1Spooka "$@" -M 3141.1Spooka fi 3151.1Spooka stat=$? 3161.1Spooka if test $stat -ne 0; then 3171.1Spooka rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3181.1Spooka exit $stat 3191.1Spooka fi 3201.1Spooka 3211.1Spooka for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3221.1Spooka do 3231.1Spooka test -f "$tmpdepfile" && break 3241.1Spooka done 3251.1Spooka aix_post_process_depfile 3261.1Spooka ;; 3271.1Spooka 3281.1Spookatcc) 3291.1Spooka # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 3301.1Spooka # FIXME: That version still under development at the moment of writing. 3311.1Spooka # Make that this statement remains true also for stable, released 3321.1Spooka # versions. 3331.1Spooka # It will wrap lines (doesn't matter whether long or short) with a 3341.1Spooka # trailing '\', as in: 3351.1Spooka # 3361.1Spooka # foo.o : \ 3371.1Spooka # foo.c \ 3381.1Spooka # foo.h \ 3391.1Spooka # 3401.1Spooka # It will put a trailing '\' even on the last line, and will use leading 3411.1Spooka # spaces rather than leading tabs (at least since its commit 0394caf7 3421.1Spooka # "Emit spaces for -MD"). 3431.1Spooka "$@" -MD -MF "$tmpdepfile" 3441.1Spooka stat=$? 3451.1Spooka if test $stat -ne 0; then 3461.1Spooka rm -f "$tmpdepfile" 3471.1Spooka exit $stat 3481.1Spooka fi 3491.1Spooka rm -f "$depfile" 3501.1Spooka # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 3511.1Spooka # We have to change lines of the first kind to '$object: \'. 3521.1Spooka sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 3531.1Spooka # And for each line of the second kind, we have to emit a 'dep.h:' 3541.1Spooka # dummy dependency, to avoid the deleted-header problem. 3551.1Spooka sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 3561.1Spooka rm -f "$tmpdepfile" 3571.1Spooka ;; 3581.1Spooka 3591.1Spooka## The order of this option in the case statement is important, since the 3601.1Spooka## shell code in configure will try each of these formats in the order 3611.1Spooka## listed in this file. A plain '-MD' option would be understood by many 3621.1Spooka## compilers, so we must ensure this comes after the gcc and icc options. 3631.1Spookapgcc) 3641.1Spooka # Portland's C compiler understands '-MD'. 3651.1Spooka # Will always output deps to 'file.d' where file is the root name of the 3661.1Spooka # source file under compilation, even if file resides in a subdirectory. 3671.1Spooka # The object file name does not affect the name of the '.d' file. 3681.1Spooka # pgcc 10.2 will output 3691.1Spooka # foo.o: sub/foo.c sub/foo.h 3701.1Spooka # and will wrap long lines using '\' : 3711.1Spooka # foo.o: sub/foo.c ... \ 3721.1Spooka # sub/foo.h ... \ 3731.1Spooka # ... 3741.1Spooka set_dir_from "$object" 3751.1Spooka # Use the source, not the object, to determine the base name, since 3761.1Spooka # that's sadly what pgcc will do too. 3771.1Spooka set_base_from "$source" 3781.1Spooka tmpdepfile=$base.d 3791.1Spooka 3801.1Spooka # For projects that build the same source file twice into different object 3811.1Spooka # files, the pgcc approach of using the *source* file root name can cause 3821.1Spooka # problems in parallel builds. Use a locking strategy to avoid stomping on 3831.1Spooka # the same $tmpdepfile. 3841.1Spooka lockdir=$base.d-lock 3851.1Spooka trap " 3861.1Spooka echo '$0: caught signal, cleaning up...' >&2 3871.1Spooka rmdir '$lockdir' 3881.1Spooka exit 1 3891.1Spooka " 1 2 13 15 3901.1Spooka numtries=100 3911.1Spooka i=$numtries 3921.1Spooka while test $i -gt 0; do 3931.1Spooka # mkdir is a portable test-and-set. 3941.1Spooka if mkdir "$lockdir" 2>/dev/null; then 3951.1Spooka # This process acquired the lock. 3961.1Spooka "$@" -MD 3971.1Spooka stat=$? 3981.1Spooka # Release the lock. 3991.1Spooka rmdir "$lockdir" 4001.1Spooka break 4011.1Spooka else 4021.1Spooka # If the lock is being held by a different process, wait 4031.1Spooka # until the winning process is done or we timeout. 4041.1Spooka while test -d "$lockdir" && test $i -gt 0; do 4051.1Spooka sleep 1 4061.1Spooka i=`expr $i - 1` 4071.1Spooka done 4081.1Spooka fi 4091.1Spooka i=`expr $i - 1` 4101.1Spooka done 4111.1Spooka trap - 1 2 13 15 4121.1Spooka if test $i -le 0; then 4131.1Spooka echo "$0: failed to acquire lock after $numtries attempts" >&2 4141.1Spooka echo "$0: check lockdir '$lockdir'" >&2 4151.1Spooka exit 1 4161.1Spooka fi 4171.1Spooka 4181.1Spooka if test $stat -ne 0; then 4191.1Spooka rm -f "$tmpdepfile" 4201.1Spooka exit $stat 4211.1Spooka fi 4221.1Spooka rm -f "$depfile" 4231.1Spooka # Each line is of the form `foo.o: dependent.h', 4241.1Spooka # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 4251.1Spooka # Do two passes, one to just change these to 4261.1Spooka # `$object: dependent.h' and one to simply `dependent.h:'. 4271.1Spooka sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 4281.1Spooka # Some versions of the HPUX 10.20 sed can't process this invocation 4291.1Spooka # correctly. Breaking it into two sed invocations is a workaround. 4301.1Spooka sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 4311.1Spooka | sed -e 's/$/ :/' >> "$depfile" 4321.1Spooka rm -f "$tmpdepfile" 4331.1Spooka ;; 4341.1Spooka 4351.1Spookahp2) 4361.1Spooka # The "hp" stanza above does not work with aCC (C++) and HP's ia64 4371.1Spooka # compilers, which have integrated preprocessors. The correct option 4381.1Spooka # to use with these is +Maked; it writes dependencies to a file named 4391.1Spooka # 'foo.d', which lands next to the object file, wherever that 4401.1Spooka # happens to be. 4411.1Spooka # Much of this is similar to the tru64 case; see comments there. 4421.1Spooka set_dir_from "$object" 4431.1Spooka set_base_from "$object" 4441.1Spooka if test "$libtool" = yes; then 4451.1Spooka tmpdepfile1=$dir$base.d 4461.1Spooka tmpdepfile2=$dir.libs/$base.d 4471.1Spooka "$@" -Wc,+Maked 4481.1Spooka else 4491.1Spooka tmpdepfile1=$dir$base.d 4501.1Spooka tmpdepfile2=$dir$base.d 4511.1Spooka "$@" +Maked 4521.1Spooka fi 4531.1Spooka stat=$? 4541.1Spooka if test $stat -ne 0; then 4551.1Spooka rm -f "$tmpdepfile1" "$tmpdepfile2" 4561.1Spooka exit $stat 4571.1Spooka fi 4581.1Spooka 4591.1Spooka for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 4601.1Spooka do 4611.1Spooka test -f "$tmpdepfile" && break 4621.1Spooka done 4631.1Spooka if test -f "$tmpdepfile"; then 4641.1Spooka sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 4651.1Spooka # Add 'dependent.h:' lines. 4661.1Spooka sed -ne '2,${ 4671.1Spooka s/^ *// 4681.1Spooka s/ \\*$// 4691.1Spooka s/$/:/ 4701.1Spooka p 4711.1Spooka }' "$tmpdepfile" >> "$depfile" 4721.1Spooka else 4731.1Spooka make_dummy_depfile 4741.1Spooka fi 4751.1Spooka rm -f "$tmpdepfile" "$tmpdepfile2" 4761.1Spooka ;; 4771.1Spooka 4781.1Spookatru64) 4791.1Spooka # The Tru64 compiler uses -MD to generate dependencies as a side 4801.1Spooka # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 4811.1Spooka # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 4821.1Spooka # dependencies in 'foo.d' instead, so we check for that too. 4831.1Spooka # Subdirectories are respected. 4841.1Spooka set_dir_from "$object" 4851.1Spooka set_base_from "$object" 4861.1Spooka 4871.1Spooka if test "$libtool" = yes; then 4881.1Spooka # Libtool generates 2 separate objects for the 2 libraries. These 4891.1Spooka # two compilations output dependencies in $dir.libs/$base.o.d and 4901.1Spooka # in $dir$base.o.d. We have to check for both files, because 4911.1Spooka # one of the two compilations can be disabled. We should prefer 4921.1Spooka # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 4931.1Spooka # automatically cleaned when .libs/ is deleted, while ignoring 4941.1Spooka # the former would cause a distcleancheck panic. 4951.1Spooka tmpdepfile1=$dir$base.o.d # libtool 1.5 4961.1Spooka tmpdepfile2=$dir.libs/$base.o.d # Likewise. 4971.1Spooka tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 4981.1Spooka "$@" -Wc,-MD 4991.1Spooka else 5001.1Spooka tmpdepfile1=$dir$base.d 5011.1Spooka tmpdepfile2=$dir$base.d 5021.1Spooka tmpdepfile3=$dir$base.d 5031.1Spooka "$@" -MD 5041.1Spooka fi 5051.1Spooka 5061.1Spooka stat=$? 5071.1Spooka if test $stat -ne 0; then 5081.1Spooka rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5091.1Spooka exit $stat 5101.1Spooka fi 5111.1Spooka 5121.1Spooka for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5131.1Spooka do 5141.1Spooka test -f "$tmpdepfile" && break 5151.1Spooka done 5161.1Spooka # Same post-processing that is required for AIX mode. 5171.1Spooka aix_post_process_depfile 5181.1Spooka ;; 5191.1Spooka 5201.1Spookamsvc7) 5211.1Spooka if test "$libtool" = yes; then 5221.1Spooka showIncludes=-Wc,-showIncludes 5231.1Spooka else 5241.1Spooka showIncludes=-showIncludes 5251.1Spooka fi 5261.1Spooka "$@" $showIncludes > "$tmpdepfile" 5271.1Spooka stat=$? 5281.1Spooka grep -v '^Note: including file: ' "$tmpdepfile" 5291.1Spooka if test $stat -ne 0; then 5301.1Spooka rm -f "$tmpdepfile" 5311.1Spooka exit $stat 5321.1Spooka fi 5331.1Spooka rm -f "$depfile" 5341.1Spooka echo "$object : \\" > "$depfile" 5351.1Spooka # The first sed program below extracts the file names and escapes 5361.1Spooka # backslashes for cygpath. The second sed program outputs the file 5371.1Spooka # name when reading, but also accumulates all include files in the 5381.1Spooka # hold buffer in order to output them again at the end. This only 5391.1Spooka # works with sed implementations that can handle large buffers. 5401.1Spooka sed < "$tmpdepfile" -n ' 5411.1Spooka/^Note: including file: *\(.*\)/ { 5421.1Spooka s//\1/ 5431.1Spooka s/\\/\\\\/g 5441.1Spooka p 5451.1Spooka}' | $cygpath_u | sort -u | sed -n ' 5461.1Spookas/ /\\ /g 5471.1Spookas/\(.*\)/'"$tab"'\1 \\/p 5481.1Spookas/.\(.*\) \\/\1:/ 5491.1SpookaH 5501.1Spooka$ { 5511.1Spooka s/.*/'"$tab"'/ 5521.1Spooka G 5531.1Spooka p 5541.1Spooka}' >> "$depfile" 5551.1Spooka echo >> "$depfile" # make sure the fragment doesn't end with a backslash 5561.1Spooka rm -f "$tmpdepfile" 5571.1Spooka ;; 5581.1Spooka 5591.1Spookamsvc7msys) 5601.1Spooka # This case exists only to let depend.m4 do its work. It works by 5611.1Spooka # looking at the text of this script. This case will never be run, 5621.1Spooka # since it is checked for above. 5631.1Spooka exit 1 5641.1Spooka ;; 5651.1Spooka 5661.1Spooka#nosideeffect) 5671.1Spooka # This comment above is used by automake to tell side-effect 5681.1Spooka # dependency tracking mechanisms from slower ones. 5691.1Spooka 5701.1Spookadashmstdout) 5711.1Spooka # Important note: in order to support this mode, a compiler *must* 5721.1Spooka # always write the preprocessed file to stdout, regardless of -o. 5731.1Spooka "$@" || exit $? 5741.1Spooka 5751.1Spooka # Remove the call to Libtool. 5761.1Spooka if test "$libtool" = yes; then 5771.1Spooka while test "X$1" != 'X--mode=compile'; do 5781.1Spooka shift 5791.1Spooka done 5801.1Spooka shift 5811.1Spooka fi 5821.1Spooka 5831.1Spooka # Remove '-o $object'. 5841.1Spooka IFS=" " 5851.1Spooka for arg 5861.1Spooka do 5871.1Spooka case $arg in 5881.1Spooka -o) 5891.1Spooka shift 5901.1Spooka ;; 5911.1Spooka $object) 5921.1Spooka shift 5931.1Spooka ;; 5941.1Spooka *) 5951.1Spooka set fnord "$@" "$arg" 5961.1Spooka shift # fnord 5971.1Spooka shift # $arg 5981.1Spooka ;; 5991.1Spooka esac 6001.1Spooka done 6011.1Spooka 6021.1Spooka test -z "$dashmflag" && dashmflag=-M 6031.1Spooka # Require at least two characters before searching for ':' 6041.1Spooka # in the target name. This is to cope with DOS-style filenames: 6051.1Spooka # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 6061.1Spooka "$@" $dashmflag | 6071.1Spooka sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 6081.1Spooka rm -f "$depfile" 6091.1Spooka cat < "$tmpdepfile" > "$depfile" 6101.1Spooka # Some versions of the HPUX 10.20 sed can't process this sed invocation 6111.1Spooka # correctly. Breaking it into two sed invocations is a workaround. 6121.1Spooka tr ' ' "$nl" < "$tmpdepfile" \ 6131.1Spooka | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 6141.1Spooka | sed -e 's/$/ :/' >> "$depfile" 6151.1Spooka rm -f "$tmpdepfile" 6161.1Spooka ;; 6171.1Spooka 6181.1SpookadashXmstdout) 6191.1Spooka # This case only exists to satisfy depend.m4. It is never actually 6201.1Spooka # run, as this mode is specially recognized in the preamble. 6211.1Spooka exit 1 6221.1Spooka ;; 6231.1Spooka 6241.1Spookamakedepend) 6251.1Spooka "$@" || exit $? 6261.1Spooka # Remove any Libtool call 6271.1Spooka if test "$libtool" = yes; then 6281.1Spooka while test "X$1" != 'X--mode=compile'; do 6291.1Spooka shift 6301.1Spooka done 6311.1Spooka shift 6321.1Spooka fi 6331.1Spooka # X makedepend 6341.1Spooka shift 6351.1Spooka cleared=no eat=no 6361.1Spooka for arg 6371.1Spooka do 6381.1Spooka case $cleared in 6391.1Spooka no) 6401.1Spooka set ""; shift 6411.1Spooka cleared=yes ;; 6421.1Spooka esac 6431.1Spooka if test $eat = yes; then 6441.1Spooka eat=no 6451.1Spooka continue 6461.1Spooka fi 6471.1Spooka case "$arg" in 6481.1Spooka -D*|-I*) 6491.1Spooka set fnord "$@" "$arg"; shift ;; 6501.1Spooka # Strip any option that makedepend may not understand. Remove 6511.1Spooka # the object too, otherwise makedepend will parse it as a source file. 6521.1Spooka -arch) 6531.1Spooka eat=yes ;; 6541.1Spooka -*|$object) 6551.1Spooka ;; 6561.1Spooka *) 6571.1Spooka set fnord "$@" "$arg"; shift ;; 6581.1Spooka esac 6591.1Spooka done 6601.1Spooka obj_suffix=`echo "$object" | sed 's/^.*\././'` 6611.1Spooka touch "$tmpdepfile" 6621.1Spooka ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 6631.1Spooka rm -f "$depfile" 6641.1Spooka # makedepend may prepend the VPATH from the source file name to the object. 6651.1Spooka # No need to regex-escape $object, excess matching of '.' is harmless. 6661.1Spooka sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 6671.1Spooka # Some versions of the HPUX 10.20 sed can't process the last invocation 6681.1Spooka # correctly. Breaking it into two sed invocations is a workaround. 6691.1Spooka sed '1,2d' "$tmpdepfile" \ 6701.1Spooka | tr ' ' "$nl" \ 6711.1Spooka | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 6721.1Spooka | sed -e 's/$/ :/' >> "$depfile" 6731.1Spooka rm -f "$tmpdepfile" "$tmpdepfile".bak 6741.1Spooka ;; 6751.1Spooka 6761.1Spookacpp) 6771.1Spooka # Important note: in order to support this mode, a compiler *must* 6781.1Spooka # always write the preprocessed file to stdout. 6791.1Spooka "$@" || exit $? 6801.1Spooka 6811.1Spooka # Remove the call to Libtool. 6821.1Spooka if test "$libtool" = yes; then 6831.1Spooka while test "X$1" != 'X--mode=compile'; do 6841.1Spooka shift 6851.1Spooka done 6861.1Spooka shift 6871.1Spooka fi 6881.1Spooka 6891.1Spooka # Remove '-o $object'. 6901.1Spooka IFS=" " 6911.1Spooka for arg 6921.1Spooka do 6931.1Spooka case $arg in 6941.1Spooka -o) 6951.1Spooka shift 6961.1Spooka ;; 6971.1Spooka $object) 6981.1Spooka shift 6991.1Spooka ;; 7001.1Spooka *) 7011.1Spooka set fnord "$@" "$arg" 7021.1Spooka shift # fnord 7031.1Spooka shift # $arg 7041.1Spooka ;; 7051.1Spooka esac 7061.1Spooka done 7071.1Spooka 7081.1Spooka "$@" -E \ 7091.1Spooka | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 7101.1Spooka -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 7111.1Spooka | sed '$ s: \\$::' > "$tmpdepfile" 7121.1Spooka rm -f "$depfile" 7131.1Spooka echo "$object : \\" > "$depfile" 7141.1Spooka cat < "$tmpdepfile" >> "$depfile" 7151.1Spooka sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 7161.1Spooka rm -f "$tmpdepfile" 7171.1Spooka ;; 7181.1Spooka 7191.1Spookamsvisualcpp) 7201.1Spooka # Important note: in order to support this mode, a compiler *must* 7211.1Spooka # always write the preprocessed file to stdout. 7221.1Spooka "$@" || exit $? 7231.1Spooka 7241.1Spooka # Remove the call to Libtool. 7251.1Spooka if test "$libtool" = yes; then 7261.1Spooka while test "X$1" != 'X--mode=compile'; do 7271.1Spooka shift 7281.1Spooka done 7291.1Spooka shift 7301.1Spooka fi 7311.1Spooka 7321.1Spooka IFS=" " 7331.1Spooka for arg 7341.1Spooka do 7351.1Spooka case "$arg" in 7361.1Spooka -o) 7371.1Spooka shift 7381.1Spooka ;; 7391.1Spooka $object) 7401.1Spooka shift 7411.1Spooka ;; 7421.1Spooka "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 7431.1Spooka set fnord "$@" 7441.1Spooka shift 7451.1Spooka shift 7461.1Spooka ;; 7471.1Spooka *) 7481.1Spooka set fnord "$@" "$arg" 7491.1Spooka shift 7501.1Spooka shift 7511.1Spooka ;; 7521.1Spooka esac 7531.1Spooka done 7541.1Spooka "$@" -E 2>/dev/null | 7551.1Spooka sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 7561.1Spooka rm -f "$depfile" 7571.1Spooka echo "$object : \\" > "$depfile" 7581.1Spooka sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 7591.1Spooka echo "$tab" >> "$depfile" 7601.1Spooka sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 7611.1Spooka rm -f "$tmpdepfile" 7621.1Spooka ;; 7631.1Spooka 7641.1Spookamsvcmsys) 7651.1Spooka # This case exists only to let depend.m4 do its work. It works by 7661.1Spooka # looking at the text of this script. This case will never be run, 7671.1Spooka # since it is checked for above. 7681.1Spooka exit 1 7691.1Spooka ;; 7701.1Spooka 7711.1Spookanone) 7721.1Spooka exec "$@" 7731.1Spooka ;; 7741.1Spooka 7751.1Spooka*) 7761.1Spooka echo "Unknown depmode $depmode" 1>&2 7771.1Spooka exit 1 7781.1Spooka ;; 7791.1Spookaesac 7801.1Spooka 7811.1Spookaexit 0 7821.1Spooka 7831.1Spooka# Local Variables: 7841.1Spooka# mode: shell-script 7851.1Spooka# sh-indentation: 2 7861.1Spooka# eval: (add-hook 'write-file-hooks 'time-stamp) 7871.1Spooka# time-stamp-start: "scriptversion=" 7881.1Spooka# time-stamp-format: "%:y-%02m-%02d.%02H" 7891.1Spooka# time-stamp-time-zone: "UTC" 7901.1Spooka# time-stamp-end: "; # UTC" 7911.1Spooka# End: 792