depcomp 20 KB

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