OSDN Git Service

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