depcomp 23 KB

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