config-ml.in 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  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. msp430-*-*)
  371. if [ x$enable_no_exceptions = xno ]
  372. then
  373. old_multidirs="${multidirs}"
  374. multidirs=""
  375. for x in ${old_multidirs}; do
  376. case "$x" in
  377. *no-exceptions* ) : ;;
  378. *) multidirs="${multidirs} ${x}" ;;
  379. esac
  380. done
  381. fi
  382. ;;
  383. powerpc*-*-* | rs6000*-*-*)
  384. if [ x$enable_aix64 = xno ]
  385. then
  386. old_multidirs="${multidirs}"
  387. multidirs=""
  388. for x in ${old_multidirs}; do
  389. case "$x" in
  390. *ppc64* ) : ;;
  391. *) multidirs="${multidirs} ${x}" ;;
  392. esac
  393. done
  394. fi
  395. if [ x$enable_pthread = xno ]
  396. then
  397. old_multidirs="${multidirs}"
  398. multidirs=""
  399. for x in ${old_multidirs}; do
  400. case "$x" in
  401. *pthread* ) : ;;
  402. *) multidirs="${multidirs} ${x}" ;;
  403. esac
  404. done
  405. fi
  406. if [ x$enable_softfloat = xno ]
  407. then
  408. old_multidirs="${multidirs}"
  409. multidirs=""
  410. for x in ${old_multidirs}; do
  411. case "$x" in
  412. *soft-float* ) : ;;
  413. *) multidirs="${multidirs} ${x}" ;;
  414. esac
  415. done
  416. fi
  417. if [ x$enable_powercpu = xno ]
  418. then
  419. old_multidirs="${multidirs}"
  420. multidirs=""
  421. for x in ${old_multidirs}; do
  422. case "$x" in
  423. power | */power | */power/* ) : ;;
  424. *) multidirs="${multidirs} ${x}" ;;
  425. esac
  426. done
  427. fi
  428. if [ x$enable_powerpccpu = xno ]
  429. then
  430. old_multidirs="${multidirs}"
  431. multidirs=""
  432. for x in ${old_multidirs}; do
  433. case "$x" in
  434. *powerpc* ) : ;;
  435. *) multidirs="${multidirs} ${x}" ;;
  436. esac
  437. done
  438. fi
  439. if [ x$enable_powerpcos = xno ]
  440. then
  441. old_multidirs="${multidirs}"
  442. multidirs=""
  443. for x in ${old_multidirs}; do
  444. case "$x" in
  445. *mcall-linux* | *mcall-solaris* ) : ;;
  446. *) multidirs="${multidirs} ${x}" ;;
  447. esac
  448. done
  449. fi
  450. if [ x$enable_biendian = xno ]
  451. then
  452. old_multidirs="${multidirs}"
  453. multidirs=""
  454. for x in ${old_multidirs}; do
  455. case "$x" in
  456. *mlittle* | *mbig* ) : ;;
  457. *) multidirs="${multidirs} ${x}" ;;
  458. esac
  459. done
  460. fi
  461. if [ x$enable_sysv = xno ]
  462. then
  463. old_multidirs="${multidirs}"
  464. multidirs=""
  465. for x in ${old_multidirs}; do
  466. case "$x" in
  467. *mcall-sysv* ) : ;;
  468. *) multidirs="${multidirs} ${x}" ;;
  469. esac
  470. done
  471. fi
  472. ;;
  473. esac
  474. # Remove extraneous blanks from multidirs.
  475. # Tests like `if [ -n "$multidirs" ]' require it.
  476. multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
  477. # Add code to library's top level makefile to handle building the multilib
  478. # subdirs.
  479. cat > Multi.tem <<\EOF
  480. PWD_COMMAND=$${PWDCMD-pwd}
  481. multi-do:
  482. @if [ -z "$(MULTIDIRS)" ]; then \
  483. true; \
  484. else \
  485. rootpre=`${PWD_COMMAND}`/; export rootpre; \
  486. srcrootpre=`cd $(srcdir); ${PWD_COMMAND}`/; export srcrootpre; \
  487. lib=`echo "$${rootpre}" | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
  488. compiler="$(CC)"; \
  489. for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
  490. dir=`echo $$i | sed -e 's/;.*$$//'`; \
  491. if [ "$${dir}" = "." ]; then \
  492. true; \
  493. else \
  494. if [ -d ../$${dir}/$${lib} ]; then \
  495. flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
  496. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
  497. CFLAGS="$(CFLAGS) $${flags}" \
  498. CCASFLAGS="$(CCASFLAGS) $${flags}" \
  499. FCFLAGS="$(FCFLAGS) $${flags}" \
  500. FFLAGS="$(FFLAGS) $${flags}" \
  501. ADAFLAGS="$(ADAFLAGS) $${flags}" \
  502. prefix="$(prefix)" \
  503. exec_prefix="$(exec_prefix)" \
  504. GOCFLAGS="$(GOCFLAGS) $${flags}" \
  505. GDCFLAGS="$(GDCFLAGS) $${flags}" \
  506. CXXFLAGS="$(CXXFLAGS) $${flags}" \
  507. LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
  508. LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
  509. LDFLAGS="$(LDFLAGS) $${flags}" \
  510. MULTIFLAGS="$${flags}" \
  511. DESTDIR="$(DESTDIR)" \
  512. INSTALL="$(INSTALL)" \
  513. INSTALL_DATA="$(INSTALL_DATA)" \
  514. INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
  515. INSTALL_SCRIPT="$(INSTALL_SCRIPT)" \
  516. $(DO)); then \
  517. true; \
  518. else \
  519. exit 1; \
  520. fi; \
  521. else true; \
  522. fi; \
  523. fi; \
  524. done; \
  525. fi
  526. multi-clean:
  527. @if [ -z "$(MULTIDIRS)" ]; then \
  528. true; \
  529. else \
  530. lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
  531. for dir in : $(MULTIDIRS); do \
  532. test $$dir != : || continue; \
  533. EOF
  534. cat >>Multi.tem <<EOF
  535. if [ -f ../\$\${dir}/\$\${lib}/${Makefile} ]; then \\
  536. EOF
  537. cat >>Multi.tem <<\EOF
  538. if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
  539. then true; \
  540. else exit 1; \
  541. fi; \
  542. else true; \
  543. fi; \
  544. done; \
  545. fi
  546. EOF
  547. cat ${Makefile} Multi.tem > Makefile.tem
  548. rm -f ${Makefile} Multi.tem
  549. mv Makefile.tem ${Makefile}
  550. fi # ${ml_toplevel_p} = yes
  551. if [ "${ml_verbose}" = --verbose ]; then
  552. echo "Adding multilib support to ${Makefile} in ${ml_realsrcdir}"
  553. if [ "${ml_toplevel_p}" = yes ]; then
  554. echo "multidirs=${multidirs}"
  555. fi
  556. echo "with_multisubdir=${with_multisubdir}"
  557. fi
  558. if [ "${srcdir}" = "." ]; then
  559. if [ "${with_target_subdir}" != "." ]; then
  560. ml_srcdotdot="../"
  561. else
  562. ml_srcdotdot=""
  563. fi
  564. else
  565. ml_srcdotdot=""
  566. fi
  567. if [ -z "${with_multisubdir}" ]; then
  568. ml_subdir=
  569. ml_builddotdot=
  570. : # ml_srcdotdot= # already set
  571. else
  572. ml_subdir="/${with_multisubdir}"
  573. # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
  574. ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
  575. if [ "$srcdir" = "." ]; then
  576. ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
  577. else
  578. : # ml_srcdotdot= # already set
  579. fi
  580. fi
  581. if [ "${ml_toplevel_p}" = yes ]; then
  582. ml_do='$(MAKE)'
  583. ml_clean='$(MAKE)'
  584. else
  585. ml_do=true
  586. ml_clean=true
  587. fi
  588. # TOP is used by newlib and should not be used elsewhere for this purpose.
  589. # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
  590. # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
  591. # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
  592. # delete TOP. Newlib may wish to continue to use TOP for its own purposes
  593. # of course.
  594. # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
  595. # and lists the subdirectories to recurse into.
  596. # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
  597. # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
  598. # a leading '/'.
  599. # MULTIDO is used for targets like all, install, and check where
  600. # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
  601. # MULTICLEAN is used for the *clean targets.
  602. #
  603. # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
  604. # currently kept separate because we don't want the *clean targets to require
  605. # the existence of the compiler (which MULTIDO currently requires) and
  606. # therefore we'd have to record the directory options as well as names
  607. # (currently we just record the names and use --print-multi-lib to get the
  608. # options).
  609. sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
  610. -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
  611. -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
  612. -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
  613. -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
  614. -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
  615. -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
  616. ${Makefile} > Makefile.tem
  617. rm -f ${Makefile}
  618. mv Makefile.tem ${Makefile}
  619. # If this is the library's top level, configure each multilib subdir.
  620. # This is done at the end because this is the loop that runs configure
  621. # in each multilib subdir and it seemed reasonable to finish updating the
  622. # Makefile before going on to configure the subdirs.
  623. if [ "${ml_toplevel_p}" = yes ]; then
  624. # We must freshly configure each subdirectory. This bit of code is
  625. # actually partially stolen from the main configure script. FIXME.
  626. if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
  627. if [ "${ml_verbose}" = --verbose ]; then
  628. echo "Running configure in multilib subdirs ${multidirs}"
  629. echo "pwd: `${PWDCMD-pwd}`"
  630. fi
  631. ml_origdir=`${PWDCMD-pwd}`
  632. ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'`
  633. # cd to top-level-build-dir/${with_target_subdir}
  634. cd ..
  635. for ml_dir in ${multidirs}; do
  636. if [ "${ml_verbose}" = --verbose ]; then
  637. echo "Running configure in multilib subdir ${ml_dir}"
  638. echo "pwd: `${PWDCMD-pwd}`"
  639. fi
  640. if [ -d ${ml_dir} ]; then true; else
  641. # ``mkdir -p ${ml_dir}'' See also mkinstalldirs.
  642. pathcomp=""
  643. for d in `echo ":${ml_dir}" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; do
  644. pathcomp="$pathcomp$d"
  645. case "$pathcomp" in
  646. -* ) pathcomp=./$pathcomp ;;
  647. esac
  648. if test ! -d "$pathcomp"; then
  649. echo "mkdir $pathcomp" 1>&2
  650. mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
  651. fi
  652. if test ! -d "$pathcomp"; then
  653. exit $lasterr
  654. fi
  655. pathcomp="$pathcomp/"
  656. done
  657. fi
  658. if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
  659. # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
  660. dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
  661. case ${srcdir} in
  662. ".")
  663. echo "Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}"
  664. if [ "${with_target_subdir}" != "." ]; then
  665. ml_unsubdir="../"
  666. else
  667. ml_unsubdir=""
  668. fi
  669. (cd ${ml_dir}/${ml_libdir};
  670. ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
  671. if [ -f ${ml_dir}/${ml_libdir}/${Makefile} ]; then
  672. if [ x"${MAKE}" = x ]; then
  673. (cd ${ml_dir}/${ml_libdir}; make distclean)
  674. else
  675. (cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
  676. fi
  677. fi
  678. ml_newsrcdir="."
  679. ml_srcdiroption=
  680. multisrctop=${dotdot}
  681. ;;
  682. *)
  683. case "${srcdir}" in
  684. /* | [A-Za-z]:[\\/]* ) # absolute path
  685. ml_newsrcdir=${srcdir}
  686. ;;
  687. *) # otherwise relative
  688. ml_newsrcdir=${dotdot}${srcdir}
  689. ;;
  690. esac
  691. ml_srcdiroption="-srcdir=${ml_newsrcdir}"
  692. multisrctop=
  693. ;;
  694. esac
  695. case "${progname}" in
  696. /* | [A-Za-z]:[\\/]* ) ml_recprog=${progname} ;;
  697. *) ml_recprog=${dotdot}${progname} ;;
  698. esac
  699. # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
  700. ML_POPDIR=`${PWDCMD-pwd}`
  701. cd ${ml_dir}/${ml_libdir}
  702. if [ -f ${ml_newsrcdir}/configure ]; then
  703. ml_recprog="${ml_newsrcdir}/configure"
  704. fi
  705. # find compiler flag corresponding to ${ml_dir}
  706. for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
  707. dir=`echo $i | sed -e 's/;.*$//'`
  708. if [ "${dir}" = "${ml_dir}" ]; then
  709. flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
  710. break
  711. fi
  712. done
  713. ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" F77="${F77_}$flags" GFORTRAN="${GFORTRAN_}$flags" GOC="${GOC_}$flags" GDC="${GDC_}$flags"'
  714. if [ "${with_target_subdir}" = "." ]; then
  715. CC_=$CC' '
  716. CXX_=$CXX' '
  717. F77_=$F77' '
  718. GFORTRAN_=$GFORTRAN' '
  719. GOC_=$GOC' '
  720. GDC_=$GDC' '
  721. else
  722. # Create a regular expression that matches any string as long
  723. # as ML_POPDIR.
  724. popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'`
  725. CC_=
  726. for arg in ${CC}; do
  727. case $arg in
  728. -[BIL]"${ML_POPDIR}"/*)
  729. 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"`' ' ;;
  730. "${ML_POPDIR}"/*)
  731. 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"`' ' ;;
  732. *)
  733. CC_="${CC_}${arg} " ;;
  734. esac
  735. done
  736. CXX_=
  737. for arg in ${CXX}; do
  738. case $arg in
  739. -[BIL]"${ML_POPDIR}"/*)
  740. 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"`' ' ;;
  741. "${ML_POPDIR}"/*)
  742. 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"`' ' ;;
  743. *)
  744. CXX_="${CXX_}${arg} " ;;
  745. esac
  746. done
  747. F77_=
  748. for arg in ${F77}; do
  749. case $arg in
  750. -[BIL]"${ML_POPDIR}"/*)
  751. 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"`' ' ;;
  752. "${ML_POPDIR}"/*)
  753. 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"`' ' ;;
  754. *)
  755. F77_="${F77_}${arg} " ;;
  756. esac
  757. done
  758. GFORTRAN_=
  759. for arg in ${GFORTRAN}; do
  760. case $arg in
  761. -[BIL]"${ML_POPDIR}"/*)
  762. 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"`' ' ;;
  763. "${ML_POPDIR}"/*)
  764. 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"`' ' ;;
  765. *)
  766. GFORTRAN_="${GFORTRAN_}${arg} " ;;
  767. esac
  768. done
  769. GOC_=
  770. for arg in ${GOC}; do
  771. case $arg in
  772. -[BIL]"${ML_POPDIR}"/*)
  773. 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"`' ' ;;
  774. "${ML_POPDIR}"/*)
  775. 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"`' ' ;;
  776. *)
  777. GOC_="${GOC_}${arg} " ;;
  778. esac
  779. done
  780. GDC_=
  781. for arg in ${GDC}; do
  782. case $arg in
  783. -[BIL]"${ML_POPDIR}"/*)
  784. GDC_="${GDC_}"`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"`' ' ;;
  785. "${ML_POPDIR}"/*)
  786. GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
  787. *)
  788. GDC_="${GDC_}${arg} " ;;
  789. esac
  790. done
  791. if test "x${LD_LIBRARY_PATH+set}" = xset; then
  792. LD_LIBRARY_PATH_=
  793. for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do
  794. case "$arg" in
  795. "${ML_POPDIR}"/*)
  796. 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"`
  797. ;;
  798. esac
  799. if test "x$LD_LIBRARY_PATH_" != x; then
  800. LD_LIBRARY_PATH_=$LD_LIBRARY_PATH_:$arg
  801. else
  802. LD_LIBRARY_PATH_=$arg
  803. fi
  804. done
  805. ml_config_env="$ml_config_env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_"
  806. fi
  807. if test "x${SHLIB_PATH+set}" = xset; then
  808. SHLIB_PATH_=
  809. for arg in `echo "$SHLIB_PATH" | tr ':' ' '`; do
  810. case "$arg" in
  811. "${ML_POPDIR}"/*)
  812. 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"`
  813. ;;
  814. esac
  815. if test "x$SHLIB_PATH_" != x; then
  816. SHLIB_PATH_=$SHLIB_PATH_:$arg
  817. else
  818. SHLIB_PATH_=$arg
  819. fi
  820. done
  821. ml_config_env="$ml_config_env SHLIB_PATH=$SHLIB_PATH_"
  822. fi
  823. fi
  824. if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
  825. --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
  826. "${ac_configure_args}" ${ml_config_env} ${ml_srcdiroption} ; then
  827. true
  828. else
  829. exit 1
  830. fi
  831. cd "${ML_POPDIR}"
  832. done
  833. cd "${ml_origdir}"
  834. fi
  835. fi # ${ml_toplevel_p} = yes
  836. fi # ${enable_multilib} = yes