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