2 # Configure fragment invoked in the post-target section for subdirs
3 # wanting multilib support.
5 # It is advisable to support a few --enable/--disable options to let the
6 # user select which libraries s/he really wants.
8 # Subdirectories wishing to use multilib should put the following lines
9 # in the "post-target" section of configure.in.
11 # if [ "${srcdir}" = "." ] ; then
12 # if [ "${with_target_subdir}" != "." ] ; then
13 # . ${srcdir}/${with_multisrctop}../../config-ml.in
15 # . ${srcdir}/${with_multisrctop}../config-ml.in
18 # . ${srcdir}/../config-ml.in
21 # See librx/configure.in in the libg++ distribution for an example of how
22 # to handle autoconf'd libraries.
24 # Things are complicated because 6 separate cases must be handled:
25 # 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
27 # srcdir=. is special. It must handle make programs that don't handle VPATH.
28 # To implement this, a symlink tree is built for each library and for each
31 # The build tree is layed out as
43 # The nice feature about this arrangement is that inter-library references
44 # in the build tree work without having to care where you are. Note that
45 # inter-library references also work in the source tree because symlink trees
46 # are built when srcdir=.
48 # Configure variables:
49 # ${with_target_subdir} = "." for native, or ${target_alias} for cross.
50 # Set by top level Makefile.
51 # ${with_multisrctop} = how many levels of multilibs there are in the source
52 # tree. It exists to handle the case of configuring in the source tree:
53 # ${srcdir} is not constant.
54 # ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
57 # MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
58 # MULITBUILDTOP = number of multilib levels in build tree
59 # MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...)
60 # (only defined in each library's main Makefile).
61 # MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000)
62 # (only defined in each multilib subdir).
64 # FIXME: Multilib is currently disabled by default for everything other than
65 # newlib. It is up to each target to turn on multilib support for the other
66 # libraries as desired.
68 # We have to handle being invoked by both Cygnus configure and Autoconf.
69 # We except both to define `srcdir' and `target' (we *could* figure them
70 # out, but we'd have to do work that they're already done to figure them out).
71 # We expect Cygnus configure to define `arguments' and Autoconf to define
72 # `ac_configure_args'.
74 if [ -n "${ac_configure_args}" ]; then
75 Makefile=${ac_file-Makefile}
76 config_shell=${CONFIG_SHELL-/bin/sh}
77 arguments="${ac_configure_args}"
79 Makefile=${Makefile-Makefile}
80 config_shell=${config_shell-/bin/sh}
83 # Scan all the arguments and set all the ones we need.
85 for option in $arguments
89 -*) option=-$option ;;
94 optarg=`echo $option | sed -e 's/^[^=]*=//'`
100 enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
108 enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
109 eval $enableopt="$optarg"
111 --norecursion | --no*)
114 --verbose | --v | --verb*)
122 withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
123 eval $withopt="$optarg"
126 withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
132 # Only do this if --enable-multilib.
133 if [ "${enable_multilib}" = yes ]; then
135 # Compute whether this is the library's top level directory
136 # (ie: not a multilib subdirectory, and not a subdirectory like libg++/src).
137 # ${with_multisubdir} tells us we're in the right branch, but we could be
138 # in a subdir of that.
139 # ??? The previous version could void this test by separating the process into
140 # two files: one that only the library's toplevel configure.in ran (to
141 # configure the multilib subdirs), and another that all configure.in's ran to
142 # update the Makefile. It seemed reasonable to collapse all multilib support
143 # into one file, but it does leave us with having to perform this test.
145 if [ -z "${with_multisubdir}" ]; then
146 if [ "${srcdir}" = "." ]; then
147 # ${with_target_subdir} = "." for native, otherwise target alias.
148 if [ "${with_target_subdir}" = "." ]; then
149 if [ -f ../config-ml.in ]; then
153 if [ -f ../../config-ml.in ]; then
158 if [ -f ${srcdir}/../config-ml.in ]; then
164 # If this is the library's top level directory, set multidirs to the
165 # multilib subdirs to support. This lives at the top because we need
166 # `multidirs' set right away, and this section is subject to frequent
167 # editing (addition of new targets, etc.).
169 if [ "${ml_toplevel_p}" = yes ]; then
174 if [ x$enable_biendian = xyes ]
176 multidirs="be host graphics audio be/host be/graphics be/audio"
178 multidirs="host graphics audio"
186 multidirs="soft-float"
188 #m68*-*-aout* | m68*-*-coff* | m68*-*-elf* | m68*-*-vxworks*)
189 # multidirs="m68000 m68020 m68881 msoft-float m68000/m68881 m68000/msoft-float m68020/m68881 m68020/msoft-float"
191 m68*-*-aout* | m68*-*-coff* | m68*-*-elf* | m68*-*-vxworks*)
192 multidirs="m68000 m68000/m68881"
197 sparclite-*-* | sparclitefrw*-*-*)
198 multidirs="mfpu msoft-float mflat mno-flat mfpu/mflat mfpu/mno-flat msoft-float/mflat msoft-float/mno-flat"
200 sparc-*-* | sparcfrw*-*-*)
201 multidirs="soft v8 soft/v8"
204 multidirs="z8001 std z8001/std"
210 multidirs="mbig msmall mcompact mmedium"
212 # start-sanitize-jaguar
216 # end-sanitize-jaguar
218 multidirs="ml m2 ml/m2"
219 # start-sanitize-sh3e
220 multidirs="ml m2 ml/m2 m3e ml/m3e"
224 # Note that not all of these will be built for a particular
225 # target; what is build depends upon the output gcc
226 # --print-multi-lib. We configure them all, to make our life
227 # simpler here. If somebody cares about configuration
228 # efficiency, they will need to switch off on the various
229 # targets to configure just the directories needed for that
232 # In the long run, it would be better to configure based on
233 # the output of gcc --print-multi-lib, but, to do that, we
234 # would have to build gcc before configuring newlib.
236 # Default to including the single-float directories.
237 if [ x$enable_single_float = x ]; then
238 enable_single_float=yes
240 if [ x$enable_single_float = xyes ]; then
241 multidirs="soft-float single el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 single/el single/eb single/mips1 single/mips3 single/el/mips1 single/el/mips3 single/eb/mips1 single/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3"
243 multidirs="soft-float el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3"
245 if [ x$enable_biendian = xno ]
247 old_multidirs="${multidirs}"
249 for x in ${old_multidirs}; do
252 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
256 if [ x$enable_softfloat = xno ]
258 old_multidirs="${multidirs}"
260 for x in ${old_multidirs}; do
263 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
267 if [ x$enable_relocatable = xno ]
269 old_multidirs="${multidirs}"
271 for x in ${old_multidirs}; do
274 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
278 if [ x$enable_sysv = xno ]
280 old_multidirs="${multidirs}"
282 for x in ${old_multidirs}; do
285 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
290 powerpc-ibm-aix* | rs6000-ibm-aix*)
291 multidirs="soft-float common soft-float/common"
292 if [ x$enable_softfloat = xno ]
294 old_multidirs="${multidirs}"
296 for x in ${old_multidirs}; do
299 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
303 if [ x$enable_commoncpu = xno ]
305 old_multidirs="${multidirs}"
307 for x in ${old_multidirs}; do
310 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
316 multidirs="soft-float relocatable little sysv little/sysv relocatable/little relocatable/sysv relocatable/little/sysv soft-float/relocatable soft-float/little soft-float/sysv soft-float/little/sysv soft-float/relocatable/little soft-float/relocatable/sysv soft-float/relocatable/little/sysv"
317 if [ x$enable_biendian = xno ]
319 old_multidirs="${multidirs}"
321 for x in ${old_multidirs}; do
324 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
328 if [ x$enable_softfloat = xno ]
330 old_multidirs="${multidirs}"
332 for x in ${old_multidirs}; do
335 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
339 if [ x$enable_relocatable = xno ]
341 old_multidirs="${multidirs}"
343 for x in ${old_multidirs}; do
346 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
350 if [ x$enable_sysv = xno ]
352 old_multidirs="${multidirs}"
354 for x in ${old_multidirs}; do
357 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
362 powerpc-*-eabi* | powerpc-*-elf* | powerpc-*-sysv4*)
363 multidirs="soft-float relocatable little aix little/aix relocatable/little relocatable/aix relocatable/little/aix soft-float/relocatable soft-float/little soft-float/aix soft-float/little/aix soft-float/relocatable/little soft-float/relocatable/aix soft-float/relocatable/little/aix aixdesc soft-float/aixdesc"
364 if [ x$enable_biendian = xno ]
366 old_multidirs="${multidirs}"
368 for x in ${old_multidirs}; do
371 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
375 if [ x$enable_softfloat = xno ]
377 old_multidirs="${multidirs}"
379 for x in ${old_multidirs}; do
382 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
386 if [ x$enable_relocatable = xno ]
388 old_multidirs="${multidirs}"
390 for x in ${old_multidirs}; do
393 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
397 if [ x$enable_aix = xno ]
399 old_multidirs="${multidirs}"
401 for x in ${old_multidirs}; do
404 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
409 powerpcle-*-eabi* | powerpcle-*-elf* | powerpcle-*-sysv4*)
410 multidirs="soft-float relocatable big aix big/aix relocatable/big relocatable/aix relocatable/big/aix soft-float/relocatable soft-float/big soft-float/aix soft-float/big/aix soft-float/relocatable/big soft-float/relocatable/aix soft-float/relocatable/big/aix"
411 if [ x$enable_biendian = xno ]
413 old_multidirs="${multidirs}"
415 for x in ${old_multidirs}; do
418 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
422 if [ x$enable_softfloat = xno ]
424 old_multidirs="${multidirs}"
426 for x in ${old_multidirs}; do
429 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
433 if [ x$enable_relocatable = xno ]
435 old_multidirs="${multidirs}"
437 for x in ${old_multidirs}; do
440 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
444 if [ x$enable_aix = xno ]
446 old_multidirs="${multidirs}"
448 for x in ${old_multidirs}; do
451 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
461 # Add code to library's top level makefile to handle building the multilib
464 cat > Multi.tem <<\EOF
466 # FIXME: There should be an @-sign in front of the `if'.
467 # Leave out until this is tested a bit more.
469 if [ -z "$(MULTIDIRS)" ]; then \
472 rootpre=`pwd`/; export rootpre; \
473 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
474 lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
476 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
477 dir=`echo $$i | sed -e 's/;.*$$//'`; \
478 if [ "$${dir}" = "." ]; then \
481 if [ -d ../$${dir}/$${lib} ]; then \
482 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
483 if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
484 CFLAGS="$(CFLAGS) $${flags}" \
485 CXXFLAGS="$(CXXFLAGS) $${flags}" \
486 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
487 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
499 # FIXME: There should be an @-sign in front of the `if'.
500 # Leave out until this is tested a bit more.
502 if [ -z "$(MULTIDIRS)" ]; then \
505 lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
506 for dir in Makefile $(MULTIDIRS); do \
507 if [ -f ../$${dir}/$${lib}/Makefile ]; then \
508 if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
518 cat ${Makefile} Multi.tem > Makefile.tem
519 rm -f ${Makefile} Multi.tem
520 mv Makefile.tem ${Makefile}
522 fi # ${ml_toplevel_p} = yes
524 if [ "${verbose}" = --verbose ]; then
525 echo "Adding multilib support to Makefile in `pwd`"
526 if [ "${ml_toplevel_p}" = yes ]; then
527 echo "multidirs=${multidirs}"
529 echo "with_multisubdir=${with_multisubdir}"
532 if [ "${srcdir}" = "." ]; then
533 if [ "${with_target_subdir}" != "." ]; then
542 if [ -z "${with_multisubdir}" ]; then
545 : # ml_srcdotdot= # already set
547 ml_subdir="/${with_multisubdir}"
548 # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
549 ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
550 if [ "$srcdir" = "." ]; then
551 ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
553 : # ml_srcdotdot= # already set
557 if [ "${ml_toplevel_p}" = yes ]; then
565 # TOP is used by newlib and should not be used elsewhere for this purpose.
566 # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
567 # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
568 # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
569 # delete TOP. Newlib may wish to continue to use TOP for its own purposes
571 # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
572 # and lists the subdirectories to recurse into.
573 # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
574 # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
576 # MULTIDO is used for targets like all, install, and check where
577 # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
578 # MULTICLEAN is used for the *clean targets.
580 # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
581 # currently kept separate because we don't want the *clean targets to require
582 # the existence of the compiler (which MULTIDO currently requires) and
583 # therefore we'd have to record the directory options as well as names
584 # (currently we just record the names and use --print-multi-lib to get the
587 sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
588 -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
589 -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
590 -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
591 -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
592 -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
593 -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
594 ${Makefile} > Makefile.tem
596 mv Makefile.tem ${Makefile}
598 # If this is the library's top level, configure each multilib subdir.
599 # This is done at the end because this is the loop that runs configure
600 # in each multilib subdir and it seemed reasonable to finish updating the
601 # Makefile before going on to configure the subdirs.
603 if [ "${ml_toplevel_p}" = yes ]; then
605 # We must freshly configure each subdirectory. This bit of code is
606 # actually partially stolen from the main configure script. FIXME.
608 if [ -n "${multidirs}" ] && [ -z "${norecursion}" ]; then
610 if [ "${verbose}" = --verbose ]; then
611 echo "Running configure in multilib subdirs ${multidirs}"
616 ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
617 # cd to top-level-build-dir/${with_target_subdir}
620 for dir in ${multidirs}; do
622 if [ "${verbose}" = --verbose ]; then
623 echo "Running configure in multilib subdir ${dir}"
627 if [ -d ${dir} ]; then true; else mkdir ${dir}; fi
628 if [ -d ${dir}/${ml_libdir} ]; then true; else mkdir ${dir}/${ml_libdir}; fi
630 # Eg: if ${dir} = m68000/m68881, dotdot = ../../
631 dotdot=../`echo ${dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
635 echo Building symlink tree in `pwd`/${dir}/${ml_libdir}
636 if [ "${with_target_subdir}" != "." ]; then
641 (cd ${dir}/${ml_libdir};
642 ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
645 multisrctop=${dotdot}
652 *) # otherwise relative
653 newsrcdir=${dotdot}${srcdir}
656 srcdiroption="-srcdir=${newsrcdir}"
661 case "${progname}" in
662 /*) recprog=${progname} ;;
663 *) recprog=${dotdot}${progname} ;;
666 # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
668 cd ${dir}/${ml_libdir}
670 if [ -f ${newsrcdir}/configure ]; then
671 recprog=${newsrcdir}/configure
673 if eval ${config_shell} -x ${recprog} \
674 --with-multisubdir=${dir} --with-multisrctop=${multisrctop} \
675 $arguments ${srcdiroption} ; then
688 fi # ${ml_toplevel_p} = yes
689 fi # ${enable_multilib} = yes