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
66 default_newlib_io_c99_formats=no
67 default_newlib_io_long_long=no
68 default_newlib_io_long_double=no
69 default_newlib_io_pos_args=no
70 default_newlib_atexit_dynamic_alloc=yes
75 case "${target_optspace}:${host}" in
77 newlib_cflags="${newlib_cflags} -Os"
79 :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
80 newlib_cflags="${newlib_cflags} -Os"
86 # Get the source directories to use for the CPU type.
87 # machine_dir should supply CPU dependent routines, such as setjmp.
88 # newlib_cflags is passed to gcc when compiling.
89 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
102 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
124 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
145 # Don't use for these since they provide their own setjmp.
147 *-*-sco* | *-*-cygwin*)
148 libm_machine_dir=i386
152 libm_machine_dir=i386
168 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
175 m68hc11|m6811|m68hc12|m6812)
177 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
183 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
187 newlib_cflags="${newlib_cflags} -m88000"
191 newlib_cflags="${newlib_cflags} -m88110"
196 machine_dir=microblaze
210 default_newlib_io_long_long="yes"
228 default_newlib_io_long_long="yes"
229 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
236 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
237 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
260 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
264 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
276 machine_dir=xstormy16
277 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
278 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
287 newlib_cflags="${newlib_cflags} -D_POSIX_MODE"
288 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
289 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
290 newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
293 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
298 # Disable thread support if requested.
300 if [ "${newlib_multithread}" = "no" ] ; then
301 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
304 # Disable syscall support if requested.
306 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
307 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
310 # Enable multibyte support if requested or it is defaulted
313 if [ "x${newlib_mb}" = "x" ]; then
315 i[34567]86-pc-linux-*|*-*-cygwin*)
321 # Disable printf/scanf floating-point support if requested.
323 if [ "${newlib_io_float}" = "no" ] ; then
324 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
327 # Verify if shared newlib support is allowed and set appropriate variables
328 # We don't want to use libtool for platforms that we are not going to
329 # support shared libraries. This is because it adds executable tests which
330 # we don't want for most embedded platforms.
332 i[34567]86-pc-linux-*)
334 have_sys_mach_dir=yes
339 *) ;; #shared library not supported for ${host}
342 # Get the source directories to use for the host. unix_dir is set
343 # to unix to get some standard Unix routines. posix_dir is set to get some
344 # standard Posix routines. sys_dir should supply system dependent routines
346 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
357 *-*-rtems*) # generic RTEMS support
371 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
389 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
416 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
422 i[34567]86-pc-linux-*)
427 crt1_dir=libc/sys/${sys_dir}
428 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
429 default_newlib_io_c99_formats="yes"
430 default_newlib_io_long_double="yes"
431 default_newlib_io_long_long="yes"
432 default_newlib_io_pos_args="yes"
433 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
434 newlib_cflags="${newlib_cflags} -Wall"
435 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
436 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
437 newlib_cflags="${newlib_cflags} -DHAVE_GETOPT"
438 # --- Required when building a shared library ------------------------
439 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
440 # --- The three lines below are optional ------------------------------
441 ##newlib_cflags="${newlib_cflags} -nostdinc"
442 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
443 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
446 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
456 default_newlib_io_long_long="yes"
457 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
460 machine_dir=microblaze
486 default_newlib_io_long_long="yes"
487 default_newlib_atexit_dynamic_alloc="no"
491 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
497 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
524 if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
533 # Host specific flag settings -- usually for features that are not
534 # general enough or broad enough to be handled above.
535 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
539 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
541 default_newlib_io_c99_formats="yes"
542 default_newlib_io_long_long="yes"
543 default_newlib_io_long_double="yes"
544 default_newlib_io_pos_args="yes"
545 CC="${CC} -I${cygwin_srcdir}/include"
546 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
549 # RTEMS supplies its own versions of some routines:
550 # malloc() (reentrant version)
551 # exit() RTEMS has a "global" reent to flush
552 # signal()/raise() RTEMS has its own including pthread signals
553 # _XYZ_r() RTEMS has its own reentrant routines
555 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
557 default_newlib_io_long_long="yes"
558 default_newlib_io_c99_formats="yes"
559 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
560 # turn off unsupported items in posix directory
561 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"
563 # VxWorks supplies its own version of malloc, and the newlib one
564 # doesn't work because VxWorks does not have sbrk.
566 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
568 # UDI doesn't have exec, so system() should fail the right way
570 newlib_cflags="${newlib_cflags} -DNO_EXEC"
581 # If newlib is supplying syscalls, select which debug protocol is being used.
582 # ARM_RDP_MONITOR selects the Demon monitor.
583 # ARM_RDI_MONITOR selects the Angel monitor.
584 # If neither are defined, then hard coded defaults will be used
585 # to create the program's environment.
586 # If --disable-newlib-supplied-syscalls is specified, then the end-user
587 # may specify the protocol via gcc spec files supplied by libgloss.
588 # See also thumb below.
589 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
590 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
591 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
595 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
598 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
603 cris-*-* | crisv32-*-*)
604 default_newlib_io_long_long="yes"
605 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE"
609 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
613 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
617 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
622 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
623 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
627 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
635 default_newlib_io_long_long="yes"
639 default_newlib_io_long_long="yes"
640 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
641 # Simulator only extensions for H8300.
642 # Uncomment the next line to enable them.
643 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
647 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
650 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
652 i[34567]86-*-netware*)
653 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
657 default_newlib_io_long_long="yes"
663 default_newlib_io_long_long="yes"
664 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DABORT_PROVIDED"
668 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
669 # We don't generate sda relocs however for upward compatibility.
670 # FIXME: This is necessary because the default multilib doesn't
671 # use --print-multi-lib.
672 newlib_cflags="${newlib_cflags} -msdata=sdata"
675 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
676 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
679 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
686 default_newlib_io_long_long="yes"
687 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DSMALL_MEMORY -D_REENT_SMALL"
690 default_newlib_io_long_long="yes"
691 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
694 default_newlib_io_long_long="yes"
695 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
699 # We need every symbol 32-bit aligned, so the invalid
700 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
701 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
708 default_newlib_io_long_long="yes"
710 powerpc*-*-eabialtivec*)
711 default_newlib_io_long_long="yes"
712 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
715 default_newlib_io_long_long="yes"
716 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
720 powerpc*-*-linux* | \
724 default_newlib_io_long_long="yes"
725 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
728 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
732 default_newlib_io_long_long="yes"
736 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
739 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL"
740 # This either belongs elsewhere or nowhere. But I need *something*,
741 # so for now it's here ...
744 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
746 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
754 # Don't use the debugging protocols just yet.
758 # If newlib is supplying syscalls, select which debug protocol is being used.
759 # ARM_RDP_MONITOR selects the Demon monitor.
760 # ARM_RDI_MONITOR selects the Angel monitor.
761 # If neither are defined, then hard coded defaults will be used
762 # to create the program's environment.
763 # If --disable-newlib-supplied-syscalls is specified, then the end-user
764 # may specify the protocol via gcc spec files supplied by libgloss.
765 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
766 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
767 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
784 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
791 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
792 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
793 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
803 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
808 # Use defaults for certain settings if not specified by user
810 # Enable C99 format support in I/O routines if requested.
811 if [ "x${newlib_io_c99_formats}" = "x" ]; then
812 if [ ${default_newlib_io_c99_formats} = "yes" ]; then
813 newlib_io_c99_formats="yes";
817 # Enable long long support in I/O routines if requested.
818 if [ "x${newlib_io_long_long}" = "x" ]; then
819 if [ ${default_newlib_io_long_long} = "yes" ]; then
820 newlib_io_long_long="yes";
824 # Enable long double support in I/O routines if requested.
825 if [ "x${newlib_io_long_double}" = "x" ]; then
826 if [ ${default_newlib_io_long_double} = "yes" ]; then
827 newlib_io_long_double="yes";
831 # Enable printf positional argument support if requested.
832 if [ "x${newlib_io_pos_args}" = "x" ]; then
833 if [ ${default_newlib_io_pos_args} = "yes" ]; then
834 newlib_io_pos_args="yes";
838 # Disable atexit dynamic allocation if requested.
839 if [ "x${newlib_atexit_dynamic_alloc}" = "x" ]; then
840 if [ ${default_newlib_atexit_dynamic_alloc} = "yes" ]; then
841 newlib_atexit_dynamic_alloc="yes";
845 if test -z "${have_crt0}" && test -n "${sys_dir}"; then