14b0ead49Smrg#! /bin/sh 24b0ead49Smrg# depcomp - compile a program generating dependencies as side-effects 34b0ead49Smrg 4c3e29c03Smrgscriptversion=2018-03-07.03; # UTC 54b0ead49Smrg 6c3e29c03Smrg# Copyright (C) 1999-2021 Free Software Foundation, Inc. 74b0ead49Smrg 84b0ead49Smrg# This program is free software; you can redistribute it and/or modify 94b0ead49Smrg# it under the terms of the GNU General Public License as published by 104b0ead49Smrg# the Free Software Foundation; either version 2, or (at your option) 114b0ead49Smrg# any later version. 124b0ead49Smrg 134b0ead49Smrg# This program is distributed in the hope that it will be useful, 144b0ead49Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 154b0ead49Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 164b0ead49Smrg# GNU General Public License for more details. 174b0ead49Smrg 184b0ead49Smrg# You should have received a copy of the GNU General Public License 19c3e29c03Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 204b0ead49Smrg 214b0ead49Smrg# As a special exception to the GNU General Public License, if you 224b0ead49Smrg# distribute this file as part of a program that contains a 234b0ead49Smrg# configuration script generated by Autoconf, you may include it under 244b0ead49Smrg# the same distribution terms that you use for the rest of that program. 254b0ead49Smrg 264b0ead49Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 274b0ead49Smrg 284b0ead49Smrgcase $1 in 294b0ead49Smrg '') 3026372658Smrg echo "$0: No command. Try '$0 --help' for more information." 1>&2 3126372658Smrg exit 1; 3226372658Smrg ;; 334b0ead49Smrg -h | --h*) 344b0ead49Smrg cat <<\EOF 354b0ead49SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 364b0ead49Smrg 374b0ead49SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 384b0ead49Smrgas side-effects. 394b0ead49Smrg 404b0ead49SmrgEnvironment variables: 414b0ead49Smrg depmode Dependency tracking mode. 4226372658Smrg source Source file read by 'PROGRAMS ARGS'. 4326372658Smrg object Object file output by 'PROGRAMS ARGS'. 444b0ead49Smrg DEPDIR directory where to store dependencies. 454b0ead49Smrg depfile Dependency file to output. 464e7590efSmrg tmpdepfile Temporary file to use when outputting dependencies. 474b0ead49Smrg libtool Whether libtool is used (yes/no). 484b0ead49Smrg 494b0ead49SmrgReport bugs to <bug-automake@gnu.org>. 504b0ead49SmrgEOF 514b0ead49Smrg exit $? 524b0ead49Smrg ;; 534b0ead49Smrg -v | --v*) 544b0ead49Smrg echo "depcomp $scriptversion" 554b0ead49Smrg exit $? 564b0ead49Smrg ;; 574b0ead49Smrgesac 584b0ead49Smrg 5926372658Smrg# Get the directory component of the given path, and save it in the 6026372658Smrg# global variables '$dir'. Note that this directory component will 6126372658Smrg# be either empty or ending with a '/' character. This is deliberate. 6226372658Smrgset_dir_from () 6326372658Smrg{ 6426372658Smrg case $1 in 6526372658Smrg */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 6626372658Smrg *) dir=;; 6726372658Smrg esac 6826372658Smrg} 6926372658Smrg 7026372658Smrg# Get the suffix-stripped basename of the given path, and save it the 7126372658Smrg# global variable '$base'. 7226372658Smrgset_base_from () 7326372658Smrg{ 7426372658Smrg base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 7526372658Smrg} 7626372658Smrg 7726372658Smrg# If no dependency file was actually created by the compiler invocation, 7826372658Smrg# we still have to create a dummy depfile, to avoid errors with the 7926372658Smrg# Makefile "include basename.Plo" scheme. 8026372658Smrgmake_dummy_depfile () 8126372658Smrg{ 8226372658Smrg echo "#dummy" > "$depfile" 8326372658Smrg} 8426372658Smrg 8526372658Smrg# Factor out some common post-processing of the generated depfile. 8626372658Smrg# Requires the auxiliary global variable '$tmpdepfile' to be set. 8726372658Smrgaix_post_process_depfile () 8826372658Smrg{ 8926372658Smrg # If the compiler actually managed to produce a dependency file, 9026372658Smrg # post-process it. 9126372658Smrg if test -f "$tmpdepfile"; then 9226372658Smrg # Each line is of the form 'foo.o: dependency.h'. 9326372658Smrg # Do two passes, one to just change these to 9426372658Smrg # $object: dependency.h 9526372658Smrg # and one to simply output 9626372658Smrg # dependency.h: 9726372658Smrg # which is needed to avoid the deleted-header problem. 9826372658Smrg { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 9926372658Smrg sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 10026372658Smrg } > "$depfile" 10126372658Smrg rm -f "$tmpdepfile" 10226372658Smrg else 10326372658Smrg make_dummy_depfile 10426372658Smrg fi 10526372658Smrg} 10626372658Smrg 10726372658Smrg# A tabulation character. 10826372658Smrgtab=' ' 10926372658Smrg# A newline character. 11026372658Smrgnl=' 11126372658Smrg' 11226372658Smrg# Character ranges might be problematic outside the C locale. 11326372658Smrg# These definitions help. 11426372658Smrgupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 11526372658Smrglower=abcdefghijklmnopqrstuvwxyz 11626372658Smrgdigits=0123456789 11726372658Smrgalpha=${upper}${lower} 11826372658Smrg 1194b0ead49Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 1204b0ead49Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 1214b0ead49Smrg exit 1 1224b0ead49Smrgfi 1234b0ead49Smrg 1244b0ead49Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 1254b0ead49Smrgdepfile=${depfile-`echo "$object" | 1264b0ead49Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 1274b0ead49Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 1284b0ead49Smrg 1294b0ead49Smrgrm -f "$tmpdepfile" 1304b0ead49Smrg 13126372658Smrg# Avoid interferences from the environment. 13226372658Smrggccflag= dashmflag= 13326372658Smrg 1344b0ead49Smrg# Some modes work just like other modes, but use different flags. We 1354b0ead49Smrg# parameterize here, but still list the modes in the big case below, 1364b0ead49Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 1374b0ead49Smrg# here, because this file can only contain one case statement. 1384b0ead49Smrgif test "$depmode" = hp; then 1394b0ead49Smrg # HP compiler uses -M and no extra arg. 1404b0ead49Smrg gccflag=-M 1414b0ead49Smrg depmode=gcc 1424b0ead49Smrgfi 1434b0ead49Smrg 1444b0ead49Smrgif test "$depmode" = dashXmstdout; then 14526372658Smrg # This is just like dashmstdout with a different argument. 14626372658Smrg dashmflag=-xM 14726372658Smrg depmode=dashmstdout 1484b0ead49Smrgfi 1494b0ead49Smrg 15052b01e16Smrgcygpath_u="cygpath -u -f -" 15152b01e16Smrgif test "$depmode" = msvcmsys; then 15226372658Smrg # This is just like msvisualcpp but w/o cygpath translation. 15326372658Smrg # Just convert the backslash-escaped backslashes to single forward 15426372658Smrg # slashes to satisfy depend.m4 15526372658Smrg cygpath_u='sed s,\\\\,/,g' 15626372658Smrg depmode=msvisualcpp 15752b01e16Smrgfi 15852b01e16Smrg 1594e7590efSmrgif test "$depmode" = msvc7msys; then 16026372658Smrg # This is just like msvc7 but w/o cygpath translation. 16126372658Smrg # Just convert the backslash-escaped backslashes to single forward 16226372658Smrg # slashes to satisfy depend.m4 16326372658Smrg cygpath_u='sed s,\\\\,/,g' 16426372658Smrg depmode=msvc7 16526372658Smrgfi 16626372658Smrg 16726372658Smrgif test "$depmode" = xlc; then 16826372658Smrg # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 16926372658Smrg gccflag=-qmakedep=gcc,-MF 17026372658Smrg depmode=gcc 1714e7590efSmrgfi 1724e7590efSmrg 1734b0ead49Smrgcase "$depmode" in 1744b0ead49Smrggcc3) 1754b0ead49Smrg## gcc 3 implements dependency tracking that does exactly what 1764b0ead49Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1774b0ead49Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 17852b01e16Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 17952b01e16Smrg## the command line argument order; so add the flags where they 18052b01e16Smrg## appear in depend2.am. Note that the slowdown incurred here 18152b01e16Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 18252b01e16Smrg for arg 18352b01e16Smrg do 18452b01e16Smrg case $arg in 18552b01e16Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 18652b01e16Smrg *) set fnord "$@" "$arg" ;; 18752b01e16Smrg esac 18852b01e16Smrg shift # fnord 18952b01e16Smrg shift # $arg 19052b01e16Smrg done 19152b01e16Smrg "$@" 1924b0ead49Smrg stat=$? 19326372658Smrg if test $stat -ne 0; then 1944b0ead49Smrg rm -f "$tmpdepfile" 1954b0ead49Smrg exit $stat 1964b0ead49Smrg fi 1974b0ead49Smrg mv "$tmpdepfile" "$depfile" 1984b0ead49Smrg ;; 1994b0ead49Smrg 2004b0ead49Smrggcc) 20126372658Smrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 20226372658Smrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 20326372658Smrg## (see the conditional assignment to $gccflag above). 2044b0ead49Smrg## There are various ways to get dependency output from gcc. Here's 2054b0ead49Smrg## why we pick this rather obscure method: 2064b0ead49Smrg## - Don't want to use -MD because we'd like the dependencies to end 2074b0ead49Smrg## up in a subdir. Having to rename by hand is ugly. 2084b0ead49Smrg## (We might end up doing this anyway to support other compilers.) 2094b0ead49Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 21026372658Smrg## -MM, not -M (despite what the docs say). Also, it might not be 21126372658Smrg## supported by the other compilers which use the 'gcc' depmode. 2124b0ead49Smrg## - Using -M directly means running the compiler twice (even worse 2134b0ead49Smrg## than renaming). 2144b0ead49Smrg if test -z "$gccflag"; then 2154b0ead49Smrg gccflag=-MD, 2164b0ead49Smrg fi 2174b0ead49Smrg "$@" -Wp,"$gccflag$tmpdepfile" 2184b0ead49Smrg stat=$? 21926372658Smrg if test $stat -ne 0; then 2204b0ead49Smrg rm -f "$tmpdepfile" 2214b0ead49Smrg exit $stat 2224b0ead49Smrg fi 2234b0ead49Smrg rm -f "$depfile" 2244b0ead49Smrg echo "$object : \\" > "$depfile" 22526372658Smrg # The second -e expression handles DOS-style file names with drive 22626372658Smrg # letters. 2274b0ead49Smrg sed -e 's/^[^:]*: / /' \ 2284b0ead49Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 22926372658Smrg## This next piece of magic avoids the "deleted header file" problem. 2304b0ead49Smrg## The problem is that when a header file which appears in a .P file 2314b0ead49Smrg## is deleted, the dependency causes make to die (because there is 2324b0ead49Smrg## typically no way to rebuild the header). We avoid this by adding 2334b0ead49Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 2344b0ead49Smrg## this for us directly. 23526372658Smrg## Some versions of gcc put a space before the ':'. On the theory 2364b0ead49Smrg## that the space means something, we add a space to the output as 2374e7590efSmrg## well. hp depmode also adds that space, but also prefixes the VPATH 2384e7590efSmrg## to the object. Take care to not repeat it in the output. 2394b0ead49Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 2404b0ead49Smrg## correctly. Breaking it into two sed invocations is a workaround. 24126372658Smrg tr ' ' "$nl" < "$tmpdepfile" \ 24226372658Smrg | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 24326372658Smrg | sed -e 's/$/ :/' >> "$depfile" 2444b0ead49Smrg rm -f "$tmpdepfile" 2454b0ead49Smrg ;; 2464b0ead49Smrg 2474b0ead49Smrghp) 2484b0ead49Smrg # This case exists only to let depend.m4 do its work. It works by 2494b0ead49Smrg # looking at the text of this script. This case will never be run, 2504b0ead49Smrg # since it is checked for above. 2514b0ead49Smrg exit 1 2524b0ead49Smrg ;; 2534b0ead49Smrg 2544b0ead49Smrgsgi) 2554b0ead49Smrg if test "$libtool" = yes; then 2564b0ead49Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 2574b0ead49Smrg else 2584b0ead49Smrg "$@" -MDupdate "$tmpdepfile" 2594b0ead49Smrg fi 2604b0ead49Smrg stat=$? 26126372658Smrg if test $stat -ne 0; then 2624b0ead49Smrg rm -f "$tmpdepfile" 2634b0ead49Smrg exit $stat 2644b0ead49Smrg fi 2654b0ead49Smrg rm -f "$depfile" 2664b0ead49Smrg 2674b0ead49Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 2684b0ead49Smrg echo "$object : \\" > "$depfile" 2694b0ead49Smrg # Clip off the initial element (the dependent). Don't try to be 2704b0ead49Smrg # clever and replace this with sed code, as IRIX sed won't handle 2714b0ead49Smrg # lines with more than a fixed number of characters (4096 in 2724b0ead49Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 27326372658Smrg # the IRIX cc adds comments like '#:fec' to the end of the 2744b0ead49Smrg # dependency line. 27526372658Smrg tr ' ' "$nl" < "$tmpdepfile" \ 27626372658Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 27726372658Smrg | tr "$nl" ' ' >> "$depfile" 27852b01e16Smrg echo >> "$depfile" 2794b0ead49Smrg # The second pass generates a dummy entry for each header file. 28026372658Smrg tr ' ' "$nl" < "$tmpdepfile" \ 28126372658Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 28226372658Smrg >> "$depfile" 2834b0ead49Smrg else 28426372658Smrg make_dummy_depfile 2854b0ead49Smrg fi 2864b0ead49Smrg rm -f "$tmpdepfile" 2874b0ead49Smrg ;; 2884b0ead49Smrg 28926372658Smrgxlc) 29026372658Smrg # This case exists only to let depend.m4 do its work. It works by 29126372658Smrg # looking at the text of this script. This case will never be run, 29226372658Smrg # since it is checked for above. 29326372658Smrg exit 1 29426372658Smrg ;; 29526372658Smrg 2964b0ead49Smrgaix) 2974b0ead49Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2984b0ead49Smrg # in a .u file. In older versions, this file always lives in the 29926372658Smrg # current directory. Also, the AIX compiler puts '$object:' at the 3004b0ead49Smrg # start of each line; $object doesn't have directory information. 3014b0ead49Smrg # Version 6 uses the directory in both cases. 30226372658Smrg set_dir_from "$object" 30326372658Smrg set_base_from "$object" 3044b0ead49Smrg if test "$libtool" = yes; then 30552b01e16Smrg tmpdepfile1=$dir$base.u 30652b01e16Smrg tmpdepfile2=$base.u 30752b01e16Smrg tmpdepfile3=$dir.libs/$base.u 3084b0ead49Smrg "$@" -Wc,-M 3094b0ead49Smrg else 31052b01e16Smrg tmpdepfile1=$dir$base.u 31152b01e16Smrg tmpdepfile2=$dir$base.u 31252b01e16Smrg tmpdepfile3=$dir$base.u 3134b0ead49Smrg "$@" -M 3144b0ead49Smrg fi 3154b0ead49Smrg stat=$? 31626372658Smrg if test $stat -ne 0; then 31752b01e16Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3184b0ead49Smrg exit $stat 3194b0ead49Smrg fi 3204b0ead49Smrg 32152b01e16Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 32252b01e16Smrg do 32352b01e16Smrg test -f "$tmpdepfile" && break 32452b01e16Smrg done 32526372658Smrg aix_post_process_depfile 32626372658Smrg ;; 32726372658Smrg 32826372658Smrgtcc) 32926372658Smrg # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 33026372658Smrg # FIXME: That version still under development at the moment of writing. 33126372658Smrg # Make that this statement remains true also for stable, released 33226372658Smrg # versions. 33326372658Smrg # It will wrap lines (doesn't matter whether long or short) with a 33426372658Smrg # trailing '\', as in: 33526372658Smrg # 33626372658Smrg # foo.o : \ 33726372658Smrg # foo.c \ 33826372658Smrg # foo.h \ 33926372658Smrg # 34026372658Smrg # It will put a trailing '\' even on the last line, and will use leading 34126372658Smrg # spaces rather than leading tabs (at least since its commit 0394caf7 34226372658Smrg # "Emit spaces for -MD"). 34326372658Smrg "$@" -MD -MF "$tmpdepfile" 34426372658Smrg stat=$? 34526372658Smrg if test $stat -ne 0; then 34626372658Smrg rm -f "$tmpdepfile" 34726372658Smrg exit $stat 3484b0ead49Smrg fi 34926372658Smrg rm -f "$depfile" 35026372658Smrg # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 35126372658Smrg # We have to change lines of the first kind to '$object: \'. 35226372658Smrg sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 35326372658Smrg # And for each line of the second kind, we have to emit a 'dep.h:' 35426372658Smrg # dummy dependency, to avoid the deleted-header problem. 35526372658Smrg sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 3564b0ead49Smrg rm -f "$tmpdepfile" 3574b0ead49Smrg ;; 3584b0ead49Smrg 35926372658Smrg## The order of this option in the case statement is important, since the 36026372658Smrg## shell code in configure will try each of these formats in the order 36126372658Smrg## listed in this file. A plain '-MD' option would be understood by many 36226372658Smrg## compilers, so we must ensure this comes after the gcc and icc options. 36326372658Smrgpgcc) 36426372658Smrg # Portland's C compiler understands '-MD'. 36526372658Smrg # Will always output deps to 'file.d' where file is the root name of the 36626372658Smrg # source file under compilation, even if file resides in a subdirectory. 36726372658Smrg # The object file name does not affect the name of the '.d' file. 36826372658Smrg # pgcc 10.2 will output 3694b0ead49Smrg # foo.o: sub/foo.c sub/foo.h 37026372658Smrg # and will wrap long lines using '\' : 3714b0ead49Smrg # foo.o: sub/foo.c ... \ 3724b0ead49Smrg # sub/foo.h ... \ 3734b0ead49Smrg # ... 37426372658Smrg set_dir_from "$object" 37526372658Smrg # Use the source, not the object, to determine the base name, since 37626372658Smrg # that's sadly what pgcc will do too. 37726372658Smrg set_base_from "$source" 37826372658Smrg tmpdepfile=$base.d 37926372658Smrg 38026372658Smrg # For projects that build the same source file twice into different object 38126372658Smrg # files, the pgcc approach of using the *source* file root name can cause 38226372658Smrg # problems in parallel builds. Use a locking strategy to avoid stomping on 38326372658Smrg # the same $tmpdepfile. 38426372658Smrg lockdir=$base.d-lock 38526372658Smrg trap " 38626372658Smrg echo '$0: caught signal, cleaning up...' >&2 38726372658Smrg rmdir '$lockdir' 38826372658Smrg exit 1 38926372658Smrg " 1 2 13 15 39026372658Smrg numtries=100 39126372658Smrg i=$numtries 39226372658Smrg while test $i -gt 0; do 39326372658Smrg # mkdir is a portable test-and-set. 39426372658Smrg if mkdir "$lockdir" 2>/dev/null; then 39526372658Smrg # This process acquired the lock. 39626372658Smrg "$@" -MD 39726372658Smrg stat=$? 39826372658Smrg # Release the lock. 39926372658Smrg rmdir "$lockdir" 40026372658Smrg break 40126372658Smrg else 40226372658Smrg # If the lock is being held by a different process, wait 40326372658Smrg # until the winning process is done or we timeout. 40426372658Smrg while test -d "$lockdir" && test $i -gt 0; do 40526372658Smrg sleep 1 40626372658Smrg i=`expr $i - 1` 40726372658Smrg done 40826372658Smrg fi 40926372658Smrg i=`expr $i - 1` 41026372658Smrg done 41126372658Smrg trap - 1 2 13 15 41226372658Smrg if test $i -le 0; then 41326372658Smrg echo "$0: failed to acquire lock after $numtries attempts" >&2 41426372658Smrg echo "$0: check lockdir '$lockdir'" >&2 41526372658Smrg exit 1 41626372658Smrg fi 4174b0ead49Smrg 41826372658Smrg if test $stat -ne 0; then 4194b0ead49Smrg rm -f "$tmpdepfile" 4204b0ead49Smrg exit $stat 4214b0ead49Smrg fi 4224b0ead49Smrg rm -f "$depfile" 4234b0ead49Smrg # Each line is of the form `foo.o: dependent.h', 4244b0ead49Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 4254b0ead49Smrg # Do two passes, one to just change these to 4264b0ead49Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 4274b0ead49Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 4284b0ead49Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 4294b0ead49Smrg # correctly. Breaking it into two sed invocations is a workaround. 43026372658Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 43126372658Smrg | sed -e 's/$/ :/' >> "$depfile" 4324b0ead49Smrg rm -f "$tmpdepfile" 4334b0ead49Smrg ;; 4344b0ead49Smrg 43552b01e16Smrghp2) 43652b01e16Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 43752b01e16Smrg # compilers, which have integrated preprocessors. The correct option 43852b01e16Smrg # to use with these is +Maked; it writes dependencies to a file named 43952b01e16Smrg # 'foo.d', which lands next to the object file, wherever that 44052b01e16Smrg # happens to be. 44152b01e16Smrg # Much of this is similar to the tru64 case; see comments there. 44226372658Smrg set_dir_from "$object" 44326372658Smrg set_base_from "$object" 44452b01e16Smrg if test "$libtool" = yes; then 44552b01e16Smrg tmpdepfile1=$dir$base.d 44652b01e16Smrg tmpdepfile2=$dir.libs/$base.d 44752b01e16Smrg "$@" -Wc,+Maked 44852b01e16Smrg else 44952b01e16Smrg tmpdepfile1=$dir$base.d 45052b01e16Smrg tmpdepfile2=$dir$base.d 45152b01e16Smrg "$@" +Maked 45252b01e16Smrg fi 45352b01e16Smrg stat=$? 45426372658Smrg if test $stat -ne 0; then 45552b01e16Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 45652b01e16Smrg exit $stat 45752b01e16Smrg fi 45852b01e16Smrg 45952b01e16Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 46052b01e16Smrg do 46152b01e16Smrg test -f "$tmpdepfile" && break 46252b01e16Smrg done 46352b01e16Smrg if test -f "$tmpdepfile"; then 46426372658Smrg sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 46526372658Smrg # Add 'dependent.h:' lines. 46652b01e16Smrg sed -ne '2,${ 46726372658Smrg s/^ *// 46826372658Smrg s/ \\*$// 46926372658Smrg s/$/:/ 47026372658Smrg p 47126372658Smrg }' "$tmpdepfile" >> "$depfile" 47252b01e16Smrg else 47326372658Smrg make_dummy_depfile 47452b01e16Smrg fi 47552b01e16Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 47652b01e16Smrg ;; 47752b01e16Smrg 4784b0ead49Smrgtru64) 47926372658Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 48026372658Smrg # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 48126372658Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 48226372658Smrg # dependencies in 'foo.d' instead, so we check for that too. 48326372658Smrg # Subdirectories are respected. 48426372658Smrg set_dir_from "$object" 48526372658Smrg set_base_from "$object" 48626372658Smrg 48726372658Smrg if test "$libtool" = yes; then 48826372658Smrg # Libtool generates 2 separate objects for the 2 libraries. These 48926372658Smrg # two compilations output dependencies in $dir.libs/$base.o.d and 49026372658Smrg # in $dir$base.o.d. We have to check for both files, because 49126372658Smrg # one of the two compilations can be disabled. We should prefer 49226372658Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 49326372658Smrg # automatically cleaned when .libs/ is deleted, while ignoring 49426372658Smrg # the former would cause a distcleancheck panic. 49526372658Smrg tmpdepfile1=$dir$base.o.d # libtool 1.5 49626372658Smrg tmpdepfile2=$dir.libs/$base.o.d # Likewise. 49726372658Smrg tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 49826372658Smrg "$@" -Wc,-MD 49926372658Smrg else 50026372658Smrg tmpdepfile1=$dir$base.d 50126372658Smrg tmpdepfile2=$dir$base.d 50226372658Smrg tmpdepfile3=$dir$base.d 50326372658Smrg "$@" -MD 50426372658Smrg fi 50526372658Smrg 50626372658Smrg stat=$? 50726372658Smrg if test $stat -ne 0; then 50826372658Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 50926372658Smrg exit $stat 51026372658Smrg fi 51126372658Smrg 51226372658Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 51326372658Smrg do 51426372658Smrg test -f "$tmpdepfile" && break 51526372658Smrg done 51626372658Smrg # Same post-processing that is required for AIX mode. 51726372658Smrg aix_post_process_depfile 51826372658Smrg ;; 5194b0ead49Smrg 5204e7590efSmrgmsvc7) 5214e7590efSmrg if test "$libtool" = yes; then 5224e7590efSmrg showIncludes=-Wc,-showIncludes 5234e7590efSmrg else 5244e7590efSmrg showIncludes=-showIncludes 5254e7590efSmrg fi 5264e7590efSmrg "$@" $showIncludes > "$tmpdepfile" 5274e7590efSmrg stat=$? 5284e7590efSmrg grep -v '^Note: including file: ' "$tmpdepfile" 52926372658Smrg if test $stat -ne 0; then 5304e7590efSmrg rm -f "$tmpdepfile" 5314e7590efSmrg exit $stat 5324e7590efSmrg fi 5334e7590efSmrg rm -f "$depfile" 5344e7590efSmrg echo "$object : \\" > "$depfile" 5354e7590efSmrg # The first sed program below extracts the file names and escapes 5364e7590efSmrg # backslashes for cygpath. The second sed program outputs the file 5374e7590efSmrg # name when reading, but also accumulates all include files in the 5384e7590efSmrg # hold buffer in order to output them again at the end. This only 5394e7590efSmrg # works with sed implementations that can handle large buffers. 5404e7590efSmrg sed < "$tmpdepfile" -n ' 5414e7590efSmrg/^Note: including file: *\(.*\)/ { 5424e7590efSmrg s//\1/ 5434e7590efSmrg s/\\/\\\\/g 5444e7590efSmrg p 5454e7590efSmrg}' | $cygpath_u | sort -u | sed -n ' 5464e7590efSmrgs/ /\\ /g 54726372658Smrgs/\(.*\)/'"$tab"'\1 \\/p 5484e7590efSmrgs/.\(.*\) \\/\1:/ 5494e7590efSmrgH 5504e7590efSmrg$ { 55126372658Smrg s/.*/'"$tab"'/ 5524e7590efSmrg G 5534e7590efSmrg p 5544e7590efSmrg}' >> "$depfile" 55526372658Smrg echo >> "$depfile" # make sure the fragment doesn't end with a backslash 5564e7590efSmrg rm -f "$tmpdepfile" 5574e7590efSmrg ;; 5584e7590efSmrg 5594e7590efSmrgmsvc7msys) 5604e7590efSmrg # This case exists only to let depend.m4 do its work. It works by 5614e7590efSmrg # looking at the text of this script. This case will never be run, 5624e7590efSmrg # since it is checked for above. 5634e7590efSmrg exit 1 5644e7590efSmrg ;; 5654e7590efSmrg 5664b0ead49Smrg#nosideeffect) 5674b0ead49Smrg # This comment above is used by automake to tell side-effect 5684b0ead49Smrg # dependency tracking mechanisms from slower ones. 5694b0ead49Smrg 5704b0ead49Smrgdashmstdout) 5714b0ead49Smrg # Important note: in order to support this mode, a compiler *must* 5724b0ead49Smrg # always write the preprocessed file to stdout, regardless of -o. 5734b0ead49Smrg "$@" || exit $? 5744b0ead49Smrg 5754b0ead49Smrg # Remove the call to Libtool. 5764b0ead49Smrg if test "$libtool" = yes; then 57752b01e16Smrg while test "X$1" != 'X--mode=compile'; do 5784b0ead49Smrg shift 5794b0ead49Smrg done 5804b0ead49Smrg shift 5814b0ead49Smrg fi 5824b0ead49Smrg 58326372658Smrg # Remove '-o $object'. 5844b0ead49Smrg IFS=" " 5854b0ead49Smrg for arg 5864b0ead49Smrg do 5874b0ead49Smrg case $arg in 5884b0ead49Smrg -o) 5894b0ead49Smrg shift 5904b0ead49Smrg ;; 5914b0ead49Smrg $object) 5924b0ead49Smrg shift 5934b0ead49Smrg ;; 5944b0ead49Smrg *) 5954b0ead49Smrg set fnord "$@" "$arg" 5964b0ead49Smrg shift # fnord 5974b0ead49Smrg shift # $arg 5984b0ead49Smrg ;; 5994b0ead49Smrg esac 6004b0ead49Smrg done 6014b0ead49Smrg 6024b0ead49Smrg test -z "$dashmflag" && dashmflag=-M 60326372658Smrg # Require at least two characters before searching for ':' 6044b0ead49Smrg # in the target name. This is to cope with DOS-style filenames: 60526372658Smrg # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 6064b0ead49Smrg "$@" $dashmflag | 60726372658Smrg sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 6084b0ead49Smrg rm -f "$depfile" 6094b0ead49Smrg cat < "$tmpdepfile" > "$depfile" 61026372658Smrg # Some versions of the HPUX 10.20 sed can't process this sed invocation 61126372658Smrg # correctly. Breaking it into two sed invocations is a workaround. 61226372658Smrg tr ' ' "$nl" < "$tmpdepfile" \ 61326372658Smrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 61426372658Smrg | sed -e 's/$/ :/' >> "$depfile" 6154b0ead49Smrg rm -f "$tmpdepfile" 6164b0ead49Smrg ;; 6174b0ead49Smrg 6184b0ead49SmrgdashXmstdout) 6194b0ead49Smrg # This case only exists to satisfy depend.m4. It is never actually 6204b0ead49Smrg # run, as this mode is specially recognized in the preamble. 6214b0ead49Smrg exit 1 6224b0ead49Smrg ;; 6234b0ead49Smrg 6244b0ead49Smrgmakedepend) 6254b0ead49Smrg "$@" || exit $? 6264b0ead49Smrg # Remove any Libtool call 6274b0ead49Smrg if test "$libtool" = yes; then 62852b01e16Smrg while test "X$1" != 'X--mode=compile'; do 6294b0ead49Smrg shift 6304b0ead49Smrg done 6314b0ead49Smrg shift 6324b0ead49Smrg fi 6334b0ead49Smrg # X makedepend 6344b0ead49Smrg shift 63552b01e16Smrg cleared=no eat=no 63652b01e16Smrg for arg 63752b01e16Smrg do 6384b0ead49Smrg case $cleared in 6394b0ead49Smrg no) 6404b0ead49Smrg set ""; shift 6414b0ead49Smrg cleared=yes ;; 6424b0ead49Smrg esac 64352b01e16Smrg if test $eat = yes; then 64452b01e16Smrg eat=no 64552b01e16Smrg continue 64652b01e16Smrg fi 6474b0ead49Smrg case "$arg" in 6484b0ead49Smrg -D*|-I*) 6494b0ead49Smrg set fnord "$@" "$arg"; shift ;; 6504b0ead49Smrg # Strip any option that makedepend may not understand. Remove 6514b0ead49Smrg # the object too, otherwise makedepend will parse it as a source file. 65252b01e16Smrg -arch) 65352b01e16Smrg eat=yes ;; 6544b0ead49Smrg -*|$object) 6554b0ead49Smrg ;; 6564b0ead49Smrg *) 6574b0ead49Smrg set fnord "$@" "$arg"; shift ;; 6584b0ead49Smrg esac 6594b0ead49Smrg done 66052b01e16Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 6614b0ead49Smrg touch "$tmpdepfile" 6624b0ead49Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 6634b0ead49Smrg rm -f "$depfile" 6644e7590efSmrg # makedepend may prepend the VPATH from the source file name to the object. 6654e7590efSmrg # No need to regex-escape $object, excess matching of '.' is harmless. 6664e7590efSmrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 66726372658Smrg # Some versions of the HPUX 10.20 sed can't process the last invocation 66826372658Smrg # correctly. Breaking it into two sed invocations is a workaround. 66926372658Smrg sed '1,2d' "$tmpdepfile" \ 67026372658Smrg | tr ' ' "$nl" \ 67126372658Smrg | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 67226372658Smrg | sed -e 's/$/ :/' >> "$depfile" 6734b0ead49Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 6744b0ead49Smrg ;; 6754b0ead49Smrg 6764b0ead49Smrgcpp) 6774b0ead49Smrg # Important note: in order to support this mode, a compiler *must* 6784b0ead49Smrg # always write the preprocessed file to stdout. 6794b0ead49Smrg "$@" || exit $? 6804b0ead49Smrg 6814b0ead49Smrg # Remove the call to Libtool. 6824b0ead49Smrg if test "$libtool" = yes; then 68352b01e16Smrg while test "X$1" != 'X--mode=compile'; do 6844b0ead49Smrg shift 6854b0ead49Smrg done 6864b0ead49Smrg shift 6874b0ead49Smrg fi 6884b0ead49Smrg 68926372658Smrg # Remove '-o $object'. 6904b0ead49Smrg IFS=" " 6914b0ead49Smrg for arg 6924b0ead49Smrg do 6934b0ead49Smrg case $arg in 6944b0ead49Smrg -o) 6954b0ead49Smrg shift 6964b0ead49Smrg ;; 6974b0ead49Smrg $object) 6984b0ead49Smrg shift 6994b0ead49Smrg ;; 7004b0ead49Smrg *) 7014b0ead49Smrg set fnord "$@" "$arg" 7024b0ead49Smrg shift # fnord 7034b0ead49Smrg shift # $arg 7044b0ead49Smrg ;; 7054b0ead49Smrg esac 7064b0ead49Smrg done 7074b0ead49Smrg 70826372658Smrg "$@" -E \ 70926372658Smrg | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 71026372658Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 71126372658Smrg | sed '$ s: \\$::' > "$tmpdepfile" 7124b0ead49Smrg rm -f "$depfile" 7134b0ead49Smrg echo "$object : \\" > "$depfile" 7144b0ead49Smrg cat < "$tmpdepfile" >> "$depfile" 7154b0ead49Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 7164b0ead49Smrg rm -f "$tmpdepfile" 7174b0ead49Smrg ;; 7184b0ead49Smrg 7194b0ead49Smrgmsvisualcpp) 7204b0ead49Smrg # Important note: in order to support this mode, a compiler *must* 72152b01e16Smrg # always write the preprocessed file to stdout. 7224b0ead49Smrg "$@" || exit $? 72352b01e16Smrg 72452b01e16Smrg # Remove the call to Libtool. 72552b01e16Smrg if test "$libtool" = yes; then 72652b01e16Smrg while test "X$1" != 'X--mode=compile'; do 72752b01e16Smrg shift 72852b01e16Smrg done 72952b01e16Smrg shift 73052b01e16Smrg fi 73152b01e16Smrg 7324b0ead49Smrg IFS=" " 7334b0ead49Smrg for arg 7344b0ead49Smrg do 7354b0ead49Smrg case "$arg" in 73652b01e16Smrg -o) 73752b01e16Smrg shift 73852b01e16Smrg ;; 73952b01e16Smrg $object) 74052b01e16Smrg shift 74152b01e16Smrg ;; 7424b0ead49Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 74326372658Smrg set fnord "$@" 74426372658Smrg shift 74526372658Smrg shift 74626372658Smrg ;; 7474b0ead49Smrg *) 74826372658Smrg set fnord "$@" "$arg" 74926372658Smrg shift 75026372658Smrg shift 75126372658Smrg ;; 7524b0ead49Smrg esac 7534b0ead49Smrg done 75452b01e16Smrg "$@" -E 2>/dev/null | 75552b01e16Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 7564b0ead49Smrg rm -f "$depfile" 7574b0ead49Smrg echo "$object : \\" > "$depfile" 75826372658Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 75926372658Smrg echo "$tab" >> "$depfile" 76052b01e16Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 7614b0ead49Smrg rm -f "$tmpdepfile" 7624b0ead49Smrg ;; 7634b0ead49Smrg 76452b01e16Smrgmsvcmsys) 76552b01e16Smrg # This case exists only to let depend.m4 do its work. It works by 76652b01e16Smrg # looking at the text of this script. This case will never be run, 76752b01e16Smrg # since it is checked for above. 76852b01e16Smrg exit 1 76952b01e16Smrg ;; 77052b01e16Smrg 7714b0ead49Smrgnone) 7724b0ead49Smrg exec "$@" 7734b0ead49Smrg ;; 7744b0ead49Smrg 7754b0ead49Smrg*) 7764b0ead49Smrg echo "Unknown depmode $depmode" 1>&2 7774b0ead49Smrg exit 1 7784b0ead49Smrg ;; 7794b0ead49Smrgesac 7804b0ead49Smrg 7814b0ead49Smrgexit 0 7824b0ead49Smrg 7834b0ead49Smrg# Local Variables: 7844b0ead49Smrg# mode: shell-script 7854b0ead49Smrg# sh-indentation: 2 786c3e29c03Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 7874b0ead49Smrg# time-stamp-start: "scriptversion=" 7884b0ead49Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 789c3e29c03Smrg# time-stamp-time-zone: "UTC0" 79052b01e16Smrg# time-stamp-end: "; # UTC" 7914b0ead49Smrg# End: 792