depcomp revision 1fd23544
172b676d7Smrg#! /bin/sh 272b676d7Smrg# depcomp - compile a program generating dependencies as side-effects 372b676d7Smrg 41fd23544Smrgscriptversion=2007-03-29.01 572b676d7Smrg 61fd23544Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 71fd23544Smrg# Foundation, Inc. 872b676d7Smrg 972b676d7Smrg# This program is free software; you can redistribute it and/or modify 1072b676d7Smrg# it under the terms of the GNU General Public License as published by 1172b676d7Smrg# the Free Software Foundation; either version 2, or (at your option) 1272b676d7Smrg# any later version. 1372b676d7Smrg 1472b676d7Smrg# This program is distributed in the hope that it will be useful, 1572b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1672b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1772b676d7Smrg# GNU General Public License for more details. 1872b676d7Smrg 1972b676d7Smrg# You should have received a copy of the GNU General Public License 2072b676d7Smrg# along with this program; if not, write to the Free Software 2172b676d7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2272b676d7Smrg# 02110-1301, USA. 2372b676d7Smrg 2472b676d7Smrg# As a special exception to the GNU General Public License, if you 2572b676d7Smrg# distribute this file as part of a program that contains a 2672b676d7Smrg# configuration script generated by Autoconf, you may include it under 2772b676d7Smrg# the same distribution terms that you use for the rest of that program. 2872b676d7Smrg 2972b676d7Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 3072b676d7Smrg 3172b676d7Smrgcase $1 in 3272b676d7Smrg '') 3372b676d7Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3472b676d7Smrg exit 1; 3572b676d7Smrg ;; 3672b676d7Smrg -h | --h*) 3772b676d7Smrg cat <<\EOF 3872b676d7SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3972b676d7Smrg 4072b676d7SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 4172b676d7Smrgas side-effects. 4272b676d7Smrg 4372b676d7SmrgEnvironment variables: 4472b676d7Smrg depmode Dependency tracking mode. 4572b676d7Smrg source Source file read by `PROGRAMS ARGS'. 4672b676d7Smrg object Object file output by `PROGRAMS ARGS'. 4772b676d7Smrg DEPDIR directory where to store dependencies. 4872b676d7Smrg depfile Dependency file to output. 4972b676d7Smrg tmpdepfile Temporary file to use when outputing dependencies. 5072b676d7Smrg libtool Whether libtool is used (yes/no). 5172b676d7Smrg 5272b676d7SmrgReport bugs to <bug-automake@gnu.org>. 5372b676d7SmrgEOF 5472b676d7Smrg exit $? 5572b676d7Smrg ;; 5672b676d7Smrg -v | --v*) 5772b676d7Smrg echo "depcomp $scriptversion" 5872b676d7Smrg exit $? 5972b676d7Smrg ;; 6072b676d7Smrgesac 6172b676d7Smrg 6272b676d7Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6372b676d7Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6472b676d7Smrg exit 1 6572b676d7Smrgfi 6672b676d7Smrg 6772b676d7Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6872b676d7Smrgdepfile=${depfile-`echo "$object" | 6972b676d7Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 7072b676d7Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 7172b676d7Smrg 7272b676d7Smrgrm -f "$tmpdepfile" 7372b676d7Smrg 7472b676d7Smrg# Some modes work just like other modes, but use different flags. We 7572b676d7Smrg# parameterize here, but still list the modes in the big case below, 7672b676d7Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7772b676d7Smrg# here, because this file can only contain one case statement. 7872b676d7Smrgif test "$depmode" = hp; then 7972b676d7Smrg # HP compiler uses -M and no extra arg. 8072b676d7Smrg gccflag=-M 8172b676d7Smrg depmode=gcc 8272b676d7Smrgfi 8372b676d7Smrg 8472b676d7Smrgif test "$depmode" = dashXmstdout; then 8572b676d7Smrg # This is just like dashmstdout with a different argument. 8672b676d7Smrg dashmflag=-xM 8772b676d7Smrg depmode=dashmstdout 8872b676d7Smrgfi 8972b676d7Smrg 9072b676d7Smrgcase "$depmode" in 9172b676d7Smrggcc3) 9272b676d7Smrg## gcc 3 implements dependency tracking that does exactly what 9372b676d7Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 9472b676d7Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 951fd23544Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 961fd23544Smrg## the command line argument order; so add the flags where they 971fd23544Smrg## appear in depend2.am. Note that the slowdown incurred here 981fd23544Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 991fd23544Smrg for arg 1001fd23544Smrg do 1011fd23544Smrg case $arg in 1021fd23544Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1031fd23544Smrg *) set fnord "$@" "$arg" ;; 1041fd23544Smrg esac 1051fd23544Smrg shift # fnord 1061fd23544Smrg shift # $arg 1071fd23544Smrg done 1081fd23544Smrg "$@" 10972b676d7Smrg stat=$? 11072b676d7Smrg if test $stat -eq 0; then : 11172b676d7Smrg else 11272b676d7Smrg rm -f "$tmpdepfile" 11372b676d7Smrg exit $stat 11472b676d7Smrg fi 11572b676d7Smrg mv "$tmpdepfile" "$depfile" 11672b676d7Smrg ;; 11772b676d7Smrg 11872b676d7Smrggcc) 11972b676d7Smrg## There are various ways to get dependency output from gcc. Here's 12072b676d7Smrg## why we pick this rather obscure method: 12172b676d7Smrg## - Don't want to use -MD because we'd like the dependencies to end 12272b676d7Smrg## up in a subdir. Having to rename by hand is ugly. 12372b676d7Smrg## (We might end up doing this anyway to support other compilers.) 12472b676d7Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 12572b676d7Smrg## -MM, not -M (despite what the docs say). 12672b676d7Smrg## - Using -M directly means running the compiler twice (even worse 12772b676d7Smrg## than renaming). 12872b676d7Smrg if test -z "$gccflag"; then 12972b676d7Smrg gccflag=-MD, 13072b676d7Smrg fi 13172b676d7Smrg "$@" -Wp,"$gccflag$tmpdepfile" 13272b676d7Smrg stat=$? 13372b676d7Smrg if test $stat -eq 0; then : 13472b676d7Smrg else 13572b676d7Smrg rm -f "$tmpdepfile" 13672b676d7Smrg exit $stat 13772b676d7Smrg fi 13872b676d7Smrg rm -f "$depfile" 13972b676d7Smrg echo "$object : \\" > "$depfile" 14072b676d7Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 14172b676d7Smrg## The second -e expression handles DOS-style file names with drive letters. 14272b676d7Smrg sed -e 's/^[^:]*: / /' \ 14372b676d7Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 14472b676d7Smrg## This next piece of magic avoids the `deleted header file' problem. 14572b676d7Smrg## The problem is that when a header file which appears in a .P file 14672b676d7Smrg## is deleted, the dependency causes make to die (because there is 14772b676d7Smrg## typically no way to rebuild the header). We avoid this by adding 14872b676d7Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 14972b676d7Smrg## this for us directly. 15072b676d7Smrg tr ' ' ' 15172b676d7Smrg' < "$tmpdepfile" | 15272b676d7Smrg## Some versions of gcc put a space before the `:'. On the theory 15372b676d7Smrg## that the space means something, we add a space to the output as 15472b676d7Smrg## well. 15572b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 15672b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 15772b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 15872b676d7Smrg rm -f "$tmpdepfile" 15972b676d7Smrg ;; 16072b676d7Smrg 16172b676d7Smrghp) 16272b676d7Smrg # This case exists only to let depend.m4 do its work. It works by 16372b676d7Smrg # looking at the text of this script. This case will never be run, 16472b676d7Smrg # since it is checked for above. 16572b676d7Smrg exit 1 16672b676d7Smrg ;; 16772b676d7Smrg 16872b676d7Smrgsgi) 16972b676d7Smrg if test "$libtool" = yes; then 17072b676d7Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 17172b676d7Smrg else 17272b676d7Smrg "$@" -MDupdate "$tmpdepfile" 17372b676d7Smrg fi 17472b676d7Smrg stat=$? 17572b676d7Smrg if test $stat -eq 0; then : 17672b676d7Smrg else 17772b676d7Smrg rm -f "$tmpdepfile" 17872b676d7Smrg exit $stat 17972b676d7Smrg fi 18072b676d7Smrg rm -f "$depfile" 18172b676d7Smrg 18272b676d7Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 18372b676d7Smrg echo "$object : \\" > "$depfile" 18472b676d7Smrg 18572b676d7Smrg # Clip off the initial element (the dependent). Don't try to be 18672b676d7Smrg # clever and replace this with sed code, as IRIX sed won't handle 18772b676d7Smrg # lines with more than a fixed number of characters (4096 in 18872b676d7Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 18972b676d7Smrg # the IRIX cc adds comments like `#:fec' to the end of the 19072b676d7Smrg # dependency line. 19172b676d7Smrg tr ' ' ' 19272b676d7Smrg' < "$tmpdepfile" \ 19372b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 19472b676d7Smrg tr ' 19572b676d7Smrg' ' ' >> $depfile 19672b676d7Smrg echo >> $depfile 19772b676d7Smrg 19872b676d7Smrg # The second pass generates a dummy entry for each header file. 19972b676d7Smrg tr ' ' ' 20072b676d7Smrg' < "$tmpdepfile" \ 20172b676d7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20272b676d7Smrg >> $depfile 20372b676d7Smrg else 20472b676d7Smrg # The sourcefile does not contain any dependencies, so just 20572b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 20672b676d7Smrg # "include basename.Plo" scheme. 20772b676d7Smrg echo "#dummy" > "$depfile" 20872b676d7Smrg fi 20972b676d7Smrg rm -f "$tmpdepfile" 21072b676d7Smrg ;; 21172b676d7Smrg 21272b676d7Smrgaix) 21372b676d7Smrg # The C for AIX Compiler uses -M and outputs the dependencies 21472b676d7Smrg # in a .u file. In older versions, this file always lives in the 21572b676d7Smrg # current directory. Also, the AIX compiler puts `$object:' at the 21672b676d7Smrg # start of each line; $object doesn't have directory information. 21772b676d7Smrg # Version 6 uses the directory in both cases. 2181fd23544Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2191fd23544Smrg test "x$dir" = "x$object" && dir= 2201fd23544Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22172b676d7Smrg if test "$libtool" = yes; then 2221fd23544Smrg tmpdepfile1=$dir$base.u 2231fd23544Smrg tmpdepfile2=$base.u 2241fd23544Smrg tmpdepfile3=$dir.libs/$base.u 22572b676d7Smrg "$@" -Wc,-M 22672b676d7Smrg else 2271fd23544Smrg tmpdepfile1=$dir$base.u 2281fd23544Smrg tmpdepfile2=$dir$base.u 2291fd23544Smrg tmpdepfile3=$dir$base.u 23072b676d7Smrg "$@" -M 23172b676d7Smrg fi 23272b676d7Smrg stat=$? 23372b676d7Smrg 23472b676d7Smrg if test $stat -eq 0; then : 23572b676d7Smrg else 2361fd23544Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 23772b676d7Smrg exit $stat 23872b676d7Smrg fi 23972b676d7Smrg 2401fd23544Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2411fd23544Smrg do 2421fd23544Smrg test -f "$tmpdepfile" && break 2431fd23544Smrg done 24472b676d7Smrg if test -f "$tmpdepfile"; then 24572b676d7Smrg # Each line is of the form `foo.o: dependent.h'. 24672b676d7Smrg # Do two passes, one to just change these to 24772b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2481fd23544Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2491fd23544Smrg # That's a tab and a space in the []. 2501fd23544Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 25172b676d7Smrg else 25272b676d7Smrg # The sourcefile does not contain any dependencies, so just 25372b676d7Smrg # store a dummy comment line, to avoid errors with the Makefile 25472b676d7Smrg # "include basename.Plo" scheme. 25572b676d7Smrg echo "#dummy" > "$depfile" 25672b676d7Smrg fi 25772b676d7Smrg rm -f "$tmpdepfile" 25872b676d7Smrg ;; 25972b676d7Smrg 26072b676d7Smrgicc) 26172b676d7Smrg # Intel's C compiler understands `-MD -MF file'. However on 26272b676d7Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 26372b676d7Smrg # ICC 7.0 will fill foo.d with something like 26472b676d7Smrg # foo.o: sub/foo.c 26572b676d7Smrg # foo.o: sub/foo.h 26672b676d7Smrg # which is wrong. We want: 26772b676d7Smrg # sub/foo.o: sub/foo.c 26872b676d7Smrg # sub/foo.o: sub/foo.h 26972b676d7Smrg # sub/foo.c: 27072b676d7Smrg # sub/foo.h: 27172b676d7Smrg # ICC 7.1 will output 27272b676d7Smrg # foo.o: sub/foo.c sub/foo.h 27372b676d7Smrg # and will wrap long lines using \ : 27472b676d7Smrg # foo.o: sub/foo.c ... \ 27572b676d7Smrg # sub/foo.h ... \ 27672b676d7Smrg # ... 27772b676d7Smrg 27872b676d7Smrg "$@" -MD -MF "$tmpdepfile" 27972b676d7Smrg stat=$? 28072b676d7Smrg if test $stat -eq 0; then : 28172b676d7Smrg else 28272b676d7Smrg rm -f "$tmpdepfile" 28372b676d7Smrg exit $stat 28472b676d7Smrg fi 28572b676d7Smrg rm -f "$depfile" 28672b676d7Smrg # Each line is of the form `foo.o: dependent.h', 28772b676d7Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 28872b676d7Smrg # Do two passes, one to just change these to 28972b676d7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 29072b676d7Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 29172b676d7Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 29272b676d7Smrg # correctly. Breaking it into two sed invocations is a workaround. 29372b676d7Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 29472b676d7Smrg sed -e 's/$/ :/' >> "$depfile" 29572b676d7Smrg rm -f "$tmpdepfile" 29672b676d7Smrg ;; 29772b676d7Smrg 2981fd23544Smrghp2) 2991fd23544Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3001fd23544Smrg # compilers, which have integrated preprocessors. The correct option 3011fd23544Smrg # to use with these is +Maked; it writes dependencies to a file named 3021fd23544Smrg # 'foo.d', which lands next to the object file, wherever that 3031fd23544Smrg # happens to be. 3041fd23544Smrg # Much of this is similar to the tru64 case; see comments there. 3051fd23544Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3061fd23544Smrg test "x$dir" = "x$object" && dir= 3071fd23544Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3081fd23544Smrg if test "$libtool" = yes; then 3091fd23544Smrg tmpdepfile1=$dir$base.d 3101fd23544Smrg tmpdepfile2=$dir.libs/$base.d 3111fd23544Smrg "$@" -Wc,+Maked 3121fd23544Smrg else 3131fd23544Smrg tmpdepfile1=$dir$base.d 3141fd23544Smrg tmpdepfile2=$dir$base.d 3151fd23544Smrg "$@" +Maked 3161fd23544Smrg fi 3171fd23544Smrg stat=$? 3181fd23544Smrg if test $stat -eq 0; then : 3191fd23544Smrg else 3201fd23544Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3211fd23544Smrg exit $stat 3221fd23544Smrg fi 3231fd23544Smrg 3241fd23544Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3251fd23544Smrg do 3261fd23544Smrg test -f "$tmpdepfile" && break 3271fd23544Smrg done 3281fd23544Smrg if test -f "$tmpdepfile"; then 3291fd23544Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3301fd23544Smrg # Add `dependent.h:' lines. 3311fd23544Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3321fd23544Smrg else 3331fd23544Smrg echo "#dummy" > "$depfile" 3341fd23544Smrg fi 3351fd23544Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3361fd23544Smrg ;; 3371fd23544Smrg 33872b676d7Smrgtru64) 33972b676d7Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 34072b676d7Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 34172b676d7Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 34272b676d7Smrg # dependencies in `foo.d' instead, so we check for that too. 34372b676d7Smrg # Subdirectories are respected. 34472b676d7Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 34572b676d7Smrg test "x$dir" = "x$object" && dir= 34672b676d7Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 34772b676d7Smrg 34872b676d7Smrg if test "$libtool" = yes; then 34972b676d7Smrg # With Tru64 cc, shared objects can also be used to make a 3501fd23544Smrg # static library. This mechanism is used in libtool 1.4 series to 35172b676d7Smrg # handle both shared and static libraries in a single compilation. 35272b676d7Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 35372b676d7Smrg # 35472b676d7Smrg # With libtool 1.5 this exception was removed, and libtool now 35572b676d7Smrg # generates 2 separate objects for the 2 libraries. These two 3561fd23544Smrg # compilations output dependencies in $dir.libs/$base.o.d and 35772b676d7Smrg # in $dir$base.o.d. We have to check for both files, because 35872b676d7Smrg # one of the two compilations can be disabled. We should prefer 35972b676d7Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 36072b676d7Smrg # automatically cleaned when .libs/ is deleted, while ignoring 36172b676d7Smrg # the former would cause a distcleancheck panic. 36272b676d7Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 36372b676d7Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 36472b676d7Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 36572b676d7Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 36672b676d7Smrg "$@" -Wc,-MD 36772b676d7Smrg else 36872b676d7Smrg tmpdepfile1=$dir$base.o.d 36972b676d7Smrg tmpdepfile2=$dir$base.d 37072b676d7Smrg tmpdepfile3=$dir$base.d 37172b676d7Smrg tmpdepfile4=$dir$base.d 37272b676d7Smrg "$@" -MD 37372b676d7Smrg fi 37472b676d7Smrg 37572b676d7Smrg stat=$? 37672b676d7Smrg if test $stat -eq 0; then : 37772b676d7Smrg else 37872b676d7Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 37972b676d7Smrg exit $stat 38072b676d7Smrg fi 38172b676d7Smrg 38272b676d7Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 38372b676d7Smrg do 38472b676d7Smrg test -f "$tmpdepfile" && break 38572b676d7Smrg done 38672b676d7Smrg if test -f "$tmpdepfile"; then 38772b676d7Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 38872b676d7Smrg # That's a tab and a space in the []. 38972b676d7Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 39072b676d7Smrg else 39172b676d7Smrg echo "#dummy" > "$depfile" 39272b676d7Smrg fi 39372b676d7Smrg rm -f "$tmpdepfile" 39472b676d7Smrg ;; 39572b676d7Smrg 39672b676d7Smrg#nosideeffect) 39772b676d7Smrg # This comment above is used by automake to tell side-effect 39872b676d7Smrg # dependency tracking mechanisms from slower ones. 39972b676d7Smrg 40072b676d7Smrgdashmstdout) 40172b676d7Smrg # Important note: in order to support this mode, a compiler *must* 40272b676d7Smrg # always write the preprocessed file to stdout, regardless of -o. 40372b676d7Smrg "$@" || exit $? 40472b676d7Smrg 40572b676d7Smrg # Remove the call to Libtool. 40672b676d7Smrg if test "$libtool" = yes; then 40772b676d7Smrg while test $1 != '--mode=compile'; do 40872b676d7Smrg shift 40972b676d7Smrg done 41072b676d7Smrg shift 41172b676d7Smrg fi 41272b676d7Smrg 41372b676d7Smrg # Remove `-o $object'. 41472b676d7Smrg IFS=" " 41572b676d7Smrg for arg 41672b676d7Smrg do 41772b676d7Smrg case $arg in 41872b676d7Smrg -o) 41972b676d7Smrg shift 42072b676d7Smrg ;; 42172b676d7Smrg $object) 42272b676d7Smrg shift 42372b676d7Smrg ;; 42472b676d7Smrg *) 42572b676d7Smrg set fnord "$@" "$arg" 42672b676d7Smrg shift # fnord 42772b676d7Smrg shift # $arg 42872b676d7Smrg ;; 42972b676d7Smrg esac 43072b676d7Smrg done 43172b676d7Smrg 43272b676d7Smrg test -z "$dashmflag" && dashmflag=-M 43372b676d7Smrg # Require at least two characters before searching for `:' 43472b676d7Smrg # in the target name. This is to cope with DOS-style filenames: 43572b676d7Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 43672b676d7Smrg "$@" $dashmflag | 43772b676d7Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 43872b676d7Smrg rm -f "$depfile" 43972b676d7Smrg cat < "$tmpdepfile" > "$depfile" 44072b676d7Smrg tr ' ' ' 44172b676d7Smrg' < "$tmpdepfile" | \ 44272b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 44372b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 44472b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 44572b676d7Smrg rm -f "$tmpdepfile" 44672b676d7Smrg ;; 44772b676d7Smrg 44872b676d7SmrgdashXmstdout) 44972b676d7Smrg # This case only exists to satisfy depend.m4. It is never actually 45072b676d7Smrg # run, as this mode is specially recognized in the preamble. 45172b676d7Smrg exit 1 45272b676d7Smrg ;; 45372b676d7Smrg 45472b676d7Smrgmakedepend) 45572b676d7Smrg "$@" || exit $? 45672b676d7Smrg # Remove any Libtool call 45772b676d7Smrg if test "$libtool" = yes; then 45872b676d7Smrg while test $1 != '--mode=compile'; do 45972b676d7Smrg shift 46072b676d7Smrg done 46172b676d7Smrg shift 46272b676d7Smrg fi 46372b676d7Smrg # X makedepend 46472b676d7Smrg shift 46572b676d7Smrg cleared=no 46672b676d7Smrg for arg in "$@"; do 46772b676d7Smrg case $cleared in 46872b676d7Smrg no) 46972b676d7Smrg set ""; shift 47072b676d7Smrg cleared=yes ;; 47172b676d7Smrg esac 47272b676d7Smrg case "$arg" in 47372b676d7Smrg -D*|-I*) 47472b676d7Smrg set fnord "$@" "$arg"; shift ;; 47572b676d7Smrg # Strip any option that makedepend may not understand. Remove 47672b676d7Smrg # the object too, otherwise makedepend will parse it as a source file. 47772b676d7Smrg -*|$object) 47872b676d7Smrg ;; 47972b676d7Smrg *) 48072b676d7Smrg set fnord "$@" "$arg"; shift ;; 48172b676d7Smrg esac 48272b676d7Smrg done 48372b676d7Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 48472b676d7Smrg touch "$tmpdepfile" 48572b676d7Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 48672b676d7Smrg rm -f "$depfile" 48772b676d7Smrg cat < "$tmpdepfile" > "$depfile" 48872b676d7Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 48972b676d7Smrg' | \ 49072b676d7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 49172b676d7Smrg## correctly. Breaking it into two sed invocations is a workaround. 49272b676d7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 49372b676d7Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 49472b676d7Smrg ;; 49572b676d7Smrg 49672b676d7Smrgcpp) 49772b676d7Smrg # Important note: in order to support this mode, a compiler *must* 49872b676d7Smrg # always write the preprocessed file to stdout. 49972b676d7Smrg "$@" || exit $? 50072b676d7Smrg 50172b676d7Smrg # Remove the call to Libtool. 50272b676d7Smrg if test "$libtool" = yes; then 50372b676d7Smrg while test $1 != '--mode=compile'; do 50472b676d7Smrg shift 50572b676d7Smrg done 50672b676d7Smrg shift 50772b676d7Smrg fi 50872b676d7Smrg 50972b676d7Smrg # Remove `-o $object'. 51072b676d7Smrg IFS=" " 51172b676d7Smrg for arg 51272b676d7Smrg do 51372b676d7Smrg case $arg in 51472b676d7Smrg -o) 51572b676d7Smrg shift 51672b676d7Smrg ;; 51772b676d7Smrg $object) 51872b676d7Smrg shift 51972b676d7Smrg ;; 52072b676d7Smrg *) 52172b676d7Smrg set fnord "$@" "$arg" 52272b676d7Smrg shift # fnord 52372b676d7Smrg shift # $arg 52472b676d7Smrg ;; 52572b676d7Smrg esac 52672b676d7Smrg done 52772b676d7Smrg 52872b676d7Smrg "$@" -E | 52972b676d7Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 53072b676d7Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 53172b676d7Smrg sed '$ s: \\$::' > "$tmpdepfile" 53272b676d7Smrg rm -f "$depfile" 53372b676d7Smrg echo "$object : \\" > "$depfile" 53472b676d7Smrg cat < "$tmpdepfile" >> "$depfile" 53572b676d7Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 53672b676d7Smrg rm -f "$tmpdepfile" 53772b676d7Smrg ;; 53872b676d7Smrg 53972b676d7Smrgmsvisualcpp) 54072b676d7Smrg # Important note: in order to support this mode, a compiler *must* 54172b676d7Smrg # always write the preprocessed file to stdout, regardless of -o, 54272b676d7Smrg # because we must use -o when running libtool. 54372b676d7Smrg "$@" || exit $? 54472b676d7Smrg IFS=" " 54572b676d7Smrg for arg 54672b676d7Smrg do 54772b676d7Smrg case "$arg" in 54872b676d7Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 54972b676d7Smrg set fnord "$@" 55072b676d7Smrg shift 55172b676d7Smrg shift 55272b676d7Smrg ;; 55372b676d7Smrg *) 55472b676d7Smrg set fnord "$@" "$arg" 55572b676d7Smrg shift 55672b676d7Smrg shift 55772b676d7Smrg ;; 55872b676d7Smrg esac 55972b676d7Smrg done 56072b676d7Smrg "$@" -E | 56172b676d7Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 56272b676d7Smrg rm -f "$depfile" 56372b676d7Smrg echo "$object : \\" > "$depfile" 56472b676d7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 56572b676d7Smrg echo " " >> "$depfile" 56672b676d7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 56772b676d7Smrg rm -f "$tmpdepfile" 56872b676d7Smrg ;; 56972b676d7Smrg 57072b676d7Smrgnone) 57172b676d7Smrg exec "$@" 57272b676d7Smrg ;; 57372b676d7Smrg 57472b676d7Smrg*) 57572b676d7Smrg echo "Unknown depmode $depmode" 1>&2 57672b676d7Smrg exit 1 57772b676d7Smrg ;; 57872b676d7Smrgesac 57972b676d7Smrg 58072b676d7Smrgexit 0 58172b676d7Smrg 58272b676d7Smrg# Local Variables: 58372b676d7Smrg# mode: shell-script 58472b676d7Smrg# sh-indentation: 2 58572b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 58672b676d7Smrg# time-stamp-start: "scriptversion=" 58772b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 58872b676d7Smrg# time-stamp-end: "$" 58972b676d7Smrg# End: 590