1 # Configure fragment invoked in the post-target section for subdirs
2 # wanting multilib support.
4 # It is advisable to support a few --enable/--disable options to let the
5 # user select which libraries s/he really wants.
7 # Subdirectories wishing to use multilib should put the following lines
8 # in the "post-target" section of configure.in.
10 # if [ "${srcdir}" = "." ] ; then
11 # if [ "${with_target_subdir}" != "." ] ; then
12 # . ${srcdir}/${with_multisrctop}../../config-ml.in
14 # . ${srcdir}/${with_multisrctop}../config-ml.in
17 # . ${srcdir}/../config-ml.in
20 # See librx/configure.in in the libg++ distribution for an example of how
21 # to handle autoconf'd libraries.
23 # Things are complicated because 6 separate cases must be handled:
24 # 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
26 # srcdir=. is special. It must handle make programs that don't handle VPATH.
27 # To implement this, a symlink tree is built for each library and for each
30 # The build tree is layed out as
42 # The nice feature about this arrangement is that inter-library references
43 # in the build tree work without having to care where you are. Note that
44 # inter-library references also work in the source tree because symlink trees
45 # are built when srcdir=.
47 # Configure variables:
48 # ${with_target_subdir} = "." for native, or ${target_alias} for cross.
49 # Set by top level Makefile.
50 # ${with_multisrctop} = how many levels of multilibs there are in the source
51 # tree. It exists to handle the case of configuring in the source tree:
52 # ${srcdir} is not constant.
53 # ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
56 # MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
57 # MULITBUILDTOP = number of multilib levels in build tree
58 # MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...)
59 # (only defined in each library's main Makefile).
60 # MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000)
61 # (only defined in each multilib subdir).
63 # FIXME: Multilib is currently disabled by default for everything other than
64 # newlib. It is up to each target to turn on multilib support for the other
65 # libraries as desired.
67 # We have to handle being invoked by both Cygnus configure and Autoconf.
68 # We except both to define `srcdir' and `target' (we *could* figure them
69 # out, but we'd have to do work that they're already done to figure them out).
70 # We expect Cygnus configure to define `arguments' and Autoconf to define
71 # `ac_configure_args'.
73 if [ -n "${ac_configure_args}" ]; then
74 Makefile=${ac_file-Makefile}
75 ml_config_shell=${CONFIG_SHELL-/bin/sh}
76 ml_arguments="${ac_configure_args}"
78 Makefile=${Makefile-Makefile}
79 ml_config_shell=${config_shell-/bin/sh}
80 ml_arguments="${arguments}"
83 # Scan all the arguments and set all the ones we need.
85 for option in ${ml_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"
194 sparclite-*-* | sparclitefrw*-*-*)
195 multidirs="mfpu msoft-float mflat mno-flat mfpu/mflat mfpu/mno-flat msoft-float/mflat msoft-float/mno-flat"
197 sparc-*-* | sparcfrw*-*-*)
198 multidirs="soft v8 soft/v8"
201 multidirs="z8001 std z8001/std"
207 multidirs="mbig msmall mcompact mmedium"
209 # start-sanitize-jaguar
213 # end-sanitize-jaguar
215 multidirs="ml m2 ml/m2"
216 # start-sanitize-sh3e
217 multidirs="ml m2 ml/m2 m3e ml/m3e"
221 # Note that not all of these will be built for a particular
222 # target; what is build depends upon the output gcc
223 # --print-multi-lib. We configure them all, to make our life
224 # simpler here. If somebody cares about configuration
225 # efficiency, they will need to switch off on the various
226 # targets to configure just the directories needed for that
229 # In the long run, it would be better to configure based on
230 # the output of gcc --print-multi-lib, but, to do that, we
231 # would have to build gcc before configuring newlib.
233 # Default to including the single-float directories.
234 if [ x$enable_single_float = x ]; then
235 enable_single_float=yes
237 if [ x$enable_single_float = xyes ]; then
238 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"
240 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"
242 if [ x$enable_biendian = xno ]
244 old_multidirs="${multidirs}"
246 for x in ${old_multidirs}; do
249 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
253 if [ x$enable_softfloat = xno ]
255 old_multidirs="${multidirs}"
257 for x in ${old_multidirs}; do
260 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
264 if [ x$enable_relocatable = xno ]
266 old_multidirs="${multidirs}"
268 for x in ${old_multidirs}; do
271 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
275 if [ x$enable_sysv = xno ]
277 old_multidirs="${multidirs}"
279 for x in ${old_multidirs}; do
282 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
287 powerpc-ibm-aix* | rs6000-ibm-aix*)
288 multidirs="soft-float common soft-float/common"
289 if [ x$enable_softfloat = xno ]
291 old_multidirs="${multidirs}"
293 for x in ${old_multidirs}; do
296 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
300 if [ x$enable_commoncpu = xno ]
302 old_multidirs="${multidirs}"
304 for x in ${old_multidirs}; do
307 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
313 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"
314 if [ x$enable_biendian = xno ]
316 old_multidirs="${multidirs}"
318 for x in ${old_multidirs}; do
321 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
325 if [ x$enable_softfloat = xno ]
327 old_multidirs="${multidirs}"
329 for x in ${old_multidirs}; do
332 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
336 if [ x$enable_relocatable = xno ]
338 old_multidirs="${multidirs}"
340 for x in ${old_multidirs}; do
343 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
347 if [ x$enable_sysv = xno ]
349 old_multidirs="${multidirs}"
351 for x in ${old_multidirs}; do
354 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
359 powerpc-*-eabi* | powerpc-*-elf* | powerpc-*-sysv4*)
360 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"
361 if [ x$enable_biendian = xno ]
363 old_multidirs="${multidirs}"
365 for x in ${old_multidirs}; do
368 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
372 if [ x$enable_softfloat = xno ]
374 old_multidirs="${multidirs}"
376 for x in ${old_multidirs}; do
379 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
383 if [ x$enable_relocatable = xno ]
385 old_multidirs="${multidirs}"
387 for x in ${old_multidirs}; do
390 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
394 if [ x$enable_aix = xno ]
396 old_multidirs="${multidirs}"
398 for x in ${old_multidirs}; do
401 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
406 powerpcle-*-eabi* | powerpcle-*-elf* | powerpcle-*-sysv4*)
407 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"
408 if [ x$enable_biendian = xno ]
410 old_multidirs="${multidirs}"
412 for x in ${old_multidirs}; do
415 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
419 if [ x$enable_softfloat = xno ]
421 old_multidirs="${multidirs}"
423 for x in ${old_multidirs}; do
426 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
430 if [ x$enable_relocatable = xno ]
432 old_multidirs="${multidirs}"
434 for x in ${old_multidirs}; do
437 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
441 if [ x$enable_aix = xno ]
443 old_multidirs="${multidirs}"
445 for x in ${old_multidirs}; do
448 *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
458 # Add code to library's top level makefile to handle building the multilib
461 cat > Multi.tem <<\EOF
463 # FIXME: There should be an @-sign in front of the `if'.
464 # Leave out until this is tested a bit more.
466 if [ -z "$(MULTIDIRS)" ]; then \
469 rootpre=`pwd`/; export rootpre; \
470 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
471 lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
473 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
474 dir=`echo $$i | sed -e 's/;.*$$//'`; \
475 if [ "$${dir}" = "." ]; then \
478 if [ -d ../$${dir}/$${lib} ]; then \
479 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
480 if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
481 CFLAGS="$(CFLAGS) $${flags}" \
482 CXXFLAGS="$(CXXFLAGS) $${flags}" \
483 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
484 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
496 # FIXME: There should be an @-sign in front of the `if'.
497 # Leave out until this is tested a bit more.
499 if [ -z "$(MULTIDIRS)" ]; then \
502 lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
503 for dir in Makefile $(MULTIDIRS); do \
504 if [ -f ../$${dir}/$${lib}/Makefile ]; then \
505 if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
515 cat ${Makefile} Multi.tem > Makefile.tem
516 rm -f ${Makefile} Multi.tem
517 mv Makefile.tem ${Makefile}
519 fi # ${ml_toplevel_p} = yes
521 if [ "${ml_verbose}" = --verbose ]; then
522 echo "Adding multilib support to Makefile in `pwd`"
523 if [ "${ml_toplevel_p}" = yes ]; then
524 echo "multidirs=${multidirs}"
526 echo "with_multisubdir=${with_multisubdir}"
529 if [ "${srcdir}" = "." ]; then
530 if [ "${with_target_subdir}" != "." ]; then
539 if [ -z "${with_multisubdir}" ]; then
542 : # ml_srcdotdot= # already set
544 ml_subdir="/${with_multisubdir}"
545 # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
546 ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
547 if [ "$srcdir" = "." ]; then
548 ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
550 : # ml_srcdotdot= # already set
554 if [ "${ml_toplevel_p}" = yes ]; then
562 # TOP is used by newlib and should not be used elsewhere for this purpose.
563 # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
564 # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
565 # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
566 # delete TOP. Newlib may wish to continue to use TOP for its own purposes
568 # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
569 # and lists the subdirectories to recurse into.
570 # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
571 # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
573 # MULTIDO is used for targets like all, install, and check where
574 # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
575 # MULTICLEAN is used for the *clean targets.
577 # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
578 # currently kept separate because we don't want the *clean targets to require
579 # the existence of the compiler (which MULTIDO currently requires) and
580 # therefore we'd have to record the directory options as well as names
581 # (currently we just record the names and use --print-multi-lib to get the
584 sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
585 -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
586 -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
587 -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
588 -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
589 -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
590 -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
591 ${Makefile} > Makefile.tem
593 mv Makefile.tem ${Makefile}
595 # If this is the library's top level, configure each multilib subdir.
596 # This is done at the end because this is the loop that runs configure
597 # in each multilib subdir and it seemed reasonable to finish updating the
598 # Makefile before going on to configure the subdirs.
600 if [ "${ml_toplevel_p}" = yes ]; then
602 # We must freshly configure each subdirectory. This bit of code is
603 # actually partially stolen from the main configure script. FIXME.
605 if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
607 if [ "${ml_verbose}" = --verbose ]; then
608 echo "Running configure in multilib subdirs ${multidirs}"
613 ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
614 # cd to top-level-build-dir/${with_target_subdir}
617 for ml_dir in ${multidirs}; do
619 if [ "${ml_verbose}" = --verbose ]; then
620 echo "Running configure in multilib subdir ${ml_dir}"
624 if [ -d ${ml_dir} ]; then true; else mkdir ${ml_dir}; fi
625 if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
627 # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
628 dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
632 echo Building symlink tree in `pwd`/${ml_dir}/${ml_libdir}
633 if [ "${with_target_subdir}" != "." ]; then
638 (cd ${ml_dir}/${ml_libdir};
639 ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
642 multisrctop=${dotdot}
647 ml_newsrcdir=${srcdir}
649 *) # otherwise relative
650 ml_newsrcdir=${dotdot}${srcdir}
653 ml_srcdiroption="-srcdir=${ml_newsrcdir}"
658 case "${progname}" in
659 /*) ml_recprog=${progname} ;;
660 *) ml_recprog=${dotdot}${progname} ;;
663 # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
665 cd ${ml_dir}/${ml_libdir}
667 if [ -f ${ml_newsrcdir}/configure ]; then
668 ml_recprog=${ml_newsrcdir}/configure
670 if eval ${ml_config_shell} ${ml_recprog} \
671 --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
672 ${ml_arguments} ${ml_srcdiroption} ; then
685 fi # ${ml_toplevel_p} = yes
686 fi # ${enable_multilib} = yes