1# configure.host 2 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. 7 8# This shell script should be invoked as 9# . configure.host 10# If it encounters an error, it will exit with a message. 11 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. 15 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. 19 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 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 43 44newlib_cflags= 45libm_machine_dir= 46machine_dir= 47sys_dir= 48posix_dir= 49signal_dir=signal 50stdio64_dir= 51syscall_dir= 52unix_dir= 53mach_add_setjmp= 54crt1= 55crt1_dir= 56use_libtool=no 57have_sys_mach_dir=no 58aext=a 59oext=o 60 61case "${target_optspace}:${host}" in 62 yes:*) 63 newlib_cflags="${newlib_cflags} -Os" 64 ;; 65 :m32r-* | :d10v-* | :d30v-* | :avr-*) 66 newlib_cflags="${newlib_cflags} -Os" 67 ;; 68 no:* | :*) 69 newlib_cflags="${newlib_cflags} -O2" 70 ;; 71esac 72 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. 77 78case "${host_cpu}" in 79 a29k) 80 machine_dir=a29k 81 ;; 82 arc) 83 machine_dir= 84 ;; 85 arm) 86 machine_dir=arm 87 ;; 88 avr*) 89 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues" 90 ;; 91 d10v*) 92 machine_dir=d10v 93 ;; 94 d30v*) 95 machine_dir=d30v 96 ;; 97 ep9312) 98 machine_dir=arm 99 ;; 100 fr30) 101 machine_dir=fr30 102 ;; 103 frv) 104 machine_dir=frv 105 ;; 106 h8300) 107 machine_dir=h8300 108 ;; 109 h8500) 110 machine_dir=h8500 111 ;; 112 hppa*) 113 machine_dir=hppa 114 ;; 115 i960) 116 machine_dir=i960 117 ;; 118 i[34567]86) 119 # Don't use for these since they provide their own setjmp. 120 case ${host} in 121 *-*-sco* | *-*-cygwin*) 122 libm_machine_dir=i386 123 machine_dir=i386 124 ;; 125 *) 126 libm_machine_dir=i386 127 machine_dir=i386 128 mach_add_setjmp=true 129 ;; 130 esac 131 ;; 132 ia64*) 133 ;; 134 iq2000) 135 machine_dir=iq2000 136 ;; 137 m32r*) 138 machine_dir=m32r 139 ;; 140 141 m68hc11|m6811|m68hc12|m6812) 142 machine_dir=m68hc11 143 newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax" 144 CFLAGS="-g -Os" 145 ;; 146 147 m68*) 148 machine_dir=m68k 149 newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE" 150 ;; 151 zpu*) 152 machine_dir=zpu 153 ;; 154 m88k) 155 machine_dir=m88k 156 newlib_cflags="${newlib_cflags} -m88000" 157 ;; 158 m88110) 159 machine_dir=m88k 160 newlib_cflags="${newlib_cflags} -m88110" 161 ;; 162 mcore) 163 ;; 164 mips*) 165 machine_dir=mips 166 ;; 167 mmix) 168 ;; 169 mn10200) 170 machine_dir=mn10200 171 ;; 172 mn10300) 173 machine_dir=mn10300 174 ;; 175 or16) 176 ;; 177 or32) 178 ;; 179 powerpc*) 180 machine_dir=powerpc 181 ;; 182 sh | sh64) 183 machine_dir=sh 184 ;; 185 sparc*) 186 machine_dir=sparc 187 # FIXME: Might wish to make MALLOC_ALIGNMENT more generic. 188 newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8" 189 ;; 190 strongarm) 191 machine_dir=arm 192 ;; 193 xscale) 194 machine_dir=xscale 195 ;; 196 thumb) 197 machine_dir=arm 198 ;; 199 tic4x|c4x) 200 machine_dir=tic4x 201 ;; 202 tic80*) 203 machine_dir=tic80 204 ;; 205 v70) 206 ;; 207 v810) 208 ;; 209 v850) 210 machine_dir=v850 211 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 " 212 ;; 213 v850e) 214 machine_dir=v850 215 newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED " 216 ;; 217 w65*) 218 machine_dir=w65 219 ;; 220 xstormy16) 221 machine_dir=xstormy16 222 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED" 223 ;; 224 z8k) 225 machine_dir=z8k 226 ;; 227 *) 228 echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2 229 exit 1 230 ;; 231esac 232 233# Disable thread support if requested. 234 235if [ "${newlib_multithread}" = "no" ] ; then 236 newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__" 237fi 238 239# Disable syscall support if requested. 240 241if [ "${newlib_may_supply_syscalls}" = "no" ] ; then 242 newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__" 243fi 244 245# Enable multibyte support if requested or it is defaulted 246# for target. 247 248if [ "x${newlib_mb}" = "x" ]; then 249 case "${host}" in 250 i[34567]86-pc-linux-*|*-*-cygwin*) 251 newlib_mb=yes 252 ;; 253 esac 254fi 255 256if [ "x${newlib_mb}" = "xyes" ] ; then 257 newlib_cflags="${newlib_cflags} -DMB_CAPABLE" 258fi 259 260# Disable printf/scanf floating-point support if requested. 261 262if [ "${newlib_io_float}" = "no" ] ; then 263 newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT" 264fi 265 266# Enable printf positional argument support if requested. 267 268if [ "${newlib_io_pos_args}" = "yes" ] ; then 269 newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS" 270fi 271 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. 276case "${host}" in 277 i[34567]86-pc-linux-*) 278 use_libtool=yes 279 have_sys_mach_dir=yes 280 stdio64_dir=stdio64 281 oext=lo 282 aext=la ;; 283 *) ;; #shared library not supported for ${host} 284esac 285 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 289# including crt0. 290# THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY. 291 292case "${host}" in 293 *-*-cygwin*) 294 posix_dir=posix 295 stdio64_dir=stdio64 296 ;; 297 *-*-netware*) 298 signal_dir= 299 sys_dir=netware 300 ;; 301 *-*-rtems*) # generic RTEMS support 302 sys_dir=rtems 303 # RTEMS POSIX support is all inside RTEMS 304 ;; 305 a29k-*-*) 306 sys_dir=a29khif 307 signal_dir= 308 ;; 309 arc-*-*) 310 sys_dir=arc 311 ;; 312 arm-*-*) 313 sys_dir=arm 314 ;; 315 d10v*) 316 sys_dir=d10v 317 ;; 318 d30v*) 319 sys_dir= 320 ;; 321 ep9312-*-*) 322 sys_dir=arm 323 ;; 324 h8300-*-hms*) 325 sys_dir=h8300hms 326 ;; 327 h8300-*-elf*) 328 sys_dir=h8300hms 329 ;; 330 h8300-*-coff*) 331 sys_dir=h8300hms 332 ;; 333 h8300-*-xray*) 334 sys_dir=h8300xray 335 ;; 336 h8500-*-hms*) 337 sys_dir=h8500hms 338 ;; 339 h8500-*-elf*) 340 sys_dir=h8500hms 341 ;; 342 i[34567]86-*-sco*) 343 sys_dir=sysvi386 344 unix_dir=unix 345 ;; 346 i[34567]86-pc-linux-*) 347 sys_dir=linux 348 unix_dir=unix 349 posix_dir=posix 350 crt1=crt1.o 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" 364 ;; 365 366 m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*) 367 ;; 368 369 m68k-sun-sunos*) 370 unix_dir=unix 371 ;; 372 m8*-bug-*) 373 sys_dir=m88kbug 374 ;; 375 mips*-dec-*) 376 sys_dir=decstation 377 ;; 378 mmix-knuth-mmixware) 379 sys_dir=mmixware 380 ;; 381 powerpcle-*-pe) 382 posix_dir=posix 383 ;; 384 sh*-*) 385 sys_dir=sh 386 ;; 387 sparc-sun-sunos*) 388 sys_dir=sun4 389 unix_dir=unix 390 ;; 391 sparc64*) 392 sys_dir=sparc64 393 unix_dir=unix 394 ;; 395 strongarm-*-*) 396 sys_dir=arm 397 ;; 398 xscale-*-*) 399 sys_dir=arm 400 ;; 401 thumb-*-*) 402 sys_dir=arm 403 ;; 404 tic80*) 405 sys_dir=tic80 406 ;; 407 v70-nec-*) 408 sys_dir=sysvnecv70 409 ;; 410 v810-*-*) 411 sys_dir=sysnec810 412 ;; 413 v850-*-*) 414 sys_dir=sysnecv850 415 ;; 416 v850e-*-*) 417 sys_dir=sysnecv850 418 ;; 419 v850ea-*-*) 420 sys_dir=sysnecv850 421 ;; 422 frv*) 423 sys_dir= 424 ;; 425 w65-*-*) 426 sys_dir=w65 427 ;; 428 z8k-*-coff) 429 sys_dir=z8ksim 430 ;; 431esac 432 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. 436 437case "${host}" in 438 *-*-cygwin*) 439 test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd` 440 export cygwin_srcdir 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" 442 syscall_dir=syscalls 443 ;; 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 449# 450# NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that. 451 *-*-rtems*) 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" 453 ;; 454# VxWorks supplies its own version of malloc, and the newlib one 455# doesn't work because VxWorks does not have sbrk. 456 *-wrs-vxworks*) 457 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL" 458 ;; 459# UDI doesn't have exec, so system() should fail the right way 460 a29k-amd-udi) 461 newlib_cflags="${newlib_cflags} -DNO_EXEC" 462 syscall_dir=syscalls 463 ;; 464 arc-*-*) 465 syscall_dir=syscalls 466 ;; 467 arm-*-pe) 468 syscall_dir=syscalls 469 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY" 470# Don't use the debugging protocols just yet. 471 ;; 472 arm-*-*) 473 syscall_dir=syscalls 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" 483 ;; 484 avr*) 485 newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES" 486 ;; 487 d10v*) 488 newlib_cflags="${newlib_cflags} -DSMALL_MEMORY" 489 syscall_dir=syscalls 490 ;; 491 d30v*) 492 newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES" 493 syscall_dir= 494 ;; 495 ep9312-*-*) 496 syscall_dir=syscalls 497 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY" 498 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR" 499 ;; 500 fr30-*-*) 501 newlib_cflags="${newlib_cflags}" 502 syscall_dir=syscalls 503 ;; 504 frv-*-*) 505 syscall_dir=syscalls 506 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG" 507 ;; 508 h8300*-*-*) 509 syscall_dir=syscalls 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__" 514 ;; 515 h8500-*-*) 516 syscall_dir=syscalls 517 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY" 518 ;; 519 i[34567]86-*-sco*) 520 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL" 521 ;; 522 i[34567]86-*-netware*) 523 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL" 524 ;; 525 iq2000*) 526 syscall_dir=syscalls 527 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG" 528 ;; 529 m32r-*-*) 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" 535 syscall_dir=syscalls 536 ;; 537 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*) 538 newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES" 539 ;; 540 mcore-*-*) 541 newlib_cflags="${newlib_cflags}" 542 syscall_dir=syscalls 543 ;; 544 mips64vr*-*-*) 545 newlib_cflags="${newlib_cflags} -DWANT_PRINTF_LONG_LONG -DMISSING_SYSCALL_NAMES" 546 ;; 547 mmix-*) 548 syscall_dir=syscalls 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" 552 ;; 553 mn10?00-*-*) 554 syscall_dir=syscalls 555 ;; 556 powerpc*-*-eabialtivec*) 557 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG" 558 ;; 559 powerpc*-*-eabispe*) 560 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG" 561 ;; 562 powerpc*-*-eabi* | \ 563 powerpc*-*-elf* | \ 564 powerpc*-*-linux* | \ 565 powerpc*-*-rtem* | \ 566 powerpc*-*-sysv* | \ 567 powerpc*-*-solaris*) 568 newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES -DWANT_PRINTF_LONG_LONG" 569 ;; 570 powerpcle-*-pe) 571 newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL" 572 syscall_dir=syscalls 573 ;; 574 sh*-*-*) 575 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG" 576 syscall_dir=syscalls 577 ;; 578 sparc-sun-sunos*) 579 newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED" 580 ;; 581 sparc64-*-*) 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 ... 585 case "${host_os}" in 586 aoutv8 | *32p) 587 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;; 588 *) 589 newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;; 590 esac 591 ;; 592 strongarm-*-*) 593 syscall_dir=syscalls 594 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY" 595 newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR" 596 ;; 597 xscale-*-*) 598 syscall_dir=syscalls 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" 602 ;; 603 thumb-*-pe) 604 syscall_dir=syscalls 605 newlib_cflags="${newlib_cflags} -DABORT_PROVIDED -DHAVE_GETTIMEOFDAY" 606# Don't use the debugging protocols just yet. 607 ;; 608 thumb-*-*) 609 syscall_dir=syscalls 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" 619 ;; 620 tic80*) 621 syscall_dir=syscalls 622 ;; 623 v850-*-*) 624 syscall_dir=syscalls 625 ;; 626 v850e-*-*) 627 syscall_dir=syscalls 628 ;; 629 v850ea-*-*) 630 syscall_dir=syscalls 631 ;; 632 w65-*-*) 633 syscall_dir=syscalls 634 newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY" 635 ;; 636 xstormy16-*-*) 637 newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY" 638 syscall_dir=syscalls 639 ;; 640 z8k-*-*) 641 syscall_dir=syscalls 642 ;; 643 zpu-*-*) 644 newlib_cflags="${newlib_cflags} -DNO_EXEC -DMISSING_SYSCALL_NAMES" 645 syscall_dir= 646 ;; 647 *) 648 newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES" 649 syscall_dir= 650 ;; 651esac 652