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