1c35d236eSmrg#! /bin/sh 2c35d236eSmrg# depcomp - compile a program generating dependencies as side-effects 3c35d236eSmrg 414210e8eSmrgscriptversion=2013-05-30.07; # UTC 5c35d236eSmrg 614210e8eSmrg# Copyright (C) 1999-2014 Free Software Foundation, Inc. 7c35d236eSmrg 8c35d236eSmrg# This program is free software; you can redistribute it and/or modify 9c35d236eSmrg# it under the terms of the GNU General Public License as published by 10c35d236eSmrg# the Free Software Foundation; either version 2, or (at your option) 11c35d236eSmrg# any later version. 12c35d236eSmrg 13c35d236eSmrg# This program is distributed in the hope that it will be useful, 14c35d236eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15c35d236eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16c35d236eSmrg# GNU General Public License for more details. 17c35d236eSmrg 18c35d236eSmrg# You should have received a copy of the GNU General Public License 19518bcf38Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 20c35d236eSmrg 21c35d236eSmrg# As a special exception to the GNU General Public License, if you 22c35d236eSmrg# distribute this file as part of a program that contains a 23c35d236eSmrg# configuration script generated by Autoconf, you may include it under 24c35d236eSmrg# the same distribution terms that you use for the rest of that program. 25c35d236eSmrg 26c35d236eSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 27c35d236eSmrg 28c35d236eSmrgcase $1 in 29c35d236eSmrg '') 3014210e8eSmrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 3114210e8eSmrg exit 1; 3214210e8eSmrg ;; 33c35d236eSmrg -h | --h*) 34c35d236eSmrg cat <<\EOF 35c35d236eSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 36c35d236eSmrg 37c35d236eSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 38c35d236eSmrgas side-effects. 39c35d236eSmrg 40c35d236eSmrgEnvironment variables: 41c35d236eSmrg depmode Dependency tracking mode. 4214210e8eSmrg source Source file read by 'PROGRAMS ARGS'. 4314210e8eSmrg object Object file output by 'PROGRAMS ARGS'. 44c35d236eSmrg DEPDIR directory where to store dependencies. 45c35d236eSmrg depfile Dependency file to output. 461fb744b4Smrg tmpdepfile Temporary file to use when outputting dependencies. 47c35d236eSmrg libtool Whether libtool is used (yes/no). 48c35d236eSmrg 49c35d236eSmrgReport bugs to <bug-automake@gnu.org>. 50c35d236eSmrgEOF 51c35d236eSmrg exit $? 52c35d236eSmrg ;; 53c35d236eSmrg -v | --v*) 54c35d236eSmrg echo "depcomp $scriptversion" 55c35d236eSmrg exit $? 56c35d236eSmrg ;; 57c35d236eSmrgesac 58c35d236eSmrg 5914210e8eSmrg# Get the directory component of the given path, and save it in the 6014210e8eSmrg# global variables '$dir'. Note that this directory component will 6114210e8eSmrg# be either empty or ending with a '/' character. This is deliberate. 6214210e8eSmrgset_dir_from () 6314210e8eSmrg{ 6414210e8eSmrg case $1 in 6514210e8eSmrg */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 6614210e8eSmrg *) dir=;; 6714210e8eSmrg esac 6814210e8eSmrg} 6914210e8eSmrg 7014210e8eSmrg# Get the suffix-stripped basename of the given path, and save it the 7114210e8eSmrg# global variable '$base'. 7214210e8eSmrgset_base_from () 7314210e8eSmrg{ 7414210e8eSmrg base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 7514210e8eSmrg} 7614210e8eSmrg 7714210e8eSmrg# If no dependency file was actually created by the compiler invocation, 7814210e8eSmrg# we still have to create a dummy depfile, to avoid errors with the 7914210e8eSmrg# Makefile "include basename.Plo" scheme. 8014210e8eSmrgmake_dummy_depfile () 8114210e8eSmrg{ 8214210e8eSmrg echo "#dummy" > "$depfile" 8314210e8eSmrg} 8414210e8eSmrg 8514210e8eSmrg# Factor out some common post-processing of the generated depfile. 8614210e8eSmrg# Requires the auxiliary global variable '$tmpdepfile' to be set. 8714210e8eSmrgaix_post_process_depfile () 8814210e8eSmrg{ 8914210e8eSmrg # If the compiler actually managed to produce a dependency file, 9014210e8eSmrg # post-process it. 9114210e8eSmrg if test -f "$tmpdepfile"; then 9214210e8eSmrg # Each line is of the form 'foo.o: dependency.h'. 9314210e8eSmrg # Do two passes, one to just change these to 9414210e8eSmrg # $object: dependency.h 9514210e8eSmrg # and one to simply output 9614210e8eSmrg # dependency.h: 9714210e8eSmrg # which is needed to avoid the deleted-header problem. 9814210e8eSmrg { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 9914210e8eSmrg sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 10014210e8eSmrg } > "$depfile" 10114210e8eSmrg rm -f "$tmpdepfile" 10214210e8eSmrg else 10314210e8eSmrg make_dummy_depfile 10414210e8eSmrg fi 10514210e8eSmrg} 10614210e8eSmrg 10714210e8eSmrg# A tabulation character. 10814210e8eSmrgtab=' ' 10914210e8eSmrg# A newline character. 11014210e8eSmrgnl=' 11114210e8eSmrg' 11214210e8eSmrg# Character ranges might be problematic outside the C locale. 11314210e8eSmrg# These definitions help. 11414210e8eSmrgupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 11514210e8eSmrglower=abcdefghijklmnopqrstuvwxyz 11614210e8eSmrgdigits=0123456789 11714210e8eSmrgalpha=${upper}${lower} 11814210e8eSmrg 119c35d236eSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 120c35d236eSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 121c35d236eSmrg exit 1 122c35d236eSmrgfi 123c35d236eSmrg 124c35d236eSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 125c35d236eSmrgdepfile=${depfile-`echo "$object" | 126c35d236eSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 127c35d236eSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 128c35d236eSmrg 129c35d236eSmrgrm -f "$tmpdepfile" 130c35d236eSmrg 13114210e8eSmrg# Avoid interferences from the environment. 13214210e8eSmrggccflag= dashmflag= 13314210e8eSmrg 134c35d236eSmrg# Some modes work just like other modes, but use different flags. We 135c35d236eSmrg# parameterize here, but still list the modes in the big case below, 136c35d236eSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 137c35d236eSmrg# here, because this file can only contain one case statement. 138c35d236eSmrgif test "$depmode" = hp; then 139c35d236eSmrg # HP compiler uses -M and no extra arg. 140c35d236eSmrg gccflag=-M 141c35d236eSmrg depmode=gcc 142c35d236eSmrgfi 143c35d236eSmrg 144c35d236eSmrgif test "$depmode" = dashXmstdout; then 14514210e8eSmrg # This is just like dashmstdout with a different argument. 14614210e8eSmrg dashmflag=-xM 14714210e8eSmrg depmode=dashmstdout 148c35d236eSmrgfi 149c35d236eSmrg 150518bcf38Smrgcygpath_u="cygpath -u -f -" 151518bcf38Smrgif test "$depmode" = msvcmsys; then 15214210e8eSmrg # This is just like msvisualcpp but w/o cygpath translation. 15314210e8eSmrg # Just convert the backslash-escaped backslashes to single forward 15414210e8eSmrg # slashes to satisfy depend.m4 15514210e8eSmrg cygpath_u='sed s,\\\\,/,g' 15614210e8eSmrg depmode=msvisualcpp 157518bcf38Smrgfi 158518bcf38Smrg 1591fb744b4Smrgif test "$depmode" = msvc7msys; then 16014210e8eSmrg # This is just like msvc7 but w/o cygpath translation. 16114210e8eSmrg # Just convert the backslash-escaped backslashes to single forward 16214210e8eSmrg # slashes to satisfy depend.m4 16314210e8eSmrg cygpath_u='sed s,\\\\,/,g' 16414210e8eSmrg depmode=msvc7 16514210e8eSmrgfi 16614210e8eSmrg 16714210e8eSmrgif test "$depmode" = xlc; then 16814210e8eSmrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 16914210e8eSmrg gccflag=-qmakedep=gcc,-MF 17014210e8eSmrg depmode=gcc 1711fb744b4Smrgfi 1721fb744b4Smrg 173c35d236eSmrgcase "$depmode" in 174c35d236eSmrggcc3) 175c35d236eSmrg## gcc 3 implements dependency tracking that does exactly what 176c35d236eSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 177c35d236eSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1784f6cd06fSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1794f6cd06fSmrg## the command line argument order; so add the flags where they 1804f6cd06fSmrg## appear in depend2.am. Note that the slowdown incurred here 1814f6cd06fSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1824f6cd06fSmrg for arg 1834f6cd06fSmrg do 1844f6cd06fSmrg case $arg in 1854f6cd06fSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1864f6cd06fSmrg *) set fnord "$@" "$arg" ;; 1874f6cd06fSmrg esac 1884f6cd06fSmrg shift # fnord 1894f6cd06fSmrg shift # $arg 1904f6cd06fSmrg done 1914f6cd06fSmrg "$@" 192c35d236eSmrg stat=$? 19314210e8eSmrg if test $stat -ne 0; then 194c35d236eSmrg rm -f "$tmpdepfile" 195c35d236eSmrg exit $stat 196c35d236eSmrg fi 197c35d236eSmrg mv "$tmpdepfile" "$depfile" 198c35d236eSmrg ;; 199c35d236eSmrg 200c35d236eSmrggcc) 20114210e8eSmrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 20214210e8eSmrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 20314210e8eSmrg## (see the conditional assignment to $gccflag above). 204c35d236eSmrg## There are various ways to get dependency output from gcc. Here's 205c35d236eSmrg## why we pick this rather obscure method: 206c35d236eSmrg## - Don't want to use -MD because we'd like the dependencies to end 207c35d236eSmrg## up in a subdir. Having to rename by hand is ugly. 208c35d236eSmrg## (We might end up doing this anyway to support other compilers.) 209c35d236eSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 21014210e8eSmrg## -MM, not -M (despite what the docs say). Also, it might not be 21114210e8eSmrg## supported by the other compilers which use the 'gcc' depmode. 212c35d236eSmrg## - Using -M directly means running the compiler twice (even worse 213c35d236eSmrg## than renaming). 214c35d236eSmrg if test -z "$gccflag"; then 215c35d236eSmrg gccflag=-MD, 216c35d236eSmrg fi 217c35d236eSmrg "$@" -Wp,"$gccflag$tmpdepfile" 218c35d236eSmrg stat=$? 21914210e8eSmrg if test $stat -ne 0; then 220c35d236eSmrg rm -f "$tmpdepfile" 221c35d236eSmrg exit $stat 222c35d236eSmrg fi 223c35d236eSmrg rm -f "$depfile" 224c35d236eSmrg echo "$object : \\" > "$depfile" 22514210e8eSmrg # The second -e expression handles DOS-style file names with drive 22614210e8eSmrg # letters. 227c35d236eSmrg sed -e 's/^[^:]*: / /' \ 228c35d236eSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 22914210e8eSmrg## This next piece of magic avoids the "deleted header file" problem. 230c35d236eSmrg## The problem is that when a header file which appears in a .P file 231c35d236eSmrg## is deleted, the dependency causes make to die (because there is 232c35d236eSmrg## typically no way to rebuild the header). We avoid this by adding 233c35d236eSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 234c35d236eSmrg## this for us directly. 23514210e8eSmrg## Some versions of gcc put a space before the ':'. On the theory 236c35d236eSmrg## that the space means something, we add a space to the output as 2371fb744b4Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 2381fb744b4Smrg## to the object. Take care to not repeat it in the output. 239c35d236eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 240c35d236eSmrg## correctly. Breaking it into two sed invocations is a workaround. 24114210e8eSmrg tr ' ' "$nl" < "$tmpdepfile" \ 24214210e8eSmrg | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 24314210e8eSmrg | sed -e 's/$/ :/' >> "$depfile" 244c35d236eSmrg rm -f "$tmpdepfile" 245c35d236eSmrg ;; 246c35d236eSmrg 247c35d236eSmrghp) 248c35d236eSmrg # This case exists only to let depend.m4 do its work. It works by 249c35d236eSmrg # looking at the text of this script. This case will never be run, 250c35d236eSmrg # since it is checked for above. 251c35d236eSmrg exit 1 252c35d236eSmrg ;; 253c35d236eSmrg 254c35d236eSmrgsgi) 255c35d236eSmrg if test "$libtool" = yes; then 256c35d236eSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 257c35d236eSmrg else 258c35d236eSmrg "$@" -MDupdate "$tmpdepfile" 259c35d236eSmrg fi 260c35d236eSmrg stat=$? 26114210e8eSmrg if test $stat -ne 0; then 262c35d236eSmrg rm -f "$tmpdepfile" 263c35d236eSmrg exit $stat 264c35d236eSmrg fi 265c35d236eSmrg rm -f "$depfile" 266c35d236eSmrg 267c35d236eSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 268c35d236eSmrg echo "$object : \\" > "$depfile" 269c35d236eSmrg # Clip off the initial element (the dependent). Don't try to be 270c35d236eSmrg # clever and replace this with sed code, as IRIX sed won't handle 271c35d236eSmrg # lines with more than a fixed number of characters (4096 in 272c35d236eSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 27314210e8eSmrg # the IRIX cc adds comments like '#:fec' to the end of the 274c35d236eSmrg # dependency line. 27514210e8eSmrg tr ' ' "$nl" < "$tmpdepfile" \ 27614210e8eSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 27714210e8eSmrg | tr "$nl" ' ' >> "$depfile" 278518bcf38Smrg echo >> "$depfile" 279c35d236eSmrg # The second pass generates a dummy entry for each header file. 28014210e8eSmrg tr ' ' "$nl" < "$tmpdepfile" \ 28114210e8eSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 28214210e8eSmrg >> "$depfile" 283c35d236eSmrg else 28414210e8eSmrg make_dummy_depfile 285c35d236eSmrg fi 286c35d236eSmrg rm -f "$tmpdepfile" 287c35d236eSmrg ;; 288c35d236eSmrg 28914210e8eSmrgxlc) 29014210e8eSmrg # This case exists only to let depend.m4 do its work. It works by 29114210e8eSmrg # looking at the text of this script. This case will never be run, 29214210e8eSmrg # since it is checked for above. 29314210e8eSmrg exit 1 29414210e8eSmrg ;; 29514210e8eSmrg 296c35d236eSmrgaix) 297c35d236eSmrg # The C for AIX Compiler uses -M and outputs the dependencies 298c35d236eSmrg # in a .u file. In older versions, this file always lives in the 29914210e8eSmrg # current directory. Also, the AIX compiler puts '$object:' at the 300c35d236eSmrg # start of each line; $object doesn't have directory information. 301c35d236eSmrg # Version 6 uses the directory in both cases. 30214210e8eSmrg set_dir_from "$object" 30314210e8eSmrg set_base_from "$object" 304c35d236eSmrg if test "$libtool" = yes; then 305f55e6a01Smrg tmpdepfile1=$dir$base.u 306f55e6a01Smrg tmpdepfile2=$base.u 307f55e6a01Smrg tmpdepfile3=$dir.libs/$base.u 308c35d236eSmrg "$@" -Wc,-M 309c35d236eSmrg else 310f55e6a01Smrg tmpdepfile1=$dir$base.u 311f55e6a01Smrg tmpdepfile2=$dir$base.u 312f55e6a01Smrg tmpdepfile3=$dir$base.u 313c35d236eSmrg "$@" -M 314c35d236eSmrg fi 315c35d236eSmrg stat=$? 31614210e8eSmrg if test $stat -ne 0; then 317f55e6a01Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 318c35d236eSmrg exit $stat 319c35d236eSmrg fi 320c35d236eSmrg 321f55e6a01Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 322f55e6a01Smrg do 323f55e6a01Smrg test -f "$tmpdepfile" && break 324f55e6a01Smrg done 32514210e8eSmrg aix_post_process_depfile 32614210e8eSmrg ;; 32714210e8eSmrg 32814210e8eSmrgtcc) 32914210e8eSmrg # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 33014210e8eSmrg # FIXME: That version still under development at the moment of writing. 33114210e8eSmrg # Make that this statement remains true also for stable, released 33214210e8eSmrg # versions. 33314210e8eSmrg # It will wrap lines (doesn't matter whether long or short) with a 33414210e8eSmrg # trailing '\', as in: 33514210e8eSmrg # 33614210e8eSmrg # foo.o : \ 33714210e8eSmrg # foo.c \ 33814210e8eSmrg # foo.h \ 33914210e8eSmrg # 34014210e8eSmrg # It will put a trailing '\' even on the last line, and will use leading 34114210e8eSmrg # spaces rather than leading tabs (at least since its commit 0394caf7 34214210e8eSmrg # "Emit spaces for -MD"). 34314210e8eSmrg "$@" -MD -MF "$tmpdepfile" 34414210e8eSmrg stat=$? 34514210e8eSmrg if test $stat -ne 0; then 34614210e8eSmrg rm -f "$tmpdepfile" 34714210e8eSmrg exit $stat 348c35d236eSmrg fi 34914210e8eSmrg rm -f "$depfile" 35014210e8eSmrg # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 35114210e8eSmrg # We have to change lines of the first kind to '$object: \'. 35214210e8eSmrg sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 35314210e8eSmrg # And for each line of the second kind, we have to emit a 'dep.h:' 35414210e8eSmrg # dummy dependency, to avoid the deleted-header problem. 35514210e8eSmrg sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 356c35d236eSmrg rm -f "$tmpdepfile" 357c35d236eSmrg ;; 358c35d236eSmrg 35914210e8eSmrg## The order of this option in the case statement is important, since the 36014210e8eSmrg## shell code in configure will try each of these formats in the order 36114210e8eSmrg## listed in this file. A plain '-MD' option would be understood by many 36214210e8eSmrg## compilers, so we must ensure this comes after the gcc and icc options. 36314210e8eSmrgpgcc) 36414210e8eSmrg # Portland's C compiler understands '-MD'. 36514210e8eSmrg # Will always output deps to 'file.d' where file is the root name of the 36614210e8eSmrg # source file under compilation, even if file resides in a subdirectory. 36714210e8eSmrg # The object file name does not affect the name of the '.d' file. 36814210e8eSmrg # pgcc 10.2 will output 369c35d236eSmrg # foo.o: sub/foo.c sub/foo.h 37014210e8eSmrg # and will wrap long lines using '\' : 371c35d236eSmrg # foo.o: sub/foo.c ... \ 372c35d236eSmrg # sub/foo.h ... \ 373c35d236eSmrg # ... 37414210e8eSmrg set_dir_from "$object" 37514210e8eSmrg # Use the source, not the object, to determine the base name, since 37614210e8eSmrg # that's sadly what pgcc will do too. 37714210e8eSmrg set_base_from "$source" 37814210e8eSmrg tmpdepfile=$base.d 37914210e8eSmrg 38014210e8eSmrg # For projects that build the same source file twice into different object 38114210e8eSmrg # files, the pgcc approach of using the *source* file root name can cause 38214210e8eSmrg # problems in parallel builds. Use a locking strategy to avoid stomping on 38314210e8eSmrg # the same $tmpdepfile. 38414210e8eSmrg lockdir=$base.d-lock 38514210e8eSmrg trap " 38614210e8eSmrg echo '$0: caught signal, cleaning up...' >&2 38714210e8eSmrg rmdir '$lockdir' 38814210e8eSmrg exit 1 38914210e8eSmrg " 1 2 13 15 39014210e8eSmrg numtries=100 39114210e8eSmrg i=$numtries 39214210e8eSmrg while test $i -gt 0; do 39314210e8eSmrg # mkdir is a portable test-and-set. 39414210e8eSmrg if mkdir "$lockdir" 2>/dev/null; then 39514210e8eSmrg # This process acquired the lock. 39614210e8eSmrg "$@" -MD 39714210e8eSmrg stat=$? 39814210e8eSmrg # Release the lock. 39914210e8eSmrg rmdir "$lockdir" 40014210e8eSmrg break 40114210e8eSmrg else 40214210e8eSmrg # If the lock is being held by a different process, wait 40314210e8eSmrg # until the winning process is done or we timeout. 40414210e8eSmrg while test -d "$lockdir" && test $i -gt 0; do 40514210e8eSmrg sleep 1 40614210e8eSmrg i=`expr $i - 1` 40714210e8eSmrg done 40814210e8eSmrg fi 40914210e8eSmrg i=`expr $i - 1` 41014210e8eSmrg done 41114210e8eSmrg trap - 1 2 13 15 41214210e8eSmrg if test $i -le 0; then 41314210e8eSmrg echo "$0: failed to acquire lock after $numtries attempts" >&2 41414210e8eSmrg echo "$0: check lockdir '$lockdir'" >&2 41514210e8eSmrg exit 1 41614210e8eSmrg fi 417c35d236eSmrg 41814210e8eSmrg if test $stat -ne 0; then 419c35d236eSmrg rm -f "$tmpdepfile" 420c35d236eSmrg exit $stat 421c35d236eSmrg fi 422c35d236eSmrg rm -f "$depfile" 423c35d236eSmrg # Each line is of the form `foo.o: dependent.h', 424c35d236eSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 425c35d236eSmrg # Do two passes, one to just change these to 426c35d236eSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 427c35d236eSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 428c35d236eSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 429c35d236eSmrg # correctly. Breaking it into two sed invocations is a workaround. 43014210e8eSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 43114210e8eSmrg | sed -e 's/$/ :/' >> "$depfile" 432c35d236eSmrg rm -f "$tmpdepfile" 433c35d236eSmrg ;; 434c35d236eSmrg 4354f6cd06fSmrghp2) 4364f6cd06fSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 4374f6cd06fSmrg # compilers, which have integrated preprocessors. The correct option 4384f6cd06fSmrg # to use with these is +Maked; it writes dependencies to a file named 4394f6cd06fSmrg # 'foo.d', which lands next to the object file, wherever that 4404f6cd06fSmrg # happens to be. 4414f6cd06fSmrg # Much of this is similar to the tru64 case; see comments there. 44214210e8eSmrg set_dir_from "$object" 44314210e8eSmrg set_base_from "$object" 4444f6cd06fSmrg if test "$libtool" = yes; then 4454f6cd06fSmrg tmpdepfile1=$dir$base.d 4464f6cd06fSmrg tmpdepfile2=$dir.libs/$base.d 4474f6cd06fSmrg "$@" -Wc,+Maked 4484f6cd06fSmrg else 4494f6cd06fSmrg tmpdepfile1=$dir$base.d 4504f6cd06fSmrg tmpdepfile2=$dir$base.d 4514f6cd06fSmrg "$@" +Maked 4524f6cd06fSmrg fi 4534f6cd06fSmrg stat=$? 45414210e8eSmrg if test $stat -ne 0; then 4554f6cd06fSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 4564f6cd06fSmrg exit $stat 4574f6cd06fSmrg fi 4584f6cd06fSmrg 4594f6cd06fSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 4604f6cd06fSmrg do 4614f6cd06fSmrg test -f "$tmpdepfile" && break 4624f6cd06fSmrg done 4634f6cd06fSmrg if test -f "$tmpdepfile"; then 46414210e8eSmrg sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 46514210e8eSmrg # Add 'dependent.h:' lines. 466518bcf38Smrg sed -ne '2,${ 46714210e8eSmrg s/^ *// 46814210e8eSmrg s/ \\*$// 46914210e8eSmrg s/$/:/ 47014210e8eSmrg p 47114210e8eSmrg }' "$tmpdepfile" >> "$depfile" 4724f6cd06fSmrg else 47314210e8eSmrg make_dummy_depfile 4744f6cd06fSmrg fi 4754f6cd06fSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 4764f6cd06fSmrg ;; 4774f6cd06fSmrg 478c35d236eSmrgtru64) 47914210e8eSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 48014210e8eSmrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 48114210e8eSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 48214210e8eSmrg # dependencies in 'foo.d' instead, so we check for that too. 48314210e8eSmrg # Subdirectories are respected. 48414210e8eSmrg set_dir_from "$object" 48514210e8eSmrg set_base_from "$object" 48614210e8eSmrg 48714210e8eSmrg if test "$libtool" = yes; then 48814210e8eSmrg # Libtool generates 2 separate objects for the 2 libraries. These 48914210e8eSmrg # two compilations output dependencies in $dir.libs/$base.o.d and 49014210e8eSmrg # in $dir$base.o.d. We have to check for both files, because 49114210e8eSmrg # one of the two compilations can be disabled. We should prefer 49214210e8eSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 49314210e8eSmrg # automatically cleaned when .libs/ is deleted, while ignoring 49414210e8eSmrg # the former would cause a distcleancheck panic. 49514210e8eSmrg tmpdepfile1=$dir$base.o.d # libtool 1.5 49614210e8eSmrg tmpdepfile2=$dir.libs/$base.o.d # Likewise. 49714210e8eSmrg tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 49814210e8eSmrg "$@" -Wc,-MD 49914210e8eSmrg else 50014210e8eSmrg tmpdepfile1=$dir$base.d 50114210e8eSmrg tmpdepfile2=$dir$base.d 50214210e8eSmrg tmpdepfile3=$dir$base.d 50314210e8eSmrg "$@" -MD 50414210e8eSmrg fi 50514210e8eSmrg 50614210e8eSmrg stat=$? 50714210e8eSmrg if test $stat -ne 0; then 50814210e8eSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 50914210e8eSmrg exit $stat 51014210e8eSmrg fi 51114210e8eSmrg 51214210e8eSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 51314210e8eSmrg do 51414210e8eSmrg test -f "$tmpdepfile" && break 51514210e8eSmrg done 51614210e8eSmrg # Same post-processing that is required for AIX mode. 51714210e8eSmrg aix_post_process_depfile 51814210e8eSmrg ;; 519c35d236eSmrg 5201fb744b4Smrgmsvc7) 5211fb744b4Smrg if test "$libtool" = yes; then 5221fb744b4Smrg showIncludes=-Wc,-showIncludes 5231fb744b4Smrg else 5241fb744b4Smrg showIncludes=-showIncludes 5251fb744b4Smrg fi 5261fb744b4Smrg "$@" $showIncludes > "$tmpdepfile" 5271fb744b4Smrg stat=$? 5281fb744b4Smrg grep -v '^Note: including file: ' "$tmpdepfile" 52914210e8eSmrg if test $stat -ne 0; then 5301fb744b4Smrg rm -f "$tmpdepfile" 5311fb744b4Smrg exit $stat 5321fb744b4Smrg fi 5331fb744b4Smrg rm -f "$depfile" 5341fb744b4Smrg echo "$object : \\" > "$depfile" 5351fb744b4Smrg # The first sed program below extracts the file names and escapes 5361fb744b4Smrg # backslashes for cygpath. The second sed program outputs the file 5371fb744b4Smrg # name when reading, but also accumulates all include files in the 5381fb744b4Smrg # hold buffer in order to output them again at the end. This only 5391fb744b4Smrg # works with sed implementations that can handle large buffers. 5401fb744b4Smrg sed < "$tmpdepfile" -n ' 5411fb744b4Smrg/^Note: including file: *\(.*\)/ { 5421fb744b4Smrg s//\1/ 5431fb744b4Smrg s/\\/\\\\/g 5441fb744b4Smrg p 5451fb744b4Smrg}' | $cygpath_u | sort -u | sed -n ' 5461fb744b4Smrgs/ /\\ /g 54714210e8eSmrgs/\(.*\)/'"$tab"'\1 \\/p 5481fb744b4Smrgs/.\(.*\) \\/\1:/ 5491fb744b4SmrgH 5501fb744b4Smrg$ { 55114210e8eSmrg s/.*/'"$tab"'/ 5521fb744b4Smrg G 5531fb744b4Smrg p 5541fb744b4Smrg}' >> "$depfile" 55514210e8eSmrg echo >> "$depfile" # make sure the fragment doesn't end with a backslash 5561fb744b4Smrg rm -f "$tmpdepfile" 5571fb744b4Smrg ;; 5581fb744b4Smrg 5591fb744b4Smrgmsvc7msys) 5601fb744b4Smrg # This case exists only to let depend.m4 do its work. It works by 5611fb744b4Smrg # looking at the text of this script. This case will never be run, 5621fb744b4Smrg # since it is checked for above. 5631fb744b4Smrg exit 1 5641fb744b4Smrg ;; 5651fb744b4Smrg 566c35d236eSmrg#nosideeffect) 567c35d236eSmrg # This comment above is used by automake to tell side-effect 568c35d236eSmrg # dependency tracking mechanisms from slower ones. 569c35d236eSmrg 570c35d236eSmrgdashmstdout) 571c35d236eSmrg # Important note: in order to support this mode, a compiler *must* 572c35d236eSmrg # always write the preprocessed file to stdout, regardless of -o. 573c35d236eSmrg "$@" || exit $? 574c35d236eSmrg 575c35d236eSmrg # Remove the call to Libtool. 576c35d236eSmrg if test "$libtool" = yes; then 577518bcf38Smrg while test "X$1" != 'X--mode=compile'; do 578c35d236eSmrg shift 579c35d236eSmrg done 580c35d236eSmrg shift 581c35d236eSmrg fi 582c35d236eSmrg 58314210e8eSmrg # Remove '-o $object'. 584c35d236eSmrg IFS=" " 585c35d236eSmrg for arg 586c35d236eSmrg do 587c35d236eSmrg case $arg in 588c35d236eSmrg -o) 589c35d236eSmrg shift 590c35d236eSmrg ;; 591c35d236eSmrg $object) 592c35d236eSmrg shift 593c35d236eSmrg ;; 594c35d236eSmrg *) 595c35d236eSmrg set fnord "$@" "$arg" 596c35d236eSmrg shift # fnord 597c35d236eSmrg shift # $arg 598c35d236eSmrg ;; 599c35d236eSmrg esac 600c35d236eSmrg done 601c35d236eSmrg 602c35d236eSmrg test -z "$dashmflag" && dashmflag=-M 60314210e8eSmrg # Require at least two characters before searching for ':' 604c35d236eSmrg # in the target name. This is to cope with DOS-style filenames: 60514210e8eSmrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 606c35d236eSmrg "$@" $dashmflag | 60714210e8eSmrg sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 608c35d236eSmrg rm -f "$depfile" 609c35d236eSmrg cat < "$tmpdepfile" > "$depfile" 61014210e8eSmrg # Some versions of the HPUX 10.20 sed can't process this sed invocation 61114210e8eSmrg # correctly. Breaking it into two sed invocations is a workaround. 61214210e8eSmrg tr ' ' "$nl" < "$tmpdepfile" \ 61314210e8eSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 61414210e8eSmrg | sed -e 's/$/ :/' >> "$depfile" 615c35d236eSmrg rm -f "$tmpdepfile" 616c35d236eSmrg ;; 617c35d236eSmrg 618c35d236eSmrgdashXmstdout) 619c35d236eSmrg # This case only exists to satisfy depend.m4. It is never actually 620c35d236eSmrg # run, as this mode is specially recognized in the preamble. 621c35d236eSmrg exit 1 622c35d236eSmrg ;; 623c35d236eSmrg 624c35d236eSmrgmakedepend) 625c35d236eSmrg "$@" || exit $? 626c35d236eSmrg # Remove any Libtool call 627c35d236eSmrg if test "$libtool" = yes; then 628518bcf38Smrg while test "X$1" != 'X--mode=compile'; do 629c35d236eSmrg shift 630c35d236eSmrg done 631c35d236eSmrg shift 632c35d236eSmrg fi 633c35d236eSmrg # X makedepend 634c35d236eSmrg shift 635518bcf38Smrg cleared=no eat=no 636518bcf38Smrg for arg 637518bcf38Smrg do 638c35d236eSmrg case $cleared in 639c35d236eSmrg no) 640c35d236eSmrg set ""; shift 641c35d236eSmrg cleared=yes ;; 642c35d236eSmrg esac 643518bcf38Smrg if test $eat = yes; then 644518bcf38Smrg eat=no 645518bcf38Smrg continue 646518bcf38Smrg fi 647c35d236eSmrg case "$arg" in 648c35d236eSmrg -D*|-I*) 649c35d236eSmrg set fnord "$@" "$arg"; shift ;; 650c35d236eSmrg # Strip any option that makedepend may not understand. Remove 651c35d236eSmrg # the object too, otherwise makedepend will parse it as a source file. 652518bcf38Smrg -arch) 653518bcf38Smrg eat=yes ;; 654c35d236eSmrg -*|$object) 655c35d236eSmrg ;; 656c35d236eSmrg *) 657c35d236eSmrg set fnord "$@" "$arg"; shift ;; 658c35d236eSmrg esac 659c35d236eSmrg done 660518bcf38Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 661c35d236eSmrg touch "$tmpdepfile" 662c35d236eSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 663c35d236eSmrg rm -f "$depfile" 6641fb744b4Smrg # makedepend may prepend the VPATH from the source file name to the object. 6651fb744b4Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 6661fb744b4Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 66714210e8eSmrg # Some versions of the HPUX 10.20 sed can't process the last invocation 66814210e8eSmrg # correctly. Breaking it into two sed invocations is a workaround. 66914210e8eSmrg sed '1,2d' "$tmpdepfile" \ 67014210e8eSmrg | tr ' ' "$nl" \ 67114210e8eSmrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 67214210e8eSmrg | sed -e 's/$/ :/' >> "$depfile" 673c35d236eSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 674c35d236eSmrg ;; 675c35d236eSmrg 676c35d236eSmrgcpp) 677c35d236eSmrg # Important note: in order to support this mode, a compiler *must* 678c35d236eSmrg # always write the preprocessed file to stdout. 679c35d236eSmrg "$@" || exit $? 680c35d236eSmrg 681c35d236eSmrg # Remove the call to Libtool. 682c35d236eSmrg if test "$libtool" = yes; then 683518bcf38Smrg while test "X$1" != 'X--mode=compile'; do 684c35d236eSmrg shift 685c35d236eSmrg done 686c35d236eSmrg shift 687c35d236eSmrg fi 688c35d236eSmrg 68914210e8eSmrg # Remove '-o $object'. 690c35d236eSmrg IFS=" " 691c35d236eSmrg for arg 692c35d236eSmrg do 693c35d236eSmrg case $arg in 694c35d236eSmrg -o) 695c35d236eSmrg shift 696c35d236eSmrg ;; 697c35d236eSmrg $object) 698c35d236eSmrg shift 699c35d236eSmrg ;; 700c35d236eSmrg *) 701c35d236eSmrg set fnord "$@" "$arg" 702c35d236eSmrg shift # fnord 703c35d236eSmrg shift # $arg 704c35d236eSmrg ;; 705c35d236eSmrg esac 706c35d236eSmrg done 707c35d236eSmrg 70814210e8eSmrg "$@" -E \ 70914210e8eSmrg | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 71014210e8eSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 71114210e8eSmrg | sed '$ s: \\$::' > "$tmpdepfile" 712c35d236eSmrg rm -f "$depfile" 713c35d236eSmrg echo "$object : \\" > "$depfile" 714c35d236eSmrg cat < "$tmpdepfile" >> "$depfile" 715c35d236eSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 716c35d236eSmrg rm -f "$tmpdepfile" 717c35d236eSmrg ;; 718c35d236eSmrg 719c35d236eSmrgmsvisualcpp) 720c35d236eSmrg # Important note: in order to support this mode, a compiler *must* 721518bcf38Smrg # always write the preprocessed file to stdout. 722c35d236eSmrg "$@" || exit $? 723518bcf38Smrg 724518bcf38Smrg # Remove the call to Libtool. 725518bcf38Smrg if test "$libtool" = yes; then 726518bcf38Smrg while test "X$1" != 'X--mode=compile'; do 727518bcf38Smrg shift 728518bcf38Smrg done 729518bcf38Smrg shift 730518bcf38Smrg fi 731518bcf38Smrg 732c35d236eSmrg IFS=" " 733c35d236eSmrg for arg 734c35d236eSmrg do 735c35d236eSmrg case "$arg" in 736518bcf38Smrg -o) 737518bcf38Smrg shift 738518bcf38Smrg ;; 739518bcf38Smrg $object) 740518bcf38Smrg shift 741518bcf38Smrg ;; 742c35d236eSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 74314210e8eSmrg set fnord "$@" 74414210e8eSmrg shift 74514210e8eSmrg shift 74614210e8eSmrg ;; 747c35d236eSmrg *) 74814210e8eSmrg set fnord "$@" "$arg" 74914210e8eSmrg shift 75014210e8eSmrg shift 75114210e8eSmrg ;; 752c35d236eSmrg esac 753c35d236eSmrg done 754518bcf38Smrg "$@" -E 2>/dev/null | 755518bcf38Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 756c35d236eSmrg rm -f "$depfile" 757c35d236eSmrg echo "$object : \\" > "$depfile" 75814210e8eSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 75914210e8eSmrg echo "$tab" >> "$depfile" 760518bcf38Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 761c35d236eSmrg rm -f "$tmpdepfile" 762c35d236eSmrg ;; 763c35d236eSmrg 764518bcf38Smrgmsvcmsys) 765518bcf38Smrg # This case exists only to let depend.m4 do its work. It works by 766518bcf38Smrg # looking at the text of this script. This case will never be run, 767518bcf38Smrg # since it is checked for above. 768518bcf38Smrg exit 1 769518bcf38Smrg ;; 770518bcf38Smrg 771c35d236eSmrgnone) 772c35d236eSmrg exec "$@" 773c35d236eSmrg ;; 774c35d236eSmrg 775c35d236eSmrg*) 776c35d236eSmrg echo "Unknown depmode $depmode" 1>&2 777c35d236eSmrg exit 1 778c35d236eSmrg ;; 779c35d236eSmrgesac 780c35d236eSmrg 781c35d236eSmrgexit 0 782c35d236eSmrg 783c35d236eSmrg# Local Variables: 784c35d236eSmrg# mode: shell-script 785c35d236eSmrg# sh-indentation: 2 786c35d236eSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 787c35d236eSmrg# time-stamp-start: "scriptversion=" 788c35d236eSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 789518bcf38Smrg# time-stamp-time-zone: "UTC" 790518bcf38Smrg# time-stamp-end: "; # UTC" 791c35d236eSmrg# End: 792