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