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