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