Set required version to 2.
[AROS.git] / configure.in
blobdb02bd7735f67401531b1818eec6374d90df9fe9
1 dnl Copyright © 1997-2016, The AROS Development Team. All rights reserved.
2 dnl $Id$
3 dnl
4 dnl Desc: Autoconf source for configuration file
5 dnl Lang: english 
7 # Note: After file changes, generate configure anew and commit _both_ files.
9 #TODO
10 # method of getting shared/non-shared ld/ar tool for target.
12 # ------------------------------------------------------------------------
13 # Here starts the first section of the configure.in file.
14 # ------------------------------------------------------------------------
16 AC_INIT(mmakefile)
17 AC_PREREQ(2.61)
18 AC_CONFIG_AUX_DIR(scripts/autoconf)
20 # Check what host we are running on.
21 # If a target is not suggested, we use this one.
22 # Note that what we call a target, Autoconf calls a host.
23 AC_CANONICAL_HOST
25 # Default versions for the gnu tools we build
26 default_gcc_version="4.6.4"
27 default_binutils_version="2.23.2"
29 # The AROS target is slightly different to the normal GNU style
30 # format. We don't have the middle part, and we reverse the order
31 # of the $(CPU) and $(OS) bits.
33 # Don't strip the version of the target yet, it might be
34 # useful on some systems.
36 AC_MSG_CHECKING([for AROS style target])
38 if test "$target" = "NONE" ; then
39     target=$host_os-$host_cpu
40 else
41     if test "$target" = "" ; then
42         target=$host_os-$host_cpu
43     fi
45 AC_MSG_RESULT($target)
47 if test "$host_os" = "mingw32" ; then
48     PWDCMD="pwd -W"
51 # Don't know where else to put this...
52 AC_MSG_CHECKING([building AROS in])
53 AROS_BUILDDIR=`${PWDCMD-pwd}`
54 AROS_BUILDDIR_UNIX=${PWD}
55 AC_MSG_RESULT($AROS_BUILDDIR)
57 AC_MSG_CHECKING([AROS source in])
58 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
59 SRCDIR=${srcpwd}
60 AC_MSG_RESULT($SRCDIR)
62 # Parse the target field into something useful.
63 changequote(<<,>>)
64 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
65 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
66 changequote([,])
68 # Some debug output, to be removed again.
69 AC_MSG_CHECKING([for target system (debug output)])
70 AC_MSG_RESULT($target_os)
71 AC_MSG_CHECKING([for target cpu (debug output)])
72 AC_MSG_RESULT($target_cpu)
74 dnl --------------------------------------------------------------------
75 dnl Set the default Workbench resolution
76 dnl --------------------------------------------------------------------
77 aros_nominal_width=800
78 aros_nominal_height=600
79 aros_nominal_depth=4
81 dnl --------------------------------------------------------------------
82 dnl Host Configuration Section
83 dnl --------------------------------------------------------------------
84 dnl
85 dnl The idea here is to find out all the information we need about the
86 dnl host. This means things like tools for building directory structures,
87 dnl copying files around and the like.
89 default_c_compilers="gcc clang cc"
90 AC_ARG_WITH(c-compiler,AC_HELP_STRING([--with-c-compiler=VERSION],[Use specified c compiler for building AROS]),use_c_compiler="$withval",use_c_compiler="")
91 if test "$use_c_compiler" = ""; then
92     host_c_compilers="$default_c_compilers"
93 else
94     host_c_compilers="$use_c_compiler"
97 default_cxx_compilers="g++ clang++ c++"
98 AC_ARG_WITH(cxx-compiler,AC_HELP_STRING([--with-cxx-compiler=VERSION],[Use specified c++ compiler building AROS]),use_cxx_compiler="$withval",use_cxx_compiler="")
99 if test "$use_cxx_compiler" = ""; then
100         host_cxx_compilers="$default_cxx_compilers"
101 else
102     host_cxx_compilers="$use_cxx_compiler"
106 # The first step is to find the host binaries.
107 # Check for a compiler.
108 # Due to a bug in autoconf check for c++ compiler first.
109 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
110 AC_PROG_CXX([${host_cxx_compilers}])
111 AC_PROG_CC([${host_c_compilers}])
112 aros_host_def_cc="$CC"
113 AC_PROG_CC_STDC
114 AC_PROG_CPP
116 # Check for a compatible awk
117 AC_CHECK_PROGS(AWK,[gawk nawk])
118 AROS_REQUIRED(gawk,$AWK)
119 AROS_PROG(MMAKE,mmake)
121 # Perform some default variable assignments. Note all of these will be
122 # Regenerated from the script, so there is no need to cache them.
124 aros_build_host=$host
125 aros_host_cpp="$CPP"
126 aros_host_cc="$CC"
127 aros_host_cxx="$CXX"
128 AROS_TOOL_CCPATH(aros_host_ld,ld)
129 AROS_REQUIRED(ld,$aros_host_ld)
130 aros_host_make="make"
131 aros_host_cflags="$CFLAGS"
132 aros_host_cxxflags="$CXXFLAGS"
133 aros_host_ldflags="$LDFLAGS"
134 aros_host_debug="-g -O0"
135 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
136 aros_host_mkargs="--no-print-directory"
137 aros_host_exe_suffix="$EXEEXT"
138 aros_host_lib_suffix=""
140 # Ignore all compliance, AROS ROMs = 0
141 # KickStart v1.0 = 30
142 # KickStart v1.3 = 34
143 # KickStart v2.0 = 37
144 # KickStart v3.0 = 39
145 # KickStart v3.1 = 40
146 # AmigaOS   v3.5 = 44
147 aros_amigaos_compliance=0
149 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
150 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
151 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
152 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
154 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
155 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
157 case "$aros_host_cc" in
158     *clang*)
159         aros_host_cc_pipe=""
160         ;;
161     *gcc*)
162         aros_host_cc_pipe="-pipe"
163         ;;
164     icc)
165         aros_host_cc_pipe=""
166         ;;
167     *)
168         aros_host_cc_pipe=""
169         ;;
170 esac
172 aros_kernel_cc_includes=""
173 aros_target_cc_includes=""
174 host_cc_elf=yes
176 # ----------------------------------------------------------------------------------------
177 # Host-specific defaults
179 # This is the main host configuration section. It is where the host
180 # can change the values of any variables it needs to change. We do
181 # not look at anything that compiles to the target yet, we'll get
182 # to that later.
184 case "$host_os" in
185     aros*)
186         aros_host_arch="aros"
187         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
188         case "$host_cpu" in
189             *i?86*)
190                 aros_host_cpu="i386"
191                 ;;
192             *x86_64*)
193                 aros_host_cpu="x86_64"
194                 ;;
195             *powerpc*)
196                 aros_host_cpu="ppc"
197                 ;;
198             *)
199                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
200                 aros_host_cpu="$host_cpu"
201                 ;;
202         esac
203         ;;
205     linux*)
206         aros_host_arch="linux"
207         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
208         android_build_os="linux-x86"
209         android_tool="android"
210         default_android_sdk="/opt/android-sdk-linux_x86"
211         case "$host_cpu" in
212             *i?86*)
213                 aros_host_cpu="i386"
214                 ;;
215             *x86_64*)
216                 aros_host_cpu="x86_64"
217                 ;;
218             *m68k*)
219                 aros_host_cpu="m68k"
220                 ;;
221             *powerpc*)
222                 aros_host_cpu="ppc"
223                 ;;
224             *arm*)
225                 aros_host_cpu="arm"
226                 ;;
227             *)
228                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
229                 aros_host_cpu="$host_cpu"
230                 ;;
231         esac
232         ;;
234     freebsd*)
235         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe -I/usr/local/include"
236         aros_host_make="gmake"
237         aros_host_arch="freebsd"
238         aros_host_cpu="i386"
240         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
242         dnl FreeBSD 5.x (and later) has changed the default object format.
243         dnl The double [[]] is necessary to get around m4's quoting rules.
244         case $host_os in
245             freebsd[[234]]*)
246                 aros_object_format="elf_i386"
247                 ;;
249             *)
250                 aros_object_format="elf_i386_fbsd"
251                 ;;
252         esac
254         ;;
256     darwin*)
257         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
258         aros_host_arch="darwin"
259         host_cc_elf=no
260         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
261         android_build_os="darwin-x86"
262         android_tool="android"
263         default_android_sdk="/android-sdk-mac_x86"
264         case "$host_cpu" in
265             *i?86*)
266                 aros_host_cpu="i386"
267                 ;;
268             *x86_64*)
269                 aros_host_cpu="x86_64"
270                 ;;
271             *powerpc*)
272                 aros_host_cpu="ppc"
273                 ;;
274             *)
275                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
276                 aros_host_cpu="$host_cpu"
277                 ;;
278         esac
280         aros_host_ldflags="$aros_host_ldflags -liconv"
282         ;;
284     dragonfly*)
285         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
286         aros_host_make="gmake"
287         aros_host_arch="dragonfly"
288         case $host_cpu in
289             *i?86*)
290                 aros_host_cpu="i386"
291                 ;;
292             *amd64*)
293                 aros_host_cpu="x86_64"
294                 ;;
295             *)
296                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
297                 aros_host_cpu="$host_cpu"
298                 ;;
299         esac
300         ;;
302     netbsd*)
303         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
304         aros_host_make="gmake"
305         aros_host_arch="netbsd"
306         case "$host_cpu" in
307             *i?86*)
308                 aros_host_cpu="i386"
309                 ;;
310             *m68k*)
311                 aros_host_cpu="m68k"
312                 ;;
313             *)
314                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
315                 aros_host_cpu="$host_cpu"
316                 ;;
317         esac    
318         aros_host_lib_suffix=".0.0"
319         ;;
321     openbsd*)
322         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
323         aros_host_make="gmake"
324         aros_host_arch="openbsd"
325         case "$host_cpu" in
326             *i?86*)
327                 aros_host_cpu="i386"
328                 ;;
329             *)
330                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
331                 aros_host_cpu="$host_cpu"
332                 ;;
333         esac
334         ;;
335         
336     solaris*)
337         aros_host_arch="solaris"
338         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
339         case "$host_cpu" in
340             *i?86*)
341                 aros_host_cpu="i386"
342                 ;;
343             *sparc*)
344                 aros_host_cpu="sparc"
345                 ;;
346             *)
347                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
348                 aros_host_cpu="$host_cpu"
349                 ;;
350         esac
351         ;;
353     morphos*)
354         aros_host_arch="morphos"
355         aros_host_cpu="ppc"
356         host_cc_elf=no
357         ;;
359     amiga*)
360         aros_host_arch="amiga"
361         host_cc_elf=no
362         SORT="/gg/bin/sort"
363         TEST="/gg/bin/test"
364         UNIQ="/gg/bin/uniq"
365         FOR="for"
366         TOUCH="/gg/bin/touch"
367         case "$host_cpu" in
368             *m68k*)
369                 aros_host_cpu="m68k"
370                 ;;
371             *powerpc*)
372                 aros_host_cpu="ppc"
373                 ;;
374             *)
375                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
376                 aros_host_cpu="$host_cpu"
377                 ;;
378         esac
379         ;;
381     cygwin*)
382         aros_host_arch="cygwin"
383         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
384         host_cc_elf=no
385         android_build_os="windows"
386         android_tool="android.bat"
387         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
389         case "$host_cpu" in
390             *i?86*)
391                 aros_host_cpu="i386"
392                 ;;
393             *)
394                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
395                 aros_host_cpu="$host_cpu"
396                 ;;
397         esac
398         ;;
400     mingw32*)
401         aros_host_arch="mingw32"
402         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
403         host_cc_elf=no
404         android_build_os="windows"
405         android_tool="android.bat"
406         default_android_sdk="/c/android-sdk-windows-1.6_r1"
408         case "$host_cpu" in
409         *i?86*)
410             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
411             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
412             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
413             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
415             AC_MSG_CHECKING([for Windows native gcc target])
416             host_cpu=`gcc -dumpmachine`
417             AC_MSG_RESULT($host_cpu)
418             ;;
420         esac
422         case "$host_cpu" in
423         *i?86*)
424             aros_host_cpu="i386"
425             ;;
427         mingw32*)
428             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
429             aros_host_cpu="i386"
430             ;;
432         *x86_64*)
433             aros_host_cpu="x86_64"
434             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
435             dnl directory, so we have to add it explicitly here.
436             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
437             ;;
439         *)
440             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
441             aros_host_cpu="$host_cpu"
442             ;;
443         esac
444         ;;
445     *)
446         AC_MSG_ERROR([Unsupported host architecture $host])
447         ;;
448 esac
450 AROS_PROG(aros_host_ar,[ar],[cr])
451 AROS_REQUIRED(ar,$aros_host_ar)
452 AROS_PROG(aros_host_ranlib,ranlib)
453 AROS_REQUIRED(ranlib,$aros_host_ranlib)
454 AROS_PROG(aros_host_strip,strip)
455 AROS_REQUIRED(strip,$aros_host_strip)
457 AROS_PROG(RM,[rm],[-rf])
458 AROS_REQUIRED(rm,$RM)
459 AROS_PROG(CP,[cp])
460 AROS_REQUIRED(cp,$CP)
461 AROS_PROG(MV,[mv])
462 AROS_REQUIRED(mv,$MV)
463 AROS_PROG(ECHO,[echo])
464 AROS_REQUIRED(echo,$ECHO)
465 AROS_PROG(MKDIR,[mkdir],[-p])
466 AROS_REQUIRED(mkdir,$MKDIR)
467 AROS_PROG(TOUCH,[touch])
468 AROS_REQUIRED(touch,$TOUCH)
469 AROS_PROG(SORT,[sort])
470 AROS_REQUIRED(sort,$SORT)
471 AROS_PROG(UNIQ,[uniq])
472 AROS_REQUIRED(uniq,$UNIQ)
473 AROS_PROG(NOP,[true])
474 AROS_REQUIRED(true,$NOP)
475 AROS_PROG(CAT,[cat])
476 AROS_REQUIRED(cat,$CAT)
477 AROS_PROG(BISON,[bison])
478 AROS_REQUIRED(bison,$BISON)
479 AROS_PROG(FLEX,[flex])
480 AROS_REQUIRED(flex,$FLEX)
481 AROS_PROG(PNGTOPNM,[pngtopnm])
482 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
483 AROS_PROG(PPMTOILBM,[ppmtoilbm])
484 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
485 AROS_PROG(SED,[sed])
486 AROS_REQUIRED(sed,$SED)
487 AROS_PROG(CHMOD,[chmod])
488 AROS_REQUIRED(chmod,$CHMOD)
489 AROS_PROG(PATCH,[patch])
490 AROS_REQUIRED(patch,$PATCH)
492 AM_PATH_PYTHON(2.5)
494 AC_CHECK_LIB(png, png_read_png, [libpng="png"], 
495      [AC_CHECK_LIB(png16, png_read_png, [libpng="png16"], [libpng="no"])])
496 AROS_REQUIRED(libpng, $libpng)
497 AC_SUBST(libpng)
499 AC_SUBST(FOR, for)
500 AC_SUBST(IF, if)
501 AC_SUBST(TEST, test)
502 AC_SUBST(CMP, cmp)
504 dnl ---------------------------------------------------------------------------
505 dnl Look for things about the host system, good for hosted targets.
506 dnl ---------------------------------------------------------------------------
508 # Check for some includes for the X11 HIDD and the kernel
509 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
510     sys/mmap.h sys/mman.h sysexits.h \
511     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
514 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
516 AC_HEADER_DIRENT
517 AC_HEADER_STAT
518 AC_HEADER_STDC
519 AC_HEADER_SYS_WAIT
520 AC_HEADER_TIME
521 AC_STRUCT_ST_BLKSIZE
522 AC_STRUCT_ST_BLOCKS
523 AC_STRUCT_ST_RDEV
524 AC_STRUCT_TM
525 AC_STRUCT_TIMEZONE
526 AC_TYPE_OFF_T
527 AC_TYPE_PID_T
528 AC_TYPE_SIZE_T
529 AC_TYPE_UID_T
531 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
533 # Look for some functions
534 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
535     clone kse_create rfork_thread thr_create sa_register \
536     getcontext makecontext setcontext sigaltstack swapcontext])
538 AC_FUNC_MMAP
540 #-----------------------------------------------------------------------------
543 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
544 # it switched on by default, and we use the host compiler, so it compiles AROS
545 # code with this enabled resulting in link failures as we don't have support
546 # for it.
548 # We use two methods to disable it. For the host compiler (used to compile
549 # some hosted modules), we test to see if the compiler supports stack
550 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
551 # work on all platforms.
553 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
554 # (this is done unconditionally, as it should have no effect on compilers
555 # without the stack protection feature). This may be specific to the way that
556 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
557 # strong enough to disable it in a generic way though, so we'll live with it
558 # until another vendor ships GCC with it enabled in a different way, and deal
559 # with it then.
562 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
563 save_cflags="$CFLAGS"
564 CFLAGS="$CFLAGS -fno-stack-protector"
565 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
566 AC_MSG_RESULT($use_no_stack_protector)
567 if test "x-$use_no_stack_protector" = "x-yes" ; then
568     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
570 CFLAGS="$save_cflags"
572 #-----------------------------------------------------------------------------
574 # Disable pointer-signedness warnings if the compiler recognises the option
575 # (this only works for the host compiler at the moment)
577 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
578 save_cflags="$CFLAGS"
579 CFLAGS="$CFLAGS -Wno-pointer-sign"
580 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
581 AC_MSG_RESULT($use_no_sign_warning)
582 if test "x-$use_no_sign_warning" = "x-yes" ; then
583     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
585 CFLAGS="$save_cflags"
587 #-----------------------------------------------------------------------------
589 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
591 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
592 save_cflags="$CFLAGS"
593 CFLAGS="$CFLAGS -fgnu89-inline"
594 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
595 AC_MSG_RESULT($use_gnu89_inline)
596 if test "x-$use_gnu89_inline" = "x-yes" ; then
597     gnu89_inline="-fgnu89-inline"
599 CFLAGS="$save_cflags"
601 AC_MSG_NOTICE([Performing target configuration...])
603 dnl --------------------------------------------------------------------
604 dnl Target Configuration Section
605 dnl --------------------------------------------------------------------
607 dnl The target configuration section is responsible for setting up all
608 dnl the paths for includes, and tools required to build AROS to some
609 dnl particular target.
611 aros_nowarn_flags="NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
613 toolchain_needs_sysroot=no
615 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
616 aros_config_aflags="-Wall -x assembler-with-cpp -c"
617 aros_config_ldflags=""
619 aros_shared_default=yes
621 aros_shared_cflags="-fPIC"
622 aros_shared_aflags=""
623 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
624 aros_kernel_ldflags="-Wl,-rpath,./lib"
626 aros_kernel_ar_flags="cr"
627 aros_target_ar_flags="cr"
628 aros_target_nm_flags="-C -ul"
629 aros_target_strip_flags="--strip-unneeded -R.comment"
631 aros_compiler_libs=
632 aros_arch_libs=
634 aros_target_genmap="-Wl,-Map -Xlinker"
636 # Native flavour stuff
637 aros_serial_debug="0"
639 # Palm native flavour stuff
640 aros_palm_debug_hack="0"
642 # Unix flavour stuff
643 aros_nesting_supervisor="0"
645 # Collect-aros stuff: "-ius" to ignore undefined symbols
646 ignore_undefined_symbols=""
648 # Check for X11 by default
649 need_x11="auto"
651 host_x_gfx=no
652 host_sdl_gfx=no
653 host_android_gfx=no
656 AC_MSG_CHECKING([Which toolchain family to use ...])
657 AC_ARG_WITH(toolchain,AC_HELP_STRING([--with-toolchain=family],[Which toolchain family to crosscompile with (defaults to gnu)]),aros_toolchain="$withval",aros_toolchain="gnu")
658 AC_MSG_RESULT($aros_toolchain)
660 case "$aros_toolchain" in
661     *llvm*)
662         # toolchain_needs_sysroot=yes
663         toolchain_c_compiler="clang"
664         toolchain_cxx_compiler="clang++"
665         toolchain_cpp_preprocessor="clang -E"
666         toolchain_ld="lld"
667         toolchain_as="llvm-as"
668         toolchain_ar="llvm-ar"
669         toolchain_ranlib="llvm-ranlib"
670         toolchain_nm="llvm-nm"
671         toolchain_strip="true"
672         toolchain_objcopy="llvm-objcopy"
673         toolchain_objdump="llvm-objdump"
674         ;;
675     *gnu*)
676         toolchain_c_compiler="gcc"
677         toolchain_cxx_compiler="g++"
678         toolchain_cpp_preprocessor="cpp"
679         toolchain_ld="ld"
680         toolchain_as="as"
681         toolchain_ar="ar"
682         toolchain_ranlib="ranlib"
683         toolchain_nm="nm"
684         toolchain_strip="strip"
685         toolchain_objcopy="objcopy"
686         toolchain_objdump="objdump"
687         ;;
688     *)
689         AC_MSG_WARN("Unknown toolchain family!")
690         toolchain_c_compiler="cc"
691         toolchain_cxx_compiler="c++"
692         toolchain_cpp_preprocessor="cpp"
693         toolchain_ld="ld"
694         toolchain_as="as"
695         toolchain_ar="ar"
696         toolchain_ranlib="ranlib"
697         toolchain_nm="nm"
698         toolchain_strip="strip"
699         toolchain_objcopy="objcopy"
700         toolchain_objdump="objdump"
701         ;;
702 esac
704 #-----------------------------------------------------------------------------
706 AC_MSG_CHECKING([which type of build to do])
707 AC_ARG_ENABLE(build_type,AC_HELP_STRING([--enable-build-type=TYPE],[Select the build type. Available types are: personal, nightly, snapshot, milestone, release. Do NOT use this option unless you know what you are doing! (default=personal)]),build_type=$enableval,build_type="personal")
709 if test "$build_type" = "nightly"; then
710     build_type_string="NIGHTLY"
711 elif test "$build_type" = "snapshot"; then
712     build_type_string="SNAPSHOT"
713 elif test "$build_type" = "milestone"; then
714     build_type_string="MILESTONE"
715 elif test "$build_type" = "release"; then
716     build_type_string="RELEASE"
717 else
718     build_type_string="PERSONAL"
719     build_type="personal"
722 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
724 AC_MSG_RESULT($build_type)
726 #-----------------------------------------------------------------------------
727 all_debug_types="messages stack modules mungwall symbols"
729 AC_MSG_CHECKING([which debug types to enable])
730 AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug=list],[Enable different types of debug. Commas or whitespaces can be used to separate the items in the list. Available types of debug are: all, none, messages, stack, mungwall, modules, symbols. If no list is provided then "all" is assumed. (default=none)]),
731  debug="$enableval",debug="")
733 if test "$debug" = "" -o "$debug" = "no"; then
734     debug="none"
735 elif test "$debug" = "yes"; then
736     debug="all"
739 if test "$debug" = "all" ; then
740     debug="messages stack modules symbols"
741     for d in $all_debug_types; do
742         export aros_${d}_debug="1"
743     done
744 else
745     for d in $all_debug_types; do
746         export aros_${d}_debug="0"
747     done
750 if test "$debug" != "none"; then
751     debug=`echo $debug | sed s/,/\ /g`
752     for d in $debug; do
753         found="0"
754         for d2 in $all_debug_types; do
755             if test "$d2" = "$d"; then
756                 found="1"
757                 break
758             fi
759         done
760         if test "$found" = "0"; then
761             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
762         fi
763         export aros_${d}_debug="1"
764     done
765     aros_debug="yes"
767 AC_MSG_RESULT($debug)
769 if test "$aros_messages_debug" = "1"; then
770     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
771 else
772     aros_messages_debug=""
774 if test "$aros_symbols_debug" = "1"; then
775     aros_symbols_debug="-g"
776 else
777     aros_symbols_debug=""
780 # These are the flags to pass when compiling debugged programs
781 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
782 aros_debug_aflags=""
783 aros_debug_ldflags="$aros_symbols_debug"
785 #-----------------------------------------------------------------------------
786 #   Checking for distcc and ccache.
788 #   Always apply the transforms in this particular order. Basically you should
789 #   always run 'ccache distcc compiler' in that order for the best performance.
791 AC_MSG_CHECKING([whether to enable distcc])
792 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
793 if test "$distcc" != "" -a "$distcc" != "no"; then
794     # AC_CHECK_PROG will print out the result in this case
795     AC_PATH_PROG(DISTCC,[distcc],distcc,)
796 else
797     AC_MSG_RESULT(no)
800 AC_MSG_CHECKING([whether to enable ccache])
801 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
802 if test "$ccache" != "" -a "$ccache" != "no"; then
803     # AC_CHECK_PROG will print out the result in this case
804     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
805 else
806     AC_MSG_RESULT(no)
809 #-----------------------------------------------------------------------------
810 AC_MSG_CHECKING([what specific host gcc version to use])
811 AC_ARG_WITH(kernel-gcc-version,AC_HELP_STRING([--with-kernel-gcc-version=VERSION],[Use gcc-VERSION for building bootstrap]),kernel_tool_version="$withval",kernel_tool_version="")
812 AC_MSG_RESULT($kernel_tool_version)
814 #-----------------------------------------------------------------------------
815 AC_MSG_CHECKING([what optimization flags to use])
816 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
817 if test "$optimization" = "unknown"; then
818     dnl default is -O2 for normal builds, -O0 for debug builds
819     if test "$debug" != "none"; then
820         optimization="-O0"
821     else
822         optimization="-O2"
823     fi
825 aros_optimization_cflags="$optimization"
826 AC_MSG_RESULT($optimization)
828 #-----------------------------------------------------------------------------
829 AC_MSG_CHECKING([which paranoia flags to use])
830 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[compiler warning flags to enable for paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
831 if test "$paranoia_flags" = "default"; then
832         paranoia_flags=""
833         msg_result="none"
834 else if test "$paranoia_flags" = "yes"; then
835         paranoia_flags="-Wall -Werror"
836         msg_result="$paranoia_flags"
837 fi fi
838 AC_MSG_RESULT($msg_result)
839 aros_config_cflags="$aros_config_cflags $paranoia_flags"
841 #-----------------------------------------------------------------------------
842 AC_MSG_CHECKING([what target variant to enable])
843 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
844 if test "$target_variant" = ""; then
845     aros_target_variant=""
846     aros_target_suffix=""
847     enableval="none"
848 else
849     aros_target_variant="$target_variant"
850     aros_target_suffix="-$target_variant"
852 AC_MSG_RESULT($enableval)
854 #-----------------------------------------------------------------------------
855 # Target-specific defaults. You can override then on a per-target basis.
857 # Bootloader name. Currently used by PC target.
858 target_bootloader="none"
859 ENABLE_EXECSMP=
861 #-----------------------------------------------------------------------------
862 # Additional options for some specific targets
864 case "$aros_target_variant" in
865 ios)
866     AC_MSG_CHECKING([XCode path])
867     AC_ARG_WITH(xcode,AC_HELP_STRING([--with-xcode=PATH],[Specify XCode path for iOS targets (default=/Developer).]),aros_xcode_path="$withval",aros_xcode_path="/Developer")
868     AC_MSG_RESULT($aros_xcode_path)
870     AC_MSG_CHECKING([what iOS SDK version to use])
871     AC_ARG_WITH(sdk-version,AC_HELP_STRING([--with-sdk-version=VERSION],[Use iOS SDK version VERSION (default=4.1).]),aros_sdk_version="$withval",aros_sdk_version="4.1")
872     AC_MSG_RESULT($aros_sdk_version)
874     ;;
876 "android")
877     AC_MSG_CHECKING([Android SDK path])
878     AC_ARG_WITH(sdk,AC_HELP_STRING([--with-sdk=PATH],[Specify Android SDK path (default=$default_android_sdk).]),aros_android_sdk="$withval",aros_android_sdk=$default_android_sdk)
879     AC_MSG_RESULT($aros_android_sdk)
881     AC_MSG_CHECKING([Android NDK path])
882     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
883     AC_MSG_RESULT($aros_android_ndk)
885     AC_MSG_CHECKING([what Android SDK version to use])
886     AC_ARG_WITH(sdk-version,AC_HELP_STRING([--with-sdk-version=LEVEL],[Use Android SDK for API LEVEL (default=12).]),aros_sdk_version="$withval",aros_sdk_version="12")
887     AC_MSG_RESULT($aros_sdk_version)
889     aros_android_level=android-$aros_sdk_version
890     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
891         echo "Platform $aros_android_level is not installed in your SDK"
892         echo "Use --with-sdk-version=<API level number> to select another platform version"
893         echo "You can check what plaform versions are installed in your SDK"
894         echo "by examining contents of $aros_android_sdk/platforms directory"
895         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
896     fi
898     export PATH="$aros_android_sdk/tools:$PATH"
899     AC_PATH_PROG(android_tool, $android_tool)
900     AROS_REQUIRED(android,$android_tool)
902     if test "$aros_android_ndk" != "none"; then
903         AC_MSG_CHECKING([what Android NDK version to use])
904         AC_ARG_WITH(ndk-version,AC_HELP_STRING([--with-ndk-version=LEVEL],[Use Android NDK for API LEVEL (default=9).]),aros_ndk_version="$withval",aros_ndk_version="9")
905         AC_MSG_RESULT($aros_ndk_version)
906     fi
908     AC_PATH_PROG(ant, ant)
909     if test "$ant" = ""; then
910         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
911     fi
913     AC_MSG_CHECKING([Build debug or release apk])
914     AC_ARG_WITH(apk-version,AC_HELP_STRING([--with-apk-version=(release|debug)],[Which version of AROSBootstrap.apk to compile. Release version needs key for signing, debug version will only run in emulator. (default=release)]),aros_android_antapk=$withval,aros_android_antapk=release)
915     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
916         AC_MSG_ERROR([apk-version has to be release or debug])
917     fi
918     AC_MSG_RESULT($aros_android_antapk)
920     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
921     if test "$host_os" = "mingw32"; then
922         android_tool="cmd //c $android_tool"
923     fi
925     need_dlopen="no"
927     ;;
928 esac
930 #-----------------------------------------------------------------------------
931 # External toolchains
932 kernel_tool_prefix="none"
933 aros_tool_prefix="none"
934 elf_tool_prefix="${target_cpu}-elf-"
936 # This is the target configuration switch.
937 case "$target_os" in
938     linux*)
939         aros_target_arch="linux"
940         aros_target_family="unix"
941         case "$target_cpu" in
942             *m68k*)
943                 aros_target_cpu="m68k"
944                 aros_object_format="m68kelf"
945                 aros_flavour="emulcompat"
946                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
947                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
948                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
949                 gcc_target_cpu="mc68000"
950                 ;;
951             *i?86*)
952                 aros_target_cpu="i386"
953                 aros_object_format="elf_i386"
954                 aros_flavour="emulation"
955                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
956                 aros_kernel_ldflags="-Wl,-melf_i386"
957                 aros_nominal_depth=8
958                 gcc_target_cpu="i386"
959                 pci_hidd_target="hidd-pci-linux"
960                 android_tool_dir_prefix="x86"
961                 android_tool_prefix="i686-android-linux"
962                 android_ndk_arch="x86"
963                 ;;
964             *x86_64*)
965                 aros_target_cpu="x86_64"
966                 aros_object_format="elf_x86_64"
967                 aros_flavour="emulation"
968                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
969                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
970                 aros_nominal_depth=8
971                 pci_hidd_target="hidd-pci-linux"
972                 ;;
973             *powerpc*)
974                 aros_target_cpu="ppc"
975                 aros_object_format="elf32ppc"
976                 aros_flavour="emulation"
977                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
978                 aros_nominal_depth=8
979                 gcc_target_cpu="ppc"
980                 ;;
981 # TODO
982 # Same as powerpc, but I need this for the nightly build to work again.
983 # Actually, the nightly should be made working with powerpc target.
984 # That just was too much work for the moment, another week or two.
985             *ppc*)
986                 aros_target_cpu="ppc"
987                 aros_object_format="elf32ppc"
988                 aros_flavour="emulation"
989                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
990                 aros_nominal_depth=8
991                 gcc_target_cpu="ppc"
992                 ;;
993             *aarch64*)
994                 aros_target_cpu="aarch64"
995                 target_cpu="aarch64"
996                 aros_object_format="aarch64elf_aros"
997                 aros_flavour="emulation"
998                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
999                 gcc_target_cpu="aarch64"
1000                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1001                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1002                 aros_arch_libs="-laeabi"
1003                 gcc_default_float_abi="hard"
1004                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1005                 ;;
1006             *armhf*)
1007                 aros_target_cpu="arm"
1008                 target_cpu="arm"
1009                 aros_object_format="armelf_aros"
1010                 aros_flavour="emulation"
1011                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1012                 gcc_target_cpu="arm"
1013                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1014                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1015                 aros_arch_libs="-laeabi"
1016                 gcc_default_float_abi="hard"
1017                 android_tool_dir_prefix="arm-linux-androideabi"
1018                 android_tool_prefix="arm-linux-androideabi"
1019                 android_ndk_arch="arm"
1020                 kernel_tool_prefix="arm-linux-gnueabihf-"
1021                 ;;
1022             *arm*)
1023                 aros_target_cpu="arm"
1024                 aros_object_format="armelf_aros"
1025                 aros_flavour="emulation"
1026                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1027                 gcc_target_cpu="arm"
1028                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1029                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1030                 aros_arch_libs="-laeabi"
1031                 android_tool_dir_prefix="arm-linux-androideabi"
1032                 android_tool_prefix="arm-linux-androideabi"
1033                 android_ndk_arch="arm"
1034                 kernel_tool_prefix="arm-linux-gnueabi-"
1035                 ;;
1036             *)
1037                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1038                 ;;
1039         esac
1040         case "$aros_target_variant" in
1041             android)
1043                 dnl Not all Linux CPUs are supported by Android
1044                 if test "$android_ndk_arch" = ""; then
1045                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1046                 fi
1048                 aros_nominal_width=320
1049                 aros_nominal_height=480
1050                 if test "$aros_android_ndk" = "none"; then
1051                     dnl Use standalone toolchain, don't adjust paths
1052                     aros_kernel_cflags="-mandroid"
1053                     aros_kernel_ldflags="-mandroid"
1054                     CFLAGS="-mandroid"
1055                 else
1056                     dnl In Android NDK toolchains are placed in own directories,
1057                     dnl but tool names are not suffixed with version 
1058                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1059                     kernel_tool_version=""
1060                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1061                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1062                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1063                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1064                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1065                 fi
1066                 need_x11=no
1067                 host_android_gfx=yes
1068                 # Disable implicit PIC mode
1069                 aros_target_cflags="$aros_target_cflags -fno-pic"
1070                 kernel_tool_prefix="$android_tool_prefix-"
1071             ;;
1072         esac
1073     ;;
1075     pc)
1076         aros_target_arch="pc"
1077         aros_shared_default="no"
1078         target_bootloader="grub2"
1079         case "$target_cpu" in
1080             *i?86*)
1081                 aros_target_cpu="i386"
1083                 dnl If somebody hasn't already set the target object
1084                 dnl format, then use this value. Mostly to support
1085                 dnl FreeBSD cross-compilation.
1086                 dnl TODO: Remove when we always use our compiler.
1088                 if test "$aros_object_format" = "" ; then
1089                     aros_object_format="elf_i386"
1090                 fi
1091                 aros_flavour="standalone"
1092                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1093                 aros_kernel_ldflags="-Wl,-melf_i386"
1094                 aros_nominal_width=640
1095                 aros_nominal_height=480
1096                 gcc_target_cpu="i386"
1097                 ;;
1098             *x86_64*)
1099                 aros_target_cpu="x86_64"
1100                 aros_serial_debug=1
1101                 if test "$aros_object_format" = "" ; then
1102                     aros_object_format="elf_x86_64"
1103                 fi
1104                 aros_flavour="standalone"
1105                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1106                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1107                 aros_kernel_ldflags=""
1108                 aros_nominal_width=640
1109                 aros_nominal_height=480
1110                 case "$aros_target_variant" in
1111                     smp)
1112                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1113                     ;;
1114                 esac
1115                 ;;
1116             *)
1117                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1118                 ;;
1119         esac
1120         ;;
1122     prep)
1123         aros_target_arch="prep"
1124         aros_shared_default="no"
1125         aros_target_cpu="ppc"
1126         aros_object_format="elf32ppc"
1127         aros_flavour="ppcnative"
1128         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1129         aros_kernel_ldflags=""
1130         aros_nominal_width=640
1131         aros_nominal_height=480
1132         gcc_target_cpu="ppc"
1133         ;;
1135     freebsd*)
1136         aros_target_arch="freebsd"
1137         aros_target_family="unix"
1138         aros_target_cpu="i386"
1139         aros_flavour="emulation"
1140         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1141         gcc_target_cpu="i386"
1143         aros_target_strip_flags="-x"
1144         ;;
1146     darwin*)
1147         aros_target_arch="darwin"
1148         aros_target_family="unix"
1149         aros_flavour="emulation"
1150         case "$target_cpu" in
1151             *i?86*)
1152                 aros_ios_platform="iPhoneSimulator"
1153                 aros_target_cpu="i386"
1154                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1155                 aros_kernel_ldflags=""
1156                 aros_macosx_version="10.4"
1157                 aros_nominal_depth=8
1158                 gcc_target_cpu="i386"
1159                 aros_object_format="elf_i386"
1160                 aros_kernel_ar_flags="-cr"
1161                 aros_target_strip_flags="-x"
1162                 kernel_tool_flags="-m32"
1163                 ;;
1164             *x86_64*)
1165                 aros_target_cpu="x86_64"
1166                 aros_object_format="elf_x86_64"
1167                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1168                 aros_macosx_version="10.6"
1169                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1170                 aros_kernel_cflags="-m64"
1171                 aros_kernel_ldflags="-m64"
1172                 aros_target_cflags="-mcmodel=large"
1173                 aros_nominal_depth=8
1174                 aros_kernel_ar="ar"
1175                 aros_kernel_ar_flags="-cr"
1176                 aros_kernel_ld="ld"
1177                 aros_kernel_as="as"
1178                 aros_kernel_ranlib="ranlib"
1179                 aros_kernel_nm="nm"
1180                 aros_kernel_strip="strip"
1181                 kernel_tool_prefix="i686-apple-darwin10-"
1182                 ;;
1183             *ppc*)
1184                 aros_target_cpu="ppc"
1185                 aros_object_format="elf32ppc"
1186                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1187                 aros_kernel_ldflags=""
1188                 aros_macosx_version="10.0"
1189                 aros_nominal_depth=8
1190                 gcc_target_cpu="ppc"
1191                 aros_kernel_ar="ar"
1192                 aros_kernel_ar_flags="-cr"
1193                 aros_kernel_ld="ld -arch ppc"
1194                 aros_kernel_as="as -arch ppc"
1195                 aros_kernel_ranlib="ranlib -arch ppc"
1196                 aros_kernel_nm="nm -arch ppc"
1197                 aros_kernel_strip="strip -arch ppc"
1198                 kernel_tool_prefix="powerpc-apple-darwin10-"
1199                 ;;
1200             *arm*)
1201                 aros_ios_platform="iPhoneOS"
1202                 aros_target_cpu="arm"
1203                 aros_object_format="armelf_aros"
1204                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1205                 aros_arch_libs="-laeabi"
1206                 aros_nominal_depth=8
1207                 gcc_target_cpu="arm"
1208                 aros_kernel_ar="ar"
1209                 aros_kernel_ar_flags="-cr"
1210                 aros_kernel_ld="ld -arch arm"
1211                 aros_kernel_ranlib="ranlib -arch arm"
1212                 kernel_tool_prefix="arm-apple-darwin10-" 
1213                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1214                 ;;
1215             *)
1216                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1217                 ;;
1218         esac
1219         case "$aros_target_variant" in
1220             ios)
1221                 aros_ios_version="3.0"
1222                 aros_nominal_width=320
1223                 aros_nominal_height=480
1224                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1225                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1226                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1227                 need_x11=no
1228                 # This is here because it may depend on iOS or SDK version
1229                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1230                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1231                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1232             ;;
1233             *)
1234                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1235                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1236             ;;
1237         esac
1238         ;;
1240     dragonfly*)
1241         aros_target_arch="dragonfly"
1242         aros_target_family="unix"
1243         aros_flavour="emulation"
1244         case "$target_cpu" in
1245             *i?86*)
1246                 aros_target_cpu="i386"
1247                 aros_object_format="elf_i386"
1248                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1249                 ;;
1250             *x86_64*)
1251                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1252                 aros_target_cpu="x86_64"
1253                 aros_object_format="elf_x86_64"
1254                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1255                 ;;
1256             *)
1257                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1258                 ;;
1259         esac
1260         ;;
1262     netbsd*)
1263         aros_target_arch="netbsd"
1264         aros_target_family="unix"
1265         case "$target_cpu" in
1266             *m68k*)
1267                 aros_target_cpu="m68k"
1268                 aros_object_format="m68kelf"
1269                 aros_flavour="emulcompat"
1270                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1271                 gcc_target_cpu="mc68000"
1272                 ;;
1273             *i?86*)
1274                 aros_target_cpu="i386"
1275                 aros_object_format="elf_i386"
1276                 aros_flavour="emulation"
1277                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1278                 aros_nominal_depth=8
1279                 gcc_target_cpu="i386"
1280                 ;;
1281             *)
1282                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1283                 ;;
1284         esac
1285         aros_target_genmap="-Wl,-M -Xlinker >"
1286         aros_flavour="emulation"
1287         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1288         ;;   
1290     openbsd*)
1291         aros_target_arch="openbsd"
1292         aros_target_family="unix"
1293         case "$target_cpu" in
1294             *i?86*)
1295                 aros_target_cpu="i386"
1296                 aros_object_format="elf_i386"
1297                 aros_flavour="emulation"
1298                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1299                 gcc_target_cpu="i386"
1300                 ;;
1301             *)
1302                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1303                 ;;
1304         esac
1305         aros_target_genmap="-Wl,-M -Xlinker >"
1306         aros_target_nm_flags="-u"
1307         aros_flavour="emulation"
1308         ;;
1310     solaris*)
1311         aros_target_arch="solaris"
1312         aros_target_family="unix"
1313         case "$target_cpu" in
1314            *i?86*)
1315                aros_target_cpu="i386"
1316                aros_object_format="elf_i386"
1317                aros_flavour="emulation"
1318                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1319                aros_nominal_depth=8
1320                gcc_target_cpu="i386"
1321                ;;
1322             *sparc*)
1323                 aros_target_cpu="sparc"
1324                 aros_object_format="elf_sparc"
1325                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1326                 gcc_target_cpu="sparc"
1327                 ;;
1328             *)
1329                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1330                 ;;
1331         esac
1332         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1333         aros_flavour="emulation"
1334         ;;
1336     morphos*)
1337         aros_target_arch="morphos"
1338         aros_shared_default="no"
1339         aros_target_cpu="ppc"
1340         aros_object_format="elf_ppc"
1341         aros_flavour="nativecompat"
1342         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1343         gcc_target_cpu="ppc"
1344         ;;
1346     sam440)
1347         aros_target_arch="sam440"
1348         aros_shared_default="no"
1349         aros_target_cpu="ppc"
1350         aros_object_format="elf32ppc"
1351         aros_flavour="ppcnative"
1352         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1353         aros_kernel_ldflags=""
1354         aros_nominal_width=1024
1355         aros_nominal_height=768
1356         aros_nominal_depth=24
1357         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1358         gcc_target_cpu="powerpc"
1359         ;;
1361     efika)
1362         aros_target_arch="efika"
1363         aros_shared_default="no"
1364         aros_target_cpu="arm"
1365         aros_object_format="armelf_aros"
1366         aros_flavour="standalone"
1367         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1368         aros_kernel_ldflags=""
1369         aros_nominal_width=1024
1370         aros_nominal_height=600
1371         aros_arch_libs="-laeabi"
1372         gcc_default_cpu="armv7-a"
1373         gcc_default_fpu="vfpv3"
1374         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1375         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1376         aros_optimization_cflags="$aros_optimization_cflags -Os"
1377         case "$target_cpu" in
1378             *armhf*)
1379                 gcc_default_float_abi="hard"
1380                 target_cpu=arm
1381                 aros_target_cpu=arm
1382                 ;;
1383             *arm*)
1384                 gcc_default_float_abi="softfp"
1385                 ;;
1386             *)
1387                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1388                 ;;
1389         esac
1390         ;;
1391         
1392     chrp)
1393         aros_target_arch="chrp"
1394         aros_shared_default="no"
1395         aros_target_cpu="ppc"
1396         aros_object_format="elf32ppc"
1397         aros_flavour="ppcnative"
1398         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1399         aros_kernel_ldflags=""
1400         aros_nominal_width=640
1401         aros_nominal_height=480
1402         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1403         gcc_target_cpu="powerpc"
1404         case "$aros_target_variant" in
1405             efika)
1406                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1407             ;;
1408         esac
1409         ;;
1411     r*pi)
1412         aros_flavour="standalone"
1413         aros_target_arch="raspi"
1415         aros_shared_default="no"
1416         aros_arch_libs="-laeabi"
1418         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1419         aros_config_cflags="$aros_config_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1420         aros_config_aflags="$aros_config_aflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1421         aros_kernel_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1422         aros_target_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1423         case "$target_cpu" in
1424             *aarch64*)
1425                 aros_target_cpu="aarch64"
1426                 gcc_default_cpu="aarch64"
1427                 aros_object_format="aarch64elf_aros"
1428                 ;;
1429             *armhf*)
1430                 aros_target_cpu="arm"
1431                 gcc_default_cpu="armv6zk"
1432                 gcc_default_cpu_tune="arm1176jzf-s"
1433                 aros_object_format="armelf_aros"
1434                 ;;
1435             *arm*)
1436                 aros_target_cpu="arm"
1437                 gcc_default_cpu="armv6zk"
1438                 gcc_default_cpu_tune="arm1176jzf-s"
1439                 aros_object_format="armelf_aros"
1440                 ;;
1441             *)
1442                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1443                 ;;
1444         esac
1446         case "$aros_target_variant" in
1447             smp)
1448                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1449             ;;
1450         esac
1451         ;;
1453     stm32f7_discovery)
1454         aros_flavour="standalone"
1455         aros_target_arch="stm32f7_discovery"
1456         aros_target_cpu="arm"
1457         aros_target_cpu_mode="thumb2"
1458         aros_object_format="armelf_aros"
1459         aros_shared_default="no"
1461         # stm32f7 has DSP opcode support
1462         gcc_default_cpu="armv7e-m"
1463         # gcc_default_cpu="armv7-m"
1464         gcc_default_cpu_tune="cortex-m7"
1465         gcc_default_fpu="fpv4-sp-d16"
1466         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1467         # gcc_default_fpu="fpv5-sp-d16"
1468                 gcc_default_float_abi="hard"
1470         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1471         ;;
1473     amiga*)
1474         aros_target_arch="amiga"
1475         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1476         aros_shared_default="no"
1478         case "$target_cpu" in
1479             *m68k*)
1480                 AC_ARG_ENABLE(amigaos_compliance,AC_HELP_STRING([--enable-amigaos-compliance=VERSION],[Enforce userspace AmigaOS compliance to a specific KickStart version (default=none).]),aros_amigaos_compliance="$enableval")
1481                 aros_enable_mmu=no
1482                 aros_target_cpu="m68k"
1483                 aros_object_format="m68kelf"
1484                 aros_flavour="standcompat"
1485                 gcc_target_cpu="m68000"
1486                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1487                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1488                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1489                 aros_config_aflags="$aros_config_aflags"
1490                 aros_target_strip_flags="-R.comment --strip-debug"
1491                 aros_nominal_width=640
1492                 aros_nominal_height=256
1493                 aros_nominal_depth=2
1494                 ;;
1495             *ppc*)
1496                 aros_cpu="ppc"
1497                 aros_flavour="native"
1498                 gcc_target_cpu="ppc"
1499                 ;;
1500             *)
1501                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1502                 ;;
1503         esac
1504         ;;
1506     mingw*)
1507         aros_target_arch="mingw32"
1508         aros_shared_default="no"
1509         aros_flavour="emulation"
1510         aros_shared_cflags=""
1511         need_crosstools="yes"
1512         need_dlopen="no"
1513         rescomp="windres"
1514         case "$target_cpu" in
1515             *i?86*)
1516                 aros_target_cpu="i386"
1517                 aros_object_format="elf_i386"
1518                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1519                 aros_nominal_depth=8
1520                 gcc_target_cpu="i386"
1522                 kernel_tool_prefix="i386-mingw32-"
1523                 ;;
1524             *x86_64*)
1525                 aros_target_cpu="x86_64"
1526                 aros_object_format="elf_x86_64"
1527                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1528                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1529                 aros_nominal_depth=8
1530                 kernel_tool_prefix="x86_64-w64-mingw32-"
1531                 ;;
1532             *arm*)
1533                 aros_target_cpu="arm"
1534                 aros_object_format="armelf_aros"
1535                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1536                 aros_arch_libs="-laeabi"
1537                 aros_nominal_depth=8
1538                 gcc_target_cpu="arm"
1539                 gcc_default_float_abi="soft"
1540                 kernel_tool_prefix="arm-mingw32ce-"
1541                 aros_nominal_width=160
1542                 aros_nominal_height=160
1543                 ;;
1544             *)
1545                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1546                 ;;
1547         esac
1548         if test $host_os = "cygwin"; then
1549                 aros_kernel_cflags="-mno-cygwin"
1550         fi
1551     ;;
1552     pp*)
1553         aros_target_arch="pp"
1554         aros_shared_default="no"
1555         case "$target_cpu" in
1556             *m68k*)
1557                 aros_target_cpu="m68k"
1558                 aros_object_format="m68kelf"
1559                 aros_flavour="palmnative"
1560                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1561                 aros_nominal_width=160
1562                 aros_nominal_height=160
1563                 aros_nominal_depth=1
1564                 aros_target_ar_flags="cru"
1565                 aros_compiler_libs="-lgcc1"
1566                 aros_shared_default=no
1567                 aros_shared_cflags="-fpic"
1568                 aros_shared_aflags=""
1569                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1570                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1571                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1572                 aros_debug_aflags=""
1573                 aros_debug_ldflags="$aros_symbols_debug"
1574                 aros_mungwall_debug="0"
1575                 aros_modules_debug="0"
1576                 gcc_target_cpu="mc68000"
1577                 ignore_undefined_symbols="-ius"
1578                 ;;
1579            *)
1580                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1581                 ;;
1582         esac
1583         ;;
1585     mac*)
1586         aros_target_arch="mac"
1587         aros_shared_default="no"
1588         case "$target_cpu" in
1589             *m68k*)
1590                 aros_target_cpu="m68k"
1591                 aros_object_format="m68kelf"
1592                 aros_flavour="mac68knative"
1593                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1594                 aros_nominal_width=512
1595                 aros_nominal_height=384
1596                 aros_nominal_depth=8
1597                 aros_target_ar_flags="cru"
1598                 aros_compiler_libs="-lgcc1"
1599                 aros_shared_default=no
1600                 aros_shared_cflags="-fpic"
1601                 aros_shared_aflags=""
1602                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1603                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1604                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1605                 aros_debug_aflags=""
1606                 aros_debug_ldflags="$aros_symbols_debug"
1607                 aros_mungwall_debug="0"
1608                 aros_modules_debug="0"
1609                 gcc_target_cpu="mc68000"
1610                 ignore_undefined_symbols="-ius"
1611                 ;;
1612            *)
1613                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1614                 ;;
1615         esac
1616         ;;
1618     *)
1619         AC_MSG_ERROR([Unsupported target architecture $target])
1620         ;;
1621 esac
1623 #-----------------------------------------------------------------------------
1624 crosstools_guess="yes"
1625 aros_target_toolchain="no"
1626 aros_config_sysroot=""
1627 aros_kernel_sysroot=""
1629 AC_MSG_CHECKING([Kernel toolchain prefix])
1630 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1631 AC_MSG_RESULT($kernel_tool_prefix)
1633 AC_MSG_CHECKING([ELF toolchain prefix])
1634 AC_ARG_WITH(elf-toolchain-prefix,AC_HELP_STRING([--with-elf-toolchain-prefix=...],[Specify crosscompile toolchain prefix to wrap for AROS objects]),[elf_tool_prefix="$withval"
1635                                                  crosstools_guess="no"])
1636 AC_MSG_RESULT($elf_tool_prefix)
1638 AC_MSG_CHECKING([AROS toolchain prefix])
1639 AC_ARG_WITH(aros-toolchain,AC_HELP_STRING([--with-aros-toolchain=PREFIX],[Specify prebuilt AROS toolchain. Use yes for default name]),[aros_tool_prefix="$withval"
1640                 crosstools_guess="no"])
1641 if test "$aros_tool_prefix" = "yes" ; then
1642     aros_tool_prefix=$aros_target_cpu-aros-
1644 AC_MSG_RESULT($aros_tool_prefix)
1646 #-----------------------------------------------------------------------------
1647 #   Checking if we should build crosstools..
1648 AC_MSG_CHECKING([whether to build crosstools])
1649 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1650 AC_MSG_RESULT($crosstools)
1652 if test "${crosstools}" = "yes"; then
1653     if test "${crosstools_guess}" = "no"; then
1654         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1655     fi
1658 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1659     aros_target_toolchain="yes"
1662 AC_MSG_CHECKING([where to install the crosstools binaries])
1663 AC_ARG_WITH(aros-toolchain-install,AC_HELP_STRING([--with-aros-toolchain-install=DIR],[Where to install or search for cross tools binaries]),[aros_toolchain_install=$withval])
1664 if test "x$aros_toolchain_install" = "x"; then
1665     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1666 else
1667     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1668     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1669     if test "$crosstools_guess" = "no" ; then
1670         toolchain_needs_sysroot=yes
1672         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1673             aros_kernel_sysroot = $aros_config_sysroot
1674         fi
1675     fi
1677 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1679 AC_MSG_CHECKING([If we need to use --sysroot])
1680 if test "$toolchain_needs_sysroot" = "yes" ; then
1681     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1683 AC_MSG_RESULT($toolchain_needs_sysroot)
1685 #-----------------------------------------------------------------------------
1686 if test "$aros_toolchain" = "gnu" ; then
1687     AC_MSG_CHECKING([what specific target binutils version to use])
1689 AC_ARG_WITH(binutils-version,AC_HELP_STRING([--with-binutils-version=VERSION],[Use binutils-VERSION for building AROS]),use_binutils_version="$withval",use_binutils_version="")
1690 if test "$use_binutils_version" = ""; then
1691         target_binutils_version="$default_binutils_version"
1692 else
1693     target_binutils_version="$use_binutils_version"
1695 if test "$aros_toolchain" = "gnu" ; then
1696     AC_MSG_RESULT($target_binutils_version)
1700 # Helper to identify gcc version
1701 AC_DEFUN([CROSS_GCC_VERSION], [
1702   target_gcc_version=""
1703   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1704     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1705     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1706       ax_cv_gcc_version=""
1707     ])
1708   ])
1709   target_gcc_version=$ax_cv_gcc_version
1710   AC_SUBST([target_gcc_version])
1713 #-----------------------------------------------------------------------------
1714 if test "$aros_toolchain" = "gnu" ; then
1715     AC_MSG_CHECKING([what specific target gcc version to use])
1717 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1718 if test "$use_gcc_version" = ""; then
1719     if test "${crosstools}" = "no"; then
1720       if test "x$aros_toolchain_install" != "x"; then
1721           CROSS_GCC_VERSION
1722       fi
1723     fi
1724     if test "$use_gcc_version" = ""; then
1725         target_gcc_version="$default_gcc_version"
1726     fi
1727 else
1728     target_gcc_version="$use_gcc_version"
1730 if test "$aros_toolchain" = "gnu" ; then
1731     AC_MSG_RESULT($target_gcc_version)
1733     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1734     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1735     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1737     gcc_fix_bitfields="false"
1738     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1739         gcc_fix_bitfields="true"
1740     else
1741         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1742             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1743                 gcc_fix_bitfields="true"
1744             fi
1745         fi
1746     fi
1748     if test "$gcc_fix_bitfields" = "true" ; then
1749         case "$aros_target_cpu" in
1750         *x86_64*)
1751             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1752             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1753             ;;
1754         i386)
1755             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1756             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1757             ;;
1758         esac
1759     fi
1762 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1763 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1764 AC_MSG_RESULT($objc)
1765 if test "x$objc" = "xyes"; then
1766     objc_target="$objc"
1767 else
1768     objc_target="no-objc"
1771 AC_MSG_CHECKING([whether to enable Java suppport])
1772 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1773 AC_MSG_RESULT($java)
1774 if test "x$java" != "xno"; then
1775     java_target="$java"
1776 else
1777     java_target="no-java"
1780 spec_obj_format="-m $aros_object_format"
1781 # Now process extra architecture-specific options.
1782 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1783 # as well as floating-point ABI.
1784 case "$aros_target_cpu" in
1785 *x86_64*)
1786     dnl x86_64 can build 32 or 64bit code
1787     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1788     ;;
1789 arm*)
1790     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1791     if test "$gcc_default_cpu" = ""; then
1792         gcc_default_cpu="armv6"
1793     fi
1794     if test "$gcc_default_fpu" = ""; then
1795         gcc_default_fpu="vfp"
1796     fi
1797     if test "$gcc_default_float_abi" = ""; then
1798         if test "$target_cpu" = "armhf"; then
1799             gcc_default_float_abi="hard"
1800         else
1801             gcc_default_float_abi="softfp"
1802         fi
1803     fi
1805     AC_MSG_CHECKING([Which minimum CPU to use])
1806     AC_ARG_WITH(cpu,AC_HELP_STRING([--with-cpu=<spec>],[Specify minumum CPU (default=$gcc_default_cpu).]),aros_gcc_cpu="$withval",aros_gcc_cpu=$gcc_default_cpu)
1807     AC_MSG_RESULT($aros_gcc_cpu)
1809     AC_MSG_CHECKING([Which minimum FPU to use])
1810     AC_ARG_WITH(fpu,AC_HELP_STRING([--with-fpu=<spec>],[Specify minumum FPU (default=$gcc_default_fpu).]),aros_gcc_fpu="$withval",aros_gcc_fpu=$gcc_default_fpu)
1811     AC_MSG_RESULT($aros_gcc_fpu)
1813     AC_MSG_CHECKING([Which floating point ABI to use])
1814     AC_ARG_WITH(float,AC_HELP_STRING([--with-float=<spec>],[Specify floating point ABI (default=$gcc_default_float_abi).]),aros_gcc_float_abi="$withval",aros_gcc_float_abi=$gcc_default_float_abi)
1815     AC_MSG_RESULT($aros_gcc_float_abi)
1817     AC_MSG_CHECKING([Which ARM mode to use])
1818     if test "$aros_target_cpu_mode" = ""; then
1819         aros_target_cpu_mode="arm32"
1820         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1821     else
1822         AC_MSG_RESULT([$aros_target_cpu_mode])
1823     fi
1825     case "$aros_target_cpu_mode" in
1826     arm32)
1827         gcc_default_mode="arm"
1828         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1829     ;;
1830     arm64)
1831         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1832     ;;
1833     thumb)
1834         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1835     ;;
1836     thumb1)
1837         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1838     ;;
1839     thumb2)
1840         gcc_default_mode="thumb"
1841         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1842         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1843     ;;
1844     *)
1845         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1846     ;;
1847     esac
1849     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1850     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1851     ;;
1852 i386)
1853     aros_isa_flags="-m32 -march=i486"
1854     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1855     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1856     ;;
1857 esac
1859 # Some architectures may need custom ELF specs.
1860 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1861     elf_specs_in=config/${aros_object_format}-specs.in
1862 else
1863     elf_specs_in=config/elf-specs.in
1866 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1867 # Since we override specs, we may need to put these defines there
1868 if test "$gcc_target_cpu" != ""; then
1869     gcc_target_cpu="-D__${gcc_target_cpu}__"
1872 AC_MSG_CHECKING([where to download sourcecode for external ports])
1873 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1874 if test "$with_portssrcdir" = "default"; then
1875     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1876 else
1877     AROS_PORTSSRCDIR="$with_portssrcdir"
1879 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1881 AC_MSG_CHECKING([which bootloader to use])
1882 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1883 if test "$target_bootloader" = "none"; then
1884     aros_target_bootloader=""
1885 else
1886     aros_target_bootloader="$target_bootloader"
1888 AC_MSG_RESULT($target_bootloader)
1890 AC_MSG_CHECKING([which icon-set to use])
1891 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1892 if test "$target_iconset" = "default"; then
1893     aros_target_iconset="Gorilla"
1894     target_iconset="default (Gorilla)"
1895 else
1896     aros_target_iconset="$target_iconset"
1898 AC_MSG_RESULT($target_iconset)
1900 AC_MSG_CHECKING([which GUI Theme to use])
1901 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1902 if test "$target_guitheme" = "default"; then
1903     aros_target_guitheme="Ice"
1904 else
1905     aros_target_guitheme="$target_guitheme"
1907 AC_MSG_RESULT($aros_target_guitheme)
1909 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1910 # for target code)
1911 cross_compiling=no
1913 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1914 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1915     cross_compiling=yes
1918 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1919 dnl The flag itself is given in per-target section, because some targets require to pass it
1920 dnl in a different manner, otherwise some tests fail.
1921 dnl TODO: Justify this.
1922 if test "$aros_host_cpu" == "x86_64" ; then
1923     if test "$aros_target_cpu" == "i386" ; then
1924         cross_compiling=no
1925     fi
1928 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1929     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1930     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1931     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1932     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1933     dnl used to build bootstrap for target arch in either case.
1934     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1935     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1936     dnl perhaps introducing aros_host_variant
1937     if test "$aros_host_arch" != "$aros_target_arch" ; then
1938         cross_compiling=yes
1939     fi
1940 else
1941     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1942     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1943     if test "$host_cc_elf" = "no" ; then
1944         cross_compiling=yes
1945     fi
1948 if test "$cross_compiling" = "no" ; then
1949     kernel_tool_prefix=""
1950     if test "$host_cc_elf" = "yes" ; then
1951         elf_tool_prefix=""
1952     fi
1955 if test "$kernel_tool_version" != ""; then
1956     kernel_tool_version="-$kernel_tool_version"
1959 #######################################################################
1960 ## Compute what toolchains to use, and their paths                   ##
1961 #######################################################################
1963 # This takes, as input:
1964 #   crosstools             {yes,no}
1965 #   kernel_tool_version    {"",[version]}
1966 #   target_tool_version    {"",[version]}
1967 #   kernel_tool_prefix     {none,[some-arch-os-]}
1968 #   gnu-toolchain -:
1969 #     target_tool_prefix     ${aros_target_cpu}-aros-
1970 #     aros_tool_prefix       ${aros_target_cpu}-aros-
1972 # The output is
1973 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1974 #        Where the 'kernel' binaries are located
1975 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1976 #        Where the 'target' binaries are located
1977 #        (not the symlink farm - that is aros_target_*!)
1979 # The rules are:
1980 #   if crosstools then
1981 #      if kernel_tools_prefix = "no-kernel-prefix-"
1982 #          aros_kernel_* = crosstools cc paths
1983 #          aros_kernel_cc = elf cc wrapper around crosstools cc
1984 #      else
1985 #          VALIDATE(${kernel_tools_prefix}*)
1986 #          aros_kernel_* = ${kernel_tools_prefix}*
1987 #          if ${kernel_tools_prefix}cc is an AROS gcc
1988 #              aros_kernel_cc = ${kernel_tools_prefix}cc
1989 #          else
1990 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
1991 #          fi
1992 #      fi
1994 #      orig_target_* = aros built crosstools
1995 #      orig_target_cc = elf cc wrapper around crosstools cc
1996 #   else
1997 #      VALIDATE(${kernel_tools_prefix}*)
1999 #      orig_target_* = aros_kernel_*
2000 #      if aros_kernel_cc is an AROS gcc
2001 #          orig_target_cc = aros_kernel_cc
2002 #      else
2003 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2004 #      fi
2005 #   fi
2007 if test "$aros_toolchain" = "gnu" ; then
2008     target_tool_prefix="${aros_target_cpu}-aros-"
2009 elif test "$aros_toolchain" = "llvm" ; then
2010     target_tool_prefix="bin/"
2013 if test "$kernel_tool_prefix" != "" ; then
2014     AC_MSG_CHECKING([which kernel tools])
2015     AC_MSG_RESULT([$kernel_tool_prefix]);
2018 if test "$kernel_tool_prefix" = "none" ; then
2019     dnl ELF wrapper can be used only for native bootstrap
2020     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2021         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2022     fi
2023 else
2024     # Kernel tools required - find them
2025     # Note that 'normally', aros_kernel_* overrides will be
2026     # empty, unless specified in the per-arch sections above.
2027     if test "x$aros_kernel_cpp" = "x"; then
2028         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2029     fi
2030     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
2031     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2032     if test "x$aros_kernel_cc" = "x"; then
2033         aros_kernel_cc=${kernel_tool_prefix}${CC}
2034     fi
2035     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
2036     AROS_REQUIRED(cc,$aros_kernel_cc)
2037     if test "x$aros_kernel_cxx" = "x"; then
2038         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2039     fi
2040     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
2041     # If it's set, make sure it's really there
2042     if test "x$aros_kernel_cxx" != "x" ; then
2043         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2044     fi
2045     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2046     AROS_REQUIRED(ld,$aros_kernel_ld)
2047     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2048     AROS_REQUIRED(as,$aros_kernel_as)
2049     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2050     AROS_REQUIRED(ar,$aros_kernel_ar)
2051     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2052     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2053     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2054     AROS_REQUIRED(nm,$aros_kernel_nm)
2055     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2056     AROS_REQUIRED(strip,$aros_kernel_strip)
2058     # Objcopy and objdump are not required for the kernel
2059     # toolchain on many architectures.
2060     # So we'll look for them, but not make them strictly required.
2061     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2062     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2063     if test "x${crosstools}" != "xyes" ; then
2064         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2065         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2066     fi
2069 AC_MSG_CHECKING([which target tools to use])
2070 if test "$aros_target_toolchain" = "yes"; then
2071     if test "$aros_toolchain" = "llvm" ; then
2072         msg_result="llvm"
2073     else
2074         msg_result=$target_tool_prefix
2075     fi
2076     AC_MSG_RESULT([$msg_result])
2077     # We are building AROS crosstools
2078     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2079     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2080     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2081     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2082     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2083     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2084     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2085     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2086     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2087     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2088     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2089     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2090 else
2091     # Determine whether AROS or ELF tools should be used
2092     if test "$aros_tool_prefix" = "none"; then
2093         aros_tool_prefix="${elf_tool_prefix}"
2094     fi
2096     AC_MSG_RESULT([$aros_tool_prefix])
2097     # We are *not* building AROS crosstools - use the AROS or ELF tools
2098     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2099     AROS_REQUIRED(cpp,$orig_target_cpp)
2100     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2101     AROS_REQUIRED(cc,$orig_target_cc)
2102     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2103     AROS_REQUIRED(cxx,$orig_target_cxx)
2104     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2105     AROS_REQUIRED(ld,$orig_target_ld)
2106     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2107     AROS_REQUIRED(as,$orig_target_as)
2108     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2109     AROS_REQUIRED(ar,$orig_target_ar)
2110     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2111     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2112     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2113     AROS_REQUIRED(nm,$orig_target_nm)
2114     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2115     AROS_REQUIRED(strip,$orig_target_strip)
2116     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2117     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2118     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2119     AROS_REQUIRED(objdump,$orig_target_objdump)
2122 if test "$kernel_tool_prefix" = "none" ; then
2123     # No kernel tools specified
2124     # Assume target tools == kernel tools with ELF wrapper
2125     aros_kernel_cc=$orig_target_cc
2126     aros_kernel_cxx=$orig_target_cxx
2127     aros_kernel_cpp=$orig_target_cpp
2128     aros_kernel_ld=$orig_target_ld
2129     aros_kernel_as=$orig_target_as
2130     aros_kernel_ar=$orig_target_ar
2131     aros_kernel_ranlib=$orig_target_ranlib
2132     aros_kernel_nm=$orig_target_nm
2133     aros_kernel_strip=$orig_target_strip
2134     aros_kernel_objcopy=$orig_target_objcopy
2135     aros_kernel_objdump=$orig_target_objdump
2136     use_kernel_cc_wrapper=yes
2139 # At this point, all aros_kernel_* and aros_target_* 
2140 # tools should be set up correctly
2142 CC="$aros_kernel_cc $kernel_tool_flags"
2143 CPP="$aros_kernel_cpp"
2145 #-----------------------------------------------------------------------------
2147 # Find all the tools we need to compile. This could be cross-compiling
2148 # though! If that is the case we use the GNU form of the target and
2149 # simply add this to the front of the binary name. This is rather simple,
2150 # but it should work under most circumstances.
2152 # The default tools are to use the same as the host, but only if the
2153 # host and target CPU are the same. With GCC this is normally enough.
2156 aros_cc_pre=""
2157 aros_shared_ld="$aros_host_ld"
2159 aros_target_mkdep="$aros_host_mkdep"
2161 # The default tools executables to be linked to.
2162 if test "$rescomp" != ""; then
2163     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2164     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2167 # Set up the sources for the symlink farm
2168 if test "$crosstools" = "yes"; then
2169     crosstools_target=tools-crosstools
2172 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2173 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2175 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2176 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2177 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2178 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2179 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2180 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2181 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2183 # aros_cc_pre is a variable that is added to the front of the compiler name
2184 # in the generated aros-gcc shell script. We need this to enable the cache
2185 # to work across cleaned builds. Also, support DISTCC using the correct
2186 # environment variable.
2189 if test "x${DISTCC}" != "x" ; then
2190     if test "x${CCACHE}" != "x" ; then
2191         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2192     else
2193         aros_cc_pre="${DISTCC} "
2194     fi
2195 else
2196     if test "x${CCACHE}" != "x" ; then
2197         aros_cc_pre="${CCACHE} "
2198     fi
2201 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2202 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2203 AC_SUBST(aros_target_nix_ldflags,-nix)
2204 AC_SUBST(aros_target_detach_ldflags,-detach)
2205 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2207 # Target tools
2208 AC_SUBST(aros_toolchain)
2209 if test "$aros_target_toolchain" != "yes"; then
2210     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2211     if test "$GCC" = "yes"; then
2212         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2213     fi
2214 else
2215     # We do not know which c compiler version we are going to build and what we need to know
2216     # here is different for different versions so this will be set later during the
2217     # build of crosstools.
2218     if test "$aros_toolchain" = "gnu" ; then
2219         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2220     elif test "$aros_toolchain" = "llvm" ; then
2221         prefix="$AROS_CROSSTOOLSDIR/bin/"
2222     fi
2223     aros_target_cc_path=@aros_target_cc_path@
2225 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2226 aros_target_cc="${prefix}${toolchain_c_compiler}"
2227 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2228 aros_target_as="${prefix}${toolchain_as}"
2229 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_ld}"
2230 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2231 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2232 aros_target_objdump="${prefix}${toolchain_objdump}"
2233 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2234 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2235 aros_target_strip="${prefix}${toolchain_strip}"
2236 aros_plain_nm="${prefix}${toolchain_nm}"
2237 aros_plain_ar="${prefix}${toolchain_ar}"
2239 AC_ARG_ENABLE(includes,
2240 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2241 [aros_target_incl=$enable_includes], [aros_target_incl=`$aros_kernel_cc -print-sysroot`/`$aros_kernel_cc --print-sysroot-headers-suffix 2>/dev/null || echo usr/include`])
2243 if test "$aros_kernel_includes" = ""; then
2244     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2245         aros_kernel_includes="-isystem $aros_target_incl"
2246     fi
2249 if test "$aros_kernel_includes" != "" ; then
2250     dnl find out about the kernel cc's include path
2251     AC_MSG_CHECKING([for the kernel compiler's include path])
2252     if test "$aros_kernel_cc_includes" = "" ; then
2253         # Try to guess where the directory is.
2254         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2255         if test -d $aros_kernel_cc_includes; then
2256             # Check if there is also an include-fixed directory and add it
2257             # to kernel compiler's include path as it may contain some of
2258             # the headers we need.
2259             if test -d "$aros_kernel_cc_includes"-fixed; then
2260                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2261             fi
2262             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2263             case ${host_cpu} in
2264                 i[[3456]]86)
2265                     host_cpu_glibc=i386
2266                     ;;
2267                 *)
2268                     host_cpu_glibc=${host_cpu}
2269                     ;;
2270             esac
2271             if test -d "/usr/include/${host_cpu_glibc}-linux-gnu"; then
2272                 aros_kernel_cc_includes+=" -isystem /usr/include/${host_cpu_glibc}-linux-gnu"
2273             fi
2274         else
2275             # The directory doesn't exist, we need to do some more work.
2276             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2278             # These are the headers we're looking for.
2279             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2280                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2281                      zutil.h stdint.h"
2283             dirs=
2284             for h in $headers; do
2285                 # Which other headers are needed by each of the above?
2286                 deps=$(echo "#include <$h>" | \
2287                        $aros_kernel_cc -E -M - 2>/dev/null | \
2288                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2290                 # Copy all the needed headers to a directory beneath gendir.
2291                 for d in $deps; do
2292                     h=$(basename $d)
2293                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2294                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2295                     ! test -d $dir && mkdir -p $dir
2296                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2297                 done
2298             done            
2299         fi
2300     fi
2301     AC_MSG_RESULT($aros_kernel_cc_includes)
2302     # Adding -nostdinc to kernel includes as they are always used together.
2303     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2306 if test "$crosstools" != "yes"; then
2307     dnl find out about the target cc's include path
2308     AC_MSG_CHECKING([for the target compiler's include path])
2309     if test "$aros_target_cc_includes" = "" ; then
2310         #try to guess where the directory is
2311         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2312         if ! test -d $aros_target_cc_includes; then
2313             #the directory doesn't exist, we need to do some more work
2314             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2315         
2316             #these are the headers we're looking for
2317             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2318                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2319                     zutil.h"
2321             dirs=
2322             for h in $headers; do
2323                 #which other headers each of the above headers needs?
2324                 deps=$(echo "#include <$h>" | \
2325                     $orig_target_cc -E -M - 2>/dev/null | \
2326                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2327             
2328                 #copy all the needed headers to a directory beneath gendir
2329                 for d in $deps; do
2330                     h=$(basename $d)
2331                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2332                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2333                     ! test -d $dir && mkdir -p $dir
2334                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2335                 done
2336             done
2337         fi
2338     fi
2339     AC_MSG_RESULT($aros_target_cc_includes)
2340 else
2341     # We do not know which c compiler version we are going to build and what we need to know
2342     # here is different for different versions so this will be set later during the
2343     # build of crosstools.
2344     aros_target_cc_includes=@aros_target_cc_includes@
2348 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2349 # On GCC >= 4.0 -iquote should be used
2352 save_cc="$CC"
2353 save_cflags="$CFLAGS"
2354 CFLAGS="-iquote."
2355 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2356 if test "x-$crosstools" != "x-yes"; then
2357     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2358 else
2359     # we do know it is supported for the smallest version of ${toolchain_c_compiler} we are going to build
2360     # we assume it's also supported by later versions
2361     has_iquote=yes
2363 AC_MSG_RESULT($has_iquote)
2364 if test "x-$has_iquote" = "x-yes" ; then
2365     host_cflags_iquote=-iquote
2366     host_cflags_iquote_end=
2367 else
2368     host_cflags_iquote=-I
2369     host_cflags_iquote_end=-I-
2371 kernel_cflags_iquote=$host_cflags_iquote
2372 kernel_cflags_iquote_end=$host_cflags_iquote_end
2373 if test "x-$cross_compiling" = "x-yes"; then
2374     CC="$aros_kernel_cc"
2375     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2376     if test "x-$crosstools" != "x-yes"; then
2377         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2378     else
2379         # we do know it is supported for the smallest version of gcc we are going to build
2380         # we assume it's also supported by later versions
2381         use_no_stack_protector=yes
2382     fi
2383     AC_MSG_RESULT($use_no_stack_protector)
2384     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2385     if test "x-$crosstools" != "x-yes"; then
2386         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2387     else
2388         # we do know it is supported for the smallest version of gcc we are going to build
2389         # we assume it's also supported by later versions
2390         has_iquote=yes
2391     fi
2392     AC_MSG_RESULT($has_iquote)
2393     if test "x-$has_iquote" = "x-yes" ; then
2394         kernel_cflags_iquote=-iquote
2395         kernel_cflags_iquote_end=
2396     else
2397         kernel_cflags_iquote=-I
2398         kernel_cflags_iquote_end=-I-
2399     fi
2401 aros_cflags_iquote=$kernel_cflags_iquote
2402 aros_cflags_iquote_end=$kernel_cflags_iquote_end
2403 if test "$orig_target_cc" != "$aros_kernel_cc"; then
2404     CC="$orig_target_cc"
2405     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2406     if test "x-$crosstools" != "x-yes"; then
2407         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2408     else
2409         # we do know it is supported for the smallest version of gcc we are going to build
2410         # we assume it's also supported by later versions
2411         has_iquote=yes
2412     fi
2413     AC_MSG_RESULT($has_iquote)
2414     if test "x-$has_iquote" = "x-yes" ; then
2415         aros_cflags_iquote=-iquote
2416         aros_cflags_iquote_end=
2417     else
2418         aros_cflags_iquote=-I
2419         aros_cflags_iquote_end=-I-
2420     fi
2422 if test "x-$use_no_stack_protector" = "x-yes" ; then
2423     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2426 #-----------------------------------------------------------------------------
2428 # Check if we can explicitly choose older version of symbol hashing
2430 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2431 CC="$aros_kernel_cc"
2432 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2433 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2434 AC_MSG_RESULT($use_hash_style)
2435 if test "x-$use_hash_style" = "x-yes" ; then
2436     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2438 CC="$save_cc"
2439 CFLAGS="$save_cflags"
2441 AC_SUBST(host_cflags_iquote)
2442 AC_SUBST(host_cflags_iquote_end)
2443 AC_SUBST(kernel_cflags_iquote)
2444 AC_SUBST(kernel_cflags_iquote_end)
2445 AC_SUBST(aros_cflags_iquote)
2446 AC_SUBST(aros_cflags_iquote_end)
2449 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2450 AC_MSG_CHECKING([for default resolution of WBScreen])
2451 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2452 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2453 if test "$resolution" = "yes" ; then
2454     resolution="none"
2456 if test "$resolution" = "no" ; then
2457     resolution="none"
2459 if test "$resolution" != "none" ; then
2460     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2461     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2462     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2464 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2465 aros_cv_nominal_width=$aros_nominal_width
2466 aros_cv_nominal_height=$aros_nominal_height
2467 aros_cv_nominal_depth=$aros_nominal_depth
2469 dnl See if the user wants the serial debug output for native flavour
2470 AC_MSG_CHECKING([whether serial debug is enabled])
2471 AC_ARG_WITH(serial-debug,AC_HELP_STRING([--with-serial-debug],[Enable serial debug output in native (default=no)]),serial_debug=$withval,serial_debug=none)
2472 if test "$aros_serial_debug" = 0 ; then
2473     serial_debug_forced=""
2474     if test "$serial_debug" = "yes" ; then
2475         serial_debug="1"
2476     fi
2477     if test "$serial_debug" = "no" ; then
2478         serial_debug="none"
2479     fi
2480 else
2481     serial_debug_forced="(forced)"
2482     serial_debug=$aros_serial_debug
2484 if test "$serial_debug" != "none" ; then
2485     aros_serial_debug=$serial_debug
2486     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2487 else
2488     AC_MSG_RESULT(no)
2491 dnl See if the user wants the palm debug output hack for palm native flavour
2492 AC_MSG_CHECKING([whether palm debug hack is enabled])
2493 AC_ARG_ENABLE(palm_debug_hack,AC_HELP_STRING([--enable-palm-debug-hack],[Enable palm debug output hack in palm native (default=no)]),palm_debug_hack="yes",palm_debug_hack="no")
2494 if test "$palm_debug_hack" = "yes" ; then
2495     aros_palm_debug_hack="1"
2497 AC_MSG_RESULT($palm_debug_hack)
2499 dnl See if dev wants the usb3.0 code
2500 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2501 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2502 if test "$usb30_code" = "yes" ; then
2503     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2504     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2506 AC_MSG_RESULT($usb30_code)
2508 dnl See if the user wants nesting supervisor activated for unix flavour
2509 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2510 AC_ARG_ENABLE(nesting_supervisor,AC_HELP_STRING([--enable-nesting-supervisor],[Enable nesting supervisor support in unix (default=no)]),nesting_supervisor="yes",nesting_supervisor="no")
2511 if test "$nesting_supervisor" = "yes" ; then
2512     aros_nesting_supervisor="1"
2514 AC_MSG_RESULT($nesting_supervisor)
2516 dnl See if the user wants to disable MMU support
2517 dnl This can be overriden on per-target basis,
2518 dnl set $aros_enable_mmu to "yes" or "no" to do this
2519 if test "$aros_enable_mmu" = "" ; then
2520     AC_MSG_CHECKING([whether MMU support is enabled])
2521     dnl Enabled by default
2522     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2523     if test "$aros_enable_mmu" = "" ; then
2524         aros_enable_mmu="yes"
2525     fi
2526     AC_MSG_RESULT($aros_enable_mmu)
2528 if test "$aros_enable_mmu" = "no" ; then
2529     aros_enable_mmu="0"
2530 else
2531     aros_enable_mmu="1"
2533     
2535 dnl things specifically required for hosted flavours
2536 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2538     if test "x-$need_dlopen" != "x-no" ; then
2539       save_libs="$LIBS"
2540       LIBS=""
2541       dnl some kind of dynamic library access system is required for hostlib.resource
2542       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2543       if test "x-$have_dl" = "x-no" ; then
2544           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2545                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2546                                     have_dl="no")
2547       fi
2548       if test "x-$have_dl" = "x-no" ; then
2549           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2550       fi
2551       LIBS="$save_libs"
2552     fi
2555     dnl x11 hidd
2556     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2557                                            [build X11 hidd for hosted (default=auto)]),
2558                                            x11_hidd="$enableval",
2559                                            x11_hidd="$need_x11")
2560     case "x-$x11_hidd" in
2561         x-yes|x-no|x-auto)                 ;;
2562         *)                 x11_hidd="$need_x11" ;;
2563     esac
2565     ENABLE_X11=0
2567     dnl they want it
2568     if test "x-$x11_hidd" != "x-no" ; then
2570         dnl find x11 stuff
2571         AC_PATH_X
2573         x_cflags=
2574         for path in $x_libraries
2575         do
2576             x_cflags="$x_cflags -L$path"
2577         done
2579         for path in $x_includes
2580         do
2581             x_cflags="$x_cflags -I$path"
2582         done
2583         
2584         if test "x-$no_x" = "x-yes" ; then
2586             dnl didn't find it
2587             if test "x-$x11_hidd" != "x-auto" ; then
2588                 dnl and they explicitly asked for it, bail out
2589                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2590             fi
2591         
2592         else
2593             dnl found it, setup the metatarget
2594             host_x_gfx=yes
2595             ENABLE_X11=1
2597             dnl setup shared memory extensions
2598             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2599                                                   [use X11 shared memory (default=auto)]),
2600                                                   x11_hidd_shm="$enableval",
2601                                                   x11_hidd_shm="auto")
2602             case "x-$x11_hidd_shm" in
2603                 x-yes|x-no|x-auto)                     ;;
2604                 *)                 x11_hidd_shm="auto" ;;
2605             esac
2607             have_xshm=no
2609             dnl they want it
2610             if test "x-$x11_hidd_shm" != "x-no" ; then
2612                 dnl system shm headers
2613                 AC_CHECK_HEADERS(sys/ipc.h)
2614                 AC_CHECK_HEADERS(sys/shm.h)
2616                 dnl got them
2617                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2619                     dnl make sure X libs have shm functions
2620                     save_cflags="$CFLAGS"
2621                     CFLAGS="$CFLAGS $x_cflags"
2622                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2623                     CFLAGS="$save_cflags"
2624                 fi
2625             fi
2627             dnl detection done, prepare output
2628             if test "x-$have_xshm" = "x-yes" ; then
2629                 dnl we can do shm
2630                 DO_XSHM_SUPPORT="1"
2631             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2632                 dnl they explicitly asked for it, but we can't do it
2633                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2634             else
2635                 dnl otherwise just disable it
2636                 DO_XSHM_SUPPORT="0"
2637             fi
2639             
2640             dnl setup vidmode (fullscreen) extensions
2641             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2642                                                       [use X11 vidmode extension (default=auto)]),
2643                                                       x11_hidd_vidmode="$enableval",
2644                                                       x11_hidd_vidmode="auto")
2645             case "x-$x11_hidd_vidmode" in
2646                 x-yes|x-no|x-auto)                         ;;
2647                 *)                 x11_hidd_vidmode="auto" ;;
2648             esac
2650             have_vidmode=no
2652             dnl they want it
2653             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2655                 dnl make sure X libs have vidmode functions
2656                 save_cflags="$CFLAGS"
2657                 CFLAGS="$CFLAGS $x_cflags"
2658                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2659                 CFLAGS="$save_cflags"
2660             fi
2662             dnl detection done, prepare output
2663             if test "x-$have_vidmode" = "x-yes" ; then
2664                 dnl we can do vidmode
2665                 DO_VIDMODE_SUPPORT="1"
2666             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2667                 dnl they explicitly asked for it, but we can't do it
2668                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2669             else
2670                 dnl otherwise just disable it
2671                 DO_VIDMODE_SUPPORT="0"
2672             fi
2673         fi
2675         aros_host_x11_includes=$x_includes 
2676         aros_host_x11_libdirs=$x_libraries
2677     fi
2680     dnl sdl hidd
2681     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2682                                            [build SDL hidd for hosted (default=auto)]),
2683                                            sdl_hidd="$enableval",
2684                                            sdl_hidd="auto")
2685     case "x-$sdl_hidd" in
2686         x-yes|x-no|x-auto)                 ;;
2687         *)                 sdl_hidd="auto" ;;
2688     esac
2690     dnl they want it
2691     if test "x-$sdl_hidd" != "x-no" ; then
2693         dnl find sdl
2694         SDL_VERSION=1.2.5
2695         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2696             [have_sdl="no"])
2698         if test "x-$have_sdl" != "x-yes" ; then
2700             dnl didn't find it
2701             if test "x-$sdl_hidd" != "x-auto" ; then
2702                 dnl and they explicitly asked for it, bail out
2703                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2704             fi
2706         else
2707             dnl found it, enable the build
2708             host_sdl_gfx=yes
2709             aros_host_sdl_cflags=$SDL_CFLAGS
2710             aros_host_sdl_libs=$SDL_LIBS
2711         fi
2712     fi
2717 dnl See if the user wants dbus.library
2718 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2719 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2720 if test "$dbus" = "yes" ; then
2721     ENABLE_DBUS=1
2722     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2723     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2724     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2725     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2726 else
2727     ENABLE_DBUS=0
2729 AC_MSG_RESULT($dbus)
2731 if test "$use_kernel_cc_wrapper" = "yes" ; then
2732     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2735 dnl --------------------------------------------------------------------
2736 dnl Configuration Output Section
2737 dnl --------------------------------------------------------------------
2739 # Generic
2740 AC_SUBST(aros_arch)
2741 AC_SUBST(aros_cpu)
2742 AC_SUBST(aros_flavour)
2743 AC_SUBST(aros_flavour_uc)
2744 AC_SUBST(aros_target_toolchain)
2745 AC_SUBST(aros_build_host)
2746 AC_SUBST(AROS_BUILDDIR)
2747 AC_SUBST(AROS_BUILDDIR_UNIX)
2748 AC_SUBST(SRCDIR)
2749 AC_SUBST(AROS_CROSSTOOLSDIR)
2750 AC_SUBST(AROS_PORTSSRCDIR)
2752 # Compatability with other Amiga-like operation systems
2753 AC_SUBST(aros_amigaos_compliance)
2755 # Host related
2756 AC_SUBST(aros_cc_pre)
2757 AC_SUBST(aros_host_strip)
2758 AC_SUBST(aros_host_arch)
2759 AC_SUBST(aros_host_cpu)
2760 AC_SUBST(aros_host_cpp)
2761 AC_SUBST(aros_host_def_cc)
2762 AC_SUBST(aros_host_cc)
2763 AC_SUBST(aros_host_cxx)
2764 AC_SUBST(aros_host_ar)
2765 AC_SUBST(aros_host_ranlib)
2766 AC_SUBST(aros_host_ld)
2767 AC_SUBST(aros_host_make)
2768 AC_SUBST(aros_host_cflags)
2769 AC_SUBST(aros_host_cxxflags)
2770 AC_SUBST(gnu89_inline)
2771 AC_SUBST(aros_host_ldflags)
2772 AC_SUBST(aros_host_debug)
2773 AC_SUBST(aros_host_mkdep)
2774 AC_SUBST(aros_host_mkargs)
2775 AC_SUBST(aros_host_exe_suffix)
2776 AC_SUBST(aros_host_lib_suffix)
2777 AC_SUBST(aros_tools_dir)
2778 AC_SUBST(aros_host_aclocal)
2779 AC_SUBST(aros_host_autoconf)
2780 AC_SUBST(aros_host_autoheader)
2781 AC_SUBST(aros_host_automake)
2782 AC_SUBST(ant)
2784 # Target Related
2785 AC_SUBST(aros_target_guitheme)
2786 AC_SUBST(aros_target_iconset)
2787 AC_SUBST(aros_target_bootloader)
2788 AC_SUBST(aros_target_arch)
2789 AC_SUBST(aros_target_family)
2790 AC_SUBST(aros_target_cpu)
2791 AC_SUBST(aros_target_cpu_mode)
2792 AC_SUBST(aros_target_variant)
2793 AC_SUBST(aros_target_suffix)
2794 AC_SUBST(aros_target_ar)
2795 AC_SUBST(aros_target_ranlib)
2796 AC_SUBST(aros_plain_nm)
2797 AC_SUBST(aros_plain_ar)
2798 AC_SUBST(aros_kernel_ar)
2799 AC_SUBST(aros_kernel_ranlib)
2800 AC_SUBST(orig_target_cc)
2801 AC_SUBST(aros_target_cc)
2802 AC_SUBST(aros_kernel_cc)
2803 AC_SUBST(orig_target_cxx)
2804 AC_SUBST(aros_target_cxx)
2805 AC_SUBST(aros_kernel_cxx)
2806 AC_SUBST(orig_target_cpp)
2807 AC_SUBST(aros_target_cpp)
2808 AC_SUBST(aros_kernel_cpp)
2809 AC_SUBST(orig_target_as)
2810 AC_SUBST(aros_target_as)
2811 AC_SUBST(aros_kernel_as)
2812 AC_SUBST(orig_target_ld)
2813 AC_SUBST(aros_target_ld)
2814 AC_SUBST(aros_kernel_ld)
2815 AC_SUBST(aros_target_cc_includes)
2816 AC_SUBST(aros_target_cc_path)
2817 AC_SUBST(aros_target_objdump)
2818 AC_SUBST(aros_target_objcopy)
2819 AC_SUBST(aros_target_strip)
2820 AC_SUBST(aros_target_nm)
2821 AC_SUBST(aros_kernel_rescomp)
2822 AC_SUBST(aros_shared_default)
2823 AC_SUBST(aros_shared_ld)
2824 AC_SUBST(aros_object_format)
2825 AC_SUBST(spec_obj_format)
2826 AC_SUBST(aros_compiler_libs)
2827 AC_SUBST(aros_arch_libs)
2829 AC_SUBST(aros_shared_cflags)
2830 AC_SUBST(aros_shared_aflags)
2831 AC_SUBST(aros_shared_ldflags)
2833 AC_SUBST(aros_config_sysroot)
2834 AC_SUBST(aros_nowarn_flags)
2835 AC_SUBST(aros_config_cflags)
2836 AC_SUBST(aros_config_aflags)
2837 AC_SUBST(aros_config_ldflags)
2839 AC_SUBST(aros_kernel_sysroot)
2840 AC_SUBST(aros_kernel_cflags)
2841 AC_SUBST(aros_kernel_includes)
2842 AC_SUBST(aros_kernel_objcflags)
2843 AC_SUBST(aros_kernel_ldflags)
2844 AC_SUBST(aros_target_cflags)
2845 AC_SUBST(aros_debug_cflags)
2846 AC_SUBST(aros_debug_aflags)
2847 AC_SUBST(aros_debug_ldflags)
2848 AC_SUBST(aros_target_genmap)
2849 AC_SUBST(aros_target_strip_flags)
2850 AC_SUBST(aros_optimization_cflags)
2851 AC_SUBST(aros_isa_flags)
2853 AC_SUBST(crosstools_target)
2854 AC_SUBST(crosstools_cxx_target)
2856 # Hosted Graphics Related
2857 AC_SUBST(host_x_gfx)
2858 AC_SUBST(host_sdl_gfx)
2859 AC_SUBST(host_android_gfx)
2861 AC_SUBST(pci_hidd_target)
2863 AC_SUBST(aros_nominal_width)
2864 AC_SUBST(aros_nominal_height)
2865 AC_SUBST(aros_nominal_depth)
2866 AC_SUBST(DO_XSHM_SUPPORT)
2867 AC_SUBST(DO_VIDMODE_SUPPORT)
2869 AC_SUBST(aros_host_x11_includes)
2870 AC_SUBST(aros_host_x11_libdirs)
2871 AC_SUBST(aros_host_sdl_cflags)
2872 AC_SUBST(aros_host_sdl_libs)
2874 # Native version related
2875 AC_SUBST(aros_serial_debug)
2876 AC_SUBST(ENABLE_EXECSMP)
2878 # Palm native version related
2879 AC_SUBST(aros_palm_debug_hack)
2881 # Unix/Hosted version related
2882 AC_SUBST(aros_nesting_supervisor)
2884 # MMU related
2885 AC_SUBST(aros_enable_mmu)
2887 # Apple iOS related
2888 AC_SUBST(aros_ios_platform)
2889 AC_SUBST(aros_ios_version)
2890 AC_SUBST(aros_ios_sdk)
2892 # ARM default GCC target related
2893 AC_SUBST(gcc_default_cpu)
2894 AC_SUBST(gcc_default_cpu_tune)
2895 AC_SUBST(gcc_default_fpu)
2896 AC_SUBST(gcc_default_float_abi)
2897 AC_SUBST(gcc_default_mode)
2899 # Android related
2900 AC_SUBST(android_tool)
2901 AC_SUBST(aros_android_level)
2902 AC_SUBST(aros_android_antapk)
2904 # DBUS related
2905 AC_SUBST(ENABLE_DBUS)
2906 AC_SUBST(DBUS_CFLAGS)
2907 AC_SUBST(DBUS_LIBFLAGS)
2908 AC_SUBST(KERNEL_DBUS_KOBJ)
2909 AC_SUBST(KERNEL_DBUS_INCLUDES)
2911 #X11 related
2912 AC_SUBST(ENABLE_X11)
2914 # Debug related
2915 AC_SUBST(aros_debug)
2916 AC_SUBST(aros_mungwall_debug)
2917 AC_SUBST(aros_stack_debug)
2918 AC_SUBST(aros_modules_debug)
2920 # Collect-aros stuff: "-ius" to ignore undefined symbols
2921 AC_SUBST(ignore_undefined_symbols)
2923 # C compiler related
2924 AC_SUBST(gcc_target_cpu)
2925 AC_SUBST(target_binutils_version)
2926 AC_SUBST(target_gcc_version)
2928 #ObjC compiler related
2929 AC_SUBST(objc_target)
2931 #Java related
2932 AC_SUBST(java_target)
2934 # USB3.0 code
2935 AC_SUBST(aros_usb30_code)
2937 dnl Prepare for output, make up all the generated patches
2938 case "$aros_flavour" in
2939 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2940                 aros_flavour="emulation" ;;
2941 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2942                 aros_flavour="emulation" ;;
2943 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2944                 aros_flavour="standalone";;
2945 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2946                 aros_flavour="standalone";;
2947 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2948                 aros_flavour="native" ;;
2949 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2950                 aros_flavour="native" ;;
2951 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2952                 aros_flavour="linklib" ;;
2953 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2954                 aros_flavour="palmnative" ;;
2955 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2956                 aros_flavour="mac68knative" ;;
2957 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2958                 aros_flavour="ppcnative" ;;
2959 esac
2961 if test ! -d ${aros_inc_dir} ; then
2962     ${MKDIR} ${aros_inc_dir}
2964 if test ! -d ${aros_geninc_dir} ; then
2965     ${MKDIR} ${aros_geninc_dir}
2967 if test ! -d ${aros_hostcfg_dir} ; then
2968     ${MKDIR} ${aros_hostcfg_dir}
2970 if test ! -d ${aros_targetcfg_dir} ; then
2971     ${MKDIR} ${aros_targetcfg_dir}
2973 if test ! -d ${aros_tools_dir} ; then
2974     ${MKDIR} ${aros_tools_dir}
2976 if test ! -d ${aros_scripts_dir} ; then
2977     ${MKDIR} ${aros_scripts_dir}
2980 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2982 # Generic build tools (metamake, etc)
2983 AC_CONFIG_COMMANDS([genmf-executable-support],
2984     [chmod a+x ${aros_tools_dir}/genmf.py],
2985     [aros_tools_dir=${aros_tools_dir}]
2987 AC_CONFIG_FILES(
2988     Makefile
2989     config/make.cfg
2990     ${aros_inc_dir}/config.h:config/config.h.in
2991     ${aros_geninc_dir}/config.h:config/config.h.in
2992     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2993     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2994     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
2995     mmake.config
2996     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2997     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2998     tools/collect-aros/env.h
3001 # Binutils
3002 AC_CONFIG_COMMANDS([binutils-support],
3003     [
3004         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3005         mkdir -p $prefix
3006         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3008         chmod a+x ${prefix2}-ld
3010         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3011         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3012         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3013         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3014         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3015         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3016         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3017     ],
3018     [
3019         aros_host_exe_suffix=${aros_host_exe_suffix}
3020         aros_tools_dir=${aros_tools_dir}
3021         aros_target_cpu=${aros_target_cpu}
3022         aros_target_arch=${aros_target_arch}
3023         aros_target_suffix=${aros_target_suffix}
3024         orig_target_nm=${orig_target_nm}
3025         orig_target_as=${orig_target_as}
3026         orig_target_ar=${orig_target_ar}
3027         orig_target_ranlib=${orig_target_ranlib}
3028         orig_target_objdump=${orig_target_objdump}
3029         orig_target_objcopy=${orig_target_objcopy}
3030         orig_target_strip=${orig_target_strip}
3031         aros_kernel_ld=${aros_kernel_ld}
3032     ]
3034 AC_CONFIG_FILES(
3035     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
3038 # Bare Elf support script and spec
3039 if test "${use_kernel_cc_wrapper}" = "yes"; then
3040     AC_CONFIG_COMMANDS([elf-compiler-support],
3041         [
3042             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3043             mkdir -p $prefix
3044             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3046             chmod a+x ${prefix2}-gcc
3048             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3049         ],
3050         [
3051             aros_host_exe_suffix=${aros_host_exe_suffix}
3052             aros_tools_dir=${aros_tools_dir}
3053             aros_target_cpu=${aros_target_cpu}
3054             aros_target_arch=${aros_target_arch}
3055             aros_target_suffix=${aros_target_suffix}
3056             aros_kernel_ld=${aros_kernel_ld}
3057         ]
3058     )
3059     AC_CONFIG_FILES(
3060         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3061         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3062     )
3065 # Host compiler support scripts and spec
3066 if test "${aros_target_toolchain}" = "no"; then
3067     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3068         [
3069             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3070             mkdir -p $prefix
3071             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3073             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3074         ],
3075         [
3076             aros_host_exe_suffix=${aros_host_exe_suffix}
3077             aros_tools_dir=${aros_tools_dir}
3078             aros_target_cpu=${aros_target_cpu}
3079             aros_target_arch=${aros_target_arch}
3080             aros_target_suffix=${aros_target_suffix}
3081         ]
3082     )
3083     AC_CONFIG_FILES(
3084         ${aros_targetcfg_dir}/specs:config/specs.in
3085         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3086         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3087         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3088     )
3091 # Android support
3092 if test "$aros_target_variant" == "android"; then
3093     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3096 # cmake helper
3097 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3099 AC_OUTPUT
3101 dnl This is in order to not define SHARED_CFLAGS sometimes
3102 dnl We don't always do aros_shared_ar, aros_shared_cflags
3104 #XXX compatability...
3105 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3107 if test -n "$aros_shared_cflags" ; then
3108     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3109     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg