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"
119 # Don't use for these since they provide their own setjmp.
121 *-*-sco* | *-*-cygwin*)
122 libm_machine_dir=i386
126 libm_machine_dir=i386
141 m68hc11|m6811|m68hc12|m6812)
143 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
149 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
153 newlib_cflags="${newlib_cflags} -m88000"
157 newlib_cflags="${newlib_cflags} -m88110"
184 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
185 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
205 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
209 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
215 machine_dir=xstormy16
216 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
222 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
227 # Disable thread support if requested.
229 if [ "${newlib_multithread}" = "no" ] ; then
230 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
233 # Disable syscall support if requested.
235 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
236 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
239 # Enable multibyte support if requested or it is defaulted
242 if [ "x${newlib_mb}" = "x" ]; then
244 i[34567]86-pc-linux-*|*-*-cygwin*)
250 if [ "x${newlib_mb}" = "xyes" ] ; then
251 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
254 # Disable printf/scanf floating-point support if requested.
256 if [ "${newlib_io_float}" = "no" ] ; then
257 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
260 # Enable printf positional argument support if requested.
262 if [ "${newlib_io_pos_args}" = "yes" ] ; then
263 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
266 # Verify if shared newlib support is allowed and set appropriate variables
267 # We don't want to use libtool for platforms that we are not going to
268 # support shared libraries. This is because it adds executable tests which
269 # we don't want for most embedded platforms.
271 i[34567]86-pc-linux-*)
273 have_sys_mach_dir=yes
277 *) ;; #shared library not supported for ${host}
280 # Get the source directories to use for the host. unix_dir is set
281 # to unix to get some standard Unix routines. posix_dir is set to get some
282 # standard Posix routines. sys_dir should supply system dependent routines
284 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
295 *-*-rtems*) # generic RTEMS support
297 # RTEMS POSIX support is all inside RTEMS
340 i[34567]86-pc-linux-*)
345 crt1_dir=libc/sys/${sys_dir}
346 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
347 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
348 newlib_cflags="${newlib_cflags} -Wall"
349 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
350 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
351 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS -DWANT_IO_LONG_DBL"
352 # --- Required when building a shared library ------------------------
353 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
354 # --- The three lines below are optional ------------------------------
355 ##newlib_cflags="${newlib_cflags} -nostdinc"
356 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
357 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
360 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
427 # Host specific flag settings -- usually for features that are not
428 # general enough or broad enough to be handled above.
429 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
433 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
435 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 -I${cygwin_srcdir}/include"
438 # RTEMS supplies its own versions of some routines:
439 # malloc() (reentrant version)
440 # exit() RTEMS has a "global" reent to flush
441 # signal()/raise() RTEMS has its own including pthread signals
442 # _XYZ_r() RTEMS has its own reentrant routines
444 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
446 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"
448 # VxWorks supplies its own version of malloc, and the newlib one
449 # doesn't work because VxWorks does not have sbrk.
451 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
453 # UDI doesn't have exec, so system() should fail the right way
455 newlib_cflags="${newlib_cflags} -DNO_EXEC"
463 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
464 # Don't use the debugging protocols just yet.
468 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
469 # Select which debug protocol is being used.
470 # ARM_RDP_MONITOR selects the Demon monitor.
471 # ARM_RDI_MONITOR selects the Angel monitor.
472 # If neither are defined, then hard coded defaults will be used
473 # to create the program's environment.
474 # See also thumb below.
475 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
476 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
479 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
482 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
486 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
491 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
492 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
495 newlib_cflags="${newlib_cflags}"
500 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG"
504 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
505 # Simulator only extensions for H8300.
506 # Uncomment the next line to enable them.
507 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
511 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
514 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
516 i[34567]86-*-netware*)
517 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
521 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG"
524 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
525 # We don't generate sda relocs however for upward compatibility.
526 # FIXME: This is necessary because the default multilib doesn't
527 # use --print-multi-lib.
528 newlib_cflags="${newlib_cflags} -msdata=sdata"
531 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
532 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
535 newlib_cflags="${newlib_cflags}"
539 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG -DMISSING_SYSCALL_NAMES"
543 # We need every symbol 32-bit aligned, so the invalid
544 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
545 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
550 powerpc*-*-eabialtivec*)
551 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
554 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
558 powerpc*-*-linux* | \
562 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
565 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
569 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
573 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
576 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
577 # This either belongs elsewhere or nowhere. But I need *something*,
578 # so for now it's here ...
581 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
583 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
588 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
589 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
593 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
594 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
595 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
599 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
600 # Don't use the debugging protocols just yet.
604 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
605 # Select which debug protocol is being used.
606 # ARM_RDP_MONITOR selects the Demon monitor.
607 # ARM_RDI_MONITOR selects the Angel monitor.
608 # If neither are defined, then hard coded defaults will be used
609 # to create the program's environment.
610 # See also arm and strongarm above.
611 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
612 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
628 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
631 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
638 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"