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