* configure.in: Do build gcc and the target libraries for
[platform/upstream/binutils.git] / configure.in
1 #! /bin/bash
2 ##############################################################################
3
4 ## This file is a shell script fragment that supplies the information
5 ## necessary to tailor a template configure script into the configure
6 ## script appropriate for this directory.  For more information, check
7 ## any existing configure script.  
8
9 ## Be warned, there are two types of configure.in files.  There are those
10 ## used by Autoconf, which are macros which are expanded into a configure
11 ## script by autoconf.  The other sort, of which this is one, is executed
12 ## by Cygnus configure.  
13
14 ## For more information on these two systems, check out the documentation
15 ## for 'Autoconf' (autoconf.texi) and 'Configure' (configure.texi).  
16
17 #   Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
18 #
19 # This file is free software; you can redistribute it and/or modify it
20 # under the terms of the GNU General Public License as published by
21 # the Free Software Foundation; either version 2 of the License, or
22 # (at your option) any later version.
23 #
24 # This program is distributed in the hope that it will be useful, but
25 # WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27 # General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write to the Free Software
31 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32
33 ##############################################################################
34
35 ### To add a new directory to the tree, first choose whether it is a target
36 ### or a host dependent tool.  Then put it into the appropriate list
37 ### (library or tools, host or target), doing a dependency sort.  For
38 ### example, gdb requires that byacc (or bison) be built first, so it is in
39 ### the ${host_tools} list after byacc and bison.  
40
41
42 # these libraries are used by various programs built for the host environment
43 #
44 host_libs="mmalloc libiberty opcodes bfd readline gash tcl tk tclX"
45
46 if [ "${enable_gdbgui}" = "yes" ] ; then
47         host_libs="${host_libs} libgui"
48 fi
49
50 # these tools are built for the host environment
51 #
52 host_tools="texinfo byacc flex bison binutils ld gas gcc gdb make patch prms send-pr gprof gdbtest tgas etc expect dejagnu sim bash m4 autoconf ispell grep diff rcs cvs fileutils shellutils time textutils wdiff find emacs emacs19 uudecode hello tar gzip indent recode release sed utils guile perl apache inet gawk findutils"
53
54
55 # these libraries are built for the target environment, and are built after
56 # the host libraries and the host tools (which may be a cross compiler)
57 #
58 target_libs="target-libiberty target-libgloss target-newlib target-libio target-librx target-libstdc++ target-libg++"
59
60
61 # these tools are built using the target libs, and are intended to run only
62 # in the target environment
63 #
64 # note: any program that *uses* libraries that are in the "target_libs"
65 # list belongs in this list.  those programs are also very likely
66 # candidates for the "native_only" list which follows
67 #
68 target_tools="target-examples target-groff"
69
70 ################################################################################
71
72 ## These two lists are of directories that are to be removed from the
73 ## ${configdirs} list for either cross-compilations or for native-
74 ## compilations.  For example, it doesn't make that much sense to
75 ## cross-compile Emacs, nor is it terribly useful to compile target-libiberty in
76 ## a native environment.  
77
78 # directories to be built in the native environment only
79 #
80 # This must be a single line because of the way it is searched by grep in
81 # the code below.
82 native_only="autoconf cvs emacs emacs19 fileutils find gawk grep gzip hello indent ispell m4 rcs recode sed shellutils tar textutils gash uudecode wdiff gprof target-groff guile perl apache inet time bash prms"
83
84 # directories to be built in a cross environment only
85 #
86 cross_only="target-libiberty target-libgloss target-newlib"
87
88 ## All tools belong in one of the four categories, and are assigned above
89 ## We assign ${configdirs} this way to remove all embedded newlines.  This
90 ## is important because configure will choke if they ever get through.
91 ## ${configdirs} is directories we build using the host tools.
92 ## ${target_configdirs} is directories we build using the target tools.
93 #
94 configdirs=`echo ${host_libs} ${host_tools}`
95 target_configdirs=`echo ${target_libs} ${target_tools}`
96
97 ################################################################################
98
99 srctrigger=move-if-change
100 srcname="gnu development package"
101
102 # This gets set non-empty for some net releases of packages.
103 appdirs=""
104
105 # per-host:
106
107 # Work in distributions that contain no compiler tools, like Autoconf.
108 if [ -d ${srcdir}/config ]; then
109 case "${host}" in
110   m68k-hp-hpux*)          host_makefile_frag=config/mh-hp300 ;;
111   m68k-apollo-sysv*)      host_makefile_frag=config/mh-apollo68 ;;
112   m68k-apollo-bsd*)       host_makefile_frag=config/mh-a68bsd ;;
113   m68k-*-linux*)          host_makefile_frag=config/mh-linux ;;
114   m88k-dg-dgux*)          host_makefile_frag=config/mh-dgux ;;
115   m88k-harris-cxux*)      host_makefile_frag=config/mh-cxux ;;
116   m88k-motorola-sysv*)    host_makefile_frag=config/mh-delta88;;
117   mips*-dec-ultrix*)      host_makefile_frag=config/mh-decstation ;;
118   mips*-nec-sysv4*)       host_makefile_frag=config/mh-necv4 ;;
119   mips*-sgi-irix6*)       host_makefile_frag=config/mh-irix6 ;;
120   mips*-sgi-irix5*)       host_makefile_frag=config/mh-irix5 ;;
121   mips*-sgi-irix4*)       host_makefile_frag=config/mh-irix4 ;;
122   mips*-sgi-irix3*)       host_makefile_frag=config/mh-sysv ;;
123   mips*-*-sysv4*)         host_makefile_frag=config/mh-sysv4 ;;
124   mips*-*-sysv*)          host_makefile_frag=config/mh-riscos ;;
125   i[3456]86-*-dgux*)      host_makefile_frag=config/mh-dgux386 ;;
126   i[3456]86-ncr-sysv4.3)  host_makefile_frag=config/mh-ncrsvr43 ;;
127   i[3456]86-ncr-sysv4*)   host_makefile_frag=config/mh-ncr3000 ;;
128   i[3456]86-*-sco3.2v5*)  host_makefile_frag=config/mh-sysv ;;
129   i[3456]86-*-sco*)       host_makefile_frag=config/mh-sco ;;
130   i[3456]86-*-isc*)       host_makefile_frag=config/mh-sysv ;;
131   i[3456]86-*-linux*)     host_makefile_frag=config/mh-linux ;;
132   i[3456]86-*-solaris2*)  host_makefile_frag=config/mh-sysv4 ;;
133   i[3456]86-*-aix*)       host_makefile_frag=config/mh-aix386 ;;
134   i[3456]86-*-go32*)      host_makefile_frag=config/mh-go32 ;;
135   *-cygwin32*)            host_makefile_frag=config/mh-cygwin32 ;;
136   *-windows*)             host_makefile_frag=config/mh-windows ;;
137   vax-*-ultrix2*)         host_makefile_frag=config/mh-vaxult2 ;;
138   *-*-solaris2*)          host_makefile_frag=config/mh-solaris ;;
139   m68k-sun-sunos*)        host_makefile_frag=config/mh-sun3 ;;
140   *-hp-hpux[78]*)         host_makefile_frag=config/mh-hpux8 ;;
141   *-hp-hpux*)             host_makefile_frag=config/mh-hpux ;;
142   *-*-hiux*)              host_makefile_frag=config/mh-hpux ;;
143   rs6000-*-lynxos*)       host_makefile_frag=config/mh-lynxrs6k ;;
144   *-*-lynxos*)            host_makefile_frag=config/mh-lynxos ;;
145   *-*-sysv4*)             host_makefile_frag=config/mh-sysv4 ;;
146   *-*-sysv*)              host_makefile_frag=config/mh-sysv ;;
147 esac
148 fi
149
150 # If we aren't going to be using gcc, see if we can extract a definition
151 # of CC from the fragment.
152 if [ -z "${CC}" -a "${build}" = "${host}" ]; then
153   IFS="${IFS=   }"; save_ifs="$IFS"; IFS="${IFS}:"
154   found=
155   for dir in $PATH; do
156     test -z "$dir" && dir=.
157     if test -f $dir/gcc; then
158       found=yes
159       break
160     fi
161   done
162   IFS="$save_ifs"
163   if [ -z "${found}" -a -n "${host_makefile_frag}" -a -f "${srcdir}/${host_makefile_frag}" ]; then
164     xx=`sed -n -e 's/^[         ]*CC[   ]*=[    ]*\(.*\)$/\1/p' < ${srcdir}/${host_makefile_frag}`
165     if [ -n "${xx}" ] ; then
166       CC=$xx
167     fi
168   fi
169 fi
170
171 # We default to --with-shared on platforms where -fpic is meaningless.
172 # Well, we don't yet, but we will.
173 if false && [ "${host}" = "${target}" ] && [ x${enable_shared} = x ]; then
174   case "${target}" in
175     alpha-dec-osf*)     enable_shared=yes ;;
176     alpha-*-linux*)     enable_shared=yes ;;
177     mips-sgi-irix5*)    enable_shared=yes ;;
178     *)                  enable_shared=no ;;
179   esac
180 fi
181
182 case "${enable_shared}" in
183   yes) shared=yes ;;
184   no) shared=no ;;
185   "") shared=no ;;
186   *) shared=yes ;;
187 esac
188
189 if [ x${shared} = xyes ]; then
190   waugh=
191   case "${host}" in
192     hppa*)              waugh=config/mh-papic ;;
193     i[3456]86-*)        waugh=config/mh-x86pic ;;
194     sparc64-*)          waugh=config/mh-sparcpic ;;
195     *)                  waugh=config/mh-${host_cpu}pic ;;
196   esac
197   if [ -f ${srcdir}/${waugh} ]; then
198     if [ -n "${host_makefile_frag}" ] ; then
199       cat ${srcdir}/${host_makefile_frag} > mh-frag
200       cat ${srcdir}/${waugh} >> mh-frag
201       host_makefile_frag=mh-frag
202     else
203       host_makefile_frag=${waugh}
204     fi
205   fi
206 fi
207
208 # per-target:
209
210 case "${target}" in
211   v810*)                target_makefile_frag=config/mt-v810 ;;
212   i[3456]86-*-netware*) target_makefile_frag=config/mt-netware ;;
213   powerpc-*-netware*)   target_makefile_frag=config/mt-netware ;;
214 esac
215
216 skipdirs=
217 gasdir=gas
218 use_gnu_ld=
219 use_gnu_as=
220
221 # some tools are so dependent upon X11 that if we're not building with X, 
222 # it's not even worth trying to configure, much less build, that tool.
223
224 case ${with_x} in
225   yes | "")  # the default value for this tree is that X11 is available
226         ;;
227   no)
228         skipdirs="${skipdirs} tk gash"
229         ;;
230   *)
231         echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2
232         ;;
233 esac
234
235 # Some tools are only suitable for building in a "native" situation.
236 # Those are added when we have a host==target configuration.  For cross
237 # toolchains, we add some directories that should only be useful in a
238 # cross-compiler.
239
240 is_cross_compiler=
241
242 if [ x"${host}" = x"${target}" ] ; then
243         # when doing a native toolchain, don't build the targets
244         # that are in the 'cross only' list
245         skipdirs="${skipdirs} ${cross_only}"
246         is_cross_compiler=no
247         target_subdir=.
248 else
249         # similarly, don't build the targets in the 'native only' 
250         # list when building a cross compiler
251         skipdirs="${skipdirs} ${native_only}"
252         is_cross_compiler=yes
253         target_subdir=${target_alias}
254         if [ ! -d ${target_subdir} ] ; then
255             if mkdir ${target_subdir} ; then true
256             else
257                 echo "'*** could not make ${PWD=`pwd`}/${target_subdir}" 1>&2
258                 exit 1
259             fi
260         fi
261 fi      
262
263 copy_dirs=
264
265 # Handle --with-headers=XXX.  The contents of the named directory are
266 # copied to $(tooldir)/sys-include.
267 if [ x"${with_headers}" != x ]; then
268   if [ x${is_cross_compiler} = xno ]; then
269     echo 1>&2 '***' --with-headers is only supported when cross compiling
270     exit 1
271   fi
272   case "${exec_prefixoption}" in
273   "") x=${prefix} ;;
274   *) x=${exec_prefix} ;;
275   esac
276   copy_dirs="${copy_dirs} ${with_headers} $x/${target_alias}/sys-include"
277 fi
278
279 # Handle --with-libs=XXX.  Multiple directories are permitted.  The
280 # contents are copied to $(tooldir)/lib.
281 if [ x"${with_libs}" != x ]; then
282   if [ x${is_cross_compiler} = xno ]; then
283     echo 1>&2 '***' --with-libs is only supported when cross compiling
284     exit 1
285   fi
286   # Copy the libraries in reverse order, so that files in the first named
287   # library override files in subsequent libraries.
288   case "${exec_prefixoption}" in
289   "") x=${prefix} ;;
290   *) x=${exec_prefix} ;;
291   esac
292   for l in ${with_libs}; do
293     copy_dirs="$l $x/${target_alias}/lib ${copy_dirs}"
294   done
295 fi
296
297 # If both --with-headers and --with-libs are specified, default to
298 # --without-newlib.
299 if [ x"${with_headers}" != x ] && [ x"${with_libs}" != x ]; then
300   if [ x"${with_newlib}" = x ]; then
301     with_newlib=no
302   fi
303 fi
304
305 # Recognize --with-newlib/--without-newlib.
306 if [ x${with_newlib} = xno ]; then
307   skipdirs="${skipdirs} target-newlib"
308 elif [ x${with_newlib} = xyes ]; then
309   skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
310 fi
311
312 # Default to using --with-stabs for certain targets.
313 if [ x${with_stabs} = x ]; then
314   case "${target}" in
315   mips*-*-irix6*)
316     ;;
317   mips*-*-* | alpha*-*-osf* | i[3456]86*-*-sysv4* | i[3456]86*-*-unixware*)
318     with_stabs=yes;
319     withoptions="${withoptions} --with-stabs"
320     ;;
321   esac
322 fi
323
324 # Handle ${copy_dirs}
325 set fnord ${copy_dirs}
326 shift
327 while [ $# != 0 ]; do
328   if [ -f $2/COPIED ] && [ x"`cat $2/COPIED`" = x"$1" ]; then
329     :
330   else
331     echo Copying $1 to $2
332
333     # Use the install script to create the directory and all required
334     # parent directories.
335     if [ -d $2 ]; then
336       :
337     else
338       echo >config.temp
339       ${srcdir}/install.sh -c -m 644 config.temp $2/COPIED
340     fi
341
342     # Copy the directory, assuming we have tar.
343     # FIXME: Should we use B in the second tar?  Not all systems support it.
344     (cd $1; tar -cf - .) | (cd $2; tar -xpf -)
345
346     # It is the responsibility of the user to correctly adjust all
347     # symlinks.  If somebody can figure out how to handle them correctly
348     # here, feel free to add the code.
349
350     echo $1 > $2/COPIED
351   fi
352   shift; shift
353 done
354
355 # Configure extra directories which are host specific
356
357 case "${host}" in
358         i[3456]86-*-go32*)
359           configdirs="$configdirs dosrel" ;;
360         *-cygwin32*)
361           configdirs="$configdirs dosrel" ;;
362 esac
363
364 # Remove more programs from consideration, based on the host or 
365 # target this usually means that a port of the program doesn't
366 # exist yet.
367
368 noconfigdirs=""
369
370 case "${host}" in
371   i[3456]86-*-vsta)
372     noconfigdirs="tcl expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff guile perl apache inet"
373     ;;
374   i[3456]86-*-go32)
375     noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff guile perl apache inet"
376         ;;
377   *-*-cygwin32)
378      noconfigdirs="tk tcl expect dejagnu cvs autoconf bison send-pr gprof rcs guile perl texinfo apache inet"
379     ;;
380   *-*-windows*)
381 # This is only used to build WinGDB...
382      configdirs="bfd gdb libiberty opcodes readline sim"
383      target_configdirs=
384     ;;
385   ppc*-*-pe)
386      noconfigdirs="patch diff make tk tcl expect dejagnu cvs autoconf texinfo bison send-pr gprof rcs guile perl apache inet"
387     ;;
388 esac
389
390
391 case "${target}" in
392   *-*-netware)
393     noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-librx target-newlib target-libiberty target-libgloss"
394     ;;
395   *-*-vxworks*)
396     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
397     ;;
398   alpha-dec-osf*)
399     # ld works, but does not support shared libraries.  emacs doesn't
400     # work.  newlib is not 64 bit ready.  I'm not sure about fileutils or grep.
401     # gas doesn't generate exception information.
402     noconfigdirs="$noconfigdirs gas ld emacs fileutils grep target-newlib target-libgloss"
403     ;;
404   alpha*-*-*vms*)
405     noconfigdirs="$noconfigdirs gdb ld target-newlib target-libgloss"
406     ;;
407   alpha*-*-*)
408     # newlib is not 64 bit ready
409     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
410     ;;
411 # start-sanitize-arc
412   arc-*-*)
413     noconfigdirs="$noconfigdirs target-libgloss"
414     ;;
415 # end-sanitize-arc
416   arm-*-pe*)
417     noconfigdirs="$noconfigdirs target-libgloss"
418     ;;
419   arm-*-coff*)
420     noconfigdirs="$noconfigdirs target-libgloss"
421     ;;
422   arm-*-riscix*)
423     noconfigdirs="$noconfigdirs ld target-libgloss"
424     ;;
425 # start-sanitize-d10v
426   d10v-*-*)
427     noconfigdirs="$noconfigdirs target-librx target-libg++ target-libstdc++ target-libio target-libgloss"
428     ;;
429 # end-sanitize-d10v
430   h8300*-*-* | \
431   h8500-*-*)
432     noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss"
433     ;;
434   hppa*-*-*elf* | \
435   hppa*-*-lites*)
436     # Do configure ld/binutils/gas for this case.
437     ;;
438   hppa*-*-*)
439     # HP's C compiler doesn't handle Emacs correctly (but on BSD and Mach
440     # cc is gcc, and on any system a user should be able to link cc to
441     # whatever they want.  FIXME, emacs emacs19).
442     case "${CC}" in
443         "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;;
444         *) ;;
445     esac
446     noconfigdirs="$noconfigdirs ld shellutils"
447     ;;
448   i[3456]86-*-go32)
449     # but don't build gdb
450     noconfigdirs="$noconfigdirs gdb target-libg++ target-libstdc++ target-libio target-librx"
451     ;;
452   *-*-cygwin32)
453     target_configdirs="$target_configdirs target-winsup"
454     noconfigdirs="$noconfigdirs tcl tk expect target-libgloss"
455     # always build newlib.
456     skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
457
458     # Can't build gdb for cygwin32 if not native.
459     case "${host}" in
460       *-*-cygwin32) ;; # keep gdb
461       *) noconfigdirs="$noconfigdirs gdb"
462     esac
463     ;;    
464   i[3456]86-*-pe)
465     noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss"
466     ;;
467   i[3456]86-*-sco3.2v5*)
468     # The linker does not yet know about weak symbols in COFF,
469     # and is not configured to handle mixed ELF and COFF.
470     noconfigdirs="$noconfigdirs gprof ld target-libgloss"
471     ;;
472   i[3456]86-*-sco*)
473     noconfigdirs="$noconfigdirs gprof target-libgloss"
474     ;;
475   i[3456]86-*-solaris2*)
476     # The linker does static linking correctly, but the Solaris C library
477     # has bugs such that some important functions won't work when statically
478     # linked.  (See man pages for getpwuid, for example.)
479     noconfigdirs="$noconfigdirs ld target-libgloss"
480     ;;
481   i[3456]86-*-sysv4*)
482     # The SYSV4 C compiler doesn't handle Emacs correctly
483     case "${CC}" in
484         "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;;
485         *) ;;
486     esac
487     # but that's okay since emacs doesn't work anyway
488     noconfigdirs="$noconfigdirs emacs emacs19 target-libgloss"
489     ;;
490   mn10200-*-*)
491     noconfigdirs="$noconfigdirs gdb target-libgloss"
492     ;;
493   mn10300-*-*)
494     noconfigdirs="$noconfigdirs target-libgloss"
495     ;;
496   powerpc-*-aix*)
497     # copied from rs6000-*-* entry
498     noconfigdirs="$noconfigdirs gprof cvs target-libgloss"
499     # This is needed until gcc and ld are fixed to work together.
500     use_gnu_ld=no
501     ;;
502   powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe)
503     target_configdirs="$target_configdirs target-winsup"
504     noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss"
505     # always build newlib.
506     skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
507     ;;
508     # This is temporary until we can link against shared libraries
509   powerpcle-*-solaris*)
510     noconfigdirs="$noconfigdirs gdb sim make tcl tk expect"
511     ;;
512   rs6000-*-lynxos*)
513     # The CVS server code doesn't work on the RS/6000
514     # Newlib makes problems for libg++ in crosses.
515     noconfigdirs="$noconfigdirs target-newlib gprof cvs"
516     ;;
517   rs6000-*-aix*)
518     noconfigdirs="$noconfigdirs gprof"
519     # This is needed until gcc and ld are fixed to work together.
520     use_gnu_ld=no
521     ;;
522   rs6000-*-*)
523     noconfigdirs="$noconfigdirs gprof"
524     ;;
525   m68k-apollo-*)
526     noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss"
527     ;;
528   mips*-*-irix5*)
529     # The GNU linker does not support shared libraries.
530     # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work)
531     noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss"
532     ;;
533   mips*-*-irix6*)
534     # The GNU linker does not support shared libraries.
535     # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work)
536     noconfigdirs="$noconfigdirs binutils ld gas gprof emacs target-libgloss"
537     ;;
538   mips*-dec-bsd*)
539     noconfigdirs="$noconfigdirs gprof target-libgloss"
540     ;;
541   mips*-*-bsd*)
542     noconfigdirs="$noconfigdirs gprof target-libgloss"
543     ;;
544   mips*-*-*)
545     noconfigdirs="$noconfigdirs gprof"
546     ;;
547   romp-*-*)
548     noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss"
549     ;;
550   sh-*-*)
551     case "${host}" in
552       i[3456]86-*-vsta) ;; # don't add gprof back in
553       i[3456]86-*-go32) ;; # don't add gprof back in
554       *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;;
555     esac
556     noconfigdirs="$noconfigdirs target-libgloss"
557     ;;
558   sparc-*-sunos4*)
559     if [ x${is_cross_compiler} != xno ] ; then
560            noconfigdirs="$noconfigdirs gdb gdbtest target-newlib target-libgloss"
561     else
562            use_gnu_ld=no
563     fi
564     ;;
565   v810-*-*)
566     noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld target-libio target-libg++ target-libstdc++ opcodes target-libgloss"
567     ;;
568 # start-sanitize-v850
569   v850-*-*)
570     noconfigdirs="$noconfigdirs target-libgloss"
571     ;;
572 # end-sanitize-v850
573   vax-*-vms)
574     noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes target-libgloss"
575     ;;
576   vax-*-*)
577     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
578     ;;
579   *-*-lynxos*)
580     # Newlib makes problems for libg++ in crosses.
581     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
582     ;; 
583   *-*-macos* | \
584   *-*-mpw*)
585     # Macs want a resource compiler.
586     configdirs="$configdirs grez"
587     ;;    
588 esac
589
590 # targets that need a second pass
591 case "${target}" in
592   *-gm-magic*)
593     noconfigdirs="$noconfigdirs target-libgloss"
594     ;;
595 esac
596
597 # If we aren't building newlib, then don't build libgloss, since libgloss
598 # depends upon some newlib header files.
599 case "${noconfigdirs}" in
600   *target-libgloss*) ;;
601   *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;;
602 esac
603
604 # If we are building a Canadian Cross, discard tools that can not be built
605 # using a cross compiler.  FIXME: These tools should be fixed.
606 if [ "${build}" != "${host}" ]; then
607   noconfigdirs="$noconfigdirs tcl tk expect dejagnu"
608 fi
609
610 # Make sure we don't let GNU ld be added if we didn't want it.
611 if [ x$with_gnu_ld = xno ]; then
612   use_gnu_ld=no
613   noconfigdirs="$noconfigdirs ld"
614 fi
615
616 # Make sure we don't let GNU as be added if we didn't want it.
617 if [ x$with_gnu_as = xno ]; then
618   use_gnu_as=no
619   noconfigdirs="$noconfigdirs gas"
620 fi
621
622 # Remove the entries in $skipdirs and $noconfigdirs from $configdirs and
623 # $target_configdirs.
624 # If we have the source for $noconfigdirs entries, add them to $notsupp.
625
626 notsupp=""
627 for dir in . $skipdirs $noconfigdirs ; do
628   dirname=`echo $dir | sed -e s/target-//g`
629   if [ $dir != . ]  && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
630     configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
631     if [ -r $srcdir/$dirname/configure ] \
632         || [ -r $srcdir/$dirname/configure.in ]; then
633       if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
634         true
635       else
636         notsupp="$notsupp $dir"
637       fi
638     fi
639   fi
640   if [ $dir != . ]  && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
641     target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
642     if [ -r $srcdir/$dirname/configure ] \
643         || [ -r $srcdir/$dirname/configure.in ]; then
644       if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
645         true
646       else
647         notsupp="$notsupp $dir"
648       fi
649     fi
650   fi
651 done
652
653 # Sometimes the tools are distributed with libiberty but with no other
654 # libraries.  In that case, we don't want to build target-libiberty.
655 if [ -n "${target_configdirs}" ]; then
656   others=
657   for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
658     if [ "$i" != "libiberty" ]; then
659       if [ -r $srcdir/$i/configure ] || [ -r $srcdir/$i/configure.in ]; then
660         others=yes;
661         break;
662       fi
663     fi
664   done
665   if [ -z "${others}" ]; then
666     target_configdirs=
667   fi
668 fi
669
670 # Deconfigure all subdirectories, in case we are changing the
671 # configuration from one where a subdirectory is supported to one where it
672 # is not.
673 if [ -z "${norecursion}" -a -n "${configdirs}" ]; then
674   for i in `echo ${configdirs} | sed -e s/target-//g` ; do
675     rm -f $i/Makefile
676   done
677 fi
678 if [ -z "${norecursion}" -a -n "${target_configdirs}" ]; then
679   for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
680     rm -f ${target_subdir}/$i/Makefile
681   done
682 fi
683
684 # Produce a warning message for the subdirs we can't configure.
685 # This isn't especially interesting in the Cygnus tree, but in the individual
686 # FSF releases, it's important to let people know when their machine isn't
687 # supported by the one or two programs in a package.
688
689 if [ -n "${notsupp}" ] && [ -z "${norecursion}" ]; then
690   # If $appdirs is non-empty, at least one of those directories must still
691   # be configured, or we error out.  (E.g., if the gas release supports a
692   # specified target in some subdirs but not the gas subdir, we shouldn't
693   # pretend that all is well.)
694   if [ -n "$appdirs" ]; then
695     for dir in $appdirs ; do
696       if [ -r $dir/Makefile.in ]; then
697         if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
698           appdirs=""
699           break
700         fi
701         if echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
702           appdirs=""
703           break
704         fi
705       fi
706     done
707     if [ -n "$appdirs" ]; then
708       echo "*** This configuration is not supported by this package." 1>&2
709       exit 1
710     fi
711   fi
712   # Okay, some application will build, or we don't care to check.  Still
713   # notify of subdirs not getting built.
714   echo "*** This configuration is not supported in the following subdirectories:" 1>&2
715   echo "    ${notsupp}" 1>&2
716   echo "    (Any other directories should still work fine.)" 1>&2
717 fi
718
719 # Set with_gnu_as and with_gnu_ld as appropriate.
720 #
721 # This is done by determining whether or not the appropriate directory
722 # is available, and by checking whether or not specific configurations
723 # have requested that this magic not happen.
724
725 # The command line options always override the explicit settings in 
726 # configure.in, and the settings in configure.in override this magic.
727 #
728 # If the default for a toolchain is to use GNU as and ld, and you don't 
729 # want to do that, then you should use the --without-gnu-as and
730 # --without-gnu-ld options for the configure script.
731
732 if [ x${use_gnu_as} = x ] ; then
733   if [ x${with_gnu_as} != xno ] && echo " ${configdirs} " | grep " ${gasdir} " > /dev/null 2>&1 && [ -d ${srcdir}/${gasdir} ] ; then
734     with_gnu_as=yes
735     withoptions="$withoptions --with-gnu-as"
736   fi
737 fi
738
739 if [ x${use_gnu_ld} = x ] ; then
740   if [ x${with_gnu_ld} != xno ] && echo " ${configdirs} " | grep " ld " > /dev/null 2>&1 && [ -d ${srcdir}/ld ] ; then
741     with_gnu_ld=yes
742     withoptions="$withoptions --with-gnu-ld"
743   fi
744 fi
745
746 # If using newlib, add --with-newlib to the withoptions so that gcc/configure
747 # can detect this case.
748
749 if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then
750   with_newlib=yes
751   withoptions="$withoptions --with-newlib"
752 fi
753
754 if [ x${shared} = xyes ]; then
755   case "${target}" in
756     hppa*)              target_makefile_frag=config/mt-papic ;;
757     i[3456]86-*)                target_makefile_frag=config/mt-x86pic ;;
758     *)                  target_makefile_frag=config/mt-${target_cpu}pic ;;
759   esac
760 fi
761
762 # post-target:
763
764 # Make sure that the compiler is able to generate an executable.  If it
765 # can't, we are probably in trouble.  We don't care whether we can run the
766 # executable--we might be using a cross compiler--we only care whether it
767 # can be created.  At this point the main configure script has set CC.
768 echo "int main () { return 0; }" > conftest.c
769 ${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
770 if [ $? = 0 ] && [ -s conftest ]; then
771   :
772 else
773   echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
774   echo 1>&2 "*** You must set the environment variable CC to a working compiler."
775   rm -f conftest*
776   exit 1
777 fi
778 rm -f conftest*
779
780 # The Solaris /usr/ucb/cc compiler does not appear to work.
781 case "${host}" in
782   sparc-sun-solaris2*)
783       CCBASE="`echo ${CC-cc} | sed 's/ .*$//'`"
784       if [ "`/usr/bin/which $CCBASE`" = "/usr/ucb/cc" ] ; then
785           could_use=
786           [ -d /opt/SUNWspro/bin ] && could_use="/opt/SUNWspro/bin"
787           if [ -d /opt/cygnus/bin ] ; then
788               if [ "$could_use" = "" ] ; then
789                   could_use="/opt/cygnus/bin"
790               else
791                   could_use="$could_use or /opt/cygnus/bin"
792               fi
793           fi
794         if [ "$could_use" = "" ] ; then
795             echo "Warning: compilation may fail because you're using"
796             echo "/usr/ucb/cc.  You should change your PATH or CC "
797             echo "variable and rerun configure."
798         else
799             echo "Warning: compilation may fail because you're using"
800             echo "/usr/ucb/cc, when you should use the C compiler from"
801             echo "$could_use.  You should change your"
802             echo "PATH or CC variable and rerun configure."
803         fi
804       fi
805   ;;
806 esac
807
808 # If --enable-shared was set, we must set LD_LIBRARY_PATH so that the
809 # binutils tools will find libbfd.so.
810 if [ "${shared}" = "yes" ]; then
811   sed -e 's/^SET_LIB_PATH[      ]*=.*$/SET_LIB_PATH = $(REALLY_SET_LIB_PATH)/' \
812       Makefile > Makefile.tem
813   rm -f Makefile
814   mv -f Makefile.tem Makefile
815
816   case "${host}" in
817   *-*-hpux*)
818     sed -e 's/RPATH_ENVVAR[     ]*=.*$/RPATH_ENVVAR = SHLIB_PATH/' \
819         Makefile > Makefile.tem
820     rm -f Makefile
821     mv -f Makefile.tem Makefile
822     ;;
823   esac
824 fi
825
826 # Record target_configdirs and the configure arguments in Makefile.
827 target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
828 targargs=`echo "${arguments}" | \
829         sed -e 's/--norecursion//' \
830             -e 's/--cache[a-z-]*=[^     ]*//' \
831             -e 's/--ho[a-z-]*=[^        ]*//' \
832             -e 's/--ta[a-z-]*=[^        ]*//'`
833
834 # Passing a --with-cross-host argument lets the target libraries know
835 # whether they are being built with a cross-compiler or being built
836 # native.  However, it would be better to use other mechanisms to make the
837 # sorts of decisions they want to make on this basis.  Please consider
838 # this option to be deprecated.  FIXME.
839 if [ x${is_cross_compiler} = xyes ]; then
840   targargs="--with-cross-host=${host_alias} ${targargs}"
841 fi
842
843 targargs="--host=${target_alias} ${targargs}"
844 sed -e "s:^TARGET_CONFIGDIRS[   ]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
845     -e "s%^CONFIG_ARGUMENTS[    ]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
846     -e "s%^TARGET_SUBDIR[       ]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
847        Makefile > Makefile.tem
848 rm -f Makefile
849 mv -f Makefile.tem Makefile
850
851 #
852 # Local Variables:
853 # fill-column: 131
854 # End:
855 #