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 # posix_dir "posix" to build libc/posix, "" otherwise
31 # signal_dir "signal" to build libc/signal, "" otherwise
32 # syscall_dir "syscalls" to build libc/syscalls, "" otherwise
33 # unix_dir "unix" to build libc/unix, "" otherwise
34 # use_libtool flag: use libtool to build newlib?
35 # aext library extension - needed for libtool support
36 # oext object file extension - needed for libtool support
51 case "${target_optspace}:${host}" in
53 newlib_cflags="${newlib_cflags} -Os"
55 :m32r-* | :d10v-* | :d30v-* | :avr-*)
56 newlib_cflags="${newlib_cflags} -Os"
59 newlib_cflags="${newlib_cflags} -O2"
63 # Get the source directories to use for the CPU type.
64 # machine_dir should supply CPU dependent routines, such as setjmp.
65 # newlib_cflags is passed to gcc when compiling.
66 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
79 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
104 # Don't use for these since they provide their own setjmp.
106 *-*-go32 | *-*-sco* | *-*-cygwin*)
107 libm_machine_dir=i386
111 libm_machine_dir=i386
127 newlib_cflags="${newlib_cflags} -m88000"
131 newlib_cflags="${newlib_cflags} -m88110"
158 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
159 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
179 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
183 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
187 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
196 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
201 # Enable multibyte support if requested.
203 if [ "${newlib_mb}" = "yes" ] ; then
204 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
207 # Verify if shared newlib support is allowed and set appropriate variables
208 # We don't want to use libtool for platforms that we are not going to
209 # support shared libraries. This is because it adds executable tests which
210 # we don't want for most embedded platforms.
212 i[3456]86-pc-linux-*)
216 *) ;; #shared library not supported for ${host}
219 # Get the source directories to use for the host. unix_dir is set
220 # to unix to get some standard Unix routines. posix_dir is set to get some
221 # standard Posix routines. sys_dir should supply system dependent routines
223 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
234 *-*-rtems*) # generic RTEMS support
236 # RTEMS POSIX support is all inside RTEMS
276 i[3456]86-pc-linux-*)
280 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
281 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
282 newlib_cflags="${newlib_cflags} -Wall"
283 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
284 newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
285 # --- Required when building a shared library ------------------------
286 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
287 # --- The three lines below are optional ------------------------------
288 ##newlib_cflags="${newlib_cflags} -nostdinc"
289 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
290 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
354 # Host specific flag settings -- usually for features that are not
355 # general enough or broad enough to be handled above.
356 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
360 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL"
361 # CYGWIN provides its own malloc if --enable-malloc-debugging is set
362 if [ "x${malloc_debugging}" = "xyes" ] ; then
363 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
367 # RTEMS supplies its own versions of some routines:
368 # malloc() (reentrant version)
369 # exit() RTEMS has a "global" reent to flush
370 # signal()/raise() RTEMS has its own including pthread signals
371 # _XYZ_r() RTEMS has its own reentrant routines
373 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
375 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"
377 # VxWorks supplies its own version of malloc, and the newlib one
378 # doesn't work because VxWorks does not have sbrk.
380 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
382 # UDI doesn't have exec, so system() should fail the right way
384 newlib_cflags="${newlib_cflags} -DNO_EXEC"
392 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
393 # Don't use the debugging protocols just yet.
397 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
398 # Select which debug protocol is being used.
399 # ARM_RDP_MONITOR selects the Demon monitor.
400 # ARM_RDI_MONITOR selects the Angel monitor.
401 # If neither are defined, then hard coded defaults will be used
402 # to create the program's environment.
403 # See also thumb below.
404 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
405 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
408 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
411 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
415 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
419 newlib_cflags="${newlib_cflags}"
424 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
428 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
431 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
433 i[3456]86-*-netware*)
434 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
437 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL"
440 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
441 # We don't generate sda relocs however for upward compatibility.
442 # FIXME: This is necessary because the default multilib doesn't
443 # use --print-multi-lib.
444 newlib_cflags="${newlib_cflags} -msdata=sdata"
448 newlib_cflags="${newlib_cflags}"
453 # We need every symbol 32-bit aligned, so the invalid
454 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
455 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
462 powerpc*-*-linux* | \
466 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
469 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
473 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
477 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
480 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
481 # This either belongs elsewhere or nowhere. But I need *something*,
482 # so for now it's here ...
485 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
487 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
492 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
493 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
497 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
498 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
502 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
503 # Don't use the debugging protocols just yet.
507 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
508 # Select which debug protocol is being used.
509 # ARM_RDP_MONITOR selects the Demon monitor.
510 # ARM_RDI_MONITOR selects the Angel monitor.
511 # If neither are defined, then hard coded defaults will be used
512 # to create the program's environment.
513 # See also arm and strongarm above.
514 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
515 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
531 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
537 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"