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