depcomp revision 357bfbb2
1357bfbb2Smrg#! /bin/sh 2357bfbb2Smrg# depcomp - compile a program generating dependencies as side-effects 3357bfbb2Smrg 4357bfbb2Smrgscriptversion=2005-07-09.11 5357bfbb2Smrg 6357bfbb2Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7357bfbb2Smrg 8357bfbb2Smrg# This program is free software; you can redistribute it and/or modify 9357bfbb2Smrg# it under the terms of the GNU General Public License as published by 10357bfbb2Smrg# the Free Software Foundation; either version 2, or (at your option) 11357bfbb2Smrg# any later version. 12357bfbb2Smrg 13357bfbb2Smrg# This program is distributed in the hope that it will be useful, 14357bfbb2Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15357bfbb2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16357bfbb2Smrg# GNU General Public License for more details. 17357bfbb2Smrg 18357bfbb2Smrg# You should have received a copy of the GNU General Public License 19357bfbb2Smrg# along with this program; if not, write to the Free Software 20357bfbb2Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21357bfbb2Smrg# 02110-1301, USA. 22357bfbb2Smrg 23357bfbb2Smrg# As a special exception to the GNU General Public License, if you 24357bfbb2Smrg# distribute this file as part of a program that contains a 25357bfbb2Smrg# configuration script generated by Autoconf, you may include it under 26357bfbb2Smrg# the same distribution terms that you use for the rest of that program. 27357bfbb2Smrg 28357bfbb2Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29357bfbb2Smrg 30357bfbb2Smrgcase $1 in 31357bfbb2Smrg '') 32357bfbb2Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33357bfbb2Smrg exit 1; 34357bfbb2Smrg ;; 35357bfbb2Smrg -h | --h*) 36357bfbb2Smrg cat <<\EOF 37357bfbb2SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38357bfbb2Smrg 39357bfbb2SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 40357bfbb2Smrgas side-effects. 41357bfbb2Smrg 42357bfbb2SmrgEnvironment variables: 43357bfbb2Smrg depmode Dependency tracking mode. 44357bfbb2Smrg source Source file read by `PROGRAMS ARGS'. 45357bfbb2Smrg object Object file output by `PROGRAMS ARGS'. 46357bfbb2Smrg DEPDIR directory where to store dependencies. 47357bfbb2Smrg depfile Dependency file to output. 48357bfbb2Smrg tmpdepfile Temporary file to use when outputing dependencies. 49357bfbb2Smrg libtool Whether libtool is used (yes/no). 50357bfbb2Smrg 51357bfbb2SmrgReport bugs to <bug-automake@gnu.org>. 52357bfbb2SmrgEOF 53357bfbb2Smrg exit $? 54357bfbb2Smrg ;; 55357bfbb2Smrg -v | --v*) 56357bfbb2Smrg echo "depcomp $scriptversion" 57357bfbb2Smrg exit $? 58357bfbb2Smrg ;; 59357bfbb2Smrgesac 60357bfbb2Smrg 61357bfbb2Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62357bfbb2Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 63357bfbb2Smrg exit 1 64357bfbb2Smrgfi 65357bfbb2Smrg 66357bfbb2Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67357bfbb2Smrgdepfile=${depfile-`echo "$object" | 68357bfbb2Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69357bfbb2Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70357bfbb2Smrg 71357bfbb2Smrgrm -f "$tmpdepfile" 72357bfbb2Smrg 73357bfbb2Smrg# Some modes work just like other modes, but use different flags. We 74357bfbb2Smrg# parameterize here, but still list the modes in the big case below, 75357bfbb2Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 76357bfbb2Smrg# here, because this file can only contain one case statement. 77357bfbb2Smrgif test "$depmode" = hp; then 78357bfbb2Smrg # HP compiler uses -M and no extra arg. 79357bfbb2Smrg gccflag=-M 80357bfbb2Smrg depmode=gcc 81357bfbb2Smrgfi 82357bfbb2Smrg 83357bfbb2Smrgif test "$depmode" = dashXmstdout; then 84357bfbb2Smrg # This is just like dashmstdout with a different argument. 85357bfbb2Smrg dashmflag=-xM 86357bfbb2Smrg depmode=dashmstdout 87357bfbb2Smrgfi 88357bfbb2Smrg 89357bfbb2Smrgcase "$depmode" in 90357bfbb2Smrggcc3) 91357bfbb2Smrg## gcc 3 implements dependency tracking that does exactly what 92357bfbb2Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93357bfbb2Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 94357bfbb2Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95357bfbb2Smrg stat=$? 96357bfbb2Smrg if test $stat -eq 0; then : 97357bfbb2Smrg else 98357bfbb2Smrg rm -f "$tmpdepfile" 99357bfbb2Smrg exit $stat 100357bfbb2Smrg fi 101357bfbb2Smrg mv "$tmpdepfile" "$depfile" 102357bfbb2Smrg ;; 103357bfbb2Smrg 104357bfbb2Smrggcc) 105357bfbb2Smrg## There are various ways to get dependency output from gcc. Here's 106357bfbb2Smrg## why we pick this rather obscure method: 107357bfbb2Smrg## - Don't want to use -MD because we'd like the dependencies to end 108357bfbb2Smrg## up in a subdir. Having to rename by hand is ugly. 109357bfbb2Smrg## (We might end up doing this anyway to support other compilers.) 110357bfbb2Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111357bfbb2Smrg## -MM, not -M (despite what the docs say). 112357bfbb2Smrg## - Using -M directly means running the compiler twice (even worse 113357bfbb2Smrg## than renaming). 114357bfbb2Smrg if test -z "$gccflag"; then 115357bfbb2Smrg gccflag=-MD, 116357bfbb2Smrg fi 117357bfbb2Smrg "$@" -Wp,"$gccflag$tmpdepfile" 118357bfbb2Smrg stat=$? 119357bfbb2Smrg if test $stat -eq 0; then : 120357bfbb2Smrg else 121357bfbb2Smrg rm -f "$tmpdepfile" 122357bfbb2Smrg exit $stat 123357bfbb2Smrg fi 124357bfbb2Smrg rm -f "$depfile" 125357bfbb2Smrg echo "$object : \\" > "$depfile" 126357bfbb2Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127357bfbb2Smrg## The second -e expression handles DOS-style file names with drive letters. 128357bfbb2Smrg sed -e 's/^[^:]*: / /' \ 129357bfbb2Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130357bfbb2Smrg## This next piece of magic avoids the `deleted header file' problem. 131357bfbb2Smrg## The problem is that when a header file which appears in a .P file 132357bfbb2Smrg## is deleted, the dependency causes make to die (because there is 133357bfbb2Smrg## typically no way to rebuild the header). We avoid this by adding 134357bfbb2Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 135357bfbb2Smrg## this for us directly. 136357bfbb2Smrg tr ' ' ' 137357bfbb2Smrg' < "$tmpdepfile" | 138357bfbb2Smrg## Some versions of gcc put a space before the `:'. On the theory 139357bfbb2Smrg## that the space means something, we add a space to the output as 140357bfbb2Smrg## well. 141357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 142357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 143357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144357bfbb2Smrg rm -f "$tmpdepfile" 145357bfbb2Smrg ;; 146357bfbb2Smrg 147357bfbb2Smrghp) 148357bfbb2Smrg # This case exists only to let depend.m4 do its work. It works by 149357bfbb2Smrg # looking at the text of this script. This case will never be run, 150357bfbb2Smrg # since it is checked for above. 151357bfbb2Smrg exit 1 152357bfbb2Smrg ;; 153357bfbb2Smrg 154357bfbb2Smrgsgi) 155357bfbb2Smrg if test "$libtool" = yes; then 156357bfbb2Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 157357bfbb2Smrg else 158357bfbb2Smrg "$@" -MDupdate "$tmpdepfile" 159357bfbb2Smrg fi 160357bfbb2Smrg stat=$? 161357bfbb2Smrg if test $stat -eq 0; then : 162357bfbb2Smrg else 163357bfbb2Smrg rm -f "$tmpdepfile" 164357bfbb2Smrg exit $stat 165357bfbb2Smrg fi 166357bfbb2Smrg rm -f "$depfile" 167357bfbb2Smrg 168357bfbb2Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169357bfbb2Smrg echo "$object : \\" > "$depfile" 170357bfbb2Smrg 171357bfbb2Smrg # Clip off the initial element (the dependent). Don't try to be 172357bfbb2Smrg # clever and replace this with sed code, as IRIX sed won't handle 173357bfbb2Smrg # lines with more than a fixed number of characters (4096 in 174357bfbb2Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175357bfbb2Smrg # the IRIX cc adds comments like `#:fec' to the end of the 176357bfbb2Smrg # dependency line. 177357bfbb2Smrg tr ' ' ' 178357bfbb2Smrg' < "$tmpdepfile" \ 179357bfbb2Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180357bfbb2Smrg tr ' 181357bfbb2Smrg' ' ' >> $depfile 182357bfbb2Smrg echo >> $depfile 183357bfbb2Smrg 184357bfbb2Smrg # The second pass generates a dummy entry for each header file. 185357bfbb2Smrg tr ' ' ' 186357bfbb2Smrg' < "$tmpdepfile" \ 187357bfbb2Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188357bfbb2Smrg >> $depfile 189357bfbb2Smrg else 190357bfbb2Smrg # The sourcefile does not contain any dependencies, so just 191357bfbb2Smrg # store a dummy comment line, to avoid errors with the Makefile 192357bfbb2Smrg # "include basename.Plo" scheme. 193357bfbb2Smrg echo "#dummy" > "$depfile" 194357bfbb2Smrg fi 195357bfbb2Smrg rm -f "$tmpdepfile" 196357bfbb2Smrg ;; 197357bfbb2Smrg 198357bfbb2Smrgaix) 199357bfbb2Smrg # The C for AIX Compiler uses -M and outputs the dependencies 200357bfbb2Smrg # in a .u file. In older versions, this file always lives in the 201357bfbb2Smrg # current directory. Also, the AIX compiler puts `$object:' at the 202357bfbb2Smrg # start of each line; $object doesn't have directory information. 203357bfbb2Smrg # Version 6 uses the directory in both cases. 204357bfbb2Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205357bfbb2Smrg tmpdepfile="$stripped.u" 206357bfbb2Smrg if test "$libtool" = yes; then 207357bfbb2Smrg "$@" -Wc,-M 208357bfbb2Smrg else 209357bfbb2Smrg "$@" -M 210357bfbb2Smrg fi 211357bfbb2Smrg stat=$? 212357bfbb2Smrg 213357bfbb2Smrg if test -f "$tmpdepfile"; then : 214357bfbb2Smrg else 215357bfbb2Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 216357bfbb2Smrg tmpdepfile="$stripped.u" 217357bfbb2Smrg fi 218357bfbb2Smrg 219357bfbb2Smrg if test $stat -eq 0; then : 220357bfbb2Smrg else 221357bfbb2Smrg rm -f "$tmpdepfile" 222357bfbb2Smrg exit $stat 223357bfbb2Smrg fi 224357bfbb2Smrg 225357bfbb2Smrg if test -f "$tmpdepfile"; then 226357bfbb2Smrg outname="$stripped.o" 227357bfbb2Smrg # Each line is of the form `foo.o: dependent.h'. 228357bfbb2Smrg # Do two passes, one to just change these to 229357bfbb2Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 230357bfbb2Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231357bfbb2Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232357bfbb2Smrg else 233357bfbb2Smrg # The sourcefile does not contain any dependencies, so just 234357bfbb2Smrg # store a dummy comment line, to avoid errors with the Makefile 235357bfbb2Smrg # "include basename.Plo" scheme. 236357bfbb2Smrg echo "#dummy" > "$depfile" 237357bfbb2Smrg fi 238357bfbb2Smrg rm -f "$tmpdepfile" 239357bfbb2Smrg ;; 240357bfbb2Smrg 241357bfbb2Smrgicc) 242357bfbb2Smrg # Intel's C compiler understands `-MD -MF file'. However on 243357bfbb2Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244357bfbb2Smrg # ICC 7.0 will fill foo.d with something like 245357bfbb2Smrg # foo.o: sub/foo.c 246357bfbb2Smrg # foo.o: sub/foo.h 247357bfbb2Smrg # which is wrong. We want: 248357bfbb2Smrg # sub/foo.o: sub/foo.c 249357bfbb2Smrg # sub/foo.o: sub/foo.h 250357bfbb2Smrg # sub/foo.c: 251357bfbb2Smrg # sub/foo.h: 252357bfbb2Smrg # ICC 7.1 will output 253357bfbb2Smrg # foo.o: sub/foo.c sub/foo.h 254357bfbb2Smrg # and will wrap long lines using \ : 255357bfbb2Smrg # foo.o: sub/foo.c ... \ 256357bfbb2Smrg # sub/foo.h ... \ 257357bfbb2Smrg # ... 258357bfbb2Smrg 259357bfbb2Smrg "$@" -MD -MF "$tmpdepfile" 260357bfbb2Smrg stat=$? 261357bfbb2Smrg if test $stat -eq 0; then : 262357bfbb2Smrg else 263357bfbb2Smrg rm -f "$tmpdepfile" 264357bfbb2Smrg exit $stat 265357bfbb2Smrg fi 266357bfbb2Smrg rm -f "$depfile" 267357bfbb2Smrg # Each line is of the form `foo.o: dependent.h', 268357bfbb2Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269357bfbb2Smrg # Do two passes, one to just change these to 270357bfbb2Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 271357bfbb2Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272357bfbb2Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 273357bfbb2Smrg # correctly. Breaking it into two sed invocations is a workaround. 274357bfbb2Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275357bfbb2Smrg sed -e 's/$/ :/' >> "$depfile" 276357bfbb2Smrg rm -f "$tmpdepfile" 277357bfbb2Smrg ;; 278357bfbb2Smrg 279357bfbb2Smrgtru64) 280357bfbb2Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 281357bfbb2Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282357bfbb2Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283357bfbb2Smrg # dependencies in `foo.d' instead, so we check for that too. 284357bfbb2Smrg # Subdirectories are respected. 285357bfbb2Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286357bfbb2Smrg test "x$dir" = "x$object" && dir= 287357bfbb2Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288357bfbb2Smrg 289357bfbb2Smrg if test "$libtool" = yes; then 290357bfbb2Smrg # With Tru64 cc, shared objects can also be used to make a 291357bfbb2Smrg # static library. This mecanism is used in libtool 1.4 series to 292357bfbb2Smrg # handle both shared and static libraries in a single compilation. 293357bfbb2Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294357bfbb2Smrg # 295357bfbb2Smrg # With libtool 1.5 this exception was removed, and libtool now 296357bfbb2Smrg # generates 2 separate objects for the 2 libraries. These two 297357bfbb2Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 298357bfbb2Smrg # in $dir$base.o.d. We have to check for both files, because 299357bfbb2Smrg # one of the two compilations can be disabled. We should prefer 300357bfbb2Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301357bfbb2Smrg # automatically cleaned when .libs/ is deleted, while ignoring 302357bfbb2Smrg # the former would cause a distcleancheck panic. 303357bfbb2Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304357bfbb2Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 305357bfbb2Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306357bfbb2Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307357bfbb2Smrg "$@" -Wc,-MD 308357bfbb2Smrg else 309357bfbb2Smrg tmpdepfile1=$dir$base.o.d 310357bfbb2Smrg tmpdepfile2=$dir$base.d 311357bfbb2Smrg tmpdepfile3=$dir$base.d 312357bfbb2Smrg tmpdepfile4=$dir$base.d 313357bfbb2Smrg "$@" -MD 314357bfbb2Smrg fi 315357bfbb2Smrg 316357bfbb2Smrg stat=$? 317357bfbb2Smrg if test $stat -eq 0; then : 318357bfbb2Smrg else 319357bfbb2Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320357bfbb2Smrg exit $stat 321357bfbb2Smrg fi 322357bfbb2Smrg 323357bfbb2Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324357bfbb2Smrg do 325357bfbb2Smrg test -f "$tmpdepfile" && break 326357bfbb2Smrg done 327357bfbb2Smrg if test -f "$tmpdepfile"; then 328357bfbb2Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329357bfbb2Smrg # That's a tab and a space in the []. 330357bfbb2Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331357bfbb2Smrg else 332357bfbb2Smrg echo "#dummy" > "$depfile" 333357bfbb2Smrg fi 334357bfbb2Smrg rm -f "$tmpdepfile" 335357bfbb2Smrg ;; 336357bfbb2Smrg 337357bfbb2Smrg#nosideeffect) 338357bfbb2Smrg # This comment above is used by automake to tell side-effect 339357bfbb2Smrg # dependency tracking mechanisms from slower ones. 340357bfbb2Smrg 341357bfbb2Smrgdashmstdout) 342357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 343357bfbb2Smrg # always write the preprocessed file to stdout, regardless of -o. 344357bfbb2Smrg "$@" || exit $? 345357bfbb2Smrg 346357bfbb2Smrg # Remove the call to Libtool. 347357bfbb2Smrg if test "$libtool" = yes; then 348357bfbb2Smrg while test $1 != '--mode=compile'; do 349357bfbb2Smrg shift 350357bfbb2Smrg done 351357bfbb2Smrg shift 352357bfbb2Smrg fi 353357bfbb2Smrg 354357bfbb2Smrg # Remove `-o $object'. 355357bfbb2Smrg IFS=" " 356357bfbb2Smrg for arg 357357bfbb2Smrg do 358357bfbb2Smrg case $arg in 359357bfbb2Smrg -o) 360357bfbb2Smrg shift 361357bfbb2Smrg ;; 362357bfbb2Smrg $object) 363357bfbb2Smrg shift 364357bfbb2Smrg ;; 365357bfbb2Smrg *) 366357bfbb2Smrg set fnord "$@" "$arg" 367357bfbb2Smrg shift # fnord 368357bfbb2Smrg shift # $arg 369357bfbb2Smrg ;; 370357bfbb2Smrg esac 371357bfbb2Smrg done 372357bfbb2Smrg 373357bfbb2Smrg test -z "$dashmflag" && dashmflag=-M 374357bfbb2Smrg # Require at least two characters before searching for `:' 375357bfbb2Smrg # in the target name. This is to cope with DOS-style filenames: 376357bfbb2Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377357bfbb2Smrg "$@" $dashmflag | 378357bfbb2Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379357bfbb2Smrg rm -f "$depfile" 380357bfbb2Smrg cat < "$tmpdepfile" > "$depfile" 381357bfbb2Smrg tr ' ' ' 382357bfbb2Smrg' < "$tmpdepfile" | \ 383357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 384357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 385357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386357bfbb2Smrg rm -f "$tmpdepfile" 387357bfbb2Smrg ;; 388357bfbb2Smrg 389357bfbb2SmrgdashXmstdout) 390357bfbb2Smrg # This case only exists to satisfy depend.m4. It is never actually 391357bfbb2Smrg # run, as this mode is specially recognized in the preamble. 392357bfbb2Smrg exit 1 393357bfbb2Smrg ;; 394357bfbb2Smrg 395357bfbb2Smrgmakedepend) 396357bfbb2Smrg "$@" || exit $? 397357bfbb2Smrg # Remove any Libtool call 398357bfbb2Smrg if test "$libtool" = yes; then 399357bfbb2Smrg while test $1 != '--mode=compile'; do 400357bfbb2Smrg shift 401357bfbb2Smrg done 402357bfbb2Smrg shift 403357bfbb2Smrg fi 404357bfbb2Smrg # X makedepend 405357bfbb2Smrg shift 406357bfbb2Smrg cleared=no 407357bfbb2Smrg for arg in "$@"; do 408357bfbb2Smrg case $cleared in 409357bfbb2Smrg no) 410357bfbb2Smrg set ""; shift 411357bfbb2Smrg cleared=yes ;; 412357bfbb2Smrg esac 413357bfbb2Smrg case "$arg" in 414357bfbb2Smrg -D*|-I*) 415357bfbb2Smrg set fnord "$@" "$arg"; shift ;; 416357bfbb2Smrg # Strip any option that makedepend may not understand. Remove 417357bfbb2Smrg # the object too, otherwise makedepend will parse it as a source file. 418357bfbb2Smrg -*|$object) 419357bfbb2Smrg ;; 420357bfbb2Smrg *) 421357bfbb2Smrg set fnord "$@" "$arg"; shift ;; 422357bfbb2Smrg esac 423357bfbb2Smrg done 424357bfbb2Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 425357bfbb2Smrg touch "$tmpdepfile" 426357bfbb2Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427357bfbb2Smrg rm -f "$depfile" 428357bfbb2Smrg cat < "$tmpdepfile" > "$depfile" 429357bfbb2Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 430357bfbb2Smrg' | \ 431357bfbb2Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 432357bfbb2Smrg## correctly. Breaking it into two sed invocations is a workaround. 433357bfbb2Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434357bfbb2Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 435357bfbb2Smrg ;; 436357bfbb2Smrg 437357bfbb2Smrgcpp) 438357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 439357bfbb2Smrg # always write the preprocessed file to stdout. 440357bfbb2Smrg "$@" || exit $? 441357bfbb2Smrg 442357bfbb2Smrg # Remove the call to Libtool. 443357bfbb2Smrg if test "$libtool" = yes; then 444357bfbb2Smrg while test $1 != '--mode=compile'; do 445357bfbb2Smrg shift 446357bfbb2Smrg done 447357bfbb2Smrg shift 448357bfbb2Smrg fi 449357bfbb2Smrg 450357bfbb2Smrg # Remove `-o $object'. 451357bfbb2Smrg IFS=" " 452357bfbb2Smrg for arg 453357bfbb2Smrg do 454357bfbb2Smrg case $arg in 455357bfbb2Smrg -o) 456357bfbb2Smrg shift 457357bfbb2Smrg ;; 458357bfbb2Smrg $object) 459357bfbb2Smrg shift 460357bfbb2Smrg ;; 461357bfbb2Smrg *) 462357bfbb2Smrg set fnord "$@" "$arg" 463357bfbb2Smrg shift # fnord 464357bfbb2Smrg shift # $arg 465357bfbb2Smrg ;; 466357bfbb2Smrg esac 467357bfbb2Smrg done 468357bfbb2Smrg 469357bfbb2Smrg "$@" -E | 470357bfbb2Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471357bfbb2Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472357bfbb2Smrg sed '$ s: \\$::' > "$tmpdepfile" 473357bfbb2Smrg rm -f "$depfile" 474357bfbb2Smrg echo "$object : \\" > "$depfile" 475357bfbb2Smrg cat < "$tmpdepfile" >> "$depfile" 476357bfbb2Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477357bfbb2Smrg rm -f "$tmpdepfile" 478357bfbb2Smrg ;; 479357bfbb2Smrg 480357bfbb2Smrgmsvisualcpp) 481357bfbb2Smrg # Important note: in order to support this mode, a compiler *must* 482357bfbb2Smrg # always write the preprocessed file to stdout, regardless of -o, 483357bfbb2Smrg # because we must use -o when running libtool. 484357bfbb2Smrg "$@" || exit $? 485357bfbb2Smrg IFS=" " 486357bfbb2Smrg for arg 487357bfbb2Smrg do 488357bfbb2Smrg case "$arg" in 489357bfbb2Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490357bfbb2Smrg set fnord "$@" 491357bfbb2Smrg shift 492357bfbb2Smrg shift 493357bfbb2Smrg ;; 494357bfbb2Smrg *) 495357bfbb2Smrg set fnord "$@" "$arg" 496357bfbb2Smrg shift 497357bfbb2Smrg shift 498357bfbb2Smrg ;; 499357bfbb2Smrg esac 500357bfbb2Smrg done 501357bfbb2Smrg "$@" -E | 502357bfbb2Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503357bfbb2Smrg rm -f "$depfile" 504357bfbb2Smrg echo "$object : \\" > "$depfile" 505357bfbb2Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506357bfbb2Smrg echo " " >> "$depfile" 507357bfbb2Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508357bfbb2Smrg rm -f "$tmpdepfile" 509357bfbb2Smrg ;; 510357bfbb2Smrg 511357bfbb2Smrgnone) 512357bfbb2Smrg exec "$@" 513357bfbb2Smrg ;; 514357bfbb2Smrg 515357bfbb2Smrg*) 516357bfbb2Smrg echo "Unknown depmode $depmode" 1>&2 517357bfbb2Smrg exit 1 518357bfbb2Smrg ;; 519357bfbb2Smrgesac 520357bfbb2Smrg 521357bfbb2Smrgexit 0 522357bfbb2Smrg 523357bfbb2Smrg# Local Variables: 524357bfbb2Smrg# mode: shell-script 525357bfbb2Smrg# sh-indentation: 2 526357bfbb2Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 527357bfbb2Smrg# time-stamp-start: "scriptversion=" 528357bfbb2Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 529357bfbb2Smrg# time-stamp-end: "$" 530357bfbb2Smrg# End: 531