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 # lpfx library object prefix - generated when no libtool
44 # crt1 name of crt1 object if one is provided
45 # crt1_dir directory where crt1 object is found
46 # have_crt0 "yes"/"no" if crt0 is/isn't provided.
47 # "" if crt0 is provided when sys_dir is set
64 default_newlib_io_long_long=no
65 default_newlib_io_long_double=no
66 default_newlib_io_pos_args=no
67 default_newlib_atexit_dynamic_alloc=yes
72 case "${target_optspace}:${host}" in
74 newlib_cflags="${newlib_cflags} -Os"
76 :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
77 newlib_cflags="${newlib_cflags} -Os"
80 newlib_cflags="${newlib_cflags} -O2"
84 # Get the source directories to use for the CPU type.
85 # machine_dir should supply CPU dependent routines, such as setjmp.
86 # newlib_cflags is passed to gcc when compiling.
87 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
100 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
136 # Don't use for these since they provide their own setjmp.
138 *-*-sco* | *-*-cygwin*)
139 libm_machine_dir=i386
143 libm_machine_dir=i386
156 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DABORT_PROVIDED -DSMALL_MEMORY"
163 m68hc11|m6811|m68hc12|m6812)
165 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
171 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
175 newlib_cflags="${newlib_cflags} -m88000"
179 newlib_cflags="${newlib_cflags} -m88110"
192 default_newlib_io_long_long="yes"
210 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
211 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
234 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
238 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
244 machine_dir=xstormy16
245 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
246 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
252 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
257 # Disable thread support if requested.
259 if [ "${newlib_multithread}" = "no" ] ; then
260 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
263 # Disable syscall support if requested.
265 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
266 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
269 # Enable multibyte support if requested or it is defaulted
272 if [ "x${newlib_mb}" = "x" ]; then
274 i[34567]86-pc-linux-*|*-*-cygwin*)
280 # Disable printf/scanf floating-point support if requested.
282 if [ "${newlib_io_float}" = "no" ] ; then
283 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
286 # Verify if shared newlib support is allowed and set appropriate variables
287 # We don't want to use libtool for platforms that we are not going to
288 # support shared libraries. This is because it adds executable tests which
289 # we don't want for most embedded platforms.
291 i[34567]86-pc-linux-*)
293 have_sys_mach_dir=yes
298 *) ;; #shared library not supported for ${host}
301 # Get the source directories to use for the host. unix_dir is set
302 # to unix to get some standard Unix routines. posix_dir is set to get some
303 # standard Posix routines. sys_dir should supply system dependent routines
305 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
316 *-*-rtems*) # generic RTEMS support
318 # RTEMS POSIX support is all inside RTEMS
329 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
344 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
371 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
377 i[34567]86-pc-linux-*)
382 crt1_dir=libc/sys/${sys_dir}
383 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
384 default_newlib_io_long_double="yes"
385 default_newlib_io_long_long="yes"
386 default_newlib_io_pos_args="yes"
387 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
388 newlib_cflags="${newlib_cflags} -Wall"
389 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
390 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
391 # --- Required when building a shared library ------------------------
392 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
393 # --- The three lines below are optional ------------------------------
394 ##newlib_cflags="${newlib_cflags} -nostdinc"
395 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
396 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
399 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
430 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
436 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
463 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
472 # Host specific flag settings -- usually for features that are not
473 # general enough or broad enough to be handled above.
474 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
478 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
480 default_newlib_io_long_long="yes"
481 default_newlib_io_long_double="yes"
482 default_newlib_io_pos_args="yes"
483 CC="${CC} -I${cygwin_srcdir}/include"
484 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
487 # RTEMS supplies its own versions of some routines:
488 # malloc() (reentrant version)
489 # exit() RTEMS has a "global" reent to flush
490 # signal()/raise() RTEMS has its own including pthread signals
491 # _XYZ_r() RTEMS has its own reentrant routines
493 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
495 default_newlib_io_long_long="yes"
496 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DHAVE_FCNTL"
498 # VxWorks supplies its own version of malloc, and the newlib one
499 # doesn't work because VxWorks does not have sbrk.
501 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
503 # UDI doesn't have exec, so system() should fail the right way
505 newlib_cflags="${newlib_cflags} -DNO_EXEC"
513 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
517 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
518 # If newlib is supplying syscalls, select which debug protocol is being used.
519 # ARM_RDP_MONITOR selects the Demon monitor.
520 # ARM_RDI_MONITOR selects the Angel monitor.
521 # If neither are defined, then hard coded defaults will be used
522 # to create the program's environment.
523 # If --disable-newlib-supplied-syscalls is specified, then the end-user
524 # may specify the protocol via gcc spec files supplied by libgloss.
525 # See also thumb below.
526 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
527 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
528 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
532 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
535 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
537 cris-*-* | crisv32-*-*)
538 default_newlib_io_long_long="yes"
539 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_GETTIMEOFDAY -D_USE_WRITE -DCOMPACT_CTYPE"
543 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
547 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
551 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
556 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
557 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
558 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
566 default_newlib_io_long_long="yes"
570 default_newlib_io_long_long="yes"
571 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
572 # Simulator only extensions for H8300.
573 # Uncomment the next line to enable them.
574 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
578 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
581 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
583 i[34567]86-*-netware*)
584 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
588 default_newlib_io_long_long="yes"
591 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
592 # We don't generate sda relocs however for upward compatibility.
593 # FIXME: This is necessary because the default multilib doesn't
594 # use --print-multi-lib.
595 newlib_cflags="${newlib_cflags} -msdata=sdata"
598 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
599 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
605 default_newlib_io_long_long="yes"
606 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
609 default_newlib_io_long_long="yes"
610 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
614 # We need every symbol 32-bit aligned, so the invalid
615 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
616 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
621 powerpc*-*-eabialtivec*)
622 default_newlib_io_long_long="yes"
623 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
626 default_newlib_io_long_long="yes"
627 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
631 powerpc*-*-linux* | \
635 default_newlib_io_long_long="yes"
636 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
639 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
643 default_newlib_io_long_long="yes"
644 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
648 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
651 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
652 # This either belongs elsewhere or nowhere. But I need *something*,
653 # so for now it's here ...
656 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
658 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
663 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
667 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
668 # Don't use the debugging protocols just yet.
672 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
673 # If newlib is supplying syscalls, select which debug protocol is being used.
674 # ARM_RDP_MONITOR selects the Demon monitor.
675 # ARM_RDI_MONITOR selects the Angel monitor.
676 # If neither are defined, then hard coded defaults will be used
677 # to create the program's environment.
678 # If --disable-newlib-supplied-syscalls is specified, then the end-user
679 # may specify the protocol via gcc spec files supplied by libgloss.
680 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
681 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
682 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
699 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
703 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
704 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
705 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
706 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
710 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
717 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
722 # Use defaults for certain settings if not specified by user
724 # Enable long long support in I/O routines if requested.
725 if [ "x${newlib_io_long_long}" = "x" ]; then
726 if [ ${default_newlib_io_long_long} = "yes" ]; then
727 newlib_io_long_long="yes";
731 # Enable long double support in I/O routines if requested.
732 if [ "x${newlib_io_long_double}" = "x" ]; then
733 if [ ${default_newlib_io_long_double} = "yes" ]; then
734 newlib_io_long_double="yes";
738 # Enable printf positional argument support if requested.
739 if [ "x${newlib_io_pos_args}" = "x" ]; then
740 if [ ${default_newlib_io_pos_args} = "yes" ]; then
741 newlib_io_pos_args="yes";
745 # Disable atexit dynamic allocation if requested.
746 if [ "x${newlib_atexit_dynamic_alloc}" = "x" ]; then
747 if [ ${default_newlib_atexit_dynamic_alloc} = "yes" ]; then
748 newlib_atexit_dynamic_alloc="yes";
752 if test -z "${have_crt0}" && test -n "${sys_dir}"; then