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_c99_formats --enable-newlib-io-c99-formats ("yes", "no", "")
28 # newlib_io_long_long --enable-newlib-io-long-long ("yes", "no", "")
29 # newlib_io_long_double --enable-newlib-io-long-double ("yes", "no", "")
31 # It sets the following shell variables:
32 # newlib_cflags Special CFLAGS to use when building
33 # machine_dir Subdirectory of libc/machine to configure
34 # sys_dir Subdirectory of libc/sys to configure
35 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
36 # posix_dir "posix" to build libc/posix, "" otherwise
37 # signal_dir "signal" to build libc/signal, "" otherwise
38 # stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
39 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
40 # unix_dir "unix" to build libc/unix, "" otherwise
41 # use_libtool flag: use libtool to build newlib?
42 # aext library extension - needed for libtool support
43 # oext object file extension - needed for libtool support
44 # lpfx library object prefix - generated when no libtool
45 # crt1 name of crt1 object if one is provided
46 # crt1_dir directory where crt1 object is found
47 # have_crt0 "yes"/"no" if crt0 is/isn't provided.
48 # "" if crt0 is provided when sys_dir is set
49 # noinclude list of include files to not install
69 default_newlib_io_c99_formats=no
70 default_newlib_io_long_long=no
71 default_newlib_io_long_double=no
72 default_newlib_io_pos_args=no
73 default_newlib_atexit_dynamic_alloc=yes
78 case "${target_optspace}:${host}" in
80 newlib_cflags="${newlib_cflags} -Os"
82 :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
83 newlib_cflags="${newlib_cflags} -Os"
89 # Get the source directories to use for the CPU type.
90 # machine_dir should supply CPU dependent routines, such as setjmp.
91 # newlib_cflags is passed to gcc when compiling.
92 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
105 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
130 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
151 # Don't use for these since they provide their own setjmp.
153 *-*-sco* | *-*-cygwin*)
154 libm_machine_dir=i386
158 libm_machine_dir=i386
174 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
181 m68hc11|m6811|m68hc12|m6812)
183 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
189 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
193 newlib_cflags="${newlib_cflags} -m88000"
197 newlib_cflags="${newlib_cflags} -m88110"
202 machine_dir=microblaze
216 default_newlib_io_long_long="yes"
234 default_newlib_io_long_long="yes"
235 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
242 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
243 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
269 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
281 machine_dir=xstormy16
282 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
283 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
292 newlib_cflags="${newlib_cflags} -D_POSIX_MODE"
293 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
294 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
295 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
298 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
303 # Disable thread support if requested.
305 if [ "${newlib_multithread}" = "no" ] ; then
306 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
309 # Disable syscall support if requested.
311 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
312 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
315 # Enable multibyte support if requested or it is defaulted
318 if [ "x${newlib_mb}" = "x" ]; then
320 i[34567]86-pc-linux-*|*-*-cygwin*)
326 # Disable printf/scanf floating-point support if requested.
328 if [ "${newlib_io_float}" = "no" ] ; then
329 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
332 # Verify if shared newlib support is allowed and set appropriate variables
333 # We don't want to use libtool for platforms that we are not going to
334 # support shared libraries. This is because it adds executable tests which
335 # we don't want for most embedded platforms.
337 i[34567]86-pc-linux-*)
339 have_sys_mach_dir=yes
344 *) ;; #shared library not supported for ${host}
347 # Get the source directories to use for the host. unix_dir is set
348 # to unix to get some standard Unix routines. posix_dir is set to get some
349 # standard Posix routines. sys_dir should supply system dependent routines
351 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
363 *-*-rtems*) # generic RTEMS support
377 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
398 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
425 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
431 i[34567]86-pc-linux-*)
436 crt1_dir=libc/sys/${sys_dir}
437 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
438 default_newlib_io_c99_formats="yes"
439 default_newlib_io_long_double="yes"
440 default_newlib_io_long_long="yes"
441 default_newlib_io_pos_args="yes"
442 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
443 newlib_cflags="${newlib_cflags} -Wall"
444 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
445 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
446 newlib_cflags="${newlib_cflags} -DHAVE_GETOPT"
447 # --- Required when building a shared library ------------------------
448 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
449 # --- The three lines below are optional ------------------------------
450 ##newlib_cflags="${newlib_cflags} -nostdinc"
451 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
452 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
455 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
465 default_newlib_io_long_long="yes"
466 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
469 machine_dir=microblaze
495 default_newlib_io_long_long="yes"
496 default_newlib_atexit_dynamic_alloc="no"
500 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
506 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
511 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
525 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
534 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
543 # Host specific flag settings -- usually for features that are not
544 # general enough or broad enough to be handled above.
545 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
549 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
551 default_newlib_io_c99_formats="yes"
552 default_newlib_io_long_long="yes"
553 default_newlib_io_long_double="yes"
554 default_newlib_io_pos_args="yes"
555 CC="${CC} -I${cygwin_srcdir}/include"
556 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
559 # RTEMS supplies its own versions of some routines:
560 # malloc() (reentrant version)
561 # exit() RTEMS has a "global" reent to flush
562 # signal()/raise() RTEMS has its own including pthread signals
563 # _XYZ_r() RTEMS has its own reentrant routines
565 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
567 default_newlib_io_long_long="yes"
568 default_newlib_io_c99_formats="yes"
569 newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
570 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
571 # turn off unsupported items in posix directory
572 newlib_cflags="${newlib_cflags} -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN"
574 # VxWorks supplies its own version of malloc, and the newlib one
575 # doesn't work because VxWorks does not have sbrk.
577 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
579 # UDI doesn't have exec, so system() should fail the right way
581 newlib_cflags="${newlib_cflags} -DNO_EXEC"
592 # If newlib is supplying syscalls, select which debug protocol is being used.
593 # ARM_RDP_MONITOR selects the Demon monitor.
594 # ARM_RDI_MONITOR selects the Angel monitor.
595 # If neither are defined, then hard coded defaults will be used
596 # to create the program's environment.
597 # If --disable-newlib-supplied-syscalls is specified, then the end-user
598 # may specify the protocol via gcc spec files supplied by libgloss.
599 # See also thumb below.
600 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
601 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
602 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
606 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
609 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
614 cris-*-* | crisv32-*-*)
615 default_newlib_io_long_long="yes"
616 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE"
623 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
627 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
631 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
636 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
637 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
641 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
649 default_newlib_io_long_long="yes"
653 default_newlib_io_long_long="yes"
654 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
655 # Simulator only extensions for H8300.
656 # Uncomment the next line to enable them.
657 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
661 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
664 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
666 i[34567]86-*-netware*)
667 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
671 default_newlib_io_long_long="yes"
677 default_newlib_io_long_long="yes"
678 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DABORT_PROVIDED"
682 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
683 # We don't generate sda relocs however for upward compatibility.
684 # FIXME: This is necessary because the default multilib doesn't
685 # use --print-multi-lib.
686 newlib_cflags="${newlib_cflags} -msdata=sdata"
689 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
690 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
693 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
700 default_newlib_io_long_long="yes"
701 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DSMALL_MEMORY -D_REENT_SMALL"
704 default_newlib_io_long_long="yes"
705 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
708 default_newlib_io_long_long="yes"
709 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
713 # We need every symbol 32-bit aligned, so the invalid
714 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
715 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
722 default_newlib_io_long_long="yes"
724 powerpc*-*-eabialtivec*)
725 default_newlib_io_long_long="yes"
726 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
729 default_newlib_io_long_long="yes"
730 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
734 powerpc*-*-linux* | \
738 default_newlib_io_long_long="yes"
739 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
742 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
746 default_newlib_io_long_long="yes"
750 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
753 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL"
754 # This either belongs elsewhere or nowhere. But I need *something*,
755 # so for now it's here ...
758 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
760 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
768 # Don't use the debugging protocols just yet.
772 # If newlib is supplying syscalls, select which debug protocol is being used.
773 # ARM_RDP_MONITOR selects the Demon monitor.
774 # ARM_RDI_MONITOR selects the Angel monitor.
775 # If neither are defined, then hard coded defaults will be used
776 # to create the program's environment.
777 # If --disable-newlib-supplied-syscalls is specified, then the end-user
778 # may specify the protocol via gcc spec files supplied by libgloss.
779 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
780 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
781 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
786 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED"
796 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
803 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
804 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
805 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
815 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
820 # Use defaults for certain settings if not specified by user
822 # Enable C99 format support in I/O routines if requested.
823 if [ "x${newlib_io_c99_formats}" = "x" ]; then
824 if [ ${default_newlib_io_c99_formats} = "yes" ]; then
825 newlib_io_c99_formats="yes";
829 # Enable long long support in I/O routines if requested.
830 if [ "x${newlib_io_long_long}" = "x" ]; then
831 if [ ${default_newlib_io_long_long} = "yes" ]; then
832 newlib_io_long_long="yes";
836 # Enable long double support in I/O routines if requested.
837 if [ "x${newlib_io_long_double}" = "x" ]; then
838 if [ ${default_newlib_io_long_double} = "yes" ]; then
839 newlib_io_long_double="yes";
843 # Enable printf positional argument support if requested.
844 if [ "x${newlib_io_pos_args}" = "x" ]; then
845 if [ ${default_newlib_io_pos_args} = "yes" ]; then
846 newlib_io_pos_args="yes";
850 # Disable atexit dynamic allocation if requested.
851 if [ "x${newlib_atexit_dynamic_alloc}" = "x" ]; then
852 if [ ${default_newlib_atexit_dynamic_alloc} = "yes" ]; then
853 newlib_atexit_dynamic_alloc="yes";
857 # Remove rpc headers if xdr_dir not specified
858 if [ "x${xdir_dir}" = "x" ]; then
859 noinclude="${noinclude} rpc/types.h rpc/xdr.h"
862 if test -z "${have_crt0}" && test -n "${sys_dir}"; then