1*75fd0b74Schristos#! /bin/sh 2*75fd0b74Schristos# depcomp - compile a program generating dependencies as side-effects 3*75fd0b74Schristos 4*75fd0b74Schristosscriptversion=2013-05-30.07; # UTC 5*75fd0b74Schristos 6*75fd0b74Schristos# Copyright (C) 1999-2014 Free Software Foundation, Inc. 7*75fd0b74Schristos 8*75fd0b74Schristos# This program is free software; you can redistribute it and/or modify 9*75fd0b74Schristos# it under the terms of the GNU General Public License as published by 10*75fd0b74Schristos# the Free Software Foundation; either version 2, or (at your option) 11*75fd0b74Schristos# any later version. 12*75fd0b74Schristos 13*75fd0b74Schristos# This program is distributed in the hope that it will be useful, 14*75fd0b74Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 15*75fd0b74Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*75fd0b74Schristos# GNU General Public License for more details. 17*75fd0b74Schristos 18*75fd0b74Schristos# You should have received a copy of the GNU General Public License 19*75fd0b74Schristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 20*75fd0b74Schristos 21*75fd0b74Schristos# As a special exception to the GNU General Public License, if you 22*75fd0b74Schristos# distribute this file as part of a program that contains a 23*75fd0b74Schristos# configuration script generated by Autoconf, you may include it under 24*75fd0b74Schristos# the same distribution terms that you use for the rest of that program. 25*75fd0b74Schristos 26*75fd0b74Schristos# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 27*75fd0b74Schristos 28*75fd0b74Schristoscase $1 in 29*75fd0b74Schristos '') 30*75fd0b74Schristos echo "$0: No command. Try '$0 --help' for more information." 1>&2 31*75fd0b74Schristos exit 1; 32*75fd0b74Schristos ;; 33*75fd0b74Schristos -h | --h*) 34*75fd0b74Schristos cat <<\EOF 35*75fd0b74SchristosUsage: depcomp [--help] [--version] PROGRAM [ARGS] 36*75fd0b74Schristos 37*75fd0b74SchristosRun PROGRAMS ARGS to compile a file, generating dependencies 38*75fd0b74Schristosas side-effects. 39*75fd0b74Schristos 40*75fd0b74SchristosEnvironment variables: 41*75fd0b74Schristos depmode Dependency tracking mode. 42*75fd0b74Schristos source Source file read by 'PROGRAMS ARGS'. 43*75fd0b74Schristos object Object file output by 'PROGRAMS ARGS'. 44*75fd0b74Schristos DEPDIR directory where to store dependencies. 45*75fd0b74Schristos depfile Dependency file to output. 46*75fd0b74Schristos tmpdepfile Temporary file to use when outputting dependencies. 47*75fd0b74Schristos libtool Whether libtool is used (yes/no). 48*75fd0b74Schristos 49*75fd0b74SchristosReport bugs to <bug-automake@gnu.org>. 50*75fd0b74SchristosEOF 51*75fd0b74Schristos exit $? 52*75fd0b74Schristos ;; 53*75fd0b74Schristos -v | --v*) 54*75fd0b74Schristos echo "depcomp $scriptversion" 55*75fd0b74Schristos exit $? 56*75fd0b74Schristos ;; 57*75fd0b74Schristosesac 58*75fd0b74Schristos 59*75fd0b74Schristos# Get the directory component of the given path, and save it in the 60*75fd0b74Schristos# global variables '$dir'. Note that this directory component will 61*75fd0b74Schristos# be either empty or ending with a '/' character. This is deliberate. 62*75fd0b74Schristosset_dir_from () 63*75fd0b74Schristos{ 64*75fd0b74Schristos case $1 in 65*75fd0b74Schristos */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 66*75fd0b74Schristos *) dir=;; 67*75fd0b74Schristos esac 68*75fd0b74Schristos} 69*75fd0b74Schristos 70*75fd0b74Schristos# Get the suffix-stripped basename of the given path, and save it the 71*75fd0b74Schristos# global variable '$base'. 72*75fd0b74Schristosset_base_from () 73*75fd0b74Schristos{ 74*75fd0b74Schristos base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 75*75fd0b74Schristos} 76*75fd0b74Schristos 77*75fd0b74Schristos# If no dependency file was actually created by the compiler invocation, 78*75fd0b74Schristos# we still have to create a dummy depfile, to avoid errors with the 79*75fd0b74Schristos# Makefile "include basename.Plo" scheme. 80*75fd0b74Schristosmake_dummy_depfile () 81*75fd0b74Schristos{ 82*75fd0b74Schristos echo "#dummy" > "$depfile" 83*75fd0b74Schristos} 84*75fd0b74Schristos 85*75fd0b74Schristos# Factor out some common post-processing of the generated depfile. 86*75fd0b74Schristos# Requires the auxiliary global variable '$tmpdepfile' to be set. 87*75fd0b74Schristosaix_post_process_depfile () 88*75fd0b74Schristos{ 89*75fd0b74Schristos # If the compiler actually managed to produce a dependency file, 90*75fd0b74Schristos # post-process it. 91*75fd0b74Schristos if test -f "$tmpdepfile"; then 92*75fd0b74Schristos # Each line is of the form 'foo.o: dependency.h'. 93*75fd0b74Schristos # Do two passes, one to just change these to 94*75fd0b74Schristos # $object: dependency.h 95*75fd0b74Schristos # and one to simply output 96*75fd0b74Schristos # dependency.h: 97*75fd0b74Schristos # which is needed to avoid the deleted-header problem. 98*75fd0b74Schristos { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 99*75fd0b74Schristos sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 100*75fd0b74Schristos } > "$depfile" 101*75fd0b74Schristos rm -f "$tmpdepfile" 102*75fd0b74Schristos else 103*75fd0b74Schristos make_dummy_depfile 104*75fd0b74Schristos fi 105*75fd0b74Schristos} 106*75fd0b74Schristos 107*75fd0b74Schristos# A tabulation character. 108*75fd0b74Schristostab=' ' 109*75fd0b74Schristos# A newline character. 110*75fd0b74Schristosnl=' 111*75fd0b74Schristos' 112*75fd0b74Schristos# Character ranges might be problematic outside the C locale. 113*75fd0b74Schristos# These definitions help. 114*75fd0b74Schristosupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 115*75fd0b74Schristoslower=abcdefghijklmnopqrstuvwxyz 116*75fd0b74Schristosdigits=0123456789 117*75fd0b74Schristosalpha=${upper}${lower} 118*75fd0b74Schristos 119*75fd0b74Schristosif test -z "$depmode" || test -z "$source" || test -z "$object"; then 120*75fd0b74Schristos echo "depcomp: Variables source, object and depmode must be set" 1>&2 121*75fd0b74Schristos exit 1 122*75fd0b74Schristosfi 123*75fd0b74Schristos 124*75fd0b74Schristos# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 125*75fd0b74Schristosdepfile=${depfile-`echo "$object" | 126*75fd0b74Schristos sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 127*75fd0b74Schristostmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 128*75fd0b74Schristos 129*75fd0b74Schristosrm -f "$tmpdepfile" 130*75fd0b74Schristos 131*75fd0b74Schristos# Avoid interferences from the environment. 132*75fd0b74Schristosgccflag= dashmflag= 133*75fd0b74Schristos 134*75fd0b74Schristos# Some modes work just like other modes, but use different flags. We 135*75fd0b74Schristos# parameterize here, but still list the modes in the big case below, 136*75fd0b74Schristos# to make depend.m4 easier to write. Note that we *cannot* use a case 137*75fd0b74Schristos# here, because this file can only contain one case statement. 138*75fd0b74Schristosif test "$depmode" = hp; then 139*75fd0b74Schristos # HP compiler uses -M and no extra arg. 140*75fd0b74Schristos gccflag=-M 141*75fd0b74Schristos depmode=gcc 142*75fd0b74Schristosfi 143*75fd0b74Schristos 144*75fd0b74Schristosif test "$depmode" = dashXmstdout; then 145*75fd0b74Schristos # This is just like dashmstdout with a different argument. 146*75fd0b74Schristos dashmflag=-xM 147*75fd0b74Schristos depmode=dashmstdout 148*75fd0b74Schristosfi 149*75fd0b74Schristos 150*75fd0b74Schristoscygpath_u="cygpath -u -f -" 151*75fd0b74Schristosif test "$depmode" = msvcmsys; then 152*75fd0b74Schristos # This is just like msvisualcpp but w/o cygpath translation. 153*75fd0b74Schristos # Just convert the backslash-escaped backslashes to single forward 154*75fd0b74Schristos # slashes to satisfy depend.m4 155*75fd0b74Schristos cygpath_u='sed s,\\\\,/,g' 156*75fd0b74Schristos depmode=msvisualcpp 157*75fd0b74Schristosfi 158*75fd0b74Schristos 159*75fd0b74Schristosif test "$depmode" = msvc7msys; then 160*75fd0b74Schristos # This is just like msvc7 but w/o cygpath translation. 161*75fd0b74Schristos # Just convert the backslash-escaped backslashes to single forward 162*75fd0b74Schristos # slashes to satisfy depend.m4 163*75fd0b74Schristos cygpath_u='sed s,\\\\,/,g' 164*75fd0b74Schristos depmode=msvc7 165*75fd0b74Schristosfi 166*75fd0b74Schristos 167*75fd0b74Schristosif test "$depmode" = xlc; then 168*75fd0b74Schristos # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 169*75fd0b74Schristos gccflag=-qmakedep=gcc,-MF 170*75fd0b74Schristos depmode=gcc 171*75fd0b74Schristosfi 172*75fd0b74Schristos 173*75fd0b74Schristoscase "$depmode" in 174*75fd0b74Schristosgcc3) 175*75fd0b74Schristos## gcc 3 implements dependency tracking that does exactly what 176*75fd0b74Schristos## we want. Yay! Note: for some reason libtool 1.4 doesn't like 177*75fd0b74Schristos## it if -MD -MP comes after the -MF stuff. Hmm. 178*75fd0b74Schristos## Unfortunately, FreeBSD c89 acceptance of flags depends upon 179*75fd0b74Schristos## the command line argument order; so add the flags where they 180*75fd0b74Schristos## appear in depend2.am. Note that the slowdown incurred here 181*75fd0b74Schristos## affects only configure: in makefiles, %FASTDEP% shortcuts this. 182*75fd0b74Schristos for arg 183*75fd0b74Schristos do 184*75fd0b74Schristos case $arg in 185*75fd0b74Schristos -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 186*75fd0b74Schristos *) set fnord "$@" "$arg" ;; 187*75fd0b74Schristos esac 188*75fd0b74Schristos shift # fnord 189*75fd0b74Schristos shift # $arg 190*75fd0b74Schristos done 191*75fd0b74Schristos "$@" 192*75fd0b74Schristos stat=$? 193*75fd0b74Schristos if test $stat -ne 0; then 194*75fd0b74Schristos rm -f "$tmpdepfile" 195*75fd0b74Schristos exit $stat 196*75fd0b74Schristos fi 197*75fd0b74Schristos mv "$tmpdepfile" "$depfile" 198*75fd0b74Schristos ;; 199*75fd0b74Schristos 200*75fd0b74Schristosgcc) 201*75fd0b74Schristos## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 202*75fd0b74Schristos## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 203*75fd0b74Schristos## (see the conditional assignment to $gccflag above). 204*75fd0b74Schristos## There are various ways to get dependency output from gcc. Here's 205*75fd0b74Schristos## why we pick this rather obscure method: 206*75fd0b74Schristos## - Don't want to use -MD because we'd like the dependencies to end 207*75fd0b74Schristos## up in a subdir. Having to rename by hand is ugly. 208*75fd0b74Schristos## (We might end up doing this anyway to support other compilers.) 209*75fd0b74Schristos## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 210*75fd0b74Schristos## -MM, not -M (despite what the docs say). Also, it might not be 211*75fd0b74Schristos## supported by the other compilers which use the 'gcc' depmode. 212*75fd0b74Schristos## - Using -M directly means running the compiler twice (even worse 213*75fd0b74Schristos## than renaming). 214*75fd0b74Schristos if test -z "$gccflag"; then 215*75fd0b74Schristos gccflag=-MD, 216*75fd0b74Schristos fi 217*75fd0b74Schristos "$@" -Wp,"$gccflag$tmpdepfile" 218*75fd0b74Schristos stat=$? 219*75fd0b74Schristos if test $stat -ne 0; then 220*75fd0b74Schristos rm -f "$tmpdepfile" 221*75fd0b74Schristos exit $stat 222*75fd0b74Schristos fi 223*75fd0b74Schristos rm -f "$depfile" 224*75fd0b74Schristos echo "$object : \\" > "$depfile" 225*75fd0b74Schristos # The second -e expression handles DOS-style file names with drive 226*75fd0b74Schristos # letters. 227*75fd0b74Schristos sed -e 's/^[^:]*: / /' \ 228*75fd0b74Schristos -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229*75fd0b74Schristos## This next piece of magic avoids the "deleted header file" problem. 230*75fd0b74Schristos## The problem is that when a header file which appears in a .P file 231*75fd0b74Schristos## is deleted, the dependency causes make to die (because there is 232*75fd0b74Schristos## typically no way to rebuild the header). We avoid this by adding 233*75fd0b74Schristos## dummy dependencies for each header file. Too bad gcc doesn't do 234*75fd0b74Schristos## this for us directly. 235*75fd0b74Schristos## Some versions of gcc put a space before the ':'. On the theory 236*75fd0b74Schristos## that the space means something, we add a space to the output as 237*75fd0b74Schristos## well. hp depmode also adds that space, but also prefixes the VPATH 238*75fd0b74Schristos## to the object. Take care to not repeat it in the output. 239*75fd0b74Schristos## Some versions of the HPUX 10.20 sed can't process this invocation 240*75fd0b74Schristos## correctly. Breaking it into two sed invocations is a workaround. 241*75fd0b74Schristos tr ' ' "$nl" < "$tmpdepfile" \ 242*75fd0b74Schristos | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243*75fd0b74Schristos | sed -e 's/$/ :/' >> "$depfile" 244*75fd0b74Schristos rm -f "$tmpdepfile" 245*75fd0b74Schristos ;; 246*75fd0b74Schristos 247*75fd0b74Schristoshp) 248*75fd0b74Schristos # This case exists only to let depend.m4 do its work. It works by 249*75fd0b74Schristos # looking at the text of this script. This case will never be run, 250*75fd0b74Schristos # since it is checked for above. 251*75fd0b74Schristos exit 1 252*75fd0b74Schristos ;; 253*75fd0b74Schristos 254*75fd0b74Schristosxlc) 255*75fd0b74Schristos # This case exists only to let depend.m4 do its work. It works by 256*75fd0b74Schristos # looking at the text of this script. This case will never be run, 257*75fd0b74Schristos # since it is checked for above. 258*75fd0b74Schristos exit 1 259*75fd0b74Schristos ;; 260*75fd0b74Schristos 261*75fd0b74Schristosaix) 262*75fd0b74Schristos # The C for AIX Compiler uses -M and outputs the dependencies 263*75fd0b74Schristos # in a .u file. In older versions, this file always lives in the 264*75fd0b74Schristos # current directory. Also, the AIX compiler puts '$object:' at the 265*75fd0b74Schristos # start of each line; $object doesn't have directory information. 266*75fd0b74Schristos # Version 6 uses the directory in both cases. 267*75fd0b74Schristos set_dir_from "$object" 268*75fd0b74Schristos set_base_from "$object" 269*75fd0b74Schristos if test "$libtool" = yes; then 270*75fd0b74Schristos tmpdepfile1=$dir$base.u 271*75fd0b74Schristos tmpdepfile2=$base.u 272*75fd0b74Schristos tmpdepfile3=$dir.libs/$base.u 273*75fd0b74Schristos "$@" -Wc,-M 274*75fd0b74Schristos else 275*75fd0b74Schristos tmpdepfile1=$dir$base.u 276*75fd0b74Schristos tmpdepfile2=$dir$base.u 277*75fd0b74Schristos tmpdepfile3=$dir$base.u 278*75fd0b74Schristos "$@" -M 279*75fd0b74Schristos fi 280*75fd0b74Schristos stat=$? 281*75fd0b74Schristos if test $stat -ne 0; then 282*75fd0b74Schristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 283*75fd0b74Schristos exit $stat 284*75fd0b74Schristos fi 285*75fd0b74Schristos 286*75fd0b74Schristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 287*75fd0b74Schristos do 288*75fd0b74Schristos test -f "$tmpdepfile" && break 289*75fd0b74Schristos done 290*75fd0b74Schristos aix_post_process_depfile 291*75fd0b74Schristos ;; 292*75fd0b74Schristos 293*75fd0b74Schristostcc) 294*75fd0b74Schristos # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 295*75fd0b74Schristos # FIXME: That version still under development at the moment of writing. 296*75fd0b74Schristos # Make that this statement remains true also for stable, released 297*75fd0b74Schristos # versions. 298*75fd0b74Schristos # It will wrap lines (doesn't matter whether long or short) with a 299*75fd0b74Schristos # trailing '\', as in: 300*75fd0b74Schristos # 301*75fd0b74Schristos # foo.o : \ 302*75fd0b74Schristos # foo.c \ 303*75fd0b74Schristos # foo.h \ 304*75fd0b74Schristos # 305*75fd0b74Schristos # It will put a trailing '\' even on the last line, and will use leading 306*75fd0b74Schristos # spaces rather than leading tabs (at least since its commit 0394caf7 307*75fd0b74Schristos # "Emit spaces for -MD"). 308*75fd0b74Schristos "$@" -MD -MF "$tmpdepfile" 309*75fd0b74Schristos stat=$? 310*75fd0b74Schristos if test $stat -ne 0; then 311*75fd0b74Schristos rm -f "$tmpdepfile" 312*75fd0b74Schristos exit $stat 313*75fd0b74Schristos fi 314*75fd0b74Schristos rm -f "$depfile" 315*75fd0b74Schristos # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 316*75fd0b74Schristos # We have to change lines of the first kind to '$object: \'. 317*75fd0b74Schristos sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 318*75fd0b74Schristos # And for each line of the second kind, we have to emit a 'dep.h:' 319*75fd0b74Schristos # dummy dependency, to avoid the deleted-header problem. 320*75fd0b74Schristos sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 321*75fd0b74Schristos rm -f "$tmpdepfile" 322*75fd0b74Schristos ;; 323*75fd0b74Schristos 324*75fd0b74Schristos## The order of this option in the case statement is important, since the 325*75fd0b74Schristos## shell code in configure will try each of these formats in the order 326*75fd0b74Schristos## listed in this file. A plain '-MD' option would be understood by many 327*75fd0b74Schristos## compilers, so we must ensure this comes after the gcc and icc options. 328*75fd0b74Schristospgcc) 329*75fd0b74Schristos # Portland's C compiler understands '-MD'. 330*75fd0b74Schristos # Will always output deps to 'file.d' where file is the root name of the 331*75fd0b74Schristos # source file under compilation, even if file resides in a subdirectory. 332*75fd0b74Schristos # The object file name does not affect the name of the '.d' file. 333*75fd0b74Schristos # pgcc 10.2 will output 334*75fd0b74Schristos # foo.o: sub/foo.c sub/foo.h 335*75fd0b74Schristos # and will wrap long lines using '\' : 336*75fd0b74Schristos # foo.o: sub/foo.c ... \ 337*75fd0b74Schristos # sub/foo.h ... \ 338*75fd0b74Schristos # ... 339*75fd0b74Schristos set_dir_from "$object" 340*75fd0b74Schristos # Use the source, not the object, to determine the base name, since 341*75fd0b74Schristos # that's sadly what pgcc will do too. 342*75fd0b74Schristos set_base_from "$source" 343*75fd0b74Schristos tmpdepfile=$base.d 344*75fd0b74Schristos 345*75fd0b74Schristos # For projects that build the same source file twice into different object 346*75fd0b74Schristos # files, the pgcc approach of using the *source* file root name can cause 347*75fd0b74Schristos # problems in parallel builds. Use a locking strategy to avoid stomping on 348*75fd0b74Schristos # the same $tmpdepfile. 349*75fd0b74Schristos lockdir=$base.d-lock 350*75fd0b74Schristos trap " 351*75fd0b74Schristos echo '$0: caught signal, cleaning up...' >&2 352*75fd0b74Schristos rmdir '$lockdir' 353*75fd0b74Schristos exit 1 354*75fd0b74Schristos " 1 2 13 15 355*75fd0b74Schristos numtries=100 356*75fd0b74Schristos i=$numtries 357*75fd0b74Schristos while test $i -gt 0; do 358*75fd0b74Schristos # mkdir is a portable test-and-set. 359*75fd0b74Schristos if mkdir "$lockdir" 2>/dev/null; then 360*75fd0b74Schristos # This process acquired the lock. 361*75fd0b74Schristos "$@" -MD 362*75fd0b74Schristos stat=$? 363*75fd0b74Schristos # Release the lock. 364*75fd0b74Schristos rmdir "$lockdir" 365*75fd0b74Schristos break 366*75fd0b74Schristos else 367*75fd0b74Schristos # If the lock is being held by a different process, wait 368*75fd0b74Schristos # until the winning process is done or we timeout. 369*75fd0b74Schristos while test -d "$lockdir" && test $i -gt 0; do 370*75fd0b74Schristos sleep 1 371*75fd0b74Schristos i=`expr $i - 1` 372*75fd0b74Schristos done 373*75fd0b74Schristos fi 374*75fd0b74Schristos i=`expr $i - 1` 375*75fd0b74Schristos done 376*75fd0b74Schristos trap - 1 2 13 15 377*75fd0b74Schristos if test $i -le 0; then 378*75fd0b74Schristos echo "$0: failed to acquire lock after $numtries attempts" >&2 379*75fd0b74Schristos echo "$0: check lockdir '$lockdir'" >&2 380*75fd0b74Schristos exit 1 381*75fd0b74Schristos fi 382*75fd0b74Schristos 383*75fd0b74Schristos if test $stat -ne 0; then 384*75fd0b74Schristos rm -f "$tmpdepfile" 385*75fd0b74Schristos exit $stat 386*75fd0b74Schristos fi 387*75fd0b74Schristos rm -f "$depfile" 388*75fd0b74Schristos # Each line is of the form `foo.o: dependent.h', 389*75fd0b74Schristos # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 390*75fd0b74Schristos # Do two passes, one to just change these to 391*75fd0b74Schristos # `$object: dependent.h' and one to simply `dependent.h:'. 392*75fd0b74Schristos sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 393*75fd0b74Schristos # Some versions of the HPUX 10.20 sed can't process this invocation 394*75fd0b74Schristos # correctly. Breaking it into two sed invocations is a workaround. 395*75fd0b74Schristos sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 396*75fd0b74Schristos | sed -e 's/$/ :/' >> "$depfile" 397*75fd0b74Schristos rm -f "$tmpdepfile" 398*75fd0b74Schristos ;; 399*75fd0b74Schristos 400*75fd0b74Schristoshp2) 401*75fd0b74Schristos # The "hp" stanza above does not work with aCC (C++) and HP's ia64 402*75fd0b74Schristos # compilers, which have integrated preprocessors. The correct option 403*75fd0b74Schristos # to use with these is +Maked; it writes dependencies to a file named 404*75fd0b74Schristos # 'foo.d', which lands next to the object file, wherever that 405*75fd0b74Schristos # happens to be. 406*75fd0b74Schristos # Much of this is similar to the tru64 case; see comments there. 407*75fd0b74Schristos set_dir_from "$object" 408*75fd0b74Schristos set_base_from "$object" 409*75fd0b74Schristos if test "$libtool" = yes; then 410*75fd0b74Schristos tmpdepfile1=$dir$base.d 411*75fd0b74Schristos tmpdepfile2=$dir.libs/$base.d 412*75fd0b74Schristos "$@" -Wc,+Maked 413*75fd0b74Schristos else 414*75fd0b74Schristos tmpdepfile1=$dir$base.d 415*75fd0b74Schristos tmpdepfile2=$dir$base.d 416*75fd0b74Schristos "$@" +Maked 417*75fd0b74Schristos fi 418*75fd0b74Schristos stat=$? 419*75fd0b74Schristos if test $stat -ne 0; then 420*75fd0b74Schristos rm -f "$tmpdepfile1" "$tmpdepfile2" 421*75fd0b74Schristos exit $stat 422*75fd0b74Schristos fi 423*75fd0b74Schristos 424*75fd0b74Schristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 425*75fd0b74Schristos do 426*75fd0b74Schristos test -f "$tmpdepfile" && break 427*75fd0b74Schristos done 428*75fd0b74Schristos if test -f "$tmpdepfile"; then 429*75fd0b74Schristos sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 430*75fd0b74Schristos # Add 'dependent.h:' lines. 431*75fd0b74Schristos sed -ne '2,${ 432*75fd0b74Schristos s/^ *// 433*75fd0b74Schristos s/ \\*$// 434*75fd0b74Schristos s/$/:/ 435*75fd0b74Schristos p 436*75fd0b74Schristos }' "$tmpdepfile" >> "$depfile" 437*75fd0b74Schristos else 438*75fd0b74Schristos make_dummy_depfile 439*75fd0b74Schristos fi 440*75fd0b74Schristos rm -f "$tmpdepfile" "$tmpdepfile2" 441*75fd0b74Schristos ;; 442*75fd0b74Schristos 443*75fd0b74Schristostru64) 444*75fd0b74Schristos # The Tru64 compiler uses -MD to generate dependencies as a side 445*75fd0b74Schristos # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 446*75fd0b74Schristos # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 447*75fd0b74Schristos # dependencies in 'foo.d' instead, so we check for that too. 448*75fd0b74Schristos # Subdirectories are respected. 449*75fd0b74Schristos set_dir_from "$object" 450*75fd0b74Schristos set_base_from "$object" 451*75fd0b74Schristos 452*75fd0b74Schristos if test "$libtool" = yes; then 453*75fd0b74Schristos # Libtool generates 2 separate objects for the 2 libraries. These 454*75fd0b74Schristos # two compilations output dependencies in $dir.libs/$base.o.d and 455*75fd0b74Schristos # in $dir$base.o.d. We have to check for both files, because 456*75fd0b74Schristos # one of the two compilations can be disabled. We should prefer 457*75fd0b74Schristos # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 458*75fd0b74Schristos # automatically cleaned when .libs/ is deleted, while ignoring 459*75fd0b74Schristos # the former would cause a distcleancheck panic. 460*75fd0b74Schristos tmpdepfile1=$dir$base.o.d # libtool 1.5 461*75fd0b74Schristos tmpdepfile2=$dir.libs/$base.o.d # Likewise. 462*75fd0b74Schristos tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 463*75fd0b74Schristos "$@" -Wc,-MD 464*75fd0b74Schristos else 465*75fd0b74Schristos tmpdepfile1=$dir$base.d 466*75fd0b74Schristos tmpdepfile2=$dir$base.d 467*75fd0b74Schristos tmpdepfile3=$dir$base.d 468*75fd0b74Schristos "$@" -MD 469*75fd0b74Schristos fi 470*75fd0b74Schristos 471*75fd0b74Schristos stat=$? 472*75fd0b74Schristos if test $stat -ne 0; then 473*75fd0b74Schristos rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 474*75fd0b74Schristos exit $stat 475*75fd0b74Schristos fi 476*75fd0b74Schristos 477*75fd0b74Schristos for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 478*75fd0b74Schristos do 479*75fd0b74Schristos test -f "$tmpdepfile" && break 480*75fd0b74Schristos done 481*75fd0b74Schristos # Same post-processing that is required for AIX mode. 482*75fd0b74Schristos aix_post_process_depfile 483*75fd0b74Schristos ;; 484*75fd0b74Schristos 485*75fd0b74Schristosmsvc7) 486*75fd0b74Schristos if test "$libtool" = yes; then 487*75fd0b74Schristos showIncludes=-Wc,-showIncludes 488*75fd0b74Schristos else 489*75fd0b74Schristos showIncludes=-showIncludes 490*75fd0b74Schristos fi 491*75fd0b74Schristos "$@" $showIncludes > "$tmpdepfile" 492*75fd0b74Schristos stat=$? 493*75fd0b74Schristos grep -v '^Note: including file: ' "$tmpdepfile" 494*75fd0b74Schristos if test $stat -ne 0; then 495*75fd0b74Schristos rm -f "$tmpdepfile" 496*75fd0b74Schristos exit $stat 497*75fd0b74Schristos fi 498*75fd0b74Schristos rm -f "$depfile" 499*75fd0b74Schristos echo "$object : \\" > "$depfile" 500*75fd0b74Schristos # The first sed program below extracts the file names and escapes 501*75fd0b74Schristos # backslashes for cygpath. The second sed program outputs the file 502*75fd0b74Schristos # name when reading, but also accumulates all include files in the 503*75fd0b74Schristos # hold buffer in order to output them again at the end. This only 504*75fd0b74Schristos # works with sed implementations that can handle large buffers. 505*75fd0b74Schristos sed < "$tmpdepfile" -n ' 506*75fd0b74Schristos/^Note: including file: *\(.*\)/ { 507*75fd0b74Schristos s//\1/ 508*75fd0b74Schristos s/\\/\\\\/g 509*75fd0b74Schristos p 510*75fd0b74Schristos}' | $cygpath_u | sort -u | sed -n ' 511*75fd0b74Schristoss/ /\\ /g 512*75fd0b74Schristoss/\(.*\)/'"$tab"'\1 \\/p 513*75fd0b74Schristoss/.\(.*\) \\/\1:/ 514*75fd0b74SchristosH 515*75fd0b74Schristos$ { 516*75fd0b74Schristos s/.*/'"$tab"'/ 517*75fd0b74Schristos G 518*75fd0b74Schristos p 519*75fd0b74Schristos}' >> "$depfile" 520*75fd0b74Schristos echo >> "$depfile" # make sure the fragment doesn't end with a backslash 521*75fd0b74Schristos rm -f "$tmpdepfile" 522*75fd0b74Schristos ;; 523*75fd0b74Schristos 524*75fd0b74Schristosmsvc7msys) 525*75fd0b74Schristos # This case exists only to let depend.m4 do its work. It works by 526*75fd0b74Schristos # looking at the text of this script. This case will never be run, 527*75fd0b74Schristos # since it is checked for above. 528*75fd0b74Schristos exit 1 529*75fd0b74Schristos ;; 530*75fd0b74Schristos 531*75fd0b74Schristos#nosideeffect) 532*75fd0b74Schristos # This comment above is used by automake to tell side-effect 533*75fd0b74Schristos # dependency tracking mechanisms from slower ones. 534*75fd0b74Schristos 535*75fd0b74Schristosdashmstdout) 536*75fd0b74Schristos # Important note: in order to support this mode, a compiler *must* 537*75fd0b74Schristos # always write the preprocessed file to stdout, regardless of -o. 538*75fd0b74Schristos "$@" || exit $? 539*75fd0b74Schristos 540*75fd0b74Schristos # Remove the call to Libtool. 541*75fd0b74Schristos if test "$libtool" = yes; then 542*75fd0b74Schristos while test "X$1" != 'X--mode=compile'; do 543*75fd0b74Schristos shift 544*75fd0b74Schristos done 545*75fd0b74Schristos shift 546*75fd0b74Schristos fi 547*75fd0b74Schristos 548*75fd0b74Schristos # Remove '-o $object'. 549*75fd0b74Schristos IFS=" " 550*75fd0b74Schristos for arg 551*75fd0b74Schristos do 552*75fd0b74Schristos case $arg in 553*75fd0b74Schristos -o) 554*75fd0b74Schristos shift 555*75fd0b74Schristos ;; 556*75fd0b74Schristos $object) 557*75fd0b74Schristos shift 558*75fd0b74Schristos ;; 559*75fd0b74Schristos *) 560*75fd0b74Schristos set fnord "$@" "$arg" 561*75fd0b74Schristos shift # fnord 562*75fd0b74Schristos shift # $arg 563*75fd0b74Schristos ;; 564*75fd0b74Schristos esac 565*75fd0b74Schristos done 566*75fd0b74Schristos 567*75fd0b74Schristos test -z "$dashmflag" && dashmflag=-M 568*75fd0b74Schristos # Require at least two characters before searching for ':' 569*75fd0b74Schristos # in the target name. This is to cope with DOS-style filenames: 570*75fd0b74Schristos # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 571*75fd0b74Schristos "$@" $dashmflag | 572*75fd0b74Schristos sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 573*75fd0b74Schristos rm -f "$depfile" 574*75fd0b74Schristos cat < "$tmpdepfile" > "$depfile" 575*75fd0b74Schristos # Some versions of the HPUX 10.20 sed can't process this sed invocation 576*75fd0b74Schristos # correctly. Breaking it into two sed invocations is a workaround. 577*75fd0b74Schristos tr ' ' "$nl" < "$tmpdepfile" \ 578*75fd0b74Schristos | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 579*75fd0b74Schristos | sed -e 's/$/ :/' >> "$depfile" 580*75fd0b74Schristos rm -f "$tmpdepfile" 581*75fd0b74Schristos ;; 582*75fd0b74Schristos 583*75fd0b74SchristosdashXmstdout) 584*75fd0b74Schristos # This case only exists to satisfy depend.m4. It is never actually 585*75fd0b74Schristos # run, as this mode is specially recognized in the preamble. 586*75fd0b74Schristos exit 1 587*75fd0b74Schristos ;; 588*75fd0b74Schristos 589*75fd0b74Schristosmakedepend) 590*75fd0b74Schristos "$@" || exit $? 591*75fd0b74Schristos # Remove any Libtool call 592*75fd0b74Schristos if test "$libtool" = yes; then 593*75fd0b74Schristos while test "X$1" != 'X--mode=compile'; do 594*75fd0b74Schristos shift 595*75fd0b74Schristos done 596*75fd0b74Schristos shift 597*75fd0b74Schristos fi 598*75fd0b74Schristos # X makedepend 599*75fd0b74Schristos shift 600*75fd0b74Schristos cleared=no eat=no 601*75fd0b74Schristos for arg 602*75fd0b74Schristos do 603*75fd0b74Schristos case $cleared in 604*75fd0b74Schristos no) 605*75fd0b74Schristos set ""; shift 606*75fd0b74Schristos cleared=yes ;; 607*75fd0b74Schristos esac 608*75fd0b74Schristos if test $eat = yes; then 609*75fd0b74Schristos eat=no 610*75fd0b74Schristos continue 611*75fd0b74Schristos fi 612*75fd0b74Schristos case "$arg" in 613*75fd0b74Schristos -D*|-I*) 614*75fd0b74Schristos set fnord "$@" "$arg"; shift ;; 615*75fd0b74Schristos # Strip any option that makedepend may not understand. Remove 616*75fd0b74Schristos # the object too, otherwise makedepend will parse it as a source file. 617*75fd0b74Schristos -arch) 618*75fd0b74Schristos eat=yes ;; 619*75fd0b74Schristos -*|$object) 620*75fd0b74Schristos ;; 621*75fd0b74Schristos *) 622*75fd0b74Schristos set fnord "$@" "$arg"; shift ;; 623*75fd0b74Schristos esac 624*75fd0b74Schristos done 625*75fd0b74Schristos obj_suffix=`echo "$object" | sed 's/^.*\././'` 626*75fd0b74Schristos touch "$tmpdepfile" 627*75fd0b74Schristos ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 628*75fd0b74Schristos rm -f "$depfile" 629*75fd0b74Schristos # makedepend may prepend the VPATH from the source file name to the object. 630*75fd0b74Schristos # No need to regex-escape $object, excess matching of '.' is harmless. 631*75fd0b74Schristos sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 632*75fd0b74Schristos # Some versions of the HPUX 10.20 sed can't process the last invocation 633*75fd0b74Schristos # correctly. Breaking it into two sed invocations is a workaround. 634*75fd0b74Schristos sed '1,2d' "$tmpdepfile" \ 635*75fd0b74Schristos | tr ' ' "$nl" \ 636*75fd0b74Schristos | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 637*75fd0b74Schristos | sed -e 's/$/ :/' >> "$depfile" 638*75fd0b74Schristos rm -f "$tmpdepfile" "$tmpdepfile".bak 639*75fd0b74Schristos ;; 640*75fd0b74Schristos 641*75fd0b74Schristoscpp) 642*75fd0b74Schristos # Important note: in order to support this mode, a compiler *must* 643*75fd0b74Schristos # always write the preprocessed file to stdout. 644*75fd0b74Schristos "$@" || exit $? 645*75fd0b74Schristos 646*75fd0b74Schristos # Remove the call to Libtool. 647*75fd0b74Schristos if test "$libtool" = yes; then 648*75fd0b74Schristos while test "X$1" != 'X--mode=compile'; do 649*75fd0b74Schristos shift 650*75fd0b74Schristos done 651*75fd0b74Schristos shift 652*75fd0b74Schristos fi 653*75fd0b74Schristos 654*75fd0b74Schristos # Remove '-o $object'. 655*75fd0b74Schristos IFS=" " 656*75fd0b74Schristos for arg 657*75fd0b74Schristos do 658*75fd0b74Schristos case $arg in 659*75fd0b74Schristos -o) 660*75fd0b74Schristos shift 661*75fd0b74Schristos ;; 662*75fd0b74Schristos $object) 663*75fd0b74Schristos shift 664*75fd0b74Schristos ;; 665*75fd0b74Schristos *) 666*75fd0b74Schristos set fnord "$@" "$arg" 667*75fd0b74Schristos shift # fnord 668*75fd0b74Schristos shift # $arg 669*75fd0b74Schristos ;; 670*75fd0b74Schristos esac 671*75fd0b74Schristos done 672*75fd0b74Schristos 673*75fd0b74Schristos "$@" -E \ 674*75fd0b74Schristos | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 675*75fd0b74Schristos -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 676*75fd0b74Schristos | sed '$ s: \\$::' > "$tmpdepfile" 677*75fd0b74Schristos rm -f "$depfile" 678*75fd0b74Schristos echo "$object : \\" > "$depfile" 679*75fd0b74Schristos cat < "$tmpdepfile" >> "$depfile" 680*75fd0b74Schristos sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 681*75fd0b74Schristos rm -f "$tmpdepfile" 682*75fd0b74Schristos ;; 683*75fd0b74Schristos 684*75fd0b74Schristosmsvisualcpp) 685*75fd0b74Schristos # Important note: in order to support this mode, a compiler *must* 686*75fd0b74Schristos # always write the preprocessed file to stdout. 687*75fd0b74Schristos "$@" || exit $? 688*75fd0b74Schristos 689*75fd0b74Schristos # Remove the call to Libtool. 690*75fd0b74Schristos if test "$libtool" = yes; then 691*75fd0b74Schristos while test "X$1" != 'X--mode=compile'; do 692*75fd0b74Schristos shift 693*75fd0b74Schristos done 694*75fd0b74Schristos shift 695*75fd0b74Schristos fi 696*75fd0b74Schristos 697*75fd0b74Schristos IFS=" " 698*75fd0b74Schristos for arg 699*75fd0b74Schristos do 700*75fd0b74Schristos case "$arg" in 701*75fd0b74Schristos -o) 702*75fd0b74Schristos shift 703*75fd0b74Schristos ;; 704*75fd0b74Schristos $object) 705*75fd0b74Schristos shift 706*75fd0b74Schristos ;; 707*75fd0b74Schristos "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 708*75fd0b74Schristos set fnord "$@" 709*75fd0b74Schristos shift 710*75fd0b74Schristos shift 711*75fd0b74Schristos ;; 712*75fd0b74Schristos *) 713*75fd0b74Schristos set fnord "$@" "$arg" 714*75fd0b74Schristos shift 715*75fd0b74Schristos shift 716*75fd0b74Schristos ;; 717*75fd0b74Schristos esac 718*75fd0b74Schristos done 719*75fd0b74Schristos "$@" -E 2>/dev/null | 720*75fd0b74Schristos sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 721*75fd0b74Schristos rm -f "$depfile" 722*75fd0b74Schristos echo "$object : \\" > "$depfile" 723*75fd0b74Schristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 724*75fd0b74Schristos echo "$tab" >> "$depfile" 725*75fd0b74Schristos sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 726*75fd0b74Schristos rm -f "$tmpdepfile" 727*75fd0b74Schristos ;; 728*75fd0b74Schristos 729*75fd0b74Schristosmsvcmsys) 730*75fd0b74Schristos # This case exists only to let depend.m4 do its work. It works by 731*75fd0b74Schristos # looking at the text of this script. This case will never be run, 732*75fd0b74Schristos # since it is checked for above. 733*75fd0b74Schristos exit 1 734*75fd0b74Schristos ;; 735*75fd0b74Schristos 736*75fd0b74Schristosnone) 737*75fd0b74Schristos exec "$@" 738*75fd0b74Schristos ;; 739*75fd0b74Schristos 740*75fd0b74Schristos*) 741*75fd0b74Schristos echo "Unknown depmode $depmode" 1>&2 742*75fd0b74Schristos exit 1 743*75fd0b74Schristos ;; 744*75fd0b74Schristosesac 745*75fd0b74Schristos 746*75fd0b74Schristosexit 0 747*75fd0b74Schristos 748*75fd0b74Schristos# Local Variables: 749*75fd0b74Schristos# mode: shell-script 750*75fd0b74Schristos# sh-indentation: 2 751*75fd0b74Schristos# eval: (add-hook 'write-file-hooks 'time-stamp) 752*75fd0b74Schristos# time-stamp-start: "scriptversion=" 753*75fd0b74Schristos# time-stamp-format: "%:y-%02m-%02d.%02H" 754*75fd0b74Schristos# time-stamp-time-zone: "UTC" 755*75fd0b74Schristos# time-stamp-end: "; # UTC" 756*75fd0b74Schristos# End: 757