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