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