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