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.
8 # This shell script should be invoked as
10 # If it encounters an error, it will exit with a message.
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.
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.
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 # newlib_multithread --enable-newlib-multithread ("yes", "no", "yes")
26 # newlib_elix_level --enable-newlib-elix-level ("1","2","3","4") ("4")
28 # It sets the following shell variables:
29 # newlib_cflags Special CFLAGS to use when building
30 # machine_dir Subdirectory of libc/machine to configure
31 # sys_dir Subdirectory of libc/sys to configure
32 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
33 # posix_dir "posix" to build libc/posix, "" otherwise
34 # signal_dir "signal" to build libc/signal, "" otherwise
35 # stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
36 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
37 # unix_dir "unix" to build libc/unix, "" otherwise
38 # use_libtool flag: use libtool to build newlib?
39 # aext library extension - needed for libtool support
40 # oext object file extension - needed for libtool support
41 # crt1 name of crt1 object if one is provided
42 # crt1_dir directory where crt1 object is found
61 case "${target_optspace}:${host}" in
63 newlib_cflags="${newlib_cflags} -Os"
65 :m32r-* | :d10v-* | :d30v-* | :avr-*)
66 newlib_cflags="${newlib_cflags} -Os"
69 newlib_cflags="${newlib_cflags} -O2"
73 # Get the source directories to use for the CPU type.
74 # machine_dir should supply CPU dependent routines, such as setjmp.
75 # newlib_cflags is passed to gcc when compiling.
76 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
89 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
114 # Don't use for these since they provide their own setjmp.
116 *-*-sco* | *-*-cygwin*)
117 libm_machine_dir=i386
121 libm_machine_dir=i386
133 m68hc11|m6811|m68hc12|m6812)
135 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
141 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
145 newlib_cflags="${newlib_cflags} -m88000"
149 newlib_cflags="${newlib_cflags} -m88110"
176 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
177 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
197 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
201 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
205 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
214 machine_dir=xstormy16
215 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
221 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
226 # Disable thread support if requested.
228 if [ "${newlib_multithread}" = "no" ] ; then
229 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
232 # Enable multibyte support if requested or it is defaulted
235 if [ "x${newlib_mb}" = "x" ]; then
237 i[3456]86-pc-linux-*|*-*-cygwin*)
243 if [ "x${newlib_mb}" = "xyes" ] ; then
244 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
247 # Disable printf/scanf floating-point support if requested.
249 if [ "${newlib_io_float}" = "no" ] ; then
250 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
253 # Enable printf positional argument support if requested.
255 if [ "${newlib_io_pos_args}" = "yes" ] ; then
256 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
259 # Verify if shared newlib support is allowed and set appropriate variables
260 # We don't want to use libtool for platforms that we are not going to
261 # support shared libraries. This is because it adds executable tests which
262 # we don't want for most embedded platforms.
264 i[3456]86-pc-linux-*)
266 have_sys_mach_dir=yes
270 *) ;; #shared library not supported for ${host}
273 # Get the source directories to use for the host. unix_dir is set
274 # to unix to get some standard Unix routines. posix_dir is set to get some
275 # standard Posix routines. sys_dir should supply system dependent routines
277 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
288 *-*-rtems*) # generic RTEMS support
290 # RTEMS POSIX support is all inside RTEMS
330 i[3456]86-pc-linux-*)
335 crt1_dir=libc/sys/${sys_dir}
336 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
337 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
338 newlib_cflags="${newlib_cflags} -Wall"
339 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
340 newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
341 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS -DWANT_IO_LONG_DBL"
342 # --- Required when building a shared library ------------------------
343 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
344 # --- The three lines below are optional ------------------------------
345 ##newlib_cflags="${newlib_cflags} -nostdinc"
346 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
347 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
350 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
418 # Host specific flag settings -- usually for features that are not
419 # general enough or broad enough to be handled above.
420 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
424 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
427 # RTEMS supplies its own versions of some routines:
428 # malloc() (reentrant version)
429 # exit() RTEMS has a "global" reent to flush
430 # signal()/raise() RTEMS has its own including pthread signals
431 # _XYZ_r() RTEMS has its own reentrant routines
433 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
435 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"
437 # VxWorks supplies its own version of malloc, and the newlib one
438 # doesn't work because VxWorks does not have sbrk.
440 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
442 # UDI doesn't have exec, so system() should fail the right way
444 newlib_cflags="${newlib_cflags} -DNO_EXEC"
452 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
453 # Don't use the debugging protocols just yet.
457 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
458 # Select which debug protocol is being used.
459 # ARM_RDP_MONITOR selects the Demon monitor.
460 # ARM_RDI_MONITOR selects the Angel monitor.
461 # If neither are defined, then hard coded defaults will be used
462 # to create the program's environment.
463 # See also thumb below.
464 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
465 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
468 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
471 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
475 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
479 newlib_cflags="${newlib_cflags}"
484 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
488 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
491 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
493 i[3456]86-*-netware*)
494 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
497 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
498 # We don't generate sda relocs however for upward compatibility.
499 # FIXME: This is necessary because the default multilib doesn't
500 # use --print-multi-lib.
501 newlib_cflags="${newlib_cflags} -msdata=sdata"
504 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
505 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
508 newlib_cflags="${newlib_cflags}"
512 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG -DMISSING_SYSCALL_NAMES"
516 # We need every symbol 32-bit aligned, so the invalid
517 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
518 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
523 powerpc*-*-eabialtivec*)
524 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
527 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
531 powerpc*-*-linux* | \
535 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
538 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
542 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
546 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
549 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
550 # This either belongs elsewhere or nowhere. But I need *something*,
551 # so for now it's here ...
554 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
556 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
561 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
562 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
566 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
567 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
568 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
572 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
573 # Don't use the debugging protocols just yet.
577 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
578 # Select which debug protocol is being used.
579 # ARM_RDP_MONITOR selects the Demon monitor.
580 # ARM_RDI_MONITOR selects the Angel monitor.
581 # If neither are defined, then hard coded defaults will be used
582 # to create the program's environment.
583 # See also arm and strongarm above.
584 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
585 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
601 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG"
605 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
608 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
615 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"