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", "")
26 # It sets the following shell variables:
27 # newlib_cflags Special CFLAGS to use when building
28 # machine_dir Subdirectory of libc/machine to configure
29 # sys_dir Subdirectory of libc/sys to configure
30 # have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
31 # posix_dir "posix" to build libc/posix, "" otherwise
32 # signal_dir "signal" to build libc/signal, "" otherwise
33 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
34 # unix_dir "unix" to build libc/unix, "" otherwise
35 # use_libtool flag: use libtool to build newlib?
36 # aext library extension - needed for libtool support
37 # oext object file extension - needed for libtool support
38 # crt1 name of crt1 object if one is provided
39 # crt1_dir directory where crt1 object is found
57 case "${target_optspace}:${host}" in
59 newlib_cflags="${newlib_cflags} -Os"
61 :m32r-* | :d10v-* | :d30v-* | :avr-*)
62 newlib_cflags="${newlib_cflags} -Os"
65 newlib_cflags="${newlib_cflags} -O2"
69 # Get the source directories to use for the CPU type.
70 # machine_dir should supply CPU dependent routines, such as setjmp.
71 # newlib_cflags is passed to gcc when compiling.
72 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
85 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
110 # Don't use for these since they provide their own setjmp.
112 *-*-go32 | *-*-sco* | *-*-cygwin*)
113 libm_machine_dir=i386
117 libm_machine_dir=i386
130 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
134 newlib_cflags="${newlib_cflags} -m88000"
138 newlib_cflags="${newlib_cflags} -m88110"
165 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
166 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
186 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
190 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
194 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
200 machine_dir=xstormy16
201 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
207 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
212 # Enable multibyte support if requested.
214 if [ "${newlib_mb}" = "yes" ] ; then
215 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
218 # Disable printf/scanf floating-point support if requested.
220 if [ "${newlib_io_float}" = "no" ] ; then
221 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
224 # Verify if shared newlib support is allowed and set appropriate variables
225 # We don't want to use libtool for platforms that we are not going to
226 # support shared libraries. This is because it adds executable tests which
227 # we don't want for most embedded platforms.
229 i[3456]86-pc-linux-*)
231 have_sys_mach_dir=yes
234 *) ;; #shared library not supported for ${host}
237 # Get the source directories to use for the host. unix_dir is set
238 # to unix to get some standard Unix routines. posix_dir is set to get some
239 # standard Posix routines. sys_dir should supply system dependent routines
241 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
252 *-*-rtems*) # generic RTEMS support
254 # RTEMS POSIX support is all inside RTEMS
294 i[3456]86-pc-linux-*)
299 crt1_dir=libc/sys/${sys_dir}
300 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
301 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
302 newlib_cflags="${newlib_cflags} -Wall"
303 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
304 newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
305 # --- Required when building a shared library ------------------------
306 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
307 # --- The three lines below are optional ------------------------------
308 ##newlib_cflags="${newlib_cflags} -nostdinc"
309 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
310 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
374 # Host specific flag settings -- usually for features that are not
375 # general enough or broad enough to be handled above.
376 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
380 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL"
381 # CYGWIN provides its own malloc if --enable-malloc-debugging is set
382 if [ "x${malloc_debugging}" = "xyes" ] ; then
383 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
387 # RTEMS supplies its own versions of some routines:
388 # malloc() (reentrant version)
389 # exit() RTEMS has a "global" reent to flush
390 # signal()/raise() RTEMS has its own including pthread signals
391 # _XYZ_r() RTEMS has its own reentrant routines
393 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
395 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"
397 # VxWorks supplies its own version of malloc, and the newlib one
398 # doesn't work because VxWorks does not have sbrk.
400 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
402 # UDI doesn't have exec, so system() should fail the right way
404 newlib_cflags="${newlib_cflags} -DNO_EXEC"
412 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
413 # Don't use the debugging protocols just yet.
417 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
418 # Select which debug protocol is being used.
419 # ARM_RDP_MONITOR selects the Demon monitor.
420 # ARM_RDI_MONITOR selects the Angel monitor.
421 # If neither are defined, then hard coded defaults will be used
422 # to create the program's environment.
423 # See also thumb below.
424 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
425 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
428 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
431 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
435 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
439 newlib_cflags="${newlib_cflags}"
444 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
448 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
451 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
453 i[3456]86-*-netware*)
454 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
457 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL"
460 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
461 # We don't generate sda relocs however for upward compatibility.
462 # FIXME: This is necessary because the default multilib doesn't
463 # use --print-multi-lib.
464 newlib_cflags="${newlib_cflags} -msdata=sdata"
468 newlib_cflags="${newlib_cflags}"
473 # We need every symbol 32-bit aligned, so the invalid
474 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
475 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
480 powerpc*-*-eabialtivec*)
481 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG"
485 powerpc*-*-linux* | \
489 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
492 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
496 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
500 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
503 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
504 # This either belongs elsewhere or nowhere. But I need *something*,
505 # so for now it's here ...
508 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
510 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
515 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
516 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
520 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
521 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
525 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
526 # Don't use the debugging protocols just yet.
530 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
531 # Select which debug protocol is being used.
532 # ARM_RDP_MONITOR selects the Demon monitor.
533 # ARM_RDI_MONITOR selects the Angel monitor.
534 # If neither are defined, then hard coded defaults will be used
535 # to create the program's environment.
536 # See also arm and strongarm above.
537 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
538 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
554 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
557 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
564 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"