Counter Strike : Global Offensive Source Code
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.

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