depcomp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. #! /bin/sh
  2. # depcomp - compile a program generating dependencies as side-effects
  3. scriptversion=2012-03-27.16; # 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. hp2)
  305. # The "hp" stanza above does not work with aCC (C++) and HP's ia64
  306. # compilers, which have integrated preprocessors. The correct option
  307. # to use with these is +Maked; it writes dependencies to a file named
  308. # 'foo.d', which lands next to the object file, wherever that
  309. # happens to be.
  310. # Much of this is similar to the tru64 case; see comments there.
  311. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
  312. test "x$dir" = "x$object" && dir=
  313. base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
  314. if test "$libtool" = yes; then
  315. tmpdepfile1=$dir$base.d
  316. tmpdepfile2=$dir.libs/$base.d
  317. "$@" -Wc,+Maked
  318. else
  319. tmpdepfile1=$dir$base.d
  320. tmpdepfile2=$dir$base.d
  321. "$@" +Maked
  322. fi
  323. stat=$?
  324. if test $stat -eq 0; then :
  325. else
  326. rm -f "$tmpdepfile1" "$tmpdepfile2"
  327. exit $stat
  328. fi
  329. for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
  330. do
  331. test -f "$tmpdepfile" && break
  332. done
  333. if test -f "$tmpdepfile"; then
  334. sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
  335. # Add 'dependent.h:' lines.
  336. sed -ne '2,${
  337. s/^ *//
  338. s/ \\*$//
  339. s/$/:/
  340. p
  341. }' "$tmpdepfile" >> "$depfile"
  342. else
  343. echo "#dummy" > "$depfile"
  344. fi
  345. rm -f "$tmpdepfile" "$tmpdepfile2"
  346. ;;
  347. tru64)
  348. # The Tru64 compiler uses -MD to generate dependencies as a side
  349. # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
  350. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
  351. # dependencies in 'foo.d' instead, so we check for that too.
  352. # Subdirectories are respected.
  353. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
  354. test "x$dir" = "x$object" && dir=
  355. base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
  356. if test "$libtool" = yes; then
  357. # With Tru64 cc, shared objects can also be used to make a
  358. # static library. This mechanism is used in libtool 1.4 series to
  359. # handle both shared and static libraries in a single compilation.
  360. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
  361. #
  362. # With libtool 1.5 this exception was removed, and libtool now
  363. # generates 2 separate objects for the 2 libraries. These two
  364. # compilations output dependencies in $dir.libs/$base.o.d and
  365. # in $dir$base.o.d. We have to check for both files, because
  366. # one of the two compilations can be disabled. We should prefer
  367. # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
  368. # automatically cleaned when .libs/ is deleted, while ignoring
  369. # the former would cause a distcleancheck panic.
  370. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
  371. tmpdepfile2=$dir$base.o.d # libtool 1.5
  372. tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
  373. tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
  374. "$@" -Wc,-MD
  375. else
  376. tmpdepfile1=$dir$base.o.d
  377. tmpdepfile2=$dir$base.d
  378. tmpdepfile3=$dir$base.d
  379. tmpdepfile4=$dir$base.d
  380. "$@" -MD
  381. fi
  382. stat=$?
  383. if test $stat -eq 0; then :
  384. else
  385. rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
  386. exit $stat
  387. fi
  388. for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
  389. do
  390. test -f "$tmpdepfile" && break
  391. done
  392. if test -f "$tmpdepfile"; then
  393. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
  394. sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
  395. else
  396. echo "#dummy" > "$depfile"
  397. fi
  398. rm -f "$tmpdepfile"
  399. ;;
  400. msvc7)
  401. if test "$libtool" = yes; then
  402. showIncludes=-Wc,-showIncludes
  403. else
  404. showIncludes=-showIncludes
  405. fi
  406. "$@" $showIncludes > "$tmpdepfile"
  407. stat=$?
  408. grep -v '^Note: including file: ' "$tmpdepfile"
  409. if test "$stat" = 0; then :
  410. else
  411. rm -f "$tmpdepfile"
  412. exit $stat
  413. fi
  414. rm -f "$depfile"
  415. echo "$object : \\" > "$depfile"
  416. # The first sed program below extracts the file names and escapes
  417. # backslashes for cygpath. The second sed program outputs the file
  418. # name when reading, but also accumulates all include files in the
  419. # hold buffer in order to output them again at the end. This only
  420. # works with sed implementations that can handle large buffers.
  421. sed < "$tmpdepfile" -n '
  422. /^Note: including file: *\(.*\)/ {
  423. s//\1/
  424. s/\\/\\\\/g
  425. p
  426. }' | $cygpath_u | sort -u | sed -n '
  427. s/ /\\ /g
  428. s/\(.*\)/'"$tab"'\1 \\/p
  429. s/.\(.*\) \\/\1:/
  430. H
  431. $ {
  432. s/.*/'"$tab"'/
  433. G
  434. p
  435. }' >> "$depfile"
  436. rm -f "$tmpdepfile"
  437. ;;
  438. msvc7msys)
  439. # This case exists only to let depend.m4 do its work. It works by
  440. # looking at the text of this script. This case will never be run,
  441. # since it is checked for above.
  442. exit 1
  443. ;;
  444. #nosideeffect)
  445. # This comment above is used by automake to tell side-effect
  446. # dependency tracking mechanisms from slower ones.
  447. dashmstdout)
  448. # Important note: in order to support this mode, a compiler *must*
  449. # always write the preprocessed file to stdout, regardless of -o.
  450. "$@" || exit $?
  451. # Remove the call to Libtool.
  452. if test "$libtool" = yes; then
  453. while test "X$1" != 'X--mode=compile'; do
  454. shift
  455. done
  456. shift
  457. fi
  458. # Remove '-o $object'.
  459. IFS=" "
  460. for arg
  461. do
  462. case $arg in
  463. -o)
  464. shift
  465. ;;
  466. $object)
  467. shift
  468. ;;
  469. *)
  470. set fnord "$@" "$arg"
  471. shift # fnord
  472. shift # $arg
  473. ;;
  474. esac
  475. done
  476. test -z "$dashmflag" && dashmflag=-M
  477. # Require at least two characters before searching for ':'
  478. # in the target name. This is to cope with DOS-style filenames:
  479. # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
  480. "$@" $dashmflag |
  481. sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
  482. rm -f "$depfile"
  483. cat < "$tmpdepfile" > "$depfile"
  484. tr ' ' "$nl" < "$tmpdepfile" | \
  485. ## Some versions of the HPUX 10.20 sed can't process this invocation
  486. ## correctly. Breaking it into two sed invocations is a workaround.
  487. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  488. rm -f "$tmpdepfile"
  489. ;;
  490. dashXmstdout)
  491. # This case only exists to satisfy depend.m4. It is never actually
  492. # run, as this mode is specially recognized in the preamble.
  493. exit 1
  494. ;;
  495. makedepend)
  496. "$@" || exit $?
  497. # Remove any Libtool call
  498. if test "$libtool" = yes; then
  499. while test "X$1" != 'X--mode=compile'; do
  500. shift
  501. done
  502. shift
  503. fi
  504. # X makedepend
  505. shift
  506. cleared=no eat=no
  507. for arg
  508. do
  509. case $cleared in
  510. no)
  511. set ""; shift
  512. cleared=yes ;;
  513. esac
  514. if test $eat = yes; then
  515. eat=no
  516. continue
  517. fi
  518. case "$arg" in
  519. -D*|-I*)
  520. set fnord "$@" "$arg"; shift ;;
  521. # Strip any option that makedepend may not understand. Remove
  522. # the object too, otherwise makedepend will parse it as a source file.
  523. -arch)
  524. eat=yes ;;
  525. -*|$object)
  526. ;;
  527. *)
  528. set fnord "$@" "$arg"; shift ;;
  529. esac
  530. done
  531. obj_suffix=`echo "$object" | sed 's/^.*\././'`
  532. touch "$tmpdepfile"
  533. ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
  534. rm -f "$depfile"
  535. # makedepend may prepend the VPATH from the source file name to the object.
  536. # No need to regex-escape $object, excess matching of '.' is harmless.
  537. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
  538. sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
  539. ## Some versions of the HPUX 10.20 sed can't process this invocation
  540. ## correctly. Breaking it into two sed invocations is a workaround.
  541. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  542. rm -f "$tmpdepfile" "$tmpdepfile".bak
  543. ;;
  544. cpp)
  545. # Important note: in order to support this mode, a compiler *must*
  546. # always write the preprocessed file to stdout.
  547. "$@" || exit $?
  548. # Remove the call to Libtool.
  549. if test "$libtool" = yes; then
  550. while test "X$1" != 'X--mode=compile'; do
  551. shift
  552. done
  553. shift
  554. fi
  555. # Remove '-o $object'.
  556. IFS=" "
  557. for arg
  558. do
  559. case $arg in
  560. -o)
  561. shift
  562. ;;
  563. $object)
  564. shift
  565. ;;
  566. *)
  567. set fnord "$@" "$arg"
  568. shift # fnord
  569. shift # $arg
  570. ;;
  571. esac
  572. done
  573. "$@" -E |
  574. sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
  575. -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
  576. sed '$ s: \\$::' > "$tmpdepfile"
  577. rm -f "$depfile"
  578. echo "$object : \\" > "$depfile"
  579. cat < "$tmpdepfile" >> "$depfile"
  580. sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
  581. rm -f "$tmpdepfile"
  582. ;;
  583. msvisualcpp)
  584. # Important note: in order to support this mode, a compiler *must*
  585. # always write the preprocessed file to stdout.
  586. "$@" || exit $?
  587. # Remove the call to Libtool.
  588. if test "$libtool" = yes; then
  589. while test "X$1" != 'X--mode=compile'; do
  590. shift
  591. done
  592. shift
  593. fi
  594. IFS=" "
  595. for arg
  596. do
  597. case "$arg" in
  598. -o)
  599. shift
  600. ;;
  601. $object)
  602. shift
  603. ;;
  604. "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
  605. set fnord "$@"
  606. shift
  607. shift
  608. ;;
  609. *)
  610. set fnord "$@" "$arg"
  611. shift
  612. shift
  613. ;;
  614. esac
  615. done
  616. "$@" -E 2>/dev/null |
  617. sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
  618. rm -f "$depfile"
  619. echo "$object : \\" > "$depfile"
  620. sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
  621. echo "$tab" >> "$depfile"
  622. sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
  623. rm -f "$tmpdepfile"
  624. ;;
  625. msvcmsys)
  626. # This case exists only to let depend.m4 do its work. It works by
  627. # looking at the text of this script. This case will never be run,
  628. # since it is checked for above.
  629. exit 1
  630. ;;
  631. none)
  632. exec "$@"
  633. ;;
  634. *)
  635. echo "Unknown depmode $depmode" 1>&2
  636. exit 1
  637. ;;
  638. esac
  639. exit 0
  640. # Local Variables:
  641. # mode: shell-script
  642. # sh-indentation: 2
  643. # eval: (add-hook 'write-file-hooks 'time-stamp)
  644. # time-stamp-start: "scriptversion="
  645. # time-stamp-format: "%:y-%02m-%02d.%02H"
  646. # time-stamp-time-zone: "UTC"
  647. # time-stamp-end: "; # UTC"
  648. # End: