depcomp revision 8697ee19
1ab47cfaaSmrg#! /bin/sh 2ab47cfaaSmrg# depcomp - compile a program generating dependencies as side-effects 3ab47cfaaSmrg 48697ee19Smrgscriptversion=2006-10-15.18 5ab47cfaaSmrg 68697ee19Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software 78697ee19Smrg# Foundation, Inc. 8ab47cfaaSmrg 9ab47cfaaSmrg# This program is free software; you can redistribute it and/or modify 10ab47cfaaSmrg# it under the terms of the GNU General Public License as published by 11ab47cfaaSmrg# the Free Software Foundation; either version 2, or (at your option) 12ab47cfaaSmrg# any later version. 13ab47cfaaSmrg 14ab47cfaaSmrg# This program is distributed in the hope that it will be useful, 15ab47cfaaSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16ab47cfaaSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17ab47cfaaSmrg# GNU General Public License for more details. 18ab47cfaaSmrg 19ab47cfaaSmrg# You should have received a copy of the GNU General Public License 20ab47cfaaSmrg# along with this program; if not, write to the Free Software 21ab47cfaaSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22ab47cfaaSmrg# 02110-1301, USA. 23ab47cfaaSmrg 24ab47cfaaSmrg# As a special exception to the GNU General Public License, if you 25ab47cfaaSmrg# distribute this file as part of a program that contains a 26ab47cfaaSmrg# configuration script generated by Autoconf, you may include it under 27ab47cfaaSmrg# the same distribution terms that you use for the rest of that program. 28ab47cfaaSmrg 29ab47cfaaSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 30ab47cfaaSmrg 31ab47cfaaSmrgcase $1 in 32ab47cfaaSmrg '') 33ab47cfaaSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 34ab47cfaaSmrg exit 1; 35ab47cfaaSmrg ;; 36ab47cfaaSmrg -h | --h*) 37ab47cfaaSmrg cat <<\EOF 38ab47cfaaSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 39ab47cfaaSmrg 40ab47cfaaSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 41ab47cfaaSmrgas side-effects. 42ab47cfaaSmrg 43ab47cfaaSmrgEnvironment variables: 44ab47cfaaSmrg depmode Dependency tracking mode. 45ab47cfaaSmrg source Source file read by `PROGRAMS ARGS'. 46ab47cfaaSmrg object Object file output by `PROGRAMS ARGS'. 47ab47cfaaSmrg DEPDIR directory where to store dependencies. 48ab47cfaaSmrg depfile Dependency file to output. 49ab47cfaaSmrg tmpdepfile Temporary file to use when outputing dependencies. 50ab47cfaaSmrg libtool Whether libtool is used (yes/no). 51ab47cfaaSmrg 52ab47cfaaSmrgReport bugs to <bug-automake@gnu.org>. 53ab47cfaaSmrgEOF 54ab47cfaaSmrg exit $? 55ab47cfaaSmrg ;; 56ab47cfaaSmrg -v | --v*) 57ab47cfaaSmrg echo "depcomp $scriptversion" 58ab47cfaaSmrg exit $? 59ab47cfaaSmrg ;; 60ab47cfaaSmrgesac 61ab47cfaaSmrg 62ab47cfaaSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 63ab47cfaaSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 64ab47cfaaSmrg exit 1 65ab47cfaaSmrgfi 66ab47cfaaSmrg 67ab47cfaaSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 68ab47cfaaSmrgdepfile=${depfile-`echo "$object" | 69ab47cfaaSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 70ab47cfaaSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 71ab47cfaaSmrg 72ab47cfaaSmrgrm -f "$tmpdepfile" 73ab47cfaaSmrg 74ab47cfaaSmrg# Some modes work just like other modes, but use different flags. We 75ab47cfaaSmrg# parameterize here, but still list the modes in the big case below, 76ab47cfaaSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 77ab47cfaaSmrg# here, because this file can only contain one case statement. 78ab47cfaaSmrgif test "$depmode" = hp; then 79ab47cfaaSmrg # HP compiler uses -M and no extra arg. 80ab47cfaaSmrg gccflag=-M 81ab47cfaaSmrg depmode=gcc 82ab47cfaaSmrgfi 83ab47cfaaSmrg 84ab47cfaaSmrgif test "$depmode" = dashXmstdout; then 85ab47cfaaSmrg # This is just like dashmstdout with a different argument. 86ab47cfaaSmrg dashmflag=-xM 87ab47cfaaSmrg depmode=dashmstdout 88ab47cfaaSmrgfi 89ab47cfaaSmrg 90ab47cfaaSmrgcase "$depmode" in 91ab47cfaaSmrggcc3) 92ab47cfaaSmrg## gcc 3 implements dependency tracking that does exactly what 93ab47cfaaSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 94ab47cfaaSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 958697ee19Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 968697ee19Smrg## the command line argument order; so add the flags where they 978697ee19Smrg## appear in depend2.am. Note that the slowdown incurred here 988697ee19Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 998697ee19Smrg for arg 1008697ee19Smrg do 1018697ee19Smrg case $arg in 1028697ee19Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1038697ee19Smrg *) set fnord "$@" "$arg" ;; 1048697ee19Smrg esac 1058697ee19Smrg shift # fnord 1068697ee19Smrg shift # $arg 1078697ee19Smrg done 1088697ee19Smrg "$@" 109ab47cfaaSmrg stat=$? 110ab47cfaaSmrg if test $stat -eq 0; then : 111ab47cfaaSmrg else 112ab47cfaaSmrg rm -f "$tmpdepfile" 113ab47cfaaSmrg exit $stat 114ab47cfaaSmrg fi 115ab47cfaaSmrg mv "$tmpdepfile" "$depfile" 116ab47cfaaSmrg ;; 117ab47cfaaSmrg 118ab47cfaaSmrggcc) 119ab47cfaaSmrg## There are various ways to get dependency output from gcc. Here's 120ab47cfaaSmrg## why we pick this rather obscure method: 121ab47cfaaSmrg## - Don't want to use -MD because we'd like the dependencies to end 122ab47cfaaSmrg## up in a subdir. Having to rename by hand is ugly. 123ab47cfaaSmrg## (We might end up doing this anyway to support other compilers.) 124ab47cfaaSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 125ab47cfaaSmrg## -MM, not -M (despite what the docs say). 126ab47cfaaSmrg## - Using -M directly means running the compiler twice (even worse 127ab47cfaaSmrg## than renaming). 128ab47cfaaSmrg if test -z "$gccflag"; then 129ab47cfaaSmrg gccflag=-MD, 130ab47cfaaSmrg fi 131ab47cfaaSmrg "$@" -Wp,"$gccflag$tmpdepfile" 132ab47cfaaSmrg stat=$? 133ab47cfaaSmrg if test $stat -eq 0; then : 134ab47cfaaSmrg else 135ab47cfaaSmrg rm -f "$tmpdepfile" 136ab47cfaaSmrg exit $stat 137ab47cfaaSmrg fi 138ab47cfaaSmrg rm -f "$depfile" 139ab47cfaaSmrg echo "$object : \\" > "$depfile" 140ab47cfaaSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 141ab47cfaaSmrg## The second -e expression handles DOS-style file names with drive letters. 142ab47cfaaSmrg sed -e 's/^[^:]*: / /' \ 143ab47cfaaSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 144ab47cfaaSmrg## This next piece of magic avoids the `deleted header file' problem. 145ab47cfaaSmrg## The problem is that when a header file which appears in a .P file 146ab47cfaaSmrg## is deleted, the dependency causes make to die (because there is 147ab47cfaaSmrg## typically no way to rebuild the header). We avoid this by adding 148ab47cfaaSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 149ab47cfaaSmrg## this for us directly. 150ab47cfaaSmrg tr ' ' ' 151ab47cfaaSmrg' < "$tmpdepfile" | 152ab47cfaaSmrg## Some versions of gcc put a space before the `:'. On the theory 153ab47cfaaSmrg## that the space means something, we add a space to the output as 154ab47cfaaSmrg## well. 155ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 156ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 157ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 158ab47cfaaSmrg rm -f "$tmpdepfile" 159ab47cfaaSmrg ;; 160ab47cfaaSmrg 161ab47cfaaSmrghp) 162ab47cfaaSmrg # This case exists only to let depend.m4 do its work. It works by 163ab47cfaaSmrg # looking at the text of this script. This case will never be run, 164ab47cfaaSmrg # since it is checked for above. 165ab47cfaaSmrg exit 1 166ab47cfaaSmrg ;; 167ab47cfaaSmrg 168ab47cfaaSmrgsgi) 169ab47cfaaSmrg if test "$libtool" = yes; then 170ab47cfaaSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 171ab47cfaaSmrg else 172ab47cfaaSmrg "$@" -MDupdate "$tmpdepfile" 173ab47cfaaSmrg fi 174ab47cfaaSmrg stat=$? 175ab47cfaaSmrg if test $stat -eq 0; then : 176ab47cfaaSmrg else 177ab47cfaaSmrg rm -f "$tmpdepfile" 178ab47cfaaSmrg exit $stat 179ab47cfaaSmrg fi 180ab47cfaaSmrg rm -f "$depfile" 181ab47cfaaSmrg 182ab47cfaaSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 183ab47cfaaSmrg echo "$object : \\" > "$depfile" 184ab47cfaaSmrg 185ab47cfaaSmrg # Clip off the initial element (the dependent). Don't try to be 186ab47cfaaSmrg # clever and replace this with sed code, as IRIX sed won't handle 187ab47cfaaSmrg # lines with more than a fixed number of characters (4096 in 188ab47cfaaSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 189ab47cfaaSmrg # the IRIX cc adds comments like `#:fec' to the end of the 190ab47cfaaSmrg # dependency line. 191ab47cfaaSmrg tr ' ' ' 192ab47cfaaSmrg' < "$tmpdepfile" \ 193ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 194ab47cfaaSmrg tr ' 195ab47cfaaSmrg' ' ' >> $depfile 196ab47cfaaSmrg echo >> $depfile 197ab47cfaaSmrg 198ab47cfaaSmrg # The second pass generates a dummy entry for each header file. 199ab47cfaaSmrg tr ' ' ' 200ab47cfaaSmrg' < "$tmpdepfile" \ 201ab47cfaaSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 202ab47cfaaSmrg >> $depfile 203ab47cfaaSmrg else 204ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 205ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 206ab47cfaaSmrg # "include basename.Plo" scheme. 207ab47cfaaSmrg echo "#dummy" > "$depfile" 208ab47cfaaSmrg fi 209ab47cfaaSmrg rm -f "$tmpdepfile" 210ab47cfaaSmrg ;; 211ab47cfaaSmrg 212ab47cfaaSmrgaix) 213ab47cfaaSmrg # The C for AIX Compiler uses -M and outputs the dependencies 214ab47cfaaSmrg # in a .u file. In older versions, this file always lives in the 215ab47cfaaSmrg # current directory. Also, the AIX compiler puts `$object:' at the 216ab47cfaaSmrg # start of each line; $object doesn't have directory information. 217ab47cfaaSmrg # Version 6 uses the directory in both cases. 218ab47cfaaSmrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 219ab47cfaaSmrg tmpdepfile="$stripped.u" 220ab47cfaaSmrg if test "$libtool" = yes; then 221ab47cfaaSmrg "$@" -Wc,-M 222ab47cfaaSmrg else 223ab47cfaaSmrg "$@" -M 224ab47cfaaSmrg fi 225ab47cfaaSmrg stat=$? 226ab47cfaaSmrg 227ab47cfaaSmrg if test -f "$tmpdepfile"; then : 228ab47cfaaSmrg else 229ab47cfaaSmrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 230ab47cfaaSmrg tmpdepfile="$stripped.u" 231ab47cfaaSmrg fi 232ab47cfaaSmrg 233ab47cfaaSmrg if test $stat -eq 0; then : 234ab47cfaaSmrg else 235ab47cfaaSmrg rm -f "$tmpdepfile" 236ab47cfaaSmrg exit $stat 237ab47cfaaSmrg fi 238ab47cfaaSmrg 239ab47cfaaSmrg if test -f "$tmpdepfile"; then 240ab47cfaaSmrg outname="$stripped.o" 241ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h'. 242ab47cfaaSmrg # Do two passes, one to just change these to 243ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 244ab47cfaaSmrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 245ab47cfaaSmrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 246ab47cfaaSmrg else 247ab47cfaaSmrg # The sourcefile does not contain any dependencies, so just 248ab47cfaaSmrg # store a dummy comment line, to avoid errors with the Makefile 249ab47cfaaSmrg # "include basename.Plo" scheme. 250ab47cfaaSmrg echo "#dummy" > "$depfile" 251ab47cfaaSmrg fi 252ab47cfaaSmrg rm -f "$tmpdepfile" 253ab47cfaaSmrg ;; 254ab47cfaaSmrg 255ab47cfaaSmrgicc) 256ab47cfaaSmrg # Intel's C compiler understands `-MD -MF file'. However on 257ab47cfaaSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 258ab47cfaaSmrg # ICC 7.0 will fill foo.d with something like 259ab47cfaaSmrg # foo.o: sub/foo.c 260ab47cfaaSmrg # foo.o: sub/foo.h 261ab47cfaaSmrg # which is wrong. We want: 262ab47cfaaSmrg # sub/foo.o: sub/foo.c 263ab47cfaaSmrg # sub/foo.o: sub/foo.h 264ab47cfaaSmrg # sub/foo.c: 265ab47cfaaSmrg # sub/foo.h: 266ab47cfaaSmrg # ICC 7.1 will output 267ab47cfaaSmrg # foo.o: sub/foo.c sub/foo.h 268ab47cfaaSmrg # and will wrap long lines using \ : 269ab47cfaaSmrg # foo.o: sub/foo.c ... \ 270ab47cfaaSmrg # sub/foo.h ... \ 271ab47cfaaSmrg # ... 272ab47cfaaSmrg 273ab47cfaaSmrg "$@" -MD -MF "$tmpdepfile" 274ab47cfaaSmrg stat=$? 275ab47cfaaSmrg if test $stat -eq 0; then : 276ab47cfaaSmrg else 277ab47cfaaSmrg rm -f "$tmpdepfile" 278ab47cfaaSmrg exit $stat 279ab47cfaaSmrg fi 280ab47cfaaSmrg rm -f "$depfile" 281ab47cfaaSmrg # Each line is of the form `foo.o: dependent.h', 282ab47cfaaSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 283ab47cfaaSmrg # Do two passes, one to just change these to 284ab47cfaaSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 285ab47cfaaSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 286ab47cfaaSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 287ab47cfaaSmrg # correctly. Breaking it into two sed invocations is a workaround. 288ab47cfaaSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 289ab47cfaaSmrg sed -e 's/$/ :/' >> "$depfile" 290ab47cfaaSmrg rm -f "$tmpdepfile" 291ab47cfaaSmrg ;; 292ab47cfaaSmrg 2938697ee19Smrghp2) 2948697ee19Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 2958697ee19Smrg # compilers, which have integrated preprocessors. The correct option 2968697ee19Smrg # to use with these is +Maked; it writes dependencies to a file named 2978697ee19Smrg # 'foo.d', which lands next to the object file, wherever that 2988697ee19Smrg # happens to be. 2998697ee19Smrg # Much of this is similar to the tru64 case; see comments there. 3008697ee19Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3018697ee19Smrg test "x$dir" = "x$object" && dir= 3028697ee19Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3038697ee19Smrg if test "$libtool" = yes; then 3048697ee19Smrg tmpdepfile1=$dir$base.d 3058697ee19Smrg tmpdepfile2=$dir.libs/$base.d 3068697ee19Smrg "$@" -Wc,+Maked 3078697ee19Smrg else 3088697ee19Smrg tmpdepfile1=$dir$base.d 3098697ee19Smrg tmpdepfile2=$dir$base.d 3108697ee19Smrg "$@" +Maked 3118697ee19Smrg fi 3128697ee19Smrg stat=$? 3138697ee19Smrg if test $stat -eq 0; then : 3148697ee19Smrg else 3158697ee19Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3168697ee19Smrg exit $stat 3178697ee19Smrg fi 3188697ee19Smrg 3198697ee19Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3208697ee19Smrg do 3218697ee19Smrg test -f "$tmpdepfile" && break 3228697ee19Smrg done 3238697ee19Smrg if test -f "$tmpdepfile"; then 3248697ee19Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3258697ee19Smrg # Add `dependent.h:' lines. 3268697ee19Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3278697ee19Smrg else 3288697ee19Smrg echo "#dummy" > "$depfile" 3298697ee19Smrg fi 3308697ee19Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3318697ee19Smrg ;; 3328697ee19Smrg 333ab47cfaaSmrgtru64) 334ab47cfaaSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 335ab47cfaaSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 336ab47cfaaSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 337ab47cfaaSmrg # dependencies in `foo.d' instead, so we check for that too. 338ab47cfaaSmrg # Subdirectories are respected. 339ab47cfaaSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 340ab47cfaaSmrg test "x$dir" = "x$object" && dir= 341ab47cfaaSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 342ab47cfaaSmrg 343ab47cfaaSmrg if test "$libtool" = yes; then 344ab47cfaaSmrg # With Tru64 cc, shared objects can also be used to make a 3458697ee19Smrg # static library. This mechanism is used in libtool 1.4 series to 346ab47cfaaSmrg # handle both shared and static libraries in a single compilation. 347ab47cfaaSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 348ab47cfaaSmrg # 349ab47cfaaSmrg # With libtool 1.5 this exception was removed, and libtool now 350ab47cfaaSmrg # generates 2 separate objects for the 2 libraries. These two 3518697ee19Smrg # compilations output dependencies in $dir.libs/$base.o.d and 352ab47cfaaSmrg # in $dir$base.o.d. We have to check for both files, because 353ab47cfaaSmrg # one of the two compilations can be disabled. We should prefer 354ab47cfaaSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 355ab47cfaaSmrg # automatically cleaned when .libs/ is deleted, while ignoring 356ab47cfaaSmrg # the former would cause a distcleancheck panic. 357ab47cfaaSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 358ab47cfaaSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 359ab47cfaaSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 360ab47cfaaSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 361ab47cfaaSmrg "$@" -Wc,-MD 362ab47cfaaSmrg else 363ab47cfaaSmrg tmpdepfile1=$dir$base.o.d 364ab47cfaaSmrg tmpdepfile2=$dir$base.d 365ab47cfaaSmrg tmpdepfile3=$dir$base.d 366ab47cfaaSmrg tmpdepfile4=$dir$base.d 367ab47cfaaSmrg "$@" -MD 368ab47cfaaSmrg fi 369ab47cfaaSmrg 370ab47cfaaSmrg stat=$? 371ab47cfaaSmrg if test $stat -eq 0; then : 372ab47cfaaSmrg else 373ab47cfaaSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 374ab47cfaaSmrg exit $stat 375ab47cfaaSmrg fi 376ab47cfaaSmrg 377ab47cfaaSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 378ab47cfaaSmrg do 379ab47cfaaSmrg test -f "$tmpdepfile" && break 380ab47cfaaSmrg done 381ab47cfaaSmrg if test -f "$tmpdepfile"; then 382ab47cfaaSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 383ab47cfaaSmrg # That's a tab and a space in the []. 384ab47cfaaSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 385ab47cfaaSmrg else 386ab47cfaaSmrg echo "#dummy" > "$depfile" 387ab47cfaaSmrg fi 388ab47cfaaSmrg rm -f "$tmpdepfile" 389ab47cfaaSmrg ;; 390ab47cfaaSmrg 391ab47cfaaSmrg#nosideeffect) 392ab47cfaaSmrg # This comment above is used by automake to tell side-effect 393ab47cfaaSmrg # dependency tracking mechanisms from slower ones. 394ab47cfaaSmrg 395ab47cfaaSmrgdashmstdout) 396ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 397ab47cfaaSmrg # always write the preprocessed file to stdout, regardless of -o. 398ab47cfaaSmrg "$@" || exit $? 399ab47cfaaSmrg 400ab47cfaaSmrg # Remove the call to Libtool. 401ab47cfaaSmrg if test "$libtool" = yes; then 402ab47cfaaSmrg while test $1 != '--mode=compile'; do 403ab47cfaaSmrg shift 404ab47cfaaSmrg done 405ab47cfaaSmrg shift 406ab47cfaaSmrg fi 407ab47cfaaSmrg 408ab47cfaaSmrg # Remove `-o $object'. 409ab47cfaaSmrg IFS=" " 410ab47cfaaSmrg for arg 411ab47cfaaSmrg do 412ab47cfaaSmrg case $arg in 413ab47cfaaSmrg -o) 414ab47cfaaSmrg shift 415ab47cfaaSmrg ;; 416ab47cfaaSmrg $object) 417ab47cfaaSmrg shift 418ab47cfaaSmrg ;; 419ab47cfaaSmrg *) 420ab47cfaaSmrg set fnord "$@" "$arg" 421ab47cfaaSmrg shift # fnord 422ab47cfaaSmrg shift # $arg 423ab47cfaaSmrg ;; 424ab47cfaaSmrg esac 425ab47cfaaSmrg done 426ab47cfaaSmrg 427ab47cfaaSmrg test -z "$dashmflag" && dashmflag=-M 428ab47cfaaSmrg # Require at least two characters before searching for `:' 429ab47cfaaSmrg # in the target name. This is to cope with DOS-style filenames: 430ab47cfaaSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 431ab47cfaaSmrg "$@" $dashmflag | 432ab47cfaaSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 433ab47cfaaSmrg rm -f "$depfile" 434ab47cfaaSmrg cat < "$tmpdepfile" > "$depfile" 435ab47cfaaSmrg tr ' ' ' 436ab47cfaaSmrg' < "$tmpdepfile" | \ 437ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 438ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 439ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 440ab47cfaaSmrg rm -f "$tmpdepfile" 441ab47cfaaSmrg ;; 442ab47cfaaSmrg 443ab47cfaaSmrgdashXmstdout) 444ab47cfaaSmrg # This case only exists to satisfy depend.m4. It is never actually 445ab47cfaaSmrg # run, as this mode is specially recognized in the preamble. 446ab47cfaaSmrg exit 1 447ab47cfaaSmrg ;; 448ab47cfaaSmrg 449ab47cfaaSmrgmakedepend) 450ab47cfaaSmrg "$@" || exit $? 451ab47cfaaSmrg # Remove any Libtool call 452ab47cfaaSmrg if test "$libtool" = yes; then 453ab47cfaaSmrg while test $1 != '--mode=compile'; do 454ab47cfaaSmrg shift 455ab47cfaaSmrg done 456ab47cfaaSmrg shift 457ab47cfaaSmrg fi 458ab47cfaaSmrg # X makedepend 459ab47cfaaSmrg shift 460ab47cfaaSmrg cleared=no 461ab47cfaaSmrg for arg in "$@"; do 462ab47cfaaSmrg case $cleared in 463ab47cfaaSmrg no) 464ab47cfaaSmrg set ""; shift 465ab47cfaaSmrg cleared=yes ;; 466ab47cfaaSmrg esac 467ab47cfaaSmrg case "$arg" in 468ab47cfaaSmrg -D*|-I*) 469ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 470ab47cfaaSmrg # Strip any option that makedepend may not understand. Remove 471ab47cfaaSmrg # the object too, otherwise makedepend will parse it as a source file. 472ab47cfaaSmrg -*|$object) 473ab47cfaaSmrg ;; 474ab47cfaaSmrg *) 475ab47cfaaSmrg set fnord "$@" "$arg"; shift ;; 476ab47cfaaSmrg esac 477ab47cfaaSmrg done 478ab47cfaaSmrg obj_suffix="`echo $object | sed 's/^.*\././'`" 479ab47cfaaSmrg touch "$tmpdepfile" 480ab47cfaaSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 481ab47cfaaSmrg rm -f "$depfile" 482ab47cfaaSmrg cat < "$tmpdepfile" > "$depfile" 483ab47cfaaSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 484ab47cfaaSmrg' | \ 485ab47cfaaSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 486ab47cfaaSmrg## correctly. Breaking it into two sed invocations is a workaround. 487ab47cfaaSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 488ab47cfaaSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 489ab47cfaaSmrg ;; 490ab47cfaaSmrg 491ab47cfaaSmrgcpp) 492ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 493ab47cfaaSmrg # always write the preprocessed file to stdout. 494ab47cfaaSmrg "$@" || exit $? 495ab47cfaaSmrg 496ab47cfaaSmrg # Remove the call to Libtool. 497ab47cfaaSmrg if test "$libtool" = yes; then 498ab47cfaaSmrg while test $1 != '--mode=compile'; do 499ab47cfaaSmrg shift 500ab47cfaaSmrg done 501ab47cfaaSmrg shift 502ab47cfaaSmrg fi 503ab47cfaaSmrg 504ab47cfaaSmrg # Remove `-o $object'. 505ab47cfaaSmrg IFS=" " 506ab47cfaaSmrg for arg 507ab47cfaaSmrg do 508ab47cfaaSmrg case $arg in 509ab47cfaaSmrg -o) 510ab47cfaaSmrg shift 511ab47cfaaSmrg ;; 512ab47cfaaSmrg $object) 513ab47cfaaSmrg shift 514ab47cfaaSmrg ;; 515ab47cfaaSmrg *) 516ab47cfaaSmrg set fnord "$@" "$arg" 517ab47cfaaSmrg shift # fnord 518ab47cfaaSmrg shift # $arg 519ab47cfaaSmrg ;; 520ab47cfaaSmrg esac 521ab47cfaaSmrg done 522ab47cfaaSmrg 523ab47cfaaSmrg "$@" -E | 524ab47cfaaSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 525ab47cfaaSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 526ab47cfaaSmrg sed '$ s: \\$::' > "$tmpdepfile" 527ab47cfaaSmrg rm -f "$depfile" 528ab47cfaaSmrg echo "$object : \\" > "$depfile" 529ab47cfaaSmrg cat < "$tmpdepfile" >> "$depfile" 530ab47cfaaSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 531ab47cfaaSmrg rm -f "$tmpdepfile" 532ab47cfaaSmrg ;; 533ab47cfaaSmrg 534ab47cfaaSmrgmsvisualcpp) 535ab47cfaaSmrg # Important note: in order to support this mode, a compiler *must* 536ab47cfaaSmrg # always write the preprocessed file to stdout, regardless of -o, 537ab47cfaaSmrg # because we must use -o when running libtool. 538ab47cfaaSmrg "$@" || exit $? 539ab47cfaaSmrg IFS=" " 540ab47cfaaSmrg for arg 541ab47cfaaSmrg do 542ab47cfaaSmrg case "$arg" in 543ab47cfaaSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 544ab47cfaaSmrg set fnord "$@" 545ab47cfaaSmrg shift 546ab47cfaaSmrg shift 547ab47cfaaSmrg ;; 548ab47cfaaSmrg *) 549ab47cfaaSmrg set fnord "$@" "$arg" 550ab47cfaaSmrg shift 551ab47cfaaSmrg shift 552ab47cfaaSmrg ;; 553ab47cfaaSmrg esac 554ab47cfaaSmrg done 555ab47cfaaSmrg "$@" -E | 556ab47cfaaSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 557ab47cfaaSmrg rm -f "$depfile" 558ab47cfaaSmrg echo "$object : \\" > "$depfile" 559ab47cfaaSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 560ab47cfaaSmrg echo " " >> "$depfile" 561ab47cfaaSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 562ab47cfaaSmrg rm -f "$tmpdepfile" 563ab47cfaaSmrg ;; 564ab47cfaaSmrg 565ab47cfaaSmrgnone) 566ab47cfaaSmrg exec "$@" 567ab47cfaaSmrg ;; 568ab47cfaaSmrg 569ab47cfaaSmrg*) 570ab47cfaaSmrg echo "Unknown depmode $depmode" 1>&2 571ab47cfaaSmrg exit 1 572ab47cfaaSmrg ;; 573ab47cfaaSmrgesac 574ab47cfaaSmrg 575ab47cfaaSmrgexit 0 576ab47cfaaSmrg 577ab47cfaaSmrg# Local Variables: 578ab47cfaaSmrg# mode: shell-script 579ab47cfaaSmrg# sh-indentation: 2 580ab47cfaaSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 581ab47cfaaSmrg# time-stamp-start: "scriptversion=" 582ab47cfaaSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 583ab47cfaaSmrg# time-stamp-end: "$" 584ab47cfaaSmrg# End: 585