depcomp revision 268515
155714Skris#! /bin/sh 255714Skris# depcomp - compile a program generating dependencies as side-effects 355714Skris 455714Skrisscriptversion=2013-05-30.07; # UTC 555714Skris 655714Skris# Copyright (C) 1999-2013 Free Software Foundation, Inc. 755714Skris 855714Skris# This program is free software; you can redistribute it and/or modify 955714Skris# it under the terms of the GNU General Public License as published by 1055714Skris# the Free Software Foundation; either version 2, or (at your option) 1155714Skris# any later version. 1255714Skris 1355714Skris# This program is distributed in the hope that it will be useful, 1455714Skris# but WITHOUT ANY WARRANTY; without even the implied warranty of 1555714Skris# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1655714Skris# GNU General Public License for more details. 1755714Skris 1855714Skris# You should have received a copy of the GNU General Public License 1955714Skris# along with this program. If not, see <http://www.gnu.org/licenses/>. 2055714Skris 2155714Skris# As a special exception to the GNU General Public License, if you 2255714Skris# distribute this file as part of a program that contains a 2355714Skris# configuration script generated by Autoconf, you may include it under 2455714Skris# the same distribution terms that you use for the rest of that program. 2555714Skris 2655714Skris# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2755714Skris 2855714Skriscase $1 in 2955714Skris '') 3055714Skris echo "$0: No command. Try '$0 --help' for more information." 1>&2 3155714Skris exit 1; 3255714Skris ;; 3355714Skris -h | --h*) 3455714Skris cat <<\EOF 3555714SkrisUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3655714Skris 3755714SkrisRun PROGRAMS ARGS to compile a file, generating dependencies 3855714Skrisas side-effects. 3955714Skris 4055714SkrisEnvironment variables: 4155714Skris depmode Dependency tracking mode. 4255714Skris source Source file read by 'PROGRAMS ARGS'. 4355714Skris object Object file output by 'PROGRAMS ARGS'. 4455714Skris DEPDIR directory where to store dependencies. 4555714Skris depfile Dependency file to output. 4655714Skris tmpdepfile Temporary file to use when outputting dependencies. 4755714Skris libtool Whether libtool is used (yes/no). 4855714Skris 4955714SkrisReport bugs to <bug-automake@gnu.org>. 5055714SkrisEOF 5155714Skris exit $? 5255714Skris ;; 5355714Skris -v | --v*) 5455714Skris echo "depcomp $scriptversion" 5555714Skris exit $? 5655714Skris ;; 5755714Skrisesac 5859191Skris 59109998Smarkm# Get the directory component of the given path, and save it in the 6059191Skris# global variables '$dir'. Note that this directory component will 6159191Skris# be either empty or ending with a '/' character. This is deliberate. 6259191Skrisset_dir_from () 6359191Skris{ 6459191Skris case $1 in 6559191Skris */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 6659191Skris *) dir=;; 6759191Skris esac 6859191Skris} 6959191Skris 7059191Skris# Get the suffix-stripped basename of the given path, and save it the 7159191Skris# global variable '$base'. 7259191Skrisset_base_from () 7359191Skris{ 7459191Skris base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 7559191Skris} 7659191Skris 7759191Skris# If no dependency file was actually created by the compiler invocation, 7859191Skris# we still have to create a dummy depfile, to avoid errors with the 7959191Skris# Makefile "include basename.Plo" scheme. 8059191Skrismake_dummy_depfile () 8159191Skris{ 8259191Skris echo "#dummy" > "$depfile" 8359191Skris} 8459191Skris 8559191Skris# Factor out some common post-processing of the generated depfile. 8659191Skris# Requires the auxiliary global variable '$tmpdepfile' to be set. 8759191Skrisaix_post_process_depfile () 8859191Skris{ 8959191Skris # If the compiler actually managed to produce a dependency file, 9059191Skris # post-process it. 9159191Skris if test -f "$tmpdepfile"; then 9259191Skris # Each line is of the form 'foo.o: dependency.h'. 9359191Skris # Do two passes, one to just change these to 9459191Skris # $object: dependency.h 9559191Skris # and one to simply output 9659191Skris # dependency.h: 9759191Skris # which is needed to avoid the deleted-header problem. 9859191Skris { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 9959191Skris sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 10059191Skris } > "$depfile" 10159191Skris rm -f "$tmpdepfile" 10259191Skris else 10359191Skris make_dummy_depfile 10459191Skris fi 10559191Skris} 10659191Skris 10759191Skris# A tabulation character. 10859191Skristab=' ' 10959191Skris# A newline character. 11059191Skrisnl=' 11155714Skris' 11255714Skris# Character ranges might be problematic outside the C locale. 11355714Skris# These definitions help. 11455714Skrisupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 11555714Skrislower=abcdefghijklmnopqrstuvwxyz 11655714Skrisdigits=0123456789 11755714Skrisalpha=${upper}${lower} 118160814Ssimon 119160814Ssimonif test -z "$depmode" || test -z "$source" || test -z "$object"; then 120160814Ssimon echo "depcomp: Variables source, object and depmode must be set" 1>&2 121160814Ssimon exit 1 122160814Ssimonfi 12359191Skris 12455714Skris# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 12555714Skrisdepfile=${depfile-`echo "$object" | 12655714Skris sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 12755714Skristmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 12855714Skris 12959191Skrisrm -f "$tmpdepfile" 13059191Skris 13155714Skris# Avoid interferences from the environment. 13255714Skrisgccflag= dashmflag= 133109998Smarkm 13459191Skris# Some modes work just like other modes, but use different flags. We 135109998Smarkm# parameterize here, but still list the modes in the big case below, 13659191Skris# to make depend.m4 easier to write. Note that we *cannot* use a case 137160814Ssimon# here, because this file can only contain one case statement. 13855714Skrisif test "$depmode" = hp; then 139160814Ssimon # HP compiler uses -M and no extra arg. 140160814Ssimon gccflag=-M 141160814Ssimon depmode=gcc 142160814Ssimonfi 143160814Ssimon 144160814Ssimonif test "$depmode" = dashXmstdout; then 145160814Ssimon # This is just like dashmstdout with a different argument. 146160814Ssimon dashmflag=-xM 147160814Ssimon depmode=dashmstdout 148160814Ssimonfi 149160814Ssimon 150160814Ssimoncygpath_u="cygpath -u -f -" 151160814Ssimonif test "$depmode" = msvcmsys; then 152160814Ssimon # This is just like msvisualcpp but w/o cygpath translation. 153160814Ssimon # Just convert the backslash-escaped backslashes to single forward 154160814Ssimon # slashes to satisfy depend.m4 155160814Ssimon cygpath_u='sed s,\\\\,/,g' 156160814Ssimon depmode=msvisualcpp 157160814Ssimonfi 158160814Ssimon 159160814Ssimonif test "$depmode" = msvc7msys; then 160160814Ssimon # This is just like msvc7 but w/o cygpath translation. 161160814Ssimon # Just convert the backslash-escaped backslashes to single forward 162160814Ssimon # slashes to satisfy depend.m4 16359191Skris cygpath_u='sed s,\\\\,/,g' 16455714Skris depmode=msvc7 16555714Skrisfi 16659191Skris 16755714Skrisif test "$depmode" = xlc; then 16855714Skris # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 16955714Skris gccflag=-qmakedep=gcc,-MF 170160814Ssimon depmode=gcc 171160814Ssimonfi 172160814Ssimon 17355714Skriscase "$depmode" in 17455714Skrisgcc3) 17555714Skris## gcc 3 implements dependency tracking that does exactly what 17655714Skris## we want. Yay! Note: for some reason libtool 1.4 doesn't like 177160814Ssimon## it if -MD -MP comes after the -MF stuff. Hmm. 17855714Skris## Unfortunately, FreeBSD c89 acceptance of flags depends upon 17955714Skris## the command line argument order; so add the flags where they 18055714Skris## appear in depend2.am. Note that the slowdown incurred here 18159191Skris## affects only configure: in makefiles, %FASTDEP% shortcuts this. 18255714Skris for arg 183160814Ssimon do 18455714Skris case $arg in 18555714Skris -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 18655714Skris *) set fnord "$@" "$arg" ;; 18755714Skris esac 188160814Ssimon shift # fnord 18955714Skris shift # $arg 19055714Skris done 19155714Skris "$@" 192160814Ssimon stat=$? 193160814Ssimon if test $stat -ne 0; then 194160814Ssimon rm -f "$tmpdepfile" 195160814Ssimon exit $stat 19655714Skris fi 19759191Skris mv "$tmpdepfile" "$depfile" 19855714Skris ;; 199160814Ssimon 20055714Skrisgcc) 20155714Skris## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 20255714Skris## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 20355714Skris## (see the conditional assignment to $gccflag above). 20455714Skris## There are various ways to get dependency output from gcc. Here's 20559191Skris## why we pick this rather obscure method: 20655714Skris## - Don't want to use -MD because we'd like the dependencies to end 20755714Skris## up in a subdir. Having to rename by hand is ugly. 20855714Skris## (We might end up doing this anyway to support other compilers.) 209160814Ssimon## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 21055714Skris## -MM, not -M (despite what the docs say). Also, it might not be 21159191Skris## supported by the other compilers which use the 'gcc' depmode. 21255714Skris## - Using -M directly means running the compiler twice (even worse 213160814Ssimon## than renaming). 21455714Skris if test -z "$gccflag"; then 21555714Skris gccflag=-MD, 21655714Skris fi 217160814Ssimon "$@" -Wp,"$gccflag$tmpdepfile" 21855714Skris stat=$? 21955714Skris if test $stat -ne 0; then 22055714Skris rm -f "$tmpdepfile" 221160814Ssimon exit $stat 222160814Ssimon fi 22359191Skris rm -f "$depfile" 22455714Skris echo "$object : \\" > "$depfile" 22555714Skris # The second -e expression handles DOS-style file names with drive 22655714Skris # letters. 22759191Skris sed -e 's/^[^:]*: / /' \ 22855714Skris -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229160814Ssimon## This next piece of magic avoids the "deleted header file" problem. 230160814Ssimon## The problem is that when a header file which appears in a .P file 231160814Ssimon## is deleted, the dependency causes make to die (because there is 232160814Ssimon## typically no way to rebuild the header). We avoid this by adding 233160814Ssimon## dummy dependencies for each header file. Too bad gcc doesn't do 234160814Ssimon## this for us directly. 235160814Ssimon## Some versions of gcc put a space before the ':'. On the theory 23655714Skris## that the space means something, we add a space to the output as 23755714Skris## well. hp depmode also adds that space, but also prefixes the VPATH 238160814Ssimon## to the object. Take care to not repeat it in the output. 23955714Skris## Some versions of the HPUX 10.20 sed can't process this invocation 240160814Ssimon## correctly. Breaking it into two sed invocations is a workaround. 24159191Skris tr ' ' "$nl" < "$tmpdepfile" \ 24255714Skris | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243160814Ssimon | sed -e 's/$/ :/' >> "$depfile" 244160814Ssimon rm -f "$tmpdepfile" 24559191Skris ;; 24659191Skris 24759191Skrishp) 24859191Skris # This case exists only to let depend.m4 do its work. It works by 24959191Skris # looking at the text of this script. This case will never be run, 25059191Skris # since it is checked for above. 25159191Skris exit 1 25259191Skris ;; 25389837Skris 25489837Skrissgi) 25589837Skris if test "$libtool" = yes; then 25659191Skris "$@" "-Wp,-MDupdate,$tmpdepfile" 25759191Skris else 25859191Skris "$@" -MDupdate "$tmpdepfile" 25959191Skris fi 26055714Skris stat=$? 261160814Ssimon if test $stat -ne 0; then 262160814Ssimon rm -f "$tmpdepfile" 26359191Skris exit $stat 26459191Skris fi 26559191Skris rm -f "$depfile" 26659191Skris 26759191Skris if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 268160814Ssimon echo "$object : \\" > "$depfile" 269160814Ssimon # Clip off the initial element (the dependent). Don't try to be 27059191Skris # clever and replace this with sed code, as IRIX sed won't handle 27159191Skris # lines with more than a fixed number of characters (4096 in 27255714Skris # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 27359191Skris # the IRIX cc adds comments like '#:fec' to the end of the 27455714Skris # dependency line. 27559191Skris tr ' ' "$nl" < "$tmpdepfile" \ 27659191Skris | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 27759191Skris | tr "$nl" ' ' >> "$depfile" 27855714Skris echo >> "$depfile" 27959191Skris # The second pass generates a dummy entry for each header file. 28059191Skris tr ' ' "$nl" < "$tmpdepfile" \ 28159191Skris | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 28259191Skris >> "$depfile" 28359191Skris else 28459191Skris make_dummy_depfile 28559191Skris fi 28659191Skris rm -f "$tmpdepfile" 28759191Skris ;; 28859191Skris 28959191Skrisxlc) 29059191Skris # This case exists only to let depend.m4 do its work. It works by 29159191Skris # looking at the text of this script. This case will never be run, 29259191Skris # since it is checked for above. 29359191Skris exit 1 29455714Skris ;; 29559191Skris 29659191Skrisaix) 29759191Skris # The C for AIX Compiler uses -M and outputs the dependencies 29859191Skris # in a .u file. In older versions, this file always lives in the 29959191Skris # current directory. Also, the AIX compiler puts '$object:' at the 30059191Skris # start of each line; $object doesn't have directory information. 30159191Skris # Version 6 uses the directory in both cases. 30259191Skris set_dir_from "$object" 30359191Skris set_base_from "$object" 30459191Skris if test "$libtool" = yes; then 30555714Skris tmpdepfile1=$dir$base.u 30659191Skris tmpdepfile2=$base.u 30759191Skris tmpdepfile3=$dir.libs/$base.u 30859191Skris "$@" -Wc,-M 30959191Skris else 31059191Skris tmpdepfile1=$dir$base.u 31159191Skris tmpdepfile2=$dir$base.u 31255714Skris tmpdepfile3=$dir$base.u 31359191Skris "$@" -M 31459191Skris fi 31559191Skris stat=$? 31659191Skris if test $stat -ne 0; then 31759191Skris rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 31859191Skris exit $stat 31959191Skris fi 32059191Skris 32155714Skris for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 32289837Skris do 32359191Skris test -f "$tmpdepfile" && break 32459191Skris done 32559191Skris aix_post_process_depfile 32659191Skris ;; 32759191Skris 32859191Skristcc) 32955714Skris # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 33055714Skris # FIXME: That version still under development at the moment of writing. 33155714Skris # Make that this statement remains true also for stable, released 33255714Skris # versions. 33355714Skris # It will wrap lines (doesn't matter whether long or short) with a 33455714Skris # trailing '\', as in: 335160814Ssimon # 336160814Ssimon # foo.o : \ 33755714Skris # foo.c \ 33855714Skris # foo.h \ 33955714Skris # 34059191Skris # It will put a trailing '\' even on the last line, and will use leading 34159191Skris # spaces rather than leading tabs (at least since its commit 0394caf7 34259191Skris # "Emit spaces for -MD"). 34359191Skris "$@" -MD -MF "$tmpdepfile" 34459191Skris stat=$? 34559191Skris if test $stat -ne 0; then 34659191Skris rm -f "$tmpdepfile" 34759191Skris exit $stat 34859191Skris fi 34955714Skris rm -f "$depfile" 35055714Skris # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 35155714Skris # We have to change lines of the first kind to '$object: \'. 35259191Skris sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 35359191Skris # And for each line of the second kind, we have to emit a 'dep.h:' 35455714Skris # dummy dependency, to avoid the deleted-header problem. 35559191Skris sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 35659191Skris rm -f "$tmpdepfile" 35759191Skris ;; 35859191Skris 35959191Skris## The order of this option in the case statement is important, since the 36059191Skris## shell code in configure will try each of these formats in the order 36159191Skris## listed in this file. A plain '-MD' option would be understood by many 36255714Skris## compilers, so we must ensure this comes after the gcc and icc options. 36359191Skrispgcc) 36459191Skris # Portland's C compiler understands '-MD'. 36559191Skris # Will always output deps to 'file.d' where file is the root name of the 36659191Skris # source file under compilation, even if file resides in a subdirectory. 36759191Skris # The object file name does not affect the name of the '.d' file. 36859191Skris # pgcc 10.2 will output 36959191Skris # foo.o: sub/foo.c sub/foo.h 37055714Skris # and will wrap long lines using '\' : 37159191Skris # foo.o: sub/foo.c ... \ 37259191Skris # sub/foo.h ... \ 373160814Ssimon # ... 37459191Skris set_dir_from "$object" 37555714Skris # Use the source, not the object, to determine the base name, since 37655714Skris # that's sadly what pgcc will do too. 37755714Skris set_base_from "$source" 37855714Skris tmpdepfile=$base.d 37955714Skris 380194206Ssimon # For projects that build the same source file twice into different object 381162911Ssimon # files, the pgcc approach of using the *source* file root name can cause 38255714Skris # problems in parallel builds. Use a locking strategy to avoid stomping on 38355714Skris # the same $tmpdepfile. 38455714Skris lockdir=$base.d-lock 38555714Skris trap " 38655714Skris echo '$0: caught signal, cleaning up...' >&2 387194206Ssimon rmdir '$lockdir' 388162911Ssimon exit 1 38955714Skris " 1 2 13 15 39055714Skris numtries=100 39155714Skris i=$numtries 39255714Skris while test $i -gt 0; do 39355714Skris # mkdir is a portable test-and-set. 39455714Skris if mkdir "$lockdir" 2>/dev/null; then 39555714Skris # This process acquired the lock. 39655714Skris "$@" -MD 397162911Ssimon stat=$? 39855714Skris # Release the lock. 39955714Skris rmdir "$lockdir" 40055714Skris break 40155714Skris else 402160814Ssimon # If the lock is being held by a different process, wait 40355714Skris # until the winning process is done or we timeout. 40455714Skris while test -d "$lockdir" && test $i -gt 0; do 40555714Skris sleep 1 406109998Smarkm i=`expr $i - 1` 407109998Smarkm done 40855714Skris fi 40955714Skris i=`expr $i - 1` 41055714Skris done 41155714Skris trap - 1 2 13 15 41259191Skris if test $i -le 0; then 41359191Skris echo "$0: failed to acquire lock after $numtries attempts" >&2 41455714Skris echo "$0: check lockdir '$lockdir'" >&2 41555714Skris exit 1 41655714Skris fi 41755714Skris 41855714Skris if test $stat -ne 0; then 41955714Skris rm -f "$tmpdepfile" 42055714Skris exit $stat 42155714Skris fi 42255714Skris rm -f "$depfile" 42355714Skris # Each line is of the form `foo.o: dependent.h', 42455714Skris # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 42555714Skris # Do two passes, one to just change these to 42655714Skris # `$object: dependent.h' and one to simply `dependent.h:'. 42755714Skris sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 42855714Skris # Some versions of the HPUX 10.20 sed can't process this invocation 42955714Skris # correctly. Breaking it into two sed invocations is a workaround. 43055714Skris sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 43155714Skris | sed -e 's/$/ :/' >> "$depfile" 43255714Skris rm -f "$tmpdepfile" 43355714Skris ;; 43455714Skris 43555714Skrishp2) 43655714Skris # The "hp" stanza above does not work with aCC (C++) and HP's ia64 43755714Skris # compilers, which have integrated preprocessors. The correct option 43855714Skris # to use with these is +Maked; it writes dependencies to a file named 43959191Skris # 'foo.d', which lands next to the object file, wherever that 440160814Ssimon # happens to be. 44155714Skris # Much of this is similar to the tru64 case; see comments there. 44255714Skris set_dir_from "$object" 44355714Skris set_base_from "$object" 444109998Smarkm if test "$libtool" = yes; then 445109998Smarkm tmpdepfile1=$dir$base.d 44655714Skris tmpdepfile2=$dir.libs/$base.d 44755714Skris "$@" -Wc,+Maked 44859191Skris else 44955714Skris tmpdepfile1=$dir$base.d 45055714Skris tmpdepfile2=$dir$base.d 45159191Skris "$@" +Maked 45259191Skris fi 45359191Skris stat=$? 45459191Skris if test $stat -ne 0; then 45559191Skris rm -f "$tmpdepfile1" "$tmpdepfile2" 45655714Skris exit $stat 45755714Skris fi 45855714Skris 45955714Skris for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 46055714Skris do 46155714Skris test -f "$tmpdepfile" && break 46255714Skris done 46355714Skris if test -f "$tmpdepfile"; then 46455714Skris sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 46555714Skris # Add 'dependent.h:' lines. 46655714Skris sed -ne '2,${ 46755714Skris s/^ *// 46855714Skris s/ \\*$// 46955714Skris s/$/:/ 47055714Skris p 47155714Skris }' "$tmpdepfile" >> "$depfile" 47255714Skris else 47355714Skris make_dummy_depfile 47455714Skris fi 47555714Skris rm -f "$tmpdepfile" "$tmpdepfile2" 47655714Skris ;; 47755714Skris 47855714Skristru64) 47955714Skris # The Tru64 compiler uses -MD to generate dependencies as a side 48055714Skris # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 48155714Skris # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 48255714Skris # dependencies in 'foo.d' instead, so we check for that too. 48355714Skris # Subdirectories are respected. 48455714Skris set_dir_from "$object" 48555714Skris set_base_from "$object" 48655714Skris 48755714Skris if test "$libtool" = yes; then 48855714Skris # Libtool generates 2 separate objects for the 2 libraries. These 48955714Skris # two compilations output dependencies in $dir.libs/$base.o.d and 49055714Skris # in $dir$base.o.d. We have to check for both files, because 49159191Skris # one of the two compilations can be disabled. We should prefer 492160814Ssimon # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 49355714Skris # automatically cleaned when .libs/ is deleted, while ignoring 49455714Skris # the former would cause a distcleancheck panic. 495 tmpdepfile1=$dir$base.o.d # libtool 1.5 496 tmpdepfile2=$dir.libs/$base.o.d # Likewise. 497 tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 498 "$@" -Wc,-MD 499 else 500 tmpdepfile1=$dir$base.d 501 tmpdepfile2=$dir$base.d 502 tmpdepfile3=$dir$base.d 503 "$@" -MD 504 fi 505 506 stat=$? 507 if test $stat -ne 0; then 508 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 509 exit $stat 510 fi 511 512 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 513 do 514 test -f "$tmpdepfile" && break 515 done 516 # Same post-processing that is required for AIX mode. 517 aix_post_process_depfile 518 ;; 519 520msvc7) 521 if test "$libtool" = yes; then 522 showIncludes=-Wc,-showIncludes 523 else 524 showIncludes=-showIncludes 525 fi 526 "$@" $showIncludes > "$tmpdepfile" 527 stat=$? 528 grep -v '^Note: including file: ' "$tmpdepfile" 529 if test $stat -ne 0; then 530 rm -f "$tmpdepfile" 531 exit $stat 532 fi 533 rm -f "$depfile" 534 echo "$object : \\" > "$depfile" 535 # The first sed program below extracts the file names and escapes 536 # backslashes for cygpath. The second sed program outputs the file 537 # name when reading, but also accumulates all include files in the 538 # hold buffer in order to output them again at the end. This only 539 # works with sed implementations that can handle large buffers. 540 sed < "$tmpdepfile" -n ' 541/^Note: including file: *\(.*\)/ { 542 s//\1/ 543 s/\\/\\\\/g 544 p 545}' | $cygpath_u | sort -u | sed -n ' 546s/ /\\ /g 547s/\(.*\)/'"$tab"'\1 \\/p 548s/.\(.*\) \\/\1:/ 549H 550$ { 551 s/.*/'"$tab"'/ 552 G 553 p 554}' >> "$depfile" 555 echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556 rm -f "$tmpdepfile" 557 ;; 558 559msvc7msys) 560 # This case exists only to let depend.m4 do its work. It works by 561 # looking at the text of this script. This case will never be run, 562 # since it is checked for above. 563 exit 1 564 ;; 565 566#nosideeffect) 567 # This comment above is used by automake to tell side-effect 568 # dependency tracking mechanisms from slower ones. 569 570dashmstdout) 571 # Important note: in order to support this mode, a compiler *must* 572 # always write the preprocessed file to stdout, regardless of -o. 573 "$@" || exit $? 574 575 # Remove the call to Libtool. 576 if test "$libtool" = yes; then 577 while test "X$1" != 'X--mode=compile'; do 578 shift 579 done 580 shift 581 fi 582 583 # Remove '-o $object'. 584 IFS=" " 585 for arg 586 do 587 case $arg in 588 -o) 589 shift 590 ;; 591 $object) 592 shift 593 ;; 594 *) 595 set fnord "$@" "$arg" 596 shift # fnord 597 shift # $arg 598 ;; 599 esac 600 done 601 602 test -z "$dashmflag" && dashmflag=-M 603 # Require at least two characters before searching for ':' 604 # in the target name. This is to cope with DOS-style filenames: 605 # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 606 "$@" $dashmflag | 607 sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 608 rm -f "$depfile" 609 cat < "$tmpdepfile" > "$depfile" 610 # Some versions of the HPUX 10.20 sed can't process this sed invocation 611 # correctly. Breaking it into two sed invocations is a workaround. 612 tr ' ' "$nl" < "$tmpdepfile" \ 613 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 614 | sed -e 's/$/ :/' >> "$depfile" 615 rm -f "$tmpdepfile" 616 ;; 617 618dashXmstdout) 619 # This case only exists to satisfy depend.m4. It is never actually 620 # run, as this mode is specially recognized in the preamble. 621 exit 1 622 ;; 623 624makedepend) 625 "$@" || exit $? 626 # Remove any Libtool call 627 if test "$libtool" = yes; then 628 while test "X$1" != 'X--mode=compile'; do 629 shift 630 done 631 shift 632 fi 633 # X makedepend 634 shift 635 cleared=no eat=no 636 for arg 637 do 638 case $cleared in 639 no) 640 set ""; shift 641 cleared=yes ;; 642 esac 643 if test $eat = yes; then 644 eat=no 645 continue 646 fi 647 case "$arg" in 648 -D*|-I*) 649 set fnord "$@" "$arg"; shift ;; 650 # Strip any option that makedepend may not understand. Remove 651 # the object too, otherwise makedepend will parse it as a source file. 652 -arch) 653 eat=yes ;; 654 -*|$object) 655 ;; 656 *) 657 set fnord "$@" "$arg"; shift ;; 658 esac 659 done 660 obj_suffix=`echo "$object" | sed 's/^.*\././'` 661 touch "$tmpdepfile" 662 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 663 rm -f "$depfile" 664 # makedepend may prepend the VPATH from the source file name to the object. 665 # No need to regex-escape $object, excess matching of '.' is harmless. 666 sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 667 # Some versions of the HPUX 10.20 sed can't process the last invocation 668 # correctly. Breaking it into two sed invocations is a workaround. 669 sed '1,2d' "$tmpdepfile" \ 670 | tr ' ' "$nl" \ 671 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 672 | sed -e 's/$/ :/' >> "$depfile" 673 rm -f "$tmpdepfile" "$tmpdepfile".bak 674 ;; 675 676cpp) 677 # Important note: in order to support this mode, a compiler *must* 678 # always write the preprocessed file to stdout. 679 "$@" || exit $? 680 681 # Remove the call to Libtool. 682 if test "$libtool" = yes; then 683 while test "X$1" != 'X--mode=compile'; do 684 shift 685 done 686 shift 687 fi 688 689 # Remove '-o $object'. 690 IFS=" " 691 for arg 692 do 693 case $arg in 694 -o) 695 shift 696 ;; 697 $object) 698 shift 699 ;; 700 *) 701 set fnord "$@" "$arg" 702 shift # fnord 703 shift # $arg 704 ;; 705 esac 706 done 707 708 "$@" -E \ 709 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 710 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 711 | sed '$ s: \\$::' > "$tmpdepfile" 712 rm -f "$depfile" 713 echo "$object : \\" > "$depfile" 714 cat < "$tmpdepfile" >> "$depfile" 715 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 716 rm -f "$tmpdepfile" 717 ;; 718 719msvisualcpp) 720 # Important note: in order to support this mode, a compiler *must* 721 # always write the preprocessed file to stdout. 722 "$@" || exit $? 723 724 # Remove the call to Libtool. 725 if test "$libtool" = yes; then 726 while test "X$1" != 'X--mode=compile'; do 727 shift 728 done 729 shift 730 fi 731 732 IFS=" " 733 for arg 734 do 735 case "$arg" in 736 -o) 737 shift 738 ;; 739 $object) 740 shift 741 ;; 742 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 743 set fnord "$@" 744 shift 745 shift 746 ;; 747 *) 748 set fnord "$@" "$arg" 749 shift 750 shift 751 ;; 752 esac 753 done 754 "$@" -E 2>/dev/null | 755 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 756 rm -f "$depfile" 757 echo "$object : \\" > "$depfile" 758 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 759 echo "$tab" >> "$depfile" 760 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 761 rm -f "$tmpdepfile" 762 ;; 763 764msvcmsys) 765 # This case exists only to let depend.m4 do its work. It works by 766 # looking at the text of this script. This case will never be run, 767 # since it is checked for above. 768 exit 1 769 ;; 770 771none) 772 exec "$@" 773 ;; 774 775*) 776 echo "Unknown depmode $depmode" 1>&2 777 exit 1 778 ;; 779esac 780 781exit 0 782 783# Local Variables: 784# mode: shell-script 785# sh-indentation: 2 786# eval: (add-hook 'write-file-hooks 'time-stamp) 787# time-stamp-start: "scriptversion=" 788# time-stamp-format: "%:y-%02m-%02d.%02H" 789# time-stamp-time-zone: "UTC" 790# time-stamp-end: "; # UTC" 791# End: 792