17c478bd9Sstevel@tonic-gate#! /bin/sh 27c478bd9Sstevel@tonic-gate# depcomp - compile a program generating dependencies as side-effects 37c478bd9Sstevel@tonic-gate 4*1b8adde7SWilliam Kucharskiscriptversion=2004-05-31.23 57c478bd9Sstevel@tonic-gate 6*1b8adde7SWilliam Kucharski# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. 77c478bd9Sstevel@tonic-gate 87c478bd9Sstevel@tonic-gate# This program is free software; you can redistribute it and/or modify 97c478bd9Sstevel@tonic-gate# it under the terms of the GNU General Public License as published by 107c478bd9Sstevel@tonic-gate# the Free Software Foundation; either version 2, or (at your option) 117c478bd9Sstevel@tonic-gate# any later version. 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate# This program is distributed in the hope that it will be useful, 147c478bd9Sstevel@tonic-gate# but WITHOUT ANY WARRANTY; without even the implied warranty of 157c478bd9Sstevel@tonic-gate# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 167c478bd9Sstevel@tonic-gate# GNU General Public License for more details. 177c478bd9Sstevel@tonic-gate 187c478bd9Sstevel@tonic-gate# You should have received a copy of the GNU General Public License 197c478bd9Sstevel@tonic-gate# along with this program; if not, write to the Free Software 207c478bd9Sstevel@tonic-gate# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 217c478bd9Sstevel@tonic-gate# 02111-1307, USA. 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate# As a special exception to the GNU General Public License, if you 247c478bd9Sstevel@tonic-gate# distribute this file as part of a program that contains a 257c478bd9Sstevel@tonic-gate# configuration script generated by Autoconf, you may include it under 267c478bd9Sstevel@tonic-gate# the same distribution terms that you use for the rest of that program. 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gatecase $1 in 317c478bd9Sstevel@tonic-gate '') 327c478bd9Sstevel@tonic-gate echo "$0: No command. Try \`$0 --help' for more information." 1>&2 337c478bd9Sstevel@tonic-gate exit 1; 347c478bd9Sstevel@tonic-gate ;; 357c478bd9Sstevel@tonic-gate -h | --h*) 367c478bd9Sstevel@tonic-gate cat <<\EOF 377c478bd9Sstevel@tonic-gateUsage: depcomp [--help] [--version] PROGRAM [ARGS] 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gateRun PROGRAMS ARGS to compile a file, generating dependencies 407c478bd9Sstevel@tonic-gateas side-effects. 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gateEnvironment variables: 437c478bd9Sstevel@tonic-gate depmode Dependency tracking mode. 447c478bd9Sstevel@tonic-gate source Source file read by `PROGRAMS ARGS'. 457c478bd9Sstevel@tonic-gate object Object file output by `PROGRAMS ARGS'. 46*1b8adde7SWilliam Kucharski DEPDIR directory where to store dependencies. 477c478bd9Sstevel@tonic-gate depfile Dependency file to output. 487c478bd9Sstevel@tonic-gate tmpdepfile Temporary file to use when outputing dependencies. 497c478bd9Sstevel@tonic-gate libtool Whether libtool is used (yes/no). 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gateReport bugs to <bug-automake@gnu.org>. 527c478bd9Sstevel@tonic-gateEOF 537c478bd9Sstevel@tonic-gate exit 0 547c478bd9Sstevel@tonic-gate ;; 557c478bd9Sstevel@tonic-gate -v | --v*) 567c478bd9Sstevel@tonic-gate echo "depcomp $scriptversion" 577c478bd9Sstevel@tonic-gate exit 0 587c478bd9Sstevel@tonic-gate ;; 597c478bd9Sstevel@tonic-gateesac 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gateif test -z "$depmode" || test -z "$source" || test -z "$object"; then 627c478bd9Sstevel@tonic-gate echo "depcomp: Variables source, object and depmode must be set" 1>&2 637c478bd9Sstevel@tonic-gate exit 1 647c478bd9Sstevel@tonic-gatefi 657c478bd9Sstevel@tonic-gate 66*1b8adde7SWilliam Kucharski# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67*1b8adde7SWilliam Kucharskidepfile=${depfile-`echo "$object" | 68*1b8adde7SWilliam Kucharski sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 697c478bd9Sstevel@tonic-gatetmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gaterm -f "$tmpdepfile" 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate# Some modes work just like other modes, but use different flags. We 747c478bd9Sstevel@tonic-gate# parameterize here, but still list the modes in the big case below, 757c478bd9Sstevel@tonic-gate# to make depend.m4 easier to write. Note that we *cannot* use a case 767c478bd9Sstevel@tonic-gate# here, because this file can only contain one case statement. 777c478bd9Sstevel@tonic-gateif test "$depmode" = hp; then 787c478bd9Sstevel@tonic-gate # HP compiler uses -M and no extra arg. 797c478bd9Sstevel@tonic-gate gccflag=-M 807c478bd9Sstevel@tonic-gate depmode=gcc 817c478bd9Sstevel@tonic-gatefi 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gateif test "$depmode" = dashXmstdout; then 847c478bd9Sstevel@tonic-gate # This is just like dashmstdout with a different argument. 857c478bd9Sstevel@tonic-gate dashmflag=-xM 867c478bd9Sstevel@tonic-gate depmode=dashmstdout 877c478bd9Sstevel@tonic-gatefi 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gatecase "$depmode" in 907c478bd9Sstevel@tonic-gategcc3) 917c478bd9Sstevel@tonic-gate## gcc 3 implements dependency tracking that does exactly what 927c478bd9Sstevel@tonic-gate## we want. Yay! Note: for some reason libtool 1.4 doesn't like 937c478bd9Sstevel@tonic-gate## it if -MD -MP comes after the -MF stuff. Hmm. 947c478bd9Sstevel@tonic-gate "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 957c478bd9Sstevel@tonic-gate stat=$? 967c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 977c478bd9Sstevel@tonic-gate else 987c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 997c478bd9Sstevel@tonic-gate exit $stat 1007c478bd9Sstevel@tonic-gate fi 1017c478bd9Sstevel@tonic-gate mv "$tmpdepfile" "$depfile" 1027c478bd9Sstevel@tonic-gate ;; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gategcc) 1057c478bd9Sstevel@tonic-gate## There are various ways to get dependency output from gcc. Here's 1067c478bd9Sstevel@tonic-gate## why we pick this rather obscure method: 1077c478bd9Sstevel@tonic-gate## - Don't want to use -MD because we'd like the dependencies to end 1087c478bd9Sstevel@tonic-gate## up in a subdir. Having to rename by hand is ugly. 1097c478bd9Sstevel@tonic-gate## (We might end up doing this anyway to support other compilers.) 1107c478bd9Sstevel@tonic-gate## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1117c478bd9Sstevel@tonic-gate## -MM, not -M (despite what the docs say). 1127c478bd9Sstevel@tonic-gate## - Using -M directly means running the compiler twice (even worse 1137c478bd9Sstevel@tonic-gate## than renaming). 1147c478bd9Sstevel@tonic-gate if test -z "$gccflag"; then 1157c478bd9Sstevel@tonic-gate gccflag=-MD, 1167c478bd9Sstevel@tonic-gate fi 1177c478bd9Sstevel@tonic-gate "$@" -Wp,"$gccflag$tmpdepfile" 1187c478bd9Sstevel@tonic-gate stat=$? 1197c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 1207c478bd9Sstevel@tonic-gate else 1217c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 1227c478bd9Sstevel@tonic-gate exit $stat 1237c478bd9Sstevel@tonic-gate fi 1247c478bd9Sstevel@tonic-gate rm -f "$depfile" 1257c478bd9Sstevel@tonic-gate echo "$object : \\" > "$depfile" 1267c478bd9Sstevel@tonic-gate alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1277c478bd9Sstevel@tonic-gate## The second -e expression handles DOS-style file names with drive letters. 1287c478bd9Sstevel@tonic-gate sed -e 's/^[^:]*: / /' \ 1297c478bd9Sstevel@tonic-gate -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1307c478bd9Sstevel@tonic-gate## This next piece of magic avoids the `deleted header file' problem. 1317c478bd9Sstevel@tonic-gate## The problem is that when a header file which appears in a .P file 1327c478bd9Sstevel@tonic-gate## is deleted, the dependency causes make to die (because there is 1337c478bd9Sstevel@tonic-gate## typically no way to rebuild the header). We avoid this by adding 1347c478bd9Sstevel@tonic-gate## dummy dependencies for each header file. Too bad gcc doesn't do 1357c478bd9Sstevel@tonic-gate## this for us directly. 1367c478bd9Sstevel@tonic-gate tr ' ' ' 1377c478bd9Sstevel@tonic-gate' < "$tmpdepfile" | 1387c478bd9Sstevel@tonic-gate## Some versions of gcc put a space before the `:'. On the theory 1397c478bd9Sstevel@tonic-gate## that the space means something, we add a space to the output as 1407c478bd9Sstevel@tonic-gate## well. 1417c478bd9Sstevel@tonic-gate## Some versions of the HPUX 10.20 sed can't process this invocation 1427c478bd9Sstevel@tonic-gate## correctly. Breaking it into two sed invocations is a workaround. 1437c478bd9Sstevel@tonic-gate sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1447c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 1457c478bd9Sstevel@tonic-gate ;; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gatehp) 1487c478bd9Sstevel@tonic-gate # This case exists only to let depend.m4 do its work. It works by 1497c478bd9Sstevel@tonic-gate # looking at the text of this script. This case will never be run, 1507c478bd9Sstevel@tonic-gate # since it is checked for above. 1517c478bd9Sstevel@tonic-gate exit 1 1527c478bd9Sstevel@tonic-gate ;; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gatesgi) 1557c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 1567c478bd9Sstevel@tonic-gate "$@" "-Wp,-MDupdate,$tmpdepfile" 1577c478bd9Sstevel@tonic-gate else 1587c478bd9Sstevel@tonic-gate "$@" -MDupdate "$tmpdepfile" 1597c478bd9Sstevel@tonic-gate fi 1607c478bd9Sstevel@tonic-gate stat=$? 1617c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 1627c478bd9Sstevel@tonic-gate else 1637c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 1647c478bd9Sstevel@tonic-gate exit $stat 1657c478bd9Sstevel@tonic-gate fi 1667c478bd9Sstevel@tonic-gate rm -f "$depfile" 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1697c478bd9Sstevel@tonic-gate echo "$object : \\" > "$depfile" 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate # Clip off the initial element (the dependent). Don't try to be 1727c478bd9Sstevel@tonic-gate # clever and replace this with sed code, as IRIX sed won't handle 1737c478bd9Sstevel@tonic-gate # lines with more than a fixed number of characters (4096 in 1747c478bd9Sstevel@tonic-gate # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1757c478bd9Sstevel@tonic-gate # the IRIX cc adds comments like `#:fec' to the end of the 1767c478bd9Sstevel@tonic-gate # dependency line. 1777c478bd9Sstevel@tonic-gate tr ' ' ' 1787c478bd9Sstevel@tonic-gate' < "$tmpdepfile" \ 1797c478bd9Sstevel@tonic-gate | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1807c478bd9Sstevel@tonic-gate tr ' 1817c478bd9Sstevel@tonic-gate' ' ' >> $depfile 1827c478bd9Sstevel@tonic-gate echo >> $depfile 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate # The second pass generates a dummy entry for each header file. 1857c478bd9Sstevel@tonic-gate tr ' ' ' 1867c478bd9Sstevel@tonic-gate' < "$tmpdepfile" \ 1877c478bd9Sstevel@tonic-gate | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 1887c478bd9Sstevel@tonic-gate >> $depfile 1897c478bd9Sstevel@tonic-gate else 1907c478bd9Sstevel@tonic-gate # The sourcefile does not contain any dependencies, so just 1917c478bd9Sstevel@tonic-gate # store a dummy comment line, to avoid errors with the Makefile 1927c478bd9Sstevel@tonic-gate # "include basename.Plo" scheme. 1937c478bd9Sstevel@tonic-gate echo "#dummy" > "$depfile" 1947c478bd9Sstevel@tonic-gate fi 1957c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 1967c478bd9Sstevel@tonic-gate ;; 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gateaix) 1997c478bd9Sstevel@tonic-gate # The C for AIX Compiler uses -M and outputs the dependencies 2007c478bd9Sstevel@tonic-gate # in a .u file. In older versions, this file always lives in the 2017c478bd9Sstevel@tonic-gate # current directory. Also, the AIX compiler puts `$object:' at the 2027c478bd9Sstevel@tonic-gate # start of each line; $object doesn't have directory information. 2037c478bd9Sstevel@tonic-gate # Version 6 uses the directory in both cases. 2047c478bd9Sstevel@tonic-gate stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 2057c478bd9Sstevel@tonic-gate tmpdepfile="$stripped.u" 2067c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 2077c478bd9Sstevel@tonic-gate "$@" -Wc,-M 2087c478bd9Sstevel@tonic-gate else 2097c478bd9Sstevel@tonic-gate "$@" -M 2107c478bd9Sstevel@tonic-gate fi 2117c478bd9Sstevel@tonic-gate stat=$? 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate if test -f "$tmpdepfile"; then : 2147c478bd9Sstevel@tonic-gate else 2157c478bd9Sstevel@tonic-gate stripped=`echo "$stripped" | sed 's,^.*/,,'` 2167c478bd9Sstevel@tonic-gate tmpdepfile="$stripped.u" 2177c478bd9Sstevel@tonic-gate fi 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 2207c478bd9Sstevel@tonic-gate else 2217c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 2227c478bd9Sstevel@tonic-gate exit $stat 2237c478bd9Sstevel@tonic-gate fi 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate if test -f "$tmpdepfile"; then 2267c478bd9Sstevel@tonic-gate outname="$stripped.o" 2277c478bd9Sstevel@tonic-gate # Each line is of the form `foo.o: dependent.h'. 2287c478bd9Sstevel@tonic-gate # Do two passes, one to just change these to 2297c478bd9Sstevel@tonic-gate # `$object: dependent.h' and one to simply `dependent.h:'. 2307c478bd9Sstevel@tonic-gate sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 2317c478bd9Sstevel@tonic-gate sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 2327c478bd9Sstevel@tonic-gate else 2337c478bd9Sstevel@tonic-gate # The sourcefile does not contain any dependencies, so just 2347c478bd9Sstevel@tonic-gate # store a dummy comment line, to avoid errors with the Makefile 2357c478bd9Sstevel@tonic-gate # "include basename.Plo" scheme. 2367c478bd9Sstevel@tonic-gate echo "#dummy" > "$depfile" 2377c478bd9Sstevel@tonic-gate fi 2387c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 2397c478bd9Sstevel@tonic-gate ;; 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gateicc) 2427c478bd9Sstevel@tonic-gate # Intel's C compiler understands `-MD -MF file'. However on 2437c478bd9Sstevel@tonic-gate # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2447c478bd9Sstevel@tonic-gate # ICC 7.0 will fill foo.d with something like 2457c478bd9Sstevel@tonic-gate # foo.o: sub/foo.c 2467c478bd9Sstevel@tonic-gate # foo.o: sub/foo.h 2477c478bd9Sstevel@tonic-gate # which is wrong. We want: 2487c478bd9Sstevel@tonic-gate # sub/foo.o: sub/foo.c 2497c478bd9Sstevel@tonic-gate # sub/foo.o: sub/foo.h 2507c478bd9Sstevel@tonic-gate # sub/foo.c: 2517c478bd9Sstevel@tonic-gate # sub/foo.h: 2527c478bd9Sstevel@tonic-gate # ICC 7.1 will output 2537c478bd9Sstevel@tonic-gate # foo.o: sub/foo.c sub/foo.h 2547c478bd9Sstevel@tonic-gate # and will wrap long lines using \ : 2557c478bd9Sstevel@tonic-gate # foo.o: sub/foo.c ... \ 2567c478bd9Sstevel@tonic-gate # sub/foo.h ... \ 2577c478bd9Sstevel@tonic-gate # ... 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate "$@" -MD -MF "$tmpdepfile" 2607c478bd9Sstevel@tonic-gate stat=$? 2617c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 2627c478bd9Sstevel@tonic-gate else 2637c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 2647c478bd9Sstevel@tonic-gate exit $stat 2657c478bd9Sstevel@tonic-gate fi 2667c478bd9Sstevel@tonic-gate rm -f "$depfile" 2677c478bd9Sstevel@tonic-gate # Each line is of the form `foo.o: dependent.h', 2687c478bd9Sstevel@tonic-gate # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2697c478bd9Sstevel@tonic-gate # Do two passes, one to just change these to 2707c478bd9Sstevel@tonic-gate # `$object: dependent.h' and one to simply `dependent.h:'. 2717c478bd9Sstevel@tonic-gate sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2727c478bd9Sstevel@tonic-gate # Some versions of the HPUX 10.20 sed can't process this invocation 2737c478bd9Sstevel@tonic-gate # correctly. Breaking it into two sed invocations is a workaround. 2747c478bd9Sstevel@tonic-gate sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2757c478bd9Sstevel@tonic-gate sed -e 's/$/ :/' >> "$depfile" 2767c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 2777c478bd9Sstevel@tonic-gate ;; 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gatetru64) 2807c478bd9Sstevel@tonic-gate # The Tru64 compiler uses -MD to generate dependencies as a side 2817c478bd9Sstevel@tonic-gate # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 2827c478bd9Sstevel@tonic-gate # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 2837c478bd9Sstevel@tonic-gate # dependencies in `foo.d' instead, so we check for that too. 2847c478bd9Sstevel@tonic-gate # Subdirectories are respected. 2857c478bd9Sstevel@tonic-gate dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2867c478bd9Sstevel@tonic-gate test "x$dir" = "x$object" && dir= 2877c478bd9Sstevel@tonic-gate base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 290*1b8adde7SWilliam Kucharski # Dependencies are output in .lo.d with libtool 1.4. 291*1b8adde7SWilliam Kucharski # With libtool 1.5 they are output both in $dir.libs/$base.o.d 292*1b8adde7SWilliam Kucharski # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the 293*1b8adde7SWilliam Kucharski # latter, because the former will be cleaned when $dir.libs is 294*1b8adde7SWilliam Kucharski # erased. 2957c478bd9Sstevel@tonic-gate tmpdepfile1="$dir.libs/$base.lo.d" 296*1b8adde7SWilliam Kucharski tmpdepfile2="$dir$base.o.d" 297*1b8adde7SWilliam Kucharski tmpdepfile3="$dir.libs/$base.d" 2987c478bd9Sstevel@tonic-gate "$@" -Wc,-MD 2997c478bd9Sstevel@tonic-gate else 3007c478bd9Sstevel@tonic-gate tmpdepfile1="$dir$base.o.d" 3017c478bd9Sstevel@tonic-gate tmpdepfile2="$dir$base.d" 302*1b8adde7SWilliam Kucharski tmpdepfile3="$dir$base.d" 3037c478bd9Sstevel@tonic-gate "$@" -MD 3047c478bd9Sstevel@tonic-gate fi 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate stat=$? 3077c478bd9Sstevel@tonic-gate if test $stat -eq 0; then : 3087c478bd9Sstevel@tonic-gate else 309*1b8adde7SWilliam Kucharski rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3107c478bd9Sstevel@tonic-gate exit $stat 3117c478bd9Sstevel@tonic-gate fi 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate if test -f "$tmpdepfile1"; then 3147c478bd9Sstevel@tonic-gate tmpdepfile="$tmpdepfile1" 315*1b8adde7SWilliam Kucharski elif test -f "$tmpdepfile2"; then 3167c478bd9Sstevel@tonic-gate tmpdepfile="$tmpdepfile2" 317*1b8adde7SWilliam Kucharski else 318*1b8adde7SWilliam Kucharski tmpdepfile="$tmpdepfile3" 3197c478bd9Sstevel@tonic-gate fi 3207c478bd9Sstevel@tonic-gate if test -f "$tmpdepfile"; then 3217c478bd9Sstevel@tonic-gate sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3227c478bd9Sstevel@tonic-gate # That's a tab and a space in the []. 3237c478bd9Sstevel@tonic-gate sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3247c478bd9Sstevel@tonic-gate else 3257c478bd9Sstevel@tonic-gate echo "#dummy" > "$depfile" 3267c478bd9Sstevel@tonic-gate fi 3277c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 3287c478bd9Sstevel@tonic-gate ;; 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate#nosideeffect) 3317c478bd9Sstevel@tonic-gate # This comment above is used by automake to tell side-effect 3327c478bd9Sstevel@tonic-gate # dependency tracking mechanisms from slower ones. 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gatedashmstdout) 3357c478bd9Sstevel@tonic-gate # Important note: in order to support this mode, a compiler *must* 3367c478bd9Sstevel@tonic-gate # always write the preprocessed file to stdout, regardless of -o. 3377c478bd9Sstevel@tonic-gate "$@" || exit $? 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate # Remove the call to Libtool. 3407c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 3417c478bd9Sstevel@tonic-gate while test $1 != '--mode=compile'; do 3427c478bd9Sstevel@tonic-gate shift 3437c478bd9Sstevel@tonic-gate done 3447c478bd9Sstevel@tonic-gate shift 3457c478bd9Sstevel@tonic-gate fi 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate # Remove `-o $object'. 3487c478bd9Sstevel@tonic-gate IFS=" " 3497c478bd9Sstevel@tonic-gate for arg 3507c478bd9Sstevel@tonic-gate do 3517c478bd9Sstevel@tonic-gate case $arg in 3527c478bd9Sstevel@tonic-gate -o) 3537c478bd9Sstevel@tonic-gate shift 3547c478bd9Sstevel@tonic-gate ;; 3557c478bd9Sstevel@tonic-gate $object) 3567c478bd9Sstevel@tonic-gate shift 3577c478bd9Sstevel@tonic-gate ;; 3587c478bd9Sstevel@tonic-gate *) 3597c478bd9Sstevel@tonic-gate set fnord "$@" "$arg" 3607c478bd9Sstevel@tonic-gate shift # fnord 3617c478bd9Sstevel@tonic-gate shift # $arg 3627c478bd9Sstevel@tonic-gate ;; 3637c478bd9Sstevel@tonic-gate esac 3647c478bd9Sstevel@tonic-gate done 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate test -z "$dashmflag" && dashmflag=-M 3677c478bd9Sstevel@tonic-gate # Require at least two characters before searching for `:' 3687c478bd9Sstevel@tonic-gate # in the target name. This is to cope with DOS-style filenames: 3697c478bd9Sstevel@tonic-gate # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 3707c478bd9Sstevel@tonic-gate "$@" $dashmflag | 3717c478bd9Sstevel@tonic-gate sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 3727c478bd9Sstevel@tonic-gate rm -f "$depfile" 3737c478bd9Sstevel@tonic-gate cat < "$tmpdepfile" > "$depfile" 3747c478bd9Sstevel@tonic-gate tr ' ' ' 3757c478bd9Sstevel@tonic-gate' < "$tmpdepfile" | \ 3767c478bd9Sstevel@tonic-gate## Some versions of the HPUX 10.20 sed can't process this invocation 3777c478bd9Sstevel@tonic-gate## correctly. Breaking it into two sed invocations is a workaround. 3787c478bd9Sstevel@tonic-gate sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 3797c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 3807c478bd9Sstevel@tonic-gate ;; 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gatedashXmstdout) 3837c478bd9Sstevel@tonic-gate # This case only exists to satisfy depend.m4. It is never actually 3847c478bd9Sstevel@tonic-gate # run, as this mode is specially recognized in the preamble. 3857c478bd9Sstevel@tonic-gate exit 1 3867c478bd9Sstevel@tonic-gate ;; 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gatemakedepend) 3897c478bd9Sstevel@tonic-gate "$@" || exit $? 3907c478bd9Sstevel@tonic-gate # Remove any Libtool call 3917c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 3927c478bd9Sstevel@tonic-gate while test $1 != '--mode=compile'; do 3937c478bd9Sstevel@tonic-gate shift 3947c478bd9Sstevel@tonic-gate done 3957c478bd9Sstevel@tonic-gate shift 3967c478bd9Sstevel@tonic-gate fi 3977c478bd9Sstevel@tonic-gate # X makedepend 3987c478bd9Sstevel@tonic-gate shift 3997c478bd9Sstevel@tonic-gate cleared=no 4007c478bd9Sstevel@tonic-gate for arg in "$@"; do 4017c478bd9Sstevel@tonic-gate case $cleared in 4027c478bd9Sstevel@tonic-gate no) 4037c478bd9Sstevel@tonic-gate set ""; shift 4047c478bd9Sstevel@tonic-gate cleared=yes ;; 4057c478bd9Sstevel@tonic-gate esac 4067c478bd9Sstevel@tonic-gate case "$arg" in 4077c478bd9Sstevel@tonic-gate -D*|-I*) 4087c478bd9Sstevel@tonic-gate set fnord "$@" "$arg"; shift ;; 4097c478bd9Sstevel@tonic-gate # Strip any option that makedepend may not understand. Remove 4107c478bd9Sstevel@tonic-gate # the object too, otherwise makedepend will parse it as a source file. 4117c478bd9Sstevel@tonic-gate -*|$object) 4127c478bd9Sstevel@tonic-gate ;; 4137c478bd9Sstevel@tonic-gate *) 4147c478bd9Sstevel@tonic-gate set fnord "$@" "$arg"; shift ;; 4157c478bd9Sstevel@tonic-gate esac 4167c478bd9Sstevel@tonic-gate done 4177c478bd9Sstevel@tonic-gate obj_suffix="`echo $object | sed 's/^.*\././'`" 4187c478bd9Sstevel@tonic-gate touch "$tmpdepfile" 4197c478bd9Sstevel@tonic-gate ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4207c478bd9Sstevel@tonic-gate rm -f "$depfile" 4217c478bd9Sstevel@tonic-gate cat < "$tmpdepfile" > "$depfile" 4227c478bd9Sstevel@tonic-gate sed '1,2d' "$tmpdepfile" | tr ' ' ' 4237c478bd9Sstevel@tonic-gate' | \ 4247c478bd9Sstevel@tonic-gate## Some versions of the HPUX 10.20 sed can't process this invocation 4257c478bd9Sstevel@tonic-gate## correctly. Breaking it into two sed invocations is a workaround. 4267c478bd9Sstevel@tonic-gate sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4277c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" "$tmpdepfile".bak 4287c478bd9Sstevel@tonic-gate ;; 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gatecpp) 4317c478bd9Sstevel@tonic-gate # Important note: in order to support this mode, a compiler *must* 4327c478bd9Sstevel@tonic-gate # always write the preprocessed file to stdout. 4337c478bd9Sstevel@tonic-gate "$@" || exit $? 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate # Remove the call to Libtool. 4367c478bd9Sstevel@tonic-gate if test "$libtool" = yes; then 4377c478bd9Sstevel@tonic-gate while test $1 != '--mode=compile'; do 4387c478bd9Sstevel@tonic-gate shift 4397c478bd9Sstevel@tonic-gate done 4407c478bd9Sstevel@tonic-gate shift 4417c478bd9Sstevel@tonic-gate fi 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate # Remove `-o $object'. 4447c478bd9Sstevel@tonic-gate IFS=" " 4457c478bd9Sstevel@tonic-gate for arg 4467c478bd9Sstevel@tonic-gate do 4477c478bd9Sstevel@tonic-gate case $arg in 4487c478bd9Sstevel@tonic-gate -o) 4497c478bd9Sstevel@tonic-gate shift 4507c478bd9Sstevel@tonic-gate ;; 4517c478bd9Sstevel@tonic-gate $object) 4527c478bd9Sstevel@tonic-gate shift 4537c478bd9Sstevel@tonic-gate ;; 4547c478bd9Sstevel@tonic-gate *) 4557c478bd9Sstevel@tonic-gate set fnord "$@" "$arg" 4567c478bd9Sstevel@tonic-gate shift # fnord 4577c478bd9Sstevel@tonic-gate shift # $arg 4587c478bd9Sstevel@tonic-gate ;; 4597c478bd9Sstevel@tonic-gate esac 4607c478bd9Sstevel@tonic-gate done 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate "$@" -E | 4637c478bd9Sstevel@tonic-gate sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 4647c478bd9Sstevel@tonic-gate sed '$ s: \\$::' > "$tmpdepfile" 4657c478bd9Sstevel@tonic-gate rm -f "$depfile" 4667c478bd9Sstevel@tonic-gate echo "$object : \\" > "$depfile" 4677c478bd9Sstevel@tonic-gate cat < "$tmpdepfile" >> "$depfile" 4687c478bd9Sstevel@tonic-gate sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 4697c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 4707c478bd9Sstevel@tonic-gate ;; 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gatemsvisualcpp) 4737c478bd9Sstevel@tonic-gate # Important note: in order to support this mode, a compiler *must* 4747c478bd9Sstevel@tonic-gate # always write the preprocessed file to stdout, regardless of -o, 4757c478bd9Sstevel@tonic-gate # because we must use -o when running libtool. 4767c478bd9Sstevel@tonic-gate "$@" || exit $? 4777c478bd9Sstevel@tonic-gate IFS=" " 4787c478bd9Sstevel@tonic-gate for arg 4797c478bd9Sstevel@tonic-gate do 4807c478bd9Sstevel@tonic-gate case "$arg" in 4817c478bd9Sstevel@tonic-gate "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 4827c478bd9Sstevel@tonic-gate set fnord "$@" 4837c478bd9Sstevel@tonic-gate shift 4847c478bd9Sstevel@tonic-gate shift 4857c478bd9Sstevel@tonic-gate ;; 4867c478bd9Sstevel@tonic-gate *) 4877c478bd9Sstevel@tonic-gate set fnord "$@" "$arg" 4887c478bd9Sstevel@tonic-gate shift 4897c478bd9Sstevel@tonic-gate shift 4907c478bd9Sstevel@tonic-gate ;; 4917c478bd9Sstevel@tonic-gate esac 4927c478bd9Sstevel@tonic-gate done 4937c478bd9Sstevel@tonic-gate "$@" -E | 4947c478bd9Sstevel@tonic-gate sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 4957c478bd9Sstevel@tonic-gate rm -f "$depfile" 4967c478bd9Sstevel@tonic-gate echo "$object : \\" > "$depfile" 4977c478bd9Sstevel@tonic-gate . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 4987c478bd9Sstevel@tonic-gate echo " " >> "$depfile" 4997c478bd9Sstevel@tonic-gate . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5007c478bd9Sstevel@tonic-gate rm -f "$tmpdepfile" 5017c478bd9Sstevel@tonic-gate ;; 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gatenone) 5047c478bd9Sstevel@tonic-gate exec "$@" 5057c478bd9Sstevel@tonic-gate ;; 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate*) 5087c478bd9Sstevel@tonic-gate echo "Unknown depmode $depmode" 1>&2 5097c478bd9Sstevel@tonic-gate exit 1 5107c478bd9Sstevel@tonic-gate ;; 5117c478bd9Sstevel@tonic-gateesac 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gateexit 0 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate# Local Variables: 5167c478bd9Sstevel@tonic-gate# mode: shell-script 5177c478bd9Sstevel@tonic-gate# sh-indentation: 2 5187c478bd9Sstevel@tonic-gate# eval: (add-hook 'write-file-hooks 'time-stamp) 5197c478bd9Sstevel@tonic-gate# time-stamp-start: "scriptversion=" 5207c478bd9Sstevel@tonic-gate# time-stamp-format: "%:y-%02m-%02d.%02H" 5217c478bd9Sstevel@tonic-gate# time-stamp-end: "$" 5227c478bd9Sstevel@tonic-gate# End: 523