make build_with_configure (and sub-classed macros) take a crossbuild parameter to...
[AROS.git] / configure.in
blob8a706ab817e76ad25c75615d81352c838f83f593
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_warn_flags=
649 aros_config_cflags=
650 aros_config_cxxflags=
651 aros_config_aflags="-Wall -x assembler-with-cpp -c"
652 aros_config_ldflags=""
654 aros_shared_default=yes
656 aros_shared_cflags="-fPIC"
657 aros_shared_aflags=""
658 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
659 aros_kernel_ldflags="-Wl,-rpath,./lib"
661 aros_kernel_ar_flags="cr"
662 aros_target_ar_flags="cr"
663 aros_target_nm_flags="-C -ul"
664 aros_target_strip_flags="--strip-unneeded -R.comment"
666 aros_compiler_libs=
667 aros_arch_libs=
669 aros_target_genmap="-Wl,-Map -Xlinker"
671 # Native flavour stuff
672 aros_serial_debug="0"
674 # Palm native flavour stuff
675 aros_palm_debug_hack="0"
677 # Unix flavour stuff
678 aros_nesting_supervisor="0"
680 # Collect-aros stuff: "-ius" to ignore undefined symbols
681 ignore_undefined_symbols=""
683 # Check for X11 by default
684 need_x11="auto"
686 host_x_gfx=no
687 host_sdl_gfx=no
688 host_android_gfx=no
691 AC_MSG_CHECKING([Which toolchain family to use ...])
692 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")
693 AC_MSG_RESULT($aros_toolchain)
696 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
697 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
698  aros_config_lto="$enableval",aros_config_lto="no")
699 if test "$aros_config_lto" != "no"; then
700     aros_config_lto="yes"
702 AC_MSG_RESULT($aros_config_lto)
704 use_ld_wrapper=yes
706 case "$aros_toolchain" in
707     *llvm*)
708         # toolchain_needs_sysroot=yes
709         toolchain_c_compiler="clang"
710         toolchain_cxx_compiler="clang++"
711         toolchain_cpp_preprocessor="clang -E"
712         toolchain_ld="ld.lld"
713         aros_ld="ld"
714         toolchain_as="llvm-as"
715         toolchain_ar="llvm-ar"
716         toolchain_ranlib="llvm-ranlib"
717         toolchain_nm="llvm-nm"
718         toolchain_strip="true"
719         toolchain_objcopy="llvm-objcopy"
720         toolchain_objdump="llvm-objdump"
721         ;;
722     *gnu*)
723         toolchain_c_compiler="gcc"
724         toolchain_cxx_compiler="g++"
725         toolchain_cpp_preprocessor="gcc -E"
726         toolchain_as="as"
727         aros_ld="ld"
728         if test "$aros_config_lto" != "yes"; then
729             toolchain_ld="ld"
730             toolchain_ar="ar"
731             toolchain_ranlib="ranlib"
732             toolchain_nm="nm"
733         else
734             toolchain_ld="ld.bfd"
735             toolchain_ar="gcc-ar"
736             toolchain_ranlib="gcc-ranlib"
737             toolchain_nm="gcc-nm"
738         fi
739         toolchain_strip="strip"
740         toolchain_objcopy="objcopy"
741         toolchain_objdump="objdump"
742         ;;
743     *)
744         AC_MSG_WARN("Unknown toolchain family!")
745         toolchain_c_compiler="cc"
746         toolchain_cxx_compiler="c++"
747         toolchain_cpp_preprocessor="cpp"
748         toolchain_ld="ld"
749         aros_ld="ld"
750         toolchain_as="as"
751         toolchain_ar="ar"
752         toolchain_ranlib="ranlib"
753         toolchain_nm="nm"
754         toolchain_strip="strip"
755         toolchain_objcopy="objcopy"
756         toolchain_objdump="objdump"
757         ;;
758 esac
760 #-----------------------------------------------------------------------------
762 AC_MSG_CHECKING([which type of build to do])
763 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")
765 if test "$build_type" = "nightly"; then
766     build_type_string="NIGHTLY"
767 elif test "$build_type" = "snapshot"; then
768     build_type_string="SNAPSHOT"
769 elif test "$build_type" = "milestone"; then
770     build_type_string="MILESTONE"
771 elif test "$build_type" = "release"; then
772     build_type_string="RELEASE"
773 else
774     build_type_string="PERSONAL"
775     build_type="personal"
778 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
779 aros_config_cxxflags="$aros_config_cxxflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
781 AC_MSG_RESULT($build_type)
783 #-----------------------------------------------------------------------------
784 all_debug_types="messages stack modules mungwall symbols"
786 AC_MSG_CHECKING([which debug types to enable])
787 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)]),
788  debug="$enableval",debug="")
790 if test "$debug" = "" -o "$debug" = "no"; then
791     debug="none"
792 elif test "$debug" = "yes"; then
793     debug="all"
796 if test "$debug" = "all" ; then
797     debug="messages stack modules symbols"
798     for d in $all_debug_types; do
799         export aros_${d}_debug="1"
800     done
801 else
802     for d in $all_debug_types; do
803         export aros_${d}_debug="0"
804     done
807 if test "$debug" != "none"; then
808     debug=`echo $debug | sed s/,/\ /g`
809     for d in $debug; do
810         found="0"
811         for d2 in $all_debug_types; do
812             if test "$d2" = "$d"; then
813                 found="1"
814                 break
815             fi
816         done
817         if test "$found" = "0"; then
818             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
819         fi
820         export aros_${d}_debug="1"
821     done
822     aros_debug="yes"
824 AC_MSG_RESULT($debug)
826 if test "$aros_messages_debug" = "1"; then
827     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
828 else
829     aros_messages_debug=""
831 if test "$aros_symbols_debug" = "1"; then
832     aros_symbols_debug="-g"
833 else
834     aros_symbols_debug=""
837 # These are the flags to pass when compiling debugged programs
838 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
839 aros_debug_aflags=""
840 aros_debug_ldflags="$aros_symbols_debug"
842 #-----------------------------------------------------------------------------
843 #   Checking for distcc and ccache.
845 #   Always apply the transforms in this particular order. Basically you should
846 #   always run 'ccache distcc compiler' in that order for the best performance.
848 AC_MSG_CHECKING([whether to enable distcc])
849 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
850 if test "$distcc" != "" -a "$distcc" != "no"; then
851     # AC_CHECK_PROG will print out the result in this case
852     AC_PATH_PROG(DISTCC,[distcc],distcc,)
853 else
854     AC_MSG_RESULT(no)
857 AC_MSG_CHECKING([whether to enable ccache])
858 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
859 if test "$ccache" != "" -a "$ccache" != "no"; then
860     # AC_CHECK_PROG will print out the result in this case
861     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
862 else
863     AC_MSG_RESULT(no)
866 #-----------------------------------------------------------------------------
867 AC_MSG_CHECKING([what specific host gcc version to use])
868 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="")
869 if test "$kernel_tool_version" != "" ; then
870     msg_result=$kernel_tool_version
871 else
872     msg_result="default"
874 AC_MSG_RESULT($msg_result)
876 #-----------------------------------------------------------------------------
877 AC_MSG_CHECKING([what optimization flags to use])
878 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
879 if test "$optimization" = "unknown"; then
880     dnl default is -O2 for normal builds, -O0 for debug builds
881     if test "$debug" != "none"; then
882         optimization="-O0"
883     else
884         optimization="-O2"
885     fi
887 aros_optimization_cflags="$optimization"
888 AC_MSG_RESULT($optimization)
890 paranoia_default=yes
891 #-----------------------------------------------------------------------------
892 AC_MSG_CHECKING([which paranoia flags to use])
893 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"])
894 if test "$paranoia_flags" = "no"; then
895         paranoia_flags="-Wall -Werror-implicit-function-declaration"
896         msg_result="none"
897 else
898     if test "$paranoia_flags" = "yes"; then
899         paranoia_flags="-Wall -Werror"
900     fi
901     msg_result="$paranoia_flags"
903 AC_MSG_RESULT($msg_result)
904 aros_warn_flags="$aros_warn_flags $paranoia_flags"
906 #-----------------------------------------------------------------------------
907 AC_MSG_CHECKING([what target variant to enable])
908 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
909 if test "$target_variant" = ""; then
910     aros_target_variant=""
911     aros_target_suffix=""
912     enableval="none"
913 else
914     aros_target_variant="$target_variant"
915     aros_target_suffix="-$target_variant"
917 AC_MSG_RESULT($enableval)
919 #-----------------------------------------------------------------------------
920 # Target-specific defaults. You can override then on a per-target basis.
922 # Bootloader name. Currently used by PC target.
923 target_bootloader="none"
924 PLATFORM_EXECSMP=
925 ENABLE_EXECSMP=
927 #-----------------------------------------------------------------------------
928 # Additional options for some specific targets
930 case "$aros_target_variant" in
931 ios)
932     AC_MSG_CHECKING([XCode path])
933     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")
934     AC_MSG_RESULT($aros_xcode_path)
936     AC_MSG_CHECKING([what iOS SDK version to use])
937     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")
938     AC_MSG_RESULT($aros_sdk_version)
940     ;;
942 "android")
943     AC_MSG_CHECKING([Android SDK path])
944     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)
945     AC_MSG_RESULT($aros_android_sdk)
947     AC_MSG_CHECKING([Android NDK path])
948     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
949     AC_MSG_RESULT($aros_android_ndk)
951     AC_MSG_CHECKING([what Android SDK version to use])
952     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")
953     AC_MSG_RESULT($aros_sdk_version)
955     aros_android_level=android-$aros_sdk_version
956     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
957         echo "Platform $aros_android_level is not installed in your SDK"
958         echo "Use --with-sdk-version=<API level number> to select another platform version"
959         echo "You can check what plaform versions are installed in your SDK"
960         echo "by examining contents of $aros_android_sdk/platforms directory"
961         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
962     fi
964     export PATH="$aros_android_sdk/tools:$PATH"
965     AC_PATH_PROG(android_tool, $android_tool)
966     AROS_REQUIRED(android,$android_tool)
968     if test "$aros_android_ndk" != "none"; then
969         AC_MSG_CHECKING([what Android NDK version to use])
970         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")
971         AC_MSG_RESULT($aros_ndk_version)
972     fi
974     AC_PATH_PROG(ant, ant)
975     if test "$ant" = ""; then
976         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
977     fi
979     AC_MSG_CHECKING([Build debug or release apk])
980     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)
981     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
982         AC_MSG_ERROR([apk-version has to be release or debug])
983     fi
984     AC_MSG_RESULT($aros_android_antapk)
986     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
987     if test "$host_os" = "mingw32"; then
988         android_tool="cmd //c $android_tool"
989     fi
991     need_dlopen="no"
993     ;;
994 esac
996 #-----------------------------------------------------------------------------
997 # External toolchains
998 kernel_tool_prefix="none"
999 aros_tool_prefix="none"
1000 elf_tool_prefix="${target_cpu}-elf-"
1002 # This is the target configuration switch.
1003 case "$target_os" in
1004     linux*)
1005         aros_target_arch="linux"
1006         aros_target_family="unix"
1007         case "$target_cpu" in
1008             *m68k*)
1009                 aros_target_cpu="m68k"
1010                 aros_object_format="m68kelf"
1011                 aros_flavour="emulcompat"
1012                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1013                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1014                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1015                 gcc_target_cpu="mc68000"
1016                 ;;
1017             *i?86*)
1018                 aros_target_cpu="i386"
1019                 aros_object_format="elf_i386"
1020                 aros_flavour="emulation"
1021                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1022                 aros_kernel_ldflags="-Wl,-melf_i386"
1023                 aros_nominal_depth=8
1024                 gcc_target_cpu="i386"
1025                 pci_hidd_target="hidd-pci-linux"
1026                 android_tool_dir_prefix="x86"
1027                 android_tool_prefix="i686-android-linux"
1028                 android_ndk_arch="x86"
1029                 ;;
1030             *x86_64*)
1031                 aros_target_cpu="x86_64"
1032                 aros_object_format="elf_x86_64"
1033                 aros_flavour="emulation"
1034                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1035                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1036                 aros_config_cxxflags="$aros_config_cxxflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1037                 aros_nominal_depth=8
1038                 pci_hidd_target="hidd-pci-linux"
1039                 ;;
1040             *powerpc*)
1041                 aros_target_cpu="ppc"
1042                 aros_object_format="elf32ppc"
1043                 aros_flavour="emulation"
1044                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1045                 aros_nominal_depth=8
1046                 gcc_target_cpu="ppc"
1047                 ;;
1048 # TODO
1049 # Same as powerpc, but I need this for the nightly build to work again.
1050 # Actually, the nightly should be made working with powerpc target.
1051 # That just was too much work for the moment, another week or two.
1052             *ppc*)
1053                 aros_target_cpu="ppc"
1054                 aros_object_format="elf32ppc"
1055                 aros_flavour="emulation"
1056                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1057                 aros_nominal_depth=8
1058                 gcc_target_cpu="ppc"
1059                 ;;
1060             *aarch64*)
1061                 aros_target_cpu="aarch64"
1062                 target_cpu="aarch64"
1063                 aros_object_format="aarch64elf_aros"
1064                 aros_flavour="emulation"
1065                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1066                 gcc_target_cpu="aarch64"
1067                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1068                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1069                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1070                 aros_arch_libs="-laeabi"
1071                 gcc_default_float_abi="hard"
1072                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1073                 ;;
1074             *armhf*)
1075                 aros_target_cpu="arm"
1076                 target_cpu="arm"
1077                 aros_object_format="armelf_aros"
1078                 aros_flavour="emulation"
1079                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1080                 gcc_target_cpu="arm"
1081                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1082                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1083                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1084                 aros_arch_libs="-laeabi"
1085                 gcc_default_float_abi="hard"
1086                 android_tool_dir_prefix="arm-linux-androideabi"
1087                 android_tool_prefix="arm-linux-androideabi"
1088                 android_ndk_arch="arm"
1089                 kernel_tool_prefix="arm-linux-gnueabihf-"
1090                 ;;
1091             *arm*)
1092                 aros_target_cpu="arm"
1093                 aros_object_format="armelf_aros"
1094                 aros_flavour="emulation"
1095                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1096                 gcc_target_cpu="arm"
1097                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1098                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1099                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1100                 aros_arch_libs="-laeabi"
1101                 android_tool_dir_prefix="arm-linux-androideabi"
1102                 android_tool_prefix="arm-linux-androideabi"
1103                 android_ndk_arch="arm"
1104                 kernel_tool_prefix="arm-linux-gnueabi-"
1105                 ;;
1106             *)
1107                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1108                 ;;
1109         esac
1110         case "$aros_target_variant" in
1111             android)
1113                 dnl Not all Linux CPUs are supported by Android
1114                 if test "$android_ndk_arch" = ""; then
1115                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1116                 fi
1118                 aros_nominal_width=320
1119                 aros_nominal_height=480
1120                 if test "$aros_android_ndk" = "none"; then
1121                     dnl Use standalone toolchain, don't adjust paths
1122                     aros_kernel_cflags="-mandroid"
1123                     aros_kernel_ldflags="-mandroid"
1124                     CFLAGS="-mandroid"
1125                 else
1126                     dnl In Android NDK toolchains are placed in own directories,
1127                     dnl but tool names are not suffixed with version 
1128                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1129                     kernel_tool_version=""
1130                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1131                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1132                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1133                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1134                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1135                 fi
1136                 need_x11=no
1137                 host_android_gfx=yes
1138                 # Disable implicit PIC mode
1139                 aros_target_cflags="$aros_target_cflags -fno-pic"
1140                 kernel_tool_prefix="$android_tool_prefix-"
1141             ;;
1142         esac
1143     ;;
1145     pc)
1146         aros_target_arch="pc"
1147         aros_shared_default="no"
1148         target_bootloader="grub2"
1149         case "$target_cpu" in
1150             *i?86*)
1151                 aros_target_cpu="i386"
1153                 dnl If somebody hasn't already set the target object
1154                 dnl format, then use this value. Mostly to support
1155                 dnl FreeBSD cross-compilation.
1156                 dnl TODO: Remove when we always use our compiler.
1158                 if test "$aros_object_format" = "" ; then
1159                     aros_object_format="elf_i386"
1160                 fi
1161                 aros_flavour="standalone"
1162                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1163                 aros_kernel_ldflags="-Wl,-melf_i386"
1164                 aros_nominal_width=640
1165                 aros_nominal_height=480
1166                 gcc_target_cpu="i386"
1167                 ;;
1168             *x86_64*)
1169                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1170                 aros_target_cpu="x86_64"
1171                 aros_serial_debug=1
1172                 if test "$aros_object_format" = "" ; then
1173                     aros_object_format="elf_x86_64"
1174                 fi
1175                 aros_flavour="standalone"
1176                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1177                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1178                 aros_config_cxxflags="$aros_config_cxxflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1179                 aros_kernel_ldflags=""
1180                 aros_nominal_width=640
1181                 aros_nominal_height=480
1182                 case "$aros_target_variant" in
1183                     smp)
1184                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1185                     ;;
1186                 esac
1187                 ;;
1188             *)
1189                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1190                 ;;
1191         esac
1192         ;;
1194     prep)
1195         aros_target_arch="prep"
1196         aros_shared_default="no"
1197         aros_target_cpu="ppc"
1198         aros_object_format="elf32ppc"
1199         aros_flavour="ppcnative"
1200         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1201         aros_kernel_ldflags=""
1202         aros_nominal_width=640
1203         aros_nominal_height=480
1204         gcc_target_cpu="ppc"
1205         ;;
1207     freebsd*)
1208         aros_target_arch="freebsd"
1209         aros_target_family="unix"
1210         aros_target_cpu="i386"
1211         aros_flavour="emulation"
1212         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1213         gcc_target_cpu="i386"
1215         aros_target_strip_flags="-x"
1216         ;;
1218     darwin*)
1219         aros_target_arch="darwin"
1220         aros_target_family="unix"
1221         aros_flavour="emulation"
1222         case "$target_cpu" in
1223             *i?86*)
1224                 aros_ios_platform="iPhoneSimulator"
1225                 aros_target_cpu="i386"
1226                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1227                 aros_kernel_ldflags=""
1228                 aros_macosx_version="10.4"
1229                 aros_nominal_depth=8
1230                 gcc_target_cpu="i386"
1231                 aros_object_format="elf_i386"
1232                 aros_kernel_ar_flags="-cr"
1233                 aros_target_strip_flags="-x"
1234                 kernel_tool_flags="-m32"
1235                 ;;
1236             *x86_64*)
1237                 aros_target_cpu="x86_64"
1238                 aros_object_format="elf_x86_64"
1239                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1240                 aros_macosx_version="10.6"
1241                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1242                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1243                 aros_kernel_cflags="-m64"
1244                 aros_kernel_ldflags="-m64"
1245                 aros_target_cflags="-mcmodel=large"
1246                 aros_nominal_depth=8
1247                 aros_kernel_ar="ar"
1248                 aros_kernel_ar_flags="-cr"
1249                 aros_kernel_ld="ld"
1250                 aros_kernel_as="as"
1251                 aros_kernel_ranlib="ranlib"
1252                 aros_kernel_nm="nm"
1253                 aros_kernel_strip="strip"
1254                 kernel_tool_prefix="i686-apple-darwin10-"
1255                 ;;
1256             *ppc*)
1257                 aros_target_cpu="ppc"
1258                 aros_object_format="elf32ppc"
1259                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1260                 aros_kernel_ldflags=""
1261                 aros_macosx_version="10.0"
1262                 aros_nominal_depth=8
1263                 gcc_target_cpu="ppc"
1264                 aros_kernel_ar="ar"
1265                 aros_kernel_ar_flags="-cr"
1266                 aros_kernel_ld="ld -arch ppc"
1267                 aros_kernel_as="as -arch ppc"
1268                 aros_kernel_ranlib="ranlib -arch ppc"
1269                 aros_kernel_nm="nm -arch ppc"
1270                 aros_kernel_strip="strip -arch ppc"
1271                 kernel_tool_prefix="powerpc-apple-darwin10-"
1272                 ;;
1273             *arm*)
1274                 aros_ios_platform="iPhoneOS"
1275                 aros_target_cpu="arm"
1276                 aros_object_format="armelf_aros"
1277                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1278                 aros_arch_libs="-laeabi"
1279                 aros_nominal_depth=8
1280                 gcc_target_cpu="arm"
1281                 aros_kernel_ar="ar"
1282                 aros_kernel_ar_flags="-cr"
1283                 aros_kernel_ld="ld -arch arm"
1284                 aros_kernel_ranlib="ranlib -arch arm"
1285                 kernel_tool_prefix="arm-apple-darwin10-" 
1286                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1287                 ;;
1288             *)
1289                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1290                 ;;
1291         esac
1292         case "$aros_target_variant" in
1293             ios)
1294                 aros_ios_version="3.0"
1295                 aros_nominal_width=320
1296                 aros_nominal_height=480
1297                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1298                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1299                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1300                 need_x11=no
1301                 # This is here because it may depend on iOS or SDK version
1302                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1303                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1304                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1305             ;;
1306             *)
1307                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1308                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1309             ;;
1310         esac
1311         ;;
1313     dragonfly*)
1314         aros_target_arch="dragonfly"
1315         aros_target_family="unix"
1316         aros_flavour="emulation"
1317         case "$target_cpu" in
1318             *i?86*)
1319                 aros_target_cpu="i386"
1320                 aros_object_format="elf_i386"
1321                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1322                 ;;
1323             *x86_64*)
1324                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1325                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1326                 aros_target_cpu="x86_64"
1327                 aros_object_format="elf_x86_64"
1328                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1329                 ;;
1330             *)
1331                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1332                 ;;
1333         esac
1334         ;;
1336     netbsd*)
1337         aros_target_arch="netbsd"
1338         aros_target_family="unix"
1339         case "$target_cpu" in
1340             *m68k*)
1341                 aros_target_cpu="m68k"
1342                 aros_object_format="m68kelf"
1343                 aros_flavour="emulcompat"
1344                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1345                 gcc_target_cpu="mc68000"
1346                 ;;
1347             *i?86*)
1348                 aros_target_cpu="i386"
1349                 aros_object_format="elf_i386"
1350                 aros_flavour="emulation"
1351                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1352                 aros_nominal_depth=8
1353                 gcc_target_cpu="i386"
1354                 ;;
1355             *)
1356                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1357                 ;;
1358         esac
1359         aros_target_genmap="-Wl,-M -Xlinker >"
1360         aros_flavour="emulation"
1361         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1362         ;;   
1364     openbsd*)
1365         aros_target_arch="openbsd"
1366         aros_target_family="unix"
1367         case "$target_cpu" in
1368             *i?86*)
1369                 aros_target_cpu="i386"
1370                 aros_object_format="elf_i386"
1371                 aros_flavour="emulation"
1372                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1373                 gcc_target_cpu="i386"
1374                 ;;
1375             *)
1376                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1377                 ;;
1378         esac
1379         aros_target_genmap="-Wl,-M -Xlinker >"
1380         aros_target_nm_flags="-u"
1381         aros_flavour="emulation"
1382         ;;
1384     solaris*)
1385         aros_target_arch="solaris"
1386         aros_target_family="unix"
1387         case "$target_cpu" in
1388            *i?86*)
1389                aros_target_cpu="i386"
1390                aros_object_format="elf_i386"
1391                aros_flavour="emulation"
1392                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1393                aros_nominal_depth=8
1394                gcc_target_cpu="i386"
1395                ;;
1396             *sparc*)
1397                 aros_target_cpu="sparc"
1398                 aros_object_format="elf_sparc"
1399                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1400                 gcc_target_cpu="sparc"
1401                 ;;
1402             *)
1403                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1404                 ;;
1405         esac
1406         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1407         aros_config_cxxflags="$aros_config_cxxflags -D$aros_target_cpu"
1408         aros_flavour="emulation"
1409         ;;
1411     morphos*)
1412         aros_target_arch="morphos"
1413         aros_shared_default="no"
1414         aros_target_cpu="ppc"
1415         aros_object_format="elf_ppc"
1416         aros_flavour="nativecompat"
1417         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1418         gcc_target_cpu="ppc"
1419         ;;
1421     sam440)
1422         aros_target_arch="sam440"
1423         aros_shared_default="no"
1424         aros_target_cpu="ppc"
1425         aros_object_format="elf32ppc"
1426         aros_flavour="ppcnative"
1427         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1428         aros_kernel_ldflags=""
1429         aros_nominal_width=1024
1430         aros_nominal_height=768
1431         aros_nominal_depth=24
1432         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1433         aros_config_cxxflags="$aros_config_cxxflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1434         gcc_target_cpu="powerpc"
1435         ;;
1437     efika)
1438         aros_target_arch="efika"
1439         aros_shared_default="no"
1440         aros_target_cpu="arm"
1441         aros_object_format="armelf_aros"
1442         aros_flavour="standalone"
1443         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1444         aros_kernel_ldflags=""
1445         aros_nominal_width=1024
1446         aros_nominal_height=600
1447         aros_arch_libs="-laeabi"
1448         gcc_default_cpu="armv7-a"
1449         gcc_default_fpu="vfpv3"
1450         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1451         aros_config_cxxflags="$aros_config_cxxflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1452         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1453         aros_optimization_cflags="$aros_optimization_cflags -Os"
1454         case "$target_cpu" in
1455             *armhf*)
1456                 gcc_default_float_abi="hard"
1457                 target_cpu=arm
1458                 aros_target_cpu=arm
1459                 ;;
1460             *arm*)
1461                 gcc_default_float_abi="softfp"
1462                 ;;
1463             *)
1464                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1465                 ;;
1466         esac
1467         ;;
1468         
1469     chrp)
1470         aros_target_arch="chrp"
1471         aros_shared_default="no"
1472         aros_target_cpu="ppc"
1473         aros_object_format="elf32ppc"
1474         aros_flavour="ppcnative"
1475         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1476         aros_kernel_ldflags=""
1477         aros_nominal_width=640
1478         aros_nominal_height=480
1479         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"
1480         aros_config_cxxflags="$aros_config_cxxflags -mno-toc -fno-asynchronous-unwind-tables"
1481         gcc_target_cpu="powerpc"
1482         case "$aros_target_variant" in
1483             efika)
1484                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1485                 aros_config_cxxflags="$aros_config_cxxflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1486             ;;
1487         esac
1488         ;;
1490     r*pi)
1491         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1492         aros_flavour="standalone"
1493         aros_target_arch="raspi"
1495         aros_shared_default="no"
1497         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1498         
1499         case "$target_cpu" in
1500             *aarch64*)
1501                 aros_target_cpu="aarch64"
1502                 gcc_default_cpu="aarch64"
1503                 aros_object_format="aarch64elf_aros"
1504                 ;;
1505             *armhf*)
1506                 aros_target_cpu="arm"
1507                 gcc_default_cpu="armv6zk"
1508                 gcc_default_cpu_tune="arm1176jzf-s"
1509                 aros_object_format="armelf_aros"
1510                 aros_config_cflags="$aros_config_cflags -marm"
1511                 aros_config_cxxflags="$aros_config_cxxflags -marm"
1512                 aros_config_aflags="$aros_config_aflags -marm"
1513                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1514                 aros_target_cflags="$aros_kernel_cflags -marm"
1515                 aros_target_mkdep="$aros_target_mkdep -Darm"
1516                 aros_arch_libs="-laeabi"
1517                 ;;
1518             *arm*)
1519                 aros_target_cpu="arm"
1520                 gcc_default_cpu="armv6zk"
1521                 gcc_default_cpu_tune="arm1176jzf-s"
1522                 aros_object_format="armelf_aros"
1523                 aros_config_cflags="$aros_config_cflags -marm"
1524                 aros_config_cxxflags="$aros_config_cxxflags -marm"
1525                 aros_config_aflags="$aros_config_aflags -marm"
1526                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1527                 aros_target_cflags="$aros_kernel_cflags -marm"
1528                 aros_target_mkdep="$aros_target_mkdep -Darm"
1529                 aros_arch_libs="-laeabi"
1530                 ;;
1531             *)
1532                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1533                 ;;
1534         esac
1536         aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1537         aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables -fno-exceptions"
1538         aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1539         aros_kernel_cflags="$aros_kernel_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1540         aros_target_cflags="$aros_kernel_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1542         case "$aros_target_variant" in
1543             smp)
1544                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1545             ;;
1546         esac
1547         ;;
1549     stm32f7_discovery)
1550         aros_flavour="standalone"
1551         aros_target_arch="stm32f7_discovery"
1552         aros_target_cpu="arm"
1553         aros_target_cpu_mode="thumb2"
1554         aros_object_format="armelf_aros"
1555         aros_shared_default="no"
1557         # stm32f7 has DSP opcode support
1558         gcc_default_cpu="armv7e-m"
1559         # gcc_default_cpu="armv7-m"
1560         gcc_default_cpu_tune="cortex-m7"
1561         gcc_default_fpu="fpv4-sp-d16"
1562         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1563         # gcc_default_fpu="fpv5-sp-d16"
1564                 gcc_default_float_abi="hard"
1566         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1567         ;;
1569     amiga*)
1570         aros_target_arch="amiga"
1571         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1572         aros_shared_default="no"
1574         case "$target_cpu" in
1575             *m68k*)
1576                 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")
1577                 aros_enable_mmu=no
1578                 aros_target_cpu="m68k"
1579                 aros_object_format="m68kelf"
1580                 aros_flavour="standcompat"
1581                 gcc_target_cpu="m68000"
1582                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1583                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1584                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1585                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1586                 aros_config_aflags="$aros_config_aflags"
1587                 aros_target_strip_flags="-R.comment --strip-debug"
1588                 aros_nominal_width=640
1589                 aros_nominal_height=256
1590                 aros_nominal_depth=2
1591                 ;;
1592             *ppc*)
1593                 aros_cpu="ppc"
1594                 aros_flavour="native"
1595                 gcc_target_cpu="ppc"
1596                 ;;
1597             *)
1598                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1599                 ;;
1600         esac
1601         ;;
1603     mingw*)
1604         aros_target_arch="mingw32"
1605         aros_shared_default="no"
1606         aros_flavour="emulation"
1607         aros_shared_cflags=""
1608         need_crosstools="yes"
1609         need_dlopen="no"
1610         rescomp="windres"
1611         case "$target_cpu" in
1612             *i?86*)
1613                 aros_target_cpu="i386"
1614                 aros_object_format="elf_i386"
1615                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1616                 aros_nominal_depth=8
1617                 gcc_target_cpu="i386"
1619                 kernel_tool_prefix="i386-mingw32-"
1620                 ;;
1621             *x86_64*)
1622                 aros_target_cpu="x86_64"
1623                 aros_object_format="elf_x86_64"
1624                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1625                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1626                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1627                 aros_nominal_depth=8
1628                 kernel_tool_prefix="x86_64-w64-mingw32-"
1629                 ;;
1630             *arm*)
1631                 aros_target_cpu="arm"
1632                 aros_object_format="armelf_aros"
1633                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1634                 aros_arch_libs="-laeabi"
1635                 aros_nominal_depth=8
1636                 gcc_target_cpu="arm"
1637                 gcc_default_float_abi="soft"
1638                 kernel_tool_prefix="arm-mingw32ce-"
1639                 aros_nominal_width=160
1640                 aros_nominal_height=160
1641                 ;;
1642             *)
1643                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1644                 ;;
1645         esac
1646         if test $host_os = "cygwin"; then
1647                 aros_kernel_cflags="-mno-cygwin"
1648         fi
1649     ;;
1650     pp*)
1651         aros_target_arch="pp"
1652         aros_shared_default="no"
1653         case "$target_cpu" in
1654             *m68k*)
1655                 aros_target_cpu="m68k"
1656                 aros_object_format="m68kelf"
1657                 aros_flavour="palmnative"
1658                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1659                 aros_nominal_width=160
1660                 aros_nominal_height=160
1661                 aros_nominal_depth=1
1662                 aros_target_ar_flags="cru"
1663                 aros_compiler_libs="-lgcc1"
1664                 aros_shared_default=no
1665                 aros_shared_cflags="-fpic"
1666                 aros_shared_aflags=""
1667                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1668                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1669                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1670                 aros_debug_aflags=""
1671                 aros_debug_ldflags="$aros_symbols_debug"
1672                 aros_mungwall_debug="0"
1673                 aros_modules_debug="0"
1674                 gcc_target_cpu="mc68000"
1675                 ignore_undefined_symbols="-ius"
1676                 ;;
1677            *)
1678                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1679                 ;;
1680         esac
1681         ;;
1683     mac*)
1684         aros_target_arch="mac"
1685         aros_shared_default="no"
1686         case "$target_cpu" in
1687             *m68k*)
1688                 aros_target_cpu="m68k"
1689                 aros_object_format="m68kelf"
1690                 aros_flavour="mac68knative"
1691                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1692                 aros_nominal_width=512
1693                 aros_nominal_height=384
1694                 aros_nominal_depth=8
1695                 aros_target_ar_flags="cru"
1696                 aros_compiler_libs="-lgcc1"
1697                 aros_shared_default=no
1698                 aros_shared_cflags="-fpic"
1699                 aros_shared_aflags=""
1700                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1701                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1702                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1703                 aros_debug_aflags=""
1704                 aros_debug_ldflags="$aros_symbols_debug"
1705                 aros_mungwall_debug="0"
1706                 aros_modules_debug="0"
1707                 gcc_target_cpu="mc68000"
1708                 ignore_undefined_symbols="-ius"
1709                 ;;
1710            *)
1711                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1712                 ;;
1713         esac
1714         ;;
1716     *)
1717         AC_MSG_ERROR([Unsupported target architecture $target])
1718         ;;
1719 esac
1721 #-----------------------------------------------------------------------------
1722 crosstools_guess="yes"
1723 aros_target_toolchain="no"
1724 aros_config_sysroot=""
1725 aros_kernel_sysroot=""
1727 AC_MSG_CHECKING([Kernel toolchain prefix])
1728 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1729 AC_MSG_RESULT($kernel_tool_prefix)
1731 AC_MSG_CHECKING([ELF toolchain prefix])
1732 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"
1733                                                  crosstools_guess="no"])
1734 AC_MSG_RESULT($elf_tool_prefix)
1736 AC_MSG_CHECKING([AROS toolchain prefix])
1737 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"
1738                 crosstools_guess="no"])
1739 if test "$aros_tool_prefix" = "yes" ; then
1740     aros_tool_prefix=$aros_target_cpu-aros-
1742 AC_MSG_RESULT($aros_tool_prefix)
1744 #-----------------------------------------------------------------------------
1745 #   Checking if we should build crosstools..
1746 AC_MSG_CHECKING([whether to build crosstools])
1747 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1748 AC_MSG_RESULT($crosstools)
1750 if test "${crosstools}" = "yes"; then
1751     if test "${crosstools_guess}" = "no"; then
1752         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1753     fi
1756 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1757     aros_target_toolchain="yes"
1760 AC_MSG_CHECKING([where to install the crosstools binaries])
1761 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])
1762 if test "x$aros_toolchain_install" = "x"; then
1763     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1764 else
1765     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1766     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1767     if test "$crosstools_guess" = "no" ; then
1768         toolchain_needs_sysroot=yes
1770         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1771             aros_kernel_sysroot = $aros_config_sysroot
1772         fi
1773     fi
1775 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1777 AC_MSG_CHECKING([If we need to use --sysroot])
1778 if test "$toolchain_needs_sysroot" = "yes" ; then
1779     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer"
1781 AC_MSG_RESULT($toolchain_needs_sysroot)
1783 #-----------------------------------------------------------------------------
1784 if test "$aros_toolchain" = "gnu" ; then
1785     AC_MSG_CHECKING([what specific target binutils version to use])
1787 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="")
1788 if test "$use_binutils_version" = ""; then
1789         target_binutils_version="$default_binutils_version"
1790 else
1791     target_binutils_version="$use_binutils_version"
1793 if test "$aros_toolchain" = "gnu" ; then
1794     AC_MSG_RESULT($target_binutils_version)
1798 # Helper to identify gcc version
1799 AC_DEFUN([CROSS_GCC_VERSION], [
1800   target_gcc_version=""
1801   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1802     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1803     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1804       ax_cv_gcc_version=""
1805     ])
1806   ])
1807   target_gcc_version=$ax_cv_gcc_version
1808   AC_SUBST([target_gcc_version])
1811 #-----------------------------------------------------------------------------
1812 if test "$aros_toolchain" = "gnu" ; then
1813     AC_MSG_CHECKING([what specific target gcc version to use])
1815 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1816 if test "$use_gcc_version" = ""; then
1817     if test "${crosstools}" = "no"; then
1818       if test "x$aros_toolchain_install" != "x"; then
1819           CROSS_GCC_VERSION
1820       fi
1821     fi
1822     if test "$use_gcc_version" = ""; then
1823         target_gcc_version="$default_gcc_version"
1824     fi
1825 else
1826     target_gcc_version="$use_gcc_version"
1828 if test "$aros_toolchain" = "gnu" ; then
1829     AC_MSG_RESULT($target_gcc_version)
1831     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1832     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1833     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1835     gcc_fix_bitfields="false"
1836     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1837         gcc_fix_bitfields="true"
1838     else
1839         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1840             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1841                 gcc_fix_bitfields="true"
1842             fi
1843         fi
1844     fi
1846     if test "$gcc_fix_bitfields" = "true" ; then
1847         case "$aros_target_cpu" in
1848         *x86_64*)
1849             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1850             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1851             ;;
1852         i386)
1853             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1854             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1855             ;;
1856         esac
1857     fi
1860 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1861 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1862 AC_MSG_RESULT($objc)
1863 if test "x$objc" = "xyes"; then
1864     objc_target="$objc"
1865 else
1866     objc_target="no-objc"
1869 AC_MSG_CHECKING([whether to enable Java suppport])
1870 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1871 AC_MSG_RESULT($java)
1872 if test "x$java" != "xno"; then
1873     java_target="$java"
1874 else
1875     java_target="no-java"
1878 spec_obj_format="-m $aros_object_format"
1879 # Now process extra architecture-specific options.
1880 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1881 # as well as floating-point ABI.
1882 case "$aros_target_cpu" in
1883 *x86_64*)
1884     dnl x86_64 can build 32 or 64bit code
1885     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1886     ;;
1887 arm*)
1888     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1889     if test "$gcc_default_cpu" = ""; then
1890         gcc_default_cpu="armv6"
1891     fi
1892     if test "$gcc_default_fpu" = ""; then
1893         gcc_default_fpu="vfp"
1894     fi
1895     if test "$gcc_default_float_abi" = ""; then
1896         if test "$target_cpu" = "armhf"; then
1897             gcc_default_float_abi="hard"
1898         else
1899             gcc_default_float_abi="softfp"
1900         fi
1901     fi
1903     AC_MSG_CHECKING([Which minimum CPU to use])
1904     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)
1905     AC_MSG_RESULT($aros_gcc_cpu)
1907     AC_MSG_CHECKING([Which minimum FPU to use])
1908     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)
1909     AC_MSG_RESULT($aros_gcc_fpu)
1911     AC_MSG_CHECKING([Which floating point ABI to use])
1912     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)
1913     AC_MSG_RESULT($aros_gcc_float_abi)
1915     AC_MSG_CHECKING([Which ARM mode to use])
1916     if test "$aros_target_cpu_mode" = ""; then
1917         aros_target_cpu_mode="arm32"
1918         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1919     else
1920         AC_MSG_RESULT([$aros_target_cpu_mode])
1921     fi
1923     case "$aros_target_cpu_mode" in
1924     arm32)
1925         gcc_default_mode="arm"
1926         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1927     ;;
1928     arm64)
1929         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1930     ;;
1931     thumb)
1932         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1933     ;;
1934     thumb1)
1935         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1936     ;;
1937     thumb2)
1938         gcc_default_mode="thumb"
1939         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1940         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1941     ;;
1942     *)
1943         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1944     ;;
1945     esac
1947     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1948     aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables -fno-exceptions"
1949     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1950     ;;
1951 i386)
1952     aros_isa_flags="-m32 -march=i486"
1953     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1954     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1955     ;;
1956 esac
1958 # Some architectures may need custom ELF specs.
1959 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1960     elf_specs_in=config/${aros_object_format}-specs.in
1961 else
1962     elf_specs_in=config/elf-specs.in
1965 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1966 # Since we override specs, we may need to put these defines there
1967 if test "$gcc_target_cpu" != ""; then
1968     gcc_target_cpu="-D__${gcc_target_cpu}__"
1971 AC_MSG_CHECKING([where to download sourcecode for external ports])
1972 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1973 if test "$with_portssrcdir" = "default"; then
1974     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1975 else
1976     AROS_PORTSSRCDIR="$with_portssrcdir"
1978 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1980 AC_MSG_CHECKING([which bootloader to use])
1981 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1982 if test "$target_bootloader" = "none"; then
1983     aros_target_bootloader=""
1984 else
1985     aros_target_bootloader="$target_bootloader"
1987 AC_MSG_RESULT($target_bootloader)
1989 AC_MSG_CHECKING([which icon-set to use])
1990 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1991 if test "$target_iconset" = "default"; then
1992     aros_target_iconset="Gorilla"
1993     target_iconset="default (Gorilla)"
1994 else
1995     aros_target_iconset="$target_iconset"
1997 AC_MSG_RESULT($target_iconset)
1999 AC_MSG_CHECKING([which GUI Theme to use])
2000 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2001 if test "$target_guitheme" = "default"; then
2002     aros_target_guitheme="Ice"
2003 else
2004     aros_target_guitheme="$target_guitheme"
2006 AC_MSG_RESULT($aros_target_guitheme)
2008 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2009 # for target code)
2010 cross_compiling=no
2012 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2013 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2014     cross_compiling=yes
2017 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2018 dnl The flag itself is given in per-target section, because some targets require to pass it
2019 dnl in a different manner, otherwise some tests fail.
2020 dnl TODO: Justify this.
2021 if test "$aros_host_cpu" == "x86_64" ; then
2022     if test "$aros_target_cpu" == "i386" ; then
2023         cross_compiling=no
2024     fi
2027 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2028     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2029     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2030     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2031     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2032     dnl used to build bootstrap for target arch in either case.
2033     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2034     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2035     dnl perhaps introducing aros_host_variant
2036     if test "$aros_host_arch" != "$aros_target_arch" ; then
2037         cross_compiling=yes
2038     fi
2039 else
2040     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2041     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2042     if test "$host_cc_elf" = "no" ; then
2043         cross_compiling=yes
2044     fi
2047 if test "$cross_compiling" = "no" ; then
2048     kernel_tool_prefix=""
2049     if test "$host_cc_elf" = "yes" ; then
2050         elf_tool_prefix=""
2051     fi
2054 if test "$kernel_tool_version" != ""; then
2055     kernel_tool_version="-$kernel_tool_version"
2058 #######################################################################
2059 ## Compute what toolchains to use, and their paths                   ##
2060 #######################################################################
2062 # This takes, as input:
2063 #   crosstools             {yes,no}
2064 #   kernel_tool_version    {"",[version]}
2065 #   target_tool_version    {"",[version]}
2066 #   kernel_tool_prefix     {none,[some-arch-os-]}
2067 #   gnu-toolchain -:
2068 #     target_tool_prefix     ${aros_target_cpu}-aros-
2069 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2071 # The output is
2072 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2073 #        Where the 'kernel' binaries are located
2074 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2075 #        Where the 'target' binaries are located
2076 #        (not the symlink farm - that is aros_target_*!)
2078 # The rules are:
2079 #   if crosstools then
2080 #      if kernel_tools_prefix = "no-kernel-prefix-"
2081 #          aros_kernel_* = crosstools cc paths
2082 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2083 #      else
2084 #          VALIDATE(${kernel_tools_prefix}*)
2085 #          aros_kernel_* = ${kernel_tools_prefix}*
2086 #          if ${kernel_tools_prefix}cc is an AROS gcc
2087 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2088 #          else
2089 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2090 #          fi
2091 #      fi
2093 #      orig_target_* = aros built crosstools
2094 #      orig_target_cc = elf cc wrapper around crosstools cc
2095 #   else
2096 #      VALIDATE(${kernel_tools_prefix}*)
2098 #      orig_target_* = aros_kernel_*
2099 #      if aros_kernel_cc is an AROS gcc
2100 #          orig_target_cc = aros_kernel_cc
2101 #      else
2102 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2103 #      fi
2104 #   fi
2106 if test "$aros_toolchain" = "gnu" ; then
2107     target_tool_prefix="${aros_target_cpu}-aros-"
2108 elif test "$aros_toolchain" = "llvm" ; then
2109     target_tool_prefix="bin/"
2112 if test "$kernel_tool_prefix" != "" ; then
2113     AC_MSG_CHECKING([which kernel tools])
2114     AC_MSG_RESULT([$kernel_tool_prefix]);
2117 if test "$kernel_tool_prefix" = "none" ; then
2118     dnl ELF wrapper can be used only for native bootstrap
2119     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2120         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2121     fi
2122 else
2123     # Kernel tools required - find them
2124     # Note that 'normally', aros_kernel_* overrides will be
2125     # empty, unless specified in the per-arch sections above.
2126     if test "x$aros_kernel_cpp" = "x"; then
2127         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2128     fi
2129     AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2130     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2131     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2133     if test "x$aros_kernel_cc" = "x"; then
2134         aros_kernel_cc=${kernel_tool_prefix}${CC}
2135     fi
2136     AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2137     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2138     AROS_REQUIRED(cc,$aros_kernel_cc)
2140     if test "x$aros_kernel_cxx" = "x"; then
2141         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2142     fi
2143     AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2144     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2145     # If it's set, make sure it's really there
2146     if test "x$aros_kernel_cxx" != "x" ; then
2147         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2148     fi
2149     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2150     AROS_REQUIRED(ld,$aros_kernel_ld)
2151     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2152     AROS_REQUIRED(as,$aros_kernel_as)
2153     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2154     AROS_REQUIRED(ar,$aros_kernel_ar)
2155     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2156     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2157     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2158     AROS_REQUIRED(nm,$aros_kernel_nm)
2159     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2160     AROS_REQUIRED(strip,$aros_kernel_strip)
2162     # Objcopy and objdump are not required for the kernel
2163     # toolchain on many architectures.
2164     # So we'll look for them, but not make them strictly required.
2165     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2166     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2167     if test "x${crosstools}" != "xyes" ; then
2168         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2169         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2170     fi
2173 AC_MSG_CHECKING([which target tools to use])
2174 if test "$aros_target_toolchain" = "yes"; then
2175     if test "$aros_toolchain" = "llvm" ; then
2176         msg_result="llvm"
2177     else
2178         msg_result=$target_tool_prefix
2179     fi
2180     AC_MSG_RESULT([$msg_result])
2181     # We are building AROS crosstools
2182     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2183     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2184     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2185     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2186     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2187     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2188     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2189     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2190     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2191     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2192     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2193     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2194 else
2195     # Determine whether AROS or ELF tools should be used
2196     if test "$aros_tool_prefix" = "none"; then
2197         aros_tool_prefix="${elf_tool_prefix}"
2198     fi
2200     AC_MSG_RESULT([$aros_tool_prefix])
2201     # We are *not* building AROS crosstools - use the AROS or ELF tools
2202     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2203     AROS_REQUIRED(cpp,$orig_target_cpp)
2204     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2205     AROS_REQUIRED(cc,$orig_target_cc)
2206     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2207     AROS_REQUIRED(cxx,$orig_target_cxx)
2208     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2209     AROS_REQUIRED(ld,$orig_target_ld)
2210     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2211     AROS_REQUIRED(as,$orig_target_as)
2212     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2213     AROS_REQUIRED(ar,$orig_target_ar)
2214     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2215     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2216     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2217     AROS_REQUIRED(nm,$orig_target_nm)
2218     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2219     AROS_REQUIRED(strip,$orig_target_strip)
2220     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2221     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2222     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2223     AROS_REQUIRED(objdump,$orig_target_objdump)
2226 if test "$kernel_tool_prefix" = "none" ; then
2227     # No kernel tools specified
2228     # Assume target tools == kernel tools with ELF wrapper
2229     aros_kernel_cc=$orig_target_cc
2230     aros_kernel_cxx=$orig_target_cxx
2231     aros_kernel_cpp=$orig_target_cpp
2232     aros_kernel_ld=$orig_target_ld
2233     aros_kernel_as=$orig_target_as
2234     aros_kernel_ar=$orig_target_ar
2235     aros_kernel_ranlib=$orig_target_ranlib
2236     aros_kernel_nm=$orig_target_nm
2237     aros_kernel_strip=$orig_target_strip
2238     aros_kernel_objcopy=$orig_target_objcopy
2239     aros_kernel_objdump=$orig_target_objdump
2240     use_kernel_cc_wrapper=yes
2243 # At this point, all aros_kernel_* and aros_target_* 
2244 # tools should be set up correctly
2246 CC="$aros_kernel_cc $kernel_tool_flags"
2247 CPP="$aros_kernel_cpp"
2249 #-----------------------------------------------------------------------------
2251 # Find all the tools we need to compile. This could be cross-compiling
2252 # though! If that is the case we use the GNU form of the target and
2253 # simply add this to the front of the binary name. This is rather simple,
2254 # but it should work under most circumstances.
2256 # The default tools are to use the same as the host, but only if the
2257 # host and target CPU are the same. With GCC this is normally enough.
2260 aros_cc_pre=""
2261 aros_shared_ld="$aros_host_ld"
2263 aros_target_mkdep="$aros_host_mkdep"
2265 # The default tools executables to be linked to.
2266 if test "$rescomp" != ""; then
2267     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2268     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2271 # Set up the sources for the symlink farm
2272 if test "$crosstools" = "yes"; then
2273     crosstools_target=tools-crosstools
2276 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2277 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2279 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2280 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2281 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2282 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2283 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2284 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2285 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2287 # aros_cc_pre is a variable that is added to the front of the compiler name
2288 # in the generated aros-gcc shell script. We need this to enable the cache
2289 # to work across cleaned builds. Also, support DISTCC using the correct
2290 # environment variable.
2293 if test "x${DISTCC}" != "x" ; then
2294     if test "x${CCACHE}" != "x" ; then
2295         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2296     else
2297         aros_cc_pre="${DISTCC} "
2298     fi
2299 else
2300     if test "x${CCACHE}" != "x" ; then
2301         aros_cc_pre="${CCACHE} "
2302     fi
2305 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2306 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2307 AC_SUBST(aros_target_nix_ldflags,-nix)
2308 AC_SUBST(aros_target_detach_ldflags,-detach)
2309 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2311 # Target tools
2312 AC_SUBST(aros_toolchain)
2313 if test "$aros_target_toolchain" != "yes"; then
2314     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2315     if test "$GCC" = "yes"; then
2316         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2317     fi
2318 else
2319     # We do not know which c compiler version we are going to build and what we need to know
2320     # here is different for different versions so this will be set later during the
2321     # build of crosstools.
2322     if test "$aros_toolchain" = "gnu" ; then
2323         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2324     elif test "$aros_toolchain" = "llvm" ; then
2325         prefix="$AROS_CROSSTOOLSDIR/bin/"
2326     fi
2327     aros_target_cc_path=@aros_target_cc_path@
2329 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2330 aros_target_cc="${prefix}${toolchain_c_compiler}"
2331 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2332 aros_target_as="${prefix}${toolchain_as}"
2333 if test "${use_ld_wrapper}" = "yes"; then
2334     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2335 else
2336     aros_target_ld="${prefix}${toolchain_ld}"
2338 aros_toolchain_ld="${prefix}${toolchain_ld}"
2340 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2341 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2342 aros_target_objdump="${prefix}${toolchain_objdump}"
2343 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2344 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2345 aros_target_strip="${prefix}${toolchain_strip}"
2346 aros_plain_nm="${prefix}${toolchain_nm}"
2347 aros_plain_ar="${prefix}${toolchain_ar}"
2349 AC_ARG_ENABLE(includes,
2350 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2351 [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`])
2353 if test "$aros_kernel_includes" = ""; then
2354     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2355         aros_kernel_includes="-isystem $aros_target_incl"
2356     fi
2359 if test "$aros_kernel_includes" != "" ; then
2360     dnl find out about the kernel cc's include path
2361     AC_MSG_CHECKING([for the kernel compiler's include path])
2362     if test "$aros_kernel_cc_includes" = "" ; then
2363         # Try to guess where the directory is.
2364         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2365         if test -d $aros_kernel_cc_includes; then
2366             # Check if there is also an include-fixed directory and add it
2367             # to kernel compiler's include path as it may contain some of
2368             # the headers we need.
2369             if test -d "$aros_kernel_cc_includes"-fixed; then
2370                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2371             fi
2372             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2373             if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2374                 aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2375             fi
2376         else
2377             # The directory doesn't exist, we need to do some more work.
2378             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2380             # These are the headers we're looking for.
2381             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2382                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2383                      zutil.h stdint.h"
2385             dirs=
2386             for h in $headers; do
2387                 # Which other headers are needed by each of the above?
2388                 deps=$(echo "#include <$h>" | \
2389                        $aros_kernel_cc -E -M - 2>/dev/null | \
2390                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2392                 # Copy all the needed headers to a directory beneath gendir.
2393                 for d in $deps; do
2394                     h=$(basename $d)
2395                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2396                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2397                     ! test -d $dir && mkdir -p $dir
2398                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2399                 done
2400             done            
2401         fi
2402     fi
2403     AC_MSG_RESULT($aros_kernel_cc_includes)
2404     # Adding -nostdinc to kernel includes as they are always used together.
2405     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2408 if test "$crosstools" != "yes"; then
2409     dnl find out about the target cc's include path
2410     AC_MSG_CHECKING([for the target compiler's include path])
2411     if test "$aros_target_cc_includes" = "" ; then
2412         #try to guess where the directory is
2413         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2414         if ! test -d $aros_target_cc_includes; then
2415             #the directory doesn't exist, we need to do some more work
2416             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2417         
2418             #these are the headers we're looking for
2419             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2420                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2421                     zutil.h"
2423             dirs=
2424             for h in $headers; do
2425                 #which other headers each of the above headers needs?
2426                 deps=$(echo "#include <$h>" | \
2427                     $orig_target_cc -E -M - 2>/dev/null | \
2428                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2429             
2430                 #copy all the needed headers to a directory beneath gendir
2431                 for d in $deps; do
2432                     h=$(basename $d)
2433                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2434                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2435                     ! test -d $dir && mkdir -p $dir
2436                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2437                 done
2438             done
2439         fi
2440     fi
2441     AC_MSG_RESULT($aros_target_cc_includes)
2442 else
2443     # We do not know which c compiler version we are going to build and what we need to know
2444     # here is different for different versions so this will be set later during the
2445     # build of crosstools.
2446     aros_target_cc_includes=@aros_target_cc_includes@
2450 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2451 # On GCC >= 4.0 -iquote should be used
2454 save_cc="$CC"
2455 save_cflags="$CFLAGS"
2456 CFLAGS="-iquote."
2457 kernel_cflags_iquote=$host_cflags_iquote
2458 kernel_cflags_iquote_end=$host_cflags_iquote_end
2459 if test "x-$cross_compiling" = "x-yes"; then
2460     CC="$aros_kernel_cc"
2461     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2462     if test "x-$crosstools" != "x-yes"; then
2463         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2464     else
2465         # we do know it is supported for the smallest version of gcc we are going to build
2466         # we assume it's also supported by later versions
2467         use_no_stack_protector=yes
2468     fi
2469     AC_MSG_RESULT($use_no_stack_protector)
2470     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2471     if test "x-$crosstools" != "x-yes"; then
2472         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2473     else
2474         # we do know it is supported for the smallest version of gcc we are going to build
2475         # we assume it's also supported by later versions
2476         has_iquote=yes
2477     fi
2478     AC_MSG_RESULT($has_iquote)
2479     if test "x-$has_iquote" = "x-yes" ; then
2480         kernel_cflags_iquote=-iquote
2481         kernel_cflags_iquote_end=
2482     else
2483         kernel_cflags_iquote=-I
2484         kernel_cflags_iquote_end=-I-
2485     fi
2487 if test "x-$use_no_stack_protector" = "x-yes" ; then
2488     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2491 #-----------------------------------------------------------------------------
2493 # Check if we can explicitly choose older version of symbol hashing
2495 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2496 CC="$aros_kernel_cc"
2497 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2498 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2499 AC_MSG_RESULT($use_hash_style)
2500 if test "x-$use_hash_style" = "x-yes" ; then
2501     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2503 CC="$save_cc"
2504 CFLAGS="$save_cflags"
2506 AC_SUBST(host_cflags_iquote)
2507 AC_SUBST(host_cflags_iquote_end)
2508 AC_SUBST(kernel_cflags_iquote)
2509 AC_SUBST(kernel_cflags_iquote_end)
2512 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2513 AC_MSG_CHECKING([for default resolution of WBScreen])
2514 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2515 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2516 if test "$resolution" = "yes" ; then
2517     resolution="none"
2519 if test "$resolution" = "no" ; then
2520     resolution="none"
2522 if test "$resolution" != "none" ; then
2523     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2524     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2525     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2527 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2528 aros_cv_nominal_width=$aros_nominal_width
2529 aros_cv_nominal_height=$aros_nominal_height
2530 aros_cv_nominal_depth=$aros_nominal_depth
2532 dnl See if the user wants the serial debug output for native flavour
2533 AC_MSG_CHECKING([whether serial debug is enabled])
2534 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)
2535 if test "$aros_serial_debug" = 0 ; then
2536     serial_debug_forced=""
2537     if test "$serial_debug" = "yes" ; then
2538         serial_debug="1"
2539     fi
2540     if test "$serial_debug" = "no" ; then
2541         serial_debug="none"
2542     fi
2543 else
2544     serial_debug_forced="(forced)"
2545     serial_debug=$aros_serial_debug
2547 if test "$serial_debug" != "none" ; then
2548     aros_serial_debug=$serial_debug
2549     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2550 else
2551     AC_MSG_RESULT(no)
2554 dnl See if the user wants the palm debug output hack for palm native flavour
2555 AC_MSG_CHECKING([whether palm debug hack is enabled])
2556 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")
2557 if test "$palm_debug_hack" = "yes" ; then
2558     aros_palm_debug_hack="1"
2560 AC_MSG_RESULT($palm_debug_hack)
2562 dnl See if dev wants the usb3.0 code
2563 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2564 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2565 if test "$usb30_code" = "yes" ; then
2566     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2567     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2569 AC_MSG_RESULT($usb30_code)
2571 dnl See if the user wants nesting supervisor activated for unix flavour
2572 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2573 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")
2574 if test "$nesting_supervisor" = "yes" ; then
2575     aros_nesting_supervisor="1"
2577 AC_MSG_RESULT($nesting_supervisor)
2579 dnl See if the user wants to disable MMU support
2580 dnl This can be overriden on per-target basis,
2581 dnl set $aros_enable_mmu to "yes" or "no" to do this
2582 if test "$aros_enable_mmu" = "" ; then
2583     AC_MSG_CHECKING([whether MMU support is enabled])
2584     dnl Enabled by default
2585     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2586     if test "$aros_enable_mmu" = "" ; then
2587         aros_enable_mmu="yes"
2588     fi
2589     AC_MSG_RESULT($aros_enable_mmu)
2591 if test "$aros_enable_mmu" = "no" ; then
2592     aros_enable_mmu="0"
2593 else
2594     aros_enable_mmu="1"
2596     
2598 dnl things specifically required for hosted flavours
2599 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2601     if test "x-$need_dlopen" != "x-no" ; then
2602       save_libs="$LIBS"
2603       LIBS=""
2604       dnl some kind of dynamic library access system is required for hostlib.resource
2605       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2606       if test "x-$have_dl" = "x-no" ; then
2607           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2608                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2609                                     have_dl="no")
2610       fi
2611       if test "x-$have_dl" = "x-no" ; then
2612           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2613       fi
2614       LIBS="$save_libs"
2615     fi
2618     dnl x11 hidd
2619     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2620                                            [build X11 hidd for hosted (default=auto)]),
2621                                            x11_hidd="$enableval",
2622                                            x11_hidd="$need_x11")
2623     case "x-$x11_hidd" in
2624         x-yes|x-no|x-auto)                 ;;
2625         *)                 x11_hidd="$need_x11" ;;
2626     esac
2628     ENABLE_X11=0
2630     dnl they want it
2631     if test "x-$x11_hidd" != "x-no" ; then
2633         dnl find x11 stuff
2634         AC_PATH_X
2636         if test -n "$x_includes"; then
2637             X_CFLAGS="$X_CFLAGS -I$x_includes"
2638         fi
2640         if test -n "$x_libraries"; then
2641             X_LIBS="$X_LIBS -L$x_libraries"
2642         fi
2644         if test "x-$no_x" = "x-yes" ; then
2646             dnl didn't find it
2647             if test "x-$x11_hidd" != "x-auto" ; then
2648                 dnl and they explicitly asked for it, bail out
2649                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2650             fi
2651         
2652         else
2653             dnl found it, setup the metatarget
2654             host_x_gfx=yes
2655             ENABLE_X11=1
2657             aros_host_x11_cflags="$X_CFLAGS"
2658             aros_host_x11_ldflags="$X_LIBS  -lX11"
2660             dnl setup shared memory extensions
2661             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2662                                                   [use X11 shared memory (default=auto)]),
2663                                                   x11_hidd_shm="$enableval",
2664                                                   x11_hidd_shm="auto")
2665             case "x-$x11_hidd_shm" in
2666                 x-yes|x-no|x-auto)                     ;;
2667                 *)                 x11_hidd_shm="auto" ;;
2668             esac
2670             have_xshm=no
2672             dnl they want it
2673             if test "x-$x11_hidd_shm" != "x-no" ; then
2675                 dnl system shm headers
2676                 AC_CHECK_HEADERS(sys/ipc.h)
2677                 AC_CHECK_HEADERS(sys/shm.h)
2679                 dnl got them
2680                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2682                     dnl make sure X libs have shm functions
2683                     save_cflags="$CFLAGS"
2684                     save_ldflags="$LDFLAGS"
2685                     CFLAGS="$CFLAGS $X_CFLAGS"
2686                     LDFLAGS="$LDFLAGS $X_LIBS"
2687                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2688                     CFLAGS="$save_cflags"
2689                     LDFLAGS="$save_ldflags"
2690                 fi
2691             fi
2693             dnl detection done, prepare output
2694             if test "x-$have_xshm" = "x-yes" ; then
2695                 dnl we can do shm
2696                 DO_XSHM_SUPPORT="1"
2697             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2698                 dnl they explicitly asked for it, but we can't do it
2699                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2700             else
2701                 dnl otherwise just disable it
2702                 DO_XSHM_SUPPORT="0"
2703             fi
2705             
2706             dnl setup vidmode (fullscreen) extensions
2707             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2708                                                       [use X11 vidmode extension (default=auto)]),
2709                                                       x11_hidd_vidmode="$enableval",
2710                                                       x11_hidd_vidmode="auto")
2711             case "x-$x11_hidd_vidmode" in
2712                 x-yes|x-no|x-auto)                         ;;
2713                 *)                 x11_hidd_vidmode="auto" ;;
2714             esac
2716             have_vidmode=no
2718             dnl they want it
2719             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2721                 dnl make sure X libs have vidmode functions
2722                 save_cflags="$CFLAGS"
2723                 save_ldflags="$LDFLAGS"
2724                 CFLAGS="$CFLAGS $X_CFLAGS"
2725                 LDFLAGS="$LDFLAGS $X_LIBS"
2726                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2727                 CFLAGS="$save_cflags"
2728                 LDFLAGS="$save_ldflags"
2729             fi
2731             dnl detection done, prepare output
2732             if test "x-$have_vidmode" = "x-yes" ; then
2733                 dnl we can do vidmode
2734                 DO_VIDMODE_SUPPORT="1"
2735             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2736                 dnl they explicitly asked for it, but we can't do it
2737                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2738             else
2739                 dnl otherwise just disable it
2740                 DO_VIDMODE_SUPPORT="0"
2741             fi
2742         fi
2743     fi
2745     dnl sdl hidd
2746     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2747                                            [build SDL hidd for hosted (default=auto)]),
2748                                            sdl_hidd="$enableval",
2749                                            sdl_hidd="auto")
2750     case "x-$sdl_hidd" in
2751         x-yes|x-no|x-auto)                 ;;
2752         *)                 sdl_hidd="auto" ;;
2753     esac
2755     dnl they want it
2756     if test "x-$sdl_hidd" != "x-no" ; then
2758         dnl find sdl
2759         SDL_VERSION=1.2.5
2760         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2761             [have_sdl="no"])
2763         if test "x-$have_sdl" != "x-yes" ; then
2765             dnl didn't find it
2766             if test "x-$sdl_hidd" != "x-auto" ; then
2767                 dnl and they explicitly asked for it, bail out
2768                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2769             fi
2771         else
2772             dnl found it, enable the build
2773             host_sdl_gfx=yes
2774             aros_host_sdl_cflags=$SDL_CFLAGS
2775             aros_host_sdl_libs=$SDL_LIBS
2776         fi
2777     fi
2782 dnl See if the user wants dbus.library
2783 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2784 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2785 if test "$dbus" = "yes" ; then
2786     ENABLE_DBUS=1
2787     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2788     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2789     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2790     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2791 else
2792     ENABLE_DBUS=0
2794 AC_MSG_RESULT($dbus)
2796 if test "$use_kernel_cc_wrapper" = "yes" ; then
2797     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2800 dnl --------------------------------------------------------------------
2801 dnl Configuration Output Section
2802 dnl --------------------------------------------------------------------
2804 # Generic
2805 AC_SUBST(aros_arch)
2806 AC_SUBST(aros_cpu)
2807 AC_SUBST(aros_flavour)
2808 AC_SUBST(aros_flavour_uc)
2809 AC_SUBST(aros_target_toolchain)
2810 AC_SUBST(aros_toolchain_ld)
2811 AC_SUBST(aros_build_host)
2812 AC_SUBST(AROS_BUILDDIR)
2813 AC_SUBST(AROS_BUILDDIR_UNIX)
2814 AC_SUBST(SRCDIR)
2815 AC_SUBST(AROS_CROSSTOOLSDIR)
2816 AC_SUBST(AROS_PORTSSRCDIR)
2818 # Compatability with other Amiga-like operation systems
2819 AC_SUBST(aros_amigaos_compliance)
2821 # Host related
2822 AC_SUBST(aros_cc_pre)
2823 AC_SUBST(aros_host_strip)
2824 AC_SUBST(aros_host_arch)
2825 AC_SUBST(aros_host_cpu)
2826 AC_SUBST(aros_host_cpp)
2827 AC_SUBST(aros_host_def_cc)
2828 AC_SUBST(aros_host_cc)
2829 AC_SUBST(aros_host_cxx)
2830 AC_SUBST(aros_host_ar)
2831 AC_SUBST(aros_host_ranlib)
2832 AC_SUBST(aros_host_ld)
2833 AC_SUBST(aros_host_make)
2834 AC_SUBST(aros_host_cflags)
2835 AC_SUBST(aros_host_cxxflags)
2836 AC_SUBST(gnu89_inline)
2837 AC_SUBST(aros_host_ldflags)
2838 AC_SUBST(aros_host_debug)
2839 AC_SUBST(aros_host_mkdep)
2840 AC_SUBST(aros_host_mkargs)
2841 AC_SUBST(aros_host_exe_suffix)
2842 AC_SUBST(aros_host_lib_suffix)
2843 AC_SUBST(aros_tools_dir)
2844 AC_SUBST(aros_host_aclocal)
2845 AC_SUBST(aros_host_autoconf)
2846 AC_SUBST(aros_host_autoheader)
2847 AC_SUBST(aros_host_automake)
2848 AC_SUBST(ant)
2850 # Target Related
2851 AC_SUBST(aros_target_guitheme)
2852 AC_SUBST(aros_target_iconset)
2853 AC_SUBST(aros_target_bootloader)
2854 AC_SUBST(aros_target_arch)
2855 AC_SUBST(aros_target_family)
2856 AC_SUBST(aros_target_cpu)
2857 AC_SUBST(aros_target_cpu_mode)
2858 AC_SUBST(aros_target_variant)
2859 AC_SUBST(aros_target_suffix)
2860 AC_SUBST(aros_target_ar)
2861 AC_SUBST(aros_target_ranlib)
2862 AC_SUBST(aros_plain_nm)
2863 AC_SUBST(aros_plain_ar)
2864 AC_SUBST(aros_kernel_ar)
2865 AC_SUBST(aros_kernel_ranlib)
2866 AC_SUBST(orig_target_cc)
2867 AC_SUBST(aros_target_cc)
2868 AC_SUBST(aros_kernel_cc)
2869 AC_SUBST(orig_target_cxx)
2870 AC_SUBST(aros_target_cxx)
2871 AC_SUBST(aros_kernel_cxx)
2872 AC_SUBST(orig_target_cpp)
2873 AC_SUBST(aros_target_cpp)
2874 AC_SUBST(aros_kernel_cpp)
2875 AC_SUBST(orig_target_as)
2876 AC_SUBST(aros_target_as)
2877 AC_SUBST(aros_kernel_as)
2878 AC_SUBST(orig_target_ld)
2879 AC_SUBST(aros_target_ld)
2880 AC_SUBST(aros_kernel_ld)
2881 AC_SUBST(aros_target_cc_includes)
2882 AC_SUBST(aros_target_cc_path)
2883 AC_SUBST(aros_target_objdump)
2884 AC_SUBST(aros_target_objcopy)
2885 AC_SUBST(aros_target_strip)
2886 AC_SUBST(aros_target_nm)
2887 AC_SUBST(aros_kernel_rescomp)
2888 AC_SUBST(aros_shared_default)
2889 AC_SUBST(aros_shared_ld)
2890 AC_SUBST(aros_object_format)
2891 AC_SUBST(spec_obj_format)
2892 AC_SUBST(aros_compiler_libs)
2893 AC_SUBST(aros_arch_libs)
2895 AC_SUBST(aros_shared_cflags)
2896 AC_SUBST(aros_shared_aflags)
2897 AC_SUBST(aros_shared_ldflags)
2899 AC_SUBST(aros_config_sysroot)
2900 AC_SUBST(aros_warn_flags)
2901 AC_SUBST(aros_nowarn_flags)
2902 AC_SUBST(aros_config_cflags)
2903 AC_SUBST(aros_config_cxxflags)
2904 AC_SUBST(aros_config_aflags)
2905 AC_SUBST(aros_config_ldflags)
2907 AC_SUBST(aros_kernel_sysroot)
2908 AC_SUBST(aros_kernel_cflags)
2909 AC_SUBST(aros_kernel_includes)
2910 AC_SUBST(aros_kernel_objcflags)
2911 AC_SUBST(aros_kernel_ldflags)
2912 AC_SUBST(aros_target_cflags)
2913 AC_SUBST(aros_debug_cflags)
2914 AC_SUBST(aros_debug_aflags)
2915 AC_SUBST(aros_debug_ldflags)
2916 AC_SUBST(aros_target_genmap)
2917 AC_SUBST(aros_target_strip_flags)
2918 AC_SUBST(aros_config_lto)
2919 AC_SUBST(aros_optimization_cflags)
2920 AC_SUBST(aros_isa_flags)
2922 AC_SUBST(crosstools_target)
2923 AC_SUBST(crosstools_cxx_target)
2925 # Hosted Graphics Related
2926 AC_SUBST(host_x_gfx)
2927 AC_SUBST(host_sdl_gfx)
2928 AC_SUBST(host_android_gfx)
2930 AC_SUBST(pci_hidd_target)
2932 AC_SUBST(aros_nominal_width)
2933 AC_SUBST(aros_nominal_height)
2934 AC_SUBST(aros_nominal_depth)
2935 AC_SUBST(DO_XSHM_SUPPORT)
2936 AC_SUBST(DO_VIDMODE_SUPPORT)
2938 AC_SUBST(aros_host_x11_cflags)
2939 AC_SUBST(aros_host_x11_ldflags)
2940 AC_SUBST(aros_host_sdl_cflags)
2941 AC_SUBST(aros_host_sdl_libs)
2943 # Native version related
2944 AC_SUBST(aros_serial_debug)
2945 AC_SUBST(PLATFORM_EXECSMP)
2946 AC_SUBST(ENABLE_EXECSMP)
2948 # Palm native version related
2949 AC_SUBST(aros_palm_debug_hack)
2951 # Unix/Hosted version related
2952 AC_SUBST(aros_nesting_supervisor)
2954 # MMU related
2955 AC_SUBST(aros_enable_mmu)
2957 # Apple iOS related
2958 AC_SUBST(aros_ios_platform)
2959 AC_SUBST(aros_ios_version)
2960 AC_SUBST(aros_ios_sdk)
2962 # ARM default GCC target related
2963 AC_SUBST(gcc_default_cpu)
2964 AC_SUBST(gcc_default_cpu_tune)
2965 AC_SUBST(gcc_default_fpu)
2966 AC_SUBST(gcc_default_float_abi)
2967 AC_SUBST(gcc_default_mode)
2969 # Android related
2970 AC_SUBST(android_tool)
2971 AC_SUBST(aros_android_level)
2972 AC_SUBST(aros_android_antapk)
2974 # DBUS related
2975 AC_SUBST(ENABLE_DBUS)
2976 AC_SUBST(DBUS_CFLAGS)
2977 AC_SUBST(DBUS_LIBFLAGS)
2978 AC_SUBST(KERNEL_DBUS_KOBJ)
2979 AC_SUBST(KERNEL_DBUS_INCLUDES)
2981 #X11 related
2982 AC_SUBST(ENABLE_X11)
2984 # Debug related
2985 AC_SUBST(aros_debug)
2986 AC_SUBST(aros_mungwall_debug)
2987 AC_SUBST(aros_stack_debug)
2988 AC_SUBST(aros_modules_debug)
2990 # Collect-aros stuff: "-ius" to ignore undefined symbols
2991 AC_SUBST(ignore_undefined_symbols)
2993 # C compiler related
2994 AC_SUBST(gcc_target_cpu)
2995 AC_SUBST(target_binutils_version)
2996 AC_SUBST(target_gcc_version)
2998 #ObjC compiler related
2999 AC_SUBST(objc_target)
3001 #Java related
3002 AC_SUBST(java_target)
3004 # USB3.0 code
3005 AC_SUBST(aros_usb30_code)
3007 dnl Prepare for output, make up all the generated patches
3008 case "$aros_flavour" in
3009 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3010                 aros_flavour="emulation" ;;
3011 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3012                 aros_flavour="emulation" ;;
3013 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3014                 aros_flavour="standalone";;
3015 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3016                 aros_flavour="standalone";;
3017 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3018                 aros_flavour="native" ;;
3019 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3020                 aros_flavour="native" ;;
3021 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3022                 aros_flavour="linklib" ;;
3023 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3024                 aros_flavour="palmnative" ;;
3025 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3026                 aros_flavour="mac68knative" ;;
3027 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3028                 aros_flavour="ppcnative" ;;
3029 esac
3031 if test ! -d ${aros_inc_dir} ; then
3032     ${MKDIR} ${aros_inc_dir}
3034 if test ! -d ${aros_geninc_dir} ; then
3035     ${MKDIR} ${aros_geninc_dir}
3037 if test ! -d ${aros_hostcfg_dir} ; then
3038     ${MKDIR} ${aros_hostcfg_dir}
3040 if test ! -d ${aros_targetcfg_dir} ; then
3041     ${MKDIR} ${aros_targetcfg_dir}
3043 if test ! -d ${aros_tools_dir} ; then
3044     ${MKDIR} ${aros_tools_dir}
3046 if test ! -d ${aros_scripts_dir} ; then
3047     ${MKDIR} ${aros_scripts_dir}
3050 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3052 # Generic build tools (metamake, etc)
3053 AC_CONFIG_COMMANDS([genmf-executable-support],
3054     [chmod a+x ${aros_tools_dir}/genmf.py],
3055     [aros_tools_dir=${aros_tools_dir}]
3057 AC_CONFIG_FILES(
3058     Makefile
3059     config/make.cfg
3060     ${aros_inc_dir}/config.h:config/config.h.in
3061     ${aros_geninc_dir}/config.h:config/config.h.in
3062     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3063     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3064     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3065     mmake.config
3066     compiler/include/mmakefile:compiler/include/mmakefile.in
3067     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3068     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3069     tools/collect-aros/env.h
3072 # Binutils
3073 AC_CONFIG_COMMANDS([binutils-support],
3074     [
3075         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3076         mkdir -p $prefix
3077         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3079         chmod a+x ${prefix2}-ld
3081         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3082         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3083         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3084         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3085         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3086         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3087         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3088     ],
3089     [
3090         aros_host_exe_suffix=${aros_host_exe_suffix}
3091         aros_tools_dir=${aros_tools_dir}
3092         aros_target_cpu=${aros_target_cpu}
3093         aros_target_arch=${aros_target_arch}
3094         aros_target_suffix=${aros_target_suffix}
3095         orig_target_nm=${orig_target_nm}
3096         orig_target_as=${orig_target_as}
3097         orig_target_ar=${orig_target_ar}
3098         orig_target_ranlib=${orig_target_ranlib}
3099         orig_target_objdump=${orig_target_objdump}
3100         orig_target_objcopy=${orig_target_objcopy}
3101         orig_target_strip=${orig_target_strip}
3102         aros_kernel_ld=${aros_kernel_ld}
3103     ]
3105 if test "${use_ld_wrapper}" = "yes"; then
3106     AC_CONFIG_FILES(
3107         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3108     )
3110 # Bare Elf support script and spec
3111 if test "${use_kernel_cc_wrapper}" = "yes"; then
3112     AC_CONFIG_COMMANDS([elf-compiler-support],
3113         [
3114             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3115             mkdir -p $prefix
3116             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3118             chmod a+x ${prefix2}-gcc
3120             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3121         ],
3122         [
3123             aros_host_exe_suffix=${aros_host_exe_suffix}
3124             aros_tools_dir=${aros_tools_dir}
3125             aros_target_cpu=${aros_target_cpu}
3126             aros_target_arch=${aros_target_arch}
3127             aros_target_suffix=${aros_target_suffix}
3128             aros_kernel_ld=${aros_kernel_ld}
3129         ]
3130     )
3131     AC_CONFIG_FILES(
3132         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3133         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3134     )
3137 # Host compiler support scripts and spec
3138 if test "${aros_target_toolchain}" = "no"; then
3139     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3140         [
3141             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3142             mkdir -p $prefix
3143             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3145             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3146         ],
3147         [
3148             aros_host_exe_suffix=${aros_host_exe_suffix}
3149             aros_tools_dir=${aros_tools_dir}
3150             aros_target_cpu=${aros_target_cpu}
3151             aros_target_arch=${aros_target_arch}
3152             aros_target_suffix=${aros_target_suffix}
3153         ]
3154     )
3155     AC_CONFIG_FILES(
3156         ${aros_targetcfg_dir}/specs:config/specs.in
3157         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3158         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3159         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3160     )
3163 # Android support
3164 if test "$aros_target_variant" == "android"; then
3165     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3168 # cmake helper
3169 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3171 AC_OUTPUT
3173 dnl This is in order to not define SHARED_CFLAGS sometimes
3174 dnl We don't always do aros_shared_ar, aros_shared_cflags
3176 #XXX compatability...
3177 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3179 if test -n "$aros_shared_cflags" ; then
3180     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3181     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg