1240a9a23Smbalmer#! /bin/sh 2240a9a23Smbalmer# depcomp - compile a program generating dependencies as side-effects 3240a9a23Smbalmer 4240a9a23Smbalmerscriptversion=2005-07-09.11 5240a9a23Smbalmer 6240a9a23Smbalmer# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7240a9a23Smbalmer 8240a9a23Smbalmer# This program is free software; you can redistribute it and/or modify 9240a9a23Smbalmer# it under the terms of the GNU General Public License as published by 10240a9a23Smbalmer# the Free Software Foundation; either version 2, or (at your option) 11240a9a23Smbalmer# any later version. 12240a9a23Smbalmer 13240a9a23Smbalmer# This program is distributed in the hope that it will be useful, 14240a9a23Smbalmer# but WITHOUT ANY WARRANTY; without even the implied warranty of 15240a9a23Smbalmer# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16240a9a23Smbalmer# GNU General Public License for more details. 17240a9a23Smbalmer 18240a9a23Smbalmer# You should have received a copy of the GNU General Public License 19240a9a23Smbalmer# along with this program; if not, write to the Free Software 20240a9a23Smbalmer# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21240a9a23Smbalmer# 02110-1301, USA. 22240a9a23Smbalmer 23240a9a23Smbalmer# As a special exception to the GNU General Public License, if you 24240a9a23Smbalmer# distribute this file as part of a program that contains a 25240a9a23Smbalmer# configuration script generated by Autoconf, you may include it under 26240a9a23Smbalmer# the same distribution terms that you use for the rest of that program. 27240a9a23Smbalmer 28240a9a23Smbalmer# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29240a9a23Smbalmer 30240a9a23Smbalmercase $1 in 31240a9a23Smbalmer '') 32240a9a23Smbalmer echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33240a9a23Smbalmer exit 1; 34240a9a23Smbalmer ;; 35240a9a23Smbalmer -h | --h*) 36240a9a23Smbalmer cat <<\EOF 37240a9a23SmbalmerUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38240a9a23Smbalmer 39240a9a23SmbalmerRun PROGRAMS ARGS to compile a file, generating dependencies 40240a9a23Smbalmeras side-effects. 41240a9a23Smbalmer 42240a9a23SmbalmerEnvironment variables: 43240a9a23Smbalmer depmode Dependency tracking mode. 44240a9a23Smbalmer source Source file read by `PROGRAMS ARGS'. 45240a9a23Smbalmer object Object file output by `PROGRAMS ARGS'. 46240a9a23Smbalmer DEPDIR directory where to store dependencies. 47240a9a23Smbalmer depfile Dependency file to output. 48240a9a23Smbalmer tmpdepfile Temporary file to use when outputing dependencies. 49240a9a23Smbalmer libtool Whether libtool is used (yes/no). 50240a9a23Smbalmer 51240a9a23SmbalmerReport bugs to <bug-automake@gnu.org>. 52240a9a23SmbalmerEOF 53240a9a23Smbalmer exit $? 54240a9a23Smbalmer ;; 55240a9a23Smbalmer -v | --v*) 56240a9a23Smbalmer echo "depcomp $scriptversion" 57240a9a23Smbalmer exit $? 58240a9a23Smbalmer ;; 59240a9a23Smbalmeresac 60240a9a23Smbalmer 61240a9a23Smbalmerif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62240a9a23Smbalmer echo "depcomp: Variables source, object and depmode must be set" 1>&2 63240a9a23Smbalmer exit 1 64240a9a23Smbalmerfi 65240a9a23Smbalmer 66240a9a23Smbalmer# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67240a9a23Smbalmerdepfile=${depfile-`echo "$object" | 68240a9a23Smbalmer sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69240a9a23Smbalmertmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70240a9a23Smbalmer 71240a9a23Smbalmerrm -f "$tmpdepfile" 72240a9a23Smbalmer 73240a9a23Smbalmer# Some modes work just like other modes, but use different flags. We 74240a9a23Smbalmer# parameterize here, but still list the modes in the big case below, 75240a9a23Smbalmer# to make depend.m4 easier to write. Note that we *cannot* use a case 76240a9a23Smbalmer# here, because this file can only contain one case statement. 77240a9a23Smbalmerif test "$depmode" = hp; then 78240a9a23Smbalmer # HP compiler uses -M and no extra arg. 79240a9a23Smbalmer gccflag=-M 80240a9a23Smbalmer depmode=gcc 81240a9a23Smbalmerfi 82240a9a23Smbalmer 83240a9a23Smbalmerif test "$depmode" = dashXmstdout; then 84240a9a23Smbalmer # This is just like dashmstdout with a different argument. 85240a9a23Smbalmer dashmflag=-xM 86240a9a23Smbalmer depmode=dashmstdout 87240a9a23Smbalmerfi 88240a9a23Smbalmer 89240a9a23Smbalmercase "$depmode" in 90240a9a23Smbalmergcc3) 91240a9a23Smbalmer## gcc 3 implements dependency tracking that does exactly what 92240a9a23Smbalmer## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93240a9a23Smbalmer## it if -MD -MP comes after the -MF stuff. Hmm. 94240a9a23Smbalmer "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95240a9a23Smbalmer stat=$? 96240a9a23Smbalmer if test $stat -eq 0; then : 97240a9a23Smbalmer else 98240a9a23Smbalmer rm -f "$tmpdepfile" 99240a9a23Smbalmer exit $stat 100240a9a23Smbalmer fi 101240a9a23Smbalmer mv "$tmpdepfile" "$depfile" 102240a9a23Smbalmer ;; 103240a9a23Smbalmer 104240a9a23Smbalmergcc) 105240a9a23Smbalmer## There are various ways to get dependency output from gcc. Here's 106240a9a23Smbalmer## why we pick this rather obscure method: 107240a9a23Smbalmer## - Don't want to use -MD because we'd like the dependencies to end 108240a9a23Smbalmer## up in a subdir. Having to rename by hand is ugly. 109240a9a23Smbalmer## (We might end up doing this anyway to support other compilers.) 110240a9a23Smbalmer## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111240a9a23Smbalmer## -MM, not -M (despite what the docs say). 112240a9a23Smbalmer## - Using -M directly means running the compiler twice (even worse 113240a9a23Smbalmer## than renaming). 114240a9a23Smbalmer if test -z "$gccflag"; then 115240a9a23Smbalmer gccflag=-MD, 116240a9a23Smbalmer fi 117240a9a23Smbalmer "$@" -Wp,"$gccflag$tmpdepfile" 118240a9a23Smbalmer stat=$? 119240a9a23Smbalmer if test $stat -eq 0; then : 120240a9a23Smbalmer else 121240a9a23Smbalmer rm -f "$tmpdepfile" 122240a9a23Smbalmer exit $stat 123240a9a23Smbalmer fi 124240a9a23Smbalmer rm -f "$depfile" 125240a9a23Smbalmer echo "$object : \\" > "$depfile" 126240a9a23Smbalmer alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127240a9a23Smbalmer## The second -e expression handles DOS-style file names with drive letters. 128240a9a23Smbalmer sed -e 's/^[^:]*: / /' \ 129240a9a23Smbalmer -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130240a9a23Smbalmer## This next piece of magic avoids the `deleted header file' problem. 131240a9a23Smbalmer## The problem is that when a header file which appears in a .P file 132240a9a23Smbalmer## is deleted, the dependency causes make to die (because there is 133240a9a23Smbalmer## typically no way to rebuild the header). We avoid this by adding 134240a9a23Smbalmer## dummy dependencies for each header file. Too bad gcc doesn't do 135240a9a23Smbalmer## this for us directly. 136240a9a23Smbalmer tr ' ' ' 137240a9a23Smbalmer' < "$tmpdepfile" | 138240a9a23Smbalmer## Some versions of gcc put a space before the `:'. On the theory 139240a9a23Smbalmer## that the space means something, we add a space to the output as 140240a9a23Smbalmer## well. 141240a9a23Smbalmer## Some versions of the HPUX 10.20 sed can't process this invocation 142240a9a23Smbalmer## correctly. Breaking it into two sed invocations is a workaround. 143240a9a23Smbalmer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144240a9a23Smbalmer rm -f "$tmpdepfile" 145240a9a23Smbalmer ;; 146240a9a23Smbalmer 147240a9a23Smbalmerhp) 148240a9a23Smbalmer # This case exists only to let depend.m4 do its work. It works by 149240a9a23Smbalmer # looking at the text of this script. This case will never be run, 150240a9a23Smbalmer # since it is checked for above. 151240a9a23Smbalmer exit 1 152240a9a23Smbalmer ;; 153240a9a23Smbalmer 154240a9a23Smbalmersgi) 155240a9a23Smbalmer if test "$libtool" = yes; then 156240a9a23Smbalmer "$@" "-Wp,-MDupdate,$tmpdepfile" 157240a9a23Smbalmer else 158240a9a23Smbalmer "$@" -MDupdate "$tmpdepfile" 159240a9a23Smbalmer fi 160240a9a23Smbalmer stat=$? 161240a9a23Smbalmer if test $stat -eq 0; then : 162240a9a23Smbalmer else 163240a9a23Smbalmer rm -f "$tmpdepfile" 164240a9a23Smbalmer exit $stat 165240a9a23Smbalmer fi 166240a9a23Smbalmer rm -f "$depfile" 167240a9a23Smbalmer 168240a9a23Smbalmer if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169240a9a23Smbalmer echo "$object : \\" > "$depfile" 170240a9a23Smbalmer 171240a9a23Smbalmer # Clip off the initial element (the dependent). Don't try to be 172240a9a23Smbalmer # clever and replace this with sed code, as IRIX sed won't handle 173240a9a23Smbalmer # lines with more than a fixed number of characters (4096 in 174240a9a23Smbalmer # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175240a9a23Smbalmer # the IRIX cc adds comments like `#:fec' to the end of the 176240a9a23Smbalmer # dependency line. 177240a9a23Smbalmer tr ' ' ' 178240a9a23Smbalmer' < "$tmpdepfile" \ 179240a9a23Smbalmer | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180240a9a23Smbalmer tr ' 181240a9a23Smbalmer' ' ' >> $depfile 182240a9a23Smbalmer echo >> $depfile 183240a9a23Smbalmer 184240a9a23Smbalmer # The second pass generates a dummy entry for each header file. 185240a9a23Smbalmer tr ' ' ' 186240a9a23Smbalmer' < "$tmpdepfile" \ 187240a9a23Smbalmer | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188240a9a23Smbalmer >> $depfile 189240a9a23Smbalmer else 190240a9a23Smbalmer # The sourcefile does not contain any dependencies, so just 191240a9a23Smbalmer # store a dummy comment line, to avoid errors with the Makefile 192240a9a23Smbalmer # "include basename.Plo" scheme. 193240a9a23Smbalmer echo "#dummy" > "$depfile" 194240a9a23Smbalmer fi 195240a9a23Smbalmer rm -f "$tmpdepfile" 196240a9a23Smbalmer ;; 197240a9a23Smbalmer 198240a9a23Smbalmeraix) 199240a9a23Smbalmer # The C for AIX Compiler uses -M and outputs the dependencies 200240a9a23Smbalmer # in a .u file. In older versions, this file always lives in the 201240a9a23Smbalmer # current directory. Also, the AIX compiler puts `$object:' at the 202240a9a23Smbalmer # start of each line; $object doesn't have directory information. 203240a9a23Smbalmer # Version 6 uses the directory in both cases. 204240a9a23Smbalmer stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205240a9a23Smbalmer tmpdepfile="$stripped.u" 206240a9a23Smbalmer if test "$libtool" = yes; then 207240a9a23Smbalmer "$@" -Wc,-M 208240a9a23Smbalmer else 209240a9a23Smbalmer "$@" -M 210240a9a23Smbalmer fi 211240a9a23Smbalmer stat=$? 212240a9a23Smbalmer 213240a9a23Smbalmer if test -f "$tmpdepfile"; then : 214240a9a23Smbalmer else 215240a9a23Smbalmer stripped=`echo "$stripped" | sed 's,^.*/,,'` 216240a9a23Smbalmer tmpdepfile="$stripped.u" 217240a9a23Smbalmer fi 218240a9a23Smbalmer 219240a9a23Smbalmer if test $stat -eq 0; then : 220240a9a23Smbalmer else 221240a9a23Smbalmer rm -f "$tmpdepfile" 222240a9a23Smbalmer exit $stat 223240a9a23Smbalmer fi 224240a9a23Smbalmer 225240a9a23Smbalmer if test -f "$tmpdepfile"; then 226240a9a23Smbalmer outname="$stripped.o" 227240a9a23Smbalmer # Each line is of the form `foo.o: dependent.h'. 228240a9a23Smbalmer # Do two passes, one to just change these to 229240a9a23Smbalmer # `$object: dependent.h' and one to simply `dependent.h:'. 230240a9a23Smbalmer sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231240a9a23Smbalmer sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232240a9a23Smbalmer else 233240a9a23Smbalmer # The sourcefile does not contain any dependencies, so just 234240a9a23Smbalmer # store a dummy comment line, to avoid errors with the Makefile 235240a9a23Smbalmer # "include basename.Plo" scheme. 236240a9a23Smbalmer echo "#dummy" > "$depfile" 237240a9a23Smbalmer fi 238240a9a23Smbalmer rm -f "$tmpdepfile" 239240a9a23Smbalmer ;; 240240a9a23Smbalmer 241240a9a23Smbalmericc) 242240a9a23Smbalmer # Intel's C compiler understands `-MD -MF file'. However on 243240a9a23Smbalmer # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244240a9a23Smbalmer # ICC 7.0 will fill foo.d with something like 245240a9a23Smbalmer # foo.o: sub/foo.c 246240a9a23Smbalmer # foo.o: sub/foo.h 247240a9a23Smbalmer # which is wrong. We want: 248240a9a23Smbalmer # sub/foo.o: sub/foo.c 249240a9a23Smbalmer # sub/foo.o: sub/foo.h 250240a9a23Smbalmer # sub/foo.c: 251240a9a23Smbalmer # sub/foo.h: 252240a9a23Smbalmer # ICC 7.1 will output 253240a9a23Smbalmer # foo.o: sub/foo.c sub/foo.h 254240a9a23Smbalmer # and will wrap long lines using \ : 255240a9a23Smbalmer # foo.o: sub/foo.c ... \ 256240a9a23Smbalmer # sub/foo.h ... \ 257240a9a23Smbalmer # ... 258240a9a23Smbalmer 259240a9a23Smbalmer "$@" -MD -MF "$tmpdepfile" 260240a9a23Smbalmer stat=$? 261240a9a23Smbalmer if test $stat -eq 0; then : 262240a9a23Smbalmer else 263240a9a23Smbalmer rm -f "$tmpdepfile" 264240a9a23Smbalmer exit $stat 265240a9a23Smbalmer fi 266240a9a23Smbalmer rm -f "$depfile" 267240a9a23Smbalmer # Each line is of the form `foo.o: dependent.h', 268240a9a23Smbalmer # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269240a9a23Smbalmer # Do two passes, one to just change these to 270240a9a23Smbalmer # `$object: dependent.h' and one to simply `dependent.h:'. 271240a9a23Smbalmer sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272240a9a23Smbalmer # Some versions of the HPUX 10.20 sed can't process this invocation 273240a9a23Smbalmer # correctly. Breaking it into two sed invocations is a workaround. 274240a9a23Smbalmer sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275240a9a23Smbalmer sed -e 's/$/ :/' >> "$depfile" 276240a9a23Smbalmer rm -f "$tmpdepfile" 277240a9a23Smbalmer ;; 278240a9a23Smbalmer 279240a9a23Smbalmertru64) 280240a9a23Smbalmer # The Tru64 compiler uses -MD to generate dependencies as a side 281240a9a23Smbalmer # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282240a9a23Smbalmer # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283240a9a23Smbalmer # dependencies in `foo.d' instead, so we check for that too. 284240a9a23Smbalmer # Subdirectories are respected. 285240a9a23Smbalmer dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286240a9a23Smbalmer test "x$dir" = "x$object" && dir= 287240a9a23Smbalmer base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288240a9a23Smbalmer 289240a9a23Smbalmer if test "$libtool" = yes; then 290240a9a23Smbalmer # With Tru64 cc, shared objects can also be used to make a 291240a9a23Smbalmer # static library. This mecanism is used in libtool 1.4 series to 292240a9a23Smbalmer # handle both shared and static libraries in a single compilation. 293240a9a23Smbalmer # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294240a9a23Smbalmer # 295240a9a23Smbalmer # With libtool 1.5 this exception was removed, and libtool now 296240a9a23Smbalmer # generates 2 separate objects for the 2 libraries. These two 297240a9a23Smbalmer # compilations output dependencies in in $dir.libs/$base.o.d and 298240a9a23Smbalmer # in $dir$base.o.d. We have to check for both files, because 299240a9a23Smbalmer # one of the two compilations can be disabled. We should prefer 300240a9a23Smbalmer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301240a9a23Smbalmer # automatically cleaned when .libs/ is deleted, while ignoring 302240a9a23Smbalmer # the former would cause a distcleancheck panic. 303240a9a23Smbalmer tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304240a9a23Smbalmer tmpdepfile2=$dir$base.o.d # libtool 1.5 305240a9a23Smbalmer tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306240a9a23Smbalmer tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307240a9a23Smbalmer "$@" -Wc,-MD 308240a9a23Smbalmer else 309240a9a23Smbalmer tmpdepfile1=$dir$base.o.d 310240a9a23Smbalmer tmpdepfile2=$dir$base.d 311240a9a23Smbalmer tmpdepfile3=$dir$base.d 312240a9a23Smbalmer tmpdepfile4=$dir$base.d 313240a9a23Smbalmer "$@" -MD 314240a9a23Smbalmer fi 315240a9a23Smbalmer 316240a9a23Smbalmer stat=$? 317240a9a23Smbalmer if test $stat -eq 0; then : 318240a9a23Smbalmer else 319240a9a23Smbalmer rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320240a9a23Smbalmer exit $stat 321240a9a23Smbalmer fi 322240a9a23Smbalmer 323240a9a23Smbalmer for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324240a9a23Smbalmer do 325240a9a23Smbalmer test -f "$tmpdepfile" && break 326240a9a23Smbalmer done 327240a9a23Smbalmer if test -f "$tmpdepfile"; then 328240a9a23Smbalmer sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329240a9a23Smbalmer # That's a tab and a space in the []. 330240a9a23Smbalmer sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331240a9a23Smbalmer else 332240a9a23Smbalmer echo "#dummy" > "$depfile" 333240a9a23Smbalmer fi 334240a9a23Smbalmer rm -f "$tmpdepfile" 335240a9a23Smbalmer ;; 336240a9a23Smbalmer 337240a9a23Smbalmer#nosideeffect) 338240a9a23Smbalmer # This comment above is used by automake to tell side-effect 339240a9a23Smbalmer # dependency tracking mechanisms from slower ones. 340240a9a23Smbalmer 341240a9a23Smbalmerdashmstdout) 342240a9a23Smbalmer # Important note: in order to support this mode, a compiler *must* 343240a9a23Smbalmer # always write the preprocessed file to stdout, regardless of -o. 344240a9a23Smbalmer "$@" || exit $? 345240a9a23Smbalmer 346240a9a23Smbalmer # Remove the call to Libtool. 347240a9a23Smbalmer if test "$libtool" = yes; then 348240a9a23Smbalmer while test $1 != '--mode=compile'; do 349240a9a23Smbalmer shift 350240a9a23Smbalmer done 351240a9a23Smbalmer shift 352240a9a23Smbalmer fi 353240a9a23Smbalmer 354240a9a23Smbalmer # Remove `-o $object'. 355240a9a23Smbalmer IFS=" " 356240a9a23Smbalmer for arg 357240a9a23Smbalmer do 358240a9a23Smbalmer case $arg in 359240a9a23Smbalmer -o) 360240a9a23Smbalmer shift 361240a9a23Smbalmer ;; 362240a9a23Smbalmer $object) 363240a9a23Smbalmer shift 364240a9a23Smbalmer ;; 365240a9a23Smbalmer *) 366240a9a23Smbalmer set fnord "$@" "$arg" 367240a9a23Smbalmer shift # fnord 368240a9a23Smbalmer shift # $arg 369240a9a23Smbalmer ;; 370240a9a23Smbalmer esac 371240a9a23Smbalmer done 372240a9a23Smbalmer 373240a9a23Smbalmer test -z "$dashmflag" && dashmflag=-M 374240a9a23Smbalmer # Require at least two characters before searching for `:' 375240a9a23Smbalmer # in the target name. This is to cope with DOS-style filenames: 376240a9a23Smbalmer # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377240a9a23Smbalmer "$@" $dashmflag | 378240a9a23Smbalmer sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379240a9a23Smbalmer rm -f "$depfile" 380240a9a23Smbalmer cat < "$tmpdepfile" > "$depfile" 381240a9a23Smbalmer tr ' ' ' 382240a9a23Smbalmer' < "$tmpdepfile" | \ 383240a9a23Smbalmer## Some versions of the HPUX 10.20 sed can't process this invocation 384240a9a23Smbalmer## correctly. Breaking it into two sed invocations is a workaround. 385240a9a23Smbalmer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386240a9a23Smbalmer rm -f "$tmpdepfile" 387240a9a23Smbalmer ;; 388240a9a23Smbalmer 389240a9a23SmbalmerdashXmstdout) 390240a9a23Smbalmer # This case only exists to satisfy depend.m4. It is never actually 391240a9a23Smbalmer # run, as this mode is specially recognized in the preamble. 392240a9a23Smbalmer exit 1 393240a9a23Smbalmer ;; 394240a9a23Smbalmer 395240a9a23Smbalmermakedepend) 396240a9a23Smbalmer "$@" || exit $? 397240a9a23Smbalmer # Remove any Libtool call 398240a9a23Smbalmer if test "$libtool" = yes; then 399240a9a23Smbalmer while test $1 != '--mode=compile'; do 400240a9a23Smbalmer shift 401240a9a23Smbalmer done 402240a9a23Smbalmer shift 403240a9a23Smbalmer fi 404240a9a23Smbalmer # X makedepend 405240a9a23Smbalmer shift 406240a9a23Smbalmer cleared=no 407240a9a23Smbalmer for arg in "$@"; do 408240a9a23Smbalmer case $cleared in 409240a9a23Smbalmer no) 410240a9a23Smbalmer set ""; shift 411240a9a23Smbalmer cleared=yes ;; 412240a9a23Smbalmer esac 413240a9a23Smbalmer case "$arg" in 414240a9a23Smbalmer -D*|-I*) 415240a9a23Smbalmer set fnord "$@" "$arg"; shift ;; 416240a9a23Smbalmer # Strip any option that makedepend may not understand. Remove 417240a9a23Smbalmer # the object too, otherwise makedepend will parse it as a source file. 418240a9a23Smbalmer -*|$object) 419240a9a23Smbalmer ;; 420240a9a23Smbalmer *) 421240a9a23Smbalmer set fnord "$@" "$arg"; shift ;; 422240a9a23Smbalmer esac 423240a9a23Smbalmer done 424240a9a23Smbalmer obj_suffix="`echo $object | sed 's/^.*\././'`" 425240a9a23Smbalmer touch "$tmpdepfile" 426240a9a23Smbalmer ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427240a9a23Smbalmer rm -f "$depfile" 428240a9a23Smbalmer cat < "$tmpdepfile" > "$depfile" 429240a9a23Smbalmer sed '1,2d' "$tmpdepfile" | tr ' ' ' 430240a9a23Smbalmer' | \ 431240a9a23Smbalmer## Some versions of the HPUX 10.20 sed can't process this invocation 432240a9a23Smbalmer## correctly. Breaking it into two sed invocations is a workaround. 433240a9a23Smbalmer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434240a9a23Smbalmer rm -f "$tmpdepfile" "$tmpdepfile".bak 435240a9a23Smbalmer ;; 436240a9a23Smbalmer 437240a9a23Smbalmercpp) 438240a9a23Smbalmer # Important note: in order to support this mode, a compiler *must* 439240a9a23Smbalmer # always write the preprocessed file to stdout. 440240a9a23Smbalmer "$@" || exit $? 441240a9a23Smbalmer 442240a9a23Smbalmer # Remove the call to Libtool. 443240a9a23Smbalmer if test "$libtool" = yes; then 444240a9a23Smbalmer while test $1 != '--mode=compile'; do 445240a9a23Smbalmer shift 446240a9a23Smbalmer done 447240a9a23Smbalmer shift 448240a9a23Smbalmer fi 449240a9a23Smbalmer 450240a9a23Smbalmer # Remove `-o $object'. 451240a9a23Smbalmer IFS=" " 452240a9a23Smbalmer for arg 453240a9a23Smbalmer do 454240a9a23Smbalmer case $arg in 455240a9a23Smbalmer -o) 456240a9a23Smbalmer shift 457240a9a23Smbalmer ;; 458240a9a23Smbalmer $object) 459240a9a23Smbalmer shift 460240a9a23Smbalmer ;; 461240a9a23Smbalmer *) 462240a9a23Smbalmer set fnord "$@" "$arg" 463240a9a23Smbalmer shift # fnord 464240a9a23Smbalmer shift # $arg 465240a9a23Smbalmer ;; 466240a9a23Smbalmer esac 467240a9a23Smbalmer done 468240a9a23Smbalmer 469240a9a23Smbalmer "$@" -E | 470240a9a23Smbalmer sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471240a9a23Smbalmer -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472240a9a23Smbalmer sed '$ s: \\$::' > "$tmpdepfile" 473240a9a23Smbalmer rm -f "$depfile" 474240a9a23Smbalmer echo "$object : \\" > "$depfile" 475240a9a23Smbalmer cat < "$tmpdepfile" >> "$depfile" 476240a9a23Smbalmer sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477240a9a23Smbalmer rm -f "$tmpdepfile" 478240a9a23Smbalmer ;; 479240a9a23Smbalmer 480240a9a23Smbalmermsvisualcpp) 481240a9a23Smbalmer # Important note: in order to support this mode, a compiler *must* 482240a9a23Smbalmer # always write the preprocessed file to stdout, regardless of -o, 483240a9a23Smbalmer # because we must use -o when running libtool. 484240a9a23Smbalmer "$@" || exit $? 485240a9a23Smbalmer IFS=" " 486240a9a23Smbalmer for arg 487240a9a23Smbalmer do 488240a9a23Smbalmer case "$arg" in 489240a9a23Smbalmer "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490240a9a23Smbalmer set fnord "$@" 491240a9a23Smbalmer shift 492240a9a23Smbalmer shift 493240a9a23Smbalmer ;; 494240a9a23Smbalmer *) 495240a9a23Smbalmer set fnord "$@" "$arg" 496240a9a23Smbalmer shift 497240a9a23Smbalmer shift 498240a9a23Smbalmer ;; 499240a9a23Smbalmer esac 500240a9a23Smbalmer done 501240a9a23Smbalmer "$@" -E | 502240a9a23Smbalmer sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503240a9a23Smbalmer rm -f "$depfile" 504240a9a23Smbalmer echo "$object : \\" > "$depfile" 505240a9a23Smbalmer . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506240a9a23Smbalmer echo " " >> "$depfile" 507240a9a23Smbalmer . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508240a9a23Smbalmer rm -f "$tmpdepfile" 509240a9a23Smbalmer ;; 510240a9a23Smbalmer 511240a9a23Smbalmernone) 512240a9a23Smbalmer exec "$@" 513240a9a23Smbalmer ;; 514240a9a23Smbalmer 515240a9a23Smbalmer*) 516240a9a23Smbalmer echo "Unknown depmode $depmode" 1>&2 517240a9a23Smbalmer exit 1 518240a9a23Smbalmer ;; 519240a9a23Smbalmeresac 520240a9a23Smbalmer 521240a9a23Smbalmerexit 0 522240a9a23Smbalmer 523240a9a23Smbalmer# Local Variables: 524240a9a23Smbalmer# mode: shell-script 525240a9a23Smbalmer# sh-indentation: 2 526240a9a23Smbalmer# eval: (add-hook 'write-file-hooks 'time-stamp) 527240a9a23Smbalmer# time-stamp-start: "scriptversion=" 528240a9a23Smbalmer# time-stamp-format: "%:y-%02m-%02d.%02H" 529240a9a23Smbalmer# time-stamp-end: "$" 530240a9a23Smbalmer# End: 531