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
124 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
128 newlib_cflags="${newlib_cflags} -m88000"
132 newlib_cflags="${newlib_cflags} -m88110"
159 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
160 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
180 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
184 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
188 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
194 machine_dir=xstormy16
195 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
201 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
206 # Enable multibyte support if requested.
208 if [ "${newlib_mb}" = "yes" ] ; then
209 newlib_cflags="${newlib_cflags} -DMB_CAPABLE"
212 # Verify if shared newlib support is allowed and set appropriate variables
213 # We don't want to use libtool for platforms that we are not going to
214 # support shared libraries. This is because it adds executable tests which
215 # we don't want for most embedded platforms.
217 i[3456]86-pc-linux-*)
221 *) ;; #shared library not supported for ${host}
224 # Get the source directories to use for the host. unix_dir is set
225 # to unix to get some standard Unix routines. posix_dir is set to get some
226 # standard Posix routines. sys_dir should supply system dependent routines
228 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
239 *-*-rtems*) # generic RTEMS support
241 # RTEMS POSIX support is all inside RTEMS
281 i[3456]86-pc-linux-*)
285 gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
286 #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
287 newlib_cflags="${newlib_cflags} -Wall"
288 newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
289 newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
290 # --- Required when building a shared library ------------------------
291 newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
292 # --- The three lines below are optional ------------------------------
293 ##newlib_cflags="${newlib_cflags} -nostdinc"
294 ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
295 ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
359 # Host specific flag settings -- usually for features that are not
360 # general enough or broad enough to be handled above.
361 # THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
365 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL"
366 # CYGWIN provides its own malloc if --enable-malloc-debugging is set
367 if [ "x${malloc_debugging}" = "xyes" ] ; then
368 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
372 # RTEMS supplies its own versions of some routines:
373 # malloc() (reentrant version)
374 # exit() RTEMS has a "global" reent to flush
375 # signal()/raise() RTEMS has its own including pthread signals
376 # _XYZ_r() RTEMS has its own reentrant routines
378 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
380 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"
382 # VxWorks supplies its own version of malloc, and the newlib one
383 # doesn't work because VxWorks does not have sbrk.
385 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
387 # UDI doesn't have exec, so system() should fail the right way
389 newlib_cflags="${newlib_cflags} -DNO_EXEC"
397 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
398 # Don't use the debugging protocols just yet.
402 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
403 # Select which debug protocol is being used.
404 # ARM_RDP_MONITOR selects the Demon monitor.
405 # ARM_RDI_MONITOR selects the Angel monitor.
406 # If neither are defined, then hard coded defaults will be used
407 # to create the program's environment.
408 # See also thumb below.
409 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
410 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
413 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
416 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
420 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
424 newlib_cflags="${newlib_cflags}"
429 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
433 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
436 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
438 i[3456]86-*-netware*)
439 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
442 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL"
445 # Pass -msdata=sdata so _impure_ptr goes in .sdata.
446 # We don't generate sda relocs however for upward compatibility.
447 # FIXME: This is necessary because the default multilib doesn't
448 # use --print-multi-lib.
449 newlib_cflags="${newlib_cflags} -msdata=sdata"
453 newlib_cflags="${newlib_cflags}"
458 # We need every symbol 32-bit aligned, so the invalid
459 # construct with attribute ((alias ("_ctype_b+127"))) breaks.
460 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
467 powerpc*-*-linux* | \
471 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
474 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
478 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
482 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
485 newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL"
486 # This either belongs elsewhere or nowhere. But I need *something*,
487 # so for now it's here ...
490 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
492 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
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 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
507 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
508 # Don't use the debugging protocols just yet.
512 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY"
513 # Select which debug protocol is being used.
514 # ARM_RDP_MONITOR selects the Demon monitor.
515 # ARM_RDI_MONITOR selects the Angel monitor.
516 # If neither are defined, then hard coded defaults will be used
517 # to create the program's environment.
518 # See also arm and strongarm above.
519 # newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
520 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
536 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
539 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
546 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"