depcomp revision dc99b369
15eefee25Smacallan#! /bin/sh 25eefee25Smacallan# depcomp - compile a program generating dependencies as side-effects 35eefee25Smacallan 4dc99b369Smrgscriptversion=2012-07-12.20; # UTC 55eefee25Smacallan 6dc99b369Smrg# Copyright (C) 1999-2012 Free Software Foundation, Inc. 75eefee25Smacallan 85eefee25Smacallan# This program is free software; you can redistribute it and/or modify 95eefee25Smacallan# it under the terms of the GNU General Public License as published by 105eefee25Smacallan# the Free Software Foundation; either version 2, or (at your option) 115eefee25Smacallan# any later version. 125eefee25Smacallan 135eefee25Smacallan# This program is distributed in the hope that it will be useful, 145eefee25Smacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 155eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 165eefee25Smacallan# GNU General Public License for more details. 175eefee25Smacallan 185eefee25Smacallan# You should have received a copy of the GNU General Public License 19dc99b369Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 205eefee25Smacallan 215eefee25Smacallan# As a special exception to the GNU General Public License, if you 225eefee25Smacallan# distribute this file as part of a program that contains a 235eefee25Smacallan# configuration script generated by Autoconf, you may include it under 245eefee25Smacallan# the same distribution terms that you use for the rest of that program. 255eefee25Smacallan 265eefee25Smacallan# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 275eefee25Smacallan 285eefee25Smacallancase $1 in 295eefee25Smacallan '') 30dc99b369Smrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 315eefee25Smacallan exit 1; 325eefee25Smacallan ;; 335eefee25Smacallan -h | --h*) 345eefee25Smacallan cat <<\EOF 355eefee25SmacallanUsage: depcomp [--help] [--version] PROGRAM [ARGS] 365eefee25Smacallan 375eefee25SmacallanRun PROGRAMS ARGS to compile a file, generating dependencies 385eefee25Smacallanas side-effects. 395eefee25Smacallan 405eefee25SmacallanEnvironment variables: 415eefee25Smacallan depmode Dependency tracking mode. 42dc99b369Smrg source Source file read by 'PROGRAMS ARGS'. 43dc99b369Smrg object Object file output by 'PROGRAMS ARGS'. 445eefee25Smacallan DEPDIR directory where to store dependencies. 455eefee25Smacallan depfile Dependency file to output. 46dc99b369Smrg tmpdepfile Temporary file to use when outputting dependencies. 475eefee25Smacallan libtool Whether libtool is used (yes/no). 485eefee25Smacallan 495eefee25SmacallanReport bugs to <bug-automake@gnu.org>. 505eefee25SmacallanEOF 515eefee25Smacallan exit $? 525eefee25Smacallan ;; 535eefee25Smacallan -v | --v*) 545eefee25Smacallan echo "depcomp $scriptversion" 555eefee25Smacallan exit $? 565eefee25Smacallan ;; 575eefee25Smacallanesac 585eefee25Smacallan 59dc99b369Smrg# A tabulation character. 60dc99b369Smrgtab=' ' 61dc99b369Smrg# A newline character. 62dc99b369Smrgnl=' 63dc99b369Smrg' 64dc99b369Smrg 655eefee25Smacallanif test -z "$depmode" || test -z "$source" || test -z "$object"; then 665eefee25Smacallan echo "depcomp: Variables source, object and depmode must be set" 1>&2 675eefee25Smacallan exit 1 685eefee25Smacallanfi 695eefee25Smacallan 705eefee25Smacallan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 715eefee25Smacallandepfile=${depfile-`echo "$object" | 725eefee25Smacallan sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 735eefee25Smacallantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 745eefee25Smacallan 755eefee25Smacallanrm -f "$tmpdepfile" 765eefee25Smacallan 77dc99b369Smrg# Avoid interferences from the environment. 78dc99b369Smrggccflag= dashmflag= 79dc99b369Smrg 805eefee25Smacallan# Some modes work just like other modes, but use different flags. We 815eefee25Smacallan# parameterize here, but still list the modes in the big case below, 825eefee25Smacallan# to make depend.m4 easier to write. Note that we *cannot* use a case 835eefee25Smacallan# here, because this file can only contain one case statement. 845eefee25Smacallanif test "$depmode" = hp; then 855eefee25Smacallan # HP compiler uses -M and no extra arg. 865eefee25Smacallan gccflag=-M 875eefee25Smacallan depmode=gcc 885eefee25Smacallanfi 895eefee25Smacallan 905eefee25Smacallanif test "$depmode" = dashXmstdout; then 915eefee25Smacallan # This is just like dashmstdout with a different argument. 925eefee25Smacallan dashmflag=-xM 935eefee25Smacallan depmode=dashmstdout 945eefee25Smacallanfi 955eefee25Smacallan 96dc99b369Smrgcygpath_u="cygpath -u -f -" 97dc99b369Smrgif test "$depmode" = msvcmsys; then 98dc99b369Smrg # This is just like msvisualcpp but w/o cygpath translation. 99dc99b369Smrg # Just convert the backslash-escaped backslashes to single forward 100dc99b369Smrg # slashes to satisfy depend.m4 101dc99b369Smrg cygpath_u='sed s,\\\\,/,g' 102dc99b369Smrg depmode=msvisualcpp 103dc99b369Smrgfi 104dc99b369Smrg 105dc99b369Smrgif test "$depmode" = msvc7msys; then 106dc99b369Smrg # This is just like msvc7 but w/o cygpath translation. 107dc99b369Smrg # Just convert the backslash-escaped backslashes to single forward 108dc99b369Smrg # slashes to satisfy depend.m4 109dc99b369Smrg cygpath_u='sed s,\\\\,/,g' 110dc99b369Smrg depmode=msvc7 111dc99b369Smrgfi 112dc99b369Smrg 113dc99b369Smrgif test "$depmode" = xlc; then 114dc99b369Smrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 115dc99b369Smrg gccflag=-qmakedep=gcc,-MF 116dc99b369Smrg depmode=gcc 117dc99b369Smrgfi 118dc99b369Smrg 1195eefee25Smacallancase "$depmode" in 1205eefee25Smacallangcc3) 1215eefee25Smacallan## gcc 3 implements dependency tracking that does exactly what 1225eefee25Smacallan## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1235eefee25Smacallan## it if -MD -MP comes after the -MF stuff. Hmm. 12462ab96baSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 12562ab96baSmrg## the command line argument order; so add the flags where they 12662ab96baSmrg## appear in depend2.am. Note that the slowdown incurred here 12762ab96baSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 12862ab96baSmrg for arg 12962ab96baSmrg do 13062ab96baSmrg case $arg in 13162ab96baSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 13262ab96baSmrg *) set fnord "$@" "$arg" ;; 13362ab96baSmrg esac 13462ab96baSmrg shift # fnord 13562ab96baSmrg shift # $arg 13662ab96baSmrg done 13762ab96baSmrg "$@" 1385eefee25Smacallan stat=$? 1395eefee25Smacallan if test $stat -eq 0; then : 1405eefee25Smacallan else 1415eefee25Smacallan rm -f "$tmpdepfile" 1425eefee25Smacallan exit $stat 1435eefee25Smacallan fi 1445eefee25Smacallan mv "$tmpdepfile" "$depfile" 1455eefee25Smacallan ;; 1465eefee25Smacallan 1475eefee25Smacallangcc) 148dc99b369Smrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 149dc99b369Smrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 150dc99b369Smrg## (see the conditional assignment to $gccflag above). 1515eefee25Smacallan## There are various ways to get dependency output from gcc. Here's 1525eefee25Smacallan## why we pick this rather obscure method: 1535eefee25Smacallan## - Don't want to use -MD because we'd like the dependencies to end 1545eefee25Smacallan## up in a subdir. Having to rename by hand is ugly. 1555eefee25Smacallan## (We might end up doing this anyway to support other compilers.) 1565eefee25Smacallan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 157dc99b369Smrg## -MM, not -M (despite what the docs say). Also, it might not be 158dc99b369Smrg## supported by the other compilers which use the 'gcc' depmode. 1595eefee25Smacallan## - Using -M directly means running the compiler twice (even worse 1605eefee25Smacallan## than renaming). 1615eefee25Smacallan if test -z "$gccflag"; then 1625eefee25Smacallan gccflag=-MD, 1635eefee25Smacallan fi 1645eefee25Smacallan "$@" -Wp,"$gccflag$tmpdepfile" 1655eefee25Smacallan stat=$? 1665eefee25Smacallan if test $stat -eq 0; then : 1675eefee25Smacallan else 1685eefee25Smacallan rm -f "$tmpdepfile" 1695eefee25Smacallan exit $stat 1705eefee25Smacallan fi 1715eefee25Smacallan rm -f "$depfile" 1725eefee25Smacallan echo "$object : \\" > "$depfile" 1735eefee25Smacallan alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1745eefee25Smacallan## The second -e expression handles DOS-style file names with drive letters. 1755eefee25Smacallan sed -e 's/^[^:]*: / /' \ 1765eefee25Smacallan -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 177dc99b369Smrg## This next piece of magic avoids the "deleted header file" problem. 1785eefee25Smacallan## The problem is that when a header file which appears in a .P file 1795eefee25Smacallan## is deleted, the dependency causes make to die (because there is 1805eefee25Smacallan## typically no way to rebuild the header). We avoid this by adding 1815eefee25Smacallan## dummy dependencies for each header file. Too bad gcc doesn't do 1825eefee25Smacallan## this for us directly. 183dc99b369Smrg tr ' ' "$nl" < "$tmpdepfile" | 184dc99b369Smrg## Some versions of gcc put a space before the ':'. On the theory 1855eefee25Smacallan## that the space means something, we add a space to the output as 186dc99b369Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 187dc99b369Smrg## to the object. Take care to not repeat it in the output. 1885eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation 1895eefee25Smacallan## correctly. Breaking it into two sed invocations is a workaround. 190dc99b369Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 191dc99b369Smrg | sed -e 's/$/ :/' >> "$depfile" 1925eefee25Smacallan rm -f "$tmpdepfile" 1935eefee25Smacallan ;; 1945eefee25Smacallan 1955eefee25Smacallanhp) 1965eefee25Smacallan # This case exists only to let depend.m4 do its work. It works by 1975eefee25Smacallan # looking at the text of this script. This case will never be run, 1985eefee25Smacallan # since it is checked for above. 1995eefee25Smacallan exit 1 2005eefee25Smacallan ;; 2015eefee25Smacallan 2025eefee25Smacallansgi) 2035eefee25Smacallan if test "$libtool" = yes; then 2045eefee25Smacallan "$@" "-Wp,-MDupdate,$tmpdepfile" 2055eefee25Smacallan else 2065eefee25Smacallan "$@" -MDupdate "$tmpdepfile" 2075eefee25Smacallan fi 2085eefee25Smacallan stat=$? 2095eefee25Smacallan if test $stat -eq 0; then : 2105eefee25Smacallan else 2115eefee25Smacallan rm -f "$tmpdepfile" 2125eefee25Smacallan exit $stat 2135eefee25Smacallan fi 2145eefee25Smacallan rm -f "$depfile" 2155eefee25Smacallan 2165eefee25Smacallan if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 2175eefee25Smacallan echo "$object : \\" > "$depfile" 2185eefee25Smacallan 2195eefee25Smacallan # Clip off the initial element (the dependent). Don't try to be 2205eefee25Smacallan # clever and replace this with sed code, as IRIX sed won't handle 2215eefee25Smacallan # lines with more than a fixed number of characters (4096 in 2225eefee25Smacallan # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 223dc99b369Smrg # the IRIX cc adds comments like '#:fec' to the end of the 2245eefee25Smacallan # dependency line. 225dc99b369Smrg tr ' ' "$nl" < "$tmpdepfile" \ 2265eefee25Smacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 227dc99b369Smrg tr "$nl" ' ' >> "$depfile" 228dc99b369Smrg echo >> "$depfile" 2295eefee25Smacallan 2305eefee25Smacallan # The second pass generates a dummy entry for each header file. 231dc99b369Smrg tr ' ' "$nl" < "$tmpdepfile" \ 2325eefee25Smacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 233dc99b369Smrg >> "$depfile" 2345eefee25Smacallan else 2355eefee25Smacallan # The sourcefile does not contain any dependencies, so just 2365eefee25Smacallan # store a dummy comment line, to avoid errors with the Makefile 2375eefee25Smacallan # "include basename.Plo" scheme. 2385eefee25Smacallan echo "#dummy" > "$depfile" 2395eefee25Smacallan fi 2405eefee25Smacallan rm -f "$tmpdepfile" 2415eefee25Smacallan ;; 2425eefee25Smacallan 243dc99b369Smrgxlc) 244dc99b369Smrg # This case exists only to let depend.m4 do its work. It works by 245dc99b369Smrg # looking at the text of this script. This case will never be run, 246dc99b369Smrg # since it is checked for above. 247dc99b369Smrg exit 1 248dc99b369Smrg ;; 249dc99b369Smrg 2505eefee25Smacallanaix) 2515eefee25Smacallan # The C for AIX Compiler uses -M and outputs the dependencies 2525eefee25Smacallan # in a .u file. In older versions, this file always lives in the 253dc99b369Smrg # current directory. Also, the AIX compiler puts '$object:' at the 2545eefee25Smacallan # start of each line; $object doesn't have directory information. 2555eefee25Smacallan # Version 6 uses the directory in both cases. 25662ab96baSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 25762ab96baSmrg test "x$dir" = "x$object" && dir= 25862ab96baSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2595eefee25Smacallan if test "$libtool" = yes; then 26062ab96baSmrg tmpdepfile1=$dir$base.u 26162ab96baSmrg tmpdepfile2=$base.u 26262ab96baSmrg tmpdepfile3=$dir.libs/$base.u 2635eefee25Smacallan "$@" -Wc,-M 2645eefee25Smacallan else 26562ab96baSmrg tmpdepfile1=$dir$base.u 26662ab96baSmrg tmpdepfile2=$dir$base.u 26762ab96baSmrg tmpdepfile3=$dir$base.u 2685eefee25Smacallan "$@" -M 2695eefee25Smacallan fi 2705eefee25Smacallan stat=$? 2715eefee25Smacallan 2725eefee25Smacallan if test $stat -eq 0; then : 2735eefee25Smacallan else 27462ab96baSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2755eefee25Smacallan exit $stat 2765eefee25Smacallan fi 2775eefee25Smacallan 27862ab96baSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 27962ab96baSmrg do 28062ab96baSmrg test -f "$tmpdepfile" && break 28162ab96baSmrg done 2825eefee25Smacallan if test -f "$tmpdepfile"; then 283dc99b369Smrg # Each line is of the form 'foo.o: dependent.h'. 2845eefee25Smacallan # Do two passes, one to just change these to 285dc99b369Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 28662ab96baSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 287dc99b369Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2885eefee25Smacallan else 2895eefee25Smacallan # The sourcefile does not contain any dependencies, so just 2905eefee25Smacallan # store a dummy comment line, to avoid errors with the Makefile 2915eefee25Smacallan # "include basename.Plo" scheme. 2925eefee25Smacallan echo "#dummy" > "$depfile" 2935eefee25Smacallan fi 2945eefee25Smacallan rm -f "$tmpdepfile" 2955eefee25Smacallan ;; 2965eefee25Smacallan 2975eefee25Smacallanicc) 298dc99b369Smrg # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. 299dc99b369Smrg # However on 300dc99b369Smrg # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c 3015eefee25Smacallan # ICC 7.0 will fill foo.d with something like 3025eefee25Smacallan # foo.o: sub/foo.c 3035eefee25Smacallan # foo.o: sub/foo.h 304dc99b369Smrg # which is wrong. We want 3055eefee25Smacallan # sub/foo.o: sub/foo.c 3065eefee25Smacallan # sub/foo.o: sub/foo.h 3075eefee25Smacallan # sub/foo.c: 3085eefee25Smacallan # sub/foo.h: 3095eefee25Smacallan # ICC 7.1 will output 3105eefee25Smacallan # foo.o: sub/foo.c sub/foo.h 311dc99b369Smrg # and will wrap long lines using '\': 3125eefee25Smacallan # foo.o: sub/foo.c ... \ 3135eefee25Smacallan # sub/foo.h ... \ 3145eefee25Smacallan # ... 315dc99b369Smrg # tcc 0.9.26 (FIXME still under development at the moment of writing) 316dc99b369Smrg # will emit a similar output, but also prepend the continuation lines 317dc99b369Smrg # with horizontal tabulation characters. 3185eefee25Smacallan "$@" -MD -MF "$tmpdepfile" 3195eefee25Smacallan stat=$? 3205eefee25Smacallan if test $stat -eq 0; then : 3215eefee25Smacallan else 3225eefee25Smacallan rm -f "$tmpdepfile" 3235eefee25Smacallan exit $stat 3245eefee25Smacallan fi 3255eefee25Smacallan rm -f "$depfile" 326dc99b369Smrg # Each line is of the form 'foo.o: dependent.h', 327dc99b369Smrg # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. 328dc99b369Smrg # Do two passes, one to just change these to 329dc99b369Smrg # '$object: dependent.h' and one to simply 'dependent.h:'. 330dc99b369Smrg sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ 331dc99b369Smrg < "$tmpdepfile" > "$depfile" 332dc99b369Smrg sed ' 333dc99b369Smrg s/[ '"$tab"'][ '"$tab"']*/ /g 334dc99b369Smrg s/^ *// 335dc99b369Smrg s/ *\\*$// 336dc99b369Smrg s/^[^:]*: *// 337dc99b369Smrg /^$/d 338dc99b369Smrg /:$/d 339dc99b369Smrg s/$/ :/ 340dc99b369Smrg ' < "$tmpdepfile" >> "$depfile" 341dc99b369Smrg rm -f "$tmpdepfile" 342dc99b369Smrg ;; 343dc99b369Smrg 344dc99b369Smrg## The order of this option in the case statement is important, since the 345dc99b369Smrg## shell code in configure will try each of these formats in the order 346dc99b369Smrg## listed in this file. A plain '-MD' option would be understood by many 347dc99b369Smrg## compilers, so we must ensure this comes after the gcc and icc options. 348dc99b369Smrgpgcc) 349dc99b369Smrg # Portland's C compiler understands '-MD'. 350dc99b369Smrg # Will always output deps to 'file.d' where file is the root name of the 351dc99b369Smrg # source file under compilation, even if file resides in a subdirectory. 352dc99b369Smrg # The object file name does not affect the name of the '.d' file. 353dc99b369Smrg # pgcc 10.2 will output 354dc99b369Smrg # foo.o: sub/foo.c sub/foo.h 355dc99b369Smrg # and will wrap long lines using '\' : 356dc99b369Smrg # foo.o: sub/foo.c ... \ 357dc99b369Smrg # sub/foo.h ... \ 358dc99b369Smrg # ... 359dc99b369Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 360dc99b369Smrg test "x$dir" = "x$object" && dir= 361dc99b369Smrg # Use the source, not the object, to determine the base name, since 362dc99b369Smrg # that's sadly what pgcc will do too. 363dc99b369Smrg base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'` 364dc99b369Smrg tmpdepfile="$base.d" 365dc99b369Smrg 366dc99b369Smrg # For projects that build the same source file twice into different object 367dc99b369Smrg # files, the pgcc approach of using the *source* file root name can cause 368dc99b369Smrg # problems in parallel builds. Use a locking strategy to avoid stomping on 369dc99b369Smrg # the same $tmpdepfile. 370dc99b369Smrg lockdir="$base.d-lock" 371dc99b369Smrg trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15 372dc99b369Smrg numtries=100 373dc99b369Smrg i=$numtries 374dc99b369Smrg while test $i -gt 0 ; do 375dc99b369Smrg # mkdir is a portable test-and-set. 376dc99b369Smrg if mkdir $lockdir 2>/dev/null; then 377dc99b369Smrg # This process acquired the lock. 378dc99b369Smrg "$@" -MD 379dc99b369Smrg stat=$? 380dc99b369Smrg # Release the lock. 381dc99b369Smrg rm -rf $lockdir 382dc99b369Smrg break 383dc99b369Smrg else 384dc99b369Smrg ## the lock is being held by a different process, 385dc99b369Smrg ## wait until the winning process is done or we timeout 386dc99b369Smrg while test -d $lockdir && test $i -gt 0; do 387dc99b369Smrg sleep 1 388dc99b369Smrg i=`expr $i - 1` 389dc99b369Smrg done 390dc99b369Smrg fi 391dc99b369Smrg i=`expr $i - 1` 392dc99b369Smrg done 393dc99b369Smrg trap - 1 2 13 15 394dc99b369Smrg if test $i -le 0; then 395dc99b369Smrg echo "$0: failed to acquire lock after $numtries attempts" >&2 396dc99b369Smrg echo "$0: check lockdir '$lockdir'" >&2 397dc99b369Smrg exit 1 398dc99b369Smrg fi 399dc99b369Smrg 400dc99b369Smrg if test $stat -ne 0; then 401dc99b369Smrg rm -f "$tmpdepfile" 402dc99b369Smrg exit $stat 403dc99b369Smrg fi 404dc99b369Smrg rm -f "$depfile" 4055eefee25Smacallan # Each line is of the form `foo.o: dependent.h', 4065eefee25Smacallan # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 4075eefee25Smacallan # Do two passes, one to just change these to 4085eefee25Smacallan # `$object: dependent.h' and one to simply `dependent.h:'. 4095eefee25Smacallan sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 4105eefee25Smacallan # Some versions of the HPUX 10.20 sed can't process this invocation 4115eefee25Smacallan # correctly. Breaking it into two sed invocations is a workaround. 4125eefee25Smacallan sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 4135eefee25Smacallan sed -e 's/$/ :/' >> "$depfile" 4145eefee25Smacallan rm -f "$tmpdepfile" 4155eefee25Smacallan ;; 4165eefee25Smacallan 41762ab96baSmrghp2) 41862ab96baSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 41962ab96baSmrg # compilers, which have integrated preprocessors. The correct option 42062ab96baSmrg # to use with these is +Maked; it writes dependencies to a file named 42162ab96baSmrg # 'foo.d', which lands next to the object file, wherever that 42262ab96baSmrg # happens to be. 42362ab96baSmrg # Much of this is similar to the tru64 case; see comments there. 42462ab96baSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 42562ab96baSmrg test "x$dir" = "x$object" && dir= 42662ab96baSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 42762ab96baSmrg if test "$libtool" = yes; then 42862ab96baSmrg tmpdepfile1=$dir$base.d 42962ab96baSmrg tmpdepfile2=$dir.libs/$base.d 43062ab96baSmrg "$@" -Wc,+Maked 43162ab96baSmrg else 43262ab96baSmrg tmpdepfile1=$dir$base.d 43362ab96baSmrg tmpdepfile2=$dir$base.d 43462ab96baSmrg "$@" +Maked 43562ab96baSmrg fi 43662ab96baSmrg stat=$? 43762ab96baSmrg if test $stat -eq 0; then : 43862ab96baSmrg else 43962ab96baSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 44062ab96baSmrg exit $stat 44162ab96baSmrg fi 44262ab96baSmrg 44362ab96baSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 44462ab96baSmrg do 44562ab96baSmrg test -f "$tmpdepfile" && break 44662ab96baSmrg done 44762ab96baSmrg if test -f "$tmpdepfile"; then 44862ab96baSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 449dc99b369Smrg # Add 'dependent.h:' lines. 450dc99b369Smrg sed -ne '2,${ 451dc99b369Smrg s/^ *// 452dc99b369Smrg s/ \\*$// 453dc99b369Smrg s/$/:/ 454dc99b369Smrg p 455dc99b369Smrg }' "$tmpdepfile" >> "$depfile" 45662ab96baSmrg else 45762ab96baSmrg echo "#dummy" > "$depfile" 45862ab96baSmrg fi 45962ab96baSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 46062ab96baSmrg ;; 46162ab96baSmrg 4625eefee25Smacallantru64) 4635eefee25Smacallan # The Tru64 compiler uses -MD to generate dependencies as a side 464dc99b369Smrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 4655eefee25Smacallan # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 466dc99b369Smrg # dependencies in 'foo.d' instead, so we check for that too. 4675eefee25Smacallan # Subdirectories are respected. 4685eefee25Smacallan dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 4695eefee25Smacallan test "x$dir" = "x$object" && dir= 4705eefee25Smacallan base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 4715eefee25Smacallan 4725eefee25Smacallan if test "$libtool" = yes; then 4735eefee25Smacallan # With Tru64 cc, shared objects can also be used to make a 47462ab96baSmrg # static library. This mechanism is used in libtool 1.4 series to 4755eefee25Smacallan # handle both shared and static libraries in a single compilation. 4765eefee25Smacallan # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 4775eefee25Smacallan # 4785eefee25Smacallan # With libtool 1.5 this exception was removed, and libtool now 4795eefee25Smacallan # generates 2 separate objects for the 2 libraries. These two 48062ab96baSmrg # compilations output dependencies in $dir.libs/$base.o.d and 4815eefee25Smacallan # in $dir$base.o.d. We have to check for both files, because 4825eefee25Smacallan # one of the two compilations can be disabled. We should prefer 4835eefee25Smacallan # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 4845eefee25Smacallan # automatically cleaned when .libs/ is deleted, while ignoring 4855eefee25Smacallan # the former would cause a distcleancheck panic. 4865eefee25Smacallan tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 4875eefee25Smacallan tmpdepfile2=$dir$base.o.d # libtool 1.5 4885eefee25Smacallan tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 4895eefee25Smacallan tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 4905eefee25Smacallan "$@" -Wc,-MD 4915eefee25Smacallan else 4925eefee25Smacallan tmpdepfile1=$dir$base.o.d 4935eefee25Smacallan tmpdepfile2=$dir$base.d 4945eefee25Smacallan tmpdepfile3=$dir$base.d 4955eefee25Smacallan tmpdepfile4=$dir$base.d 4965eefee25Smacallan "$@" -MD 4975eefee25Smacallan fi 4985eefee25Smacallan 4995eefee25Smacallan stat=$? 5005eefee25Smacallan if test $stat -eq 0; then : 5015eefee25Smacallan else 5025eefee25Smacallan rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 5035eefee25Smacallan exit $stat 5045eefee25Smacallan fi 5055eefee25Smacallan 5065eefee25Smacallan for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 5075eefee25Smacallan do 5085eefee25Smacallan test -f "$tmpdepfile" && break 5095eefee25Smacallan done 5105eefee25Smacallan if test -f "$tmpdepfile"; then 5115eefee25Smacallan sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 512dc99b369Smrg sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 5135eefee25Smacallan else 5145eefee25Smacallan echo "#dummy" > "$depfile" 5155eefee25Smacallan fi 5165eefee25Smacallan rm -f "$tmpdepfile" 5175eefee25Smacallan ;; 5185eefee25Smacallan 519dc99b369Smrgmsvc7) 520dc99b369Smrg if test "$libtool" = yes; then 521dc99b369Smrg showIncludes=-Wc,-showIncludes 522dc99b369Smrg else 523dc99b369Smrg showIncludes=-showIncludes 524dc99b369Smrg fi 525dc99b369Smrg "$@" $showIncludes > "$tmpdepfile" 526dc99b369Smrg stat=$? 527dc99b369Smrg grep -v '^Note: including file: ' "$tmpdepfile" 528dc99b369Smrg if test "$stat" = 0; then : 529dc99b369Smrg else 530dc99b369Smrg rm -f "$tmpdepfile" 531dc99b369Smrg exit $stat 532dc99b369Smrg fi 533dc99b369Smrg rm -f "$depfile" 534dc99b369Smrg echo "$object : \\" > "$depfile" 535dc99b369Smrg # The first sed program below extracts the file names and escapes 536dc99b369Smrg # backslashes for cygpath. The second sed program outputs the file 537dc99b369Smrg # name when reading, but also accumulates all include files in the 538dc99b369Smrg # hold buffer in order to output them again at the end. This only 539dc99b369Smrg # works with sed implementations that can handle large buffers. 540dc99b369Smrg sed < "$tmpdepfile" -n ' 541dc99b369Smrg/^Note: including file: *\(.*\)/ { 542dc99b369Smrg s//\1/ 543dc99b369Smrg s/\\/\\\\/g 544dc99b369Smrg p 545dc99b369Smrg}' | $cygpath_u | sort -u | sed -n ' 546dc99b369Smrgs/ /\\ /g 547dc99b369Smrgs/\(.*\)/'"$tab"'\1 \\/p 548dc99b369Smrgs/.\(.*\) \\/\1:/ 549dc99b369SmrgH 550dc99b369Smrg$ { 551dc99b369Smrg s/.*/'"$tab"'/ 552dc99b369Smrg G 553dc99b369Smrg p 554dc99b369Smrg}' >> "$depfile" 555dc99b369Smrg rm -f "$tmpdepfile" 556dc99b369Smrg ;; 557dc99b369Smrg 558dc99b369Smrgmsvc7msys) 559dc99b369Smrg # This case exists only to let depend.m4 do its work. It works by 560dc99b369Smrg # looking at the text of this script. This case will never be run, 561dc99b369Smrg # since it is checked for above. 562dc99b369Smrg exit 1 563dc99b369Smrg ;; 564dc99b369Smrg 5655eefee25Smacallan#nosideeffect) 5665eefee25Smacallan # This comment above is used by automake to tell side-effect 5675eefee25Smacallan # dependency tracking mechanisms from slower ones. 5685eefee25Smacallan 5695eefee25Smacallandashmstdout) 5705eefee25Smacallan # Important note: in order to support this mode, a compiler *must* 5715eefee25Smacallan # always write the preprocessed file to stdout, regardless of -o. 5725eefee25Smacallan "$@" || exit $? 5735eefee25Smacallan 5745eefee25Smacallan # Remove the call to Libtool. 5755eefee25Smacallan if test "$libtool" = yes; then 576dc99b369Smrg while test "X$1" != 'X--mode=compile'; do 5775eefee25Smacallan shift 5785eefee25Smacallan done 5795eefee25Smacallan shift 5805eefee25Smacallan fi 5815eefee25Smacallan 582dc99b369Smrg # Remove '-o $object'. 5835eefee25Smacallan IFS=" " 5845eefee25Smacallan for arg 5855eefee25Smacallan do 5865eefee25Smacallan case $arg in 5875eefee25Smacallan -o) 5885eefee25Smacallan shift 5895eefee25Smacallan ;; 5905eefee25Smacallan $object) 5915eefee25Smacallan shift 5925eefee25Smacallan ;; 5935eefee25Smacallan *) 5945eefee25Smacallan set fnord "$@" "$arg" 5955eefee25Smacallan shift # fnord 5965eefee25Smacallan shift # $arg 5975eefee25Smacallan ;; 5985eefee25Smacallan esac 5995eefee25Smacallan done 6005eefee25Smacallan 6015eefee25Smacallan test -z "$dashmflag" && dashmflag=-M 602dc99b369Smrg # Require at least two characters before searching for ':' 6035eefee25Smacallan # in the target name. This is to cope with DOS-style filenames: 604dc99b369Smrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 6055eefee25Smacallan "$@" $dashmflag | 606dc99b369Smrg sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" 6075eefee25Smacallan rm -f "$depfile" 6085eefee25Smacallan cat < "$tmpdepfile" > "$depfile" 609dc99b369Smrg tr ' ' "$nl" < "$tmpdepfile" | \ 6105eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation 6115eefee25Smacallan## correctly. Breaking it into two sed invocations is a workaround. 6125eefee25Smacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 6135eefee25Smacallan rm -f "$tmpdepfile" 6145eefee25Smacallan ;; 6155eefee25Smacallan 6165eefee25SmacallandashXmstdout) 6175eefee25Smacallan # This case only exists to satisfy depend.m4. It is never actually 6185eefee25Smacallan # run, as this mode is specially recognized in the preamble. 6195eefee25Smacallan exit 1 6205eefee25Smacallan ;; 6215eefee25Smacallan 6225eefee25Smacallanmakedepend) 6235eefee25Smacallan "$@" || exit $? 6245eefee25Smacallan # Remove any Libtool call 6255eefee25Smacallan if test "$libtool" = yes; then 626dc99b369Smrg while test "X$1" != 'X--mode=compile'; do 6275eefee25Smacallan shift 6285eefee25Smacallan done 6295eefee25Smacallan shift 6305eefee25Smacallan fi 6315eefee25Smacallan # X makedepend 6325eefee25Smacallan shift 633dc99b369Smrg cleared=no eat=no 634dc99b369Smrg for arg 635dc99b369Smrg do 6365eefee25Smacallan case $cleared in 6375eefee25Smacallan no) 6385eefee25Smacallan set ""; shift 6395eefee25Smacallan cleared=yes ;; 6405eefee25Smacallan esac 641dc99b369Smrg if test $eat = yes; then 642dc99b369Smrg eat=no 643dc99b369Smrg continue 644dc99b369Smrg fi 6455eefee25Smacallan case "$arg" in 6465eefee25Smacallan -D*|-I*) 6475eefee25Smacallan set fnord "$@" "$arg"; shift ;; 6485eefee25Smacallan # Strip any option that makedepend may not understand. Remove 6495eefee25Smacallan # the object too, otherwise makedepend will parse it as a source file. 650dc99b369Smrg -arch) 651dc99b369Smrg eat=yes ;; 6525eefee25Smacallan -*|$object) 6535eefee25Smacallan ;; 6545eefee25Smacallan *) 6555eefee25Smacallan set fnord "$@" "$arg"; shift ;; 6565eefee25Smacallan esac 6575eefee25Smacallan done 658dc99b369Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 6595eefee25Smacallan touch "$tmpdepfile" 6605eefee25Smacallan ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 6615eefee25Smacallan rm -f "$depfile" 662dc99b369Smrg # makedepend may prepend the VPATH from the source file name to the object. 663dc99b369Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 664dc99b369Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 665dc99b369Smrg sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ 6665eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation 6675eefee25Smacallan## correctly. Breaking it into two sed invocations is a workaround. 6685eefee25Smacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 6695eefee25Smacallan rm -f "$tmpdepfile" "$tmpdepfile".bak 6705eefee25Smacallan ;; 6715eefee25Smacallan 6725eefee25Smacallancpp) 6735eefee25Smacallan # Important note: in order to support this mode, a compiler *must* 6745eefee25Smacallan # always write the preprocessed file to stdout. 6755eefee25Smacallan "$@" || exit $? 6765eefee25Smacallan 6775eefee25Smacallan # Remove the call to Libtool. 6785eefee25Smacallan if test "$libtool" = yes; then 679dc99b369Smrg while test "X$1" != 'X--mode=compile'; do 6805eefee25Smacallan shift 6815eefee25Smacallan done 6825eefee25Smacallan shift 6835eefee25Smacallan fi 6845eefee25Smacallan 685dc99b369Smrg # Remove '-o $object'. 6865eefee25Smacallan IFS=" " 6875eefee25Smacallan for arg 6885eefee25Smacallan do 6895eefee25Smacallan case $arg in 6905eefee25Smacallan -o) 6915eefee25Smacallan shift 6925eefee25Smacallan ;; 6935eefee25Smacallan $object) 6945eefee25Smacallan shift 6955eefee25Smacallan ;; 6965eefee25Smacallan *) 6975eefee25Smacallan set fnord "$@" "$arg" 6985eefee25Smacallan shift # fnord 6995eefee25Smacallan shift # $arg 7005eefee25Smacallan ;; 7015eefee25Smacallan esac 7025eefee25Smacallan done 7035eefee25Smacallan 7045eefee25Smacallan "$@" -E | 7055eefee25Smacallan sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 7065eefee25Smacallan -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 7075eefee25Smacallan sed '$ s: \\$::' > "$tmpdepfile" 7085eefee25Smacallan rm -f "$depfile" 7095eefee25Smacallan echo "$object : \\" > "$depfile" 7105eefee25Smacallan cat < "$tmpdepfile" >> "$depfile" 7115eefee25Smacallan sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 7125eefee25Smacallan rm -f "$tmpdepfile" 7135eefee25Smacallan ;; 7145eefee25Smacallan 7155eefee25Smacallanmsvisualcpp) 7165eefee25Smacallan # Important note: in order to support this mode, a compiler *must* 717dc99b369Smrg # always write the preprocessed file to stdout. 7185eefee25Smacallan "$@" || exit $? 719dc99b369Smrg 720dc99b369Smrg # Remove the call to Libtool. 721dc99b369Smrg if test "$libtool" = yes; then 722dc99b369Smrg while test "X$1" != 'X--mode=compile'; do 723dc99b369Smrg shift 724dc99b369Smrg done 725dc99b369Smrg shift 726dc99b369Smrg fi 727dc99b369Smrg 7285eefee25Smacallan IFS=" " 7295eefee25Smacallan for arg 7305eefee25Smacallan do 7315eefee25Smacallan case "$arg" in 732dc99b369Smrg -o) 733dc99b369Smrg shift 734dc99b369Smrg ;; 735dc99b369Smrg $object) 736dc99b369Smrg shift 737dc99b369Smrg ;; 7385eefee25Smacallan "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 7395eefee25Smacallan set fnord "$@" 7405eefee25Smacallan shift 7415eefee25Smacallan shift 7425eefee25Smacallan ;; 7435eefee25Smacallan *) 7445eefee25Smacallan set fnord "$@" "$arg" 7455eefee25Smacallan shift 7465eefee25Smacallan shift 7475eefee25Smacallan ;; 7485eefee25Smacallan esac 7495eefee25Smacallan done 750dc99b369Smrg "$@" -E 2>/dev/null | 751dc99b369Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 7525eefee25Smacallan rm -f "$depfile" 7535eefee25Smacallan echo "$object : \\" > "$depfile" 754dc99b369Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 755dc99b369Smrg echo "$tab" >> "$depfile" 756dc99b369Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 7575eefee25Smacallan rm -f "$tmpdepfile" 7585eefee25Smacallan ;; 7595eefee25Smacallan 760dc99b369Smrgmsvcmsys) 761dc99b369Smrg # This case exists only to let depend.m4 do its work. It works by 762dc99b369Smrg # looking at the text of this script. This case will never be run, 763dc99b369Smrg # since it is checked for above. 764dc99b369Smrg exit 1 765dc99b369Smrg ;; 766dc99b369Smrg 7675eefee25Smacallannone) 7685eefee25Smacallan exec "$@" 7695eefee25Smacallan ;; 7705eefee25Smacallan 7715eefee25Smacallan*) 7725eefee25Smacallan echo "Unknown depmode $depmode" 1>&2 7735eefee25Smacallan exit 1 7745eefee25Smacallan ;; 7755eefee25Smacallanesac 7765eefee25Smacallan 7775eefee25Smacallanexit 0 7785eefee25Smacallan 7795eefee25Smacallan# Local Variables: 7805eefee25Smacallan# mode: shell-script 7815eefee25Smacallan# sh-indentation: 2 7825eefee25Smacallan# eval: (add-hook 'write-file-hooks 'time-stamp) 7835eefee25Smacallan# time-stamp-start: "scriptversion=" 7845eefee25Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 785dc99b369Smrg# time-stamp-time-zone: "UTC" 786dc99b369Smrg# time-stamp-end: "; # UTC" 7875eefee25Smacallan# End: 788