depcomp revision 4a8d91dc
150806d53Smrg#! /bin/sh 250806d53Smrg# depcomp - compile a program generating dependencies as side-effects 350806d53Smrg 44a8d91dcSmrgscriptversion=2013-05-30.07; # UTC 550806d53Smrg 64a8d91dcSmrg# Copyright (C) 1999-2014 Free Software Foundation, Inc. 750806d53Smrg 850806d53Smrg# This program is free software; you can redistribute it and/or modify 950806d53Smrg# it under the terms of the GNU General Public License as published by 1050806d53Smrg# the Free Software Foundation; either version 2, or (at your option) 1150806d53Smrg# any later version. 1250806d53Smrg 1350806d53Smrg# This program is distributed in the hope that it will be useful, 1450806d53Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1550806d53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1650806d53Smrg# GNU General Public License for more details. 1750806d53Smrg 1850806d53Smrg# You should have received a copy of the GNU General Public License 19a73423d7Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2050806d53Smrg 2150806d53Smrg# As a special exception to the GNU General Public License, if you 2250806d53Smrg# distribute this file as part of a program that contains a 2350806d53Smrg# configuration script generated by Autoconf, you may include it under 2450806d53Smrg# the same distribution terms that you use for the rest of that program. 2550806d53Smrg 2650806d53Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2750806d53Smrg 2850806d53Smrgcase $1 in 2950806d53Smrg '') 304a8d91dcSmrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 314a8d91dcSmrg exit 1; 324a8d91dcSmrg ;; 3350806d53Smrg -h | --h*) 3450806d53Smrg cat <<\EOF 3550806d53SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3650806d53Smrg 3750806d53SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3850806d53Smrgas side-effects. 3950806d53Smrg 4050806d53SmrgEnvironment variables: 4150806d53Smrg depmode Dependency tracking mode. 424a8d91dcSmrg source Source file read by 'PROGRAMS ARGS'. 434a8d91dcSmrg object Object file output by 'PROGRAMS ARGS'. 4450806d53Smrg DEPDIR directory where to store dependencies. 4550806d53Smrg depfile Dependency file to output. 46a73423d7Smrg tmpdepfile Temporary file to use when outputting dependencies. 4750806d53Smrg libtool Whether libtool is used (yes/no). 4850806d53Smrg 4950806d53SmrgReport bugs to <bug-automake@gnu.org>. 5050806d53SmrgEOF 5150806d53Smrg exit $? 5250806d53Smrg ;; 5350806d53Smrg -v | --v*) 5450806d53Smrg echo "depcomp $scriptversion" 5550806d53Smrg exit $? 5650806d53Smrg ;; 5750806d53Smrgesac 5850806d53Smrg 594a8d91dcSmrg# Get the directory component of the given path, and save it in the 604a8d91dcSmrg# global variables '$dir'. Note that this directory component will 614a8d91dcSmrg# be either empty or ending with a '/' character. This is deliberate. 624a8d91dcSmrgset_dir_from () 634a8d91dcSmrg{ 644a8d91dcSmrg case $1 in 654a8d91dcSmrg */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 664a8d91dcSmrg *) dir=;; 674a8d91dcSmrg esac 684a8d91dcSmrg} 694a8d91dcSmrg 704a8d91dcSmrg# Get the suffix-stripped basename of the given path, and save it the 714a8d91dcSmrg# global variable '$base'. 724a8d91dcSmrgset_base_from () 734a8d91dcSmrg{ 744a8d91dcSmrg base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 754a8d91dcSmrg} 764a8d91dcSmrg 774a8d91dcSmrg# If no dependency file was actually created by the compiler invocation, 784a8d91dcSmrg# we still have to create a dummy depfile, to avoid errors with the 794a8d91dcSmrg# Makefile "include basename.Plo" scheme. 804a8d91dcSmrgmake_dummy_depfile () 814a8d91dcSmrg{ 824a8d91dcSmrg echo "#dummy" > "$depfile" 834a8d91dcSmrg} 844a8d91dcSmrg 854a8d91dcSmrg# Factor out some common post-processing of the generated depfile. 864a8d91dcSmrg# Requires the auxiliary global variable '$tmpdepfile' to be set. 874a8d91dcSmrgaix_post_process_depfile () 884a8d91dcSmrg{ 894a8d91dcSmrg # If the compiler actually managed to produce a dependency file, 904a8d91dcSmrg # post-process it. 914a8d91dcSmrg if test -f "$tmpdepfile"; then 924a8d91dcSmrg # Each line is of the form 'foo.o: dependency.h'. 934a8d91dcSmrg # Do two passes, one to just change these to 944a8d91dcSmrg # $object: dependency.h 954a8d91dcSmrg # and one to simply output 964a8d91dcSmrg # dependency.h: 974a8d91dcSmrg # which is needed to avoid the deleted-header problem. 984a8d91dcSmrg { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 994a8d91dcSmrg sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 1004a8d91dcSmrg } > "$depfile" 1014a8d91dcSmrg rm -f "$tmpdepfile" 1024a8d91dcSmrg else 1034a8d91dcSmrg make_dummy_depfile 1044a8d91dcSmrg fi 1054a8d91dcSmrg} 1064a8d91dcSmrg 1074a8d91dcSmrg# A tabulation character. 1084a8d91dcSmrgtab=' ' 1094a8d91dcSmrg# A newline character. 1104a8d91dcSmrgnl=' 1114a8d91dcSmrg' 1124a8d91dcSmrg# Character ranges might be problematic outside the C locale. 1134a8d91dcSmrg# These definitions help. 1144a8d91dcSmrgupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 1154a8d91dcSmrglower=abcdefghijklmnopqrstuvwxyz 1164a8d91dcSmrgdigits=0123456789 1174a8d91dcSmrgalpha=${upper}${lower} 1184a8d91dcSmrg 11950806d53Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 12050806d53Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 12150806d53Smrg exit 1 12250806d53Smrgfi 12350806d53Smrg 12450806d53Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 12550806d53Smrgdepfile=${depfile-`echo "$object" | 12650806d53Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 12750806d53Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 12850806d53Smrg 12950806d53Smrgrm -f "$tmpdepfile" 13050806d53Smrg 1314a8d91dcSmrg# Avoid interferences from the environment. 1324a8d91dcSmrggccflag= dashmflag= 1334a8d91dcSmrg 13450806d53Smrg# Some modes work just like other modes, but use different flags. We 13550806d53Smrg# parameterize here, but still list the modes in the big case below, 13650806d53Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 13750806d53Smrg# here, because this file can only contain one case statement. 13850806d53Smrgif test "$depmode" = hp; then 13950806d53Smrg # HP compiler uses -M and no extra arg. 14050806d53Smrg gccflag=-M 14150806d53Smrg depmode=gcc 14250806d53Smrgfi 14350806d53Smrg 14450806d53Smrgif test "$depmode" = dashXmstdout; then 1454a8d91dcSmrg # This is just like dashmstdout with a different argument. 1464a8d91dcSmrg dashmflag=-xM 1474a8d91dcSmrg depmode=dashmstdout 14850806d53Smrgfi 14950806d53Smrg 150a73423d7Smrgcygpath_u="cygpath -u -f -" 151a73423d7Smrgif test "$depmode" = msvcmsys; then 1524a8d91dcSmrg # This is just like msvisualcpp but w/o cygpath translation. 1534a8d91dcSmrg # Just convert the backslash-escaped backslashes to single forward 1544a8d91dcSmrg # slashes to satisfy depend.m4 1554a8d91dcSmrg cygpath_u='sed s,\\\\,/,g' 1564a8d91dcSmrg depmode=msvisualcpp 157a73423d7Smrgfi 158a73423d7Smrg 159a73423d7Smrgif test "$depmode" = msvc7msys; then 1604a8d91dcSmrg # This is just like msvc7 but w/o cygpath translation. 1614a8d91dcSmrg # Just convert the backslash-escaped backslashes to single forward 1624a8d91dcSmrg # slashes to satisfy depend.m4 1634a8d91dcSmrg cygpath_u='sed s,\\\\,/,g' 1644a8d91dcSmrg depmode=msvc7 1654a8d91dcSmrgfi 1664a8d91dcSmrg 1674a8d91dcSmrgif test "$depmode" = xlc; then 1684a8d91dcSmrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 1694a8d91dcSmrg gccflag=-qmakedep=gcc,-MF 1704a8d91dcSmrg depmode=gcc 171a73423d7Smrgfi 172a73423d7Smrg 17350806d53Smrgcase "$depmode" in 17450806d53Smrggcc3) 17550806d53Smrg## gcc 3 implements dependency tracking that does exactly what 17650806d53Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 17750806d53Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1787965d9acSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1797965d9acSmrg## the command line argument order; so add the flags where they 1807965d9acSmrg## appear in depend2.am. Note that the slowdown incurred here 1817965d9acSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1827965d9acSmrg for arg 1837965d9acSmrg do 1847965d9acSmrg case $arg in 1857965d9acSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1867965d9acSmrg *) set fnord "$@" "$arg" ;; 1877965d9acSmrg esac 1887965d9acSmrg shift # fnord 1897965d9acSmrg shift # $arg 1907965d9acSmrg done 1917965d9acSmrg "$@" 19250806d53Smrg stat=$? 1934a8d91dcSmrg if test $stat -ne 0; then 19450806d53Smrg rm -f "$tmpdepfile" 19550806d53Smrg exit $stat 19650806d53Smrg fi 19750806d53Smrg mv "$tmpdepfile" "$depfile" 19850806d53Smrg ;; 19950806d53Smrg 20050806d53Smrggcc) 2014a8d91dcSmrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 2024a8d91dcSmrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 2034a8d91dcSmrg## (see the conditional assignment to $gccflag above). 20450806d53Smrg## There are various ways to get dependency output from gcc. Here's 20550806d53Smrg## why we pick this rather obscure method: 20650806d53Smrg## - Don't want to use -MD because we'd like the dependencies to end 20750806d53Smrg## up in a subdir. Having to rename by hand is ugly. 20850806d53Smrg## (We might end up doing this anyway to support other compilers.) 20950806d53Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 2104a8d91dcSmrg## -MM, not -M (despite what the docs say). Also, it might not be 2114a8d91dcSmrg## supported by the other compilers which use the 'gcc' depmode. 21250806d53Smrg## - Using -M directly means running the compiler twice (even worse 21350806d53Smrg## than renaming). 21450806d53Smrg if test -z "$gccflag"; then 21550806d53Smrg gccflag=-MD, 21650806d53Smrg fi 21750806d53Smrg "$@" -Wp,"$gccflag$tmpdepfile" 21850806d53Smrg stat=$? 2194a8d91dcSmrg if test $stat -ne 0; then 22050806d53Smrg rm -f "$tmpdepfile" 22150806d53Smrg exit $stat 22250806d53Smrg fi 22350806d53Smrg rm -f "$depfile" 22450806d53Smrg echo "$object : \\" > "$depfile" 2254a8d91dcSmrg # The second -e expression handles DOS-style file names with drive 2264a8d91dcSmrg # letters. 22750806d53Smrg sed -e 's/^[^:]*: / /' \ 22850806d53Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 2294a8d91dcSmrg## This next piece of magic avoids the "deleted header file" problem. 23050806d53Smrg## The problem is that when a header file which appears in a .P file 23150806d53Smrg## is deleted, the dependency causes make to die (because there is 23250806d53Smrg## typically no way to rebuild the header). We avoid this by adding 23350806d53Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 23450806d53Smrg## this for us directly. 2354a8d91dcSmrg## Some versions of gcc put a space before the ':'. On the theory 23650806d53Smrg## that the space means something, we add a space to the output as 237a73423d7Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 238a73423d7Smrg## to the object. Take care to not repeat it in the output. 23950806d53Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 24050806d53Smrg## correctly. Breaking it into two sed invocations is a workaround. 2414a8d91dcSmrg tr ' ' "$nl" < "$tmpdepfile" \ 2424a8d91dcSmrg | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 2434a8d91dcSmrg | sed -e 's/$/ :/' >> "$depfile" 24450806d53Smrg rm -f "$tmpdepfile" 24550806d53Smrg ;; 24650806d53Smrg 24750806d53Smrghp) 24850806d53Smrg # This case exists only to let depend.m4 do its work. It works by 24950806d53Smrg # looking at the text of this script. This case will never be run, 25050806d53Smrg # since it is checked for above. 25150806d53Smrg exit 1 25250806d53Smrg ;; 25350806d53Smrg 25450806d53Smrgsgi) 25550806d53Smrg if test "$libtool" = yes; then 25650806d53Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 25750806d53Smrg else 25850806d53Smrg "$@" -MDupdate "$tmpdepfile" 25950806d53Smrg fi 26050806d53Smrg stat=$? 2614a8d91dcSmrg if test $stat -ne 0; then 26250806d53Smrg rm -f "$tmpdepfile" 26350806d53Smrg exit $stat 26450806d53Smrg fi 26550806d53Smrg rm -f "$depfile" 26650806d53Smrg 26750806d53Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 26850806d53Smrg echo "$object : \\" > "$depfile" 26950806d53Smrg # Clip off the initial element (the dependent). Don't try to be 27050806d53Smrg # clever and replace this with sed code, as IRIX sed won't handle 27150806d53Smrg # lines with more than a fixed number of characters (4096 in 27250806d53Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 2734a8d91dcSmrg # the IRIX cc adds comments like '#:fec' to the end of the 27450806d53Smrg # dependency line. 2754a8d91dcSmrg tr ' ' "$nl" < "$tmpdepfile" \ 2764a8d91dcSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 2774a8d91dcSmrg | tr "$nl" ' ' >> "$depfile" 278a73423d7Smrg echo >> "$depfile" 27950806d53Smrg # The second pass generates a dummy entry for each header file. 2804a8d91dcSmrg tr ' ' "$nl" < "$tmpdepfile" \ 2814a8d91dcSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2824a8d91dcSmrg >> "$depfile" 28350806d53Smrg else 2844a8d91dcSmrg make_dummy_depfile 28550806d53Smrg fi 28650806d53Smrg rm -f "$tmpdepfile" 28750806d53Smrg ;; 28850806d53Smrg 2894a8d91dcSmrgxlc) 2904a8d91dcSmrg # This case exists only to let depend.m4 do its work. It works by 2914a8d91dcSmrg # looking at the text of this script. This case will never be run, 2924a8d91dcSmrg # since it is checked for above. 2934a8d91dcSmrg exit 1 2944a8d91dcSmrg ;; 2954a8d91dcSmrg 29650806d53Smrgaix) 29750806d53Smrg # The C for AIX Compiler uses -M and outputs the dependencies 29850806d53Smrg # in a .u file. In older versions, this file always lives in the 2994a8d91dcSmrg # current directory. Also, the AIX compiler puts '$object:' at the 30050806d53Smrg # start of each line; $object doesn't have directory information. 30150806d53Smrg # Version 6 uses the directory in both cases. 3024a8d91dcSmrg set_dir_from "$object" 3034a8d91dcSmrg set_base_from "$object" 30450806d53Smrg if test "$libtool" = yes; then 3057965d9acSmrg tmpdepfile1=$dir$base.u 3067965d9acSmrg tmpdepfile2=$base.u 3077965d9acSmrg tmpdepfile3=$dir.libs/$base.u 30850806d53Smrg "$@" -Wc,-M 30950806d53Smrg else 3107965d9acSmrg tmpdepfile1=$dir$base.u 3117965d9acSmrg tmpdepfile2=$dir$base.u 3127965d9acSmrg tmpdepfile3=$dir$base.u 31350806d53Smrg "$@" -M 31450806d53Smrg fi 31550806d53Smrg stat=$? 3164a8d91dcSmrg if test $stat -ne 0; then 3177965d9acSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 31850806d53Smrg exit $stat 31950806d53Smrg fi 32050806d53Smrg 3217965d9acSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3227965d9acSmrg do 3237965d9acSmrg test -f "$tmpdepfile" && break 3247965d9acSmrg done 3254a8d91dcSmrg aix_post_process_depfile 3264a8d91dcSmrg ;; 3274a8d91dcSmrg 3284a8d91dcSmrgtcc) 3294a8d91dcSmrg # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 3304a8d91dcSmrg # FIXME: That version still under development at the moment of writing. 3314a8d91dcSmrg # Make that this statement remains true also for stable, released 3324a8d91dcSmrg # versions. 3334a8d91dcSmrg # It will wrap lines (doesn't matter whether long or short) with a 3344a8d91dcSmrg # trailing '\', as in: 3354a8d91dcSmrg # 3364a8d91dcSmrg # foo.o : \ 3374a8d91dcSmrg # foo.c \ 3384a8d91dcSmrg # foo.h \ 3394a8d91dcSmrg # 3404a8d91dcSmrg # It will put a trailing '\' even on the last line, and will use leading 3414a8d91dcSmrg # spaces rather than leading tabs (at least since its commit 0394caf7 3424a8d91dcSmrg # "Emit spaces for -MD"). 3434a8d91dcSmrg "$@" -MD -MF "$tmpdepfile" 3444a8d91dcSmrg stat=$? 3454a8d91dcSmrg if test $stat -ne 0; then 3464a8d91dcSmrg rm -f "$tmpdepfile" 3474a8d91dcSmrg exit $stat 34850806d53Smrg fi 3494a8d91dcSmrg rm -f "$depfile" 3504a8d91dcSmrg # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 3514a8d91dcSmrg # We have to change lines of the first kind to '$object: \'. 3524a8d91dcSmrg sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 3534a8d91dcSmrg # And for each line of the second kind, we have to emit a 'dep.h:' 3544a8d91dcSmrg # dummy dependency, to avoid the deleted-header problem. 3554a8d91dcSmrg sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 35650806d53Smrg rm -f "$tmpdepfile" 35750806d53Smrg ;; 35850806d53Smrg 3594a8d91dcSmrg## The order of this option in the case statement is important, since the 3604a8d91dcSmrg## shell code in configure will try each of these formats in the order 3614a8d91dcSmrg## listed in this file. A plain '-MD' option would be understood by many 3624a8d91dcSmrg## compilers, so we must ensure this comes after the gcc and icc options. 3634a8d91dcSmrgpgcc) 3644a8d91dcSmrg # Portland's C compiler understands '-MD'. 3654a8d91dcSmrg # Will always output deps to 'file.d' where file is the root name of the 3664a8d91dcSmrg # source file under compilation, even if file resides in a subdirectory. 3674a8d91dcSmrg # The object file name does not affect the name of the '.d' file. 3684a8d91dcSmrg # pgcc 10.2 will output 36950806d53Smrg # foo.o: sub/foo.c sub/foo.h 3704a8d91dcSmrg # and will wrap long lines using '\' : 37150806d53Smrg # foo.o: sub/foo.c ... \ 37250806d53Smrg # sub/foo.h ... \ 37350806d53Smrg # ... 3744a8d91dcSmrg set_dir_from "$object" 3754a8d91dcSmrg # Use the source, not the object, to determine the base name, since 3764a8d91dcSmrg # that's sadly what pgcc will do too. 3774a8d91dcSmrg set_base_from "$source" 3784a8d91dcSmrg tmpdepfile=$base.d 3794a8d91dcSmrg 3804a8d91dcSmrg # For projects that build the same source file twice into different object 3814a8d91dcSmrg # files, the pgcc approach of using the *source* file root name can cause 3824a8d91dcSmrg # problems in parallel builds. Use a locking strategy to avoid stomping on 3834a8d91dcSmrg # the same $tmpdepfile. 3844a8d91dcSmrg lockdir=$base.d-lock 3854a8d91dcSmrg trap " 3864a8d91dcSmrg echo '$0: caught signal, cleaning up...' >&2 3874a8d91dcSmrg rmdir '$lockdir' 3884a8d91dcSmrg exit 1 3894a8d91dcSmrg " 1 2 13 15 3904a8d91dcSmrg numtries=100 3914a8d91dcSmrg i=$numtries 3924a8d91dcSmrg while test $i -gt 0; do 3934a8d91dcSmrg # mkdir is a portable test-and-set. 3944a8d91dcSmrg if mkdir "$lockdir" 2>/dev/null; then 3954a8d91dcSmrg # This process acquired the lock. 3964a8d91dcSmrg "$@" -MD 3974a8d91dcSmrg stat=$? 3984a8d91dcSmrg # Release the lock. 3994a8d91dcSmrg rmdir "$lockdir" 4004a8d91dcSmrg break 4014a8d91dcSmrg else 4024a8d91dcSmrg # If the lock is being held by a different process, wait 4034a8d91dcSmrg # until the winning process is done or we timeout. 4044a8d91dcSmrg while test -d "$lockdir" && test $i -gt 0; do 4054a8d91dcSmrg sleep 1 4064a8d91dcSmrg i=`expr $i - 1` 4074a8d91dcSmrg done 4084a8d91dcSmrg fi 4094a8d91dcSmrg i=`expr $i - 1` 4104a8d91dcSmrg done 4114a8d91dcSmrg trap - 1 2 13 15 4124a8d91dcSmrg if test $i -le 0; then 4134a8d91dcSmrg echo "$0: failed to acquire lock after $numtries attempts" >&2 4144a8d91dcSmrg echo "$0: check lockdir '$lockdir'" >&2 4154a8d91dcSmrg exit 1 4164a8d91dcSmrg fi 41750806d53Smrg 4184a8d91dcSmrg if test $stat -ne 0; then 41950806d53Smrg rm -f "$tmpdepfile" 42050806d53Smrg exit $stat 42150806d53Smrg fi 42250806d53Smrg rm -f "$depfile" 42350806d53Smrg # Each line is of the form `foo.o: dependent.h', 42450806d53Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 42550806d53Smrg # Do two passes, one to just change these to 42650806d53Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 42750806d53Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 42850806d53Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 42950806d53Smrg # correctly. Breaking it into two sed invocations is a workaround. 4304a8d91dcSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 4314a8d91dcSmrg | sed -e 's/$/ :/' >> "$depfile" 43250806d53Smrg rm -f "$tmpdepfile" 43350806d53Smrg ;; 43450806d53Smrg 4357965d9acSmrghp2) 4367965d9acSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 4377965d9acSmrg # compilers, which have integrated preprocessors. The correct option 4387965d9acSmrg # to use with these is +Maked; it writes dependencies to a file named 4397965d9acSmrg # 'foo.d', which lands next to the object file, wherever that 4407965d9acSmrg # happens to be. 4417965d9acSmrg # Much of this is similar to the tru64 case; see comments there. 4424a8d91dcSmrg set_dir_from "$object" 4434a8d91dcSmrg set_base_from "$object" 4447965d9acSmrg if test "$libtool" = yes; then 4457965d9acSmrg tmpdepfile1=$dir$base.d 4467965d9acSmrg tmpdepfile2=$dir.libs/$base.d 4477965d9acSmrg "$@" -Wc,+Maked 4487965d9acSmrg else 4497965d9acSmrg tmpdepfile1=$dir$base.d 4507965d9acSmrg tmpdepfile2=$dir$base.d 4517965d9acSmrg "$@" +Maked 4527965d9acSmrg fi 4537965d9acSmrg stat=$? 4544a8d91dcSmrg if test $stat -ne 0; then 4557965d9acSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 4567965d9acSmrg exit $stat 4577965d9acSmrg fi 4587965d9acSmrg 4597965d9acSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 4607965d9acSmrg do 4617965d9acSmrg test -f "$tmpdepfile" && break 4627965d9acSmrg done 4637965d9acSmrg if test -f "$tmpdepfile"; then 4644a8d91dcSmrg sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 4654a8d91dcSmrg # Add 'dependent.h:' lines. 466a73423d7Smrg sed -ne '2,${ 4674a8d91dcSmrg s/^ *// 4684a8d91dcSmrg s/ \\*$// 4694a8d91dcSmrg s/$/:/ 4704a8d91dcSmrg p 4714a8d91dcSmrg }' "$tmpdepfile" >> "$depfile" 4727965d9acSmrg else 4734a8d91dcSmrg make_dummy_depfile 4747965d9acSmrg fi 4757965d9acSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 4767965d9acSmrg ;; 4777965d9acSmrg 47850806d53Smrgtru64) 4794a8d91dcSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 4804a8d91dcSmrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 4814a8d91dcSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 4824a8d91dcSmrg # dependencies in 'foo.d' instead, so we check for that too. 4834a8d91dcSmrg # Subdirectories are respected. 4844a8d91dcSmrg set_dir_from "$object" 4854a8d91dcSmrg set_base_from "$object" 4864a8d91dcSmrg 4874a8d91dcSmrg if test "$libtool" = yes; then 4884a8d91dcSmrg # Libtool generates 2 separate objects for the 2 libraries. These 4894a8d91dcSmrg # two compilations output dependencies in $dir.libs/$base.o.d and 4904a8d91dcSmrg # in $dir$base.o.d. We have to check for both files, because 4914a8d91dcSmrg # one of the two compilations can be disabled. We should prefer 4924a8d91dcSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 4934a8d91dcSmrg # automatically cleaned when .libs/ is deleted, while ignoring 4944a8d91dcSmrg # the former would cause a distcleancheck panic. 4954a8d91dcSmrg tmpdepfile1=$dir$base.o.d # libtool 1.5 4964a8d91dcSmrg tmpdepfile2=$dir.libs/$base.o.d # Likewise. 4974a8d91dcSmrg tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 4984a8d91dcSmrg "$@" -Wc,-MD 4994a8d91dcSmrg else 5004a8d91dcSmrg tmpdepfile1=$dir$base.d 5014a8d91dcSmrg tmpdepfile2=$dir$base.d 5024a8d91dcSmrg tmpdepfile3=$dir$base.d 5034a8d91dcSmrg "$@" -MD 5044a8d91dcSmrg fi 5054a8d91dcSmrg 5064a8d91dcSmrg stat=$? 5074a8d91dcSmrg if test $stat -ne 0; then 5084a8d91dcSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5094a8d91dcSmrg exit $stat 5104a8d91dcSmrg fi 5114a8d91dcSmrg 5124a8d91dcSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5134a8d91dcSmrg do 5144a8d91dcSmrg test -f "$tmpdepfile" && break 5154a8d91dcSmrg done 5164a8d91dcSmrg # Same post-processing that is required for AIX mode. 5174a8d91dcSmrg aix_post_process_depfile 5184a8d91dcSmrg ;; 51950806d53Smrg 520a73423d7Smrgmsvc7) 521a73423d7Smrg if test "$libtool" = yes; then 522a73423d7Smrg showIncludes=-Wc,-showIncludes 523a73423d7Smrg else 524a73423d7Smrg showIncludes=-showIncludes 525a73423d7Smrg fi 526a73423d7Smrg "$@" $showIncludes > "$tmpdepfile" 527a73423d7Smrg stat=$? 528a73423d7Smrg grep -v '^Note: including file: ' "$tmpdepfile" 5294a8d91dcSmrg if test $stat -ne 0; then 530a73423d7Smrg rm -f "$tmpdepfile" 531a73423d7Smrg exit $stat 532a73423d7Smrg fi 533a73423d7Smrg rm -f "$depfile" 534a73423d7Smrg echo "$object : \\" > "$depfile" 535a73423d7Smrg # The first sed program below extracts the file names and escapes 536a73423d7Smrg # backslashes for cygpath. The second sed program outputs the file 537a73423d7Smrg # name when reading, but also accumulates all include files in the 538a73423d7Smrg # hold buffer in order to output them again at the end. This only 539a73423d7Smrg # works with sed implementations that can handle large buffers. 540a73423d7Smrg sed < "$tmpdepfile" -n ' 541a73423d7Smrg/^Note: including file: *\(.*\)/ { 542a73423d7Smrg s//\1/ 543a73423d7Smrg s/\\/\\\\/g 544a73423d7Smrg p 545a73423d7Smrg}' | $cygpath_u | sort -u | sed -n ' 546a73423d7Smrgs/ /\\ /g 5474a8d91dcSmrgs/\(.*\)/'"$tab"'\1 \\/p 548a73423d7Smrgs/.\(.*\) \\/\1:/ 549a73423d7SmrgH 550a73423d7Smrg$ { 5514a8d91dcSmrg s/.*/'"$tab"'/ 552a73423d7Smrg G 553a73423d7Smrg p 554a73423d7Smrg}' >> "$depfile" 5554a8d91dcSmrg echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556a73423d7Smrg rm -f "$tmpdepfile" 557a73423d7Smrg ;; 558a73423d7Smrg 559a73423d7Smrgmsvc7msys) 560a73423d7Smrg # This case exists only to let depend.m4 do its work. It works by 561a73423d7Smrg # looking at the text of this script. This case will never be run, 562a73423d7Smrg # since it is checked for above. 563a73423d7Smrg exit 1 564a73423d7Smrg ;; 565a73423d7Smrg 56650806d53Smrg#nosideeffect) 56750806d53Smrg # This comment above is used by automake to tell side-effect 56850806d53Smrg # dependency tracking mechanisms from slower ones. 56950806d53Smrg 57050806d53Smrgdashmstdout) 57150806d53Smrg # Important note: in order to support this mode, a compiler *must* 57250806d53Smrg # always write the preprocessed file to stdout, regardless of -o. 57350806d53Smrg "$@" || exit $? 57450806d53Smrg 57550806d53Smrg # Remove the call to Libtool. 57650806d53Smrg if test "$libtool" = yes; then 577a73423d7Smrg while test "X$1" != 'X--mode=compile'; do 57850806d53Smrg shift 57950806d53Smrg done 58050806d53Smrg shift 58150806d53Smrg fi 58250806d53Smrg 5834a8d91dcSmrg # Remove '-o $object'. 58450806d53Smrg IFS=" " 58550806d53Smrg for arg 58650806d53Smrg do 58750806d53Smrg case $arg in 58850806d53Smrg -o) 58950806d53Smrg shift 59050806d53Smrg ;; 59150806d53Smrg $object) 59250806d53Smrg shift 59350806d53Smrg ;; 59450806d53Smrg *) 59550806d53Smrg set fnord "$@" "$arg" 59650806d53Smrg shift # fnord 59750806d53Smrg shift # $arg 59850806d53Smrg ;; 59950806d53Smrg esac 60050806d53Smrg done 60150806d53Smrg 60250806d53Smrg test -z "$dashmflag" && dashmflag=-M 6034a8d91dcSmrg # Require at least two characters before searching for ':' 60450806d53Smrg # in the target name. This is to cope with DOS-style filenames: 6054a8d91dcSmrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 60650806d53Smrg "$@" $dashmflag | 6074a8d91dcSmrg sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 60850806d53Smrg rm -f "$depfile" 60950806d53Smrg cat < "$tmpdepfile" > "$depfile" 6104a8d91dcSmrg # Some versions of the HPUX 10.20 sed can't process this sed invocation 6114a8d91dcSmrg # correctly. Breaking it into two sed invocations is a workaround. 6124a8d91dcSmrg tr ' ' "$nl" < "$tmpdepfile" \ 6134a8d91dcSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 6144a8d91dcSmrg | sed -e 's/$/ :/' >> "$depfile" 61550806d53Smrg rm -f "$tmpdepfile" 61650806d53Smrg ;; 61750806d53Smrg 61850806d53SmrgdashXmstdout) 61950806d53Smrg # This case only exists to satisfy depend.m4. It is never actually 62050806d53Smrg # run, as this mode is specially recognized in the preamble. 62150806d53Smrg exit 1 62250806d53Smrg ;; 62350806d53Smrg 62450806d53Smrgmakedepend) 62550806d53Smrg "$@" || exit $? 62650806d53Smrg # Remove any Libtool call 62750806d53Smrg if test "$libtool" = yes; then 628a73423d7Smrg while test "X$1" != 'X--mode=compile'; do 62950806d53Smrg shift 63050806d53Smrg done 63150806d53Smrg shift 63250806d53Smrg fi 63350806d53Smrg # X makedepend 63450806d53Smrg shift 635a73423d7Smrg cleared=no eat=no 636a73423d7Smrg for arg 637a73423d7Smrg do 63850806d53Smrg case $cleared in 63950806d53Smrg no) 64050806d53Smrg set ""; shift 64150806d53Smrg cleared=yes ;; 64250806d53Smrg esac 643a73423d7Smrg if test $eat = yes; then 644a73423d7Smrg eat=no 645a73423d7Smrg continue 646a73423d7Smrg fi 64750806d53Smrg case "$arg" in 64850806d53Smrg -D*|-I*) 64950806d53Smrg set fnord "$@" "$arg"; shift ;; 65050806d53Smrg # Strip any option that makedepend may not understand. Remove 65150806d53Smrg # the object too, otherwise makedepend will parse it as a source file. 652a73423d7Smrg -arch) 653a73423d7Smrg eat=yes ;; 65450806d53Smrg -*|$object) 65550806d53Smrg ;; 65650806d53Smrg *) 65750806d53Smrg set fnord "$@" "$arg"; shift ;; 65850806d53Smrg esac 65950806d53Smrg done 660a73423d7Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 66150806d53Smrg touch "$tmpdepfile" 66250806d53Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 66350806d53Smrg rm -f "$depfile" 664a73423d7Smrg # makedepend may prepend the VPATH from the source file name to the object. 665a73423d7Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 666a73423d7Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 6674a8d91dcSmrg # Some versions of the HPUX 10.20 sed can't process the last invocation 6684a8d91dcSmrg # correctly. Breaking it into two sed invocations is a workaround. 6694a8d91dcSmrg sed '1,2d' "$tmpdepfile" \ 6704a8d91dcSmrg | tr ' ' "$nl" \ 6714a8d91dcSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 6724a8d91dcSmrg | sed -e 's/$/ :/' >> "$depfile" 67350806d53Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 67450806d53Smrg ;; 67550806d53Smrg 67650806d53Smrgcpp) 67750806d53Smrg # Important note: in order to support this mode, a compiler *must* 67850806d53Smrg # always write the preprocessed file to stdout. 67950806d53Smrg "$@" || exit $? 68050806d53Smrg 68150806d53Smrg # Remove the call to Libtool. 68250806d53Smrg if test "$libtool" = yes; then 683a73423d7Smrg while test "X$1" != 'X--mode=compile'; do 68450806d53Smrg shift 68550806d53Smrg done 68650806d53Smrg shift 68750806d53Smrg fi 68850806d53Smrg 6894a8d91dcSmrg # Remove '-o $object'. 69050806d53Smrg IFS=" " 69150806d53Smrg for arg 69250806d53Smrg do 69350806d53Smrg case $arg in 69450806d53Smrg -o) 69550806d53Smrg shift 69650806d53Smrg ;; 69750806d53Smrg $object) 69850806d53Smrg shift 69950806d53Smrg ;; 70050806d53Smrg *) 70150806d53Smrg set fnord "$@" "$arg" 70250806d53Smrg shift # fnord 70350806d53Smrg shift # $arg 70450806d53Smrg ;; 70550806d53Smrg esac 70650806d53Smrg done 70750806d53Smrg 7084a8d91dcSmrg "$@" -E \ 7094a8d91dcSmrg | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 7104a8d91dcSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 7114a8d91dcSmrg | sed '$ s: \\$::' > "$tmpdepfile" 71250806d53Smrg rm -f "$depfile" 71350806d53Smrg echo "$object : \\" > "$depfile" 71450806d53Smrg cat < "$tmpdepfile" >> "$depfile" 71550806d53Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 71650806d53Smrg rm -f "$tmpdepfile" 71750806d53Smrg ;; 71850806d53Smrg 71950806d53Smrgmsvisualcpp) 72050806d53Smrg # Important note: in order to support this mode, a compiler *must* 721a73423d7Smrg # always write the preprocessed file to stdout. 72250806d53Smrg "$@" || exit $? 723a73423d7Smrg 724a73423d7Smrg # Remove the call to Libtool. 725a73423d7Smrg if test "$libtool" = yes; then 726a73423d7Smrg while test "X$1" != 'X--mode=compile'; do 727a73423d7Smrg shift 728a73423d7Smrg done 729a73423d7Smrg shift 730a73423d7Smrg fi 731a73423d7Smrg 73250806d53Smrg IFS=" " 73350806d53Smrg for arg 73450806d53Smrg do 73550806d53Smrg case "$arg" in 736a73423d7Smrg -o) 737a73423d7Smrg shift 738a73423d7Smrg ;; 739a73423d7Smrg $object) 740a73423d7Smrg shift 741a73423d7Smrg ;; 74250806d53Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 7434a8d91dcSmrg set fnord "$@" 7444a8d91dcSmrg shift 7454a8d91dcSmrg shift 7464a8d91dcSmrg ;; 74750806d53Smrg *) 7484a8d91dcSmrg set fnord "$@" "$arg" 7494a8d91dcSmrg shift 7504a8d91dcSmrg shift 7514a8d91dcSmrg ;; 75250806d53Smrg esac 75350806d53Smrg done 754a73423d7Smrg "$@" -E 2>/dev/null | 755a73423d7Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 75650806d53Smrg rm -f "$depfile" 75750806d53Smrg echo "$object : \\" > "$depfile" 7584a8d91dcSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 7594a8d91dcSmrg echo "$tab" >> "$depfile" 760a73423d7Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 76150806d53Smrg rm -f "$tmpdepfile" 76250806d53Smrg ;; 76350806d53Smrg 764a73423d7Smrgmsvcmsys) 765a73423d7Smrg # This case exists only to let depend.m4 do its work. It works by 766a73423d7Smrg # looking at the text of this script. This case will never be run, 767a73423d7Smrg # since it is checked for above. 768a73423d7Smrg exit 1 769a73423d7Smrg ;; 770a73423d7Smrg 77150806d53Smrgnone) 77250806d53Smrg exec "$@" 77350806d53Smrg ;; 77450806d53Smrg 77550806d53Smrg*) 77650806d53Smrg echo "Unknown depmode $depmode" 1>&2 77750806d53Smrg exit 1 77850806d53Smrg ;; 77950806d53Smrgesac 78050806d53Smrg 78150806d53Smrgexit 0 78250806d53Smrg 78350806d53Smrg# Local Variables: 78450806d53Smrg# mode: shell-script 78550806d53Smrg# sh-indentation: 2 78650806d53Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 78750806d53Smrg# time-stamp-start: "scriptversion=" 78850806d53Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 789a73423d7Smrg# time-stamp-time-zone: "UTC" 790a73423d7Smrg# time-stamp-end: "; # UTC" 79150806d53Smrg# End: 792