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
60 default_newlib_io_long_long=no
61 default_newlib_io_long_double=no
62 default_newlib_io_pos_args=no
66 case "${target_optspace}:${host}" in
68 newlib_cflags="${newlib_cflags} -Os"
70 :m32r-* | :d10v-* | :d30v-* | :avr-*)
71 newlib_cflags="${newlib_cflags} -Os"
74 newlib_cflags="${newlib_cflags} -O2"
78 # Get the source directories to use for the CPU type.
79 # machine_dir should supply CPU dependent routines, such as setjmp.
80 # newlib_cflags is passed to gcc when compiling.
81 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
94 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
130 # Don't use for these since they provide their own setjmp.
132 *-*-sco* | *-*-cygwin*)
133 libm_machine_dir=i386
137 libm_machine_dir=i386
152 m68hc11|m6811|m68hc12|m6812)
154 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
160 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
164 newlib_cflags="${newlib_cflags} -m88000"
168 newlib_cflags="${newlib_cflags} -m88110"
181 default_newlib_io_long_long="yes"
196 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
197 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
220 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
224 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
230 machine_dir=xstormy16
231 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
232 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
238 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
243 # Disable thread support if requested.
245 if [ "${newlib_multithread}" = "no" ] ; then
246 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
249 # Disable syscall support if requested.
251 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
252 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
255 # Enable multibyte support if requested or it is defaulted
258 if [ "x${newlib_mb}" = "x" ]; then
260 i[34567]86-pc-linux-*|*-*-cygwin*)
266 # Disable printf/scanf floating-point support if requested.
268 if [ "${newlib_io_float}" = "no" ] ; then
269 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
272 # Verify if shared newlib support is allowed and set appropriate variables
273 # We don't want to use libtool for platforms that we are not going to
274 # support shared libraries. This is because it adds executable tests which
275 # we don't want for most embedded platforms.
277 i[34567]86-pc-linux-*)
279 have_sys_mach_dir=yes
283 *) ;; #shared library not supported for ${host}
286 # Get the source directories to use for the host. unix_dir is set
287 # to unix to get some standard Unix routines. posix_dir is set to get some
288 # standard Posix routines. sys_dir should supply system dependent routines
290 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
301 *-*-rtems*) # generic RTEMS support
303 # RTEMS POSIX support is all inside RTEMS
313 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
327 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
356 i[34567]86-pc-linux-*)
361 crt1_dir=libc/sys/${sys_dir}
362 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
363 default_newlib_io_long_double="yes"
364 default_newlib_io_long_long="yes"
365 default_newlib_io_pos_args="yes"
366 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
367 newlib_cflags="${newlib_cflags} -Wall"
368 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
369 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
370 # --- Required when building a shared library ------------------------
371 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
372 # --- The three lines below are optional ------------------------------
373 ##newlib_cflags="${newlib_cflags} -nostdinc"
374 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
375 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
378 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
408 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
413 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
439 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
448 # Host specific flag settings -- usually for features that are not
449 # general enough or broad enough to be handled above.
450 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
454 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
456 default_newlib_io_long_long="yes"
457 default_newlib_io_long_double="yes"
458 default_newlib_io_pos_args="yes"
459 CC="${CC} -I${cygwin_srcdir}/include"
460 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
463 # RTEMS supplies its own versions of some routines:
464 # malloc() (reentrant version)
465 # exit() RTEMS has a "global" reent to flush
466 # signal()/raise() RTEMS has its own including pthread signals
467 # _XYZ_r() RTEMS has its own reentrant routines
469 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
471 default_newlib_io_long_long="yes"
472 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DHAVE_FCNTL"
474 # VxWorks supplies its own version of malloc, and the newlib one
475 # doesn't work because VxWorks does not have sbrk.
477 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
479 # UDI doesn't have exec, so system() should fail the right way
481 newlib_cflags="${newlib_cflags} -DNO_EXEC"
489 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
493 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
494 # If newlib is supplying syscalls, select which debug protocol is being used.
495 # ARM_RDP_MONITOR selects the Demon monitor.
496 # ARM_RDI_MONITOR selects the Angel monitor.
497 # If neither are defined, then hard coded defaults will be used
498 # to create the program's environment.
499 # If --disable-newlib-supplied-syscalls is specified, then the end-user
500 # may specify the protocol via gcc spec files supplied by libgloss.
501 # See also thumb below.
502 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
503 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
504 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
508 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
511 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
513 cris-*-* | crisv32-*-*)
514 default_newlib_io_long_long="yes"
515 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_GETTIMEOFDAY -D_USE_WRITE -DCOMPACT_CTYPE"
519 newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
523 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
527 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
532 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
533 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
534 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
542 default_newlib_io_long_long="yes"
546 default_newlib_io_long_long="yes"
547 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
548 # Simulator only extensions for H8300.
549 # Uncomment the next line to enable them.
550 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
554 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
557 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
559 i[34567]86-*-netware*)
560 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
564 default_newlib_io_long_long="yes"
567 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
568 # We don't generate sda relocs however for upward compatibility.
569 # FIXME: This is necessary because the default multilib doesn't
570 # use --print-multi-lib.
571 newlib_cflags="${newlib_cflags} -msdata=sdata"
574 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
575 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
581 default_newlib_io_long_long="yes"
582 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
585 default_newlib_io_long_long="yes"
586 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
590 # We need every symbol 32-bit aligned, so the invalid
591 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
592 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
597 powerpc*-*-eabialtivec*)
598 default_newlib_io_long_long="yes"
599 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
602 default_newlib_io_long_long="yes"
603 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
607 powerpc*-*-linux* | \
611 default_newlib_io_long_long="yes"
612 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
615 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
619 default_newlib_io_long_long="yes"
620 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
624 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
627 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
628 # This either belongs elsewhere or nowhere. But I need *something*,
629 # so for now it's here ...
632 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
634 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
639 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
643 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
644 # Don't use the debugging protocols just yet.
648 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
649 # If newlib is supplying syscalls, select which debug protocol is being used.
650 # ARM_RDP_MONITOR selects the Demon monitor.
651 # ARM_RDI_MONITOR selects the Angel monitor.
652 # If neither are defined, then hard coded defaults will be used
653 # to create the program's environment.
654 # If --disable-newlib-supplied-syscalls is specified, then the end-user
655 # may specify the protocol via gcc spec files supplied by libgloss.
656 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
657 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
658 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
675 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
679 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
680 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
681 if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
682 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
686 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
693 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
698 # Use defaults for certain settings if not specified by user
700 # Enable long long support in I/O routines if requested.
701 if [ "x${newlib_io_long_long}" = "x" ]; then
702 if [ ${default_newlib_io_long_long} = "yes" ]; then
703 newlib_io_long_long="yes";
707 # Enable long double support in I/O routines if requested.
708 if [ "x${newlib_io_long_double}" = "x" ]; then
709 if [ ${default_newlib_io_long_double} = "yes" ]; then
710 newlib_io_long_double="yes";
714 # Enable printf positional argument support if requested.
715 if [ "x${newlib_io_pos_args}" = "x" ]; then
716 if [ ${default_newlib_io_pos_args} = "yes" ]; then
717 newlib_io_pos_args="yes";