1
0

depcomp 23 KB

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