cannam@167: #! /bin/sh cannam@167: # depcomp - compile a program generating dependencies as side-effects cannam@167: cannam@167: scriptversion=2013-05-30.07; # UTC cannam@167: cannam@167: # Copyright (C) 1999-2014 Free Software Foundation, Inc. cannam@167: cannam@167: # This program is free software; you can redistribute it and/or modify cannam@167: # it under the terms of the GNU General Public License as published by cannam@167: # the Free Software Foundation; either version 2, or (at your option) cannam@167: # any later version. cannam@167: cannam@167: # This program is distributed in the hope that it will be useful, cannam@167: # but WITHOUT ANY WARRANTY; without even the implied warranty of cannam@167: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@167: # GNU General Public License for more details. cannam@167: cannam@167: # You should have received a copy of the GNU General Public License cannam@167: # along with this program. If not, see . cannam@167: cannam@167: # As a special exception to the GNU General Public License, if you cannam@167: # distribute this file as part of a program that contains a cannam@167: # configuration script generated by Autoconf, you may include it under cannam@167: # the same distribution terms that you use for the rest of that program. cannam@167: cannam@167: # Originally written by Alexandre Oliva . cannam@167: cannam@167: case $1 in cannam@167: '') cannam@167: echo "$0: No command. Try '$0 --help' for more information." 1>&2 cannam@167: exit 1; cannam@167: ;; cannam@167: -h | --h*) cannam@167: cat <<\EOF cannam@167: Usage: depcomp [--help] [--version] PROGRAM [ARGS] cannam@167: cannam@167: Run PROGRAMS ARGS to compile a file, generating dependencies cannam@167: as side-effects. cannam@167: cannam@167: Environment variables: cannam@167: depmode Dependency tracking mode. cannam@167: source Source file read by 'PROGRAMS ARGS'. cannam@167: object Object file output by 'PROGRAMS ARGS'. cannam@167: DEPDIR directory where to store dependencies. cannam@167: depfile Dependency file to output. cannam@167: tmpdepfile Temporary file to use when outputting dependencies. cannam@167: libtool Whether libtool is used (yes/no). cannam@167: cannam@167: Report bugs to . cannam@167: EOF cannam@167: exit $? cannam@167: ;; cannam@167: -v | --v*) cannam@167: echo "depcomp $scriptversion" cannam@167: exit $? cannam@167: ;; cannam@167: esac cannam@167: cannam@167: # Get the directory component of the given path, and save it in the cannam@167: # global variables '$dir'. Note that this directory component will cannam@167: # be either empty or ending with a '/' character. This is deliberate. cannam@167: set_dir_from () cannam@167: { cannam@167: case $1 in cannam@167: */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; cannam@167: *) dir=;; cannam@167: esac cannam@167: } cannam@167: cannam@167: # Get the suffix-stripped basename of the given path, and save it the cannam@167: # global variable '$base'. cannam@167: set_base_from () cannam@167: { cannam@167: base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` cannam@167: } cannam@167: cannam@167: # If no dependency file was actually created by the compiler invocation, cannam@167: # we still have to create a dummy depfile, to avoid errors with the cannam@167: # Makefile "include basename.Plo" scheme. cannam@167: make_dummy_depfile () cannam@167: { cannam@167: echo "#dummy" > "$depfile" cannam@167: } cannam@167: cannam@167: # Factor out some common post-processing of the generated depfile. cannam@167: # Requires the auxiliary global variable '$tmpdepfile' to be set. cannam@167: aix_post_process_depfile () cannam@167: { cannam@167: # If the compiler actually managed to produce a dependency file, cannam@167: # post-process it. cannam@167: if test -f "$tmpdepfile"; then cannam@167: # Each line is of the form 'foo.o: dependency.h'. cannam@167: # Do two passes, one to just change these to cannam@167: # $object: dependency.h cannam@167: # and one to simply output cannam@167: # dependency.h: cannam@167: # which is needed to avoid the deleted-header problem. cannam@167: { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" cannam@167: sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" cannam@167: } > "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: else cannam@167: make_dummy_depfile cannam@167: fi cannam@167: } cannam@167: cannam@167: # A tabulation character. cannam@167: tab=' ' cannam@167: # A newline character. cannam@167: nl=' cannam@167: ' cannam@167: # Character ranges might be problematic outside the C locale. cannam@167: # These definitions help. cannam@167: upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ cannam@167: lower=abcdefghijklmnopqrstuvwxyz cannam@167: digits=0123456789 cannam@167: alpha=${upper}${lower} cannam@167: cannam@167: if test -z "$depmode" || test -z "$source" || test -z "$object"; then cannam@167: echo "depcomp: Variables source, object and depmode must be set" 1>&2 cannam@167: exit 1 cannam@167: fi cannam@167: cannam@167: # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. cannam@167: depfile=${depfile-`echo "$object" | cannam@167: sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} cannam@167: tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} cannam@167: cannam@167: rm -f "$tmpdepfile" cannam@167: cannam@167: # Avoid interferences from the environment. cannam@167: gccflag= dashmflag= cannam@167: cannam@167: # Some modes work just like other modes, but use different flags. We cannam@167: # parameterize here, but still list the modes in the big case below, cannam@167: # to make depend.m4 easier to write. Note that we *cannot* use a case cannam@167: # here, because this file can only contain one case statement. cannam@167: if test "$depmode" = hp; then cannam@167: # HP compiler uses -M and no extra arg. cannam@167: gccflag=-M cannam@167: depmode=gcc cannam@167: fi cannam@167: cannam@167: if test "$depmode" = dashXmstdout; then cannam@167: # This is just like dashmstdout with a different argument. cannam@167: dashmflag=-xM cannam@167: depmode=dashmstdout cannam@167: fi cannam@167: cannam@167: cygpath_u="cygpath -u -f -" cannam@167: if test "$depmode" = msvcmsys; then cannam@167: # This is just like msvisualcpp but w/o cygpath translation. cannam@167: # Just convert the backslash-escaped backslashes to single forward cannam@167: # slashes to satisfy depend.m4 cannam@167: cygpath_u='sed s,\\\\,/,g' cannam@167: depmode=msvisualcpp cannam@167: fi cannam@167: cannam@167: if test "$depmode" = msvc7msys; then cannam@167: # This is just like msvc7 but w/o cygpath translation. cannam@167: # Just convert the backslash-escaped backslashes to single forward cannam@167: # slashes to satisfy depend.m4 cannam@167: cygpath_u='sed s,\\\\,/,g' cannam@167: depmode=msvc7 cannam@167: fi cannam@167: cannam@167: if test "$depmode" = xlc; then cannam@167: # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. cannam@167: gccflag=-qmakedep=gcc,-MF cannam@167: depmode=gcc cannam@167: fi cannam@167: cannam@167: case "$depmode" in cannam@167: gcc3) cannam@167: ## gcc 3 implements dependency tracking that does exactly what cannam@167: ## we want. Yay! Note: for some reason libtool 1.4 doesn't like cannam@167: ## it if -MD -MP comes after the -MF stuff. Hmm. cannam@167: ## Unfortunately, FreeBSD c89 acceptance of flags depends upon cannam@167: ## the command line argument order; so add the flags where they cannam@167: ## appear in depend2.am. Note that the slowdown incurred here cannam@167: ## affects only configure: in makefiles, %FASTDEP% shortcuts this. cannam@167: for arg cannam@167: do cannam@167: case $arg in cannam@167: -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; cannam@167: *) set fnord "$@" "$arg" ;; cannam@167: esac cannam@167: shift # fnord cannam@167: shift # $arg cannam@167: done cannam@167: "$@" cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: mv "$tmpdepfile" "$depfile" cannam@167: ;; cannam@167: cannam@167: gcc) cannam@167: ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. cannam@167: ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. cannam@167: ## (see the conditional assignment to $gccflag above). cannam@167: ## There are various ways to get dependency output from gcc. Here's cannam@167: ## why we pick this rather obscure method: cannam@167: ## - Don't want to use -MD because we'd like the dependencies to end cannam@167: ## up in a subdir. Having to rename by hand is ugly. cannam@167: ## (We might end up doing this anyway to support other compilers.) cannam@167: ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like cannam@167: ## -MM, not -M (despite what the docs say). Also, it might not be cannam@167: ## supported by the other compilers which use the 'gcc' depmode. cannam@167: ## - Using -M directly means running the compiler twice (even worse cannam@167: ## than renaming). cannam@167: if test -z "$gccflag"; then cannam@167: gccflag=-MD, cannam@167: fi cannam@167: "$@" -Wp,"$gccflag$tmpdepfile" cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: rm -f "$depfile" cannam@167: echo "$object : \\" > "$depfile" cannam@167: # The second -e expression handles DOS-style file names with drive cannam@167: # letters. cannam@167: sed -e 's/^[^:]*: / /' \ cannam@167: -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" cannam@167: ## This next piece of magic avoids the "deleted header file" problem. cannam@167: ## The problem is that when a header file which appears in a .P file cannam@167: ## is deleted, the dependency causes make to die (because there is cannam@167: ## typically no way to rebuild the header). We avoid this by adding cannam@167: ## dummy dependencies for each header file. Too bad gcc doesn't do cannam@167: ## this for us directly. cannam@167: ## Some versions of gcc put a space before the ':'. On the theory cannam@167: ## that the space means something, we add a space to the output as cannam@167: ## well. hp depmode also adds that space, but also prefixes the VPATH cannam@167: ## to the object. Take care to not repeat it in the output. cannam@167: ## Some versions of the HPUX 10.20 sed can't process this invocation cannam@167: ## correctly. Breaking it into two sed invocations is a workaround. cannam@167: tr ' ' "$nl" < "$tmpdepfile" \ cannam@167: | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ cannam@167: | sed -e 's/$/ :/' >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: hp) cannam@167: # This case exists only to let depend.m4 do its work. It works by cannam@167: # looking at the text of this script. This case will never be run, cannam@167: # since it is checked for above. cannam@167: exit 1 cannam@167: ;; cannam@167: cannam@167: sgi) cannam@167: if test "$libtool" = yes; then cannam@167: "$@" "-Wp,-MDupdate,$tmpdepfile" cannam@167: else cannam@167: "$@" -MDupdate "$tmpdepfile" cannam@167: fi cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: rm -f "$depfile" cannam@167: cannam@167: if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files cannam@167: echo "$object : \\" > "$depfile" cannam@167: # Clip off the initial element (the dependent). Don't try to be cannam@167: # clever and replace this with sed code, as IRIX sed won't handle cannam@167: # lines with more than a fixed number of characters (4096 in cannam@167: # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; cannam@167: # the IRIX cc adds comments like '#:fec' to the end of the cannam@167: # dependency line. cannam@167: tr ' ' "$nl" < "$tmpdepfile" \ cannam@167: | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ cannam@167: | tr "$nl" ' ' >> "$depfile" cannam@167: echo >> "$depfile" cannam@167: # The second pass generates a dummy entry for each header file. cannam@167: tr ' ' "$nl" < "$tmpdepfile" \ cannam@167: | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ cannam@167: >> "$depfile" cannam@167: else cannam@167: make_dummy_depfile cannam@167: fi cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: xlc) cannam@167: # This case exists only to let depend.m4 do its work. It works by cannam@167: # looking at the text of this script. This case will never be run, cannam@167: # since it is checked for above. cannam@167: exit 1 cannam@167: ;; cannam@167: cannam@167: aix) cannam@167: # The C for AIX Compiler uses -M and outputs the dependencies cannam@167: # in a .u file. In older versions, this file always lives in the cannam@167: # current directory. Also, the AIX compiler puts '$object:' at the cannam@167: # start of each line; $object doesn't have directory information. cannam@167: # Version 6 uses the directory in both cases. cannam@167: set_dir_from "$object" cannam@167: set_base_from "$object" cannam@167: if test "$libtool" = yes; then cannam@167: tmpdepfile1=$dir$base.u cannam@167: tmpdepfile2=$base.u cannam@167: tmpdepfile3=$dir.libs/$base.u cannam@167: "$@" -Wc,-M cannam@167: else cannam@167: tmpdepfile1=$dir$base.u cannam@167: tmpdepfile2=$dir$base.u cannam@167: tmpdepfile3=$dir$base.u cannam@167: "$@" -M cannam@167: fi cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" cannam@167: exit $stat cannam@167: fi cannam@167: cannam@167: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" cannam@167: do cannam@167: test -f "$tmpdepfile" && break cannam@167: done cannam@167: aix_post_process_depfile cannam@167: ;; cannam@167: cannam@167: tcc) cannam@167: # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 cannam@167: # FIXME: That version still under development at the moment of writing. cannam@167: # Make that this statement remains true also for stable, released cannam@167: # versions. cannam@167: # It will wrap lines (doesn't matter whether long or short) with a cannam@167: # trailing '\', as in: cannam@167: # cannam@167: # foo.o : \ cannam@167: # foo.c \ cannam@167: # foo.h \ cannam@167: # cannam@167: # It will put a trailing '\' even on the last line, and will use leading cannam@167: # spaces rather than leading tabs (at least since its commit 0394caf7 cannam@167: # "Emit spaces for -MD"). cannam@167: "$@" -MD -MF "$tmpdepfile" cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: rm -f "$depfile" cannam@167: # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. cannam@167: # We have to change lines of the first kind to '$object: \'. cannam@167: sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" cannam@167: # And for each line of the second kind, we have to emit a 'dep.h:' cannam@167: # dummy dependency, to avoid the deleted-header problem. cannam@167: sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: ## The order of this option in the case statement is important, since the cannam@167: ## shell code in configure will try each of these formats in the order cannam@167: ## listed in this file. A plain '-MD' option would be understood by many cannam@167: ## compilers, so we must ensure this comes after the gcc and icc options. cannam@167: pgcc) cannam@167: # Portland's C compiler understands '-MD'. cannam@167: # Will always output deps to 'file.d' where file is the root name of the cannam@167: # source file under compilation, even if file resides in a subdirectory. cannam@167: # The object file name does not affect the name of the '.d' file. cannam@167: # pgcc 10.2 will output cannam@167: # foo.o: sub/foo.c sub/foo.h cannam@167: # and will wrap long lines using '\' : cannam@167: # foo.o: sub/foo.c ... \ cannam@167: # sub/foo.h ... \ cannam@167: # ... cannam@167: set_dir_from "$object" cannam@167: # Use the source, not the object, to determine the base name, since cannam@167: # that's sadly what pgcc will do too. cannam@167: set_base_from "$source" cannam@167: tmpdepfile=$base.d cannam@167: cannam@167: # For projects that build the same source file twice into different object cannam@167: # files, the pgcc approach of using the *source* file root name can cause cannam@167: # problems in parallel builds. Use a locking strategy to avoid stomping on cannam@167: # the same $tmpdepfile. cannam@167: lockdir=$base.d-lock cannam@167: trap " cannam@167: echo '$0: caught signal, cleaning up...' >&2 cannam@167: rmdir '$lockdir' cannam@167: exit 1 cannam@167: " 1 2 13 15 cannam@167: numtries=100 cannam@167: i=$numtries cannam@167: while test $i -gt 0; do cannam@167: # mkdir is a portable test-and-set. cannam@167: if mkdir "$lockdir" 2>/dev/null; then cannam@167: # This process acquired the lock. cannam@167: "$@" -MD cannam@167: stat=$? cannam@167: # Release the lock. cannam@167: rmdir "$lockdir" cannam@167: break cannam@167: else cannam@167: # If the lock is being held by a different process, wait cannam@167: # until the winning process is done or we timeout. cannam@167: while test -d "$lockdir" && test $i -gt 0; do cannam@167: sleep 1 cannam@167: i=`expr $i - 1` cannam@167: done cannam@167: fi cannam@167: i=`expr $i - 1` cannam@167: done cannam@167: trap - 1 2 13 15 cannam@167: if test $i -le 0; then cannam@167: echo "$0: failed to acquire lock after $numtries attempts" >&2 cannam@167: echo "$0: check lockdir '$lockdir'" >&2 cannam@167: exit 1 cannam@167: fi cannam@167: cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: rm -f "$depfile" cannam@167: # Each line is of the form `foo.o: dependent.h', cannam@167: # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. cannam@167: # Do two passes, one to just change these to cannam@167: # `$object: dependent.h' and one to simply `dependent.h:'. cannam@167: sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" cannam@167: # Some versions of the HPUX 10.20 sed can't process this invocation cannam@167: # correctly. Breaking it into two sed invocations is a workaround. cannam@167: sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ cannam@167: | sed -e 's/$/ :/' >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: hp2) cannam@167: # The "hp" stanza above does not work with aCC (C++) and HP's ia64 cannam@167: # compilers, which have integrated preprocessors. The correct option cannam@167: # to use with these is +Maked; it writes dependencies to a file named cannam@167: # 'foo.d', which lands next to the object file, wherever that cannam@167: # happens to be. cannam@167: # Much of this is similar to the tru64 case; see comments there. cannam@167: set_dir_from "$object" cannam@167: set_base_from "$object" cannam@167: if test "$libtool" = yes; then cannam@167: tmpdepfile1=$dir$base.d cannam@167: tmpdepfile2=$dir.libs/$base.d cannam@167: "$@" -Wc,+Maked cannam@167: else cannam@167: tmpdepfile1=$dir$base.d cannam@167: tmpdepfile2=$dir$base.d cannam@167: "$@" +Maked cannam@167: fi cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile1" "$tmpdepfile2" cannam@167: exit $stat cannam@167: fi cannam@167: cannam@167: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" cannam@167: do cannam@167: test -f "$tmpdepfile" && break cannam@167: done cannam@167: if test -f "$tmpdepfile"; then cannam@167: sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" cannam@167: # Add 'dependent.h:' lines. cannam@167: sed -ne '2,${ cannam@167: s/^ *// cannam@167: s/ \\*$// cannam@167: s/$/:/ cannam@167: p cannam@167: }' "$tmpdepfile" >> "$depfile" cannam@167: else cannam@167: make_dummy_depfile cannam@167: fi cannam@167: rm -f "$tmpdepfile" "$tmpdepfile2" cannam@167: ;; cannam@167: cannam@167: tru64) cannam@167: # The Tru64 compiler uses -MD to generate dependencies as a side cannam@167: # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. cannam@167: # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put cannam@167: # dependencies in 'foo.d' instead, so we check for that too. cannam@167: # Subdirectories are respected. cannam@167: set_dir_from "$object" cannam@167: set_base_from "$object" cannam@167: cannam@167: if test "$libtool" = yes; then cannam@167: # Libtool generates 2 separate objects for the 2 libraries. These cannam@167: # two compilations output dependencies in $dir.libs/$base.o.d and cannam@167: # in $dir$base.o.d. We have to check for both files, because cannam@167: # one of the two compilations can be disabled. We should prefer cannam@167: # $dir$base.o.d over $dir.libs/$base.o.d because the latter is cannam@167: # automatically cleaned when .libs/ is deleted, while ignoring cannam@167: # the former would cause a distcleancheck panic. cannam@167: tmpdepfile1=$dir$base.o.d # libtool 1.5 cannam@167: tmpdepfile2=$dir.libs/$base.o.d # Likewise. cannam@167: tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 cannam@167: "$@" -Wc,-MD cannam@167: else cannam@167: tmpdepfile1=$dir$base.d cannam@167: tmpdepfile2=$dir$base.d cannam@167: tmpdepfile3=$dir$base.d cannam@167: "$@" -MD cannam@167: fi cannam@167: cannam@167: stat=$? cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" cannam@167: exit $stat cannam@167: fi cannam@167: cannam@167: for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" cannam@167: do cannam@167: test -f "$tmpdepfile" && break cannam@167: done cannam@167: # Same post-processing that is required for AIX mode. cannam@167: aix_post_process_depfile cannam@167: ;; cannam@167: cannam@167: msvc7) cannam@167: if test "$libtool" = yes; then cannam@167: showIncludes=-Wc,-showIncludes cannam@167: else cannam@167: showIncludes=-showIncludes cannam@167: fi cannam@167: "$@" $showIncludes > "$tmpdepfile" cannam@167: stat=$? cannam@167: grep -v '^Note: including file: ' "$tmpdepfile" cannam@167: if test $stat -ne 0; then cannam@167: rm -f "$tmpdepfile" cannam@167: exit $stat cannam@167: fi cannam@167: rm -f "$depfile" cannam@167: echo "$object : \\" > "$depfile" cannam@167: # The first sed program below extracts the file names and escapes cannam@167: # backslashes for cygpath. The second sed program outputs the file cannam@167: # name when reading, but also accumulates all include files in the cannam@167: # hold buffer in order to output them again at the end. This only cannam@167: # works with sed implementations that can handle large buffers. cannam@167: sed < "$tmpdepfile" -n ' cannam@167: /^Note: including file: *\(.*\)/ { cannam@167: s//\1/ cannam@167: s/\\/\\\\/g cannam@167: p cannam@167: }' | $cygpath_u | sort -u | sed -n ' cannam@167: s/ /\\ /g cannam@167: s/\(.*\)/'"$tab"'\1 \\/p cannam@167: s/.\(.*\) \\/\1:/ cannam@167: H cannam@167: $ { cannam@167: s/.*/'"$tab"'/ cannam@167: G cannam@167: p cannam@167: }' >> "$depfile" cannam@167: echo >> "$depfile" # make sure the fragment doesn't end with a backslash cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: msvc7msys) cannam@167: # This case exists only to let depend.m4 do its work. It works by cannam@167: # looking at the text of this script. This case will never be run, cannam@167: # since it is checked for above. cannam@167: exit 1 cannam@167: ;; cannam@167: cannam@167: #nosideeffect) cannam@167: # This comment above is used by automake to tell side-effect cannam@167: # dependency tracking mechanisms from slower ones. cannam@167: cannam@167: dashmstdout) cannam@167: # Important note: in order to support this mode, a compiler *must* cannam@167: # always write the preprocessed file to stdout, regardless of -o. cannam@167: "$@" || exit $? cannam@167: cannam@167: # Remove the call to Libtool. cannam@167: if test "$libtool" = yes; then cannam@167: while test "X$1" != 'X--mode=compile'; do cannam@167: shift cannam@167: done cannam@167: shift cannam@167: fi cannam@167: cannam@167: # Remove '-o $object'. cannam@167: IFS=" " cannam@167: for arg cannam@167: do cannam@167: case $arg in cannam@167: -o) cannam@167: shift cannam@167: ;; cannam@167: $object) cannam@167: shift cannam@167: ;; cannam@167: *) cannam@167: set fnord "$@" "$arg" cannam@167: shift # fnord cannam@167: shift # $arg cannam@167: ;; cannam@167: esac cannam@167: done cannam@167: cannam@167: test -z "$dashmflag" && dashmflag=-M cannam@167: # Require at least two characters before searching for ':' cannam@167: # in the target name. This is to cope with DOS-style filenames: cannam@167: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. cannam@167: "$@" $dashmflag | cannam@167: sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" cannam@167: rm -f "$depfile" cannam@167: cat < "$tmpdepfile" > "$depfile" cannam@167: # Some versions of the HPUX 10.20 sed can't process this sed invocation cannam@167: # correctly. Breaking it into two sed invocations is a workaround. cannam@167: tr ' ' "$nl" < "$tmpdepfile" \ cannam@167: | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ cannam@167: | sed -e 's/$/ :/' >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: dashXmstdout) cannam@167: # This case only exists to satisfy depend.m4. It is never actually cannam@167: # run, as this mode is specially recognized in the preamble. cannam@167: exit 1 cannam@167: ;; cannam@167: cannam@167: makedepend) cannam@167: "$@" || exit $? cannam@167: # Remove any Libtool call cannam@167: if test "$libtool" = yes; then cannam@167: while test "X$1" != 'X--mode=compile'; do cannam@167: shift cannam@167: done cannam@167: shift cannam@167: fi cannam@167: # X makedepend cannam@167: shift cannam@167: cleared=no eat=no cannam@167: for arg cannam@167: do cannam@167: case $cleared in cannam@167: no) cannam@167: set ""; shift cannam@167: cleared=yes ;; cannam@167: esac cannam@167: if test $eat = yes; then cannam@167: eat=no cannam@167: continue cannam@167: fi cannam@167: case "$arg" in cannam@167: -D*|-I*) cannam@167: set fnord "$@" "$arg"; shift ;; cannam@167: # Strip any option that makedepend may not understand. Remove cannam@167: # the object too, otherwise makedepend will parse it as a source file. cannam@167: -arch) cannam@167: eat=yes ;; cannam@167: -*|$object) cannam@167: ;; cannam@167: *) cannam@167: set fnord "$@" "$arg"; shift ;; cannam@167: esac cannam@167: done cannam@167: obj_suffix=`echo "$object" | sed 's/^.*\././'` cannam@167: touch "$tmpdepfile" cannam@167: ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" cannam@167: rm -f "$depfile" cannam@167: # makedepend may prepend the VPATH from the source file name to the object. cannam@167: # No need to regex-escape $object, excess matching of '.' is harmless. cannam@167: sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" cannam@167: # Some versions of the HPUX 10.20 sed can't process the last invocation cannam@167: # correctly. Breaking it into two sed invocations is a workaround. cannam@167: sed '1,2d' "$tmpdepfile" \ cannam@167: | tr ' ' "$nl" \ cannam@167: | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ cannam@167: | sed -e 's/$/ :/' >> "$depfile" cannam@167: rm -f "$tmpdepfile" "$tmpdepfile".bak cannam@167: ;; cannam@167: cannam@167: cpp) cannam@167: # Important note: in order to support this mode, a compiler *must* cannam@167: # always write the preprocessed file to stdout. cannam@167: "$@" || exit $? cannam@167: cannam@167: # Remove the call to Libtool. cannam@167: if test "$libtool" = yes; then cannam@167: while test "X$1" != 'X--mode=compile'; do cannam@167: shift cannam@167: done cannam@167: shift cannam@167: fi cannam@167: cannam@167: # Remove '-o $object'. cannam@167: IFS=" " cannam@167: for arg cannam@167: do cannam@167: case $arg in cannam@167: -o) cannam@167: shift cannam@167: ;; cannam@167: $object) cannam@167: shift cannam@167: ;; cannam@167: *) cannam@167: set fnord "$@" "$arg" cannam@167: shift # fnord cannam@167: shift # $arg cannam@167: ;; cannam@167: esac cannam@167: done cannam@167: cannam@167: "$@" -E \ cannam@167: | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ cannam@167: -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ cannam@167: | sed '$ s: \\$::' > "$tmpdepfile" cannam@167: rm -f "$depfile" cannam@167: echo "$object : \\" > "$depfile" cannam@167: cat < "$tmpdepfile" >> "$depfile" cannam@167: sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: msvisualcpp) cannam@167: # Important note: in order to support this mode, a compiler *must* cannam@167: # always write the preprocessed file to stdout. cannam@167: "$@" || exit $? cannam@167: cannam@167: # Remove the call to Libtool. cannam@167: if test "$libtool" = yes; then cannam@167: while test "X$1" != 'X--mode=compile'; do cannam@167: shift cannam@167: done cannam@167: shift cannam@167: fi cannam@167: cannam@167: IFS=" " cannam@167: for arg cannam@167: do cannam@167: case "$arg" in cannam@167: -o) cannam@167: shift cannam@167: ;; cannam@167: $object) cannam@167: shift cannam@167: ;; cannam@167: "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") cannam@167: set fnord "$@" cannam@167: shift cannam@167: shift cannam@167: ;; cannam@167: *) cannam@167: set fnord "$@" "$arg" cannam@167: shift cannam@167: shift cannam@167: ;; cannam@167: esac cannam@167: done cannam@167: "$@" -E 2>/dev/null | cannam@167: sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" cannam@167: rm -f "$depfile" cannam@167: echo "$object : \\" > "$depfile" cannam@167: sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" cannam@167: echo "$tab" >> "$depfile" cannam@167: sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" cannam@167: rm -f "$tmpdepfile" cannam@167: ;; cannam@167: cannam@167: msvcmsys) cannam@167: # This case exists only to let depend.m4 do its work. It works by cannam@167: # looking at the text of this script. This case will never be run, cannam@167: # since it is checked for above. cannam@167: exit 1 cannam@167: ;; cannam@167: cannam@167: none) cannam@167: exec "$@" cannam@167: ;; cannam@167: cannam@167: *) cannam@167: echo "Unknown depmode $depmode" 1>&2 cannam@167: exit 1 cannam@167: ;; cannam@167: esac cannam@167: cannam@167: exit 0 cannam@167: cannam@167: # Local Variables: cannam@167: # mode: shell-script cannam@167: # sh-indentation: 2 cannam@167: # eval: (add-hook 'write-file-hooks 'time-stamp) cannam@167: # time-stamp-start: "scriptversion=" cannam@167: # time-stamp-format: "%:y-%02m-%02d.%02H" cannam@167: # time-stamp-time-zone: "UTC" cannam@167: # time-stamp-end: "; # UTC" cannam@167: # End: