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