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