depcomp revision 9027f4a0
19027f4a0Smrg#! /bin/sh 29027f4a0Smrg# depcomp - compile a program generating dependencies as side-effects 39027f4a0Smrg 49027f4a0Smrgscriptversion=2005-07-09.11 59027f4a0Smrg 69027f4a0Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 79027f4a0Smrg 89027f4a0Smrg# This program is free software; you can redistribute it and/or modify 99027f4a0Smrg# it under the terms of the GNU General Public License as published by 109027f4a0Smrg# the Free Software Foundation; either version 2, or (at your option) 119027f4a0Smrg# any later version. 129027f4a0Smrg 139027f4a0Smrg# This program is distributed in the hope that it will be useful, 149027f4a0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 159027f4a0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 169027f4a0Smrg# GNU General Public License for more details. 179027f4a0Smrg 189027f4a0Smrg# You should have received a copy of the GNU General Public License 199027f4a0Smrg# along with this program; if not, write to the Free Software 209027f4a0Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 219027f4a0Smrg# 02110-1301, USA. 229027f4a0Smrg 239027f4a0Smrg# As a special exception to the GNU General Public License, if you 249027f4a0Smrg# distribute this file as part of a program that contains a 259027f4a0Smrg# configuration script generated by Autoconf, you may include it under 269027f4a0Smrg# the same distribution terms that you use for the rest of that program. 279027f4a0Smrg 289027f4a0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 299027f4a0Smrg 309027f4a0Smrgcase $1 in 319027f4a0Smrg '') 329027f4a0Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 339027f4a0Smrg exit 1; 349027f4a0Smrg ;; 359027f4a0Smrg -h | --h*) 369027f4a0Smrg cat <<\EOF 379027f4a0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 389027f4a0Smrg 399027f4a0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 409027f4a0Smrgas side-effects. 419027f4a0Smrg 429027f4a0SmrgEnvironment variables: 439027f4a0Smrg depmode Dependency tracking mode. 449027f4a0Smrg source Source file read by `PROGRAMS ARGS'. 459027f4a0Smrg object Object file output by `PROGRAMS ARGS'. 469027f4a0Smrg DEPDIR directory where to store dependencies. 479027f4a0Smrg depfile Dependency file to output. 489027f4a0Smrg tmpdepfile Temporary file to use when outputing dependencies. 499027f4a0Smrg libtool Whether libtool is used (yes/no). 509027f4a0Smrg 519027f4a0SmrgReport bugs to <bug-automake@gnu.org>. 529027f4a0SmrgEOF 539027f4a0Smrg exit $? 549027f4a0Smrg ;; 559027f4a0Smrg -v | --v*) 569027f4a0Smrg echo "depcomp $scriptversion" 579027f4a0Smrg exit $? 589027f4a0Smrg ;; 599027f4a0Smrgesac 609027f4a0Smrg 619027f4a0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 629027f4a0Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 639027f4a0Smrg exit 1 649027f4a0Smrgfi 659027f4a0Smrg 669027f4a0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 679027f4a0Smrgdepfile=${depfile-`echo "$object" | 689027f4a0Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 699027f4a0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 709027f4a0Smrg 719027f4a0Smrgrm -f "$tmpdepfile" 729027f4a0Smrg 739027f4a0Smrg# Some modes work just like other modes, but use different flags. We 749027f4a0Smrg# parameterize here, but still list the modes in the big case below, 759027f4a0Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 769027f4a0Smrg# here, because this file can only contain one case statement. 779027f4a0Smrgif test "$depmode" = hp; then 789027f4a0Smrg # HP compiler uses -M and no extra arg. 799027f4a0Smrg gccflag=-M 809027f4a0Smrg depmode=gcc 819027f4a0Smrgfi 829027f4a0Smrg 839027f4a0Smrgif test "$depmode" = dashXmstdout; then 849027f4a0Smrg # This is just like dashmstdout with a different argument. 859027f4a0Smrg dashmflag=-xM 869027f4a0Smrg depmode=dashmstdout 879027f4a0Smrgfi 889027f4a0Smrg 899027f4a0Smrgcase "$depmode" in 909027f4a0Smrggcc3) 919027f4a0Smrg## gcc 3 implements dependency tracking that does exactly what 929027f4a0Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 939027f4a0Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 949027f4a0Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 959027f4a0Smrg stat=$? 969027f4a0Smrg if test $stat -eq 0; then : 979027f4a0Smrg else 989027f4a0Smrg rm -f "$tmpdepfile" 999027f4a0Smrg exit $stat 1009027f4a0Smrg fi 1019027f4a0Smrg mv "$tmpdepfile" "$depfile" 1029027f4a0Smrg ;; 1039027f4a0Smrg 1049027f4a0Smrggcc) 1059027f4a0Smrg## There are various ways to get dependency output from gcc. Here's 1069027f4a0Smrg## why we pick this rather obscure method: 1079027f4a0Smrg## - Don't want to use -MD because we'd like the dependencies to end 1089027f4a0Smrg## up in a subdir. Having to rename by hand is ugly. 1099027f4a0Smrg## (We might end up doing this anyway to support other compilers.) 1109027f4a0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1119027f4a0Smrg## -MM, not -M (despite what the docs say). 1129027f4a0Smrg## - Using -M directly means running the compiler twice (even worse 1139027f4a0Smrg## than renaming). 1149027f4a0Smrg if test -z "$gccflag"; then 1159027f4a0Smrg gccflag=-MD, 1169027f4a0Smrg fi 1179027f4a0Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1189027f4a0Smrg stat=$? 1199027f4a0Smrg if test $stat -eq 0; then : 1209027f4a0Smrg else 1219027f4a0Smrg rm -f "$tmpdepfile" 1229027f4a0Smrg exit $stat 1239027f4a0Smrg fi 1249027f4a0Smrg rm -f "$depfile" 1259027f4a0Smrg echo "$object : \\" > "$depfile" 1269027f4a0Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1279027f4a0Smrg## The second -e expression handles DOS-style file names with drive letters. 1289027f4a0Smrg sed -e 's/^[^:]*: / /' \ 1299027f4a0Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1309027f4a0Smrg## This next piece of magic avoids the `deleted header file' problem. 1319027f4a0Smrg## The problem is that when a header file which appears in a .P file 1329027f4a0Smrg## is deleted, the dependency causes make to die (because there is 1339027f4a0Smrg## typically no way to rebuild the header). We avoid this by adding 1349027f4a0Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1359027f4a0Smrg## this for us directly. 1369027f4a0Smrg tr ' ' ' 1379027f4a0Smrg' < "$tmpdepfile" | 1389027f4a0Smrg## Some versions of gcc put a space before the `:'. On the theory 1399027f4a0Smrg## that the space means something, we add a space to the output as 1409027f4a0Smrg## well. 1419027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1429027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 1439027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1449027f4a0Smrg rm -f "$tmpdepfile" 1459027f4a0Smrg ;; 1469027f4a0Smrg 1479027f4a0Smrghp) 1489027f4a0Smrg # This case exists only to let depend.m4 do its work. It works by 1499027f4a0Smrg # looking at the text of this script. This case will never be run, 1509027f4a0Smrg # since it is checked for above. 1519027f4a0Smrg exit 1 1529027f4a0Smrg ;; 1539027f4a0Smrg 1549027f4a0Smrgsgi) 1559027f4a0Smrg if test "$libtool" = yes; then 1569027f4a0Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1579027f4a0Smrg else 1589027f4a0Smrg "$@" -MDupdate "$tmpdepfile" 1599027f4a0Smrg fi 1609027f4a0Smrg stat=$? 1619027f4a0Smrg if test $stat -eq 0; then : 1629027f4a0Smrg else 1639027f4a0Smrg rm -f "$tmpdepfile" 1649027f4a0Smrg exit $stat 1659027f4a0Smrg fi 1669027f4a0Smrg rm -f "$depfile" 1679027f4a0Smrg 1689027f4a0Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1699027f4a0Smrg echo "$object : \\" > "$depfile" 1709027f4a0Smrg 1719027f4a0Smrg # Clip off the initial element (the dependent). Don't try to be 1729027f4a0Smrg # clever and replace this with sed code, as IRIX sed won't handle 1739027f4a0Smrg # lines with more than a fixed number of characters (4096 in 1749027f4a0Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1759027f4a0Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1769027f4a0Smrg # dependency line. 1779027f4a0Smrg tr ' ' ' 1789027f4a0Smrg' < "$tmpdepfile" \ 1799027f4a0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1809027f4a0Smrg tr ' 1819027f4a0Smrg' ' ' >> $depfile 1829027f4a0Smrg echo >> $depfile 1839027f4a0Smrg 1849027f4a0Smrg # The second pass generates a dummy entry for each header file. 1859027f4a0Smrg tr ' ' ' 1869027f4a0Smrg' < "$tmpdepfile" \ 1879027f4a0Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 1889027f4a0Smrg >> $depfile 1899027f4a0Smrg else 1909027f4a0Smrg # The sourcefile does not contain any dependencies, so just 1919027f4a0Smrg # store a dummy comment line, to avoid errors with the Makefile 1929027f4a0Smrg # "include basename.Plo" scheme. 1939027f4a0Smrg echo "#dummy" > "$depfile" 1949027f4a0Smrg fi 1959027f4a0Smrg rm -f "$tmpdepfile" 1969027f4a0Smrg ;; 1979027f4a0Smrg 1989027f4a0Smrgaix) 1999027f4a0Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2009027f4a0Smrg # in a .u file. In older versions, this file always lives in the 2019027f4a0Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2029027f4a0Smrg # start of each line; $object doesn't have directory information. 2039027f4a0Smrg # Version 6 uses the directory in both cases. 2049027f4a0Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 2059027f4a0Smrg tmpdepfile="$stripped.u" 2069027f4a0Smrg if test "$libtool" = yes; then 2079027f4a0Smrg "$@" -Wc,-M 2089027f4a0Smrg else 2099027f4a0Smrg "$@" -M 2109027f4a0Smrg fi 2119027f4a0Smrg stat=$? 2129027f4a0Smrg 2139027f4a0Smrg if test -f "$tmpdepfile"; then : 2149027f4a0Smrg else 2159027f4a0Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 2169027f4a0Smrg tmpdepfile="$stripped.u" 2179027f4a0Smrg fi 2189027f4a0Smrg 2199027f4a0Smrg if test $stat -eq 0; then : 2209027f4a0Smrg else 2219027f4a0Smrg rm -f "$tmpdepfile" 2229027f4a0Smrg exit $stat 2239027f4a0Smrg fi 2249027f4a0Smrg 2259027f4a0Smrg if test -f "$tmpdepfile"; then 2269027f4a0Smrg outname="$stripped.o" 2279027f4a0Smrg # Each line is of the form `foo.o: dependent.h'. 2289027f4a0Smrg # Do two passes, one to just change these to 2299027f4a0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2309027f4a0Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 2319027f4a0Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 2329027f4a0Smrg else 2339027f4a0Smrg # The sourcefile does not contain any dependencies, so just 2349027f4a0Smrg # store a dummy comment line, to avoid errors with the Makefile 2359027f4a0Smrg # "include basename.Plo" scheme. 2369027f4a0Smrg echo "#dummy" > "$depfile" 2379027f4a0Smrg fi 2389027f4a0Smrg rm -f "$tmpdepfile" 2399027f4a0Smrg ;; 2409027f4a0Smrg 2419027f4a0Smrgicc) 2429027f4a0Smrg # Intel's C compiler understands `-MD -MF file'. However on 2439027f4a0Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2449027f4a0Smrg # ICC 7.0 will fill foo.d with something like 2459027f4a0Smrg # foo.o: sub/foo.c 2469027f4a0Smrg # foo.o: sub/foo.h 2479027f4a0Smrg # which is wrong. We want: 2489027f4a0Smrg # sub/foo.o: sub/foo.c 2499027f4a0Smrg # sub/foo.o: sub/foo.h 2509027f4a0Smrg # sub/foo.c: 2519027f4a0Smrg # sub/foo.h: 2529027f4a0Smrg # ICC 7.1 will output 2539027f4a0Smrg # foo.o: sub/foo.c sub/foo.h 2549027f4a0Smrg # and will wrap long lines using \ : 2559027f4a0Smrg # foo.o: sub/foo.c ... \ 2569027f4a0Smrg # sub/foo.h ... \ 2579027f4a0Smrg # ... 2589027f4a0Smrg 2599027f4a0Smrg "$@" -MD -MF "$tmpdepfile" 2609027f4a0Smrg stat=$? 2619027f4a0Smrg if test $stat -eq 0; then : 2629027f4a0Smrg else 2639027f4a0Smrg rm -f "$tmpdepfile" 2649027f4a0Smrg exit $stat 2659027f4a0Smrg fi 2669027f4a0Smrg rm -f "$depfile" 2679027f4a0Smrg # Each line is of the form `foo.o: dependent.h', 2689027f4a0Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2699027f4a0Smrg # Do two passes, one to just change these to 2709027f4a0Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2719027f4a0Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2729027f4a0Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2739027f4a0Smrg # correctly. Breaking it into two sed invocations is a workaround. 2749027f4a0Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2759027f4a0Smrg sed -e 's/$/ :/' >> "$depfile" 2769027f4a0Smrg rm -f "$tmpdepfile" 2779027f4a0Smrg ;; 2789027f4a0Smrg 2799027f4a0Smrgtru64) 2809027f4a0Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 2819027f4a0Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 2829027f4a0Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 2839027f4a0Smrg # dependencies in `foo.d' instead, so we check for that too. 2849027f4a0Smrg # Subdirectories are respected. 2859027f4a0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2869027f4a0Smrg test "x$dir" = "x$object" && dir= 2879027f4a0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2889027f4a0Smrg 2899027f4a0Smrg if test "$libtool" = yes; then 2909027f4a0Smrg # With Tru64 cc, shared objects can also be used to make a 2919027f4a0Smrg # static library. This mecanism is used in libtool 1.4 series to 2929027f4a0Smrg # handle both shared and static libraries in a single compilation. 2939027f4a0Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 2949027f4a0Smrg # 2959027f4a0Smrg # With libtool 1.5 this exception was removed, and libtool now 2969027f4a0Smrg # generates 2 separate objects for the 2 libraries. These two 2979027f4a0Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 2989027f4a0Smrg # in $dir$base.o.d. We have to check for both files, because 2999027f4a0Smrg # one of the two compilations can be disabled. We should prefer 3009027f4a0Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3019027f4a0Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3029027f4a0Smrg # the former would cause a distcleancheck panic. 3039027f4a0Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3049027f4a0Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3059027f4a0Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3069027f4a0Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3079027f4a0Smrg "$@" -Wc,-MD 3089027f4a0Smrg else 3099027f4a0Smrg tmpdepfile1=$dir$base.o.d 3109027f4a0Smrg tmpdepfile2=$dir$base.d 3119027f4a0Smrg tmpdepfile3=$dir$base.d 3129027f4a0Smrg tmpdepfile4=$dir$base.d 3139027f4a0Smrg "$@" -MD 3149027f4a0Smrg fi 3159027f4a0Smrg 3169027f4a0Smrg stat=$? 3179027f4a0Smrg if test $stat -eq 0; then : 3189027f4a0Smrg else 3199027f4a0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3209027f4a0Smrg exit $stat 3219027f4a0Smrg fi 3229027f4a0Smrg 3239027f4a0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3249027f4a0Smrg do 3259027f4a0Smrg test -f "$tmpdepfile" && break 3269027f4a0Smrg done 3279027f4a0Smrg if test -f "$tmpdepfile"; then 3289027f4a0Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3299027f4a0Smrg # That's a tab and a space in the []. 3309027f4a0Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3319027f4a0Smrg else 3329027f4a0Smrg echo "#dummy" > "$depfile" 3339027f4a0Smrg fi 3349027f4a0Smrg rm -f "$tmpdepfile" 3359027f4a0Smrg ;; 3369027f4a0Smrg 3379027f4a0Smrg#nosideeffect) 3389027f4a0Smrg # This comment above is used by automake to tell side-effect 3399027f4a0Smrg # dependency tracking mechanisms from slower ones. 3409027f4a0Smrg 3419027f4a0Smrgdashmstdout) 3429027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 3439027f4a0Smrg # always write the preprocessed file to stdout, regardless of -o. 3449027f4a0Smrg "$@" || exit $? 3459027f4a0Smrg 3469027f4a0Smrg # Remove the call to Libtool. 3479027f4a0Smrg if test "$libtool" = yes; then 3489027f4a0Smrg while test $1 != '--mode=compile'; do 3499027f4a0Smrg shift 3509027f4a0Smrg done 3519027f4a0Smrg shift 3529027f4a0Smrg fi 3539027f4a0Smrg 3549027f4a0Smrg # Remove `-o $object'. 3559027f4a0Smrg IFS=" " 3569027f4a0Smrg for arg 3579027f4a0Smrg do 3589027f4a0Smrg case $arg in 3599027f4a0Smrg -o) 3609027f4a0Smrg shift 3619027f4a0Smrg ;; 3629027f4a0Smrg $object) 3639027f4a0Smrg shift 3649027f4a0Smrg ;; 3659027f4a0Smrg *) 3669027f4a0Smrg set fnord "$@" "$arg" 3679027f4a0Smrg shift # fnord 3689027f4a0Smrg shift # $arg 3699027f4a0Smrg ;; 3709027f4a0Smrg esac 3719027f4a0Smrg done 3729027f4a0Smrg 3739027f4a0Smrg test -z "$dashmflag" && dashmflag=-M 3749027f4a0Smrg # Require at least two characters before searching for `:' 3759027f4a0Smrg # in the target name. This is to cope with DOS-style filenames: 3769027f4a0Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 3779027f4a0Smrg "$@" $dashmflag | 3789027f4a0Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 3799027f4a0Smrg rm -f "$depfile" 3809027f4a0Smrg cat < "$tmpdepfile" > "$depfile" 3819027f4a0Smrg tr ' ' ' 3829027f4a0Smrg' < "$tmpdepfile" | \ 3839027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 3849027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 3859027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 3869027f4a0Smrg rm -f "$tmpdepfile" 3879027f4a0Smrg ;; 3889027f4a0Smrg 3899027f4a0SmrgdashXmstdout) 3909027f4a0Smrg # This case only exists to satisfy depend.m4. It is never actually 3919027f4a0Smrg # run, as this mode is specially recognized in the preamble. 3929027f4a0Smrg exit 1 3939027f4a0Smrg ;; 3949027f4a0Smrg 3959027f4a0Smrgmakedepend) 3969027f4a0Smrg "$@" || exit $? 3979027f4a0Smrg # Remove any Libtool call 3989027f4a0Smrg if test "$libtool" = yes; then 3999027f4a0Smrg while test $1 != '--mode=compile'; do 4009027f4a0Smrg shift 4019027f4a0Smrg done 4029027f4a0Smrg shift 4039027f4a0Smrg fi 4049027f4a0Smrg # X makedepend 4059027f4a0Smrg shift 4069027f4a0Smrg cleared=no 4079027f4a0Smrg for arg in "$@"; do 4089027f4a0Smrg case $cleared in 4099027f4a0Smrg no) 4109027f4a0Smrg set ""; shift 4119027f4a0Smrg cleared=yes ;; 4129027f4a0Smrg esac 4139027f4a0Smrg case "$arg" in 4149027f4a0Smrg -D*|-I*) 4159027f4a0Smrg set fnord "$@" "$arg"; shift ;; 4169027f4a0Smrg # Strip any option that makedepend may not understand. Remove 4179027f4a0Smrg # the object too, otherwise makedepend will parse it as a source file. 4189027f4a0Smrg -*|$object) 4199027f4a0Smrg ;; 4209027f4a0Smrg *) 4219027f4a0Smrg set fnord "$@" "$arg"; shift ;; 4229027f4a0Smrg esac 4239027f4a0Smrg done 4249027f4a0Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 4259027f4a0Smrg touch "$tmpdepfile" 4269027f4a0Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4279027f4a0Smrg rm -f "$depfile" 4289027f4a0Smrg cat < "$tmpdepfile" > "$depfile" 4299027f4a0Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 4309027f4a0Smrg' | \ 4319027f4a0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4329027f4a0Smrg## correctly. Breaking it into two sed invocations is a workaround. 4339027f4a0Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4349027f4a0Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 4359027f4a0Smrg ;; 4369027f4a0Smrg 4379027f4a0Smrgcpp) 4389027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 4399027f4a0Smrg # always write the preprocessed file to stdout. 4409027f4a0Smrg "$@" || exit $? 4419027f4a0Smrg 4429027f4a0Smrg # Remove the call to Libtool. 4439027f4a0Smrg if test "$libtool" = yes; then 4449027f4a0Smrg while test $1 != '--mode=compile'; do 4459027f4a0Smrg shift 4469027f4a0Smrg done 4479027f4a0Smrg shift 4489027f4a0Smrg fi 4499027f4a0Smrg 4509027f4a0Smrg # Remove `-o $object'. 4519027f4a0Smrg IFS=" " 4529027f4a0Smrg for arg 4539027f4a0Smrg do 4549027f4a0Smrg case $arg in 4559027f4a0Smrg -o) 4569027f4a0Smrg shift 4579027f4a0Smrg ;; 4589027f4a0Smrg $object) 4599027f4a0Smrg shift 4609027f4a0Smrg ;; 4619027f4a0Smrg *) 4629027f4a0Smrg set fnord "$@" "$arg" 4639027f4a0Smrg shift # fnord 4649027f4a0Smrg shift # $arg 4659027f4a0Smrg ;; 4669027f4a0Smrg esac 4679027f4a0Smrg done 4689027f4a0Smrg 4699027f4a0Smrg "$@" -E | 4709027f4a0Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 4719027f4a0Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 4729027f4a0Smrg sed '$ s: \\$::' > "$tmpdepfile" 4739027f4a0Smrg rm -f "$depfile" 4749027f4a0Smrg echo "$object : \\" > "$depfile" 4759027f4a0Smrg cat < "$tmpdepfile" >> "$depfile" 4769027f4a0Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 4779027f4a0Smrg rm -f "$tmpdepfile" 4789027f4a0Smrg ;; 4799027f4a0Smrg 4809027f4a0Smrgmsvisualcpp) 4819027f4a0Smrg # Important note: in order to support this mode, a compiler *must* 4829027f4a0Smrg # always write the preprocessed file to stdout, regardless of -o, 4839027f4a0Smrg # because we must use -o when running libtool. 4849027f4a0Smrg "$@" || exit $? 4859027f4a0Smrg IFS=" " 4869027f4a0Smrg for arg 4879027f4a0Smrg do 4889027f4a0Smrg case "$arg" in 4899027f4a0Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 4909027f4a0Smrg set fnord "$@" 4919027f4a0Smrg shift 4929027f4a0Smrg shift 4939027f4a0Smrg ;; 4949027f4a0Smrg *) 4959027f4a0Smrg set fnord "$@" "$arg" 4969027f4a0Smrg shift 4979027f4a0Smrg shift 4989027f4a0Smrg ;; 4999027f4a0Smrg esac 5009027f4a0Smrg done 5019027f4a0Smrg "$@" -E | 5029027f4a0Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 5039027f4a0Smrg rm -f "$depfile" 5049027f4a0Smrg echo "$object : \\" > "$depfile" 5059027f4a0Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5069027f4a0Smrg echo " " >> "$depfile" 5079027f4a0Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5089027f4a0Smrg rm -f "$tmpdepfile" 5099027f4a0Smrg ;; 5109027f4a0Smrg 5119027f4a0Smrgnone) 5129027f4a0Smrg exec "$@" 5139027f4a0Smrg ;; 5149027f4a0Smrg 5159027f4a0Smrg*) 5169027f4a0Smrg echo "Unknown depmode $depmode" 1>&2 5179027f4a0Smrg exit 1 5189027f4a0Smrg ;; 5199027f4a0Smrgesac 5209027f4a0Smrg 5219027f4a0Smrgexit 0 5229027f4a0Smrg 5239027f4a0Smrg# Local Variables: 5249027f4a0Smrg# mode: shell-script 5259027f4a0Smrg# sh-indentation: 2 5269027f4a0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 5279027f4a0Smrg# time-stamp-start: "scriptversion=" 5289027f4a0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 5299027f4a0Smrg# time-stamp-end: "$" 5309027f4a0Smrg# End: 531