18585484eSchristos#! /bin/sh 28585484eSchristos# depcomp - compile a program generating dependencies as side-effects 38585484eSchristos 4*3e3909feSchristosscriptversion=2013-05-30.07; # UTC 58585484eSchristos 6*3e3909feSchristos# Copyright (C) 1999-2014 Free Software Foundation, Inc. 78585484eSchristos 88585484eSchristos# This program is free software; you can redistribute it and/or modify 98585484eSchristos# it under the terms of the GNU General Public License as published by 108585484eSchristos# the Free Software Foundation; either version 2, or (at your option) 118585484eSchristos# any later version. 128585484eSchristos 138585484eSchristos# This program is distributed in the hope that it will be useful, 148585484eSchristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 158585484eSchristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 168585484eSchristos# GNU General Public License for more details. 178585484eSchristos 188585484eSchristos# You should have received a copy of the GNU General Public License 198585484eSchristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 208585484eSchristos 218585484eSchristos# As a special exception to the GNU General Public License, if you 228585484eSchristos# distribute this file as part of a program that contains a 238585484eSchristos# configuration script generated by Autoconf, you may include it under 248585484eSchristos# the same distribution terms that you use for the rest of that program. 258585484eSchristos 268585484eSchristos# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 278585484eSchristos 288585484eSchristoscase $1 in 298585484eSchristos '') 30*3e3909feSchristos echo "$0: No command. Try '$0 --help' for more information." 1>&2 318585484eSchristos exit 1; 328585484eSchristos ;; 338585484eSchristos -h | --h*) 348585484eSchristos cat <<\EOF 358585484eSchristosUsage: depcomp [--help] [--version] PROGRAM [ARGS] 368585484eSchristos 378585484eSchristosRun PROGRAMS ARGS to compile a file, generating dependencies 388585484eSchristosas side-effects. 398585484eSchristos 408585484eSchristosEnvironment variables: 418585484eSchristos depmode Dependency tracking mode. 42*3e3909feSchristos source Source file read by 'PROGRAMS ARGS'. 43*3e3909feSchristos object Object file output by 'PROGRAMS ARGS'. 448585484eSchristos DEPDIR directory where to store dependencies. 458585484eSchristos depfile Dependency file to output. 46*3e3909feSchristos tmpdepfile Temporary file to use when outputting dependencies. 478585484eSchristos libtool Whether libtool is used (yes/no). 488585484eSchristos 498585484eSchristosReport bugs to <bug-automake@gnu.org>. 508585484eSchristosEOF 518585484eSchristos exit $? 528585484eSchristos ;; 538585484eSchristos -v | --v*) 548585484eSchristos echo "depcomp $scriptversion" 558585484eSchristos exit $? 568585484eSchristos ;; 578585484eSchristosesac 588585484eSchristos 59*3e3909feSchristos# Get the directory component of the given path, and save it in the 60*3e3909feSchristos# global variables '$dir'. Note that this directory component will 61*3e3909feSchristos# be either empty or ending with a '/' character. This is deliberate. 62*3e3909feSchristosset_dir_from () 63*3e3909feSchristos{ 64*3e3909feSchristos case $1 in 65*3e3909feSchristos */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 66*3e3909feSchristos *) dir=;; 67*3e3909feSchristos esac 68*3e3909feSchristos} 69*3e3909feSchristos 70*3e3909feSchristos# Get the suffix-stripped basename of the given path, and save it the 71*3e3909feSchristos# global variable '$base'. 72*3e3909feSchristosset_base_from () 73*3e3909feSchristos{ 74*3e3909feSchristos base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 75*3e3909feSchristos} 76*3e3909feSchristos 77*3e3909feSchristos# If no dependency file was actually created by the compiler invocation, 78*3e3909feSchristos# we still have to create a dummy depfile, to avoid errors with the 79*3e3909feSchristos# Makefile "include basename.Plo" scheme. 80*3e3909feSchristosmake_dummy_depfile () 81*3e3909feSchristos{ 82*3e3909feSchristos echo "#dummy" > "$depfile" 83*3e3909feSchristos} 84*3e3909feSchristos 85*3e3909feSchristos# Factor out some common post-processing of the generated depfile. 86*3e3909feSchristos# Requires the auxiliary global variable '$tmpdepfile' to be set. 87*3e3909feSchristosaix_post_process_depfile () 88*3e3909feSchristos{ 89*3e3909feSchristos # If the compiler actually managed to produce a dependency file, 90*3e3909feSchristos # post-process it. 91*3e3909feSchristos if test -f "$tmpdepfile"; then 92*3e3909feSchristos # Each line is of the form 'foo.o: dependency.h'. 93*3e3909feSchristos # Do two passes, one to just change these to 94*3e3909feSchristos # $object: dependency.h 95*3e3909feSchristos # and one to simply output 96*3e3909feSchristos # dependency.h: 97*3e3909feSchristos # which is needed to avoid the deleted-header problem. 98*3e3909feSchristos { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 99*3e3909feSchristos sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 100*3e3909feSchristos } > "$depfile" 101*3e3909feSchristos rm -f "$tmpdepfile" 102*3e3909feSchristos else 103*3e3909feSchristos make_dummy_depfile 104*3e3909feSchristos fi 105*3e3909feSchristos} 106*3e3909feSchristos 107*3e3909feSchristos# A tabulation character. 108*3e3909feSchristostab=' ' 109*3e3909feSchristos# A newline character. 110*3e3909feSchristosnl=' 111*3e3909feSchristos' 112*3e3909feSchristos# Character ranges might be problematic outside the C locale. 113*3e3909feSchristos# These definitions help. 114*3e3909feSchristosupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 115*3e3909feSchristoslower=abcdefghijklmnopqrstuvwxyz 116*3e3909feSchristosdigits=0123456789 117*3e3909feSchristosalpha=${upper}${lower} 118*3e3909feSchristos 1198585484eSchristosif test -z "$depmode" || test -z "$source" || test -z "$object"; then 1208585484eSchristos echo "depcomp: Variables source, object and depmode must be set" 1>&2 1218585484eSchristos exit 1 1228585484eSchristosfi 1238585484eSchristos 1248585484eSchristos# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 1258585484eSchristosdepfile=${depfile-`echo "$object" | 1268585484eSchristos sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 1278585484eSchristostmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 1288585484eSchristos 1298585484eSchristosrm -f "$tmpdepfile" 1308585484eSchristos 131*3e3909feSchristos# Avoid interferences from the environment. 132*3e3909feSchristosgccflag= dashmflag= 133*3e3909feSchristos 1348585484eSchristos# Some modes work just like other modes, but use different flags. We 1358585484eSchristos# parameterize here, but still list the modes in the big case below, 1368585484eSchristos# to make depend.m4 easier to write. Note that we *cannot* use a case 1378585484eSchristos# here, because this file can only contain one case statement. 1388585484eSchristosif test "$depmode" = hp; then 1398585484eSchristos # HP compiler uses -M and no extra arg. 1408585484eSchristos gccflag=-M 1418585484eSchristos depmode=gcc 1428585484eSchristosfi 1438585484eSchristos 1448585484eSchristosif test "$depmode" = dashXmstdout; then 1458585484eSchristos # This is just like dashmstdout with a different argument. 1468585484eSchristos dashmflag=-xM 1478585484eSchristos depmode=dashmstdout 1488585484eSchristosfi 1498585484eSchristos 1508585484eSchristoscygpath_u="cygpath -u -f -" 1518585484eSchristosif test "$depmode" = msvcmsys; then 1528585484eSchristos # This is just like msvisualcpp but w/o cygpath translation. 1538585484eSchristos # Just convert the backslash-escaped backslashes to single forward 1548585484eSchristos # slashes to satisfy depend.m4 155*3e3909feSchristos cygpath_u='sed s,\\\\,/,g' 1568585484eSchristos depmode=msvisualcpp 1578585484eSchristosfi 1588585484eSchristos 159*3e3909feSchristosif test "$depmode" = msvc7msys; then 160*3e3909feSchristos # This is just like msvc7 but w/o cygpath translation. 161*3e3909feSchristos # Just convert the backslash-escaped backslashes to single forward 162*3e3909feSchristos # slashes to satisfy depend.m4 163*3e3909feSchristos cygpath_u='sed s,\\\\,/,g' 164*3e3909feSchristos depmode=msvc7 165*3e3909feSchristosfi 166*3e3909feSchristos 167*3e3909feSchristosif test "$depmode" = xlc; then 168*3e3909feSchristos # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 169*3e3909feSchristos gccflag=-qmakedep=gcc,-MF 170*3e3909feSchristos depmode=gcc 171*3e3909feSchristosfi 172*3e3909feSchristos 1738585484eSchristoscase "$depmode" in 1748585484eSchristosgcc3) 1758585484eSchristos## gcc 3 implements dependency tracking that does exactly what 1768585484eSchristos## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1778585484eSchristos## it if -MD -MP comes after the -MF stuff. Hmm. 1788585484eSchristos## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1798585484eSchristos## the command line argument order; so add the flags where they 1808585484eSchristos## appear in depend2.am. Note that the slowdown incurred here 1818585484eSchristos## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1828585484eSchristos for arg 1838585484eSchristos do 1848585484eSchristos case $arg in 1858585484eSchristos -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1868585484eSchristos *) set fnord "$@" "$arg" ;; 1878585484eSchristos esac 1888585484eSchristos shift # fnord 1898585484eSchristos shift # $arg 1908585484eSchristos done 1918585484eSchristos "$@" 1928585484eSchristos stat=$? 193*3e3909feSchristos if test $stat -ne 0; then 1948585484eSchristos rm -f "$tmpdepfile" 1958585484eSchristos exit $stat 1968585484eSchristos fi 1978585484eSchristos mv "$tmpdepfile" "$depfile" 1988585484eSchristos ;; 1998585484eSchristos 2008585484eSchristosgcc) 201*3e3909feSchristos## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 202*3e3909feSchristos## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 203*3e3909feSchristos## (see the conditional assignment to $gccflag above). 2048585484eSchristos## There are various ways to get dependency output from gcc. Here's 2058585484eSchristos## why we pick this rather obscure method: 2068585484eSchristos## - Don't want to use -MD because we'd like the dependencies to end 2078585484eSchristos## up in a subdir. Having to rename by hand is ugly. 2088585484eSchristos## (We might end up doing this anyway to support other compilers.) 2098585484eSchristos## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 210*3e3909feSchristos## -MM, not -M (despite what the docs say). Also, it might not be 211*3e3909feSchristos## supported by the other compilers which use the 'gcc' depmode. 2128585484eSchristos## - Using -M directly means running the compiler twice (even worse 2138585484eSchristos## than renaming). 2148585484eSchristos if test -z "$gccflag"; then 2158585484eSchristos gccflag=-MD, 2168585484eSchristos fi 2178585484eSchristos "$@" -Wp,"$gccflag$tmpdepfile" 2188585484eSchristos stat=$? 219*3e3909feSchristos if test $stat -ne 0; then 2208585484eSchristos rm -f "$tmpdepfile" 2218585484eSchristos exit $stat 2228585484eSchristos fi 2238585484eSchristos rm -f "$depfile" 2248585484eSchristos echo "$object : \\" > "$depfile" 225*3e3909feSchristos # The second -e expression handles DOS-style file names with drive 226*3e3909feSchristos # letters. 2278585484eSchristos sed -e 's/^[^:]*: / /' \ 2288585484eSchristos -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229*3e3909feSchristos## This next piece of magic avoids the "deleted header file" problem. 2308585484eSchristos## The problem is that when a header file which appears in a .P file 2318585484eSchristos## is deleted, the dependency causes make to die (because there is 2328585484eSchristos## typically no way to rebuild the header). We avoid this by adding 2338585484eSchristos## dummy dependencies for each header file. Too bad gcc doesn't do 2348585484eSchristos## this for us directly. 235*3e3909feSchristos## Some versions of gcc put a space before the ':'. On the theory 2368585484eSchristos## that the space means something, we add a space to the output as 237*3e3909feSchristos## well. hp depmode also adds that space, but also prefixes the VPATH 238*3e3909feSchristos## to the object. Take care to not repeat it in the output. 2398585484eSchristos## Some versions of the HPUX 10.20 sed can't process this invocation 2408585484eSchristos## correctly. Breaking it into two sed invocations is a workaround. 241*3e3909feSchristos tr ' ' "$nl" < "$tmpdepfile" \ 242*3e3909feSchristos | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243*3e3909feSchristos | sed -e 's/$/ :/' >> "$depfile" 2448585484eSchristos rm -f "$tmpdepfile" 2458585484eSchristos ;; 2468585484eSchristos 2478585484eSchristoshp) 2488585484eSchristos # This case exists only to let depend.m4 do its work. It works by 2498585484eSchristos # looking at the text of this script. This case will never be run, 2508585484eSchristos # since it is checked for above. 2518585484eSchristos exit 1 2528585484eSchristos ;; 2538585484eSchristos 2548585484eSchristossgi) 2558585484eSchristos if test "$libtool" = yes; then 2568585484eSchristos "$@" "-Wp,-MDupdate,$tmpdepfile" 2578585484eSchristos else 2588585484eSchristos "$@" -MDupdate "$tmpdepfile" 2598585484eSchristos fi 2608585484eSchristos stat=$? 261*3e3909feSchristos if test $stat -ne 0; then 2628585484eSchristos rm -f "$tmpdepfile" 2638585484eSchristos exit $stat 2648585484eSchristos fi 2658585484eSchristos rm -f "$depfile" 2668585484eSchristos 2678585484eSchristos if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 2688585484eSchristos echo "$object : \\" > "$depfile" 2698585484eSchristos # Clip off the initial element (the dependent). Don't try to be 2708585484eSchristos # clever and replace this with sed code, as IRIX sed won't handle 2718585484eSchristos # lines with more than a fixed number of characters (4096 in 2728585484eSchristos # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 273*3e3909feSchristos # the IRIX cc adds comments like '#:fec' to the end of the 2748585484eSchristos # dependency line. 275*3e3909feSchristos tr ' ' "$nl" < "$tmpdepfile" \ 276*3e3909feSchristos | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 277*3e3909feSchristos | tr "$nl" ' ' >> "$depfile" 2788585484eSchristos echo >> "$depfile" 2798585484eSchristos # The second pass generates a dummy entry for each header file. 280*3e3909feSchristos tr ' ' "$nl" < "$tmpdepfile" \ 2818585484eSchristos | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2828585484eSchristos >> "$depfile" 2838585484eSchristos else 284*3e3909feSchristos make_dummy_depfile 2858585484eSchristos fi 2868585484eSchristos rm -f "$tmpdepfile" 2878585484eSchristos ;; 2888585484eSchristos 289*3e3909feSchristosxlc) 290*3e3909feSchristos # This case exists only to let depend.m4 do its work. It works by 291*3e3909feSchristos # looking at the text of this script. This case will never be run, 292*3e3909feSchristos # since it is checked for above. 293*3e3909feSchristos exit 1 294*3e3909feSchristos ;; 295*3e3909feSchristos 2968585484eSchristosaix) 2978585484eSchristos # The C for AIX Compiler uses -M and outputs the dependencies 2988585484eSchristos # in a .u file. In older versions, this file always lives in the 299*3e3909feSchristos # current directory. Also, the AIX compiler puts '$object:' at the 3008585484eSchristos # start of each line; $object doesn't have directory information. 3018585484eSchristos # Version 6 uses the directory in both cases. 302*3e3909feSchristos set_dir_from "$object" 303*3e3909feSchristos set_base_from "$object" 3048585484eSchristos if test "$libtool" = yes; then 3058585484eSchristos tmpdepfile1=$dir$base.u 3068585484eSchristos tmpdepfile2=$base.u 3078585484eSchristos tmpdepfile3=$dir.libs/$base.u 3088585484eSchristos "$@" -Wc,-M 3098585484eSchristos else 3108585484eSchristos tmpdepfile1=$dir$base.u 3118585484eSchristos tmpdepfile2=$dir$base.u 3128585484eSchristos tmpdepfile3=$dir$base.u 3138585484eSchristos "$@" -M 3148585484eSchristos fi 3158585484eSchristos stat=$? 316*3e3909feSchristos if test $stat -ne 0; then 3178585484eSchristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3188585484eSchristos exit $stat 3198585484eSchristos fi 3208585484eSchristos 3218585484eSchristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 3228585484eSchristos do 3238585484eSchristos test -f "$tmpdepfile" && break 3248585484eSchristos done 325*3e3909feSchristos aix_post_process_depfile 326*3e3909feSchristos ;; 327*3e3909feSchristos 328*3e3909feSchristostcc) 329*3e3909feSchristos # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 330*3e3909feSchristos # FIXME: That version still under development at the moment of writing. 331*3e3909feSchristos # Make that this statement remains true also for stable, released 332*3e3909feSchristos # versions. 333*3e3909feSchristos # It will wrap lines (doesn't matter whether long or short) with a 334*3e3909feSchristos # trailing '\', as in: 335*3e3909feSchristos # 336*3e3909feSchristos # foo.o : \ 337*3e3909feSchristos # foo.c \ 338*3e3909feSchristos # foo.h \ 339*3e3909feSchristos # 340*3e3909feSchristos # It will put a trailing '\' even on the last line, and will use leading 341*3e3909feSchristos # spaces rather than leading tabs (at least since its commit 0394caf7 342*3e3909feSchristos # "Emit spaces for -MD"). 343*3e3909feSchristos "$@" -MD -MF "$tmpdepfile" 344*3e3909feSchristos stat=$? 345*3e3909feSchristos if test $stat -ne 0; then 346*3e3909feSchristos rm -f "$tmpdepfile" 347*3e3909feSchristos exit $stat 3488585484eSchristos fi 349*3e3909feSchristos rm -f "$depfile" 350*3e3909feSchristos # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 351*3e3909feSchristos # We have to change lines of the first kind to '$object: \'. 352*3e3909feSchristos sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 353*3e3909feSchristos # And for each line of the second kind, we have to emit a 'dep.h:' 354*3e3909feSchristos # dummy dependency, to avoid the deleted-header problem. 355*3e3909feSchristos sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 3568585484eSchristos rm -f "$tmpdepfile" 3578585484eSchristos ;; 3588585484eSchristos 359*3e3909feSchristos## The order of this option in the case statement is important, since the 360*3e3909feSchristos## shell code in configure will try each of these formats in the order 361*3e3909feSchristos## listed in this file. A plain '-MD' option would be understood by many 362*3e3909feSchristos## compilers, so we must ensure this comes after the gcc and icc options. 363*3e3909feSchristospgcc) 364*3e3909feSchristos # Portland's C compiler understands '-MD'. 365*3e3909feSchristos # Will always output deps to 'file.d' where file is the root name of the 366*3e3909feSchristos # source file under compilation, even if file resides in a subdirectory. 367*3e3909feSchristos # The object file name does not affect the name of the '.d' file. 368*3e3909feSchristos # pgcc 10.2 will output 3698585484eSchristos # foo.o: sub/foo.c sub/foo.h 370*3e3909feSchristos # and will wrap long lines using '\' : 3718585484eSchristos # foo.o: sub/foo.c ... \ 3728585484eSchristos # sub/foo.h ... \ 3738585484eSchristos # ... 374*3e3909feSchristos set_dir_from "$object" 375*3e3909feSchristos # Use the source, not the object, to determine the base name, since 376*3e3909feSchristos # that's sadly what pgcc will do too. 377*3e3909feSchristos set_base_from "$source" 378*3e3909feSchristos tmpdepfile=$base.d 3798585484eSchristos 380*3e3909feSchristos # For projects that build the same source file twice into different object 381*3e3909feSchristos # files, the pgcc approach of using the *source* file root name can cause 382*3e3909feSchristos # problems in parallel builds. Use a locking strategy to avoid stomping on 383*3e3909feSchristos # the same $tmpdepfile. 384*3e3909feSchristos lockdir=$base.d-lock 385*3e3909feSchristos trap " 386*3e3909feSchristos echo '$0: caught signal, cleaning up...' >&2 387*3e3909feSchristos rmdir '$lockdir' 388*3e3909feSchristos exit 1 389*3e3909feSchristos " 1 2 13 15 390*3e3909feSchristos numtries=100 391*3e3909feSchristos i=$numtries 392*3e3909feSchristos while test $i -gt 0; do 393*3e3909feSchristos # mkdir is a portable test-and-set. 394*3e3909feSchristos if mkdir "$lockdir" 2>/dev/null; then 395*3e3909feSchristos # This process acquired the lock. 396*3e3909feSchristos "$@" -MD 3978585484eSchristos stat=$? 398*3e3909feSchristos # Release the lock. 399*3e3909feSchristos rmdir "$lockdir" 400*3e3909feSchristos break 4018585484eSchristos else 402*3e3909feSchristos # If the lock is being held by a different process, wait 403*3e3909feSchristos # until the winning process is done or we timeout. 404*3e3909feSchristos while test -d "$lockdir" && test $i -gt 0; do 405*3e3909feSchristos sleep 1 406*3e3909feSchristos i=`expr $i - 1` 407*3e3909feSchristos done 408*3e3909feSchristos fi 409*3e3909feSchristos i=`expr $i - 1` 410*3e3909feSchristos done 411*3e3909feSchristos trap - 1 2 13 15 412*3e3909feSchristos if test $i -le 0; then 413*3e3909feSchristos echo "$0: failed to acquire lock after $numtries attempts" >&2 414*3e3909feSchristos echo "$0: check lockdir '$lockdir'" >&2 415*3e3909feSchristos exit 1 416*3e3909feSchristos fi 417*3e3909feSchristos 418*3e3909feSchristos if test $stat -ne 0; then 4198585484eSchristos rm -f "$tmpdepfile" 4208585484eSchristos exit $stat 4218585484eSchristos fi 4228585484eSchristos rm -f "$depfile" 4238585484eSchristos # Each line is of the form `foo.o: dependent.h', 4248585484eSchristos # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 4258585484eSchristos # Do two passes, one to just change these to 4268585484eSchristos # `$object: dependent.h' and one to simply `dependent.h:'. 4278585484eSchristos sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 4288585484eSchristos # Some versions of the HPUX 10.20 sed can't process this invocation 4298585484eSchristos # correctly. Breaking it into two sed invocations is a workaround. 430*3e3909feSchristos sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 431*3e3909feSchristos | sed -e 's/$/ :/' >> "$depfile" 4328585484eSchristos rm -f "$tmpdepfile" 4338585484eSchristos ;; 4348585484eSchristos 4358585484eSchristoshp2) 4368585484eSchristos # The "hp" stanza above does not work with aCC (C++) and HP's ia64 4378585484eSchristos # compilers, which have integrated preprocessors. The correct option 4388585484eSchristos # to use with these is +Maked; it writes dependencies to a file named 4398585484eSchristos # 'foo.d', which lands next to the object file, wherever that 4408585484eSchristos # happens to be. 4418585484eSchristos # Much of this is similar to the tru64 case; see comments there. 442*3e3909feSchristos set_dir_from "$object" 443*3e3909feSchristos set_base_from "$object" 4448585484eSchristos if test "$libtool" = yes; then 4458585484eSchristos tmpdepfile1=$dir$base.d 4468585484eSchristos tmpdepfile2=$dir.libs/$base.d 4478585484eSchristos "$@" -Wc,+Maked 4488585484eSchristos else 4498585484eSchristos tmpdepfile1=$dir$base.d 4508585484eSchristos tmpdepfile2=$dir$base.d 4518585484eSchristos "$@" +Maked 4528585484eSchristos fi 4538585484eSchristos stat=$? 454*3e3909feSchristos if test $stat -ne 0; then 4558585484eSchristos rm -f "$tmpdepfile1" "$tmpdepfile2" 4568585484eSchristos exit $stat 4578585484eSchristos fi 4588585484eSchristos 4598585484eSchristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 4608585484eSchristos do 4618585484eSchristos test -f "$tmpdepfile" && break 4628585484eSchristos done 4638585484eSchristos if test -f "$tmpdepfile"; then 464*3e3909feSchristos sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 465*3e3909feSchristos # Add 'dependent.h:' lines. 4668585484eSchristos sed -ne '2,${ 4678585484eSchristos s/^ *// 4688585484eSchristos s/ \\*$// 4698585484eSchristos s/$/:/ 4708585484eSchristos p 4718585484eSchristos }' "$tmpdepfile" >> "$depfile" 4728585484eSchristos else 473*3e3909feSchristos make_dummy_depfile 4748585484eSchristos fi 4758585484eSchristos rm -f "$tmpdepfile" "$tmpdepfile2" 4768585484eSchristos ;; 4778585484eSchristos 4788585484eSchristostru64) 4798585484eSchristos # The Tru64 compiler uses -MD to generate dependencies as a side 480*3e3909feSchristos # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 4818585484eSchristos # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 482*3e3909feSchristos # dependencies in 'foo.d' instead, so we check for that too. 4838585484eSchristos # Subdirectories are respected. 484*3e3909feSchristos set_dir_from "$object" 485*3e3909feSchristos set_base_from "$object" 4868585484eSchristos 4878585484eSchristos if test "$libtool" = yes; then 488*3e3909feSchristos # Libtool generates 2 separate objects for the 2 libraries. These 489*3e3909feSchristos # two compilations output dependencies in $dir.libs/$base.o.d and 4908585484eSchristos # in $dir$base.o.d. We have to check for both files, because 4918585484eSchristos # one of the two compilations can be disabled. We should prefer 4928585484eSchristos # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 4938585484eSchristos # automatically cleaned when .libs/ is deleted, while ignoring 4948585484eSchristos # the former would cause a distcleancheck panic. 495*3e3909feSchristos tmpdepfile1=$dir$base.o.d # libtool 1.5 496*3e3909feSchristos tmpdepfile2=$dir.libs/$base.o.d # Likewise. 497*3e3909feSchristos tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 4988585484eSchristos "$@" -Wc,-MD 4998585484eSchristos else 500*3e3909feSchristos tmpdepfile1=$dir$base.d 5018585484eSchristos tmpdepfile2=$dir$base.d 5028585484eSchristos tmpdepfile3=$dir$base.d 5038585484eSchristos "$@" -MD 5048585484eSchristos fi 5058585484eSchristos 5068585484eSchristos stat=$? 507*3e3909feSchristos if test $stat -ne 0; then 508*3e3909feSchristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5098585484eSchristos exit $stat 5108585484eSchristos fi 5118585484eSchristos 512*3e3909feSchristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 5138585484eSchristos do 5148585484eSchristos test -f "$tmpdepfile" && break 5158585484eSchristos done 516*3e3909feSchristos # Same post-processing that is required for AIX mode. 517*3e3909feSchristos aix_post_process_depfile 518*3e3909feSchristos ;; 519*3e3909feSchristos 520*3e3909feSchristosmsvc7) 521*3e3909feSchristos if test "$libtool" = yes; then 522*3e3909feSchristos showIncludes=-Wc,-showIncludes 5238585484eSchristos else 524*3e3909feSchristos showIncludes=-showIncludes 5258585484eSchristos fi 526*3e3909feSchristos "$@" $showIncludes > "$tmpdepfile" 527*3e3909feSchristos stat=$? 528*3e3909feSchristos grep -v '^Note: including file: ' "$tmpdepfile" 529*3e3909feSchristos if test $stat -ne 0; then 5308585484eSchristos rm -f "$tmpdepfile" 531*3e3909feSchristos exit $stat 532*3e3909feSchristos fi 533*3e3909feSchristos rm -f "$depfile" 534*3e3909feSchristos echo "$object : \\" > "$depfile" 535*3e3909feSchristos # The first sed program below extracts the file names and escapes 536*3e3909feSchristos # backslashes for cygpath. The second sed program outputs the file 537*3e3909feSchristos # name when reading, but also accumulates all include files in the 538*3e3909feSchristos # hold buffer in order to output them again at the end. This only 539*3e3909feSchristos # works with sed implementations that can handle large buffers. 540*3e3909feSchristos sed < "$tmpdepfile" -n ' 541*3e3909feSchristos/^Note: including file: *\(.*\)/ { 542*3e3909feSchristos s//\1/ 543*3e3909feSchristos s/\\/\\\\/g 544*3e3909feSchristos p 545*3e3909feSchristos}' | $cygpath_u | sort -u | sed -n ' 546*3e3909feSchristoss/ /\\ /g 547*3e3909feSchristoss/\(.*\)/'"$tab"'\1 \\/p 548*3e3909feSchristoss/.\(.*\) \\/\1:/ 549*3e3909feSchristosH 550*3e3909feSchristos$ { 551*3e3909feSchristos s/.*/'"$tab"'/ 552*3e3909feSchristos G 553*3e3909feSchristos p 554*3e3909feSchristos}' >> "$depfile" 555*3e3909feSchristos echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556*3e3909feSchristos rm -f "$tmpdepfile" 557*3e3909feSchristos ;; 558*3e3909feSchristos 559*3e3909feSchristosmsvc7msys) 560*3e3909feSchristos # This case exists only to let depend.m4 do its work. It works by 561*3e3909feSchristos # looking at the text of this script. This case will never be run, 562*3e3909feSchristos # since it is checked for above. 563*3e3909feSchristos exit 1 5648585484eSchristos ;; 5658585484eSchristos 5668585484eSchristos#nosideeffect) 5678585484eSchristos # This comment above is used by automake to tell side-effect 5688585484eSchristos # dependency tracking mechanisms from slower ones. 5698585484eSchristos 5708585484eSchristosdashmstdout) 5718585484eSchristos # Important note: in order to support this mode, a compiler *must* 5728585484eSchristos # always write the preprocessed file to stdout, regardless of -o. 5738585484eSchristos "$@" || exit $? 5748585484eSchristos 5758585484eSchristos # Remove the call to Libtool. 5768585484eSchristos if test "$libtool" = yes; then 5778585484eSchristos while test "X$1" != 'X--mode=compile'; do 5788585484eSchristos shift 5798585484eSchristos done 5808585484eSchristos shift 5818585484eSchristos fi 5828585484eSchristos 583*3e3909feSchristos # Remove '-o $object'. 5848585484eSchristos IFS=" " 5858585484eSchristos for arg 5868585484eSchristos do 5878585484eSchristos case $arg in 5888585484eSchristos -o) 5898585484eSchristos shift 5908585484eSchristos ;; 5918585484eSchristos $object) 5928585484eSchristos shift 5938585484eSchristos ;; 5948585484eSchristos *) 5958585484eSchristos set fnord "$@" "$arg" 5968585484eSchristos shift # fnord 5978585484eSchristos shift # $arg 5988585484eSchristos ;; 5998585484eSchristos esac 6008585484eSchristos done 6018585484eSchristos 6028585484eSchristos test -z "$dashmflag" && dashmflag=-M 603*3e3909feSchristos # Require at least two characters before searching for ':' 6048585484eSchristos # in the target name. This is to cope with DOS-style filenames: 605*3e3909feSchristos # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 6068585484eSchristos "$@" $dashmflag | 607*3e3909feSchristos sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 6088585484eSchristos rm -f "$depfile" 6098585484eSchristos cat < "$tmpdepfile" > "$depfile" 610*3e3909feSchristos # Some versions of the HPUX 10.20 sed can't process this sed invocation 611*3e3909feSchristos # correctly. Breaking it into two sed invocations is a workaround. 612*3e3909feSchristos tr ' ' "$nl" < "$tmpdepfile" \ 613*3e3909feSchristos | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 614*3e3909feSchristos | sed -e 's/$/ :/' >> "$depfile" 6158585484eSchristos rm -f "$tmpdepfile" 6168585484eSchristos ;; 6178585484eSchristos 6188585484eSchristosdashXmstdout) 6198585484eSchristos # This case only exists to satisfy depend.m4. It is never actually 6208585484eSchristos # run, as this mode is specially recognized in the preamble. 6218585484eSchristos exit 1 6228585484eSchristos ;; 6238585484eSchristos 6248585484eSchristosmakedepend) 6258585484eSchristos "$@" || exit $? 6268585484eSchristos # Remove any Libtool call 6278585484eSchristos if test "$libtool" = yes; then 6288585484eSchristos while test "X$1" != 'X--mode=compile'; do 6298585484eSchristos shift 6308585484eSchristos done 6318585484eSchristos shift 6328585484eSchristos fi 6338585484eSchristos # X makedepend 6348585484eSchristos shift 6358585484eSchristos cleared=no eat=no 6368585484eSchristos for arg 6378585484eSchristos do 6388585484eSchristos case $cleared in 6398585484eSchristos no) 6408585484eSchristos set ""; shift 6418585484eSchristos cleared=yes ;; 6428585484eSchristos esac 6438585484eSchristos if test $eat = yes; then 6448585484eSchristos eat=no 6458585484eSchristos continue 6468585484eSchristos fi 6478585484eSchristos case "$arg" in 6488585484eSchristos -D*|-I*) 6498585484eSchristos set fnord "$@" "$arg"; shift ;; 6508585484eSchristos # Strip any option that makedepend may not understand. Remove 6518585484eSchristos # the object too, otherwise makedepend will parse it as a source file. 6528585484eSchristos -arch) 6538585484eSchristos eat=yes ;; 6548585484eSchristos -*|$object) 6558585484eSchristos ;; 6568585484eSchristos *) 6578585484eSchristos set fnord "$@" "$arg"; shift ;; 6588585484eSchristos esac 6598585484eSchristos done 6608585484eSchristos obj_suffix=`echo "$object" | sed 's/^.*\././'` 6618585484eSchristos touch "$tmpdepfile" 6628585484eSchristos ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 6638585484eSchristos rm -f "$depfile" 664*3e3909feSchristos # makedepend may prepend the VPATH from the source file name to the object. 665*3e3909feSchristos # No need to regex-escape $object, excess matching of '.' is harmless. 666*3e3909feSchristos sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 667*3e3909feSchristos # Some versions of the HPUX 10.20 sed can't process the last invocation 668*3e3909feSchristos # correctly. Breaking it into two sed invocations is a workaround. 669*3e3909feSchristos sed '1,2d' "$tmpdepfile" \ 670*3e3909feSchristos | tr ' ' "$nl" \ 671*3e3909feSchristos | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 672*3e3909feSchristos | sed -e 's/$/ :/' >> "$depfile" 6738585484eSchristos rm -f "$tmpdepfile" "$tmpdepfile".bak 6748585484eSchristos ;; 6758585484eSchristos 6768585484eSchristoscpp) 6778585484eSchristos # Important note: in order to support this mode, a compiler *must* 6788585484eSchristos # always write the preprocessed file to stdout. 6798585484eSchristos "$@" || exit $? 6808585484eSchristos 6818585484eSchristos # Remove the call to Libtool. 6828585484eSchristos if test "$libtool" = yes; then 6838585484eSchristos while test "X$1" != 'X--mode=compile'; do 6848585484eSchristos shift 6858585484eSchristos done 6868585484eSchristos shift 6878585484eSchristos fi 6888585484eSchristos 689*3e3909feSchristos # Remove '-o $object'. 6908585484eSchristos IFS=" " 6918585484eSchristos for arg 6928585484eSchristos do 6938585484eSchristos case $arg in 6948585484eSchristos -o) 6958585484eSchristos shift 6968585484eSchristos ;; 6978585484eSchristos $object) 6988585484eSchristos shift 6998585484eSchristos ;; 7008585484eSchristos *) 7018585484eSchristos set fnord "$@" "$arg" 7028585484eSchristos shift # fnord 7038585484eSchristos shift # $arg 7048585484eSchristos ;; 7058585484eSchristos esac 7068585484eSchristos done 7078585484eSchristos 708*3e3909feSchristos "$@" -E \ 709*3e3909feSchristos | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 710*3e3909feSchristos -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 711*3e3909feSchristos | sed '$ s: \\$::' > "$tmpdepfile" 7128585484eSchristos rm -f "$depfile" 7138585484eSchristos echo "$object : \\" > "$depfile" 7148585484eSchristos cat < "$tmpdepfile" >> "$depfile" 7158585484eSchristos sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 7168585484eSchristos rm -f "$tmpdepfile" 7178585484eSchristos ;; 7188585484eSchristos 7198585484eSchristosmsvisualcpp) 7208585484eSchristos # Important note: in order to support this mode, a compiler *must* 7218585484eSchristos # always write the preprocessed file to stdout. 7228585484eSchristos "$@" || exit $? 7238585484eSchristos 7248585484eSchristos # Remove the call to Libtool. 7258585484eSchristos if test "$libtool" = yes; then 7268585484eSchristos while test "X$1" != 'X--mode=compile'; do 7278585484eSchristos shift 7288585484eSchristos done 7298585484eSchristos shift 7308585484eSchristos fi 7318585484eSchristos 7328585484eSchristos IFS=" " 7338585484eSchristos for arg 7348585484eSchristos do 7358585484eSchristos case "$arg" in 7368585484eSchristos -o) 7378585484eSchristos shift 7388585484eSchristos ;; 7398585484eSchristos $object) 7408585484eSchristos shift 7418585484eSchristos ;; 7428585484eSchristos "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 7438585484eSchristos set fnord "$@" 7448585484eSchristos shift 7458585484eSchristos shift 7468585484eSchristos ;; 7478585484eSchristos *) 7488585484eSchristos set fnord "$@" "$arg" 7498585484eSchristos shift 7508585484eSchristos shift 7518585484eSchristos ;; 7528585484eSchristos esac 7538585484eSchristos done 7548585484eSchristos "$@" -E 2>/dev/null | 7558585484eSchristos sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 7568585484eSchristos rm -f "$depfile" 7578585484eSchristos echo "$object : \\" > "$depfile" 758*3e3909feSchristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 759*3e3909feSchristos echo "$tab" >> "$depfile" 7608585484eSchristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 7618585484eSchristos rm -f "$tmpdepfile" 7628585484eSchristos ;; 7638585484eSchristos 7648585484eSchristosmsvcmsys) 7658585484eSchristos # This case exists only to let depend.m4 do its work. It works by 7668585484eSchristos # looking at the text of this script. This case will never be run, 7678585484eSchristos # since it is checked for above. 7688585484eSchristos exit 1 7698585484eSchristos ;; 7708585484eSchristos 7718585484eSchristosnone) 7728585484eSchristos exec "$@" 7738585484eSchristos ;; 7748585484eSchristos 7758585484eSchristos*) 7768585484eSchristos echo "Unknown depmode $depmode" 1>&2 7778585484eSchristos exit 1 7788585484eSchristos ;; 7798585484eSchristosesac 7808585484eSchristos 7818585484eSchristosexit 0 7828585484eSchristos 7838585484eSchristos# Local Variables: 7848585484eSchristos# mode: shell-script 7858585484eSchristos# sh-indentation: 2 7868585484eSchristos# eval: (add-hook 'write-file-hooks 'time-stamp) 7878585484eSchristos# time-stamp-start: "scriptversion=" 7888585484eSchristos# time-stamp-format: "%:y-%02m-%02d.%02H" 7898585484eSchristos# time-stamp-time-zone: "UTC" 7908585484eSchristos# time-stamp-end: "; # UTC" 7918585484eSchristos# End: 792