config-ml.in 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  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. GOCFLAGS="$(GOCFLAGS) $${flags}" \
  494. CXXFLAGS="$(CXXFLAGS) $${flags}" \
  495. LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
  496. LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
  497. LDFLAGS="$(LDFLAGS) $${flags}" \
  498. MULTIFLAGS="$${flags}" \
  499. DESTDIR="$(DESTDIR)" \
  500. INSTALL="$(INSTALL)" \
  501. INSTALL_DATA="$(INSTALL_DATA)" \
  502. INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
  503. INSTALL_SCRIPT="$(INSTALL_SCRIPT)" \
  504. $(DO)); then \
  505. true; \
  506. else \
  507. exit 1; \
  508. fi; \
  509. else true; \
  510. fi; \
  511. fi; \
  512. done; \
  513. fi
  514. # FIXME: There should be an @-sign in front of the `if'.
  515. # Leave out until this is tested a bit more.
  516. multi-clean:
  517. if [ -z "$(MULTIDIRS)" ]; then \
  518. true; \
  519. else \
  520. lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
  521. for dir in : $(MULTIDIRS); do \
  522. test $$dir != : || continue; \
  523. EOF
  524. cat >>Multi.tem <<EOF
  525. if [ -f ../\$\${dir}/\$\${lib}/${Makefile} ]; then \\
  526. EOF
  527. cat >>Multi.tem <<\EOF
  528. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
  529. then true; \
  530. else exit 1; \
  531. fi; \
  532. else true; \
  533. fi; \
  534. done; \
  535. fi
  536. EOF
  537. cat ${Makefile} Multi.tem > Makefile.tem
  538. rm -f ${Makefile} Multi.tem
  539. mv Makefile.tem ${Makefile}
  540. fi # ${ml_toplevel_p} = yes
  541. if [ "${ml_verbose}" = --verbose ]; then
  542. echo "Adding multilib support to ${Makefile} in ${ml_realsrcdir}"
  543. if [ "${ml_toplevel_p}" = yes ]; then
  544. echo "multidirs=${multidirs}"
  545. fi
  546. echo "with_multisubdir=${with_multisubdir}"
  547. fi
  548. if [ "${srcdir}" = "." ]; then
  549. if [ "${with_target_subdir}" != "." ]; then
  550. ml_srcdotdot="../"
  551. else
  552. ml_srcdotdot=""
  553. fi
  554. else
  555. ml_srcdotdot=""
  556. fi
  557. if [ -z "${with_multisubdir}" ]; then
  558. ml_subdir=
  559. ml_builddotdot=
  560. : # ml_srcdotdot= # already set
  561. else
  562. ml_subdir="/${with_multisubdir}"
  563. # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
  564. ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
  565. if [ "$srcdir" = "." ]; then
  566. ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
  567. else
  568. : # ml_srcdotdot= # already set
  569. fi
  570. fi
  571. if [ "${ml_toplevel_p}" = yes ]; then
  572. ml_do='$(MAKE)'
  573. ml_clean='$(MAKE)'
  574. else
  575. ml_do=true
  576. ml_clean=true
  577. fi
  578. # TOP is used by newlib and should not be used elsewhere for this purpose.
  579. # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
  580. # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
  581. # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
  582. # delete TOP. Newlib may wish to continue to use TOP for its own purposes
  583. # of course.
  584. # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
  585. # and lists the subdirectories to recurse into.
  586. # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
  587. # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
  588. # a leading '/'.
  589. # MULTIDO is used for targets like all, install, and check where
  590. # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
  591. # MULTICLEAN is used for the *clean targets.
  592. #
  593. # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
  594. # currently kept separate because we don't want the *clean targets to require
  595. # the existence of the compiler (which MULTIDO currently requires) and
  596. # therefore we'd have to record the directory options as well as names
  597. # (currently we just record the names and use --print-multi-lib to get the
  598. # options).
  599. sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
  600. -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
  601. -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
  602. -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
  603. -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
  604. -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
  605. -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
  606. ${Makefile} > Makefile.tem
  607. rm -f ${Makefile}
  608. mv Makefile.tem ${Makefile}
  609. # If this is the library's top level, configure each multilib subdir.
  610. # This is done at the end because this is the loop that runs configure
  611. # in each multilib subdir and it seemed reasonable to finish updating the
  612. # Makefile before going on to configure the subdirs.
  613. if [ "${ml_toplevel_p}" = yes ]; then
  614. # We must freshly configure each subdirectory. This bit of code is
  615. # actually partially stolen from the main configure script. FIXME.
  616. if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
  617. if [ "${ml_verbose}" = --verbose ]; then
  618. echo "Running configure in multilib subdirs ${multidirs}"
  619. echo "pwd: `${PWDCMD-pwd}`"
  620. fi
  621. ml_origdir=`${PWDCMD-pwd}`
  622. ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'`
  623. # cd to top-level-build-dir/${with_target_subdir}
  624. cd ..
  625. for ml_dir in ${multidirs}; do
  626. if [ "${ml_verbose}" = --verbose ]; then
  627. echo "Running configure in multilib subdir ${ml_dir}"
  628. echo "pwd: `${PWDCMD-pwd}`"
  629. fi
  630. if [ -d ${ml_dir} ]; then true; else
  631. # ``mkdir -p ${ml_dir}'' See also mkinstalldirs.
  632. pathcomp=""
  633. for d in `echo ":${ml_dir}" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; do
  634. pathcomp="$pathcomp$d"
  635. case "$pathcomp" in
  636. -* ) pathcomp=./$pathcomp ;;
  637. esac
  638. if test ! -d "$pathcomp"; then
  639. echo "mkdir $pathcomp" 1>&2
  640. mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
  641. fi
  642. if test ! -d "$pathcomp"; then
  643. exit $lasterr
  644. fi
  645. pathcomp="$pathcomp/"
  646. done
  647. fi
  648. if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
  649. # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
  650. dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
  651. case ${srcdir} in
  652. ".")
  653. echo "Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}"
  654. if [ "${with_target_subdir}" != "." ]; then
  655. ml_unsubdir="../"
  656. else
  657. ml_unsubdir=""
  658. fi
  659. (cd ${ml_dir}/${ml_libdir};
  660. ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
  661. if [ -f ${ml_dir}/${ml_libdir}/${Makefile} ]; then
  662. if [ x"${MAKE}" = x ]; then
  663. (cd ${ml_dir}/${ml_libdir}; make distclean)
  664. else
  665. (cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
  666. fi
  667. fi
  668. ml_newsrcdir="."
  669. ml_srcdiroption=
  670. multisrctop=${dotdot}
  671. ;;
  672. *)
  673. case "${srcdir}" in
  674. /* | [A-Za-z]:[\\/]* ) # absolute path
  675. ml_newsrcdir=${srcdir}
  676. ;;
  677. *) # otherwise relative
  678. ml_newsrcdir=${dotdot}${srcdir}
  679. ;;
  680. esac
  681. ml_srcdiroption="-srcdir=${ml_newsrcdir}"
  682. multisrctop=
  683. ;;
  684. esac
  685. case "${progname}" in
  686. /* | [A-Za-z]:[\\/]* ) ml_recprog=${progname} ;;
  687. *) ml_recprog=${dotdot}${progname} ;;
  688. esac
  689. # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
  690. ML_POPDIR=`${PWDCMD-pwd}`
  691. cd ${ml_dir}/${ml_libdir}
  692. if [ -f ${ml_newsrcdir}/configure ]; then
  693. ml_recprog="${ml_newsrcdir}/configure"
  694. fi
  695. # find compiler flag corresponding to ${ml_dir}
  696. for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
  697. dir=`echo $i | sed -e 's/;.*$//'`
  698. if [ "${dir}" = "${ml_dir}" ]; then
  699. flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
  700. break
  701. fi
  702. done
  703. ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" F77="${F77_}$flags" GFORTRAN="${GFORTRAN_}$flags" GOC="${GOC_}$flags"'
  704. if [ "${with_target_subdir}" = "." ]; then
  705. CC_=$CC' '
  706. CXX_=$CXX' '
  707. F77_=$F77' '
  708. GFORTRAN_=$GFORTRAN' '
  709. GOC_=$GOC' '
  710. else
  711. # Create a regular expression that matches any string as long
  712. # as ML_POPDIR.
  713. popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'`
  714. CC_=
  715. for arg in ${CC}; do
  716. case $arg in
  717. -[BIL]"${ML_POPDIR}"/*)
  718. 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"`' ' ;;
  719. "${ML_POPDIR}"/*)
  720. 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"`' ' ;;
  721. *)
  722. CC_="${CC_}${arg} " ;;
  723. esac
  724. done
  725. CXX_=
  726. for arg in ${CXX}; do
  727. case $arg in
  728. -[BIL]"${ML_POPDIR}"/*)
  729. 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"`' ' ;;
  730. "${ML_POPDIR}"/*)
  731. 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"`' ' ;;
  732. *)
  733. CXX_="${CXX_}${arg} " ;;
  734. esac
  735. done
  736. F77_=
  737. for arg in ${F77}; do
  738. case $arg in
  739. -[BIL]"${ML_POPDIR}"/*)
  740. 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"`' ' ;;
  741. "${ML_POPDIR}"/*)
  742. 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"`' ' ;;
  743. *)
  744. F77_="${F77_}${arg} " ;;
  745. esac
  746. done
  747. GFORTRAN_=
  748. for arg in ${GFORTRAN}; do
  749. case $arg in
  750. -[BIL]"${ML_POPDIR}"/*)
  751. 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"`' ' ;;
  752. "${ML_POPDIR}"/*)
  753. 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"`' ' ;;
  754. *)
  755. GFORTRAN_="${GFORTRAN_}${arg} " ;;
  756. esac
  757. done
  758. GOC_=
  759. for arg in ${GOC}; do
  760. case $arg in
  761. -[BIL]"${ML_POPDIR}"/*)
  762. 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"`' ' ;;
  763. "${ML_POPDIR}"/*)
  764. 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"`' ' ;;
  765. *)
  766. GOC_="${GOC_}${arg} " ;;
  767. esac
  768. done
  769. if test "x${LD_LIBRARY_PATH+set}" = xset; then
  770. LD_LIBRARY_PATH_=
  771. for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do
  772. case "$arg" in
  773. "${ML_POPDIR}"/*)
  774. 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"`
  775. ;;
  776. esac
  777. if test "x$LD_LIBRARY_PATH_" != x; then
  778. LD_LIBRARY_PATH_=$LD_LIBRARY_PATH_:$arg
  779. else
  780. LD_LIBRARY_PATH_=$arg
  781. fi
  782. done
  783. ml_config_env="$ml_config_env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_"
  784. fi
  785. if test "x${SHLIB_PATH+set}" = xset; then
  786. SHLIB_PATH_=
  787. for arg in `echo "$SHLIB_PATH" | tr ':' ' '`; do
  788. case "$arg" in
  789. "${ML_POPDIR}"/*)
  790. 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"`
  791. ;;
  792. esac
  793. if test "x$SHLIB_PATH_" != x; then
  794. SHLIB_PATH_=$SHLIB_PATH_:$arg
  795. else
  796. SHLIB_PATH_=$arg
  797. fi
  798. done
  799. ml_config_env="$ml_config_env SHLIB_PATH=$SHLIB_PATH_"
  800. fi
  801. fi
  802. if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
  803. --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
  804. "${ac_configure_args}" ${ml_config_env} ${ml_srcdiroption} ; then
  805. true
  806. else
  807. exit 1
  808. fi
  809. cd "${ML_POPDIR}"
  810. done
  811. cd "${ml_origdir}"
  812. fi
  813. fi # ${ml_toplevel_p} = yes
  814. fi # ${enable_multilib} = yes