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