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