* config-ml.in: Prefix more variables with ml_ so they don't collide
[external/binutils.git] / config-ml.in
1 # Configure fragment invoked in the post-target section for subdirs
2 # wanting multilib support.
3 #
4 # It is advisable to support a few --enable/--disable options to let the
5 # user select which libraries s/he really wants.
6 #
7 # Subdirectories wishing to use multilib should put the following lines
8 # in the "post-target" section of configure.in.
9 #
10 # if [ "${srcdir}" = "." ] ; then
11 #   if [ "${with_target_subdir}" != "." ] ; then
12 #     . ${srcdir}/${with_multisrctop}../../config-ml.in
13 #   else
14 #     . ${srcdir}/${with_multisrctop}../config-ml.in
15 #   fi
16 # else
17 #   . ${srcdir}/../config-ml.in
18 # fi
19 #
20 # See librx/configure.in in the libg++ distribution for an example of how
21 # to handle autoconf'd libraries.
22 #
23 # Things are complicated because 6 separate cases must be handled:
24 # 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
25 #
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
28 # multilib subdir.
29 #
30 # The build tree is layed out as
31 #
32 # ./
33 #   libg++
34 #   newlib
35 #   m68020/
36 #          libg++
37 #          newlib
38 #          m68881/
39 #                 libg++
40 #                 newlib
41 #
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=.
46 #
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).
54 #
55 # Makefile variables:
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).
62
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.
66
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'.
72
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}"
77 else
78   Makefile=${Makefile-Makefile}
79   ml_config_shell=${config_shell-/bin/sh}
80   ml_arguments="${arguments}"
81 fi
82
83 # Scan all the arguments and set all the ones we need.
84
85 for option in ${ml_arguments}
86 do
87   case $option in
88   --*) ;;
89   -*) option=-$option ;;
90   esac
91
92   case $option in
93   --*=*)
94         optarg=`echo $option | sed -e 's/^[^=]*=//'`
95         ;;
96   esac
97
98   case $option in
99   --disable-*)
100         enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
101         eval $enableopt=no
102         ;;
103   --enable-*)
104         case "$option" in
105         *=*)    ;;
106         *)      optarg=yes ;;
107         esac
108         enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
109         eval $enableopt="$optarg"
110         ;;
111   --norecursion | --no*)
112         ml_norecursion=yes
113         ;;
114   --verbose | --v | --verb*)
115         ml_verbose=--verbose
116         ;;
117   --with-*)
118         case "$option" in
119         *=*)    ;;
120         *)      optarg=yes ;;
121         esac
122         withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
123         eval $withopt="$optarg"
124         ;;
125   --without-*)
126         withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
127         eval $withopt=no
128         ;;
129   esac
130 done
131
132 # Only do this if --enable-multilib.
133 if [ "${enable_multilib}" = yes ]; then
134
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.
144 ml_toplevel_p=no
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
150         ml_toplevel_p=yes
151       fi
152     else
153       if [ -f ../../config-ml.in ]; then
154         ml_toplevel_p=yes
155       fi
156     fi
157   else
158     if [ -f ${srcdir}/../config-ml.in ]; then
159       ml_toplevel_p=yes
160     fi
161   fi
162 fi
163
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.).
168
169 if [ "${ml_toplevel_p}" = yes ]; then
170
171 case "${target}" in
172 # start-sanitize-arc
173 arc-sbp-elf*)
174         if [ x$enable_biendian = xyes ]
175         then
176                 multidirs="be host graphics audio be/host be/graphics be/audio"
177         else
178                 multidirs="host graphics audio"
179         fi
180         ;;
181 arc-*-*)
182         multidirs="be"
183         ;;
184 # end-sanitize-arc
185 hppa*-*-*)
186         multidirs="soft-float"
187         ;;
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"
190         ;;
191 i960-*-*)
192         multidirs=float
193         ;;
194 sparclite-*-* | sparclitefrw*-*-*)
195         multidirs="mfpu msoft-float mflat mno-flat mfpu/mflat mfpu/mno-flat msoft-float/mflat msoft-float/mno-flat"
196         ;;
197 sparc-*-* | sparcfrw*-*-*)
198         multidirs="soft v8 soft/v8"
199         ;;
200 z8k-*-coff)
201         multidirs="z8001 std z8001/std"
202         ;;
203 h8300-*-*)
204         multidirs=h8300h
205         ;;
206 h8500-*-*)
207         multidirs="mbig msmall mcompact mmedium"
208         ;;
209 # start-sanitize-jaguar
210 jaguar-*-*)
211         multidirs="be"
212         ;;
213 # end-sanitize-jaguar
214 sh-*-*)
215         multidirs="ml m2 ml/m2"
216 # start-sanitize-sh3e
217         multidirs="ml m2 ml/m2 m3e ml/m3e"
218 # end-sanitize-sh3e
219         ;;
220 mips*-*-*)
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
227         # target.
228         # 
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.
232         #
233         # Default to including the single-float directories.
234         if [ x$enable_single_float = x ]; then
235           enable_single_float=yes
236         fi
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"
239         else
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"
241         fi
242         if [ x$enable_biendian = xno ]
243         then
244           old_multidirs="${multidirs}"
245           multidirs=""
246           for x in ${old_multidirs}; do
247             case "$x" in
248               *endian* ) : ;;
249               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
250             esac
251           done
252         fi
253         if [ x$enable_softfloat = xno ]
254         then
255           old_multidirs="${multidirs}"
256           multidirs=""
257           for x in ${old_multidirs}; do
258             case "$x" in
259               *soft-float* ) : ;;
260               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
261             esac
262           done
263         fi
264         if [ x$enable_relocatable = xno ]
265         then
266           old_multidirs="${multidirs}"
267           multidirs=""
268           for x in ${old_multidirs}; do
269             case "$x" in
270               *relocatable* ) : ;;
271               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
272             esac
273           done
274         fi
275         if [ x$enable_sysv = xno ]
276         then
277           old_multidirs="${multidirs}"
278           multidirs=""
279           for x in ${old_multidirs}; do
280             case "$x" in
281               *sysv* ) : ;;
282               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
283             esac
284           done
285         fi
286         ;;
287 powerpc-ibm-aix* | rs6000-ibm-aix*)
288         multidirs="soft-float common soft-float/common"
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               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
297             esac
298           done
299         fi
300         if [ x$enable_commoncpu = xno ]
301         then
302           old_multidirs="${multidirs}"
303           multidirs=""
304           for x in ${old_multidirs}; do
305             case "$x" in
306               *common* ) : ;;
307               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
308             esac
309           done
310         fi
311         ;;
312 powerpc-*-eabiaix*)
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 ]
315         then
316           old_multidirs="${multidirs}"
317           multidirs=""
318           for x in ${old_multidirs}; do
319             case "$x" in
320               *endian* ) : ;;
321               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
322             esac
323           done
324         fi
325         if [ x$enable_softfloat = xno ]
326         then
327           old_multidirs="${multidirs}"
328           multidirs=""
329           for x in ${old_multidirs}; do
330             case "$x" in
331               *soft-float* ) : ;;
332               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
333             esac
334           done
335         fi
336         if [ x$enable_relocatable = xno ]
337         then
338           old_multidirs="${multidirs}"
339           multidirs=""
340           for x in ${old_multidirs}; do
341             case "$x" in
342               *relocatable* ) : ;;
343               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
344             esac
345           done
346         fi
347         if [ x$enable_sysv = xno ]
348         then
349           old_multidirs="${multidirs}"
350           multidirs=""
351           for x in ${old_multidirs}; do
352             case "$x" in
353               *sysv* ) : ;;
354               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
355             esac
356           done
357         fi
358         ;;
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 ]
362         then
363           old_multidirs="${multidirs}"
364           multidirs=""
365           for x in ${old_multidirs}; do
366             case "$x" in
367               *endian* ) : ;;
368               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
369             esac
370           done
371         fi
372         if [ x$enable_softfloat = xno ]
373         then
374           old_multidirs="${multidirs}"
375           multidirs=""
376           for x in ${old_multidirs}; do
377             case "$x" in
378               *soft-float* ) : ;;
379               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
380             esac
381           done
382         fi
383         if [ x$enable_relocatable = xno ]
384         then
385           old_multidirs="${multidirs}"
386           multidirs=""
387           for x in ${old_multidirs}; do
388             case "$x" in
389               *relocatable* ) : ;;
390               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
391             esac
392           done
393         fi
394         if [ x$enable_aix = xno ]
395         then
396           old_multidirs="${multidirs}"
397           multidirs=""
398           for x in ${old_multidirs}; do
399             case "$x" in
400               *aix* ) : ;;
401               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
402             esac
403           done
404         fi
405         ;;
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 ]
409         then
410           old_multidirs="${multidirs}"
411           multidirs=""
412           for x in ${old_multidirs}; do
413             case "$x" in
414               *endian* ) : ;;
415               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
416             esac
417           done
418         fi
419         if [ x$enable_softfloat = xno ]
420         then
421           old_multidirs="${multidirs}"
422           multidirs=""
423           for x in ${old_multidirs}; do
424             case "$x" in
425               *soft-float* ) : ;;
426               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
427             esac
428           done
429         fi
430         if [ x$enable_relocatable = xno ]
431         then
432           old_multidirs="${multidirs}"
433           multidirs=""
434           for x in ${old_multidirs}; do
435             case "$x" in
436               *relocatable* ) : ;;
437               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
438             esac
439           done
440         fi
441         if [ x$enable_aix = xno ]
442         then
443           old_multidirs="${multidirs}"
444           multidirs=""
445           for x in ${old_multidirs}; do
446             case "$x" in
447               *aix* ) : ;;
448               *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;;
449             esac
450           done
451         fi
452         ;;
453 *)
454         multidirs=
455         ;;
456 esac
457
458 # Add code to library's top level makefile to handle building the multilib
459 # subdirs.
460
461 cat > Multi.tem <<\EOF
462
463 # FIXME: There should be an @-sign in front of the `if'.
464 # Leave out until this is tested a bit more.
465 multi-do:
466         if [ -z "$(MULTIDIRS)" ]; then \
467           true; \
468         else \
469           rootpre=`pwd`/; export rootpre; \
470           srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
471           lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
472           compiler="$(CC)"; \
473           for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
474             dir=`echo $$i | sed -e 's/;.*$$//'`; \
475             if [ "$${dir}" = "." ]; then \
476               true; \
477             else \
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}" \
485                                 $(DO)); then \
486                   true; \
487                 else \
488                   exit 1; \
489                 fi; \
490               else true; \
491               fi; \
492             fi; \
493           done; \
494         fi
495
496 # FIXME: There should be an @-sign in front of the `if'.
497 # Leave out until this is tested a bit more.
498 multi-clean:
499         if [ -z "$(MULTIDIRS)" ]; then \
500           true; \
501         else \
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)); \
506               then true; \
507               else exit 1; \
508               fi; \
509             else true; \
510             fi; \
511           done; \
512         fi
513 EOF
514
515 cat ${Makefile} Multi.tem > Makefile.tem
516 rm -f ${Makefile} Multi.tem
517 mv Makefile.tem ${Makefile}
518
519 fi # ${ml_toplevel_p} = yes
520
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}"
525   fi
526   echo "with_multisubdir=${with_multisubdir}"
527 fi
528
529 if [ "${srcdir}" = "." ]; then
530   if [ "${with_target_subdir}" != "." ]; then
531     ml_srcdotdot="../"
532   else
533     ml_srcdotdot=""
534   fi
535 else
536   ml_srcdotdot=""
537 fi
538
539 if [ -z "${with_multisubdir}" ]; then
540   ml_subdir=
541   ml_builddotdot=
542   : # ml_srcdotdot= # already set
543 else
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}
549   else
550     : # ml_srcdotdot= # already set
551   fi
552 fi
553
554 if [ "${ml_toplevel_p}" = yes ]; then
555   ml_do='$(MAKE)'
556   ml_clean='$(MAKE)'
557 else
558   ml_do=true
559   ml_clean=true
560 fi
561
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
567 # of course.
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
572 # a leading '/'.
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.
576 #
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
582 # options).
583
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
592 rm -f ${Makefile}
593 mv Makefile.tem ${Makefile}
594
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.
599
600 if [ "${ml_toplevel_p}" = yes ]; then
601
602 # We must freshly configure each subdirectory.  This bit of code is
603 # actually partially stolen from the main configure script.  FIXME.
604
605 if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
606
607   if [ "${ml_verbose}" = --verbose ]; then
608     echo "Running configure in multilib subdirs ${multidirs}"
609     echo "pwd: `pwd`"
610   fi
611
612   ml_origdir=`pwd`
613   ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
614   # cd to top-level-build-dir/${with_target_subdir}
615   cd ..
616
617   for ml_dir in ${multidirs}; do
618
619     if [ "${ml_verbose}" = --verbose ]; then
620       echo "Running configure in multilib subdir ${ml_dir}"
621       echo "pwd: `pwd`"
622     fi
623
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
626
627     # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
628     dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
629
630     case ${srcdir} in
631     ".")
632       echo Building symlink tree in `pwd`/${ml_dir}/${ml_libdir}
633       if [ "${with_target_subdir}" != "." ]; then
634         ml_unsubdir="../"
635       else
636         ml_unsubdir=""
637       fi
638       (cd ${ml_dir}/${ml_libdir};
639        ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
640       ml_newsrcdir="."
641       ml_srcdiroption=
642       multisrctop=${dotdot}
643       ;;
644     *)
645       case "${srcdir}" in
646       /*) # absolute path
647         ml_newsrcdir=${srcdir}
648         ;;
649       *) # otherwise relative
650         ml_newsrcdir=${dotdot}${srcdir}
651         ;;
652       esac
653       ml_srcdiroption="-srcdir=${ml_newsrcdir}"
654       multisrctop=
655       ;;
656     esac
657
658     case "${progname}" in
659     /*)     ml_recprog=${progname} ;;
660     *)      ml_recprog=${dotdot}${progname} ;;
661     esac
662
663     # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
664     ML_POPDIR=`pwd`
665     cd ${ml_dir}/${ml_libdir}
666
667     if [ -f ${ml_newsrcdir}/configure ]; then
668       ml_recprog=${ml_newsrcdir}/configure
669     fi
670     if eval ${ml_config_shell} ${ml_recprog} \
671         --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
672         ${ml_arguments} ${ml_srcdiroption} ; then
673       true
674     else
675       exit 1
676     fi
677
678     cd ${ML_POPDIR}
679
680   done
681
682   cd ${ml_origdir}
683 fi
684
685 fi # ${ml_toplevel_p} = yes
686 fi # ${enable_multilib} = yes