xref: /openbsd-src/gnu/lib/libstdc++/config-ml.in (revision 03a78d155d6fff5698289342b62759a75b20d130)
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#     . ${with_multisrctop}../../config-ml.in
13#   else
14#     . ${with_multisrctop}../config-ml.in
15#   fi
16# else
17#   . ${srcdir}/../config-ml.in
18# fi
19#
20#
21# Things are complicated because 6 separate cases must be handled:
22# 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
23#
24# srcdir=. is special.  It must handle make programs that don't handle VPATH.
25# To implement this, a symlink tree is built for each library and for each
26# multilib subdir.
27#
28# The build tree is layed out as
29#
30# ./
31#   newlib
32#   m68020/
33#          newlib
34#          m68881/
35#                 newlib
36#
37# The nice feature about this arrangement is that inter-library references
38# in the build tree work without having to care where you are.  Note that
39# inter-library references also work in the source tree because symlink trees
40# are built when srcdir=.
41#
42# Unfortunately, trying to access the libraries in the build tree requires
43# the user to manually choose which library to use as GCC won't be able to
44# find the right one.  This is viewed as the lesser of two evils.
45#
46# Configure variables:
47# ${with_target_subdir} = "." for native, or ${target_alias} for cross.
48# Set by top level Makefile.
49# ${with_multisrctop} = how many levels of multilibs there are in the source
50# tree.  It exists to handle the case of configuring in the source tree:
51# ${srcdir} is not constant.
52# ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
53#
54# Makefile variables:
55# MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
56# (FIXME: note that this is different than ${with_multisrctop}.  Check out.).
57# MULTIBUILDTOP = 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# Autoconf incoming variables:
68# srcdir, host, ac_configure_args
69#
70# We *could* figure srcdir and host out, but we'd have to do work that
71# our caller has already done to figure them out and requiring these two
72# seems reasonable.
73# Note that `host' in this case is GCC's `target'.  Target libraries are
74# configured for a particular host.
75
76Makefile=${ac_file-Makefile}
77ml_config_shell=${CONFIG_SHELL-/bin/sh}
78ml_arguments="${ac_configure_args}"
79ml_realsrcdir=${srcdir}
80
81# Scan all the arguments and set all the ones we need.
82
83ml_verbose=--verbose
84for option in ${ml_arguments}
85do
86  case $option in
87  --*) ;;
88  -*) option=-$option ;;
89  esac
90
91  case $option in
92  --*=*)
93	optarg=`echo $option | sed -e 's/^[^=]*=//'`
94	;;
95  esac
96
97  case $option in
98  --disable-*)
99	enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
100	eval $enableopt=no
101	;;
102  --enable-*)
103	case "$option" in
104	*=*)	;;
105	*)	optarg=yes ;;
106	esac
107	enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
108	eval $enableopt="$optarg"
109	;;
110  --norecursion | --no*)
111	ml_norecursion=yes
112	;;
113  --silent | --sil* | --quiet | --q*)
114	ml_verbose=--silent
115	;;
116  --verbose | --v | --verb*)
117	ml_verbose=--verbose
118	;;
119  --with-*)
120	case "$option" in
121	*=*)	;;
122	*)	optarg=yes ;;
123	esac
124	withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
125	eval $withopt="$optarg"
126	;;
127  --without-*)
128	withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
129	eval $withopt=no
130	;;
131  esac
132done
133
134# Only do this if --enable-multilib.
135if [ "${enable_multilib}" = yes ]; then
136
137# Compute whether this is the library's top level directory
138# (ie: not a multilib subdirectory, and not a subdirectory like newlib/src).
139# ${with_multisubdir} tells us we're in the right branch, but we could be
140# in a subdir of that.
141# ??? The previous version could void this test by separating the process into
142# two files: one that only the library's toplevel configure.in ran (to
143# configure the multilib subdirs), and another that all configure.in's ran to
144# update the Makefile.  It seemed reasonable to collapse all multilib support
145# into one file, but it does leave us with having to perform this test.
146ml_toplevel_p=no
147if [ -z "${with_multisubdir}" ]; then
148  if [ "${srcdir}" = "." ]; then
149    # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
150    # ${with_target_subdir} = "." for native, otherwise target alias.
151    if [ "${with_target_subdir}" = "." ]; then
152      if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
153	ml_toplevel_p=yes
154      fi
155    else
156      if [ -f ${ml_realsrcdir}/../../config-ml.in ]; then
157	ml_toplevel_p=yes
158      fi
159    fi
160  else
161    # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
162    if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
163      ml_toplevel_p=yes
164    fi
165  fi
166fi
167
168# If this is the library's top level directory, set multidirs to the
169# multilib subdirs to support.  This lives at the top because we need
170# `multidirs' set right away.
171
172if [ "${ml_toplevel_p}" = yes ]; then
173
174multidirs=
175for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
176  dir=`echo $i | sed -e 's/;.*$//'`
177  if [ "${dir}" = "." ]; then
178    true
179  else
180    if [ -z "${multidirs}" ]; then
181      multidirs="${dir}"
182    else
183      multidirs="${multidirs} ${dir}"
184    fi
185  fi
186done
187
188# Target libraries are configured for the host they run on, so we check
189# $host here, not $target.
190
191case "${host}" in
192arc-*-elf*)
193	if [ x$enable_biendian != xyes ]
194	then
195	  old_multidirs=${multidirs}
196	  multidirs=""
197	  for x in ${old_multidirs}; do
198	    case "${x}" in
199	      *be*) : ;;
200	      *) multidirs="${multidirs} ${x}" ;;
201	    esac
202	  done
203	fi
204	;;
205arm-*-*)
206	if [ x"$enable_fpu" = xno ]
207	then
208	  old_multidirs=${multidirs}
209	  multidirs=""
210	  for x in ${old_multidirs}; do
211	    case "${x}" in
212	      *fpu*) : ;;
213	      *) multidirs="${multidirs} ${x}" ;;
214	    esac
215	  done
216	fi
217	if [ x"$enable_26bit" = xno ]
218	then
219	  old_multidirs=${multidirs}
220	  multidirs=""
221	  for x in ${old_multidirs}; do
222	    case "${x}" in
223	      *26bit*) : ;;
224	      *) multidirs="${multidirs} ${x}" ;;
225	    esac
226	  done
227	fi
228	if [ x"$enable_underscore" = xno ]
229	then
230	  old_multidirs=${multidirs}
231	  multidirs=""
232	  for x in ${old_multidirs}; do
233	    case "${x}" in
234	      *under*) : ;;
235	      *) multidirs="${multidirs} ${x}" ;;
236	    esac
237	  done
238	fi
239	if [ x"$enable_interwork" = xno ]
240	then
241	  old_multidirs=${multidirs}
242	  multidirs=""
243	  for x in ${old_multidirs}; do
244	    case "${x}" in
245	      *interwork*) : ;;
246	      *) multidirs="${multidirs} ${x}" ;;
247	    esac
248	  done
249	fi
250	if [ x$enable_biendian = xno ]
251	then
252	  old_multidirs="${multidirs}"
253	  multidirs=""
254	  for x in ${old_multidirs}; do
255	    case "$x" in
256	      *le* ) : ;;
257	      *be* ) : ;;
258	      *) multidirs="${multidirs} ${x}" ;;
259	    esac
260	  done
261	fi
262	if [ x"$enable_nofmult" = xno ]
263	then
264	  old_multidirs="${multidirs}"
265	  multidirs=""
266	  for x in ${old_multidirs}; do
267	    case "$x" in
268	      *nofmult* ) : ;;
269	      *) multidirs="${multidirs} ${x}" ;;
270	    esac
271	  done
272	fi
273	;;
274m68*-*-*)
275	if [ x$enable_softfloat = xno ]
276	then
277	  old_multidirs="${multidirs}"
278	  multidirs=""
279	  for x in ${old_multidirs}; do
280	    case "$x" in
281	      *soft-float* ) : ;;
282	      *) multidirs="${multidirs} ${x}" ;;
283	    esac
284	  done
285	fi
286	if [ x$enable_m68881 = xno ]
287	then
288	  old_multidirs="${multidirs}"
289	  multidirs=""
290	  for x in ${old_multidirs}; do
291	    case "$x" in
292	      *m68881* ) : ;;
293	      *) multidirs="${multidirs} ${x}" ;;
294	    esac
295	  done
296	fi
297	if [ x$enable_m68000 = xno ]
298	then
299	  old_multidirs="${multidirs}"
300	  multidirs=""
301	  for x in ${old_multidirs}; do
302	    case "$x" in
303	      *m68000* ) : ;;
304	      *) multidirs="${multidirs} ${x}" ;;
305	    esac
306	  done
307	fi
308	if [ x$enable_m68020 = xno ]
309	then
310	  old_multidirs="${multidirs}"
311	  multidirs=""
312	  for x in ${old_multidirs}; do
313	    case "$x" in
314	      *m68020* ) : ;;
315	      *) multidirs="${multidirs} ${x}" ;;
316	    esac
317	  done
318	fi
319	;;
320mips*-*-*)
321	if [ x$enable_single_float = xno ]
322	then
323	  old_multidirs="${multidirs}"
324	  multidirs=""
325	  for x in ${old_multidirs}; do
326	    case "$x" in
327	      *single* ) : ;;
328	      *) multidirs="${multidirs} ${x}" ;;
329	    esac
330	  done
331	fi
332	if [ x$enable_biendian = xno ]
333	then
334	  old_multidirs="${multidirs}"
335	  multidirs=""
336	  for x in ${old_multidirs}; do
337	    case "$x" in
338	      *el* ) : ;;
339	      *eb* ) : ;;
340	      *) multidirs="${multidirs} ${x}" ;;
341	    esac
342	  done
343	fi
344	if [ x$enable_softfloat = xno ]
345	then
346	  old_multidirs="${multidirs}"
347	  multidirs=""
348	  for x in ${old_multidirs}; do
349	    case "$x" in
350	      *soft-float* ) : ;;
351	      *) multidirs="${multidirs} ${x}" ;;
352	    esac
353	  done
354	fi
355	case " $multidirs " in
356	*" mabi=64 "*)
357	  # We will not be able to create libraries with -mabi=64 if
358	  # we cannot even link a trivial program.  It usually
359	  # indicates the 64bit libraries are missing.
360	  if echo 'main() {}' > conftest.c &&
361	     ${CC-gcc} -mabi=64 conftest.c -o conftest; then
362	    :
363	  else
364	    echo Could not link program with -mabi=64, disabling it.
365	    old_multidirs="${multidirs}"
366	    multidirs=""
367	    for x in ${old_multidirs}; do
368	      case "$x" in
369	      *mabi=64* ) : ;;
370	      *) multidirs="${multidirs} ${x}" ;;
371	      esac
372	    done
373	  fi
374	  rm -f conftest.c conftest
375	  ;;
376	esac
377	;;
378powerpc*-*-* | rs6000*-*-*)
379	if [ x$enable_aix64 = xno ]
380	then
381	  old_multidirs="${multidirs}"
382	  multidirs=""
383	  for x in ${old_multidirs}; do
384	    case "$x" in
385	      *ppc64* ) : ;;
386	      *) multidirs="${multidirs} ${x}" ;;
387	    esac
388	  done
389	fi
390	if [ x$enable_pthread = xno ]
391	then
392	  old_multidirs="${multidirs}"
393	  multidirs=""
394	  for x in ${old_multidirs}; do
395	    case "$x" in
396	      *pthread* ) : ;;
397	      *) multidirs="${multidirs} ${x}" ;;
398	    esac
399	  done
400	fi
401	if [ x$enable_softfloat = xno ]
402	then
403	  old_multidirs="${multidirs}"
404	  multidirs=""
405	  for x in ${old_multidirs}; do
406	    case "$x" in
407	      *soft-float* ) : ;;
408	      *) multidirs="${multidirs} ${x}" ;;
409	    esac
410	  done
411	fi
412	if [ x$enable_powercpu = xno ]
413	then
414	  old_multidirs="${multidirs}"
415	  multidirs=""
416	  for x in ${old_multidirs}; do
417	    case "$x" in
418	      power | */power | */power/* ) : ;;
419	      *) multidirs="${multidirs} ${x}" ;;
420	    esac
421	  done
422	fi
423	if [ x$enable_powerpccpu = xno ]
424	then
425	  old_multidirs="${multidirs}"
426	  multidirs=""
427	  for x in ${old_multidirs}; do
428	    case "$x" in
429	      *powerpc* ) : ;;
430	      *) multidirs="${multidirs} ${x}" ;;
431	    esac
432	  done
433	fi
434	if [ x$enable_powerpcos = xno ]
435	then
436	  old_multidirs="${multidirs}"
437	  multidirs=""
438	  for x in ${old_multidirs}; do
439	    case "$x" in
440	      *mcall-linux* | *mcall-solaris* ) : ;;
441	      *) multidirs="${multidirs} ${x}" ;;
442	    esac
443	  done
444	fi
445	if [ x$enable_biendian = xno ]
446	then
447	  old_multidirs="${multidirs}"
448	  multidirs=""
449	  for x in ${old_multidirs}; do
450	    case "$x" in
451	      *mlittle* | *mbig* ) : ;;
452	      *) multidirs="${multidirs} ${x}" ;;
453	    esac
454	  done
455	fi
456	if [ x$enable_sysv = xno ]
457	then
458	  old_multidirs="${multidirs}"
459	  multidirs=""
460	  for x in ${old_multidirs}; do
461	    case "$x" in
462	      *mcall-sysv* ) : ;;
463	      *) multidirs="${multidirs} ${x}" ;;
464	    esac
465	  done
466	fi
467	if [ x$enable_aix = xno ]
468	then
469	  old_multidirs="${multidirs}"
470	  multidirs=""
471	  for x in ${old_multidirs}; do
472	    case "$x" in
473	      *mcall-aix* ) : ;;
474	      *) multidirs="${multidirs} ${x}" ;;
475	    esac
476	  done
477	fi
478	;;
479sparc*-*-*)
480	case " $multidirs " in
481	*" m64 "*)
482	  # We will not be able to create libraries with -m64 if
483	  # we cannot even link a trivial program.  It usually
484	  # indicates the 64bit libraries are missing.
485	  if echo 'main() {}' > conftest.c &&
486	     ${CC-gcc} -m64 conftest.c -o conftest; then
487	    :
488	  else
489	    echo Could not link program with -m64, disabling it.
490	    old_multidirs="${multidirs}"
491	    multidirs=""
492	    for x in ${old_multidirs}; do
493	      case "$x" in
494	      *m64* ) : ;;
495	      *) multidirs="${multidirs} ${x}" ;;
496	      esac
497	    done
498	  fi
499	  rm -f conftest.c conftest
500	  ;;
501	esac
502	;;
503esac
504
505# Remove extraneous blanks from multidirs.
506# Tests like `if [ -n "$multidirs" ]' require it.
507multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
508
509# Add code to library's top level makefile to handle building the multilib
510# subdirs.
511
512cat > Multi.tem <<\EOF
513
514PWD_COMMAND=$${PWDCMD-pwd}
515
516# FIXME: There should be an @-sign in front of the `if'.
517# Leave out until this is tested a bit more.
518multi-do:
519	if [ -z "$(MULTIDIRS)" ]; then \
520	  true; \
521	else \
522	  rootpre=`${PWD_COMMAND}`/; export rootpre; \
523	  srcrootpre=`cd $(srcdir); ${PWD_COMMAND}`/; export srcrootpre; \
524	  lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
525	  compiler="$(CC)"; \
526	  for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
527	    dir=`echo $$i | sed -e 's/;.*$$//'`; \
528	    if [ "$${dir}" = "." ]; then \
529	      true; \
530	    else \
531	      if [ -d ../$${dir}/$${lib} ]; then \
532		flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
533		if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
534				CFLAGS="$(CFLAGS) $${flags}" \
535				prefix="$(prefix)" \
536				exec_prefix="$(exec_prefix)" \
537				GCJFLAGS="$(GCJFLAGS) $${flags}" \
538				CXXFLAGS="$(CXXFLAGS) $${flags}" \
539				LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
540				LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
541				LDFLAGS="$(LDFLAGS) $${flags}" \
542				DESTDIR="$(DESTDIR)" \
543				INSTALL="$(INSTALL)" \
544				INSTALL_DATA="$(INSTALL_DATA)" \
545				INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
546				INSTALL_SCRIPT="$(INSTALL_SCRIPT)" \
547				$(DO)); then \
548		  true; \
549		else \
550		  exit 1; \
551		fi; \
552	      else true; \
553	      fi; \
554	    fi; \
555	  done; \
556	fi
557
558# FIXME: There should be an @-sign in front of the `if'.
559# Leave out until this is tested a bit more.
560multi-clean:
561	if [ -z "$(MULTIDIRS)" ]; then \
562	  true; \
563	else \
564	  lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
565	  for dir in Makefile $(MULTIDIRS); do \
566	    if [ -f ../$${dir}/$${lib}/Makefile ]; then \
567	      if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
568	      then true; \
569	      else exit 1; \
570	      fi; \
571	    else true; \
572	    fi; \
573	  done; \
574	fi
575EOF
576
577cat ${Makefile} Multi.tem > Makefile.tem
578rm -f ${Makefile} Multi.tem
579mv Makefile.tem ${Makefile}
580
581fi # ${ml_toplevel_p} = yes
582
583if [ "${ml_verbose}" = --verbose ]; then
584  echo "Adding multilib support to Makefile in ${ml_realsrcdir}"
585  if [ "${ml_toplevel_p}" = yes ]; then
586    echo "multidirs=${multidirs}"
587  fi
588  echo "with_multisubdir=${with_multisubdir}"
589fi
590
591if [ "${srcdir}" = "." ]; then
592  if [ "${with_target_subdir}" != "." ]; then
593    ml_srcdotdot="../"
594  else
595    ml_srcdotdot=""
596  fi
597else
598  ml_srcdotdot=""
599fi
600
601if [ -z "${with_multisubdir}" ]; then
602  ml_subdir=
603  ml_builddotdot=
604  : # ml_srcdotdot= # already set
605else
606  ml_subdir="/${with_multisubdir}"
607  # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
608  ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
609  if [ "$srcdir" = "." ]; then
610    ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
611  else
612    : # ml_srcdotdot= # already set
613  fi
614fi
615
616if [ "${ml_toplevel_p}" = yes ]; then
617  ml_do='$(MAKE)'
618  ml_clean='$(MAKE)'
619else
620  ml_do=true
621  ml_clean=true
622fi
623
624# TOP is used by newlib and should not be used elsewhere for this purpose.
625# MULTI{SRC,BUILD}TOP are the proper ones to use.  MULTISRCTOP is empty
626# when srcdir != builddir.  MULTIBUILDTOP is always some number of ../'s.
627# FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
628# delete TOP.  Newlib may wish to continue to use TOP for its own purposes
629# of course.
630# MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
631# and lists the subdirectories to recurse into.
632# MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
633# (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
634# a leading '/'.
635# MULTIDO is used for targets like all, install, and check where
636# $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
637# MULTICLEAN is used for the *clean targets.
638#
639# ??? It is possible to merge MULTIDO and MULTICLEAN into one.  They are
640# currently kept separate because we don't want the *clean targets to require
641# the existence of the compiler (which MULTIDO currently requires) and
642# therefore we'd have to record the directory options as well as names
643# (currently we just record the names and use --print-multi-lib to get the
644# options).
645
646sed -e "s:^TOP[ 	]*=[ 	]*\([./]*\)[ 	]*$:TOP = ${ml_builddotdot}\1:" \
647    -e "s:^MULTISRCTOP[ 	]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
648    -e "s:^MULTIBUILDTOP[ 	]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
649    -e "s:^MULTIDIRS[ 	]*=.*$:MULTIDIRS = ${multidirs}:" \
650    -e "s:^MULTISUBDIR[ 	]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
651    -e "s:^MULTIDO[ 	]*=.*$:MULTIDO = $ml_do:" \
652    -e "s:^MULTICLEAN[ 	]*=.*$:MULTICLEAN = $ml_clean:" \
653	${Makefile} > Makefile.tem
654rm -f ${Makefile}
655mv Makefile.tem ${Makefile}
656
657# If this is the library's top level, configure each multilib subdir.
658# This is done at the end because this is the loop that runs configure
659# in each multilib subdir and it seemed reasonable to finish updating the
660# Makefile before going on to configure the subdirs.
661
662if [ "${ml_toplevel_p}" = yes ]; then
663
664# We must freshly configure each subdirectory.  This bit of code is
665# actually partially stolen from the main configure script.  FIXME.
666
667if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
668
669  if [ "${ml_verbose}" = --verbose ]; then
670    echo "Running configure in multilib subdirs ${multidirs}"
671    echo "pwd: `${PWDCMD-pwd}`"
672  fi
673
674  ml_origdir=`${PWDCMD-pwd}`
675  ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
676  # cd to top-level-build-dir/${with_target_subdir}
677  cd ..
678
679  for ml_dir in ${multidirs}; do
680
681    if [ "${ml_verbose}" = --verbose ]; then
682      echo "Running configure in multilib subdir ${ml_dir}"
683      echo "pwd: `${PWDCMD-pwd}`"
684    fi
685
686    if [ -d ${ml_dir} ]; then true; else
687      # ``mkdir -p ${ml_dir}'' See also mkinstalldirs.
688      pathcomp=""
689      for d in `echo ":${ml_dir}" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; do
690        pathcomp="$pathcomp$d"
691        case "$pathcomp" in
692          -* ) pathcomp=./$pathcomp ;;
693        esac
694        if test ! -d "$pathcomp"; then
695           echo "mkdir $pathcomp" 1>&2
696           mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
697        fi
698        if test ! -d "$pathcomp"; then
699	   exit $lasterr
700        fi
701        pathcomp="$pathcomp/"
702      done
703    fi
704    if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
705
706    # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
707    dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
708
709    case ${srcdir} in
710    ".")
711      echo Building symlink tree in `${PWDCMD-pwd}`/${ml_dir}/${ml_libdir}
712      if [ "${with_target_subdir}" != "." ]; then
713	ml_unsubdir="../"
714      else
715	ml_unsubdir=""
716      fi
717      (cd ${ml_dir}/${ml_libdir};
718       ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
719      if [ -f ${ml_dir}/${ml_libdir}/Makefile ]; then
720	if [ x"${MAKE}" = x ]; then
721	  (cd ${ml_dir}/${ml_libdir}; make distclean)
722	else
723	  (cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
724	fi
725      fi
726      ml_newsrcdir="."
727      ml_srcdiroption=
728      multisrctop=${dotdot}
729      ;;
730    *)
731      case "${srcdir}" in
732      /* | [A-Za-z]:[\\/]* ) # absolute path
733        ml_newsrcdir=${srcdir}
734        ;;
735      *) # otherwise relative
736        ml_newsrcdir=${dotdot}${srcdir}
737        ;;
738      esac
739      ml_srcdiroption="-srcdir=${ml_newsrcdir}"
740      multisrctop=
741      ;;
742    esac
743
744    case "${progname}" in
745    /* | [A-Za-z]:[\\/]* )     ml_recprog=${progname} ;;
746    *)      ml_recprog=${dotdot}${progname} ;;
747    esac
748
749    # FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
750    ML_POPDIR=`${PWDCMD-pwd}`
751    cd ${ml_dir}/${ml_libdir}
752
753    if [ -f ${ml_newsrcdir}/configure ]; then
754      ml_recprog="${ml_newsrcdir}/configure --cache-file=../config.cache"
755    fi
756
757    # find compiler flag corresponding to ${ml_dir}
758    for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
759      dir=`echo $i | sed -e 's/;.*$//'`
760      if [ "${dir}" = "${ml_dir}" ]; then
761        flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
762        break
763      fi
764    done
765    ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" GCJ="${GCJ_}$flags"'
766
767    if [ "${with_target_subdir}" = "." ]; then
768	CC_=$CC' '
769	CXX_=$CXX' '
770	GCJ_=$GCJ' '
771    else
772	# Create a regular expression that matches any string as long
773	# as ML_POPDIR.
774	popdir_rx=`echo ${ML_POPDIR} | sed 's,.,.,g'`
775	CC_=
776	for arg in ${CC}; do
777	  case $arg in
778	  -[BIL]"${ML_POPDIR}"/*)
779	    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"`' ' ;;
780	  "${ML_POPDIR}"/*)
781	    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"`' ' ;;
782	  *)
783	    CC_="${CC_}${arg} " ;;
784	  esac
785	done
786
787	CXX_=
788	for arg in ${CXX}; do
789	  case $arg in
790	  -[BIL]"${ML_POPDIR}"/*)
791	    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"`' ' ;;
792	  "${ML_POPDIR}"/*)
793	    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"`' ' ;;
794	  *)
795	    CXX_="${CXX_}${arg} " ;;
796	  esac
797	done
798
799	GCJ_=
800	for arg in ${GCJ}; do
801	  case $arg in
802	  -[BIL]"${ML_POPDIR}"/*)
803	    GCJ_="${GCJ_}"`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"`' ' ;;
804	  "${ML_POPDIR}"/*)
805	    GCJ_="${GCJ_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
806	  *)
807	    GCJ_="${GCJ_}${arg} " ;;
808	  esac
809	done
810
811	if test "x${LD_LIBRARY_PATH+set}" = xset; then
812	  LD_LIBRARY_PATH_=
813	  for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do
814	    case "$arg" in
815	    "${ML_POPDIR}"/*)
816	      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"`
817	      ;;
818	    esac
819	    if test "x$LD_LIBRARY_PATH_" != x; then
820	      LD_LIBRARY_PATH_=$LD_LIBRARY_PATH_:$arg
821	    else
822	      LD_LIBRARY_PATH_=$arg
823	    fi
824          done
825	  ml_config_env="$ml_config_env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_"
826	fi
827
828	if test "x${SHLIB_PATH+set}" = xset; then
829	  SHLIB_PATH_=
830	  for arg in `echo "$SHLIB_PATH" | tr ':' ' '`; do
831	    case "$arg" in
832	    "${ML_POPDIR}"/*)
833	      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"`
834	      ;;
835	    esac
836	    if test "x$SHLIB_PATH_" != x; then
837	      SHLIB_PATH_=$SHLIB_PATH_:$arg
838	    else
839	      SHLIB_PATH_=$arg
840	    fi
841          done
842	  ml_config_env="$ml_config_env SHLIB_PATH=$SHLIB_PATH_"
843	fi
844    fi
845
846    if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
847	--with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
848	${ml_arguments} ${ml_srcdiroption} ; then
849      true
850    else
851      exit 1
852    fi
853
854    cd ${ML_POPDIR}
855
856  done
857
858  cd ${ml_origdir}
859fi
860
861fi # ${ml_toplevel_p} = yes
862fi # ${enable_multilib} = yes
863