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", "")
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
53 case "${target_optspace}:${host}" in
55 newlib_cflags="${newlib_cflags} -Os"
57 :m32r-* | :d10v-* | :d30v-* | :avr-*)
58 newlib_cflags="${newlib_cflags} -Os"
61 newlib_cflags="${newlib_cflags} -O2"
65 # Get the source directories to use for the CPU type.
66 # machine_dir should supply CPU dependent routines, such as setjmp.
67 # newlib_cflags is passed to gcc when compiling.
68 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
81 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
106 # Don't use for these since they provide their own setjmp.
108 *-*-go32 | *-*-sco* | *-*-cygwin*)
109 libm_machine_dir=i386
113 libm_machine_dir=i386
126 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
130 newlib_cflags="${newlib_cflags} -m88000"
134 newlib_cflags="${newlib_cflags} -m88110"
161 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
162 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
182 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
186 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
190 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
196 machine_dir=xstormy16
197 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
203 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
208 # Enable multibyte support if requested.
210 if [ "${newlib_mb}" = "yes" ] ; then
211 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
214 # Disable printf/scanf floating-point support if requested.
216 if [ "${newlib_io_float}" = "no" ] ; then
217 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
220 # Verify if shared newlib support is allowed and set appropriate variables
221 # We don't want to use libtool for platforms that we are not going to
222 # support shared libraries. This is because it adds executable tests which
223 # we don't want for most embedded platforms.
225 i[3456]86-pc-linux-*)
227 have_sys_mach_dir=yes
230 *) ;; #shared library not supported for ${host}
233 # Get the source directories to use for the host. unix_dir is set
234 # to unix to get some standard Unix routines. posix_dir is set to get some
235 # standard Posix routines. sys_dir should supply system dependent routines
237 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
248 *-*-rtems*) # generic RTEMS support
250 # RTEMS POSIX support is all inside RTEMS
290 i[3456]86-pc-linux-*)
294 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
295 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
296 newlib_cflags="${newlib_cflags} -Wall"
297 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
298 newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
299 # --- Required when building a shared library ------------------------
300 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
301 # --- The three lines below are optional ------------------------------
302 ##newlib_cflags="${newlib_cflags} -nostdinc"
303 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
304 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
368 # Host specific flag settings -- usually for features that are not
369 # general enough or broad enough to be handled above.
370 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
374 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL"
375 # CYGWIN provides its own malloc if --enable-malloc-debugging is set
376 if [ "x${malloc_debugging}" = "xyes" ] ; then
377 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
381 # RTEMS supplies its own versions of some routines:
382 # malloc() (reentrant version)
383 # exit() RTEMS has a "global" reent to flush
384 # signal()/raise() RTEMS has its own including pthread signals
385 # _XYZ_r() RTEMS has its own reentrant routines
387 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
389 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"
391 # VxWorks supplies its own version of malloc, and the newlib one
392 # doesn't work because VxWorks does not have sbrk.
394 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
396 # UDI doesn't have exec, so system() should fail the right way
398 newlib_cflags="${newlib_cflags} -DNO_EXEC"
406 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
407 # Don't use the debugging protocols just yet.
411 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
412 # Select which debug protocol is being used.
413 # ARM_RDP_MONITOR selects the Demon monitor.
414 # ARM_RDI_MONITOR selects the Angel monitor.
415 # If neither are defined, then hard coded defaults will be used
416 # to create the program's environment.
417 # See also thumb below.
418 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
419 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
422 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
425 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
429 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
433 newlib_cflags="${newlib_cflags}"
438 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
442 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
445 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
447 i[3456]86-*-netware*)
448 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
451 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL"
454 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
455 # We don't generate sda relocs however for upward compatibility.
456 # FIXME: This is necessary because the default multilib doesn't
457 # use --print-multi-lib.
458 newlib_cflags="${newlib_cflags} -msdata=sdata"
462 newlib_cflags="${newlib_cflags}"
467 # We need every symbol 32-bit aligned, so the invalid
468 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
469 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
476 powerpc*-*-linux* | \
480 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
483 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
487 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
491 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
494 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
495 # This either belongs elsewhere or nowhere. But I need *something*,
496 # so for now it's here ...
499 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
501 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
506 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
507 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
511 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
512 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
516 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
517 # Don't use the debugging protocols just yet.
521 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
522 # Select which debug protocol is being used.
523 # ARM_RDP_MONITOR selects the Demon monitor.
524 # ARM_RDI_MONITOR selects the Angel monitor.
525 # If neither are defined, then hard coded defaults will be used
526 # to create the program's environment.
527 # See also arm and strongarm above.
528 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
529 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
545 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
548 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
555 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"