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")
28 # It sets the following shell variables:
29 # newlib_cflags Special CFLAGS to use when building
30 # machine_dir Subdirectory of libc/machine to configure
31 # sys_dir Subdirectory of libc/sys to configure
32 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
33 # posix_dir "posix" to build libc/posix, "" otherwise
34 # signal_dir "signal" to build libc/signal, "" otherwise
35 # stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
36 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
37 # unix_dir "unix" to build libc/unix, "" otherwise
38 # use_libtool flag: use libtool to build newlib?
39 # aext library extension - needed for libtool support
40 # oext object file extension - needed for libtool support
41 # crt1 name of crt1 object if one is provided
42 # crt1_dir directory where crt1 object is found
61 case "${target_optspace}:${host}" in
63 newlib_cflags="${newlib_cflags} -Os"
65 :m32r-* | :d10v-* | :d30v-* | :avr-*)
66 newlib_cflags="${newlib_cflags} -Os"
69 newlib_cflags="${newlib_cflags} -O2"
73 # Get the source directories to use for the CPU type.
74 # machine_dir should supply CPU dependent routines, such as setjmp.
75 # newlib_cflags is passed to gcc when compiling.
76 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
89 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
119 # Don't use for these since they provide their own setjmp.
121 *-*-sco* | *-*-cygwin*)
122 libm_machine_dir=i386
126 libm_machine_dir=i386
141 m68hc11|m6811|m68hc12|m6812)
143 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
149 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
156 newlib_cflags="${newlib_cflags} -m88000"
160 newlib_cflags="${newlib_cflags} -m88110"
187 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
188 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
211 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
215 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
221 machine_dir=xstormy16
222 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
228 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
233 # Disable thread support if requested.
235 if [ "${newlib_multithread}" = "no" ] ; then
236 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
239 # Disable syscall support if requested.
241 if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
242 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
245 # Enable multibyte support if requested or it is defaulted
248 if [ "x${newlib_mb}" = "x" ]; then
250 i[34567]86-pc-linux-*|*-*-cygwin*)
256 if [ "x${newlib_mb}" = "xyes" ] ; then
257 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
260 # Disable printf/scanf floating-point support if requested.
262 if [ "${newlib_io_float}" = "no" ] ; then
263 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
266 # Enable printf positional argument support if requested.
268 if [ "${newlib_io_pos_args}" = "yes" ] ; then
269 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
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
346 i[34567]86-pc-linux-*)
351 crt1_dir=libc/sys/${sys_dir}
352 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
353 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
354 newlib_cflags="${newlib_cflags} -Wall"
355 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
356 newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
357 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS -DWANT_IO_LONG_DBL"
358 # --- Required when building a shared library ------------------------
359 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
360 # --- The three lines below are optional ------------------------------
361 ##newlib_cflags="${newlib_cflags} -nostdinc"
362 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
363 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
366 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
433 # Host specific flag settings -- usually for features that are not
434 # general enough or broad enough to be handled above.
435 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
439 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
441 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_POS_ARGS -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED -I${cygwin_srcdir}/include"
444 # RTEMS supplies its own versions of some routines:
445 # malloc() (reentrant version)
446 # exit() RTEMS has a "global" reent to flush
447 # signal()/raise() RTEMS has its own including pthread signals
448 # _XYZ_r() RTEMS has its own reentrant routines
450 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
452 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DWANT_PRINTF_LONG_LONG -DHAVE_FCNTL"
454 # VxWorks supplies its own version of malloc, and the newlib one
455 # doesn't work because VxWorks does not have sbrk.
457 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
459 # UDI doesn't have exec, so system() should fail the right way
461 newlib_cflags="${newlib_cflags} -DNO_EXEC"
469 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
470 # Don't use the debugging protocols just yet.
474 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
475 # Select which debug protocol is being used.
476 # ARM_RDP_MONITOR selects the Demon monitor.
477 # ARM_RDI_MONITOR selects the Angel monitor.
478 # If neither are defined, then hard coded defaults will be used
479 # to create the program's environment.
480 # See also thumb below.
481 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
482 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
485 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
488 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
492 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
497 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
498 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
501 newlib_cflags="${newlib_cflags}"
506 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG"
510 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
511 # Simulator only extensions for H8300.
512 # Uncomment the next line to enable them.
513 # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
517 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
520 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
522 i[34567]86-*-netware*)
523 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
527 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG"
530 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
531 # We don't generate sda relocs however for upward compatibility.
532 # FIXME: This is necessary because the default multilib doesn't
533 # use --print-multi-lib.
534 newlib_cflags="${newlib_cflags} -msdata=sdata"
537 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
538 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
541 newlib_cflags="${newlib_cflags}"
545 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG -DMISSING_SYSCALL_NAMES"
549 # We need every symbol 32-bit aligned, so the invalid
550 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
551 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
556 powerpc*-*-eabialtivec*)
557 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
560 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
564 powerpc*-*-linux* | \
568 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
571 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
575 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
579 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
582 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
583 # This either belongs elsewhere or nowhere. But I need *something*,
584 # so for now it's here ...
587 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
589 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
594 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
595 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
599 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
600 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
601 newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
605 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
606 # Don't use the debugging protocols just yet.
610 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
611 # Select which debug protocol is being used.
612 # ARM_RDP_MONITOR selects the Demon monitor.
613 # ARM_RDI_MONITOR selects the Angel monitor.
614 # If neither are defined, then hard coded defaults will be used
615 # to create the program's environment.
616 # See also arm and strongarm above.
617 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
618 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
634 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
637 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
644 newlib_cflags="${newlib_cflags} -DNO_EXEC -DMISSING_SYSCALL_NAMES"
648 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"