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", "")
30 # newlib_global_stdio_streams --enable-global-stdio-streams ("yes", "no, "")
31 # newlib_fno_builtin --disable-newlib-fno-builtin ("yes", "no, "")
32 # newlib_reent_check_verify --enable-newlib-reent-check-verify ("yes", "no, "")
34 # It sets the following shell variables:
35 # newlib_cflags Special CFLAGS to use when building
36 # machine_dir Subdirectory of libc/machine to configure
37 # shared_machine_dir Subdirectory of libc/machine for files shared
38 # between specific architectures, optional
39 # sys_dir Subdirectory of libc/sys to configure
40 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
41 # posix_dir "posix" to build libc/posix, "" otherwise
42 # signal_dir "signal" to build libc/signal, "" otherwise
43 # stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
44 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
45 # unix_dir "unix" to build libc/unix, "" otherwise
46 # lpfx library object prefix - generated when no libtool
47 # crt1 name of crt1 object if one is provided
48 # crt1_dir directory where crt1 object is found
49 # have_crt0 "yes"/"no" if crt0 is/isn't provided.
50 # "" if crt0 is provided when sys_dir is set
51 # have_init_fini have init/fini ("yes" or "no", set to "yes" by default)
52 # noinclude list of include files to not install
54 newlib_cflags="-D_LIBC"
72 default_newlib_io_c99_formats=no
73 default_newlib_io_long_long=no
74 default_newlib_io_long_double=no
75 default_newlib_io_pos_args=no
76 default_newlib_atexit_dynamic_alloc=yes
77 default_newlib_nano_malloc=no
78 default_newlib_reent_check_verify=yes
82 case "${target_optspace}:${host}" in
84 newlib_cflags="${newlib_cflags} -Os"
86 :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* | :msp430*-* | :nds32* | :pru-* | :rl78-* )
87 newlib_cflags="${newlib_cflags} -Os"
93 case "${newlib_fno_builtin}:${host}" in
95 newlib_cflags="${newlib_cflags} -fno-builtin"
98 newlib_cflags="${newlib_cflags}"
101 # For now, all targets default to using -fno-builtin until tested without
102 newlib_cflags="${newlib_cflags} -fno-builtin"
106 # Get the source directories to use for the CPU type.
107 # machine_dir should supply CPU dependent routines, such as setjmp.
108 # newlib_cflags is passed to gcc when compiling.
109 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
111 case "${host_cpu}" in
117 libm_machine_dir=aarch64
120 newlib_cflags="${newlib_cflags} -D__DYNAMIC_REENT__"
122 newlib_cv_initfinit_array=yes
132 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
141 # The size of the (kernel_)time_t passed from or to a
142 # simulator or a Linux kernel is mandated by the
143 # gettimeofday and time system calls and fixed to 32 bits, the
144 # size of a long. Instead of churning as 64 bits what is anyway
145 # 32 bits, it makes more sense to default to long.
146 test -z "${enable_newlib_long_time_t}" && newlib_long_time_t=yes
154 default_newlib_atexit_dynamic_alloc="no"
167 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
177 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
192 libm_machine_dir=i386
194 shared_machine_dir=shared_x86
195 # Don't use for these since they provide their own setjmp.
197 *-*-sco* | *-*-cygwin*)
214 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
221 m68hc11|m6811|m68hc12|m6812)
223 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
229 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
233 newlib_cflags="${newlib_cflags} -m88000"
237 newlib_cflags="${newlib_cflags} -m88110"
242 machine_dir=microblaze
249 libm_machine_dir=mips
257 default_newlib_io_long_long="yes"
264 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
265 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
266 newlib_cflags="${newlib_cflags} -mOs "
267 newlib_cflags="${newlib_cflags} -mhwmult=none "
269 default_newlib_nano_malloc="yes"
276 libm_machine_dir=nds32
277 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections"
278 newlib_cflags="${newlib_cflags} -DHAVE_RENAME"
285 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED"
293 libm_machine_dir=powerpc
296 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
297 newlib_cflags="${newlib_cflags} -DNO_EXEC"
298 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
299 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
300 default_newlib_nano_malloc="yes"
301 default_newlib_atexit_dynamic_alloc="no"
306 libm_machine_dir=riscv
308 newlib_cflags="${newlib_cflags} -DHAVE_NANOSLEEP"
309 default_newlib_atexit_dynamic_alloc="no"
314 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
315 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
319 default_newlib_io_long_long="yes"
320 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
326 libm_machine_dir=sparc
328 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
329 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
346 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
356 libm_machine_dir=x86_64
357 shared_machine_dir=shared_x86
363 machine_dir=xstormy16
364 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
365 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
374 newlib_cflags="${newlib_cflags} -D_POSIX_MODE"
375 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
376 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
377 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
380 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
385 # Disable thread support if requested.
387 if [ "${newlib_multithread}" = "no" ] ; then
388 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
391 # Disable syscall support if requested.
393 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
394 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
397 # Enable multibyte support if requested or it is defaulted
400 if [ "x${newlib_mb}" = "x" ]; then
408 # Disable printf/scanf floating-point support if requested.
410 if [ "${newlib_io_float}" = "no" ] ; then
411 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
414 # Get the source directories to use for the host. unix_dir is set
415 # to unix to get some standard Unix routines. posix_dir is set to get some
416 # standard Posix routines. sys_dir should supply system dependent routines
418 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
435 *-*-rtems*) # generic RTEMS support
454 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
475 # crt0 is provided by libgloss.
504 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
505 newlib_cflags="${newlib_cflags} -D_I386MACH_DISABLE_HW_INTERRUPTS"
512 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
522 default_newlib_io_long_long="yes"
523 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
526 machine_dir=microblaze
537 or1k-*-elf | or1knd-*-elf)
539 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED "
549 default_newlib_io_long_long="yes"
550 default_newlib_atexit_dynamic_alloc="no"
553 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
567 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
582 # Host specific flag settings -- usually for features that are not
583 # general enough or broad enough to be handled above.
584 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
588 test -z "$cygwin_srcdir" && cygwin_srcdir="${abs_newlib_basedir}/../winsup/cygwin"
590 default_newlib_io_c99_formats="yes"
591 default_newlib_io_long_long="yes"
592 default_newlib_io_long_double="yes"
593 default_newlib_io_pos_args="yes"
594 CC="${CC} -I${cygwin_srcdir}/include"
595 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DGETREENT_PROVIDED -DSIGNAL_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
599 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DHAVE_BLKSIZE -DHAVE_NANOSLEEP"
600 default_newlib_io_long_long="yes"
603 # RTEMS supplies its own versions of some routines:
604 # malloc() (reentrant version)
605 # exit() RTEMS has a "global" reent to flush
606 # signal()/raise() RTEMS has its own including pthread signals
607 # _XYZ_r() RTEMS has its own reentrant routines
609 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
611 default_newlib_io_long_long="yes"
612 default_newlib_io_c99_formats="yes"
613 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
614 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DGETREENT_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
615 # turn off unsupported items in posix directory
616 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 -D_NO_POSIX_SPAWN"
618 # VxWorks supplies its own version of malloc, and the newlib one
619 # doesn't work because VxWorks does not have sbrk.
621 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
623 # TIRTOS supplies its own version of malloc
625 newlib_cflags="${newlib_cflags} -D__DYNAMIC_REENT__ -DMALLOC_PROVIDED"
627 # UDI doesn't have exec, so system() should fail the right way
629 newlib_cflags="${newlib_cflags} -DNO_EXEC"
633 default_newlib_io_long_long="yes"
638 default_newlib_io_long_long="yes"
645 # If newlib is supplying syscalls, select which debug protocol is being used.
646 # ARM_RDP_MONITOR selects the Demon monitor.
647 # ARM_RDI_MONITOR selects the Angel monitor.
648 # If neither are defined, then hard coded defaults will be used
649 # to create the program's environment.
650 # If --disable-newlib-supplied-syscalls is specified, then the end-user
651 # may specify the protocol via gcc spec files supplied by libgloss.
652 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
653 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
654 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
658 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
663 cris-*-* | crisv32-*-*)
664 default_newlib_io_long_long="yes"
665 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE"
672 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
676 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
680 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
684 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
689 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
692 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
700 default_newlib_io_long_long="yes"
707 default_newlib_io_long_long="yes"
708 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
709 # Simulator only extensions for H8300.
710 # Uncomment the next line to enable them.
711 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
715 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
718 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
720 i[34567]86-*-netware*)
721 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
724 newlib_cflags="${newlib_cflags} -Os -DPREFER_SIZE_OVER_SPEED -ffunction-sections -fomit-frame-pointer -DREENTRANT_SYSCALL_PROVIDED"
725 if [ "${newlib_multithread}" = "no" ] ; then
726 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
729 newlib_cflags="${newlib_cflags} -D__DYNAMIC_REENT__"
734 default_newlib_io_long_long="yes"
740 default_newlib_io_long_long="yes"
741 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DABORT_PROVIDED"
745 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
746 # We don't generate sda relocs however for upward compatibility.
747 # FIXME: This is necessary because the default multilib doesn't
748 # use --print-multi-lib.
749 newlib_cflags="${newlib_cflags} -msdata=sdata"
752 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
753 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
756 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
763 default_newlib_io_long_long="yes"
764 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DSMALL_MEMORY -D_REENT_SMALL"
767 default_newlib_io_long_long="yes"
768 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
771 default_newlib_io_long_long="yes"
772 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
776 # We need every symbol 32-bit aligned, so the invalid
777 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
778 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
783 moxie-*-elf* | moxie-*-rtems*)
785 default_newlib_io_long_long="yes"
789 default_newlib_io_long_long="yes"
790 newlib_cflags="${newlib_cflags} -Os -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
794 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
802 powerpc*-*-eabialtivec*)
803 default_newlib_io_long_long="yes"
804 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
807 default_newlib_io_long_long="yes"
808 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
812 powerpc*-*-linux* | \
816 default_newlib_io_long_long="yes"
817 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
820 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL -D_NO_POSIX_SPAWN"
825 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY -D_REENT_SMALL"
831 default_newlib_io_long_long="yes"
835 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
838 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL"
839 # This either belongs elsewhere or nowhere. But I need *something*,
840 # so for now it's here ...
843 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
845 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
850 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED"
859 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
864 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
876 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
881 # Use defaults for certain settings if not specified by user
883 # Enable C99 format support in I/O routines if requested.
884 if [ "x${newlib_io_c99_formats}" = "x" ]; then
885 if [ ${default_newlib_io_c99_formats} = "yes" ]; then
886 newlib_io_c99_formats="yes";
890 # Enable long long support in I/O routines if requested.
891 if [ "x${newlib_io_long_long}" = "x" ]; then
892 if [ ${default_newlib_io_long_long} = "yes" ]; then
893 newlib_io_long_long="yes";
897 # Enable long double support in I/O routines if requested.
898 if [ "x${newlib_io_long_double}" = "x" ]; then
899 if [ ${default_newlib_io_long_double} = "yes" ]; then
900 newlib_io_long_double="yes";
904 # Enable printf positional argument support if requested.
905 if [ "x${newlib_io_pos_args}" = "x" ]; then
906 if [ ${default_newlib_io_pos_args} = "yes" ]; then
907 newlib_io_pos_args="yes";
911 # Disable atexit dynamic allocation if requested.
912 if [ "x${newlib_atexit_dynamic_alloc}" = "x" ]; then
913 if [ ${default_newlib_atexit_dynamic_alloc} = "yes" ]; then
914 newlib_atexit_dynamic_alloc="yes";
918 # Enable nano-malloc if requested.
919 if [ "x${newlib_nano_malloc}" = "x" ]; then
920 if [ ${default_newlib_nano_malloc} = "yes" ]; then
921 newlib_nano_malloc="yes";
925 # Enable _REENT_CHECK macro memory allocation verification.
926 if [ "x${newlib_reent_check_verify}" = "x" ]; then
927 if [ ${default_newlib_reent_check_verify} = "yes" ]; then
928 newlib_reent_check_verify="yes";
932 # Remove rpc headers if xdr_dir not specified
933 if [ "x${xdr_dir}" = "x" ]; then
934 noinclude="${noinclude} rpc/types.h rpc/xdr.h"
937 # Have init/finit if not explicitly specified otherwise
938 if [ "x${have_init_fini}" != "xno" ]; then
939 newlib_cflags="${newlib_cflags} -D_HAVE_INIT_FINI"
942 if test -z "${have_crt0}" && test -n "${sys_dir}"; then
946 # Target-specific defaults
947 case "${host_cpu}" in
949 if [ "x${newlib_elix_level}" = "x0" ]; then
951 elif [ "x${newlib_elix_level}" != "x1" ]; then
952 newlib_msg_warn="nvptx does not support elix level > 1";
954 if [[ -z ${newlib_global_stdio_streams} ]]; then
955 newlib_global_stdio_streams="yes";