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