A C standard library for sh3eb-elf.
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.

depcomp 22KB

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