depcomp revision d9c7fc6c
1d9c7fc6cSmrg#! /bin/sh 2d9c7fc6cSmrg# depcomp - compile a program generating dependencies as side-effects 3d9c7fc6cSmrg 4d9c7fc6cSmrgscriptversion=2005-07-09.11 5d9c7fc6cSmrg 6d9c7fc6cSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7d9c7fc6cSmrg 8d9c7fc6cSmrg# This program is free software; you can redistribute it and/or modify 9d9c7fc6cSmrg# it under the terms of the GNU General Public License as published by 10d9c7fc6cSmrg# the Free Software Foundation; either version 2, or (at your option) 11d9c7fc6cSmrg# any later version. 12d9c7fc6cSmrg 13d9c7fc6cSmrg# This program is distributed in the hope that it will be useful, 14d9c7fc6cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15d9c7fc6cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16d9c7fc6cSmrg# GNU General Public License for more details. 17d9c7fc6cSmrg 18d9c7fc6cSmrg# You should have received a copy of the GNU General Public License 19d9c7fc6cSmrg# along with this program; if not, write to the Free Software 20d9c7fc6cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21d9c7fc6cSmrg# 02110-1301, USA. 22d9c7fc6cSmrg 23d9c7fc6cSmrg# As a special exception to the GNU General Public License, if you 24d9c7fc6cSmrg# distribute this file as part of a program that contains a 25d9c7fc6cSmrg# configuration script generated by Autoconf, you may include it under 26d9c7fc6cSmrg# the same distribution terms that you use for the rest of that program. 27d9c7fc6cSmrg 28d9c7fc6cSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29d9c7fc6cSmrg 30d9c7fc6cSmrgcase $1 in 31d9c7fc6cSmrg '') 32d9c7fc6cSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33d9c7fc6cSmrg exit 1; 34d9c7fc6cSmrg ;; 35d9c7fc6cSmrg -h | --h*) 36d9c7fc6cSmrg cat <<\EOF 37d9c7fc6cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38d9c7fc6cSmrg 39d9c7fc6cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 40d9c7fc6cSmrgas side-effects. 41d9c7fc6cSmrg 42d9c7fc6cSmrgEnvironment variables: 43d9c7fc6cSmrg depmode Dependency tracking mode. 44d9c7fc6cSmrg source Source file read by `PROGRAMS ARGS'. 45d9c7fc6cSmrg object Object file output by `PROGRAMS ARGS'. 46d9c7fc6cSmrg DEPDIR directory where to store dependencies. 47d9c7fc6cSmrg depfile Dependency file to output. 48d9c7fc6cSmrg tmpdepfile Temporary file to use when outputing dependencies. 49d9c7fc6cSmrg libtool Whether libtool is used (yes/no). 50d9c7fc6cSmrg 51d9c7fc6cSmrgReport bugs to <bug-automake@gnu.org>. 52d9c7fc6cSmrgEOF 53d9c7fc6cSmrg exit $? 54d9c7fc6cSmrg ;; 55d9c7fc6cSmrg -v | --v*) 56d9c7fc6cSmrg echo "depcomp $scriptversion" 57d9c7fc6cSmrg exit $? 58d9c7fc6cSmrg ;; 59d9c7fc6cSmrgesac 60d9c7fc6cSmrg 61d9c7fc6cSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62d9c7fc6cSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 63d9c7fc6cSmrg exit 1 64d9c7fc6cSmrgfi 65d9c7fc6cSmrg 66d9c7fc6cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67d9c7fc6cSmrgdepfile=${depfile-`echo "$object" | 68d9c7fc6cSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69d9c7fc6cSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70d9c7fc6cSmrg 71d9c7fc6cSmrgrm -f "$tmpdepfile" 72d9c7fc6cSmrg 73d9c7fc6cSmrg# Some modes work just like other modes, but use different flags. We 74d9c7fc6cSmrg# parameterize here, but still list the modes in the big case below, 75d9c7fc6cSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 76d9c7fc6cSmrg# here, because this file can only contain one case statement. 77d9c7fc6cSmrgif test "$depmode" = hp; then 78d9c7fc6cSmrg # HP compiler uses -M and no extra arg. 79d9c7fc6cSmrg gccflag=-M 80d9c7fc6cSmrg depmode=gcc 81d9c7fc6cSmrgfi 82d9c7fc6cSmrg 83d9c7fc6cSmrgif test "$depmode" = dashXmstdout; then 84d9c7fc6cSmrg # This is just like dashmstdout with a different argument. 85d9c7fc6cSmrg dashmflag=-xM 86d9c7fc6cSmrg depmode=dashmstdout 87d9c7fc6cSmrgfi 88d9c7fc6cSmrg 89d9c7fc6cSmrgcase "$depmode" in 90d9c7fc6cSmrggcc3) 91d9c7fc6cSmrg## gcc 3 implements dependency tracking that does exactly what 92d9c7fc6cSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93d9c7fc6cSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 94d9c7fc6cSmrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95d9c7fc6cSmrg stat=$? 96d9c7fc6cSmrg if test $stat -eq 0; then : 97d9c7fc6cSmrg else 98d9c7fc6cSmrg rm -f "$tmpdepfile" 99d9c7fc6cSmrg exit $stat 100d9c7fc6cSmrg fi 101d9c7fc6cSmrg mv "$tmpdepfile" "$depfile" 102d9c7fc6cSmrg ;; 103d9c7fc6cSmrg 104d9c7fc6cSmrggcc) 105d9c7fc6cSmrg## There are various ways to get dependency output from gcc. Here's 106d9c7fc6cSmrg## why we pick this rather obscure method: 107d9c7fc6cSmrg## - Don't want to use -MD because we'd like the dependencies to end 108d9c7fc6cSmrg## up in a subdir. Having to rename by hand is ugly. 109d9c7fc6cSmrg## (We might end up doing this anyway to support other compilers.) 110d9c7fc6cSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111d9c7fc6cSmrg## -MM, not -M (despite what the docs say). 112d9c7fc6cSmrg## - Using -M directly means running the compiler twice (even worse 113d9c7fc6cSmrg## than renaming). 114d9c7fc6cSmrg if test -z "$gccflag"; then 115d9c7fc6cSmrg gccflag=-MD, 116d9c7fc6cSmrg fi 117d9c7fc6cSmrg "$@" -Wp,"$gccflag$tmpdepfile" 118d9c7fc6cSmrg stat=$? 119d9c7fc6cSmrg if test $stat -eq 0; then : 120d9c7fc6cSmrg else 121d9c7fc6cSmrg rm -f "$tmpdepfile" 122d9c7fc6cSmrg exit $stat 123d9c7fc6cSmrg fi 124d9c7fc6cSmrg rm -f "$depfile" 125d9c7fc6cSmrg echo "$object : \\" > "$depfile" 126d9c7fc6cSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127d9c7fc6cSmrg## The second -e expression handles DOS-style file names with drive letters. 128d9c7fc6cSmrg sed -e 's/^[^:]*: / /' \ 129d9c7fc6cSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130d9c7fc6cSmrg## This next piece of magic avoids the `deleted header file' problem. 131d9c7fc6cSmrg## The problem is that when a header file which appears in a .P file 132d9c7fc6cSmrg## is deleted, the dependency causes make to die (because there is 133d9c7fc6cSmrg## typically no way to rebuild the header). We avoid this by adding 134d9c7fc6cSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 135d9c7fc6cSmrg## this for us directly. 136d9c7fc6cSmrg tr ' ' ' 137d9c7fc6cSmrg' < "$tmpdepfile" | 138d9c7fc6cSmrg## Some versions of gcc put a space before the `:'. On the theory 139d9c7fc6cSmrg## that the space means something, we add a space to the output as 140d9c7fc6cSmrg## well. 141d9c7fc6cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 142d9c7fc6cSmrg## correctly. Breaking it into two sed invocations is a workaround. 143d9c7fc6cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144d9c7fc6cSmrg rm -f "$tmpdepfile" 145d9c7fc6cSmrg ;; 146d9c7fc6cSmrg 147d9c7fc6cSmrghp) 148d9c7fc6cSmrg # This case exists only to let depend.m4 do its work. It works by 149d9c7fc6cSmrg # looking at the text of this script. This case will never be run, 150d9c7fc6cSmrg # since it is checked for above. 151d9c7fc6cSmrg exit 1 152d9c7fc6cSmrg ;; 153d9c7fc6cSmrg 154d9c7fc6cSmrgsgi) 155d9c7fc6cSmrg if test "$libtool" = yes; then 156d9c7fc6cSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 157d9c7fc6cSmrg else 158d9c7fc6cSmrg "$@" -MDupdate "$tmpdepfile" 159d9c7fc6cSmrg fi 160d9c7fc6cSmrg stat=$? 161d9c7fc6cSmrg if test $stat -eq 0; then : 162d9c7fc6cSmrg else 163d9c7fc6cSmrg rm -f "$tmpdepfile" 164d9c7fc6cSmrg exit $stat 165d9c7fc6cSmrg fi 166d9c7fc6cSmrg rm -f "$depfile" 167d9c7fc6cSmrg 168d9c7fc6cSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169d9c7fc6cSmrg echo "$object : \\" > "$depfile" 170d9c7fc6cSmrg 171d9c7fc6cSmrg # Clip off the initial element (the dependent). Don't try to be 172d9c7fc6cSmrg # clever and replace this with sed code, as IRIX sed won't handle 173d9c7fc6cSmrg # lines with more than a fixed number of characters (4096 in 174d9c7fc6cSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175d9c7fc6cSmrg # the IRIX cc adds comments like `#:fec' to the end of the 176d9c7fc6cSmrg # dependency line. 177d9c7fc6cSmrg tr ' ' ' 178d9c7fc6cSmrg' < "$tmpdepfile" \ 179d9c7fc6cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180d9c7fc6cSmrg tr ' 181d9c7fc6cSmrg' ' ' >> $depfile 182d9c7fc6cSmrg echo >> $depfile 183d9c7fc6cSmrg 184d9c7fc6cSmrg # The second pass generates a dummy entry for each header file. 185d9c7fc6cSmrg tr ' ' ' 186d9c7fc6cSmrg' < "$tmpdepfile" \ 187d9c7fc6cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188d9c7fc6cSmrg >> $depfile 189d9c7fc6cSmrg else 190d9c7fc6cSmrg # The sourcefile does not contain any dependencies, so just 191d9c7fc6cSmrg # store a dummy comment line, to avoid errors with the Makefile 192d9c7fc6cSmrg # "include basename.Plo" scheme. 193d9c7fc6cSmrg echo "#dummy" > "$depfile" 194d9c7fc6cSmrg fi 195d9c7fc6cSmrg rm -f "$tmpdepfile" 196d9c7fc6cSmrg ;; 197d9c7fc6cSmrg 198d9c7fc6cSmrgaix) 199d9c7fc6cSmrg # The C for AIX Compiler uses -M and outputs the dependencies 200d9c7fc6cSmrg # in a .u file. In older versions, this file always lives in the 201d9c7fc6cSmrg # current directory. Also, the AIX compiler puts `$object:' at the 202d9c7fc6cSmrg # start of each line; $object doesn't have directory information. 203d9c7fc6cSmrg # Version 6 uses the directory in both cases. 204d9c7fc6cSmrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205d9c7fc6cSmrg tmpdepfile="$stripped.u" 206d9c7fc6cSmrg if test "$libtool" = yes; then 207d9c7fc6cSmrg "$@" -Wc,-M 208d9c7fc6cSmrg else 209d9c7fc6cSmrg "$@" -M 210d9c7fc6cSmrg fi 211d9c7fc6cSmrg stat=$? 212d9c7fc6cSmrg 213d9c7fc6cSmrg if test -f "$tmpdepfile"; then : 214d9c7fc6cSmrg else 215d9c7fc6cSmrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 216d9c7fc6cSmrg tmpdepfile="$stripped.u" 217d9c7fc6cSmrg fi 218d9c7fc6cSmrg 219d9c7fc6cSmrg if test $stat -eq 0; then : 220d9c7fc6cSmrg else 221d9c7fc6cSmrg rm -f "$tmpdepfile" 222d9c7fc6cSmrg exit $stat 223d9c7fc6cSmrg fi 224d9c7fc6cSmrg 225d9c7fc6cSmrg if test -f "$tmpdepfile"; then 226d9c7fc6cSmrg outname="$stripped.o" 227d9c7fc6cSmrg # Each line is of the form `foo.o: dependent.h'. 228d9c7fc6cSmrg # Do two passes, one to just change these to 229d9c7fc6cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 230d9c7fc6cSmrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231d9c7fc6cSmrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232d9c7fc6cSmrg else 233d9c7fc6cSmrg # The sourcefile does not contain any dependencies, so just 234d9c7fc6cSmrg # store a dummy comment line, to avoid errors with the Makefile 235d9c7fc6cSmrg # "include basename.Plo" scheme. 236d9c7fc6cSmrg echo "#dummy" > "$depfile" 237d9c7fc6cSmrg fi 238d9c7fc6cSmrg rm -f "$tmpdepfile" 239d9c7fc6cSmrg ;; 240d9c7fc6cSmrg 241d9c7fc6cSmrgicc) 242d9c7fc6cSmrg # Intel's C compiler understands `-MD -MF file'. However on 243d9c7fc6cSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244d9c7fc6cSmrg # ICC 7.0 will fill foo.d with something like 245d9c7fc6cSmrg # foo.o: sub/foo.c 246d9c7fc6cSmrg # foo.o: sub/foo.h 247d9c7fc6cSmrg # which is wrong. We want: 248d9c7fc6cSmrg # sub/foo.o: sub/foo.c 249d9c7fc6cSmrg # sub/foo.o: sub/foo.h 250d9c7fc6cSmrg # sub/foo.c: 251d9c7fc6cSmrg # sub/foo.h: 252d9c7fc6cSmrg # ICC 7.1 will output 253d9c7fc6cSmrg # foo.o: sub/foo.c sub/foo.h 254d9c7fc6cSmrg # and will wrap long lines using \ : 255d9c7fc6cSmrg # foo.o: sub/foo.c ... \ 256d9c7fc6cSmrg # sub/foo.h ... \ 257d9c7fc6cSmrg # ... 258d9c7fc6cSmrg 259d9c7fc6cSmrg "$@" -MD -MF "$tmpdepfile" 260d9c7fc6cSmrg stat=$? 261d9c7fc6cSmrg if test $stat -eq 0; then : 262d9c7fc6cSmrg else 263d9c7fc6cSmrg rm -f "$tmpdepfile" 264d9c7fc6cSmrg exit $stat 265d9c7fc6cSmrg fi 266d9c7fc6cSmrg rm -f "$depfile" 267d9c7fc6cSmrg # Each line is of the form `foo.o: dependent.h', 268d9c7fc6cSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269d9c7fc6cSmrg # Do two passes, one to just change these to 270d9c7fc6cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 271d9c7fc6cSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272d9c7fc6cSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 273d9c7fc6cSmrg # correctly. Breaking it into two sed invocations is a workaround. 274d9c7fc6cSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275d9c7fc6cSmrg sed -e 's/$/ :/' >> "$depfile" 276d9c7fc6cSmrg rm -f "$tmpdepfile" 277d9c7fc6cSmrg ;; 278d9c7fc6cSmrg 279d9c7fc6cSmrgtru64) 280d9c7fc6cSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 281d9c7fc6cSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282d9c7fc6cSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283d9c7fc6cSmrg # dependencies in `foo.d' instead, so we check for that too. 284d9c7fc6cSmrg # Subdirectories are respected. 285d9c7fc6cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286d9c7fc6cSmrg test "x$dir" = "x$object" && dir= 287d9c7fc6cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288d9c7fc6cSmrg 289d9c7fc6cSmrg if test "$libtool" = yes; then 290d9c7fc6cSmrg # With Tru64 cc, shared objects can also be used to make a 291d9c7fc6cSmrg # static library. This mecanism is used in libtool 1.4 series to 292d9c7fc6cSmrg # handle both shared and static libraries in a single compilation. 293d9c7fc6cSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294d9c7fc6cSmrg # 295d9c7fc6cSmrg # With libtool 1.5 this exception was removed, and libtool now 296d9c7fc6cSmrg # generates 2 separate objects for the 2 libraries. These two 297d9c7fc6cSmrg # compilations output dependencies in in $dir.libs/$base.o.d and 298d9c7fc6cSmrg # in $dir$base.o.d. We have to check for both files, because 299d9c7fc6cSmrg # one of the two compilations can be disabled. We should prefer 300d9c7fc6cSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301d9c7fc6cSmrg # automatically cleaned when .libs/ is deleted, while ignoring 302d9c7fc6cSmrg # the former would cause a distcleancheck panic. 303d9c7fc6cSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304d9c7fc6cSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 305d9c7fc6cSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306d9c7fc6cSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307d9c7fc6cSmrg "$@" -Wc,-MD 308d9c7fc6cSmrg else 309d9c7fc6cSmrg tmpdepfile1=$dir$base.o.d 310d9c7fc6cSmrg tmpdepfile2=$dir$base.d 311d9c7fc6cSmrg tmpdepfile3=$dir$base.d 312d9c7fc6cSmrg tmpdepfile4=$dir$base.d 313d9c7fc6cSmrg "$@" -MD 314d9c7fc6cSmrg fi 315d9c7fc6cSmrg 316d9c7fc6cSmrg stat=$? 317d9c7fc6cSmrg if test $stat -eq 0; then : 318d9c7fc6cSmrg else 319d9c7fc6cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320d9c7fc6cSmrg exit $stat 321d9c7fc6cSmrg fi 322d9c7fc6cSmrg 323d9c7fc6cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324d9c7fc6cSmrg do 325d9c7fc6cSmrg test -f "$tmpdepfile" && break 326d9c7fc6cSmrg done 327d9c7fc6cSmrg if test -f "$tmpdepfile"; then 328d9c7fc6cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329d9c7fc6cSmrg # That's a tab and a space in the []. 330d9c7fc6cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331d9c7fc6cSmrg else 332d9c7fc6cSmrg echo "#dummy" > "$depfile" 333d9c7fc6cSmrg fi 334d9c7fc6cSmrg rm -f "$tmpdepfile" 335d9c7fc6cSmrg ;; 336d9c7fc6cSmrg 337d9c7fc6cSmrg#nosideeffect) 338d9c7fc6cSmrg # This comment above is used by automake to tell side-effect 339d9c7fc6cSmrg # dependency tracking mechanisms from slower ones. 340d9c7fc6cSmrg 341d9c7fc6cSmrgdashmstdout) 342d9c7fc6cSmrg # Important note: in order to support this mode, a compiler *must* 343d9c7fc6cSmrg # always write the preprocessed file to stdout, regardless of -o. 344d9c7fc6cSmrg "$@" || exit $? 345d9c7fc6cSmrg 346d9c7fc6cSmrg # Remove the call to Libtool. 347d9c7fc6cSmrg if test "$libtool" = yes; then 348d9c7fc6cSmrg while test $1 != '--mode=compile'; do 349d9c7fc6cSmrg shift 350d9c7fc6cSmrg done 351d9c7fc6cSmrg shift 352d9c7fc6cSmrg fi 353d9c7fc6cSmrg 354d9c7fc6cSmrg # Remove `-o $object'. 355d9c7fc6cSmrg IFS=" " 356d9c7fc6cSmrg for arg 357d9c7fc6cSmrg do 358d9c7fc6cSmrg case $arg in 359d9c7fc6cSmrg -o) 360d9c7fc6cSmrg shift 361d9c7fc6cSmrg ;; 362d9c7fc6cSmrg $object) 363d9c7fc6cSmrg shift 364d9c7fc6cSmrg ;; 365d9c7fc6cSmrg *) 366d9c7fc6cSmrg set fnord "$@" "$arg" 367d9c7fc6cSmrg shift # fnord 368d9c7fc6cSmrg shift # $arg 369d9c7fc6cSmrg ;; 370d9c7fc6cSmrg esac 371d9c7fc6cSmrg done 372d9c7fc6cSmrg 373d9c7fc6cSmrg test -z "$dashmflag" && dashmflag=-M 374d9c7fc6cSmrg # Require at least two characters before searching for `:' 375d9c7fc6cSmrg # in the target name. This is to cope with DOS-style filenames: 376d9c7fc6cSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377d9c7fc6cSmrg "$@" $dashmflag | 378d9c7fc6cSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379d9c7fc6cSmrg rm -f "$depfile" 380d9c7fc6cSmrg cat < "$tmpdepfile" > "$depfile" 381d9c7fc6cSmrg tr ' ' ' 382d9c7fc6cSmrg' < "$tmpdepfile" | \ 383d9c7fc6cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 384d9c7fc6cSmrg## correctly. Breaking it into two sed invocations is a workaround. 385d9c7fc6cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386d9c7fc6cSmrg rm -f "$tmpdepfile" 387d9c7fc6cSmrg ;; 388d9c7fc6cSmrg 389d9c7fc6cSmrgdashXmstdout) 390d9c7fc6cSmrg # This case only exists to satisfy depend.m4. It is never actually 391d9c7fc6cSmrg # run, as this mode is specially recognized in the preamble. 392d9c7fc6cSmrg exit 1 393d9c7fc6cSmrg ;; 394d9c7fc6cSmrg 395d9c7fc6cSmrgmakedepend) 396d9c7fc6cSmrg "$@" || exit $? 397d9c7fc6cSmrg # Remove any Libtool call 398d9c7fc6cSmrg if test "$libtool" = yes; then 399d9c7fc6cSmrg while test $1 != '--mode=compile'; do 400d9c7fc6cSmrg shift 401d9c7fc6cSmrg done 402d9c7fc6cSmrg shift 403d9c7fc6cSmrg fi 404d9c7fc6cSmrg # X makedepend 405d9c7fc6cSmrg shift 406d9c7fc6cSmrg cleared=no 407d9c7fc6cSmrg for arg in "$@"; do 408d9c7fc6cSmrg case $cleared in 409d9c7fc6cSmrg no) 410d9c7fc6cSmrg set ""; shift 411d9c7fc6cSmrg cleared=yes ;; 412d9c7fc6cSmrg esac 413d9c7fc6cSmrg case "$arg" in 414d9c7fc6cSmrg -D*|-I*) 415d9c7fc6cSmrg set fnord "$@" "$arg"; shift ;; 416d9c7fc6cSmrg # Strip any option that makedepend may not understand. Remove 417d9c7fc6cSmrg # the object too, otherwise makedepend will parse it as a source file. 418d9c7fc6cSmrg -*|$object) 419d9c7fc6cSmrg ;; 420d9c7fc6cSmrg *) 421d9c7fc6cSmrg set fnord "$@" "$arg"; shift ;; 422d9c7fc6cSmrg esac 423d9c7fc6cSmrg done 424d9c7fc6cSmrg obj_suffix="`echo $object | sed 's/^.*\././'`" 425d9c7fc6cSmrg touch "$tmpdepfile" 426d9c7fc6cSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427d9c7fc6cSmrg rm -f "$depfile" 428d9c7fc6cSmrg cat < "$tmpdepfile" > "$depfile" 429d9c7fc6cSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 430d9c7fc6cSmrg' | \ 431d9c7fc6cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 432d9c7fc6cSmrg## correctly. Breaking it into two sed invocations is a workaround. 433d9c7fc6cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434d9c7fc6cSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 435d9c7fc6cSmrg ;; 436d9c7fc6cSmrg 437d9c7fc6cSmrgcpp) 438d9c7fc6cSmrg # Important note: in order to support this mode, a compiler *must* 439d9c7fc6cSmrg # always write the preprocessed file to stdout. 440d9c7fc6cSmrg "$@" || exit $? 441d9c7fc6cSmrg 442d9c7fc6cSmrg # Remove the call to Libtool. 443d9c7fc6cSmrg if test "$libtool" = yes; then 444d9c7fc6cSmrg while test $1 != '--mode=compile'; do 445d9c7fc6cSmrg shift 446d9c7fc6cSmrg done 447d9c7fc6cSmrg shift 448d9c7fc6cSmrg fi 449d9c7fc6cSmrg 450d9c7fc6cSmrg # Remove `-o $object'. 451d9c7fc6cSmrg IFS=" " 452d9c7fc6cSmrg for arg 453d9c7fc6cSmrg do 454d9c7fc6cSmrg case $arg in 455d9c7fc6cSmrg -o) 456d9c7fc6cSmrg shift 457d9c7fc6cSmrg ;; 458d9c7fc6cSmrg $object) 459d9c7fc6cSmrg shift 460d9c7fc6cSmrg ;; 461d9c7fc6cSmrg *) 462d9c7fc6cSmrg set fnord "$@" "$arg" 463d9c7fc6cSmrg shift # fnord 464d9c7fc6cSmrg shift # $arg 465d9c7fc6cSmrg ;; 466d9c7fc6cSmrg esac 467d9c7fc6cSmrg done 468d9c7fc6cSmrg 469d9c7fc6cSmrg "$@" -E | 470d9c7fc6cSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471d9c7fc6cSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472d9c7fc6cSmrg sed '$ s: \\$::' > "$tmpdepfile" 473d9c7fc6cSmrg rm -f "$depfile" 474d9c7fc6cSmrg echo "$object : \\" > "$depfile" 475d9c7fc6cSmrg cat < "$tmpdepfile" >> "$depfile" 476d9c7fc6cSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477d9c7fc6cSmrg rm -f "$tmpdepfile" 478d9c7fc6cSmrg ;; 479d9c7fc6cSmrg 480d9c7fc6cSmrgmsvisualcpp) 481d9c7fc6cSmrg # Important note: in order to support this mode, a compiler *must* 482d9c7fc6cSmrg # always write the preprocessed file to stdout, regardless of -o, 483d9c7fc6cSmrg # because we must use -o when running libtool. 484d9c7fc6cSmrg "$@" || exit $? 485d9c7fc6cSmrg IFS=" " 486d9c7fc6cSmrg for arg 487d9c7fc6cSmrg do 488d9c7fc6cSmrg case "$arg" in 489d9c7fc6cSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490d9c7fc6cSmrg set fnord "$@" 491d9c7fc6cSmrg shift 492d9c7fc6cSmrg shift 493d9c7fc6cSmrg ;; 494d9c7fc6cSmrg *) 495d9c7fc6cSmrg set fnord "$@" "$arg" 496d9c7fc6cSmrg shift 497d9c7fc6cSmrg shift 498d9c7fc6cSmrg ;; 499d9c7fc6cSmrg esac 500d9c7fc6cSmrg done 501d9c7fc6cSmrg "$@" -E | 502d9c7fc6cSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503d9c7fc6cSmrg rm -f "$depfile" 504d9c7fc6cSmrg echo "$object : \\" > "$depfile" 505d9c7fc6cSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506d9c7fc6cSmrg echo " " >> "$depfile" 507d9c7fc6cSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508d9c7fc6cSmrg rm -f "$tmpdepfile" 509d9c7fc6cSmrg ;; 510d9c7fc6cSmrg 511d9c7fc6cSmrgnone) 512d9c7fc6cSmrg exec "$@" 513d9c7fc6cSmrg ;; 514d9c7fc6cSmrg 515d9c7fc6cSmrg*) 516d9c7fc6cSmrg echo "Unknown depmode $depmode" 1>&2 517d9c7fc6cSmrg exit 1 518d9c7fc6cSmrg ;; 519d9c7fc6cSmrgesac 520d9c7fc6cSmrg 521d9c7fc6cSmrgexit 0 522d9c7fc6cSmrg 523d9c7fc6cSmrg# Local Variables: 524d9c7fc6cSmrg# mode: shell-script 525d9c7fc6cSmrg# sh-indentation: 2 526d9c7fc6cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 527d9c7fc6cSmrg# time-stamp-start: "scriptversion=" 528d9c7fc6cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 529d9c7fc6cSmrg# time-stamp-end: "$" 530d9c7fc6cSmrg# End: 531