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")
27 # newlib_io_long_long --enable-newlib-io-long-long ("yes", "no", "")
28 # newlib_io_long_double --enable-newlib-io-long-double ("yes", "no", "")
30 # It sets the following shell variables:
31 # newlib_cflags Special CFLAGS to use when building
32 # machine_dir Subdirectory of libc/machine to configure
33 # sys_dir Subdirectory of libc/sys to configure
34 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
35 # posix_dir "posix" to build libc/posix, "" otherwise
36 # signal_dir "signal" to build libc/signal, "" otherwise
37 # stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
38 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
39 # unix_dir "unix" to build libc/unix, "" otherwise
40 # use_libtool flag: use libtool to build newlib?
41 # aext library extension - needed for libtool support
42 # oext object file extension - needed for libtool support
43 # crt1 name of crt1 object if one is provided
44 # crt1_dir directory where crt1 object is found
45 # have_crt0 "yes"/"no" if crt0 is/isn't provided.
46 # "" if crt0 is provided when sys_dir is set
63 default_newlib_io_long_long=no
64 default_newlib_io_long_double=no
65 default_newlib_io_pos_args=no
69 case "${target_optspace}:${host}" in
71 newlib_cflags="${newlib_cflags} -Os"
73 :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
74 newlib_cflags="${newlib_cflags} -Os"
77 newlib_cflags="${newlib_cflags} -O2"
81 # Get the source directories to use for the CPU type.
82 # machine_dir should supply CPU dependent routines, such as setjmp.
83 # newlib_cflags is passed to gcc when compiling.
84 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
97 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
133 # Don't use for these since they provide their own setjmp.
135 *-*-sco* | *-*-cygwin*)
136 libm_machine_dir=i386
140 libm_machine_dir=i386
153 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DABORT_PROVIDED -DSMALL_MEMORY"
160 m68hc11|m6811|m68hc12|m6812)
162 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
168 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
172 newlib_cflags="${newlib_cflags} -m88000"
176 newlib_cflags="${newlib_cflags} -m88110"
189 default_newlib_io_long_long="yes"
207 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
208 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
231 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
235 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
241 machine_dir=xstormy16
242 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
243 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
249 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
254 # Disable thread support if requested.
256 if [ "${newlib_multithread}" = "no" ] ; then
257 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
260 # Disable syscall support if requested.
262 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
263 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
266 # Enable multibyte support if requested or it is defaulted
269 if [ "x${newlib_mb}" = "x" ]; then
271 i[34567]86-pc-linux-*|*-*-cygwin*)
277 # Disable printf/scanf floating-point support if requested.
279 if [ "${newlib_io_float}" = "no" ] ; then
280 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
283 # Verify if shared newlib support is allowed and set appropriate variables
284 # We don't want to use libtool for platforms that we are not going to
285 # support shared libraries. This is because it adds executable tests which
286 # we don't want for most embedded platforms.
288 i[34567]86-pc-linux-*)
290 have_sys_mach_dir=yes
294 *) ;; #shared library not supported for ${host}
297 # Get the source directories to use for the host. unix_dir is set
298 # to unix to get some standard Unix routines. posix_dir is set to get some
299 # standard Posix routines. sys_dir should supply system dependent routines
301 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
312 *-*-rtems*) # generic RTEMS support
314 # RTEMS POSIX support is all inside RTEMS
325 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
340 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
369 i[34567]86-pc-linux-*)
374 crt1_dir=libc/sys/${sys_dir}
375 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
376 default_newlib_io_long_double="yes"
377 default_newlib_io_long_long="yes"
378 default_newlib_io_pos_args="yes"
379 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
380 newlib_cflags="${newlib_cflags} -Wall"
381 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
382 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
383 # --- Required when building a shared library ------------------------
384 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
385 # --- The three lines below are optional ------------------------------
386 ##newlib_cflags="${newlib_cflags} -nostdinc"
387 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
388 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
391 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
422 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
428 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
455 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
464 # Host specific flag settings -- usually for features that are not
465 # general enough or broad enough to be handled above.
466 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
470 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
472 default_newlib_io_long_long="yes"
473 default_newlib_io_long_double="yes"
474 default_newlib_io_pos_args="yes"
475 CC="${CC} -I${cygwin_srcdir}/include"
476 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
479 # RTEMS supplies its own versions of some routines:
480 # malloc() (reentrant version)
481 # exit() RTEMS has a "global" reent to flush
482 # signal()/raise() RTEMS has its own including pthread signals
483 # _XYZ_r() RTEMS has its own reentrant routines
485 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
487 default_newlib_io_long_long="yes"
488 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DHAVE_FCNTL"
490 # VxWorks supplies its own version of malloc, and the newlib one
491 # doesn't work because VxWorks does not have sbrk.
493 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
495 # UDI doesn't have exec, so system() should fail the right way
497 newlib_cflags="${newlib_cflags} -DNO_EXEC"
505 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
509 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
510 # If newlib is supplying syscalls, select which debug protocol is being used.
511 # ARM_RDP_MONITOR selects the Demon monitor.
512 # ARM_RDI_MONITOR selects the Angel monitor.
513 # If neither are defined, then hard coded defaults will be used
514 # to create the program's environment.
515 # If --disable-newlib-supplied-syscalls is specified, then the end-user
516 # may specify the protocol via gcc spec files supplied by libgloss.
517 # See also thumb below.
518 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
519 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
520 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
524 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
527 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
529 cris-*-* | crisv32-*-*)
530 default_newlib_io_long_long="yes"
531 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_GETTIMEOFDAY -D_USE_WRITE -DCOMPACT_CTYPE"
535 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
539 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
543 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
548 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
549 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
550 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
558 default_newlib_io_long_long="yes"
562 default_newlib_io_long_long="yes"
563 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
564 # Simulator only extensions for H8300.
565 # Uncomment the next line to enable them.
566 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
570 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
573 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
575 i[34567]86-*-netware*)
576 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
580 default_newlib_io_long_long="yes"
583 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
584 # We don't generate sda relocs however for upward compatibility.
585 # FIXME: This is necessary because the default multilib doesn't
586 # use --print-multi-lib.
587 newlib_cflags="${newlib_cflags} -msdata=sdata"
590 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
591 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
597 default_newlib_io_long_long="yes"
598 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
601 default_newlib_io_long_long="yes"
602 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
606 # We need every symbol 32-bit aligned, so the invalid
607 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
608 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
613 powerpc*-*-eabialtivec*)
614 default_newlib_io_long_long="yes"
615 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
618 default_newlib_io_long_long="yes"
619 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
623 powerpc*-*-linux* | \
627 default_newlib_io_long_long="yes"
628 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
631 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
635 default_newlib_io_long_long="yes"
636 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
640 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
643 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
644 # This either belongs elsewhere or nowhere. But I need *something*,
645 # so for now it's here ...
648 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
650 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
655 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
659 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
660 # Don't use the debugging protocols just yet.
664 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
665 # If newlib is supplying syscalls, select which debug protocol is being used.
666 # ARM_RDP_MONITOR selects the Demon monitor.
667 # ARM_RDI_MONITOR selects the Angel monitor.
668 # If neither are defined, then hard coded defaults will be used
669 # to create the program's environment.
670 # If --disable-newlib-supplied-syscalls is specified, then the end-user
671 # may specify the protocol via gcc spec files supplied by libgloss.
672 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
673 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
674 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
691 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
695 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
696 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
697 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
698 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
702 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
709 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
714 # Use defaults for certain settings if not specified by user
716 # Enable long long support in I/O routines if requested.
717 if [ "x${newlib_io_long_long}" = "x" ]; then
718 if [ ${default_newlib_io_long_long} = "yes" ]; then
719 newlib_io_long_long="yes";
723 # Enable long double support in I/O routines if requested.
724 if [ "x${newlib_io_long_double}" = "x" ]; then
725 if [ ${default_newlib_io_long_double} = "yes" ]; then
726 newlib_io_long_double="yes";
730 # Enable printf positional argument support if requested.
731 if [ "x${newlib_io_pos_args}" = "x" ]; then
732 if [ ${default_newlib_io_pos_args} = "yes" ]; then
733 newlib_io_pos_args="yes";
737 if test -z "${have_crt0}" && test -n "${sys_dir}"; then