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