OSDN Git Service

2002-04-23 Jeff Johnston <jjohnstn@redhat.com>
[pf3gnuchains/sourceware.git] / newlib / configure.host
1 # configure.host
2
3 # This shell script handles all host based configuration for newlib.
4 # It sets various shell variables based on the the host and the
5 # configuration options.  You can modify this shell script without
6 # needing to rerun autoconf.
7
8 # This shell script should be invoked as
9 #   . configure.host
10 # If it encounters an error, it will exit with a message.
11
12 # FIXME: This script is too complicated.  It does things in too many
13 # different ways.  This was taken from the old Cygnus configure script
14 # with only minor changes.  It should be cleaned up.
15
16 # FIXME: The general approach of picking and choosing which
17 # directories to configure, other than machine_dir and sys_dir, is
18 # potentially confusing.
19
20 # It uses the following shell variables:
21 #   host                The configuration host
22 #   host_cpu            The configuration host CPU
23 #   newlib_mb           --enable-newlib-mb ("yes", "no")
24 #   target_optspace     --enable-target-optspace ("yes", "no", "")
25
26 # It sets the following shell variables:
27 #   newlib_cflags       Special CFLAGS to use when building
28 #   machine_dir         Subdirectory of libc/machine to configure
29 #   sys_dir             Subdirectory of libc/sys to configure
30 #   have_sys_mach_dir   Is there a machine subdirectory in sys subdirectory
31 #   posix_dir           "posix" to build libc/posix, "" otherwise
32 #   signal_dir          "signal" to build libc/signal, "" otherwise
33 #   syscall_dir         "syscalls" to build libc/syscalls, "" otherwise
34 #   unix_dir            "unix" to build libc/unix, "" otherwise
35 #   use_libtool         flag: use libtool to build newlib?
36 #   aext                library extension - needed for libtool support
37 #   oext                object file extension - needed for libtool support
38 #   crt1                name of crt1 object if one is provided
39 #   crt1_dir            directory where crt1 object is found
40
41 newlib_cflags=
42 libm_machine_dir=
43 machine_dir=
44 sys_dir=
45 posix_dir=
46 signal_dir=signal
47 syscall_dir=
48 unix_dir=
49 mach_add_setjmp=
50 crt1=
51 crt1_dir=
52 use_libtool=no
53 have_sys_mach_dir=no
54 aext=a
55 oext=o
56
57 case "${target_optspace}:${host}" in
58   yes:*)
59     newlib_cflags="${newlib_cflags} -Os"
60     ;;
61   :m32r-* | :d10v-* | :d30v-* | :avr-*)
62     newlib_cflags="${newlib_cflags} -Os"
63     ;;
64   no:* | :*)
65     newlib_cflags="${newlib_cflags} -O2"
66     ;;
67 esac
68
69 # Get the source directories to use for the CPU type.
70 # machine_dir should supply CPU dependent routines, such as setjmp.
71 # newlib_cflags is passed to gcc when compiling.
72 # THIS TABLE IS ALPHA SORTED.  KEEP IT THAT WAY.
73
74 case "${host_cpu}" in
75   a29k)
76         machine_dir=a29k
77         ;;
78   arc)
79         machine_dir=
80         ;;
81   arm)
82         machine_dir=arm
83         ;;
84   avr*)
85         newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
86         ;;
87
88   d10v*)
89         machine_dir=d10v
90         ;;
91   d30v*)
92         machine_dir=d30v
93         ;;
94   fr30)
95         machine_dir=fr30
96         ;;
97   h8300)
98         machine_dir=h8300
99         ;;
100   h8500)
101         machine_dir=h8500
102         ;;
103   hppa*)
104         machine_dir=hppa
105         ;;
106   i960)
107         machine_dir=i960
108         ;;
109   i[3456]86)
110         # Don't use for these since they provide their own setjmp.
111         case ${host} in
112         *-*-go32 | *-*-sco* | *-*-cygwin*) 
113                 libm_machine_dir=i386
114                 machine_dir=i386
115                 ;;
116         *) 
117                 libm_machine_dir=i386
118                 machine_dir=i386
119                 mach_add_setjmp=true
120                 ;;
121         esac
122         ;;
123   ia64*)
124         ;;
125   m32r*)
126         machine_dir=m32r
127         ;;
128   m68*)
129         machine_dir=m68k
130         newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
131         ;;
132   m88k)
133         machine_dir=m88k
134         newlib_cflags="${newlib_cflags} -m88000"
135         ;;
136   m88110)
137         machine_dir=m88k
138         newlib_cflags="${newlib_cflags} -m88110"
139         ;;
140   mcore)
141         ;;
142   mips*)
143         machine_dir=mips
144         ;;
145   mmix)
146         ;;
147   mn10200)
148         machine_dir=mn10200
149         ;;
150   mn10300)
151         machine_dir=mn10300
152         ;;
153   or16)
154         ;;
155   or32)
156         ;;
157   powerpc*)
158         machine_dir=powerpc
159         ;;
160   sh | sh64)
161         machine_dir=sh
162         ;;
163   sparc*)
164         machine_dir=sparc
165         # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
166         newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
167         ;;
168   strongarm)
169         machine_dir=arm
170         ;;
171   xscale)
172         machine_dir=xscale
173         ;;
174   thumb)
175         machine_dir=arm
176         ;;
177   tic80*)
178         machine_dir=tic80
179         ;;
180   v70)
181         ;;
182   v810)
183         ;;
184   v850)
185         machine_dir=v850
186         newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
187         ;;
188   v850e)
189         machine_dir=v850
190         newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
191         ;;
192   v850ea)
193         machine_dir=v850
194         newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
195         ;;
196   w65*)
197         machine_dir=w65
198         ;;
199   xstormy16)
200         machine_dir=xstormy16
201         newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
202         ;;
203   z8k)
204         machine_dir=z8k
205         ;;
206   *)
207         echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
208         exit 1
209         ;;
210 esac
211
212 # Enable multibyte support if requested.
213
214 if [ "${newlib_mb}" = "yes" ] ; then
215         newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
216 fi
217
218 # Disable printf/scanf floating-point support if requested.
219
220 if [ "${newlib_io_float}" = "no" ] ; then
221         newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
222 fi
223
224 # Verify if shared newlib support is allowed and set appropriate variables
225 # We don't want to use libtool for platforms that we are not going to
226 # support shared libraries.  This is because it adds executable tests which
227 # we don't want for most embedded platforms.
228 case "${host}" in
229   i[3456]86-pc-linux-*)
230     use_libtool=yes
231     have_sys_mach_dir=yes
232     oext=lo
233     aext=la ;;
234   *) ;; #shared library not supported for ${host}
235 esac
236
237 # Get the source directories to use for the host.  unix_dir is set
238 # to unix to get some standard Unix routines.  posix_dir is set to get some
239 # standard Posix routines.  sys_dir should supply system dependent routines
240 # including crt0.
241 # THIS TABLE IS ALPHA SORTED.  KEEP IT THAT WAY.
242
243 case "${host}" in
244   *-*-cygwin*)
245         sys_dir=cygwin
246         posix_dir=posix
247         ;;
248   *-*-netware*)
249         signal_dir=
250         sys_dir=netware
251         ;;
252   *-*-rtems*)                   # generic RTEMS support
253         sys_dir=rtems
254         # RTEMS POSIX support is all inside RTEMS
255         ;;
256   a29k-*-*)
257         sys_dir=a29khif
258         signal_dir=
259         ;;
260   arc-*-*)
261         sys_dir=arc
262         ;;
263   arm-*-*)
264         sys_dir=arm 
265         ;;
266   d10v*)
267         sys_dir=d10v
268         ;;
269   d30v*)
270         sys_dir=
271         ;;
272   h8300-*-hms*)
273         sys_dir=h8300hms
274         ;;
275   h8300-*-elf*)
276         sys_dir=h8300hms
277         ;;
278   h8300-*-xray*)
279         sys_dir=h8300xray
280         ;;
281   h8500-*-hms*)
282         sys_dir=h8500hms
283         ;;
284   h8500-*-elf*)
285         sys_dir=h8500hms
286         ;;
287   i[3456]86-*-go32)
288         sys_dir=go32
289         ;;
290   i[3456]86-*-sco*)
291         sys_dir=sysvi386
292         unix_dir=unix
293         ;;
294   i[3456]86-pc-linux-*)
295         sys_dir=linux
296         unix_dir=unix
297         posix_dir=posix
298         crt1=crt1.o
299         crt1_dir=libc/sys/${sys_dir}    
300         gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
301         #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
302         newlib_cflags="${newlib_cflags} -Wall"
303         newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
304         newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
305         # --- Required when building a shared library ------------------------
306         newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
307         # --- The three lines below are optional ------------------------------
308         ##newlib_cflags="${newlib_cflags} -nostdinc"
309         ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
310         ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
311         ;;
312   m68k-sun-sunos*)
313         unix_dir=unix
314         ;;
315   m8*-bug-*)
316         sys_dir=m88kbug
317         ;;
318   mips*-dec-*)
319         sys_dir=decstation
320         ;;
321   mmix-knuth-mmixware)
322         sys_dir=mmixware
323         ;;
324   powerpcle-*-pe)
325         sys_dir=cygwin
326         posix_dir=posix
327         ;;
328   sh*-*)
329         sys_dir=sh
330         ;;
331   sparc-sun-sunos*)
332         sys_dir=sun4
333         unix_dir=unix
334         ;;
335   sparc64*)
336         sys_dir=sparc64
337         unix_dir=unix
338         ;;
339   strongarm-*-*)
340         sys_dir=arm 
341         ;;
342   xscale-*-*)
343         sys_dir=arm 
344         ;;
345   thumb-*-*)
346         sys_dir=arm 
347         ;;
348   tic80*)
349         sys_dir=tic80
350         ;;
351   v70-nec-*)
352         sys_dir=sysvnecv70
353         ;;
354   v810-*-*)
355         sys_dir=sysnec810
356         ;;
357   v850-*-*)
358         sys_dir=sysnecv850
359         ;;
360   v850e-*-*)
361         sys_dir=sysnecv850
362         ;;
363   v850ea-*-*)
364         sys_dir=sysnecv850
365         ;;
366   w65-*-*)
367         sys_dir=w65
368         ;;
369   z8k-*-coff)
370         sys_dir=z8ksim
371         ;;
372 esac
373
374 # Host specific flag settings -- usually for features that are not
375 # general enough or broad enough to be handled above.
376 # THIS TABLE IS ALPHA SORTED.  KEEP IT THAT WAY.
377
378 case "${host}" in
379   *-*-cygwin*)
380         newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL"
381 # CYGWIN provides its own malloc if --enable-malloc-debugging is set
382         if [ "x${malloc_debugging}" = "xyes" ] ; then
383           newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
384         fi
385         syscall_dir=syscalls
386         ;;
387 # RTEMS supplies its own versions of some routines:
388 #       malloc()            (reentrant version)
389 #       exit()              RTEMS has a "global" reent to flush
390 #       signal()/raise()    RTEMS has its own including pthread signals
391 #       _XYZ_r()            RTEMS has its own reentrant routines
392 #
393 #  NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
394   *-*-rtems*)
395         newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DWANT_PRINTF_LONG_LONG -DHAVE_FCNTL"
396         ;;
397 # VxWorks supplies its own version of malloc, and the newlib one
398 # doesn't work because VxWorks does not have sbrk.
399   *-wrs-vxworks*)
400         newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
401         ;;
402 # UDI doesn't have exec, so system() should fail the right way
403   a29k-amd-udi)
404         newlib_cflags="${newlib_cflags} -DNO_EXEC"
405         syscall_dir=syscalls
406         ;;
407   arc-*-*)
408         syscall_dir=syscalls
409         ;;
410   arm-*-pe)
411         syscall_dir=syscalls
412         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
413 # Don't use the debugging protocols just yet.
414         ;;
415   arm-*-*)
416         syscall_dir=syscalls
417         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
418 # Select which debug protocol is being used.
419 # ARM_RDP_MONITOR selects the Demon monitor.
420 # ARM_RDI_MONITOR selects the Angel monitor.
421 # If neither are defined, then hard coded defaults will be used
422 # to create the program's environment.
423 # See also thumb below.
424 #       newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
425         newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
426         ;;
427   avr*)
428         newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
429         ;;
430   d10v*)
431         newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
432         syscall_dir=syscalls
433         ;;
434   d30v*)
435         newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
436         syscall_dir=
437         ;;
438   fr30-*-*)
439         newlib_cflags="${newlib_cflags}"
440         syscall_dir=syscalls
441         ;;
442   h8300*-*-*)
443         syscall_dir=syscalls    
444         newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
445         ;;      
446   h8500-*-*)
447         syscall_dir=syscalls    
448         newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
449         ;;      
450   i[3456]86-*-sco*)
451         newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
452         ;;
453   i[3456]86-*-netware*)
454         newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
455         ;;
456   i[3456]86-*-go32)
457         newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL"
458         ;;
459   m32r-*-*)
460         # Pass -msdata=sdata so _impure_ptr goes in .sdata.
461         # We don't generate sda relocs however for upward compatibility.
462         # FIXME: This is necessary because the default multilib doesn't
463         # use --print-multi-lib.
464         newlib_cflags="${newlib_cflags} -msdata=sdata"
465         syscall_dir=syscalls
466         ;;
467   mcore-*-*)
468         newlib_cflags="${newlib_cflags}"
469         syscall_dir=syscalls
470         ;;
471   mmix-*)
472         syscall_dir=syscalls
473         # We need every symbol 32-bit aligned, so the invalid
474         # construct with attribute ((alias ("_ctype_b+127"))) breaks.
475         newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
476         ;;
477   mn10?00-*-*)
478         syscall_dir=syscalls
479         ;;
480   powerpc*-*-eabialtivec*)
481         newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
482         ;;
483   powerpc*-*-eabi* | \
484   powerpc*-*-elf* | \
485   powerpc*-*-linux* | \
486   powerpc*-*-rtem* | \
487   powerpc*-*-sysv* | \
488   powerpc*-*-solaris*)
489         newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
490         ;;
491   powerpcle-*-pe)
492         newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
493         syscall_dir=syscalls
494         ;;
495   sh*-*-*)
496         newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
497         syscall_dir=syscalls
498         ;;
499   sparc-sun-sunos*)
500         newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
501         ;;
502   sparc64-*-*)
503         newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
504         # This either belongs elsewhere or nowhere. But I need *something*,
505         # so for now it's here ...
506         case "${host_os}" in
507           aoutv8 | *32p)
508                 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
509           *)
510                 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
511         esac
512         ;;
513   strongarm-*-*)
514         syscall_dir=syscalls
515         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
516         newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
517         ;;
518   xscale-*-*)
519         syscall_dir=syscalls
520         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
521         newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
522         ;;
523   thumb-*-pe)
524         syscall_dir=syscalls
525         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
526 # Don't use the debugging protocols just yet.
527         ;;
528   thumb-*-*)
529         syscall_dir=syscalls
530         newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
531 # Select which debug protocol is being used.
532 # ARM_RDP_MONITOR selects the Demon monitor.
533 # ARM_RDI_MONITOR selects the Angel monitor.
534 # If neither are defined, then hard coded defaults will be used
535 # to create the program's environment.
536 # See also arm and strongarm above.
537 #       newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
538         newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
539         ;;
540   tic80*)
541         syscall_dir=syscalls
542         ;;
543   v850-*-*)
544         syscall_dir=syscalls
545         ;;
546   v850e-*-*)
547         syscall_dir=syscalls
548         ;;
549   v850ea-*-*)
550         syscall_dir=syscalls
551         ;;
552   w65-*-*)
553         syscall_dir=syscalls    
554         newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
555         ;;      
556   xstormy16-*-*)
557         newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
558         syscall_dir=syscalls
559         ;;
560   z8k-*-*)
561         syscall_dir=syscalls
562         ;;
563   *)
564         newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
565         syscall_dir=
566         ;;
567 esac