You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

787 lines
23 KiB

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