config-ml.in 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. # Configure fragment invoked in the post-target section for subdirs
  2. # wanting multilib support.
  3. #
  4. # Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  5. # 2005, 2006, 2007, 2008, 2010, 2011, 2014 Free Software Foundation, Inc.
  6. #
  7. # This file is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. # Boston, MA 02110-1301, USA.
  21. #
  22. # As a special exception to the GNU General Public License, if you
  23. # distribute this file as part of a program that contains a
  24. # configuration script generated by Autoconf, you may include it under
  25. # the same distribution terms that you use for the rest of that program.
  26. #
  27. # Please report bugs to <gcc-bugs@gnu.org>
  28. # and send patches to <gcc-patches@gnu.org>.
  29. # It is advisable to support a few --enable/--disable options to let the
  30. # user select which libraries s/he really wants.
  31. #
  32. # Subdirectories wishing to use multilib should put the following lines
  33. # in the "post-target" section of configure.ac.
  34. #
  35. # if [ "${srcdir}" = "." ] ; then
  36. # if [ "${with_target_subdir}" != "." ] ; then
  37. # . ${with_multisrctop}../../config-ml.in
  38. # else
  39. # . ${with_multisrctop}../config-ml.in
  40. # fi
  41. # else
  42. # . ${srcdir}/../config-ml.in
  43. # fi
  44. #
  45. #
  46. # Things are complicated because 6 separate cases must be handled:
  47. # 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
  48. #
  49. # srcdir=. is special. It must handle make programs that don't handle VPATH.
  50. # To implement this, a symlink tree is built for each library and for each
  51. # multilib subdir.
  52. #
  53. # The build tree is layed out as
  54. #
  55. # ./
  56. # newlib
  57. # m68020/
  58. # newlib
  59. # m68881/
  60. # newlib
  61. #
  62. # The nice feature about this arrangement is that inter-library references
  63. # in the build tree work without having to care where you are. Note that
  64. # inter-library references also work in the source tree because symlink trees
  65. # are built when srcdir=.
  66. #
  67. # Unfortunately, trying to access the libraries in the build tree requires
  68. # the user to manually choose which library to use as GCC won't be able to
  69. # find the right one. This is viewed as the lesser of two evils.
  70. #
  71. # Configure variables:
  72. # ${with_target_subdir} = "." for native, or ${target_alias} for cross.
  73. # Set by top level Makefile.
  74. # ${with_multisrctop} = how many levels of multilibs there are in the source
  75. # tree. It exists to handle the case of configuring in the source tree:
  76. # ${srcdir} is not constant.
  77. # ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
  78. #
  79. # Makefile variables:
  80. # MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
  81. # (FIXME: note that this is different than ${with_multisrctop}. Check out.).
  82. # MULTIBUILDTOP = number of multilib levels in build tree
  83. # MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...)
  84. # (only defined in each library's main Makefile).
  85. # MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000)
  86. # (only defined in each multilib subdir).
  87. # FIXME: Multilib is currently disabled by default for everything other than
  88. # newlib. It is up to each target to turn on multilib support for the other
  89. # libraries as desired.
  90. # Autoconf incoming variables:
  91. # srcdir, host, ac_configure_args
  92. #
  93. # We *could* figure srcdir and host out, but we'd have to do work that
  94. # our caller has already done to figure them out and requiring these two
  95. # seems reasonable.
  96. # Note that `host' in this case is GCC's `target'. Target libraries are
  97. # configured for a particular host.
  98. Makefile=${ac_file-Makefile}
  99. ml_config_shell=${CONFIG_SHELL-/bin/sh}
  100. ml_realsrcdir=${srcdir}
  101. # Scan all the arguments and set all the ones we need.
  102. scan_arguments ()
  103. {
  104. ml_verbose=--verbose
  105. for option
  106. do
  107. # Strip single quotes surrounding individual options, that is, remove one
  108. # level of shell quoting for these.
  109. case $option in
  110. \'*\') eval option=$option ;;
  111. esac
  112. case $option in
  113. --*) ;;
  114. -*) option=-$option ;;
  115. esac
  116. case $option in
  117. --*=*)
  118. optarg=`echo $option | sed -e 's/^[^=]*=//'`
  119. ;;
  120. esac
  121. case $option in
  122. --disable-*)
  123. enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
  124. eval $enableopt=no
  125. ;;
  126. --enable-*)
  127. case "$option" in
  128. *=*) ;;
  129. *) optarg=yes ;;
  130. esac
  131. enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  132. # enable_shared and enable_static are handled by configure.
  133. # Don't undo its work.
  134. case $enableopt in
  135. enable_shared | enable_static) ;;
  136. *) eval $enableopt='$optarg' ;;
  137. esac
  138. ;;
  139. --norecursion | --no-recursion)
  140. ml_norecursion=yes
  141. ;;
  142. --silent | --sil* | --quiet | --q*)
  143. ml_verbose=--silent
  144. ;;
  145. --verbose | --v | --verb*)
  146. ml_verbose=--verbose
  147. ;;
  148. --with-*)
  149. case "$option" in
  150. *=*) ;;
  151. *) optarg=yes ;;
  152. esac
  153. withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  154. eval $withopt='$optarg'
  155. ;;
  156. --without-*)
  157. withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
  158. eval $withopt=no
  159. ;;
  160. esac
  161. done
  162. }
  163. # Use eval to properly handle configure arguments such as
  164. # --enable-foo='--enable-a=1 --enable-b=2 --enable-c=3'.
  165. eval scan_arguments "${ac_configure_args}"
  166. unset scan_arguments
  167. # Only do this if --enable-multilib.
  168. if [ "${enable_multilib}" = yes ]; then
  169. # Compute whether this is the library's top level directory
  170. # (ie: not a multilib subdirectory, and not a subdirectory like newlib/src).
  171. # ${with_multisubdir} tells us we're in the right branch, but we could be
  172. # in a subdir of that.
  173. # ??? The previous version could void this test by separating the process into
  174. # two files: one that only the library's toplevel configure.ac ran (to
  175. # configure the multilib subdirs), and another that all configure.ac's ran to
  176. # update the Makefile. It seemed reasonable to collapse all multilib support
  177. # into one file, but it does leave us with having to perform this test.
  178. ml_toplevel_p=no
  179. if [ -z "${with_multisubdir}" ]; then
  180. if [ "${srcdir}" = "." ]; then
  181. # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
  182. # ${with_target_subdir} = "." for native, otherwise target alias.
  183. if [ "${with_target_subdir}" = "." ]; then
  184. if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
  185. ml_toplevel_p=yes
  186. fi
  187. else
  188. if [ -f ${ml_realsrcdir}/../../config-ml.in ]; then
  189. ml_toplevel_p=yes
  190. fi
  191. fi
  192. else
  193. # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
  194. if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
  195. ml_toplevel_p=yes
  196. fi
  197. fi
  198. fi
  199. # If this is the library's top level directory, set multidirs to the
  200. # multilib subdirs to support. This lives at the top because we need
  201. # `multidirs' set right away.
  202. if [ "${ml_toplevel_p}" = yes ]; then
  203. multidirs=
  204. for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
  205. dir=`echo $i | sed -e 's/;.*$//'`
  206. if [ "${dir}" = "." ]; then
  207. true
  208. else
  209. if [ -z "${multidirs}" ]; then
  210. multidirs="${dir}"
  211. else
  212. multidirs="${multidirs} ${dir}"
  213. fi
  214. fi
  215. done
  216. # Target libraries are configured for the host they run on, so we check
  217. # $host here, not $target.
  218. case "${host}" in
  219. arm-*-*)
  220. if [ x"$enable_fpu" = xno ]
  221. then
  222. old_multidirs=${multidirs}
  223. multidirs=""
  224. for x in ${old_multidirs}; do
  225. case "${x}" in
  226. *fpu*) : ;;
  227. *) multidirs="${multidirs} ${x}" ;;
  228. esac
  229. done
  230. fi
  231. if [ x"$enable_26bit" = xno ]
  232. then
  233. old_multidirs=${multidirs}
  234. multidirs=""
  235. for x in ${old_multidirs}; do
  236. case "${x}" in
  237. *26bit*) : ;;
  238. *) multidirs="${multidirs} ${x}" ;;
  239. esac
  240. done
  241. fi
  242. if [ x"$enable_underscore" = xno ]
  243. then
  244. old_multidirs=${multidirs}
  245. multidirs=""
  246. for x in ${old_multidirs}; do
  247. case "${x}" in
  248. *under*) : ;;
  249. *) multidirs="${multidirs} ${x}" ;;
  250. esac
  251. done
  252. fi
  253. if [ x"$enable_interwork" = xno ]
  254. then
  255. old_multidirs=${multidirs}
  256. multidirs=""
  257. for x in ${old_multidirs}; do
  258. case "${x}" in
  259. *interwork*) : ;;
  260. *) multidirs="${multidirs} ${x}" ;;
  261. esac
  262. done
  263. fi
  264. if [ x$enable_biendian = xno ]
  265. then
  266. old_multidirs="${multidirs}"
  267. multidirs=""
  268. for x in ${old_multidirs}; do
  269. case "$x" in
  270. *le* ) : ;;
  271. *be* ) : ;;
  272. *) multidirs="${multidirs} ${x}" ;;
  273. esac
  274. done
  275. fi
  276. if [ x"$enable_nofmult" = xno ]
  277. then
  278. old_multidirs="${multidirs}"
  279. multidirs=""
  280. for x in ${old_multidirs}; do
  281. case "$x" in
  282. *nofmult* ) : ;;
  283. *) multidirs="${multidirs} ${x}" ;;
  284. esac
  285. done
  286. fi
  287. ;;
  288. m68*-*-*)
  289. if [ x$enable_softfloat = xno ]
  290. then
  291. old_multidirs="${multidirs}"
  292. multidirs=""
  293. for x in ${old_multidirs}; do
  294. case "$x" in
  295. *soft-float* ) : ;;
  296. *) multidirs="${multidirs} ${x}" ;;
  297. esac
  298. done
  299. fi
  300. if [ x$enable_m68881 = xno ]
  301. then
  302. old_multidirs="${multidirs}"
  303. multidirs=""
  304. for x in ${old_multidirs}; do
  305. case "$x" in
  306. *m68881* ) : ;;
  307. *) multidirs="${multidirs} ${x}" ;;
  308. esac
  309. done
  310. fi
  311. if [ x$enable_m68000 = xno ]
  312. then
  313. old_multidirs="${multidirs}"
  314. multidirs=""
  315. for x in ${old_multidirs}; do
  316. case "$x" in
  317. *m68000* ) : ;;
  318. *) multidirs="${multidirs} ${x}" ;;
  319. esac
  320. done
  321. fi
  322. if [ x$enable_m68020 = xno ]
  323. then
  324. old_multidirs="${multidirs}"
  325. multidirs=""
  326. for x in ${old_multidirs}; do
  327. case "$x" in
  328. *m68020* ) : ;;
  329. *) multidirs="${multidirs} ${x}" ;;
  330. esac
  331. done
  332. fi
  333. ;;
  334. mips*-*-*)
  335. if [ x$enable_single_float = xno ]
  336. then
  337. old_multidirs="${multidirs}"
  338. multidirs=""
  339. for x in ${old_multidirs}; do
  340. case "$x" in
  341. *single* ) : ;;
  342. *) multidirs="${multidirs} ${x}" ;;
  343. esac
  344. done
  345. fi
  346. if [ x$enable_biendian = xno ]
  347. then
  348. old_multidirs="${multidirs}"
  349. multidirs=""
  350. for x in ${old_multidirs}; do
  351. case "$x" in
  352. *el* ) : ;;
  353. *eb* ) : ;;
  354. *) multidirs="${multidirs} ${x}" ;;
  355. esac
  356. done
  357. fi
  358. if [ x$enable_softfloat = xno ]
  359. then
  360. old_multidirs="${multidirs}"
  361. multidirs=""
  362. for x in ${old_multidirs}; do
  363. case "$x" in
  364. *soft-float* ) : ;;
  365. *) multidirs="${multidirs} ${x}" ;;
  366. esac
  367. done
  368. fi
  369. ;;
  370. powerpc*-*-* | rs6000*-*-*)
  371. if [ x$enable_aix64 = xno ]
  372. then
  373. old_multidirs="${multidirs}"
  374. multidirs=""
  375. for x in ${old_multidirs}; do
  376. case "$x" in
  377. *ppc64* ) : ;;
  378. *) multidirs="${multidirs} ${x}" ;;
  379. esac
  380. done
  381. fi
  382. if [ x$enable_pthread = xno ]
  383. then
  384. old_multidirs="${multidirs}"
  385. multidirs=""
  386. for x in ${old_multidirs}; do
  387. case "$x" in
  388. *pthread* ) : ;;
  389. *) multidirs="${multidirs} ${x}" ;;
  390. esac
  391. done
  392. fi
  393. if [ x$enable_softfloat = xno ]
  394. then
  395. old_multidirs="${multidirs}"
  396. multidirs=""
  397. for x in ${old_multidirs}; do
  398. case "$x" in
  399. *soft-float* ) : ;;
  400. *) multidirs="${multidirs} ${x}" ;;
  401. esac
  402. done
  403. fi
  404. if [ x$enable_powercpu = xno ]
  405. then
  406. old_multidirs="${multidirs}"
  407. multidirs=""
  408. for x in ${old_multidirs}; do
  409. case "$x" in
  410. power | */power | */power/* ) : ;;
  411. *) multidirs="${multidirs} ${x}" ;;
  412. esac
  413. done
  414. fi
  415. if [ x$enable_powerpccpu = xno ]
  416. then
  417. old_multidirs="${multidirs}"
  418. multidirs=""
  419. for x in ${old_multidirs}; do
  420. case "$x" in
  421. *powerpc* ) : ;;
  422. *) multidirs="${multidirs} ${x}" ;;
  423. esac
  424. done
  425. fi
  426. if [ x$enable_powerpcos = xno ]
  427. then
  428. old_multidirs="${multidirs}"
  429. multidirs=""
  430. for x in ${old_multidirs}; do
  431. case "$x" in
  432. *mcall-linux* | *mcall-solaris* ) : ;;
  433. *) multidirs="${multidirs} ${x}" ;;
  434. esac
  435. done
  436. fi
  437. if [ x$enable_biendian = xno ]
  438. then
  439. old_multidirs="${multidirs}"
  440. multidirs=""
  441. for x in ${old_multidirs}; do
  442. case "$x" in
  443. *mlittle* | *mbig* ) : ;;
  444. *) multidirs="${multidirs} ${x}" ;;
  445. esac
  446. done
  447. fi
  448. if [ x$enable_sysv = xno ]
  449. then
  450. old_multidirs="${multidirs}"
  451. multidirs=""
  452. for x in ${old_multidirs}; do
  453. case "$x" in
  454. *mcall-sysv* ) : ;;
  455. *) multidirs="${multidirs} ${x}" ;;
  456. esac
  457. done
  458. fi
  459. ;;
  460. esac
  461. # Remove extraneous blanks from multidirs.
  462. # Tests like `if [ -n "$multidirs" ]' require it.
  463. multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
  464. # Add code to library's top level makefile to handle building the multilib
  465. # subdirs.
  466. cat > Multi.tem <<\EOF
  467. PWD_COMMAND=$${PWDCMD-pwd}
  468. # FIXME: There should be an @-sign in front of the `if'.
  469. # Leave out until this is tested a bit more.
  470. multi-do:
  471. if [ -z "$(MULTIDIRS)" ]; then \
  472. true; \
  473. else \
  474. rootpre=`${PWD_COMMAND}`/; export rootpre; \
  475. srcrootpre=`cd $(srcdir); ${PWD_COMMAND}`/; export srcrootpre; \
  476. lib=`echo "$${rootpre}" | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
  477. compiler="$(CC)"; \
  478. for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
  479. dir=`echo $$i | sed -e 's/;.*$$//'`; \
  480. if [ "$${dir}" = "." ]; then \
  481. true; \
  482. else \
  483. if [ -d ../$${dir}/$${lib} ]; then \
  484. flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
  485. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
  486. CFLAGS="$(CFLAGS) $${flags}" \
  487. CCASFLAGS="$(CCASFLAGS) $${flags}" \
  488. FCFLAGS="$(FCFLAGS) $${flags}" \
  489. FFLAGS="$(FFLAGS) $${flags}" \
  490. ADAFLAGS="$(ADAFLAGS) $${flags}" \
  491. prefix="$(prefix)" \
  492. exec_prefix="$(exec_prefix)" \
  493. GCJFLAGS="$(GCJFLAGS) $${flags}" \
  494. GOCFLAGS="$(GOCFLAGS) $${flags}" \
  495. CXXFLAGS="$(CXXFLAGS) $${flags}" \
  496. LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
  497. LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
  498. LDFLAGS="$(LDFLAGS) $${flags}" \
  499. MULTIFLAGS="$${flags}" \
  500. DESTDIR="$(DESTDIR)" \
  501. INSTALL="$(INSTALL)" \
  502. INSTALL_DATA="$(INSTALL_DATA)" \
  503. INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
  504. INSTALL_SCRIPT="$(INSTALL_SCRIPT)" \
  505. $(DO)); then \
  506. true; \
  507. else \
  508. exit 1; \
  509. fi; \
  510. else true; \
  511. fi; \
  512. fi; \
  513. done; \
  514. fi
  515. # FIXME: There should be an @-sign in front of the `if'.
  516. # Leave out until this is tested a bit more.
  517. multi-clean:
  518. if [ -z "$(MULTIDIRS)" ]; then \
  519. true; \
  520. else \
  521. lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
  522. for dir in : $(MULTIDIRS); do \
  523. test $$dir != : || continue; \
  524. EOF
  525. cat >>Multi.tem <<EOF
  526. if [ -f ../\$\${dir}/\$\${lib}/${Makefile} ]; then \\
  527. EOF
  528. cat >>Multi.tem <<\EOF
  529. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
  530. then true; \
  531. else exit 1; \
  532. fi; \
  533. else true; \
  534. fi; \
  535. done; \
  536. fi
  537. EOF
  538. cat ${Makefile} Multi.tem > Makefile.tem
  539. rm -f ${Makefile} Multi.tem
  540. mv Makefile.tem ${Makefile}
  541. fi # ${ml_toplevel_p} = yes
  542. if [ "${ml_verbose}" = --verbose ]; then
  543. echo "Adding multilib support to ${Makefile} in ${ml_realsrcdir}"
  544. if [ "${ml_toplevel_p}" = yes ]; then
  545. echo "multidirs=${multidirs}"
  546. fi
  547. echo "with_multisubdir=${with_multisubdir}"
  548. fi
  549. if [ "${srcdir}" = "." ]; then
  550. if [ "${with_target_subdir}" != "." ]; then
  551. ml_srcdotdot="../"
  552. else
  553. ml_srcdotdot=""
  554. fi
  555. else
  556. ml_srcdotdot=""
  557. fi
  558. if [ -z "${with_multisubdir}" ]; then
  559. ml_subdir=
  560. ml_builddotdot=
  561. : # ml_srcdotdot= # already set
  562. else
  563. ml_subdir="/${with_multisubdir}"
  564. # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
  565. ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
  566. if [ "$srcdir" = "." ]; then
  567. ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
  568. else
  569. : # ml_srcdotdot= # already set
  570. fi
  571. fi
  572. if [ "${ml_toplevel_p}" = yes ]; then
  573. ml_do='$(MAKE)'
  574. ml_clean='$(MAKE)'
  575. else
  576. ml_do=true
  577. ml_clean=true
  578. fi
  579. # TOP is used by newlib and should not be used elsewhere for this purpose.
  580. # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
  581. # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
  582. # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
  583. # delete TOP. Newlib may wish to continue to use TOP for its own purposes
  584. # of course.
  585. # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
  586. # and lists the subdirectories to recurse into.
  587. # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
  588. # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
  589. # a leading '/'.
  590. # MULTIDO is used for targets like all, install, and check where
  591. # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
  592. # MULTICLEAN is used for the *clean targets.
  593. #
  594. # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
  595. # currently kept separate because we don't want the *clean targets to require
  596. # the existence of the compiler (which MULTIDO currently requires) and
  597. # therefore we'd have to record the directory options as well as names
  598. # (currently we just record the names and use --print-multi-lib to get the
  599. # options).
  600. sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
  601. -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
  602. -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
  603. -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
  604. -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
  605. -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
  606. -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
  607. ${Makefile} > Makefile.tem
  608. rm -f ${Makefile}
  609. mv Makefile.tem ${Makefile}
  610. # If this is the library's top level, configure each multilib subdir.
  611. # This is done at the end because this is the loop that runs configure
  612. # in each multilib subdir and it seemed reasonable to finish updating the
  613. # Makefile before going on to configure the subdirs.
  614. if [ "${ml_toplevel_p}" = yes ]; then
  615. # We must freshly configure each subdirectory. This bit of code is
  616. # actually partially stolen from the main configure script. FIXME.
  617. if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
  618. if [ "${ml_verbose}" = --verbose ]; then
  619. echo "Running configure in multilib subdirs ${multidirs}"
  620. echo "pwd: `${PWDCMD-pwd}`"
  621. fi
  622. ml_origdir=`${PWDCMD-pwd}`
  623. ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'`
  624. # cd to top-level-build-dir/${with_target_subdir}
  625. cd ..
  626. for ml_dir in ${multidirs}; do
  627. if [ "${ml_verbose}" = --verbose ]; then
  628. echo "Running configure in multilib subdir ${ml_dir}"
  629. echo "pwd: `${PWDCMD-pwd}`"
  630. fi
  631. if [ -d ${ml_dir} ]; then true; else
  632. # ``mkdir -p ${ml_dir}'' See also mkinstalldirs.
  633. pathcomp=""
  634. for d in `echo ":${ml_dir}" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; do
  635. pathcomp="$pathcomp$d"
  636. case "$pathcomp" in
  637. -* ) pathcomp=./$pathcomp ;;
  638. esac
  639. if test ! -d "$pathcomp"; then
  640. echo "mkdir $pathcomp" 1>&2
  641. mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
  642. fi
  643. if test ! -d "$pathcomp"; then
  644. exit $lasterr
  645. fi
  646. pathcomp="$pathcomp/"
  647. done
  648. fi
  649. if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
  650. # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
  651. dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
  652. case ${srcdir} in
  653. ".")
  654. echo "Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}"
  655. if [ "${with_target_subdir}" != "." ]; then
  656. ml_unsubdir="../"
  657. else
  658. ml_unsubdir=""
  659. fi
  660. (cd ${ml_dir}/${ml_libdir};
  661. ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
  662. if [ -f ${ml_dir}/${ml_libdir}/${Makefile} ]; then
  663. if [ x"${MAKE}" = x ]; then
  664. (cd ${ml_dir}/${ml_libdir}; make distclean)
  665. else
  666. (cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
  667. fi
  668. fi
  669. ml_newsrcdir="."
  670. ml_srcdiroption=
  671. multisrctop=${dotdot}
  672. ;;
  673. *)
  674. case "${srcdir}" in
  675. /* | [A-Za-z]:[\\/]* ) # absolute path
  676. ml_newsrcdir=${srcdir}
  677. ;;
  678. *) # otherwise relative
  679. ml_newsrcdir=${dotdot}${srcdir}
  680. ;;
  681. esac
  682. ml_srcdiroption="-srcdir=${ml_newsrcdir}"
  683. multisrctop=
  684. ;;
  685. esac
  686. case "${progname}" in
  687. /* | [A-Za-z]:[\\/]* ) ml_recprog=${progname} ;;
  688. *) ml_recprog=${dotdot}${progname} ;;
  689. esac
  690. # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
  691. ML_POPDIR=`${PWDCMD-pwd}`
  692. cd ${ml_dir}/${ml_libdir}
  693. if [ -f ${ml_newsrcdir}/configure ]; then
  694. ml_recprog="${ml_newsrcdir}/configure"
  695. fi
  696. # find compiler flag corresponding to ${ml_dir}
  697. for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
  698. dir=`echo $i | sed -e 's/;.*$//'`
  699. if [ "${dir}" = "${ml_dir}" ]; then
  700. flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
  701. break
  702. fi
  703. done
  704. ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" F77="${F77_}$flags" GCJ="${GCJ_}$flags" GFORTRAN="${GFORTRAN_}$flags" GOC="${GOC_}$flags"'
  705. if [ "${with_target_subdir}" = "." ]; then
  706. CC_=$CC' '
  707. CXX_=$CXX' '
  708. F77_=$F77' '
  709. GCJ_=$GCJ' '
  710. GFORTRAN_=$GFORTRAN' '
  711. GOC_=$GOC' '
  712. else
  713. # Create a regular expression that matches any string as long
  714. # as ML_POPDIR.
  715. popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'`
  716. CC_=
  717. for arg in ${CC}; do
  718. case $arg in
  719. -[BIL]"${ML_POPDIR}"/*)
  720. CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;;
  721. "${ML_POPDIR}"/*)
  722. CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  723. *)
  724. CC_="${CC_}${arg} " ;;
  725. esac
  726. done
  727. CXX_=
  728. for arg in ${CXX}; do
  729. case $arg in
  730. -[BIL]"${ML_POPDIR}"/*)
  731. CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  732. "${ML_POPDIR}"/*)
  733. CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  734. *)
  735. CXX_="${CXX_}${arg} " ;;
  736. esac
  737. done
  738. F77_=
  739. for arg in ${F77}; do
  740. case $arg in
  741. -[BIL]"${ML_POPDIR}"/*)
  742. F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  743. "${ML_POPDIR}"/*)
  744. F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  745. *)
  746. F77_="${F77_}${arg} " ;;
  747. esac
  748. done
  749. GCJ_=
  750. for arg in ${GCJ}; do
  751. case $arg in
  752. -[BIL]"${ML_POPDIR}"/*)
  753. GCJ_="${GCJ_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  754. "${ML_POPDIR}"/*)
  755. GCJ_="${GCJ_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  756. *)
  757. GCJ_="${GCJ_}${arg} " ;;
  758. esac
  759. done
  760. GFORTRAN_=
  761. for arg in ${GFORTRAN}; do
  762. case $arg in
  763. -[BIL]"${ML_POPDIR}"/*)
  764. GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  765. "${ML_POPDIR}"/*)
  766. GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  767. *)
  768. GFORTRAN_="${GFORTRAN_}${arg} " ;;
  769. esac
  770. done
  771. GOC_=
  772. for arg in ${GOC}; do
  773. case $arg in
  774. -[BIL]"${ML_POPDIR}"/*)
  775. GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  776. "${ML_POPDIR}"/*)
  777. GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  778. *)
  779. GOC_="${GOC_}${arg} " ;;
  780. esac
  781. done
  782. if test "x${LD_LIBRARY_PATH+set}" = xset; then
  783. LD_LIBRARY_PATH_=
  784. for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do
  785. case "$arg" in
  786. "${ML_POPDIR}"/*)
  787. arg=`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`
  788. ;;
  789. esac
  790. if test "x$LD_LIBRARY_PATH_" != x; then
  791. LD_LIBRARY_PATH_=$LD_LIBRARY_PATH_:$arg
  792. else
  793. LD_LIBRARY_PATH_=$arg
  794. fi
  795. done
  796. ml_config_env="$ml_config_env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_"
  797. fi
  798. if test "x${SHLIB_PATH+set}" = xset; then
  799. SHLIB_PATH_=
  800. for arg in `echo "$SHLIB_PATH" | tr ':' ' '`; do
  801. case "$arg" in
  802. "${ML_POPDIR}"/*)
  803. arg=`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`
  804. ;;
  805. esac
  806. if test "x$SHLIB_PATH_" != x; then
  807. SHLIB_PATH_=$SHLIB_PATH_:$arg
  808. else
  809. SHLIB_PATH_=$arg
  810. fi
  811. done
  812. ml_config_env="$ml_config_env SHLIB_PATH=$SHLIB_PATH_"
  813. fi
  814. fi
  815. if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
  816. --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
  817. "${ac_configure_args}" ${ml_config_env} ${ml_srcdiroption} ; then
  818. true
  819. else
  820. exit 1
  821. fi
  822. cd "${ML_POPDIR}"
  823. done
  824. cd "${ml_origdir}"
  825. fi
  826. fi # ${ml_toplevel_p} = yes
  827. fi # ${enable_multilib} = yes