Mozilla plugin that launches Kaffeine
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.
 
 
 
 
 

442 lines
13 KiB

  1. #! /bin/sh
  2. # depcomp - compile a program generating dependencies as side-effects
  3. # Copyright 1999, 2000 Free Software Foundation, Inc.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. # 02110-1301, USA.
  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. if test -z "$depmode" || test -z "$source" || test -z "$object"; then
  22. echo "depcomp: Variables source, object and depmode must be set" 1>&2
  23. exit 1
  24. fi
  25. # `libtool' can also be set to `yes' or `no'.
  26. depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
  27. tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
  28. rm -f "$tmpdepfile"
  29. # Some modes work just like other modes, but use different flags. We
  30. # parameterize here, but still list the modes in the big case below,
  31. # to make depend.m4 easier to write. Note that we *cannot* use a case
  32. # here, because this file can only contain one case statement.
  33. if test "$depmode" = hp; then
  34. # HP compiler uses -M and no extra arg.
  35. gccflag=-M
  36. depmode=gcc
  37. fi
  38. if test "$depmode" = dashXmstdout; then
  39. # This is just like dashmstdout with a different argument.
  40. dashmflag=-xM
  41. depmode=dashmstdout
  42. fi
  43. case "$depmode" in
  44. gcc3)
  45. ## gcc 3 implements dependency tracking that does exactly what
  46. ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
  47. ## it if -MD -MP comes after the -MF stuff. Hmm.
  48. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
  49. stat=$?
  50. if test $stat -eq 0; then :
  51. else
  52. rm -f "$tmpdepfile"
  53. exit $stat
  54. fi
  55. mv "$tmpdepfile" "$depfile"
  56. ;;
  57. gcc)
  58. ## There are various ways to get dependency output from gcc. Here's
  59. ## why we pick this rather obscure method:
  60. ## - Don't want to use -MD because we'd like the dependencies to end
  61. ## up in a subdir. Having to rename by hand is ugly.
  62. ## (We might end up doing this anyway to support other compilers.)
  63. ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
  64. ## -MM, not -M (despite what the docs say).
  65. ## - Using -M directly means running the compiler twice (even worse
  66. ## than renaming).
  67. if test -z "$gccflag"; then
  68. gccflag=-MD,
  69. fi
  70. "$@" -Wp,"$gccflag$tmpdepfile"
  71. stat=$?
  72. if test $stat -eq 0; then :
  73. else
  74. rm -f "$tmpdepfile"
  75. exit $stat
  76. fi
  77. rm -f "$depfile"
  78. echo "$object : \\" > "$depfile"
  79. alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  80. ## The second -e expression handles DOS-style file names with drive letters.
  81. sed -e 's/^[^:]*: / /' \
  82. -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
  83. ## This next piece of magic avoids the `deleted header file' problem.
  84. ## The problem is that when a header file which appears in a .P file
  85. ## is deleted, the dependency causes make to die (because there is
  86. ## typically no way to rebuild the header). We avoid this by adding
  87. ## dummy dependencies for each header file. Too bad gcc doesn't do
  88. ## this for us directly.
  89. tr ' ' '
  90. ' < "$tmpdepfile" |
  91. ## Some versions of gcc put a space before the `:'. On the theory
  92. ## that the space means something, we add a space to the output as
  93. ## well.
  94. ## Some versions of the HPUX 10.20 sed can't process this invocation
  95. ## correctly. Breaking it into two sed invocations is a workaround.
  96. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  97. rm -f "$tmpdepfile"
  98. ;;
  99. hp)
  100. # This case exists only to let depend.m4 do its work. It works by
  101. # looking at the text of this script. This case will never be run,
  102. # since it is checked for above.
  103. exit 1
  104. ;;
  105. sgi)
  106. if test "$libtool" = yes; then
  107. "$@" "-Wp,-MDupdate,$tmpdepfile"
  108. else
  109. "$@" -MDupdate "$tmpdepfile"
  110. fi
  111. stat=$?
  112. if test $stat -eq 0; then :
  113. else
  114. rm -f "$tmpdepfile"
  115. exit $stat
  116. fi
  117. rm -f "$depfile"
  118. if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
  119. echo "$object : \\" > "$depfile"
  120. # Clip off the initial element (the dependent). Don't try to be
  121. # clever and replace this with sed code, as IRIX sed won't handle
  122. # lines with more than a fixed number of characters (4096 in
  123. # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
  124. # the IRIX cc adds comments like `#:fec' to the end of the
  125. # dependency line.
  126. tr ' ' '
  127. ' < "$tmpdepfile" \
  128. | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
  129. tr '
  130. ' ' ' >> $depfile
  131. echo >> $depfile
  132. # The second pass generates a dummy entry for each header file.
  133. tr ' ' '
  134. ' < "$tmpdepfile" \
  135. | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
  136. >> $depfile
  137. else
  138. # The sourcefile does not contain any dependencies, so just
  139. # store a dummy comment line, to avoid errors with the Makefile
  140. # "include basename.Plo" scheme.
  141. echo "#dummy" > "$depfile"
  142. fi
  143. rm -f "$tmpdepfile"
  144. ;;
  145. aix)
  146. # The C for AIX Compiler uses -M and outputs the dependencies
  147. # in a .u file. This file always lives in the current directory.
  148. # Also, the AIX compiler puts `$object:' at the start of each line;
  149. # $object doesn't have directory information.
  150. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
  151. tmpdepfile="$stripped.u"
  152. outname="$stripped.o"
  153. if test "$libtool" = yes; then
  154. "$@" -Wc,-M
  155. else
  156. "$@" -M
  157. fi
  158. stat=$?
  159. if test $stat -eq 0; then :
  160. else
  161. rm -f "$tmpdepfile"
  162. exit $stat
  163. fi
  164. if test -f "$tmpdepfile"; then
  165. # Each line is of the form `foo.o: dependent.h'.
  166. # Do two passes, one to just change these to
  167. # `$object: dependent.h' and one to simply `dependent.h:'.
  168. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
  169. sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
  170. else
  171. # The sourcefile does not contain any dependencies, so just
  172. # store a dummy comment line, to avoid errors with the Makefile
  173. # "include basename.Plo" scheme.
  174. echo "#dummy" > "$depfile"
  175. fi
  176. rm -f "$tmpdepfile"
  177. ;;
  178. icc)
  179. # Must come before tru64.
  180. # Intel's C compiler understands `-MD -MF file'. However
  181. # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
  182. # will fill foo.d with something like
  183. # foo.o: sub/foo.c
  184. # foo.o: sub/foo.h
  185. # which is wrong. We want:
  186. # sub/foo.o: sub/foo.c
  187. # sub/foo.o: sub/foo.h
  188. # sub/foo.c:
  189. # sub/foo.h:
  190. "$@" -MD -MF "$tmpdepfile"
  191. stat=$?
  192. if test $stat -eq 0; then :
  193. else
  194. rm -f "$tmpdepfile"
  195. exit $stat
  196. fi
  197. rm -f "$depfile"
  198. # Each line is of the form `foo.o: dependent.h'.
  199. # Do two passes, one to just change these to
  200. # `$object: dependent.h' and one to simply `dependent.h:'.
  201. sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
  202. sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
  203. rm -f "$tmpdepfile"
  204. ;;
  205. tru64)
  206. # The Tru64 AIX compiler uses -MD to generate dependencies as a side
  207. # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
  208. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
  209. # dependencies in `foo.d' instead, so we check for that too.
  210. # Subdirectories are respected.
  211. tmpdepfile1="$object.d"
  212. tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
  213. if test "$libtool" = yes; then
  214. "$@" -Wc,-MD
  215. else
  216. "$@" -MD
  217. fi
  218. stat=$?
  219. if test $stat -eq 0; then :
  220. else
  221. rm -f "$tmpdepfile1" "$tmpdepfile2"
  222. exit $stat
  223. fi
  224. if test -f "$tmpdepfile1"; then
  225. tmpdepfile="$tmpdepfile1"
  226. else
  227. tmpdepfile="$tmpdepfile2"
  228. fi
  229. if test -f "$tmpdepfile"; then
  230. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
  231. # That's a space and a tab in the [].
  232. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
  233. else
  234. echo "#dummy" > "$depfile"
  235. fi
  236. rm -f "$tmpdepfile"
  237. ;;
  238. #nosideeffect)
  239. # This comment above is used by automake to tell side-effect
  240. # dependency tracking mechanisms from slower ones.
  241. dashmstdout)
  242. # Important note: in order to support this mode, a compiler *must*
  243. # always write the proprocessed file to stdout, regardless of -o,
  244. # because we must use -o when running libtool.
  245. test -z "$dashmflag" && dashmflag=-M
  246. ( IFS=" "
  247. case " $* " in
  248. *" --mode=compile "*) # this is libtool, let us make it quiet
  249. for arg
  250. do # cycle over the arguments
  251. case "$arg" in
  252. "--mode=compile")
  253. # insert --quiet before "--mode=compile"
  254. set fnord "$@" --quiet
  255. shift # fnord
  256. ;;
  257. esac
  258. set fnord "$@" "$arg"
  259. shift # fnord
  260. shift # "$arg"
  261. done
  262. ;;
  263. esac
  264. "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
  265. ) &
  266. proc=$!
  267. "$@"
  268. stat=$?
  269. wait "$proc"
  270. if test "$stat" != 0; then exit $stat; fi
  271. rm -f "$depfile"
  272. cat < "$tmpdepfile" > "$depfile"
  273. tr ' ' '
  274. ' < "$tmpdepfile" | \
  275. ## Some versions of the HPUX 10.20 sed can't process this invocation
  276. ## correctly. Breaking it into two sed invocations is a workaround.
  277. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  278. rm -f "$tmpdepfile"
  279. ;;
  280. dashXmstdout)
  281. # This case only exists to satisfy depend.m4. It is never actually
  282. # run, as this mode is specially recognized in the preamble.
  283. exit 1
  284. ;;
  285. makedepend)
  286. # X makedepend
  287. (
  288. shift
  289. cleared=no
  290. for arg in "$@"; do
  291. case $cleared in no)
  292. set ""; shift
  293. cleared=yes
  294. esac
  295. case "$arg" in
  296. -D*|-I*)
  297. set fnord "$@" "$arg"; shift;;
  298. -*)
  299. ;;
  300. *)
  301. set fnord "$@" "$arg"; shift;;
  302. esac
  303. done
  304. obj_suffix="`echo $object | sed 's/^.*\././'`"
  305. touch "$tmpdepfile"
  306. ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
  307. ) &
  308. proc=$!
  309. "$@"
  310. stat=$?
  311. wait "$proc"
  312. if test "$stat" != 0; then exit $stat; fi
  313. rm -f "$depfile"
  314. cat < "$tmpdepfile" > "$depfile"
  315. tail +3 "$tmpdepfile" | tr ' ' '
  316. ' | \
  317. ## Some versions of the HPUX 10.20 sed can't process this invocation
  318. ## correctly. Breaking it into two sed invocations is a workaround.
  319. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  320. rm -f "$tmpdepfile" "$tmpdepfile".bak
  321. ;;
  322. cpp)
  323. # Important note: in order to support this mode, a compiler *must*
  324. # always write the proprocessed file to stdout, regardless of -o,
  325. # because we must use -o when running libtool.
  326. ( IFS=" "
  327. case " $* " in
  328. *" --mode=compile "*)
  329. for arg
  330. do # cycle over the arguments
  331. case $arg in
  332. "--mode=compile")
  333. # insert --quiet before "--mode=compile"
  334. set fnord "$@" --quiet
  335. shift # fnord
  336. ;;
  337. esac
  338. set fnord "$@" "$arg"
  339. shift # fnord
  340. shift # "$arg"
  341. done
  342. ;;
  343. esac
  344. "$@" -E |
  345. sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
  346. sed '$ s: \\$::' > "$tmpdepfile"
  347. ) &
  348. proc=$!
  349. "$@"
  350. stat=$?
  351. wait "$proc"
  352. if test "$stat" != 0; then exit $stat; fi
  353. rm -f "$depfile"
  354. echo "$object : \\" > "$depfile"
  355. cat < "$tmpdepfile" >> "$depfile"
  356. sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
  357. rm -f "$tmpdepfile"
  358. ;;
  359. msvisualcpp)
  360. # Important note: in order to support this mode, a compiler *must*
  361. # always write the proprocessed file to stdout, regardless of -o,
  362. # because we must use -o when running libtool.
  363. ( IFS=" "
  364. case " $* " in
  365. *" --mode=compile "*)
  366. for arg
  367. do # cycle over the arguments
  368. case $arg in
  369. "--mode=compile")
  370. # insert --quiet before "--mode=compile"
  371. set fnord "$@" --quiet
  372. shift # fnord
  373. ;;
  374. esac
  375. set fnord "$@" "$arg"
  376. shift # fnord
  377. shift # "$arg"
  378. done
  379. ;;
  380. esac
  381. "$@" -E |
  382. sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
  383. ) &
  384. proc=$!
  385. "$@"
  386. stat=$?
  387. wait "$proc"
  388. if test "$stat" != 0; then exit $stat; fi
  389. rm -f "$depfile"
  390. echo "$object : \\" > "$depfile"
  391. . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
  392. echo " " >> "$depfile"
  393. . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
  394. rm -f "$tmpdepfile"
  395. ;;
  396. none)
  397. exec "$@"
  398. ;;
  399. *)
  400. echo "Unknown depmode $depmode" 1>&2
  401. exit 1
  402. ;;
  403. esac
  404. exit 0