Test current SDI headers.
[AROS.git] / configure.in
blob30869d0b2ba6915de910636a058705f3a27c4929
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         AC_CHECK_FILE(/usr/include/stddef.h,,
258                 AC_MSG_ERROR([XCode incorrectly configured!
259 please run 'xcode-select --install' before
260 re-running configure])
261         )
262         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
263         aros_host_arch="darwin"
264         host_cc_elf=no
265         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
266         android_build_os="darwin-x86"
267         android_tool="android"
268         default_android_sdk="/android-sdk-mac_x86"
269         case "$host_cpu" in
270             *i?86*)
271                 aros_host_cpu="i386"
272                 ;;
273             *x86_64*)
274                 aros_host_cpu="x86_64"
275                 ;;
276             *powerpc*)
277                 aros_host_cpu="ppc"
278                 ;;
279             *)
280                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
281                 aros_host_cpu="$host_cpu"
282                 ;;
283         esac
285         aros_host_ldflags="$aros_host_ldflags -liconv"
287         ;;
289     dragonfly*)
290         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
291         aros_host_make="gmake"
292         aros_host_arch="dragonfly"
293         case $host_cpu in
294             *i?86*)
295                 aros_host_cpu="i386"
296                 ;;
297             *amd64*)
298                 aros_host_cpu="x86_64"
299                 ;;
300             *)
301                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
302                 aros_host_cpu="$host_cpu"
303                 ;;
304         esac
305         ;;
307     netbsd*)
308         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
309         aros_host_make="gmake"
310         aros_host_arch="netbsd"
311         case "$host_cpu" in
312             *i?86*)
313                 aros_host_cpu="i386"
314                 ;;
315             *m68k*)
316                 aros_host_cpu="m68k"
317                 ;;
318             *)
319                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
320                 aros_host_cpu="$host_cpu"
321                 ;;
322         esac    
323         aros_host_lib_suffix=".0.0"
324         ;;
326     openbsd*)
327         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
328         aros_host_make="gmake"
329         aros_host_arch="openbsd"
330         case "$host_cpu" in
331             *i?86*)
332                 aros_host_cpu="i386"
333                 ;;
334             *)
335                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
336                 aros_host_cpu="$host_cpu"
337                 ;;
338         esac
339         ;;
340         
341     solaris*)
342         aros_host_arch="solaris"
343         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
344         case "$host_cpu" in
345             *i?86*)
346                 aros_host_cpu="i386"
347                 ;;
348             *sparc*)
349                 aros_host_cpu="sparc"
350                 ;;
351             *)
352                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
353                 aros_host_cpu="$host_cpu"
354                 ;;
355         esac
356         ;;
358     morphos*)
359         aros_host_arch="morphos"
360         aros_host_cpu="ppc"
361         host_cc_elf=no
362         ;;
364     amiga*)
365         aros_host_arch="amiga"
366         host_cc_elf=no
367         SORT="/gg/bin/sort"
368         TEST="/gg/bin/test"
369         UNIQ="/gg/bin/uniq"
370         FOR="for"
371         TOUCH="/gg/bin/touch"
372         case "$host_cpu" in
373             *m68k*)
374                 aros_host_cpu="m68k"
375                 ;;
376             *powerpc*)
377                 aros_host_cpu="ppc"
378                 ;;
379             *)
380                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
381                 aros_host_cpu="$host_cpu"
382                 ;;
383         esac
384         ;;
386     cygwin*)
387         aros_host_arch="cygwin"
388         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
389         host_cc_elf=no
390         android_build_os="windows"
391         android_tool="android.bat"
392         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
394         case "$host_cpu" in
395             *i?86*)
396                 aros_host_cpu="i386"
397                 ;;
398             *)
399                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
400                 aros_host_cpu="$host_cpu"
401                 ;;
402         esac
403         ;;
405     mingw32*)
406         aros_host_arch="mingw32"
407         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
408         host_cc_elf=no
409         android_build_os="windows"
410         android_tool="android.bat"
411         default_android_sdk="/c/android-sdk-windows-1.6_r1"
413         libpng_libextra="-lws2_32"
415         case "$host_cpu" in
416         *i?86*)
417             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
418             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
419             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
420             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
422             AC_MSG_CHECKING([for Windows native gcc target])
423             host_cpu=`gcc -dumpmachine`
424             AC_MSG_RESULT($host_cpu)
425             ;;
427         esac
429         case "$host_cpu" in
430         *i?86*)
431             aros_host_cpu="i386"
432             ;;
434         mingw32*)
435             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
436             aros_host_cpu="i386"
437             ;;
439         *x86_64*)
440             aros_host_cpu="x86_64"
441             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
442             dnl directory, so we have to add it explicitly here.
443             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
444             ;;
446         *)
447             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
448             aros_host_cpu="$host_cpu"
449             ;;
450         esac
451         ;;
452     *)
453         AC_MSG_ERROR([Unsupported host architecture $host])
454         ;;
455 esac
457 AROS_PROG(aros_host_ar,[ar],[cr])
458 AROS_REQUIRED(ar,$aros_host_ar)
459 AROS_PROG(aros_host_ranlib,ranlib)
460 AROS_REQUIRED(ranlib,$aros_host_ranlib)
461 AROS_PROG(aros_host_strip,strip)
462 AROS_REQUIRED(strip,$aros_host_strip)
464 AROS_PROG(RM,[rm],[-rf])
465 AROS_REQUIRED(rm,$RM)
466 AROS_PROG(CP,[cp])
467 AROS_REQUIRED(cp,$CP)
468 AROS_PROG(MV,[mv])
469 AROS_REQUIRED(mv,$MV)
470 AROS_PROG(ECHO,[echo])
471 AROS_REQUIRED(echo,$ECHO)
472 AROS_PROG(MKDIR,[mkdir],[-p])
473 AROS_REQUIRED(mkdir,$MKDIR)
474 AROS_PROG(TOUCH,[touch])
475 AROS_REQUIRED(touch,$TOUCH)
476 AROS_PROG(SORT,[sort])
477 AROS_REQUIRED(sort,$SORT)
478 AROS_PROG(UNIQ,[uniq])
479 AROS_REQUIRED(uniq,$UNIQ)
480 AROS_PROG(NOP,[true])
481 AROS_REQUIRED(true,$NOP)
482 AROS_PROG(CAT,[cat])
483 AROS_REQUIRED(cat,$CAT)
484 AROS_PROG(BISON,[bison])
485 AROS_REQUIRED(bison,$BISON)
486 AROS_PROG(FLEX,[flex])
487 AROS_REQUIRED(flex,$FLEX)
488 AROS_PROG(PNGTOPNM,[pngtopnm])
489 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
490 AROS_PROG(PPMTOILBM,[ppmtoilbm])
491 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
492 AROS_PROG(SED,[sed])
493 AROS_REQUIRED(sed,$SED)
494 AROS_PROG(CHMOD,[chmod])
495 AROS_REQUIRED(chmod,$CHMOD)
496 AROS_PROG(PATCH,[patch])
497 AROS_REQUIRED(patch,$PATCH)
499 AM_PATH_PYTHON(2.5)
501 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
502 if test "$enable_libpng_config" != "no"; then
503   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
505 if test "$arosconfig_use_libpngconfig" = "yes"; then
506     AC_MSG_CHECKING([libpng-config library])
507     libpng_incdir="`libpng-config --cflags`"
508     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
509     libpng="`libpng-config --libs`"
510     AC_MSG_RESULT($libpng)
511 else
512     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
513     if test "$libpng_libextra" != ""; then
514         if test "$libpng" != "no"; then
515             libpng_libextra="$libpng_libextra $libpng"
516         fi
517     fi
519 AROS_REQUIRED(libpng, $libpng)
520 AC_SUBST(libpng)
521 AC_SUBST(libpng_libextra)
522 AC_SUBST(libpng_incdir)
524 AC_SUBST(FOR, for)
525 AC_SUBST(IF, if)
526 AC_SUBST(TEST, test)
527 AC_SUBST(CMP, cmp)
529 dnl ---------------------------------------------------------------------------
530 dnl Look for things about the host system, good for hosted targets.
531 dnl ---------------------------------------------------------------------------
533 # Check for some includes for the X11 HIDD and the kernel
534 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
535     sys/mmap.h sys/mman.h sysexits.h \
536     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
539 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
541 AC_HEADER_DIRENT
542 AC_HEADER_STAT
543 AC_HEADER_STDC
544 AC_HEADER_SYS_WAIT
545 AC_HEADER_TIME
546 AC_STRUCT_ST_BLKSIZE
547 AC_STRUCT_ST_BLOCKS
548 AC_STRUCT_ST_RDEV
549 AC_STRUCT_TM
550 AC_STRUCT_TIMEZONE
551 AC_TYPE_OFF_T
552 AC_TYPE_PID_T
553 AC_TYPE_SIZE_T
554 AC_TYPE_UID_T
556 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
558 # Look for some functions
559 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
560     clone kse_create rfork_thread thr_create sa_register \
561     getcontext makecontext setcontext sigaltstack swapcontext])
563 AC_FUNC_MMAP
565 #-----------------------------------------------------------------------------
568 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
569 # it switched on by default, and we use the host compiler, so it compiles AROS
570 # code with this enabled resulting in link failures as we don't have support
571 # for it.
573 # We use two methods to disable it. For the host compiler (used to compile
574 # some hosted modules), we test to see if the compiler supports stack
575 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
576 # work on all platforms.
579 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
580 save_cflags="$CFLAGS"
581 CFLAGS="$CFLAGS -fno-stack-protector"
582 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
583 AC_MSG_RESULT($use_no_stack_protector)
584 if test "x-$use_no_stack_protector" = "x-yes" ; then
585     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
587 CFLAGS="$save_cflags"
589 #-----------------------------------------------------------------------------
591 # Disable pointer-signedness warnings if the compiler recognises the option
592 # (this only works for the host compiler at the moment)
594 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
595 save_cflags="$CFLAGS"
596 CFLAGS="$CFLAGS -Wno-pointer-sign"
597 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
598 AC_MSG_RESULT($use_no_sign_warning)
599 if test "x-$use_no_sign_warning" = "x-yes" ; then
600     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
602 CFLAGS="$save_cflags"
604 #-----------------------------------------------------------------------------
606 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
608 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
609 save_cflags="$CFLAGS"
610 CFLAGS="$CFLAGS -fgnu89-inline"
611 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
612 AC_MSG_RESULT($use_gnu89_inline)
613 if test "x-$use_gnu89_inline" = "x-yes" ; then
614     gnu89_inline="-fgnu89-inline"
616 CFLAGS="$save_cflags"
619 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
620 # On GCC >= 4.0 -iquote should be used
622 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
623 CFLAGS="$CFLAGS -iquote."
624 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
625 AC_MSG_RESULT($has_iquote)
626 if test "x-$has_iquote" = "x-yes" ; then
627     host_cflags_iquote=-iquote
628     host_cflags_iquote_end=
629 else
630     host_cflags_iquote=-I
631     host_cflags_iquote_end=-I-
634 AC_MSG_NOTICE([Performing target configuration...])
636 dnl --------------------------------------------------------------------
637 dnl Target Configuration Section
638 dnl --------------------------------------------------------------------
640 dnl The target configuration section is responsible for setting up all
641 dnl the paths for includes, and tools required to build AROS to some
642 dnl particular target.
644 aros_nowarn_flags="NOWARN_UNUSED_COMMAND_LINE_ARGUMENT NOWARN_UNKNOWN_WARNING_OPTION NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
646 toolchain_needs_sysroot=no
648 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
649 aros_config_aflags="-Wall -x assembler-with-cpp -c"
650 aros_config_ldflags=""
652 aros_shared_default=yes
654 aros_shared_cflags="-fPIC"
655 aros_shared_aflags=""
656 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
657 aros_kernel_ldflags="-Wl,-rpath,./lib"
659 aros_kernel_ar_flags="cr"
660 aros_target_ar_flags="cr"
661 aros_target_nm_flags="-C -ul"
662 aros_target_strip_flags="--strip-unneeded -R.comment"
664 aros_compiler_libs=
665 aros_arch_libs=
667 aros_target_genmap="-Wl,-Map -Xlinker"
669 # Native flavour stuff
670 aros_serial_debug="0"
672 # Palm native flavour stuff
673 aros_palm_debug_hack="0"
675 # Unix flavour stuff
676 aros_nesting_supervisor="0"
678 # Collect-aros stuff: "-ius" to ignore undefined symbols
679 ignore_undefined_symbols=""
681 # Check for X11 by default
682 need_x11="auto"
684 host_x_gfx=no
685 host_sdl_gfx=no
686 host_android_gfx=no
689 AC_MSG_CHECKING([Which toolchain family to use ...])
690 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")
691 AC_MSG_RESULT($aros_toolchain)
694 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
695 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=yes)]),
696  aros_config_lto="$enableval",aros_config_lto="yes")
697 if test "$aros_config_lto" != "yes"; then
698     aros_config_lto="no"
700 AC_MSG_RESULT($aros_config_lto)
703 case "$aros_toolchain" in
704     *llvm*)
705         # toolchain_needs_sysroot=yes
706         toolchain_c_compiler="clang"
707         toolchain_cxx_compiler="clang++"
708         toolchain_cpp_preprocessor="clang -E"
709         toolchain_ld="ld.lld"
710         toolchain_as="llvm-as"
711         toolchain_ar="llvm-ar"
712         toolchain_ranlib="llvm-ranlib"
713         toolchain_nm="llvm-nm"
714         toolchain_strip="true"
715         toolchain_objcopy="llvm-objcopy"
716         toolchain_objdump="llvm-objdump"
717         ;;
718     *gnu*)
719         toolchain_c_compiler="gcc"
720         toolchain_cxx_compiler="g++"
721         toolchain_cpp_preprocessor="gcc -E"
722         toolchain_as="as"
723         if test "$aros_config_lto" != "yes"; then
724             toolchain_ld="ld"
725             toolchain_ar="ar"
726             toolchain_ranlib="ranlib"
727             toolchain_nm="nm"
728         else
729             toolchain_ld="ld.bfd"
730             toolchain_ar="gcc-ar"
731             toolchain_ranlib="gcc-ranlib"
732             toolchain_nm="gcc-nm"
733         fi
734         toolchain_strip="strip"
735         toolchain_objcopy="objcopy"
736         toolchain_objdump="objdump"
737         ;;
738     *)
739         AC_MSG_WARN("Unknown toolchain family!")
740         toolchain_c_compiler="cc"
741         toolchain_cxx_compiler="c++"
742         toolchain_cpp_preprocessor="cpp"
743         toolchain_ld="ld"
744         toolchain_as="as"
745         toolchain_ar="ar"
746         toolchain_ranlib="ranlib"
747         toolchain_nm="nm"
748         toolchain_strip="strip"
749         toolchain_objcopy="objcopy"
750         toolchain_objdump="objdump"
751         ;;
752 esac
754 #-----------------------------------------------------------------------------
756 AC_MSG_CHECKING([which type of build to do])
757 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")
759 if test "$build_type" = "nightly"; then
760     build_type_string="NIGHTLY"
761 elif test "$build_type" = "snapshot"; then
762     build_type_string="SNAPSHOT"
763 elif test "$build_type" = "milestone"; then
764     build_type_string="MILESTONE"
765 elif test "$build_type" = "release"; then
766     build_type_string="RELEASE"
767 else
768     build_type_string="PERSONAL"
769     build_type="personal"
772 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
774 AC_MSG_RESULT($build_type)
776 #-----------------------------------------------------------------------------
777 all_debug_types="messages stack modules mungwall symbols"
779 AC_MSG_CHECKING([which debug types to enable])
780 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)]),
781  debug="$enableval",debug="")
783 if test "$debug" = "" -o "$debug" = "no"; then
784     debug="none"
785 elif test "$debug" = "yes"; then
786     debug="all"
789 if test "$debug" = "all" ; then
790     debug="messages stack modules symbols"
791     for d in $all_debug_types; do
792         export aros_${d}_debug="1"
793     done
794 else
795     for d in $all_debug_types; do
796         export aros_${d}_debug="0"
797     done
800 if test "$debug" != "none"; then
801     debug=`echo $debug | sed s/,/\ /g`
802     for d in $debug; do
803         found="0"
804         for d2 in $all_debug_types; do
805             if test "$d2" = "$d"; then
806                 found="1"
807                 break
808             fi
809         done
810         if test "$found" = "0"; then
811             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
812         fi
813         export aros_${d}_debug="1"
814     done
815     aros_debug="yes"
817 AC_MSG_RESULT($debug)
819 if test "$aros_messages_debug" = "1"; then
820     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
821 else
822     aros_messages_debug=""
824 if test "$aros_symbols_debug" = "1"; then
825     aros_symbols_debug="-g"
826 else
827     aros_symbols_debug=""
830 # These are the flags to pass when compiling debugged programs
831 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
832 aros_debug_aflags=""
833 aros_debug_ldflags="$aros_symbols_debug"
835 #-----------------------------------------------------------------------------
836 #   Checking for distcc and ccache.
838 #   Always apply the transforms in this particular order. Basically you should
839 #   always run 'ccache distcc compiler' in that order for the best performance.
841 AC_MSG_CHECKING([whether to enable distcc])
842 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
843 if test "$distcc" != "" -a "$distcc" != "no"; then
844     # AC_CHECK_PROG will print out the result in this case
845     AC_PATH_PROG(DISTCC,[distcc],distcc,)
846 else
847     AC_MSG_RESULT(no)
850 AC_MSG_CHECKING([whether to enable ccache])
851 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
852 if test "$ccache" != "" -a "$ccache" != "no"; then
853     # AC_CHECK_PROG will print out the result in this case
854     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
855 else
856     AC_MSG_RESULT(no)
859 #-----------------------------------------------------------------------------
860 AC_MSG_CHECKING([what specific host gcc version to use])
861 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="")
862 if test "$kernel_tool_version" != "" ; then
863     msg_result=$kernel_tool_version
864 else
865     msg_result="default"
867 AC_MSG_RESULT($msg_result)
869 #-----------------------------------------------------------------------------
870 AC_MSG_CHECKING([what optimization flags to use])
871 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
872 if test "$optimization" = "unknown"; then
873     dnl default is -O2 for normal builds, -O0 for debug builds
874     if test "$debug" != "none"; then
875         optimization="-O0"
876     else
877         optimization="-O2"
878     fi
880 aros_optimization_cflags="$optimization"
881 AC_MSG_RESULT($optimization)
883 paranoia_default=yes
884 #-----------------------------------------------------------------------------
885 AC_MSG_CHECKING([which paranoia flags to use])
886 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=(yes|no|FLAGS)],[Specific compiler warning FLAGS to enable for paranoia builds (default=-Wall -Werror)]),[paranoia_flags="$withval"],[paranoia_flags="$paranoia_default"])
887 if test "$paranoia_flags" = "no"; then
888         paranoia_flags=""
889         msg_result="none"
890 else
891     if test "$paranoia_flags" = "yes"; then
892         paranoia_flags="-Wall -Werror"
893     fi
894     msg_result="$paranoia_flags"
896 AC_MSG_RESULT($msg_result)
897 aros_config_cflags="$aros_config_cflags $paranoia_flags"
899 #-----------------------------------------------------------------------------
900 AC_MSG_CHECKING([what target variant to enable])
901 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
902 if test "$target_variant" = ""; then
903     aros_target_variant=""
904     aros_target_suffix=""
905     enableval="none"
906 else
907     aros_target_variant="$target_variant"
908     aros_target_suffix="-$target_variant"
910 AC_MSG_RESULT($enableval)
912 #-----------------------------------------------------------------------------
913 # Target-specific defaults. You can override then on a per-target basis.
915 # Bootloader name. Currently used by PC target.
916 target_bootloader="none"
917 ENABLE_EXECSMP=
919 #-----------------------------------------------------------------------------
920 # Additional options for some specific targets
922 case "$aros_target_variant" in
923 ios)
924     AC_MSG_CHECKING([XCode path])
925     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")
926     AC_MSG_RESULT($aros_xcode_path)
928     AC_MSG_CHECKING([what iOS SDK version to use])
929     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")
930     AC_MSG_RESULT($aros_sdk_version)
932     ;;
934 "android")
935     AC_MSG_CHECKING([Android SDK path])
936     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)
937     AC_MSG_RESULT($aros_android_sdk)
939     AC_MSG_CHECKING([Android NDK path])
940     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
941     AC_MSG_RESULT($aros_android_ndk)
943     AC_MSG_CHECKING([what Android SDK version to use])
944     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")
945     AC_MSG_RESULT($aros_sdk_version)
947     aros_android_level=android-$aros_sdk_version
948     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
949         echo "Platform $aros_android_level is not installed in your SDK"
950         echo "Use --with-sdk-version=<API level number> to select another platform version"
951         echo "You can check what plaform versions are installed in your SDK"
952         echo "by examining contents of $aros_android_sdk/platforms directory"
953         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
954     fi
956     export PATH="$aros_android_sdk/tools:$PATH"
957     AC_PATH_PROG(android_tool, $android_tool)
958     AROS_REQUIRED(android,$android_tool)
960     if test "$aros_android_ndk" != "none"; then
961         AC_MSG_CHECKING([what Android NDK version to use])
962         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")
963         AC_MSG_RESULT($aros_ndk_version)
964     fi
966     AC_PATH_PROG(ant, ant)
967     if test "$ant" = ""; then
968         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
969     fi
971     AC_MSG_CHECKING([Build debug or release apk])
972     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)
973     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
974         AC_MSG_ERROR([apk-version has to be release or debug])
975     fi
976     AC_MSG_RESULT($aros_android_antapk)
978     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
979     if test "$host_os" = "mingw32"; then
980         android_tool="cmd //c $android_tool"
981     fi
983     need_dlopen="no"
985     ;;
986 esac
988 #-----------------------------------------------------------------------------
989 # External toolchains
990 kernel_tool_prefix="none"
991 aros_tool_prefix="none"
992 elf_tool_prefix="${target_cpu}-elf-"
994 # This is the target configuration switch.
995 case "$target_os" in
996     linux*)
997         aros_target_arch="linux"
998         aros_target_family="unix"
999         case "$target_cpu" in
1000             *m68k*)
1001                 aros_target_cpu="m68k"
1002                 aros_object_format="m68kelf"
1003                 aros_flavour="emulcompat"
1004                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1005                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1006                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1007                 gcc_target_cpu="mc68000"
1008                 ;;
1009             *i?86*)
1010                 aros_target_cpu="i386"
1011                 aros_object_format="elf_i386"
1012                 aros_flavour="emulation"
1013                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1014                 aros_kernel_ldflags="-Wl,-melf_i386"
1015                 aros_nominal_depth=8
1016                 gcc_target_cpu="i386"
1017                 pci_hidd_target="hidd-pci-linux"
1018                 android_tool_dir_prefix="x86"
1019                 android_tool_prefix="i686-android-linux"
1020                 android_ndk_arch="x86"
1021                 ;;
1022             *x86_64*)
1023                 aros_target_cpu="x86_64"
1024                 aros_object_format="elf_x86_64"
1025                 aros_flavour="emulation"
1026                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1027                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1028                 aros_nominal_depth=8
1029                 pci_hidd_target="hidd-pci-linux"
1030                 ;;
1031             *powerpc*)
1032                 aros_target_cpu="ppc"
1033                 aros_object_format="elf32ppc"
1034                 aros_flavour="emulation"
1035                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1036                 aros_nominal_depth=8
1037                 gcc_target_cpu="ppc"
1038                 ;;
1039 # TODO
1040 # Same as powerpc, but I need this for the nightly build to work again.
1041 # Actually, the nightly should be made working with powerpc target.
1042 # That just was too much work for the moment, another week or two.
1043             *ppc*)
1044                 aros_target_cpu="ppc"
1045                 aros_object_format="elf32ppc"
1046                 aros_flavour="emulation"
1047                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1048                 aros_nominal_depth=8
1049                 gcc_target_cpu="ppc"
1050                 ;;
1051             *aarch64*)
1052                 aros_target_cpu="aarch64"
1053                 target_cpu="aarch64"
1054                 aros_object_format="aarch64elf_aros"
1055                 aros_flavour="emulation"
1056                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1057                 gcc_target_cpu="aarch64"
1058                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1059                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1060                 aros_arch_libs="-laeabi"
1061                 gcc_default_float_abi="hard"
1062                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1063                 ;;
1064             *armhf*)
1065                 aros_target_cpu="arm"
1066                 target_cpu="arm"
1067                 aros_object_format="armelf_aros"
1068                 aros_flavour="emulation"
1069                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1070                 gcc_target_cpu="arm"
1071                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1072                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1073                 aros_arch_libs="-laeabi"
1074                 gcc_default_float_abi="hard"
1075                 android_tool_dir_prefix="arm-linux-androideabi"
1076                 android_tool_prefix="arm-linux-androideabi"
1077                 android_ndk_arch="arm"
1078                 kernel_tool_prefix="arm-linux-gnueabihf-"
1079                 ;;
1080             *arm*)
1081                 aros_target_cpu="arm"
1082                 aros_object_format="armelf_aros"
1083                 aros_flavour="emulation"
1084                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1085                 gcc_target_cpu="arm"
1086                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1087                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1088                 aros_arch_libs="-laeabi"
1089                 android_tool_dir_prefix="arm-linux-androideabi"
1090                 android_tool_prefix="arm-linux-androideabi"
1091                 android_ndk_arch="arm"
1092                 kernel_tool_prefix="arm-linux-gnueabi-"
1093                 ;;
1094             *)
1095                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1096                 ;;
1097         esac
1098         case "$aros_target_variant" in
1099             android)
1101                 dnl Not all Linux CPUs are supported by Android
1102                 if test "$android_ndk_arch" = ""; then
1103                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1104                 fi
1106                 aros_nominal_width=320
1107                 aros_nominal_height=480
1108                 if test "$aros_android_ndk" = "none"; then
1109                     dnl Use standalone toolchain, don't adjust paths
1110                     aros_kernel_cflags="-mandroid"
1111                     aros_kernel_ldflags="-mandroid"
1112                     CFLAGS="-mandroid"
1113                 else
1114                     dnl In Android NDK toolchains are placed in own directories,
1115                     dnl but tool names are not suffixed with version 
1116                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1117                     kernel_tool_version=""
1118                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1119                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1120                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1121                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1122                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1123                 fi
1124                 need_x11=no
1125                 host_android_gfx=yes
1126                 # Disable implicit PIC mode
1127                 aros_target_cflags="$aros_target_cflags -fno-pic"
1128                 kernel_tool_prefix="$android_tool_prefix-"
1129             ;;
1130         esac
1131     ;;
1133     pc)
1134         aros_target_arch="pc"
1135         aros_shared_default="no"
1136         target_bootloader="grub2"
1137         case "$target_cpu" in
1138             *i?86*)
1139                 aros_target_cpu="i386"
1141                 dnl If somebody hasn't already set the target object
1142                 dnl format, then use this value. Mostly to support
1143                 dnl FreeBSD cross-compilation.
1144                 dnl TODO: Remove when we always use our compiler.
1146                 if test "$aros_object_format" = "" ; then
1147                     aros_object_format="elf_i386"
1148                 fi
1149                 aros_flavour="standalone"
1150                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1151                 aros_kernel_ldflags="-Wl,-melf_i386"
1152                 aros_nominal_width=640
1153                 aros_nominal_height=480
1154                 gcc_target_cpu="i386"
1155                 ;;
1156             *x86_64*)
1157                 aros_target_cpu="x86_64"
1158                 aros_serial_debug=1
1159                 if test "$aros_object_format" = "" ; then
1160                     aros_object_format="elf_x86_64"
1161                 fi
1162                 aros_flavour="standalone"
1163                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1164                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1165                 aros_kernel_ldflags=""
1166                 aros_nominal_width=640
1167                 aros_nominal_height=480
1168                 case "$aros_target_variant" in
1169                     smp)
1170                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1171                     ;;
1172                 esac
1173                 ;;
1174             *)
1175                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1176                 ;;
1177         esac
1178         ;;
1180     prep)
1181         aros_target_arch="prep"
1182         aros_shared_default="no"
1183         aros_target_cpu="ppc"
1184         aros_object_format="elf32ppc"
1185         aros_flavour="ppcnative"
1186         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1187         aros_kernel_ldflags=""
1188         aros_nominal_width=640
1189         aros_nominal_height=480
1190         gcc_target_cpu="ppc"
1191         ;;
1193     freebsd*)
1194         aros_target_arch="freebsd"
1195         aros_target_family="unix"
1196         aros_target_cpu="i386"
1197         aros_flavour="emulation"
1198         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1199         gcc_target_cpu="i386"
1201         aros_target_strip_flags="-x"
1202         ;;
1204     darwin*)
1205         aros_target_arch="darwin"
1206         aros_target_family="unix"
1207         aros_flavour="emulation"
1208         case "$target_cpu" in
1209             *i?86*)
1210                 aros_ios_platform="iPhoneSimulator"
1211                 aros_target_cpu="i386"
1212                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1213                 aros_kernel_ldflags=""
1214                 aros_macosx_version="10.4"
1215                 aros_nominal_depth=8
1216                 gcc_target_cpu="i386"
1217                 aros_object_format="elf_i386"
1218                 aros_kernel_ar_flags="-cr"
1219                 aros_target_strip_flags="-x"
1220                 kernel_tool_flags="-m32"
1221                 ;;
1222             *x86_64*)
1223                 aros_target_cpu="x86_64"
1224                 aros_object_format="elf_x86_64"
1225                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1226                 aros_macosx_version="10.6"
1227                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1228                 aros_kernel_cflags="-m64"
1229                 aros_kernel_ldflags="-m64"
1230                 aros_target_cflags="-mcmodel=large"
1231                 aros_nominal_depth=8
1232                 aros_kernel_ar="ar"
1233                 aros_kernel_ar_flags="-cr"
1234                 aros_kernel_ld="ld"
1235                 aros_kernel_as="as"
1236                 aros_kernel_ranlib="ranlib"
1237                 aros_kernel_nm="nm"
1238                 aros_kernel_strip="strip"
1239                 kernel_tool_prefix="i686-apple-darwin10-"
1240                 ;;
1241             *ppc*)
1242                 aros_target_cpu="ppc"
1243                 aros_object_format="elf32ppc"
1244                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1245                 aros_kernel_ldflags=""
1246                 aros_macosx_version="10.0"
1247                 aros_nominal_depth=8
1248                 gcc_target_cpu="ppc"
1249                 aros_kernel_ar="ar"
1250                 aros_kernel_ar_flags="-cr"
1251                 aros_kernel_ld="ld -arch ppc"
1252                 aros_kernel_as="as -arch ppc"
1253                 aros_kernel_ranlib="ranlib -arch ppc"
1254                 aros_kernel_nm="nm -arch ppc"
1255                 aros_kernel_strip="strip -arch ppc"
1256                 kernel_tool_prefix="powerpc-apple-darwin10-"
1257                 ;;
1258             *arm*)
1259                 aros_ios_platform="iPhoneOS"
1260                 aros_target_cpu="arm"
1261                 aros_object_format="armelf_aros"
1262                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1263                 aros_arch_libs="-laeabi"
1264                 aros_nominal_depth=8
1265                 gcc_target_cpu="arm"
1266                 aros_kernel_ar="ar"
1267                 aros_kernel_ar_flags="-cr"
1268                 aros_kernel_ld="ld -arch arm"
1269                 aros_kernel_ranlib="ranlib -arch arm"
1270                 kernel_tool_prefix="arm-apple-darwin10-" 
1271                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1272                 ;;
1273             *)
1274                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1275                 ;;
1276         esac
1277         case "$aros_target_variant" in
1278             ios)
1279                 aros_ios_version="3.0"
1280                 aros_nominal_width=320
1281                 aros_nominal_height=480
1282                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1283                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1284                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1285                 need_x11=no
1286                 # This is here because it may depend on iOS or SDK version
1287                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1288                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1289                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1290             ;;
1291             *)
1292                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1293                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1294             ;;
1295         esac
1296         ;;
1298     dragonfly*)
1299         aros_target_arch="dragonfly"
1300         aros_target_family="unix"
1301         aros_flavour="emulation"
1302         case "$target_cpu" in
1303             *i?86*)
1304                 aros_target_cpu="i386"
1305                 aros_object_format="elf_i386"
1306                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1307                 ;;
1308             *x86_64*)
1309                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1310                 aros_target_cpu="x86_64"
1311                 aros_object_format="elf_x86_64"
1312                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1313                 ;;
1314             *)
1315                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1316                 ;;
1317         esac
1318         ;;
1320     netbsd*)
1321         aros_target_arch="netbsd"
1322         aros_target_family="unix"
1323         case "$target_cpu" in
1324             *m68k*)
1325                 aros_target_cpu="m68k"
1326                 aros_object_format="m68kelf"
1327                 aros_flavour="emulcompat"
1328                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1329                 gcc_target_cpu="mc68000"
1330                 ;;
1331             *i?86*)
1332                 aros_target_cpu="i386"
1333                 aros_object_format="elf_i386"
1334                 aros_flavour="emulation"
1335                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1336                 aros_nominal_depth=8
1337                 gcc_target_cpu="i386"
1338                 ;;
1339             *)
1340                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1341                 ;;
1342         esac
1343         aros_target_genmap="-Wl,-M -Xlinker >"
1344         aros_flavour="emulation"
1345         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1346         ;;   
1348     openbsd*)
1349         aros_target_arch="openbsd"
1350         aros_target_family="unix"
1351         case "$target_cpu" in
1352             *i?86*)
1353                 aros_target_cpu="i386"
1354                 aros_object_format="elf_i386"
1355                 aros_flavour="emulation"
1356                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1357                 gcc_target_cpu="i386"
1358                 ;;
1359             *)
1360                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1361                 ;;
1362         esac
1363         aros_target_genmap="-Wl,-M -Xlinker >"
1364         aros_target_nm_flags="-u"
1365         aros_flavour="emulation"
1366         ;;
1368     solaris*)
1369         aros_target_arch="solaris"
1370         aros_target_family="unix"
1371         case "$target_cpu" in
1372            *i?86*)
1373                aros_target_cpu="i386"
1374                aros_object_format="elf_i386"
1375                aros_flavour="emulation"
1376                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1377                aros_nominal_depth=8
1378                gcc_target_cpu="i386"
1379                ;;
1380             *sparc*)
1381                 aros_target_cpu="sparc"
1382                 aros_object_format="elf_sparc"
1383                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1384                 gcc_target_cpu="sparc"
1385                 ;;
1386             *)
1387                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1388                 ;;
1389         esac
1390         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1391         aros_flavour="emulation"
1392         ;;
1394     morphos*)
1395         aros_target_arch="morphos"
1396         aros_shared_default="no"
1397         aros_target_cpu="ppc"
1398         aros_object_format="elf_ppc"
1399         aros_flavour="nativecompat"
1400         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1401         gcc_target_cpu="ppc"
1402         ;;
1404     sam440)
1405         aros_target_arch="sam440"
1406         aros_shared_default="no"
1407         aros_target_cpu="ppc"
1408         aros_object_format="elf32ppc"
1409         aros_flavour="ppcnative"
1410         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1411         aros_kernel_ldflags=""
1412         aros_nominal_width=1024
1413         aros_nominal_height=768
1414         aros_nominal_depth=24
1415         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1416         gcc_target_cpu="powerpc"
1417         ;;
1419     efika)
1420         aros_target_arch="efika"
1421         aros_shared_default="no"
1422         aros_target_cpu="arm"
1423         aros_object_format="armelf_aros"
1424         aros_flavour="standalone"
1425         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1426         aros_kernel_ldflags=""
1427         aros_nominal_width=1024
1428         aros_nominal_height=600
1429         aros_arch_libs="-laeabi"
1430         gcc_default_cpu="armv7-a"
1431         gcc_default_fpu="vfpv3"
1432         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1433         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1434         aros_optimization_cflags="$aros_optimization_cflags -Os"
1435         case "$target_cpu" in
1436             *armhf*)
1437                 gcc_default_float_abi="hard"
1438                 target_cpu=arm
1439                 aros_target_cpu=arm
1440                 ;;
1441             *arm*)
1442                 gcc_default_float_abi="softfp"
1443                 ;;
1444             *)
1445                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1446                 ;;
1447         esac
1448         ;;
1449         
1450     chrp)
1451         aros_target_arch="chrp"
1452         aros_shared_default="no"
1453         aros_target_cpu="ppc"
1454         aros_object_format="elf32ppc"
1455         aros_flavour="ppcnative"
1456         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1457         aros_kernel_ldflags=""
1458         aros_nominal_width=640
1459         aros_nominal_height=480
1460         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1461         gcc_target_cpu="powerpc"
1462         case "$aros_target_variant" in
1463             efika)
1464                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1465             ;;
1466         esac
1467         ;;
1469     r*pi)
1470         aros_flavour="standalone"
1471         aros_target_arch="raspi"
1473         aros_shared_default="no"
1475         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1476         
1477         case "$target_cpu" in
1478             *aarch64*)
1479                 aros_target_cpu="aarch64"
1480                 gcc_default_cpu="aarch64"
1481                 aros_object_format="aarch64elf_aros"
1482                 ;;
1483             *armhf*)
1484                 aros_target_cpu="arm"
1485                 gcc_default_cpu="armv6zk"
1486                 gcc_default_cpu_tune="arm1176jzf-s"
1487                 aros_object_format="armelf_aros"
1488                 aros_config_cflags="$aros_config_cflags -marm"
1489                 aros_config_aflags="$aros_config_aflags -marm"
1490                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1491                 aros_target_cflags="$aros_kernel_cflags -marm"
1492                 aros_target_mkdep="$aros_target_mkdep -Darm"
1493                 aros_arch_libs="-laeabi"
1494                 ;;
1495             *arm*)
1496                 aros_target_cpu="arm"
1497                 gcc_default_cpu="armv6zk"
1498                 gcc_default_cpu_tune="arm1176jzf-s"
1499                 aros_object_format="armelf_aros"
1500                 aros_config_cflags="$aros_config_cflags -marm"
1501                 aros_config_aflags="$aros_config_aflags -marm"
1502                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1503                 aros_target_cflags="$aros_kernel_cflags -marm"
1504                 aros_target_mkdep="$aros_target_mkdep -Darm"
1505                 aros_arch_libs="-laeabi"
1506                 ;;
1507             *)
1508                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1509                 ;;
1510         esac
1512         aros_config_cflags="$aros_config_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1513         aros_config_aflags="$aros_config_aflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1514         aros_kernel_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1515         aros_target_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1517         case "$aros_target_variant" in
1518             smp)
1519                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1520             ;;
1521         esac
1522         ;;
1524     stm32f7_discovery)
1525         aros_flavour="standalone"
1526         aros_target_arch="stm32f7_discovery"
1527         aros_target_cpu="arm"
1528         aros_target_cpu_mode="thumb2"
1529         aros_object_format="armelf_aros"
1530         aros_shared_default="no"
1532         # stm32f7 has DSP opcode support
1533         gcc_default_cpu="armv7e-m"
1534         # gcc_default_cpu="armv7-m"
1535         gcc_default_cpu_tune="cortex-m7"
1536         gcc_default_fpu="fpv4-sp-d16"
1537         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1538         # gcc_default_fpu="fpv5-sp-d16"
1539                 gcc_default_float_abi="hard"
1541         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1542         ;;
1544     amiga*)
1545         aros_target_arch="amiga"
1546         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1547         aros_shared_default="no"
1549         case "$target_cpu" in
1550             *m68k*)
1551                 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")
1552                 aros_enable_mmu=no
1553                 aros_target_cpu="m68k"
1554                 aros_object_format="m68kelf"
1555                 aros_flavour="standcompat"
1556                 gcc_target_cpu="m68000"
1557                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1558                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1559                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1560                 aros_config_aflags="$aros_config_aflags"
1561                 aros_target_strip_flags="-R.comment --strip-debug"
1562                 aros_nominal_width=640
1563                 aros_nominal_height=256
1564                 aros_nominal_depth=2
1565                 ;;
1566             *ppc*)
1567                 aros_cpu="ppc"
1568                 aros_flavour="native"
1569                 gcc_target_cpu="ppc"
1570                 ;;
1571             *)
1572                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1573                 ;;
1574         esac
1575         ;;
1577     mingw*)
1578         aros_target_arch="mingw32"
1579         aros_shared_default="no"
1580         aros_flavour="emulation"
1581         aros_shared_cflags=""
1582         need_crosstools="yes"
1583         need_dlopen="no"
1584         rescomp="windres"
1585         case "$target_cpu" in
1586             *i?86*)
1587                 aros_target_cpu="i386"
1588                 aros_object_format="elf_i386"
1589                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1590                 aros_nominal_depth=8
1591                 gcc_target_cpu="i386"
1593                 kernel_tool_prefix="i386-mingw32-"
1594                 ;;
1595             *x86_64*)
1596                 aros_target_cpu="x86_64"
1597                 aros_object_format="elf_x86_64"
1598                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1599                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1600                 aros_nominal_depth=8
1601                 kernel_tool_prefix="x86_64-w64-mingw32-"
1602                 ;;
1603             *arm*)
1604                 aros_target_cpu="arm"
1605                 aros_object_format="armelf_aros"
1606                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1607                 aros_arch_libs="-laeabi"
1608                 aros_nominal_depth=8
1609                 gcc_target_cpu="arm"
1610                 gcc_default_float_abi="soft"
1611                 kernel_tool_prefix="arm-mingw32ce-"
1612                 aros_nominal_width=160
1613                 aros_nominal_height=160
1614                 ;;
1615             *)
1616                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1617                 ;;
1618         esac
1619         if test $host_os = "cygwin"; then
1620                 aros_kernel_cflags="-mno-cygwin"
1621         fi
1622     ;;
1623     pp*)
1624         aros_target_arch="pp"
1625         aros_shared_default="no"
1626         case "$target_cpu" in
1627             *m68k*)
1628                 aros_target_cpu="m68k"
1629                 aros_object_format="m68kelf"
1630                 aros_flavour="palmnative"
1631                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1632                 aros_nominal_width=160
1633                 aros_nominal_height=160
1634                 aros_nominal_depth=1
1635                 aros_target_ar_flags="cru"
1636                 aros_compiler_libs="-lgcc1"
1637                 aros_shared_default=no
1638                 aros_shared_cflags="-fpic"
1639                 aros_shared_aflags=""
1640                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1641                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1642                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1643                 aros_debug_aflags=""
1644                 aros_debug_ldflags="$aros_symbols_debug"
1645                 aros_mungwall_debug="0"
1646                 aros_modules_debug="0"
1647                 gcc_target_cpu="mc68000"
1648                 ignore_undefined_symbols="-ius"
1649                 ;;
1650            *)
1651                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1652                 ;;
1653         esac
1654         ;;
1656     mac*)
1657         aros_target_arch="mac"
1658         aros_shared_default="no"
1659         case "$target_cpu" in
1660             *m68k*)
1661                 aros_target_cpu="m68k"
1662                 aros_object_format="m68kelf"
1663                 aros_flavour="mac68knative"
1664                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1665                 aros_nominal_width=512
1666                 aros_nominal_height=384
1667                 aros_nominal_depth=8
1668                 aros_target_ar_flags="cru"
1669                 aros_compiler_libs="-lgcc1"
1670                 aros_shared_default=no
1671                 aros_shared_cflags="-fpic"
1672                 aros_shared_aflags=""
1673                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1674                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1675                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1676                 aros_debug_aflags=""
1677                 aros_debug_ldflags="$aros_symbols_debug"
1678                 aros_mungwall_debug="0"
1679                 aros_modules_debug="0"
1680                 gcc_target_cpu="mc68000"
1681                 ignore_undefined_symbols="-ius"
1682                 ;;
1683            *)
1684                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1685                 ;;
1686         esac
1687         ;;
1689     *)
1690         AC_MSG_ERROR([Unsupported target architecture $target])
1691         ;;
1692 esac
1694 #-----------------------------------------------------------------------------
1695 crosstools_guess="yes"
1696 aros_target_toolchain="no"
1697 aros_config_sysroot=""
1698 aros_kernel_sysroot=""
1700 AC_MSG_CHECKING([Kernel toolchain prefix])
1701 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1702 AC_MSG_RESULT($kernel_tool_prefix)
1704 AC_MSG_CHECKING([ELF toolchain prefix])
1705 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"
1706                                                  crosstools_guess="no"])
1707 AC_MSG_RESULT($elf_tool_prefix)
1709 AC_MSG_CHECKING([AROS toolchain prefix])
1710 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"
1711                 crosstools_guess="no"])
1712 if test "$aros_tool_prefix" = "yes" ; then
1713     aros_tool_prefix=$aros_target_cpu-aros-
1715 AC_MSG_RESULT($aros_tool_prefix)
1717 #-----------------------------------------------------------------------------
1718 #   Checking if we should build crosstools..
1719 AC_MSG_CHECKING([whether to build crosstools])
1720 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1721 AC_MSG_RESULT($crosstools)
1723 if test "${crosstools}" = "yes"; then
1724     if test "${crosstools_guess}" = "no"; then
1725         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1726     fi
1729 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1730     aros_target_toolchain="yes"
1733 AC_MSG_CHECKING([where to install the crosstools binaries])
1734 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])
1735 if test "x$aros_toolchain_install" = "x"; then
1736     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1737 else
1738     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1739     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1740     if test "$crosstools_guess" = "no" ; then
1741         toolchain_needs_sysroot=yes
1743         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1744             aros_kernel_sysroot = $aros_config_sysroot
1745         fi
1746     fi
1748 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1750 AC_MSG_CHECKING([If we need to use --sysroot])
1751 if test "$toolchain_needs_sysroot" = "yes" ; then
1752     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1754 AC_MSG_RESULT($toolchain_needs_sysroot)
1756 #-----------------------------------------------------------------------------
1757 if test "$aros_toolchain" = "gnu" ; then
1758     AC_MSG_CHECKING([what specific target binutils version to use])
1760 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="")
1761 if test "$use_binutils_version" = ""; then
1762         target_binutils_version="$default_binutils_version"
1763 else
1764     target_binutils_version="$use_binutils_version"
1766 if test "$aros_toolchain" = "gnu" ; then
1767     AC_MSG_RESULT($target_binutils_version)
1771 # Helper to identify gcc version
1772 AC_DEFUN([CROSS_GCC_VERSION], [
1773   target_gcc_version=""
1774   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1775     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1776     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1777       ax_cv_gcc_version=""
1778     ])
1779   ])
1780   target_gcc_version=$ax_cv_gcc_version
1781   AC_SUBST([target_gcc_version])
1784 #-----------------------------------------------------------------------------
1785 if test "$aros_toolchain" = "gnu" ; then
1786     AC_MSG_CHECKING([what specific target gcc version to use])
1788 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1789 if test "$use_gcc_version" = ""; then
1790     if test "${crosstools}" = "no"; then
1791       if test "x$aros_toolchain_install" != "x"; then
1792           CROSS_GCC_VERSION
1793       fi
1794     fi
1795     if test "$use_gcc_version" = ""; then
1796         target_gcc_version="$default_gcc_version"
1797     fi
1798 else
1799     target_gcc_version="$use_gcc_version"
1801 if test "$aros_toolchain" = "gnu" ; then
1802     AC_MSG_RESULT($target_gcc_version)
1804     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1805     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1806     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1808     gcc_fix_bitfields="false"
1809     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1810         gcc_fix_bitfields="true"
1811     else
1812         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1813             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1814                 gcc_fix_bitfields="true"
1815             fi
1816         fi
1817     fi
1819     if test "$gcc_fix_bitfields" = "true" ; then
1820         case "$aros_target_cpu" in
1821         *x86_64*)
1822             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1823             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1824             ;;
1825         i386)
1826             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1827             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1828             ;;
1829         esac
1830     fi
1833 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1834 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1835 AC_MSG_RESULT($objc)
1836 if test "x$objc" = "xyes"; then
1837     objc_target="$objc"
1838 else
1839     objc_target="no-objc"
1842 AC_MSG_CHECKING([whether to enable Java suppport])
1843 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1844 AC_MSG_RESULT($java)
1845 if test "x$java" != "xno"; then
1846     java_target="$java"
1847 else
1848     java_target="no-java"
1851 spec_obj_format="-m $aros_object_format"
1852 # Now process extra architecture-specific options.
1853 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1854 # as well as floating-point ABI.
1855 case "$aros_target_cpu" in
1856 *x86_64*)
1857     dnl x86_64 can build 32 or 64bit code
1858     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1859     ;;
1860 arm*)
1861     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1862     if test "$gcc_default_cpu" = ""; then
1863         gcc_default_cpu="armv6"
1864     fi
1865     if test "$gcc_default_fpu" = ""; then
1866         gcc_default_fpu="vfp"
1867     fi
1868     if test "$gcc_default_float_abi" = ""; then
1869         if test "$target_cpu" = "armhf"; then
1870             gcc_default_float_abi="hard"
1871         else
1872             gcc_default_float_abi="softfp"
1873         fi
1874     fi
1876     AC_MSG_CHECKING([Which minimum CPU to use])
1877     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)
1878     AC_MSG_RESULT($aros_gcc_cpu)
1880     AC_MSG_CHECKING([Which minimum FPU to use])
1881     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)
1882     AC_MSG_RESULT($aros_gcc_fpu)
1884     AC_MSG_CHECKING([Which floating point ABI to use])
1885     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)
1886     AC_MSG_RESULT($aros_gcc_float_abi)
1888     AC_MSG_CHECKING([Which ARM mode to use])
1889     if test "$aros_target_cpu_mode" = ""; then
1890         aros_target_cpu_mode="arm32"
1891         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1892     else
1893         AC_MSG_RESULT([$aros_target_cpu_mode])
1894     fi
1896     case "$aros_target_cpu_mode" in
1897     arm32)
1898         gcc_default_mode="arm"
1899         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1900     ;;
1901     arm64)
1902         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1903     ;;
1904     thumb)
1905         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1906     ;;
1907     thumb1)
1908         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1909     ;;
1910     thumb2)
1911         gcc_default_mode="thumb"
1912         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1913         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1914     ;;
1915     *)
1916         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1917     ;;
1918     esac
1920     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1921     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1922     ;;
1923 i386)
1924     aros_isa_flags="-m32 -march=i486"
1925     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1926     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1927     ;;
1928 esac
1930 # Some architectures may need custom ELF specs.
1931 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1932     elf_specs_in=config/${aros_object_format}-specs.in
1933 else
1934     elf_specs_in=config/elf-specs.in
1937 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1938 # Since we override specs, we may need to put these defines there
1939 if test "$gcc_target_cpu" != ""; then
1940     gcc_target_cpu="-D__${gcc_target_cpu}__"
1943 AC_MSG_CHECKING([where to download sourcecode for external ports])
1944 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1945 if test "$with_portssrcdir" = "default"; then
1946     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1947 else
1948     AROS_PORTSSRCDIR="$with_portssrcdir"
1950 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1952 AC_MSG_CHECKING([which bootloader to use])
1953 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1954 if test "$target_bootloader" = "none"; then
1955     aros_target_bootloader=""
1956 else
1957     aros_target_bootloader="$target_bootloader"
1959 AC_MSG_RESULT($target_bootloader)
1961 AC_MSG_CHECKING([which icon-set to use])
1962 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1963 if test "$target_iconset" = "default"; then
1964     aros_target_iconset="Gorilla"
1965     target_iconset="default (Gorilla)"
1966 else
1967     aros_target_iconset="$target_iconset"
1969 AC_MSG_RESULT($target_iconset)
1971 AC_MSG_CHECKING([which GUI Theme to use])
1972 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1973 if test "$target_guitheme" = "default"; then
1974     aros_target_guitheme="Ice"
1975 else
1976     aros_target_guitheme="$target_guitheme"
1978 AC_MSG_RESULT($aros_target_guitheme)
1980 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1981 # for target code)
1982 cross_compiling=no
1984 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1985 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1986     cross_compiling=yes
1989 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1990 dnl The flag itself is given in per-target section, because some targets require to pass it
1991 dnl in a different manner, otherwise some tests fail.
1992 dnl TODO: Justify this.
1993 if test "$aros_host_cpu" == "x86_64" ; then
1994     if test "$aros_target_cpu" == "i386" ; then
1995         cross_compiling=no
1996     fi
1999 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2000     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2001     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2002     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2003     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2004     dnl used to build bootstrap for target arch in either case.
2005     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2006     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2007     dnl perhaps introducing aros_host_variant
2008     if test "$aros_host_arch" != "$aros_target_arch" ; then
2009         cross_compiling=yes
2010     fi
2011 else
2012     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2013     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2014     if test "$host_cc_elf" = "no" ; then
2015         cross_compiling=yes
2016     fi
2019 if test "$cross_compiling" = "no" ; then
2020     kernel_tool_prefix=""
2021     if test "$host_cc_elf" = "yes" ; then
2022         elf_tool_prefix=""
2023     fi
2026 if test "$kernel_tool_version" != ""; then
2027     kernel_tool_version="-$kernel_tool_version"
2030 #######################################################################
2031 ## Compute what toolchains to use, and their paths                   ##
2032 #######################################################################
2034 # This takes, as input:
2035 #   crosstools             {yes,no}
2036 #   kernel_tool_version    {"",[version]}
2037 #   target_tool_version    {"",[version]}
2038 #   kernel_tool_prefix     {none,[some-arch-os-]}
2039 #   gnu-toolchain -:
2040 #     target_tool_prefix     ${aros_target_cpu}-aros-
2041 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2043 # The output is
2044 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2045 #        Where the 'kernel' binaries are located
2046 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2047 #        Where the 'target' binaries are located
2048 #        (not the symlink farm - that is aros_target_*!)
2050 # The rules are:
2051 #   if crosstools then
2052 #      if kernel_tools_prefix = "no-kernel-prefix-"
2053 #          aros_kernel_* = crosstools cc paths
2054 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2055 #      else
2056 #          VALIDATE(${kernel_tools_prefix}*)
2057 #          aros_kernel_* = ${kernel_tools_prefix}*
2058 #          if ${kernel_tools_prefix}cc is an AROS gcc
2059 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2060 #          else
2061 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2062 #          fi
2063 #      fi
2065 #      orig_target_* = aros built crosstools
2066 #      orig_target_cc = elf cc wrapper around crosstools cc
2067 #   else
2068 #      VALIDATE(${kernel_tools_prefix}*)
2070 #      orig_target_* = aros_kernel_*
2071 #      if aros_kernel_cc is an AROS gcc
2072 #          orig_target_cc = aros_kernel_cc
2073 #      else
2074 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2075 #      fi
2076 #   fi
2078 if test "$aros_toolchain" = "gnu" ; then
2079     target_tool_prefix="${aros_target_cpu}-aros-"
2080 elif test "$aros_toolchain" = "llvm" ; then
2081     target_tool_prefix="bin/"
2084 if test "$kernel_tool_prefix" != "" ; then
2085     AC_MSG_CHECKING([which kernel tools])
2086     AC_MSG_RESULT([$kernel_tool_prefix]);
2089 if test "$kernel_tool_prefix" = "none" ; then
2090     dnl ELF wrapper can be used only for native bootstrap
2091     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2092         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2093     fi
2094 else
2095     # Kernel tools required - find them
2096     # Note that 'normally', aros_kernel_* overrides will be
2097     # empty, unless specified in the per-arch sections above.
2098     if test "x$aros_kernel_cpp" = "x"; then
2099         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2100     fi
2101     AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2102     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2103     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2105     if test "x$aros_kernel_cc" = "x"; then
2106         aros_kernel_cc=${kernel_tool_prefix}${CC}
2107     fi
2108     AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2109     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2110     AROS_REQUIRED(cc,$aros_kernel_cc)
2112     if test "x$aros_kernel_cxx" = "x"; then
2113         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2114     fi
2115     AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2116     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2117     # If it's set, make sure it's really there
2118     if test "x$aros_kernel_cxx" != "x" ; then
2119         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2120     fi
2121     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2122     AROS_REQUIRED(ld,$aros_kernel_ld)
2123     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2124     AROS_REQUIRED(as,$aros_kernel_as)
2125     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2126     AROS_REQUIRED(ar,$aros_kernel_ar)
2127     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2128     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2129     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2130     AROS_REQUIRED(nm,$aros_kernel_nm)
2131     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2132     AROS_REQUIRED(strip,$aros_kernel_strip)
2134     # Objcopy and objdump are not required for the kernel
2135     # toolchain on many architectures.
2136     # So we'll look for them, but not make them strictly required.
2137     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2138     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2139     if test "x${crosstools}" != "xyes" ; then
2140         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2141         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2142     fi
2145 AC_MSG_CHECKING([which target tools to use])
2146 if test "$aros_target_toolchain" = "yes"; then
2147     if test "$aros_toolchain" = "llvm" ; then
2148         msg_result="llvm"
2149     else
2150         msg_result=$target_tool_prefix
2151     fi
2152     AC_MSG_RESULT([$msg_result])
2153     # We are building AROS crosstools
2154     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2155     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2156     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2157     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2158     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2159     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2160     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2161     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2162     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2163     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2164     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2165     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2166 else
2167     # Determine whether AROS or ELF tools should be used
2168     if test "$aros_tool_prefix" = "none"; then
2169         aros_tool_prefix="${elf_tool_prefix}"
2170     fi
2172     AC_MSG_RESULT([$aros_tool_prefix])
2173     # We are *not* building AROS crosstools - use the AROS or ELF tools
2174     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2175     AROS_REQUIRED(cpp,$orig_target_cpp)
2176     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2177     AROS_REQUIRED(cc,$orig_target_cc)
2178     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2179     AROS_REQUIRED(cxx,$orig_target_cxx)
2180     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2181     AROS_REQUIRED(ld,$orig_target_ld)
2182     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2183     AROS_REQUIRED(as,$orig_target_as)
2184     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2185     AROS_REQUIRED(ar,$orig_target_ar)
2186     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2187     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2188     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2189     AROS_REQUIRED(nm,$orig_target_nm)
2190     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2191     AROS_REQUIRED(strip,$orig_target_strip)
2192     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2193     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2194     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2195     AROS_REQUIRED(objdump,$orig_target_objdump)
2198 if test "$kernel_tool_prefix" = "none" ; then
2199     # No kernel tools specified
2200     # Assume target tools == kernel tools with ELF wrapper
2201     aros_kernel_cc=$orig_target_cc
2202     aros_kernel_cxx=$orig_target_cxx
2203     aros_kernel_cpp=$orig_target_cpp
2204     aros_kernel_ld=$orig_target_ld
2205     aros_kernel_as=$orig_target_as
2206     aros_kernel_ar=$orig_target_ar
2207     aros_kernel_ranlib=$orig_target_ranlib
2208     aros_kernel_nm=$orig_target_nm
2209     aros_kernel_strip=$orig_target_strip
2210     aros_kernel_objcopy=$orig_target_objcopy
2211     aros_kernel_objdump=$orig_target_objdump
2212     use_kernel_cc_wrapper=yes
2215 # At this point, all aros_kernel_* and aros_target_* 
2216 # tools should be set up correctly
2218 CC="$aros_kernel_cc $kernel_tool_flags"
2219 CPP="$aros_kernel_cpp"
2221 #-----------------------------------------------------------------------------
2223 # Find all the tools we need to compile. This could be cross-compiling
2224 # though! If that is the case we use the GNU form of the target and
2225 # simply add this to the front of the binary name. This is rather simple,
2226 # but it should work under most circumstances.
2228 # The default tools are to use the same as the host, but only if the
2229 # host and target CPU are the same. With GCC this is normally enough.
2232 aros_cc_pre=""
2233 aros_shared_ld="$aros_host_ld"
2235 aros_target_mkdep="$aros_host_mkdep"
2237 # The default tools executables to be linked to.
2238 if test "$rescomp" != ""; then
2239     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2240     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2243 # Set up the sources for the symlink farm
2244 if test "$crosstools" = "yes"; then
2245     crosstools_target=tools-crosstools
2248 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2249 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2251 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2252 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2253 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2254 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2255 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2256 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2257 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2259 # aros_cc_pre is a variable that is added to the front of the compiler name
2260 # in the generated aros-gcc shell script. We need this to enable the cache
2261 # to work across cleaned builds. Also, support DISTCC using the correct
2262 # environment variable.
2265 if test "x${DISTCC}" != "x" ; then
2266     if test "x${CCACHE}" != "x" ; then
2267         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2268     else
2269         aros_cc_pre="${DISTCC} "
2270     fi
2271 else
2272     if test "x${CCACHE}" != "x" ; then
2273         aros_cc_pre="${CCACHE} "
2274     fi
2277 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2278 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2279 AC_SUBST(aros_target_nix_ldflags,-nix)
2280 AC_SUBST(aros_target_detach_ldflags,-detach)
2281 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2283 # Target tools
2284 AC_SUBST(aros_toolchain)
2285 if test "$aros_target_toolchain" != "yes"; then
2286     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2287     if test "$GCC" = "yes"; then
2288         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2289     fi
2290 else
2291     # We do not know which c compiler version we are going to build and what we need to know
2292     # here is different for different versions so this will be set later during the
2293     # build of crosstools.
2294     if test "$aros_toolchain" = "gnu" ; then
2295         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2296     elif test "$aros_toolchain" = "llvm" ; then
2297         prefix="$AROS_CROSSTOOLSDIR/bin/"
2298     fi
2299     aros_target_cc_path=@aros_target_cc_path@
2301 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2302 aros_target_cc="${prefix}${toolchain_c_compiler}"
2303 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2304 aros_target_as="${prefix}${toolchain_as}"
2305 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_ld}"
2306 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2307 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2308 aros_target_objdump="${prefix}${toolchain_objdump}"
2309 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2310 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2311 aros_target_strip="${prefix}${toolchain_strip}"
2312 aros_plain_nm="${prefix}${toolchain_nm}"
2313 aros_plain_ar="${prefix}${toolchain_ar}"
2315 AC_ARG_ENABLE(includes,
2316 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2317 [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`])
2319 if test "$aros_kernel_includes" = ""; then
2320     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2321         aros_kernel_includes="-isystem $aros_target_incl"
2322     fi
2325 if test "$aros_kernel_includes" != "" ; then
2326     dnl find out about the kernel cc's include path
2327     AC_MSG_CHECKING([for the kernel compiler's include path])
2328     if test "$aros_kernel_cc_includes" = "" ; then
2329         # Try to guess where the directory is.
2330         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2331         if test -d $aros_kernel_cc_includes; then
2332             # Check if there is also an include-fixed directory and add it
2333             # to kernel compiler's include path as it may contain some of
2334             # the headers we need.
2335             if test -d "$aros_kernel_cc_includes"-fixed; then
2336                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2337             fi
2338             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2339             if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2340                 aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2341             fi
2342         else
2343             # The directory doesn't exist, we need to do some more work.
2344             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2346             # These are the headers we're looking for.
2347             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2348                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2349                      zutil.h stdint.h"
2351             dirs=
2352             for h in $headers; do
2353                 # Which other headers are needed by each of the above?
2354                 deps=$(echo "#include <$h>" | \
2355                        $aros_kernel_cc -E -M - 2>/dev/null | \
2356                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2358                 # Copy all the needed headers to a directory beneath gendir.
2359                 for d in $deps; do
2360                     h=$(basename $d)
2361                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2362                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2363                     ! test -d $dir && mkdir -p $dir
2364                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2365                 done
2366             done            
2367         fi
2368     fi
2369     AC_MSG_RESULT($aros_kernel_cc_includes)
2370     # Adding -nostdinc to kernel includes as they are always used together.
2371     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2374 if test "$crosstools" != "yes"; then
2375     dnl find out about the target cc's include path
2376     AC_MSG_CHECKING([for the target compiler's include path])
2377     if test "$aros_target_cc_includes" = "" ; then
2378         #try to guess where the directory is
2379         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2380         if ! test -d $aros_target_cc_includes; then
2381             #the directory doesn't exist, we need to do some more work
2382             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2383         
2384             #these are the headers we're looking for
2385             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2386                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2387                     zutil.h"
2389             dirs=
2390             for h in $headers; do
2391                 #which other headers each of the above headers needs?
2392                 deps=$(echo "#include <$h>" | \
2393                     $orig_target_cc -E -M - 2>/dev/null | \
2394                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2395             
2396                 #copy all the needed headers to a directory beneath gendir
2397                 for d in $deps; do
2398                     h=$(basename $d)
2399                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2400                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2401                     ! test -d $dir && mkdir -p $dir
2402                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2403                 done
2404             done
2405         fi
2406     fi
2407     AC_MSG_RESULT($aros_target_cc_includes)
2408 else
2409     # We do not know which c compiler version we are going to build and what we need to know
2410     # here is different for different versions so this will be set later during the
2411     # build of crosstools.
2412     aros_target_cc_includes=@aros_target_cc_includes@
2416 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2417 # On GCC >= 4.0 -iquote should be used
2420 save_cc="$CC"
2421 save_cflags="$CFLAGS"
2422 CFLAGS="-iquote."
2423 kernel_cflags_iquote=$host_cflags_iquote
2424 kernel_cflags_iquote_end=$host_cflags_iquote_end
2425 if test "x-$cross_compiling" = "x-yes"; then
2426     CC="$aros_kernel_cc"
2427     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2428     if test "x-$crosstools" != "x-yes"; then
2429         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2430     else
2431         # we do know it is supported for the smallest version of gcc we are going to build
2432         # we assume it's also supported by later versions
2433         use_no_stack_protector=yes
2434     fi
2435     AC_MSG_RESULT($use_no_stack_protector)
2436     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2437     if test "x-$crosstools" != "x-yes"; then
2438         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2439     else
2440         # we do know it is supported for the smallest version of gcc we are going to build
2441         # we assume it's also supported by later versions
2442         has_iquote=yes
2443     fi
2444     AC_MSG_RESULT($has_iquote)
2445     if test "x-$has_iquote" = "x-yes" ; then
2446         kernel_cflags_iquote=-iquote
2447         kernel_cflags_iquote_end=
2448     else
2449         kernel_cflags_iquote=-I
2450         kernel_cflags_iquote_end=-I-
2451     fi
2453 if test "x-$use_no_stack_protector" = "x-yes" ; then
2454     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2457 #-----------------------------------------------------------------------------
2459 # Check if we can explicitly choose older version of symbol hashing
2461 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2462 CC="$aros_kernel_cc"
2463 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2464 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2465 AC_MSG_RESULT($use_hash_style)
2466 if test "x-$use_hash_style" = "x-yes" ; then
2467     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2469 CC="$save_cc"
2470 CFLAGS="$save_cflags"
2472 AC_SUBST(host_cflags_iquote)
2473 AC_SUBST(host_cflags_iquote_end)
2474 AC_SUBST(kernel_cflags_iquote)
2475 AC_SUBST(kernel_cflags_iquote_end)
2478 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2479 AC_MSG_CHECKING([for default resolution of WBScreen])
2480 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2481 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2482 if test "$resolution" = "yes" ; then
2483     resolution="none"
2485 if test "$resolution" = "no" ; then
2486     resolution="none"
2488 if test "$resolution" != "none" ; then
2489     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2490     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2491     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2493 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2494 aros_cv_nominal_width=$aros_nominal_width
2495 aros_cv_nominal_height=$aros_nominal_height
2496 aros_cv_nominal_depth=$aros_nominal_depth
2498 dnl See if the user wants the serial debug output for native flavour
2499 AC_MSG_CHECKING([whether serial debug is enabled])
2500 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)
2501 if test "$aros_serial_debug" = 0 ; then
2502     serial_debug_forced=""
2503     if test "$serial_debug" = "yes" ; then
2504         serial_debug="1"
2505     fi
2506     if test "$serial_debug" = "no" ; then
2507         serial_debug="none"
2508     fi
2509 else
2510     serial_debug_forced="(forced)"
2511     serial_debug=$aros_serial_debug
2513 if test "$serial_debug" != "none" ; then
2514     aros_serial_debug=$serial_debug
2515     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2516 else
2517     AC_MSG_RESULT(no)
2520 dnl See if the user wants the palm debug output hack for palm native flavour
2521 AC_MSG_CHECKING([whether palm debug hack is enabled])
2522 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")
2523 if test "$palm_debug_hack" = "yes" ; then
2524     aros_palm_debug_hack="1"
2526 AC_MSG_RESULT($palm_debug_hack)
2528 dnl See if dev wants the usb3.0 code
2529 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2530 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2531 if test "$usb30_code" = "yes" ; then
2532     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2533     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2535 AC_MSG_RESULT($usb30_code)
2537 dnl See if the user wants nesting supervisor activated for unix flavour
2538 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2539 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")
2540 if test "$nesting_supervisor" = "yes" ; then
2541     aros_nesting_supervisor="1"
2543 AC_MSG_RESULT($nesting_supervisor)
2545 dnl See if the user wants to disable MMU support
2546 dnl This can be overriden on per-target basis,
2547 dnl set $aros_enable_mmu to "yes" or "no" to do this
2548 if test "$aros_enable_mmu" = "" ; then
2549     AC_MSG_CHECKING([whether MMU support is enabled])
2550     dnl Enabled by default
2551     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2552     if test "$aros_enable_mmu" = "" ; then
2553         aros_enable_mmu="yes"
2554     fi
2555     AC_MSG_RESULT($aros_enable_mmu)
2557 if test "$aros_enable_mmu" = "no" ; then
2558     aros_enable_mmu="0"
2559 else
2560     aros_enable_mmu="1"
2562     
2564 dnl things specifically required for hosted flavours
2565 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2567     if test "x-$need_dlopen" != "x-no" ; then
2568       save_libs="$LIBS"
2569       LIBS=""
2570       dnl some kind of dynamic library access system is required for hostlib.resource
2571       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2572       if test "x-$have_dl" = "x-no" ; then
2573           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2574                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2575                                     have_dl="no")
2576       fi
2577       if test "x-$have_dl" = "x-no" ; then
2578           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2579       fi
2580       LIBS="$save_libs"
2581     fi
2584     dnl x11 hidd
2585     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2586                                            [build X11 hidd for hosted (default=auto)]),
2587                                            x11_hidd="$enableval",
2588                                            x11_hidd="$need_x11")
2589     case "x-$x11_hidd" in
2590         x-yes|x-no|x-auto)                 ;;
2591         *)                 x11_hidd="$need_x11" ;;
2592     esac
2594     ENABLE_X11=0
2596     dnl they want it
2597     if test "x-$x11_hidd" != "x-no" ; then
2599         dnl find x11 stuff
2600         AC_PATH_X
2602         if test -n "$x_includes"; then
2603             X_CFLAGS="$X_CFLAGS -I$x_includes"
2604         fi
2606         if test -n "$x_libraries"; then
2607             X_LIBS="$X_LIBS -L$x_libraries"
2608         fi
2610         if test "x-$no_x" = "x-yes" ; then
2612             dnl didn't find it
2613             if test "x-$x11_hidd" != "x-auto" ; then
2614                 dnl and they explicitly asked for it, bail out
2615                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2616             fi
2617         
2618         else
2619             dnl found it, setup the metatarget
2620             host_x_gfx=yes
2621             ENABLE_X11=1
2623             aros_host_x11_cflags="$X_CFLAGS"
2624             aros_host_x11_ldflags="$X_LIBS  -lX11"
2626             dnl setup shared memory extensions
2627             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2628                                                   [use X11 shared memory (default=auto)]),
2629                                                   x11_hidd_shm="$enableval",
2630                                                   x11_hidd_shm="auto")
2631             case "x-$x11_hidd_shm" in
2632                 x-yes|x-no|x-auto)                     ;;
2633                 *)                 x11_hidd_shm="auto" ;;
2634             esac
2636             have_xshm=no
2638             dnl they want it
2639             if test "x-$x11_hidd_shm" != "x-no" ; then
2641                 dnl system shm headers
2642                 AC_CHECK_HEADERS(sys/ipc.h)
2643                 AC_CHECK_HEADERS(sys/shm.h)
2645                 dnl got them
2646                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2648                     dnl make sure X libs have shm functions
2649                     save_cflags="$CFLAGS"
2650                     save_ldflags="$LDFLAGS"
2651                     CFLAGS="$CFLAGS $X_CFLAGS"
2652                     LDFLAGS="$LDFLAGS $X_LIBS"
2653                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2654                     CFLAGS="$save_cflags"
2655                     LDFLAGS="$save_ldflags"
2656                 fi
2657             fi
2659             dnl detection done, prepare output
2660             if test "x-$have_xshm" = "x-yes" ; then
2661                 dnl we can do shm
2662                 DO_XSHM_SUPPORT="1"
2663             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2664                 dnl they explicitly asked for it, but we can't do it
2665                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2666             else
2667                 dnl otherwise just disable it
2668                 DO_XSHM_SUPPORT="0"
2669             fi
2671             
2672             dnl setup vidmode (fullscreen) extensions
2673             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2674                                                       [use X11 vidmode extension (default=auto)]),
2675                                                       x11_hidd_vidmode="$enableval",
2676                                                       x11_hidd_vidmode="auto")
2677             case "x-$x11_hidd_vidmode" in
2678                 x-yes|x-no|x-auto)                         ;;
2679                 *)                 x11_hidd_vidmode="auto" ;;
2680             esac
2682             have_vidmode=no
2684             dnl they want it
2685             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2687                 dnl make sure X libs have vidmode functions
2688                 save_cflags="$CFLAGS"
2689                 save_ldflags="$LDFLAGS"
2690                 CFLAGS="$CFLAGS $X_CFLAGS"
2691                 LDFLAGS="$LDFLAGS $X_LIBS"
2692                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2693                 CFLAGS="$save_cflags"
2694                 LDFLAGS="$save_ldflags"
2695             fi
2697             dnl detection done, prepare output
2698             if test "x-$have_vidmode" = "x-yes" ; then
2699                 dnl we can do vidmode
2700                 DO_VIDMODE_SUPPORT="1"
2701             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2702                 dnl they explicitly asked for it, but we can't do it
2703                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2704             else
2705                 dnl otherwise just disable it
2706                 DO_VIDMODE_SUPPORT="0"
2707             fi
2708         fi
2709     fi
2711     dnl sdl hidd
2712     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2713                                            [build SDL hidd for hosted (default=auto)]),
2714                                            sdl_hidd="$enableval",
2715                                            sdl_hidd="auto")
2716     case "x-$sdl_hidd" in
2717         x-yes|x-no|x-auto)                 ;;
2718         *)                 sdl_hidd="auto" ;;
2719     esac
2721     dnl they want it
2722     if test "x-$sdl_hidd" != "x-no" ; then
2724         dnl find sdl
2725         SDL_VERSION=1.2.5
2726         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2727             [have_sdl="no"])
2729         if test "x-$have_sdl" != "x-yes" ; then
2731             dnl didn't find it
2732             if test "x-$sdl_hidd" != "x-auto" ; then
2733                 dnl and they explicitly asked for it, bail out
2734                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2735             fi
2737         else
2738             dnl found it, enable the build
2739             host_sdl_gfx=yes
2740             aros_host_sdl_cflags=$SDL_CFLAGS
2741             aros_host_sdl_libs=$SDL_LIBS
2742         fi
2743     fi
2748 dnl See if the user wants dbus.library
2749 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2750 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2751 if test "$dbus" = "yes" ; then
2752     ENABLE_DBUS=1
2753     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2754     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2755     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2756     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2757 else
2758     ENABLE_DBUS=0
2760 AC_MSG_RESULT($dbus)
2762 if test "$use_kernel_cc_wrapper" = "yes" ; then
2763     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2766 dnl --------------------------------------------------------------------
2767 dnl Configuration Output Section
2768 dnl --------------------------------------------------------------------
2770 # Generic
2771 AC_SUBST(aros_arch)
2772 AC_SUBST(aros_cpu)
2773 AC_SUBST(aros_flavour)
2774 AC_SUBST(aros_flavour_uc)
2775 AC_SUBST(aros_target_toolchain)
2776 AC_SUBST(aros_build_host)
2777 AC_SUBST(AROS_BUILDDIR)
2778 AC_SUBST(AROS_BUILDDIR_UNIX)
2779 AC_SUBST(SRCDIR)
2780 AC_SUBST(AROS_CROSSTOOLSDIR)
2781 AC_SUBST(AROS_PORTSSRCDIR)
2783 # Compatability with other Amiga-like operation systems
2784 AC_SUBST(aros_amigaos_compliance)
2786 # Host related
2787 AC_SUBST(aros_cc_pre)
2788 AC_SUBST(aros_host_strip)
2789 AC_SUBST(aros_host_arch)
2790 AC_SUBST(aros_host_cpu)
2791 AC_SUBST(aros_host_cpp)
2792 AC_SUBST(aros_host_def_cc)
2793 AC_SUBST(aros_host_cc)
2794 AC_SUBST(aros_host_cxx)
2795 AC_SUBST(aros_host_ar)
2796 AC_SUBST(aros_host_ranlib)
2797 AC_SUBST(aros_host_ld)
2798 AC_SUBST(aros_host_make)
2799 AC_SUBST(aros_host_cflags)
2800 AC_SUBST(aros_host_cxxflags)
2801 AC_SUBST(gnu89_inline)
2802 AC_SUBST(aros_host_ldflags)
2803 AC_SUBST(aros_host_debug)
2804 AC_SUBST(aros_host_mkdep)
2805 AC_SUBST(aros_host_mkargs)
2806 AC_SUBST(aros_host_exe_suffix)
2807 AC_SUBST(aros_host_lib_suffix)
2808 AC_SUBST(aros_tools_dir)
2809 AC_SUBST(aros_host_aclocal)
2810 AC_SUBST(aros_host_autoconf)
2811 AC_SUBST(aros_host_autoheader)
2812 AC_SUBST(aros_host_automake)
2813 AC_SUBST(ant)
2815 # Target Related
2816 AC_SUBST(aros_target_guitheme)
2817 AC_SUBST(aros_target_iconset)
2818 AC_SUBST(aros_target_bootloader)
2819 AC_SUBST(aros_target_arch)
2820 AC_SUBST(aros_target_family)
2821 AC_SUBST(aros_target_cpu)
2822 AC_SUBST(aros_target_cpu_mode)
2823 AC_SUBST(aros_target_variant)
2824 AC_SUBST(aros_target_suffix)
2825 AC_SUBST(aros_target_ar)
2826 AC_SUBST(aros_target_ranlib)
2827 AC_SUBST(aros_plain_nm)
2828 AC_SUBST(aros_plain_ar)
2829 AC_SUBST(aros_kernel_ar)
2830 AC_SUBST(aros_kernel_ranlib)
2831 AC_SUBST(orig_target_cc)
2832 AC_SUBST(aros_target_cc)
2833 AC_SUBST(aros_kernel_cc)
2834 AC_SUBST(orig_target_cxx)
2835 AC_SUBST(aros_target_cxx)
2836 AC_SUBST(aros_kernel_cxx)
2837 AC_SUBST(orig_target_cpp)
2838 AC_SUBST(aros_target_cpp)
2839 AC_SUBST(aros_kernel_cpp)
2840 AC_SUBST(orig_target_as)
2841 AC_SUBST(aros_target_as)
2842 AC_SUBST(aros_kernel_as)
2843 AC_SUBST(orig_target_ld)
2844 AC_SUBST(aros_target_ld)
2845 AC_SUBST(aros_kernel_ld)
2846 AC_SUBST(aros_target_cc_includes)
2847 AC_SUBST(aros_target_cc_path)
2848 AC_SUBST(aros_target_objdump)
2849 AC_SUBST(aros_target_objcopy)
2850 AC_SUBST(aros_target_strip)
2851 AC_SUBST(aros_target_nm)
2852 AC_SUBST(aros_kernel_rescomp)
2853 AC_SUBST(aros_shared_default)
2854 AC_SUBST(aros_shared_ld)
2855 AC_SUBST(aros_object_format)
2856 AC_SUBST(spec_obj_format)
2857 AC_SUBST(aros_compiler_libs)
2858 AC_SUBST(aros_arch_libs)
2860 AC_SUBST(aros_shared_cflags)
2861 AC_SUBST(aros_shared_aflags)
2862 AC_SUBST(aros_shared_ldflags)
2864 AC_SUBST(aros_config_sysroot)
2865 AC_SUBST(aros_nowarn_flags)
2866 AC_SUBST(aros_config_cflags)
2867 AC_SUBST(aros_config_aflags)
2868 AC_SUBST(aros_config_ldflags)
2870 AC_SUBST(aros_kernel_sysroot)
2871 AC_SUBST(aros_kernel_cflags)
2872 AC_SUBST(aros_kernel_includes)
2873 AC_SUBST(aros_kernel_objcflags)
2874 AC_SUBST(aros_kernel_ldflags)
2875 AC_SUBST(aros_target_cflags)
2876 AC_SUBST(aros_debug_cflags)
2877 AC_SUBST(aros_debug_aflags)
2878 AC_SUBST(aros_debug_ldflags)
2879 AC_SUBST(aros_target_genmap)
2880 AC_SUBST(aros_target_strip_flags)
2881 AC_SUBST(aros_config_lto)
2882 AC_SUBST(aros_optimization_cflags)
2883 AC_SUBST(aros_isa_flags)
2885 AC_SUBST(crosstools_target)
2886 AC_SUBST(crosstools_cxx_target)
2888 # Hosted Graphics Related
2889 AC_SUBST(host_x_gfx)
2890 AC_SUBST(host_sdl_gfx)
2891 AC_SUBST(host_android_gfx)
2893 AC_SUBST(pci_hidd_target)
2895 AC_SUBST(aros_nominal_width)
2896 AC_SUBST(aros_nominal_height)
2897 AC_SUBST(aros_nominal_depth)
2898 AC_SUBST(DO_XSHM_SUPPORT)
2899 AC_SUBST(DO_VIDMODE_SUPPORT)
2901 AC_SUBST(aros_host_x11_cflags)
2902 AC_SUBST(aros_host_x11_ldflags)
2903 AC_SUBST(aros_host_sdl_cflags)
2904 AC_SUBST(aros_host_sdl_libs)
2906 # Native version related
2907 AC_SUBST(aros_serial_debug)
2908 AC_SUBST(ENABLE_EXECSMP)
2910 # Palm native version related
2911 AC_SUBST(aros_palm_debug_hack)
2913 # Unix/Hosted version related
2914 AC_SUBST(aros_nesting_supervisor)
2916 # MMU related
2917 AC_SUBST(aros_enable_mmu)
2919 # Apple iOS related
2920 AC_SUBST(aros_ios_platform)
2921 AC_SUBST(aros_ios_version)
2922 AC_SUBST(aros_ios_sdk)
2924 # ARM default GCC target related
2925 AC_SUBST(gcc_default_cpu)
2926 AC_SUBST(gcc_default_cpu_tune)
2927 AC_SUBST(gcc_default_fpu)
2928 AC_SUBST(gcc_default_float_abi)
2929 AC_SUBST(gcc_default_mode)
2931 # Android related
2932 AC_SUBST(android_tool)
2933 AC_SUBST(aros_android_level)
2934 AC_SUBST(aros_android_antapk)
2936 # DBUS related
2937 AC_SUBST(ENABLE_DBUS)
2938 AC_SUBST(DBUS_CFLAGS)
2939 AC_SUBST(DBUS_LIBFLAGS)
2940 AC_SUBST(KERNEL_DBUS_KOBJ)
2941 AC_SUBST(KERNEL_DBUS_INCLUDES)
2943 #X11 related
2944 AC_SUBST(ENABLE_X11)
2946 # Debug related
2947 AC_SUBST(aros_debug)
2948 AC_SUBST(aros_mungwall_debug)
2949 AC_SUBST(aros_stack_debug)
2950 AC_SUBST(aros_modules_debug)
2952 # Collect-aros stuff: "-ius" to ignore undefined symbols
2953 AC_SUBST(ignore_undefined_symbols)
2955 # C compiler related
2956 AC_SUBST(gcc_target_cpu)
2957 AC_SUBST(target_binutils_version)
2958 AC_SUBST(target_gcc_version)
2960 #ObjC compiler related
2961 AC_SUBST(objc_target)
2963 #Java related
2964 AC_SUBST(java_target)
2966 # USB3.0 code
2967 AC_SUBST(aros_usb30_code)
2969 dnl Prepare for output, make up all the generated patches
2970 case "$aros_flavour" in
2971 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2972                 aros_flavour="emulation" ;;
2973 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2974                 aros_flavour="emulation" ;;
2975 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2976                 aros_flavour="standalone";;
2977 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2978                 aros_flavour="standalone";;
2979 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2980                 aros_flavour="native" ;;
2981 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2982                 aros_flavour="native" ;;
2983 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2984                 aros_flavour="linklib" ;;
2985 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2986                 aros_flavour="palmnative" ;;
2987 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2988                 aros_flavour="mac68knative" ;;
2989 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2990                 aros_flavour="ppcnative" ;;
2991 esac
2993 if test ! -d ${aros_inc_dir} ; then
2994     ${MKDIR} ${aros_inc_dir}
2996 if test ! -d ${aros_geninc_dir} ; then
2997     ${MKDIR} ${aros_geninc_dir}
2999 if test ! -d ${aros_hostcfg_dir} ; then
3000     ${MKDIR} ${aros_hostcfg_dir}
3002 if test ! -d ${aros_targetcfg_dir} ; then
3003     ${MKDIR} ${aros_targetcfg_dir}
3005 if test ! -d ${aros_tools_dir} ; then
3006     ${MKDIR} ${aros_tools_dir}
3008 if test ! -d ${aros_scripts_dir} ; then
3009     ${MKDIR} ${aros_scripts_dir}
3012 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3014 # Generic build tools (metamake, etc)
3015 AC_CONFIG_COMMANDS([genmf-executable-support],
3016     [chmod a+x ${aros_tools_dir}/genmf.py],
3017     [aros_tools_dir=${aros_tools_dir}]
3019 AC_CONFIG_FILES(
3020     Makefile
3021     config/make.cfg
3022     ${aros_inc_dir}/config.h:config/config.h.in
3023     ${aros_geninc_dir}/config.h:config/config.h.in
3024     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3025     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3026     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3027     mmake.config
3028     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3029     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3030     tools/collect-aros/env.h
3033 # Binutils
3034 AC_CONFIG_COMMANDS([binutils-support],
3035     [
3036         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3037         mkdir -p $prefix
3038         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3040         chmod a+x ${prefix2}-ld
3042         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3043         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3044         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3045         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3046         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3047         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3048         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$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         orig_target_nm=${orig_target_nm}
3057         orig_target_as=${orig_target_as}
3058         orig_target_ar=${orig_target_ar}
3059         orig_target_ranlib=${orig_target_ranlib}
3060         orig_target_objdump=${orig_target_objdump}
3061         orig_target_objcopy=${orig_target_objcopy}
3062         orig_target_strip=${orig_target_strip}
3063         aros_kernel_ld=${aros_kernel_ld}
3064     ]
3066 AC_CONFIG_FILES(
3067     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
3070 # Bare Elf support script and spec
3071 if test "${use_kernel_cc_wrapper}" = "yes"; then
3072     AC_CONFIG_COMMANDS([elf-compiler-support],
3073         [
3074             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3075             mkdir -p $prefix
3076             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3078             chmod a+x ${prefix2}-gcc
3080             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3081         ],
3082         [
3083             aros_host_exe_suffix=${aros_host_exe_suffix}
3084             aros_tools_dir=${aros_tools_dir}
3085             aros_target_cpu=${aros_target_cpu}
3086             aros_target_arch=${aros_target_arch}
3087             aros_target_suffix=${aros_target_suffix}
3088             aros_kernel_ld=${aros_kernel_ld}
3089         ]
3090     )
3091     AC_CONFIG_FILES(
3092         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3093         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3094     )
3097 # Host compiler support scripts and spec
3098 if test "${aros_target_toolchain}" = "no"; then
3099     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3100         [
3101             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3102             mkdir -p $prefix
3103             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3105             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3106         ],
3107         [
3108             aros_host_exe_suffix=${aros_host_exe_suffix}
3109             aros_tools_dir=${aros_tools_dir}
3110             aros_target_cpu=${aros_target_cpu}
3111             aros_target_arch=${aros_target_arch}
3112             aros_target_suffix=${aros_target_suffix}
3113         ]
3114     )
3115     AC_CONFIG_FILES(
3116         ${aros_targetcfg_dir}/specs:config/specs.in
3117         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3118         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3119         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3120     )
3123 # Android support
3124 if test "$aros_target_variant" == "android"; then
3125     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3128 # cmake helper
3129 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3131 AC_OUTPUT
3133 dnl This is in order to not define SHARED_CFLAGS sometimes
3134 dnl We don't always do aros_shared_ar, aros_shared_cflags
3136 #XXX compatability...
3137 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3139 if test -n "$aros_shared_cflags" ; then
3140     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3141     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg