123a0898aSmrg#! /bin/sh 223a0898aSmrg# depcomp - compile a program generating dependencies as side-effects 323a0898aSmrg 4b020570bSmrgscriptversion=2013-05-30.07; # UTC 523a0898aSmrg 6121a5469Smrg# Copyright (C) 1999-2014 Free Software Foundation, Inc. 723a0898aSmrg 823a0898aSmrg# This program is free software; you can redistribute it and/or modify 923a0898aSmrg# it under the terms of the GNU General Public License as published by 1023a0898aSmrg# the Free Software Foundation; either version 2, or (at your option) 1123a0898aSmrg# any later version. 1223a0898aSmrg 1323a0898aSmrg# This program is distributed in the hope that it will be useful, 1423a0898aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1523a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1623a0898aSmrg# GNU General Public License for more details. 1723a0898aSmrg 1823a0898aSmrg# You should have received a copy of the GNU General Public License 1941c30155Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2023a0898aSmrg 2123a0898aSmrg# As a special exception to the GNU General Public License, if you 2223a0898aSmrg# distribute this file as part of a program that contains a 2323a0898aSmrg# configuration script generated by Autoconf, you may include it under 2423a0898aSmrg# the same distribution terms that you use for the rest of that program. 2523a0898aSmrg 2623a0898aSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2723a0898aSmrg 2823a0898aSmrgcase $1 in 2923a0898aSmrg '') 30b020570bSmrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 31b020570bSmrg exit 1; 32b020570bSmrg ;; 3323a0898aSmrg -h | --h*) 3423a0898aSmrg cat <<\EOF 3523a0898aSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3623a0898aSmrg 3723a0898aSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3823a0898aSmrgas side-effects. 3923a0898aSmrg 4023a0898aSmrgEnvironment variables: 4123a0898aSmrg depmode Dependency tracking mode. 42b020570bSmrg source Source file read by 'PROGRAMS ARGS'. 43b020570bSmrg object Object file output by 'PROGRAMS ARGS'. 4423a0898aSmrg DEPDIR directory where to store dependencies. 4523a0898aSmrg depfile Dependency file to output. 46b020570bSmrg tmpdepfile Temporary file to use when outputting dependencies. 4723a0898aSmrg libtool Whether libtool is used (yes/no). 4823a0898aSmrg 4923a0898aSmrgReport bugs to <bug-automake@gnu.org>. 5023a0898aSmrgEOF 5123a0898aSmrg exit $? 5223a0898aSmrg ;; 5323a0898aSmrg -v | --v*) 5423a0898aSmrg echo "depcomp $scriptversion" 5523a0898aSmrg exit $? 5623a0898aSmrg ;; 5723a0898aSmrgesac 5823a0898aSmrg 59b020570bSmrg# Get the directory component of the given path, and save it in the 60b020570bSmrg# global variables '$dir'. Note that this directory component will 61b020570bSmrg# be either empty or ending with a '/' character. This is deliberate. 62b020570bSmrgset_dir_from () 63b020570bSmrg{ 64b020570bSmrg case $1 in 65b020570bSmrg */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 66b020570bSmrg *) dir=;; 67b020570bSmrg esac 68b020570bSmrg} 69b020570bSmrg 70b020570bSmrg# Get the suffix-stripped basename of the given path, and save it the 71b020570bSmrg# global variable '$base'. 72b020570bSmrgset_base_from () 73b020570bSmrg{ 74b020570bSmrg base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 75b020570bSmrg} 76b020570bSmrg 77b020570bSmrg# If no dependency file was actually created by the compiler invocation, 78b020570bSmrg# we still have to create a dummy depfile, to avoid errors with the 79b020570bSmrg# Makefile "include basename.Plo" scheme. 80b020570bSmrgmake_dummy_depfile () 81b020570bSmrg{ 82b020570bSmrg echo "#dummy" > "$depfile" 83b020570bSmrg} 84b020570bSmrg 85b020570bSmrg# Factor out some common post-processing of the generated depfile. 86b020570bSmrg# Requires the auxiliary global variable '$tmpdepfile' to be set. 87b020570bSmrgaix_post_process_depfile () 88b020570bSmrg{ 89b020570bSmrg # If the compiler actually managed to produce a dependency file, 90b020570bSmrg # post-process it. 91b020570bSmrg if test -f "$tmpdepfile"; then 92b020570bSmrg # Each line is of the form 'foo.o: dependency.h'. 93b020570bSmrg # Do two passes, one to just change these to 94b020570bSmrg # $object: dependency.h 95b020570bSmrg # and one to simply output 96b020570bSmrg # dependency.h: 97b020570bSmrg # which is needed to avoid the deleted-header problem. 98b020570bSmrg { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 99b020570bSmrg sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 100b020570bSmrg } > "$depfile" 101b020570bSmrg rm -f "$tmpdepfile" 102b020570bSmrg else 103b020570bSmrg make_dummy_depfile 104b020570bSmrg fi 105b020570bSmrg} 106b020570bSmrg 107b020570bSmrg# A tabulation character. 108b020570bSmrgtab=' ' 109b020570bSmrg# A newline character. 110b020570bSmrgnl=' 111b020570bSmrg' 112b020570bSmrg# Character ranges might be problematic outside the C locale. 113b020570bSmrg# These definitions help. 114b020570bSmrgupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 115b020570bSmrglower=abcdefghijklmnopqrstuvwxyz 116b020570bSmrgdigits=0123456789 117b020570bSmrgalpha=${upper}${lower} 118b020570bSmrg 11923a0898aSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 12023a0898aSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 12123a0898aSmrg exit 1 12223a0898aSmrgfi 12323a0898aSmrg 12423a0898aSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 12523a0898aSmrgdepfile=${depfile-`echo "$object" | 12623a0898aSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 12723a0898aSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 12823a0898aSmrg 12923a0898aSmrgrm -f "$tmpdepfile" 13023a0898aSmrg 131b020570bSmrg# Avoid interferences from the environment. 132b020570bSmrggccflag= dashmflag= 133b020570bSmrg 13423a0898aSmrg# Some modes work just like other modes, but use different flags. We 13523a0898aSmrg# parameterize here, but still list the modes in the big case below, 13623a0898aSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 13723a0898aSmrg# here, because this file can only contain one case statement. 13823a0898aSmrgif test "$depmode" = hp; then 13923a0898aSmrg # HP compiler uses -M and no extra arg. 14023a0898aSmrg gccflag=-M 14123a0898aSmrg depmode=gcc 14223a0898aSmrgfi 14323a0898aSmrg 14423a0898aSmrgif test "$depmode" = dashXmstdout; then 145b020570bSmrg # This is just like dashmstdout with a different argument. 146b020570bSmrg dashmflag=-xM 147b020570bSmrg depmode=dashmstdout 14823a0898aSmrgfi 14923a0898aSmrg 15041c30155Smrgcygpath_u="cygpath -u -f -" 15141c30155Smrgif test "$depmode" = msvcmsys; then 152b020570bSmrg # This is just like msvisualcpp but w/o cygpath translation. 153b020570bSmrg # Just convert the backslash-escaped backslashes to single forward 154b020570bSmrg # slashes to satisfy depend.m4 155b020570bSmrg cygpath_u='sed s,\\\\,/,g' 156b020570bSmrg depmode=msvisualcpp 157b020570bSmrgfi 158b020570bSmrg 159b020570bSmrgif test "$depmode" = msvc7msys; then 160b020570bSmrg # This is just like msvc7 but w/o cygpath translation. 161b020570bSmrg # Just convert the backslash-escaped backslashes to single forward 162b020570bSmrg # slashes to satisfy depend.m4 163b020570bSmrg cygpath_u='sed s,\\\\,/,g' 164b020570bSmrg depmode=msvc7 165b020570bSmrgfi 166b020570bSmrg 167b020570bSmrgif test "$depmode" = xlc; then 168b020570bSmrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 169b020570bSmrg gccflag=-qmakedep=gcc,-MF 170b020570bSmrg depmode=gcc 17141c30155Smrgfi 17241c30155Smrg 17323a0898aSmrgcase "$depmode" in 17423a0898aSmrggcc3) 17523a0898aSmrg## gcc 3 implements dependency tracking that does exactly what 17623a0898aSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 17723a0898aSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 17823a0898aSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 17923a0898aSmrg## the command line argument order; so add the flags where they 18023a0898aSmrg## appear in depend2.am. Note that the slowdown incurred here 18123a0898aSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 18223a0898aSmrg for arg 18323a0898aSmrg do 18423a0898aSmrg case $arg in 18523a0898aSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 18623a0898aSmrg *) set fnord "$@" "$arg" ;; 18723a0898aSmrg esac 18823a0898aSmrg shift # fnord 18923a0898aSmrg shift # $arg 19023a0898aSmrg done 19123a0898aSmrg "$@" 19223a0898aSmrg stat=$? 193b020570bSmrg if test $stat -ne 0; then 19423a0898aSmrg rm -f "$tmpdepfile" 19523a0898aSmrg exit $stat 19623a0898aSmrg fi 19723a0898aSmrg mv "$tmpdepfile" "$depfile" 19823a0898aSmrg ;; 19923a0898aSmrg 20023a0898aSmrggcc) 201b020570bSmrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 202b020570bSmrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 203b020570bSmrg## (see the conditional assignment to $gccflag above). 20423a0898aSmrg## There are various ways to get dependency output from gcc. Here's 20523a0898aSmrg## why we pick this rather obscure method: 20623a0898aSmrg## - Don't want to use -MD because we'd like the dependencies to end 20723a0898aSmrg## up in a subdir. Having to rename by hand is ugly. 20823a0898aSmrg## (We might end up doing this anyway to support other compilers.) 20923a0898aSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 210b020570bSmrg## -MM, not -M (despite what the docs say). Also, it might not be 211b020570bSmrg## supported by the other compilers which use the 'gcc' depmode. 21223a0898aSmrg## - Using -M directly means running the compiler twice (even worse 21323a0898aSmrg## than renaming). 21423a0898aSmrg if test -z "$gccflag"; then 21523a0898aSmrg gccflag=-MD, 21623a0898aSmrg fi 21723a0898aSmrg "$@" -Wp,"$gccflag$tmpdepfile" 21823a0898aSmrg stat=$? 219b020570bSmrg if test $stat -ne 0; then 22023a0898aSmrg rm -f "$tmpdepfile" 22123a0898aSmrg exit $stat 22223a0898aSmrg fi 22323a0898aSmrg rm -f "$depfile" 22423a0898aSmrg echo "$object : \\" > "$depfile" 225b020570bSmrg # The second -e expression handles DOS-style file names with drive 226b020570bSmrg # letters. 22723a0898aSmrg sed -e 's/^[^:]*: / /' \ 22823a0898aSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229b020570bSmrg## This next piece of magic avoids the "deleted header file" problem. 23023a0898aSmrg## The problem is that when a header file which appears in a .P file 23123a0898aSmrg## is deleted, the dependency causes make to die (because there is 23223a0898aSmrg## typically no way to rebuild the header). We avoid this by adding 23323a0898aSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 23423a0898aSmrg## this for us directly. 235b020570bSmrg## Some versions of gcc put a space before the ':'. On the theory 23623a0898aSmrg## that the space means something, we add a space to the output as 237b020570bSmrg## well. hp depmode also adds that space, but also prefixes the VPATH 238b020570bSmrg## to the object. Take care to not repeat it in the output. 23923a0898aSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 24023a0898aSmrg## correctly. Breaking it into two sed invocations is a workaround. 241b020570bSmrg tr ' ' "$nl" < "$tmpdepfile" \ 242b020570bSmrg | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243b020570bSmrg | sed -e 's/$/ :/' >> "$depfile" 24423a0898aSmrg rm -f "$tmpdepfile" 24523a0898aSmrg ;; 24623a0898aSmrg 24723a0898aSmrghp) 24823a0898aSmrg # This case exists only to let depend.m4 do its work. It works by 24923a0898aSmrg # looking at the text of this script. This case will never be run, 25023a0898aSmrg # since it is checked for above. 25123a0898aSmrg exit 1 25223a0898aSmrg ;; 25323a0898aSmrg 25423a0898aSmrgsgi) 25523a0898aSmrg if test "$libtool" = yes; then 25623a0898aSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 25723a0898aSmrg else 25823a0898aSmrg "$@" -MDupdate "$tmpdepfile" 25923a0898aSmrg fi 26023a0898aSmrg stat=$? 261b020570bSmrg if test $stat -ne 0; then 26223a0898aSmrg rm -f "$tmpdepfile" 26323a0898aSmrg exit $stat 26423a0898aSmrg fi 26523a0898aSmrg rm -f "$depfile" 26623a0898aSmrg 26723a0898aSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 26823a0898aSmrg echo "$object : \\" > "$depfile" 26923a0898aSmrg # Clip off the initial element (the dependent). Don't try to be 27023a0898aSmrg # clever and replace this with sed code, as IRIX sed won't handle 27123a0898aSmrg # lines with more than a fixed number of characters (4096 in 27223a0898aSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 273b020570bSmrg # the IRIX cc adds comments like '#:fec' to the end of the 27423a0898aSmrg # dependency line. 275b020570bSmrg tr ' ' "$nl" < "$tmpdepfile" \ 276b020570bSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 277b020570bSmrg | tr "$nl" ' ' >> "$depfile" 27841c30155Smrg echo >> "$depfile" 27923a0898aSmrg # The second pass generates a dummy entry for each header file. 280b020570bSmrg tr ' ' "$nl" < "$tmpdepfile" \ 281b020570bSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 282b020570bSmrg >> "$depfile" 28323a0898aSmrg else 284b020570bSmrg make_dummy_depfile 28523a0898aSmrg fi 28623a0898aSmrg rm -f "$tmpdepfile" 28723a0898aSmrg ;; 28823a0898aSmrg 289b020570bSmrgxlc) 290b020570bSmrg # This case exists only to let depend.m4 do its work. It works by 291b020570bSmrg # looking at the text of this script. This case will never be run, 292b020570bSmrg # since it is checked for above. 293b020570bSmrg exit 1 294b020570bSmrg ;; 295b020570bSmrg 29623a0898aSmrgaix) 29723a0898aSmrg # The C for AIX Compiler uses -M and outputs the dependencies 29823a0898aSmrg # in a .u file. In older versions, this file always lives in the 299b020570bSmrg # current directory. Also, the AIX compiler puts '$object:' at the 30023a0898aSmrg # start of each line; $object doesn't have directory information. 30123a0898aSmrg # Version 6 uses the directory in both cases. 302b020570bSmrg set_dir_from "$object" 303b020570bSmrg set_base_from "$object" 30423a0898aSmrg if test "$libtool" = yes; then 30523a0898aSmrg tmpdepfile1=$dir$base.u 30623a0898aSmrg tmpdepfile2=$base.u 30723a0898aSmrg tmpdepfile3=$dir.libs/$base.u 30823a0898aSmrg "$@" -Wc,-M 30923a0898aSmrg else 31023a0898aSmrg tmpdepfile1=$dir$base.u 31123a0898aSmrg tmpdepfile2=$dir$base.u 31223a0898aSmrg tmpdepfile3=$dir$base.u 31323a0898aSmrg "$@" -M 31423a0898aSmrg fi 31523a0898aSmrg stat=$? 316b020570bSmrg if test $stat -ne 0; then 31723a0898aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 31823a0898aSmrg exit $stat 31923a0898aSmrg fi 32023a0898aSmrg 32123a0898aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 32223a0898aSmrg do 32323a0898aSmrg test -f "$tmpdepfile" && break 32423a0898aSmrg done 325b020570bSmrg aix_post_process_depfile 326b020570bSmrg ;; 327b020570bSmrg 328b020570bSmrgtcc) 329b020570bSmrg # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 330b020570bSmrg # FIXME: That version still under development at the moment of writing. 331b020570bSmrg # Make that this statement remains true also for stable, released 332b020570bSmrg # versions. 333b020570bSmrg # It will wrap lines (doesn't matter whether long or short) with a 334b020570bSmrg # trailing '\', as in: 335b020570bSmrg # 336b020570bSmrg # foo.o : \ 337b020570bSmrg # foo.c \ 338b020570bSmrg # foo.h \ 339b020570bSmrg # 340b020570bSmrg # It will put a trailing '\' even on the last line, and will use leading 341b020570bSmrg # spaces rather than leading tabs (at least since its commit 0394caf7 342b020570bSmrg # "Emit spaces for -MD"). 343b020570bSmrg "$@" -MD -MF "$tmpdepfile" 344b020570bSmrg stat=$? 345b020570bSmrg if test $stat -ne 0; then 346b020570bSmrg rm -f "$tmpdepfile" 347b020570bSmrg exit $stat 34823a0898aSmrg fi 349b020570bSmrg rm -f "$depfile" 350b020570bSmrg # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 351b020570bSmrg # We have to change lines of the first kind to '$object: \'. 352b020570bSmrg sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 353b020570bSmrg # And for each line of the second kind, we have to emit a 'dep.h:' 354b020570bSmrg # dummy dependency, to avoid the deleted-header problem. 355b020570bSmrg sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 35623a0898aSmrg rm -f "$tmpdepfile" 35723a0898aSmrg ;; 35823a0898aSmrg 359b020570bSmrg## The order of this option in the case statement is important, since the 360b020570bSmrg## shell code in configure will try each of these formats in the order 361b020570bSmrg## listed in this file. A plain '-MD' option would be understood by many 362b020570bSmrg## compilers, so we must ensure this comes after the gcc and icc options. 363b020570bSmrgpgcc) 364b020570bSmrg # Portland's C compiler understands '-MD'. 365b020570bSmrg # Will always output deps to 'file.d' where file is the root name of the 366b020570bSmrg # source file under compilation, even if file resides in a subdirectory. 367b020570bSmrg # The object file name does not affect the name of the '.d' file. 368b020570bSmrg # pgcc 10.2 will output 36923a0898aSmrg # foo.o: sub/foo.c sub/foo.h 370b020570bSmrg # and will wrap long lines using '\' : 37123a0898aSmrg # foo.o: sub/foo.c ... \ 37223a0898aSmrg # sub/foo.h ... \ 37323a0898aSmrg # ... 374b020570bSmrg set_dir_from "$object" 375b020570bSmrg # Use the source, not the object, to determine the base name, since 376b020570bSmrg # that's sadly what pgcc will do too. 377b020570bSmrg set_base_from "$source" 378b020570bSmrg tmpdepfile=$base.d 379b020570bSmrg 380b020570bSmrg # For projects that build the same source file twice into different object 381b020570bSmrg # files, the pgcc approach of using the *source* file root name can cause 382b020570bSmrg # problems in parallel builds. Use a locking strategy to avoid stomping on 383b020570bSmrg # the same $tmpdepfile. 384b020570bSmrg lockdir=$base.d-lock 385b020570bSmrg trap " 386b020570bSmrg echo '$0: caught signal, cleaning up...' >&2 387b020570bSmrg rmdir '$lockdir' 388b020570bSmrg exit 1 389b020570bSmrg " 1 2 13 15 390b020570bSmrg numtries=100 391b020570bSmrg i=$numtries 392b020570bSmrg while test $i -gt 0; do 393b020570bSmrg # mkdir is a portable test-and-set. 394b020570bSmrg if mkdir "$lockdir" 2>/dev/null; then 395b020570bSmrg # This process acquired the lock. 396b020570bSmrg "$@" -MD 397b020570bSmrg stat=$? 398b020570bSmrg # Release the lock. 399b020570bSmrg rmdir "$lockdir" 400b020570bSmrg break 401b020570bSmrg else 402b020570bSmrg # If the lock is being held by a different process, wait 403b020570bSmrg # until the winning process is done or we timeout. 404b020570bSmrg while test -d "$lockdir" && test $i -gt 0; do 405b020570bSmrg sleep 1 406b020570bSmrg i=`expr $i - 1` 407b020570bSmrg done 408b020570bSmrg fi 409b020570bSmrg i=`expr $i - 1` 410b020570bSmrg done 411b020570bSmrg trap - 1 2 13 15 412b020570bSmrg if test $i -le 0; then 413b020570bSmrg echo "$0: failed to acquire lock after $numtries attempts" >&2 414b020570bSmrg echo "$0: check lockdir '$lockdir'" >&2 415b020570bSmrg exit 1 416b020570bSmrg fi 41723a0898aSmrg 418b020570bSmrg if test $stat -ne 0; then 41923a0898aSmrg rm -f "$tmpdepfile" 42023a0898aSmrg exit $stat 42123a0898aSmrg fi 42223a0898aSmrg rm -f "$depfile" 42323a0898aSmrg # Each line is of the form `foo.o: dependent.h', 42423a0898aSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 42523a0898aSmrg # Do two passes, one to just change these to 42623a0898aSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 42723a0898aSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 42823a0898aSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 42923a0898aSmrg # correctly. Breaking it into two sed invocations is a workaround. 430b020570bSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 431b020570bSmrg | sed -e 's/$/ :/' >> "$depfile" 43223a0898aSmrg rm -f "$tmpdepfile" 43323a0898aSmrg ;; 43423a0898aSmrg 43523a0898aSmrghp2) 43623a0898aSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 43723a0898aSmrg # compilers, which have integrated preprocessors. The correct option 43823a0898aSmrg # to use with these is +Maked; it writes dependencies to a file named 43923a0898aSmrg # 'foo.d', which lands next to the object file, wherever that 44023a0898aSmrg # happens to be. 44123a0898aSmrg # Much of this is similar to the tru64 case; see comments there. 442b020570bSmrg set_dir_from "$object" 443b020570bSmrg set_base_from "$object" 44423a0898aSmrg if test "$libtool" = yes; then 44523a0898aSmrg tmpdepfile1=$dir$base.d 44623a0898aSmrg tmpdepfile2=$dir.libs/$base.d 44723a0898aSmrg "$@" -Wc,+Maked 44823a0898aSmrg else 44923a0898aSmrg tmpdepfile1=$dir$base.d 45023a0898aSmrg tmpdepfile2=$dir$base.d 45123a0898aSmrg "$@" +Maked 45223a0898aSmrg fi 45323a0898aSmrg stat=$? 454b020570bSmrg if test $stat -ne 0; then 45523a0898aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 45623a0898aSmrg exit $stat 45723a0898aSmrg fi 45823a0898aSmrg 45923a0898aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 46023a0898aSmrg do 46123a0898aSmrg test -f "$tmpdepfile" && break 46223a0898aSmrg done 46323a0898aSmrg if test -f "$tmpdepfile"; then 464b020570bSmrg sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 465b020570bSmrg # Add 'dependent.h:' lines. 46641c30155Smrg sed -ne '2,${ 467b020570bSmrg s/^ *// 468b020570bSmrg s/ \\*$// 469b020570bSmrg s/$/:/ 470b020570bSmrg p 471b020570bSmrg }' "$tmpdepfile" >> "$depfile" 47223a0898aSmrg else 473b020570bSmrg make_dummy_depfile 47423a0898aSmrg fi 47523a0898aSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 47623a0898aSmrg ;; 47723a0898aSmrg 47823a0898aSmrgtru64) 479b020570bSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 480b020570bSmrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 481b020570bSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 482b020570bSmrg # dependencies in 'foo.d' instead, so we check for that too. 483b020570bSmrg # Subdirectories are respected. 484b020570bSmrg set_dir_from "$object" 485b020570bSmrg set_base_from "$object" 486b020570bSmrg 487b020570bSmrg if test "$libtool" = yes; then 488b020570bSmrg # Libtool generates 2 separate objects for the 2 libraries. These 489b020570bSmrg # two compilations output dependencies in $dir.libs/$base.o.d and 490b020570bSmrg # in $dir$base.o.d. We have to check for both files, because 491b020570bSmrg # one of the two compilations can be disabled. We should prefer 492b020570bSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 493b020570bSmrg # automatically cleaned when .libs/ is deleted, while ignoring 494b020570bSmrg # the former would cause a distcleancheck panic. 495b020570bSmrg tmpdepfile1=$dir$base.o.d # libtool 1.5 496b020570bSmrg tmpdepfile2=$dir.libs/$base.o.d # Likewise. 497b020570bSmrg tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 498b020570bSmrg "$@" -Wc,-MD 499b020570bSmrg else 500b020570bSmrg tmpdepfile1=$dir$base.d 501b020570bSmrg tmpdepfile2=$dir$base.d 502b020570bSmrg tmpdepfile3=$dir$base.d 503b020570bSmrg "$@" -MD 504b020570bSmrg fi 505b020570bSmrg 506b020570bSmrg stat=$? 507b020570bSmrg if test $stat -ne 0; then 508b020570bSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 509b020570bSmrg exit $stat 510b020570bSmrg fi 511b020570bSmrg 512b020570bSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 513b020570bSmrg do 514b020570bSmrg test -f "$tmpdepfile" && break 515b020570bSmrg done 516b020570bSmrg # Same post-processing that is required for AIX mode. 517b020570bSmrg aix_post_process_depfile 518b020570bSmrg ;; 519b020570bSmrg 520b020570bSmrgmsvc7) 521b020570bSmrg if test "$libtool" = yes; then 522b020570bSmrg showIncludes=-Wc,-showIncludes 523b020570bSmrg else 524b020570bSmrg showIncludes=-showIncludes 525b020570bSmrg fi 526b020570bSmrg "$@" $showIncludes > "$tmpdepfile" 527b020570bSmrg stat=$? 528b020570bSmrg grep -v '^Note: including file: ' "$tmpdepfile" 529b020570bSmrg if test $stat -ne 0; then 530b020570bSmrg rm -f "$tmpdepfile" 531b020570bSmrg exit $stat 532b020570bSmrg fi 533b020570bSmrg rm -f "$depfile" 534b020570bSmrg echo "$object : \\" > "$depfile" 535b020570bSmrg # The first sed program below extracts the file names and escapes 536b020570bSmrg # backslashes for cygpath. The second sed program outputs the file 537b020570bSmrg # name when reading, but also accumulates all include files in the 538b020570bSmrg # hold buffer in order to output them again at the end. This only 539b020570bSmrg # works with sed implementations that can handle large buffers. 540b020570bSmrg sed < "$tmpdepfile" -n ' 541b020570bSmrg/^Note: including file: *\(.*\)/ { 542b020570bSmrg s//\1/ 543b020570bSmrg s/\\/\\\\/g 544b020570bSmrg p 545b020570bSmrg}' | $cygpath_u | sort -u | sed -n ' 546b020570bSmrgs/ /\\ /g 547b020570bSmrgs/\(.*\)/'"$tab"'\1 \\/p 548b020570bSmrgs/.\(.*\) \\/\1:/ 549b020570bSmrgH 550b020570bSmrg$ { 551b020570bSmrg s/.*/'"$tab"'/ 552b020570bSmrg G 553b020570bSmrg p 554b020570bSmrg}' >> "$depfile" 555b020570bSmrg echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556b020570bSmrg rm -f "$tmpdepfile" 557b020570bSmrg ;; 558b020570bSmrg 559b020570bSmrgmsvc7msys) 560b020570bSmrg # This case exists only to let depend.m4 do its work. It works by 561b020570bSmrg # looking at the text of this script. This case will never be run, 562b020570bSmrg # since it is checked for above. 563b020570bSmrg exit 1 564b020570bSmrg ;; 56523a0898aSmrg 56623a0898aSmrg#nosideeffect) 56723a0898aSmrg # This comment above is used by automake to tell side-effect 56823a0898aSmrg # dependency tracking mechanisms from slower ones. 56923a0898aSmrg 57023a0898aSmrgdashmstdout) 57123a0898aSmrg # Important note: in order to support this mode, a compiler *must* 57223a0898aSmrg # always write the preprocessed file to stdout, regardless of -o. 57323a0898aSmrg "$@" || exit $? 57423a0898aSmrg 57523a0898aSmrg # Remove the call to Libtool. 57623a0898aSmrg if test "$libtool" = yes; then 57741c30155Smrg while test "X$1" != 'X--mode=compile'; do 57823a0898aSmrg shift 57923a0898aSmrg done 58023a0898aSmrg shift 58123a0898aSmrg fi 58223a0898aSmrg 583b020570bSmrg # Remove '-o $object'. 58423a0898aSmrg IFS=" " 58523a0898aSmrg for arg 58623a0898aSmrg do 58723a0898aSmrg case $arg in 58823a0898aSmrg -o) 58923a0898aSmrg shift 59023a0898aSmrg ;; 59123a0898aSmrg $object) 59223a0898aSmrg shift 59323a0898aSmrg ;; 59423a0898aSmrg *) 59523a0898aSmrg set fnord "$@" "$arg" 59623a0898aSmrg shift # fnord 59723a0898aSmrg shift # $arg 59823a0898aSmrg ;; 59923a0898aSmrg esac 60023a0898aSmrg done 60123a0898aSmrg 60223a0898aSmrg test -z "$dashmflag" && dashmflag=-M 603b020570bSmrg # Require at least two characters before searching for ':' 60423a0898aSmrg # in the target name. This is to cope with DOS-style filenames: 605b020570bSmrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 60623a0898aSmrg "$@" $dashmflag | 607b020570bSmrg sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 60823a0898aSmrg rm -f "$depfile" 60923a0898aSmrg cat < "$tmpdepfile" > "$depfile" 610b020570bSmrg # Some versions of the HPUX 10.20 sed can't process this sed invocation 611b020570bSmrg # correctly. Breaking it into two sed invocations is a workaround. 612b020570bSmrg tr ' ' "$nl" < "$tmpdepfile" \ 613b020570bSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 614b020570bSmrg | sed -e 's/$/ :/' >> "$depfile" 61523a0898aSmrg rm -f "$tmpdepfile" 61623a0898aSmrg ;; 61723a0898aSmrg 61823a0898aSmrgdashXmstdout) 61923a0898aSmrg # This case only exists to satisfy depend.m4. It is never actually 62023a0898aSmrg # run, as this mode is specially recognized in the preamble. 62123a0898aSmrg exit 1 62223a0898aSmrg ;; 62323a0898aSmrg 62423a0898aSmrgmakedepend) 62523a0898aSmrg "$@" || exit $? 62623a0898aSmrg # Remove any Libtool call 62723a0898aSmrg if test "$libtool" = yes; then 62841c30155Smrg while test "X$1" != 'X--mode=compile'; do 62923a0898aSmrg shift 63023a0898aSmrg done 63123a0898aSmrg shift 63223a0898aSmrg fi 63323a0898aSmrg # X makedepend 63423a0898aSmrg shift 63541c30155Smrg cleared=no eat=no 63641c30155Smrg for arg 63741c30155Smrg do 63823a0898aSmrg case $cleared in 63923a0898aSmrg no) 64023a0898aSmrg set ""; shift 64123a0898aSmrg cleared=yes ;; 64223a0898aSmrg esac 64341c30155Smrg if test $eat = yes; then 64441c30155Smrg eat=no 64541c30155Smrg continue 64641c30155Smrg fi 64723a0898aSmrg case "$arg" in 64823a0898aSmrg -D*|-I*) 64923a0898aSmrg set fnord "$@" "$arg"; shift ;; 65023a0898aSmrg # Strip any option that makedepend may not understand. Remove 65123a0898aSmrg # the object too, otherwise makedepend will parse it as a source file. 65241c30155Smrg -arch) 65341c30155Smrg eat=yes ;; 65423a0898aSmrg -*|$object) 65523a0898aSmrg ;; 65623a0898aSmrg *) 65723a0898aSmrg set fnord "$@" "$arg"; shift ;; 65823a0898aSmrg esac 65923a0898aSmrg done 66041c30155Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 66123a0898aSmrg touch "$tmpdepfile" 66223a0898aSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 66323a0898aSmrg rm -f "$depfile" 664b020570bSmrg # makedepend may prepend the VPATH from the source file name to the object. 665b020570bSmrg # No need to regex-escape $object, excess matching of '.' is harmless. 666b020570bSmrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 667b020570bSmrg # Some versions of the HPUX 10.20 sed can't process the last invocation 668b020570bSmrg # correctly. Breaking it into two sed invocations is a workaround. 669b020570bSmrg sed '1,2d' "$tmpdepfile" \ 670b020570bSmrg | tr ' ' "$nl" \ 671b020570bSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 672b020570bSmrg | sed -e 's/$/ :/' >> "$depfile" 67323a0898aSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 67423a0898aSmrg ;; 67523a0898aSmrg 67623a0898aSmrgcpp) 67723a0898aSmrg # Important note: in order to support this mode, a compiler *must* 67823a0898aSmrg # always write the preprocessed file to stdout. 67923a0898aSmrg "$@" || exit $? 68023a0898aSmrg 68123a0898aSmrg # Remove the call to Libtool. 68223a0898aSmrg if test "$libtool" = yes; then 68341c30155Smrg while test "X$1" != 'X--mode=compile'; do 68423a0898aSmrg shift 68523a0898aSmrg done 68623a0898aSmrg shift 68723a0898aSmrg fi 68823a0898aSmrg 689b020570bSmrg # Remove '-o $object'. 69023a0898aSmrg IFS=" " 69123a0898aSmrg for arg 69223a0898aSmrg do 69323a0898aSmrg case $arg in 69423a0898aSmrg -o) 69523a0898aSmrg shift 69623a0898aSmrg ;; 69723a0898aSmrg $object) 69823a0898aSmrg shift 69923a0898aSmrg ;; 70023a0898aSmrg *) 70123a0898aSmrg set fnord "$@" "$arg" 70223a0898aSmrg shift # fnord 70323a0898aSmrg shift # $arg 70423a0898aSmrg ;; 70523a0898aSmrg esac 70623a0898aSmrg done 70723a0898aSmrg 708b020570bSmrg "$@" -E \ 709b020570bSmrg | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 710b020570bSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 711b020570bSmrg | sed '$ s: \\$::' > "$tmpdepfile" 71223a0898aSmrg rm -f "$depfile" 71323a0898aSmrg echo "$object : \\" > "$depfile" 71423a0898aSmrg cat < "$tmpdepfile" >> "$depfile" 71523a0898aSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 71623a0898aSmrg rm -f "$tmpdepfile" 71723a0898aSmrg ;; 71823a0898aSmrg 71923a0898aSmrgmsvisualcpp) 72023a0898aSmrg # Important note: in order to support this mode, a compiler *must* 72141c30155Smrg # always write the preprocessed file to stdout. 72223a0898aSmrg "$@" || exit $? 72341c30155Smrg 72441c30155Smrg # Remove the call to Libtool. 72541c30155Smrg if test "$libtool" = yes; then 72641c30155Smrg while test "X$1" != 'X--mode=compile'; do 72741c30155Smrg shift 72841c30155Smrg done 72941c30155Smrg shift 73041c30155Smrg fi 73141c30155Smrg 73223a0898aSmrg IFS=" " 73323a0898aSmrg for arg 73423a0898aSmrg do 73523a0898aSmrg case "$arg" in 73641c30155Smrg -o) 73741c30155Smrg shift 73841c30155Smrg ;; 73941c30155Smrg $object) 74041c30155Smrg shift 74141c30155Smrg ;; 74223a0898aSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 743b020570bSmrg set fnord "$@" 744b020570bSmrg shift 745b020570bSmrg shift 746b020570bSmrg ;; 74723a0898aSmrg *) 748b020570bSmrg set fnord "$@" "$arg" 749b020570bSmrg shift 750b020570bSmrg shift 751b020570bSmrg ;; 75223a0898aSmrg esac 75323a0898aSmrg done 75441c30155Smrg "$@" -E 2>/dev/null | 75541c30155Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 75623a0898aSmrg rm -f "$depfile" 75723a0898aSmrg echo "$object : \\" > "$depfile" 758b020570bSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 759b020570bSmrg echo "$tab" >> "$depfile" 76041c30155Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 76123a0898aSmrg rm -f "$tmpdepfile" 76223a0898aSmrg ;; 76323a0898aSmrg 76441c30155Smrgmsvcmsys) 76541c30155Smrg # This case exists only to let depend.m4 do its work. It works by 76641c30155Smrg # looking at the text of this script. This case will never be run, 76741c30155Smrg # since it is checked for above. 76841c30155Smrg exit 1 76941c30155Smrg ;; 77041c30155Smrg 77123a0898aSmrgnone) 77223a0898aSmrg exec "$@" 77323a0898aSmrg ;; 77423a0898aSmrg 77523a0898aSmrg*) 77623a0898aSmrg echo "Unknown depmode $depmode" 1>&2 77723a0898aSmrg exit 1 77823a0898aSmrg ;; 77923a0898aSmrgesac 78023a0898aSmrg 78123a0898aSmrgexit 0 78223a0898aSmrg 78323a0898aSmrg# Local Variables: 78423a0898aSmrg# mode: shell-script 78523a0898aSmrg# sh-indentation: 2 78623a0898aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 78723a0898aSmrg# time-stamp-start: "scriptversion=" 78823a0898aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 78941c30155Smrg# time-stamp-time-zone: "UTC" 79041c30155Smrg# time-stamp-end: "; # UTC" 79123a0898aSmrg# End: 792