use the toolchain names for the commands
[AROS.git] / configure.in
blobd066a90fbf06b52bf0c4bd62aa69819dba3d6aa5
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_toolchain_family=`cat ${srcdir}/config/toolchain_def`
27 default_gcc_version=`cat ${srcdir}/config/gcc_def`
28 exp_gcc_version=`cat ${srcdir}/config/gcc_exp`
29 default_binutils_version=`cat ${srcdir}/config/binutils_def`
30 exp_binutils_version=`cat ${srcdir}/config/binutils_exp`
31 default_grub2_version="2.02"
32 target_grub2_version=$default_grub2_version
34 # The AROS target is slightly different to the normal GNU style
35 # format. We don't have the middle part, and we reverse the order
36 # of the $(CPU) and $(OS) bits.
38 # Don't strip the version of the target yet, it might be
39 # useful on some systems.
41 AC_MSG_CHECKING([for AROS style target])
43 if test "$target" = "NONE" ; then
44     target=$host_os-$host_cpu
45 else
46     if test "$target" = "" ; then
47         target=$host_os-$host_cpu
48     fi
50 AC_MSG_RESULT($target)
52 if test "$host_os" = "mingw32" ; then
53     PWDCMD="pwd -W"
56 # Don't know where else to put this...
57 AC_MSG_CHECKING([building AROS in])
58 AROS_BUILDDIR=`${PWDCMD-pwd}`
59 AROS_BUILDDIR_UNIX=${PWD}
60 AC_MSG_RESULT($AROS_BUILDDIR)
62 AC_MSG_CHECKING([AROS source in])
63 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
64 SRCDIR=${srcpwd}
65 AC_MSG_RESULT($SRCDIR)
67 # Parse the target field into something useful.
68 changequote(<<,>>)
69 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
70 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
71 changequote([,])
73 # Some debug output, to be removed again.
74 AC_MSG_CHECKING([for target system (debug output)])
75 AC_MSG_RESULT($target_os)
76 AC_MSG_CHECKING([for target cpu (debug output)])
77 AC_MSG_RESULT($target_cpu)
79 dnl --------------------------------------------------------------------
80 dnl Set the default Workbench resolution
81 dnl --------------------------------------------------------------------
82 aros_nominal_width=800
83 aros_nominal_height=600
84 aros_nominal_depth=4
86 dnl --------------------------------------------------------------------
87 dnl Host Configuration Section
88 dnl --------------------------------------------------------------------
89 dnl
90 dnl The idea here is to find out all the information we need about the
91 dnl host. This means things like tools for building directory structures,
92 dnl copying files around and the like.
94 default_c_compilers="gcc clang cc"
95 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="")
96 if test "$use_c_compiler" = ""; then
97     host_c_compilers="$default_c_compilers"
98 else
99     host_c_compilers="$use_c_compiler"
100     CC=$use_c_compiler
103 default_cxx_compilers="g++ clang++ c++"
104 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="")
105 if test "$use_cxx_compiler" = ""; then
106         host_cxx_compilers="$default_cxx_compilers"
107 else
108     host_cxx_compilers="$use_cxx_compiler"
109     CXX=$use_cxx_compiler
113 # The first step is to find the host binaries.
114 # Check for a compiler.
115 # Due to a bug in autoconf check for c++ compiler first.
116 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
117 AC_PROG_CXX([${host_cxx_compilers}])
118 CXX_BASE=$CXX
119 AC_PATH_PROG(CXX,$CXX)
120 AC_PROG_CC([${host_c_compilers}])
121 CC_BASE=$CC
122 AC_PATH_PROG(CC,$CC)
123 aros_host_def_cc="$CC"
124 AC_PROG_CC_STDC
125 AC_PROG_CPP
127 # detect the compiler version
128 AC_MSG_CHECKING([which toolchain family ${CC} belongs to])
129 HOST_COMPILER_VERSION=`"$CC" --version 2>/dev/null`
130 if test x"$HOST_COMPILER_VERSION" = "x"; then
131     HOST_COMPILER_VERSION=`"$CC" --qversion 2>/dev/null`
133 if test x"$HOST_COMPILER_VERSION" = "x"; then
134     HOST_COMPILER_VERSION=`"$CC" -V 2>/dev/null`
137 IS_SUN_COMPILER=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'Sun C\+\+'`
138 if test "$IS_SUN_COMPILER" -ne "0"; then
139     HOST_TOOLCHAIN_PREFIX=
140     HOST_TOOLCHAIN_SUFFIX=
141     HOST_TOOLCHAIN_FAMILY=sun
143 IS_LLVM_COMPILER=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'LLVM|clang'`
144 if test "$IS_LLVM_COMPILER" -ne "0"; then
145     if test "$CC_BASE" != "gcc"; then
146         HOST_TOOLCHAIN_PREFIX=llvm-
147         HOST_TOOLCHAIN_SUFFIX="`echo $CC_BASE | sed -e \"s|clang||g\"`"
148         HOST_TOOLCHAIN_FAMILY=llvm
149     else
150         IS_GNU_COMPILER=1
151     fi
153 IS_GNU_COMPILER?=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'gcc'`
154 if test "$IS_GNU_COMPILER" -ne "0"; then
155     HOST_TOOLCHAIN_PREFIX=
156     HOST_TOOLCHAIN_SUFFIX=
157     HOST_TOOLCHAIN_FAMILY=gnu
159 if test x"$HOST_TOOLCHAIN_FAMILY" = "x"; then
160     HOST_TOOLCHAIN_FAMILY=unknown
162 AC_MSG_RESULT($HOST_TOOLCHAIN_FAMILY)
164 # Check for a compatible awk
165 AC_CHECK_PROGS(AWK,[gawk nawk])
166 AROS_REQUIRED(gawk,$AWK)
167 AROS_PROG(MMAKE,mmake)
169 # Perform some default variable assignments. Note all of these will be
170 # Regenerated from the script, so there is no need to cache them.
172 aros_build_host=$host
173 aros_host_cpp="$CPP"
174 aros_host_cc="$CC"
175 aros_host_cxx="$CXX"
176 base_ld_name=${HOST_TOOLCHAIN_PREFIX}ld${HOST_TOOLCHAIN_SUFFIX}
177 if test "$HOST_TOOLCHAIN_FAMILY" = "llvm"; then
178     AC_CHECK_PROGS(base_lld_name,[$base_ld_name ld.lld${HOST_TOOLCHAIN_SUFFIX} ld64.lld${HOST_TOOLCHAIN_SUFFIX} ld-link${HOST_TOOLCHAIN_SUFFIX}.exe ld${HOST_TOOLCHAIN_SUFFIX}])
179     base_ld_name=$base_lld_name
181 AROS_TOOL_CCPATH(aros_host_ld,ld,$base_ld_name)
182 AROS_REQUIRED(ld,$aros_host_ld)
183 aros_host_make="make"
184 aros_host_cflags="$CFLAGS"
185 aros_host_cxxflags="$CXXFLAGS"
186 aros_host_cppflags="$CPPFLAGS"
187 aros_host_ldflags="$LDFLAGS"
188 aros_host_debug="-g -O0"
189 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
190 aros_host_mkargs="--no-print-directory"
191 aros_host_exe_suffix="$EXEEXT"
192 aros_host_lib_suffix=""
194 # Ignore all compliance, AROS ROMs = 0
195 # KickStart v1.0 = 30
196 # KickStart v1.3 = 34
197 # KickStart v2.0 = 37
198 # KickStart v3.0 = 39
199 # KickStart v3.1 = 40
200 # AmigaOS   v3.5 = 44
201 aros_amigaos_compliance=0
203 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
204 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
205 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
206 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
208 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
209 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
211 case "$aros_host_cc" in
212     *clang*)
213         aros_host_cc_pipe=""
214         ;;
215     *gcc*)
216         aros_host_cc_pipe="-pipe"
217         ;;
218     icc)
219         aros_host_cc_pipe=""
220         ;;
221     *)
222         aros_host_cc_pipe=""
223         ;;
224 esac
226 aros_kernel_cc_includes=""
227 aros_target_cc_includes=""
228 host_cc_elf=yes
230 # ----------------------------------------------------------------------------------------
231 # Host-specific defaults
233 # This is the main host configuration section. It is where the host
234 # can change the values of any variables it needs to change. We do
235 # not look at anything that compiles to the target yet, we'll get
236 # to that later.
238 case "$host_os" in
239     aros*)
240         aros_host_arch="aros"
241         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
242         case "$host_cpu" in
243             *i?86*)
244                 aros_host_cpu="i386"
245                 ;;
246             *x86_64*)
247                 aros_host_cpu="x86_64"
248                 ;;
249             *powerpc*)
250                 aros_host_cpu="ppc"
251                 ;;
252             *)
253                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
254                 aros_host_cpu="$host_cpu"
255                 ;;
256         esac
257         ;;
259     linux*)
260         aros_host_arch="linux"
261         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
262         android_build_os="linux-x86"
263         android_tool="android"
264         default_android_sdk="/opt/android-sdk-linux_x86"
265         case "$host_cpu" in
266             *i?86*)
267                 aros_host_cpu="i386"
268                 ;;
269             *x86_64*)
270                 aros_host_cpu="x86_64"
271                 ;;
272             *m68k*)
273                 aros_host_cpu="m68k"
274                 ;;
275             *powerpc*)
276                 aros_host_cpu="ppc"
277                 ;;
278             *arm*)
279                 aros_host_cpu="arm"
280                 ;;
281             *)
282                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
283                 aros_host_cpu="$host_cpu"
284                 ;;
285         esac
286         ;;
288     freebsd*)
289         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe -I/usr/local/include"
290         aros_host_make="gmake"
291         aros_host_arch="freebsd"
292         aros_host_cpu="i386"
294         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
296         dnl FreeBSD 5.x (and later) has changed the default object format.
297         dnl The double [[]] is necessary to get around m4's quoting rules.
298         case $host_os in
299             freebsd[[234]]*)
300                 aros_object_format="elf_i386"
301                 ;;
303             *)
304                 aros_object_format="elf_i386_fbsd"
305                 ;;
306         esac
308         ;;
310     darwin*)
311         AC_MSG_CHECKING([for macOS SDK files])
312         LOC=$( xcode-select -p )
313         AS_IF([ test $? != 0],[AC_MSG_ERROR([XCode incorrectly configured!
314 please run 'xcode-select --install' before
315 re-running configure])])
316         AC_MSG_RESULT($LOC)
317         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
318         aros_host_arch="darwin"
319         host_cc_elf=no
320         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
321         android_build_os="darwin-x86"
322         android_tool="android"
323         default_android_sdk="/android-sdk-mac_x86"
324         case "$host_cpu" in
325             *i?86*)
326                 aros_host_cpu="i386"
327                 ;;
328             *x86_64*)
329                 aros_host_cpu="x86_64"
330                 ;;
331             *powerpc*)
332                 aros_host_cpu="ppc"
333                 ;;
334             *)
335                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
336                 aros_host_cpu="$host_cpu"
337                 ;;
338         esac
340         aros_host_ldflags="$aros_host_ldflags -liconv"
342         ;;
344     dragonfly*)
345         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
346         aros_host_make="gmake"
347         aros_host_arch="dragonfly"
348         case $host_cpu in
349             *i?86*)
350                 aros_host_cpu="i386"
351                 ;;
352             *amd64*)
353                 aros_host_cpu="x86_64"
354                 ;;
355             *)
356                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
357                 aros_host_cpu="$host_cpu"
358                 ;;
359         esac
360         ;;
362     netbsd*)
363         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
364         aros_host_make="gmake"
365         aros_host_arch="netbsd"
366         case "$host_cpu" in
367             *i?86*)
368                 aros_host_cpu="i386"
369                 ;;
370             *m68k*)
371                 aros_host_cpu="m68k"
372                 ;;
373             *)
374                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
375                 aros_host_cpu="$host_cpu"
376                 ;;
377         esac    
378         aros_host_lib_suffix=".0.0"
379         ;;
381     openbsd*)
382         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
383         aros_host_make="gmake"
384         aros_host_arch="openbsd"
385         case "$host_cpu" in
386             *i?86*)
387                 aros_host_cpu="i386"
388                 ;;
389             *)
390                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
391                 aros_host_cpu="$host_cpu"
392                 ;;
393         esac
394         ;;
395         
396     solaris*)
397         aros_host_arch="solaris"
398         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
399         case "$host_cpu" in
400             *i?86*)
401                 aros_host_cpu="i386"
402                 ;;
403             *sparc*)
404                 aros_host_cpu="sparc"
405                 ;;
406             *)
407                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
408                 aros_host_cpu="$host_cpu"
409                 ;;
410         esac
411         ;;
413     morphos*)
414         aros_host_arch="morphos"
415         aros_host_cpu="ppc"
416         host_cc_elf=no
417         ;;
419     amiga*)
420         aros_host_arch="amiga"
421         host_cc_elf=no
422         SORT="/gg/bin/sort"
423         TEST="/gg/bin/test"
424         UNIQ="/gg/bin/uniq"
425         FOR="for"
426         TOUCH="/gg/bin/touch"
427         case "$host_cpu" in
428             *m68k*)
429                 aros_host_cpu="m68k"
430                 ;;
431             *powerpc*)
432                 aros_host_cpu="ppc"
433                 ;;
434             *)
435                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
436                 aros_host_cpu="$host_cpu"
437                 ;;
438         esac
439         ;;
441     cygwin*)
442         aros_host_arch="cygwin"
443         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
444         host_cc_elf=no
445         android_build_os="windows"
446         android_tool="android.bat"
447         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
449         case "$host_cpu" in
450             *i?86*)
451                 aros_host_cpu="i386"
452                 ;;
453             *)
454                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
455                 aros_host_cpu="$host_cpu"
456                 ;;
457         esac
458         ;;
460     mingw32*)
461         aros_host_arch="mingw32"
462         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
463         host_cc_elf=no
464         android_build_os="windows"
465         android_tool="android.bat"
466         default_android_sdk="/c/android-sdk-windows-1.6_r1"
468         libpng_libextra="-lws2_32"
470         case "$host_cpu" in
471         *i?86*)
472             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
473             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
474             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
475             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
477             AC_MSG_CHECKING([for Windows native gcc target])
478             host_cpu=`gcc -dumpmachine`
479             AC_MSG_RESULT($host_cpu)
480             ;;
482         esac
484         case "$host_cpu" in
485         *i?86*)
486             aros_host_cpu="i386"
487             ;;
489         mingw32*)
490             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
491             aros_host_cpu="i386"
492             ;;
494         *x86_64*)
495             aros_host_cpu="x86_64"
496             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
497             dnl directory, so we have to add it explicitly here.
498             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
499             ;;
501         *)
502             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
503             aros_host_cpu="$host_cpu"
504             ;;
505         esac
506         ;;
507     *)
508         AC_MSG_ERROR([Unsupported host architecture $host])
509         ;;
510 esac
512 base_ar_name=${HOST_TOOLCHAIN_PREFIX}ar${HOST_TOOLCHAIN_SUFFIX}
513 AROS_PROG(aros_host_cmd_ar,$base_ar_name,[cr])
514 AROS_PATH_PROG(aros_host_full_ar,$aros_host_cmd_ar)
515 aros_host_ar=`echo $aros_host_cmd_ar | sed -e "s|$base_ar_name|$aros_host_full_ar|g"`
516 AROS_REQUIRED(ar,$aros_host_ar)
517 base_ranlib_name=${HOST_TOOLCHAIN_PREFIX}ranlib${HOST_TOOLCHAIN_SUFFIX}
518 AROS_PATH_PROG(aros_host_ranlib,$base_ranlib_name)
519 AROS_REQUIRED(ranlib,$aros_host_ranlib)
520 AROS_PROG(aros_host_strip,strip)
521 AROS_REQUIRED(strip,$aros_host_strip)
523 AROS_PROG(RM,[rm],[-rf])
524 AROS_REQUIRED(rm,$RM)
525 AROS_PROG(CP,[cp])
526 AROS_REQUIRED(cp,$CP)
527 AROS_PROG(MV,[mv])
528 AROS_REQUIRED(mv,$MV)
529 AROS_PROG(ECHO,[echo])
530 AROS_REQUIRED(echo,$ECHO)
531 AROS_PROG(MKDIR,[mkdir],[-p])
532 AROS_REQUIRED(mkdir,$MKDIR)
533 AROS_PROG(TOUCH,[touch])
534 AROS_REQUIRED(touch,$TOUCH)
535 AROS_PROG(SORT,[sort])
536 AROS_REQUIRED(sort,$SORT)
537 AROS_PROG(UNIQ,[uniq])
538 AROS_REQUIRED(uniq,$UNIQ)
539 AROS_PROG(NOP,[true])
540 AROS_REQUIRED(true,$NOP)
541 AROS_PROG(CAT,[cat])
542 AROS_REQUIRED(cat,$CAT)
543 AROS_PROG(BISON,[bison])
544 AROS_REQUIRED(bison,$BISON)
545 AROS_PROG(FLEX,[flex])
546 AROS_REQUIRED(flex,$FLEX)
547 AC_MSG_CHECKING([version of $FLEX])
548 ax_cv_flex_version="`$FLEX --version | cut -d\" \" -f2`"
549 AC_MSG_RESULT($ax_cv_flex_version)
550 AROS_PROG(PNGTOPNM,[pngtopnm])
551 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
552 AROS_PROG(PPMTOILBM,[ppmtoilbm])
553 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
554 AROS_PROG(SED,[sed])
555 AROS_REQUIRED(sed,$SED)
556 AROS_PROG(CHMOD,[chmod])
557 AROS_REQUIRED(chmod,$CHMOD)
558 AROS_PROG(PATCH,[patch])
559 AROS_REQUIRED(patch,$PATCH)
561 AM_PATH_PYTHON(2.5)
563 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
564 if test "$enable_libpng_config" != "no"; then
565   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
567 if test "$arosconfig_use_libpngconfig" = "yes"; then
568     AC_MSG_CHECKING([libpng-config library])
569     libpng_incdir="`libpng-config --cflags`"
570     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
571     libpng="`libpng-config --libs`"
572     AC_MSG_RESULT($libpng)
573 else
574     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
575     if test "$libpng_libextra" != ""; then
576         if test "$libpng" != "no"; then
577             libpng_libextra="$libpng_libextra $libpng"
578         fi
579     fi
581 AROS_REQUIRED(libpng, $libpng)
582 AC_SUBST(libpng)
583 AC_SUBST(libpng_libextra)
584 AC_SUBST(libpng_incdir)
586 AC_SUBST(FOR, for)
587 AC_SUBST(IF, if)
588 AC_SUBST(TEST, test)
589 AC_SUBST(CMP, cmp)
591 dnl ---------------------------------------------------------------------------
592 dnl Look for things about the host system, good for hosted targets.
593 dnl ---------------------------------------------------------------------------
595 # Check for some includes for the X11 HIDD and the kernel
596 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
597     sys/mmap.h sys/mman.h sysexits.h \
598     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
601 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
602 AC_CHECK_HEADERS([GL/glx.h],[host_feature_glx=yes],[host_feature_glx=no],)
604 AC_MSG_CHECKING([if __unused conflicts with sys/stat.h])
605 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
606      [[
607      #define __unused __attribute__((unused))
608      #include <sys/stat.h>
609      ]])],
610      [host_stat_h__unused_used=no],
611      [host_stat_h__unused_used=yes])
612 AC_MSG_RESULT($host_stat_h__unused_used)
614 AC_HEADER_DIRENT
615 AC_HEADER_STAT
616 AC_HEADER_STDC
617 AC_HEADER_SYS_WAIT
618 AC_HEADER_TIME
619 AC_STRUCT_ST_BLKSIZE
620 AC_STRUCT_ST_BLOCKS
621 AC_STRUCT_ST_RDEV
622 AC_STRUCT_TM
623 AC_STRUCT_TIMEZONE
624 AC_TYPE_OFF_T
625 AC_TYPE_PID_T
626 AC_TYPE_SIZE_T
627 AC_TYPE_UID_T
629 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
631 # Look for some functions
632 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
633     clone kse_create rfork_thread thr_create sa_register \
634     getcontext makecontext setcontext sigaltstack swapcontext])
636 AC_FUNC_MMAP
638 #-----------------------------------------------------------------------------
641 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
642 # it switched on by default, and we use the host compiler, so it compiles AROS
643 # code with this enabled resulting in link failures as we don't have support
644 # for it.
646 # We use two methods to disable it. For the host compiler (used to compile
647 # some hosted modules), we test to see if the compiler supports stack
648 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
649 # work on all platforms.
652 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
653 save_cflags="$CFLAGS"
654 CFLAGS="$CFLAGS -fno-stack-protector"
655 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
656 AC_MSG_RESULT($use_no_stack_protector)
657 if test "x-$use_no_stack_protector" = "x-yes" ; then
658     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
660 CFLAGS="$save_cflags"
662 #-----------------------------------------------------------------------------
664 # Disable pointer-signedness warnings if the compiler recognises the option
665 # (this only works for the host compiler at the moment)
667 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
668 save_cflags="$CFLAGS"
669 CFLAGS="$CFLAGS -Wno-pointer-sign"
670 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
671 AC_MSG_RESULT($use_no_sign_warning)
672 if test "x-$use_no_sign_warning" = "x-yes" ; then
673     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
675 CFLAGS="$save_cflags"
677 #-----------------------------------------------------------------------------
679 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
681 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
682 save_cflags="$CFLAGS"
683 CFLAGS="$CFLAGS -fgnu89-inline"
684 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
685 AC_MSG_RESULT($use_gnu89_inline)
686 if test "x-$use_gnu89_inline" = "x-yes" ; then
687     gnu89_inline="-fgnu89-inline"
689 CFLAGS="$save_cflags"
692 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
693 # On GCC >= 4.0 -iquote should be used
695 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
696 CFLAGS="$CFLAGS -iquote."
697 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
698 AC_MSG_RESULT($has_iquote)
699 if test "x-$has_iquote" = "x-yes" ; then
700     host_cflags_iquote=-iquote
701     host_cflags_iquote_end=
702 else
703     host_cflags_iquote=-I
704     host_cflags_iquote_end=-I-
707 AC_MSG_NOTICE([Performing target configuration...])
709 dnl --------------------------------------------------------------------
710 dnl Target Configuration Section
711 dnl --------------------------------------------------------------------
713 dnl The target configuration section is responsible for setting up all
714 dnl the paths for includes, and tools required to build AROS to some
715 dnl particular target.
717 test_kernel_cc=no
719 aros_nowarn_flags="NOWARN_UNUSED_COMMAND_LINE_ARGUMENT NOWARN_UNKNOWN_WARNING_OPTION NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
720 export_newline="
723 aros_elf_translate=
724 aros_warn_flags=
725 aros_isa_extra=
726 aros_isa_flags=
727 aros_config_cppflags=
728 aros_config_cflags=
729 aros_config_cxxflags=
730 aros_config_aflags="$""(WARN_ALL) -x assembler-with-cpp -c"
731 aros_config_ldflags=""
733 aros_shared_default=yes
735 aros_shared_cflags="-fPIC"
736 aros_shared_aflags=""
737 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
738 aros_kernel_ldflags="-Wl,-rpath,./lib"
740 aros_kernel_ar_flags="cr"
741 aros_target_ar_flags="cr"
742 aros_target_nm_flags="-C -ul"
743 aros_target_strip_flags="--strip-unneeded -R.comment"
745 aros_c_libs=
746 aros_cxx_libs=
748 aros_target_genmap="-Wl,-Map -Xlinker"
750 # Native flavour stuff
751 aros_serial_debug="0"
753 # Palm native flavour stuff
754 aros_palm_debug_hack="0"
756 # Unix flavour stuff
757 aros_nesting_supervisor="0"
759 # Collect-aros stuff: "-ius" to ignore undefined symbols
760 ignore_undefined_symbols=""
762 # Check for X11 by default
763 need_x11="auto"
765 AC_MSG_CHECKING([Which toolchain family to use ...])
766 AC_ARG_WITH(toolchain,AC_HELP_STRING([--with-toolchain=family],[Which toolchain family to crosscompile with (defaults to gnu)]),aros_toolchain="$withval",aros_toolchain="$default_toolchain_family")
767 AC_MSG_RESULT($aros_toolchain)
770 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
771 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
772  aros_config_lto="$enableval",aros_config_lto="no")
773 if test "$aros_config_lto" != "no"; then
774     aros_config_lto="yes"
776 AC_MSG_RESULT($aros_config_lto)
778 AC_MSG_CHECKING([if we should enable coverage instrumentation])
779 AC_ARG_ENABLE(coverage,AC_HELP_STRING([--enable-coverage=[yes|no]],[Enable coverage instrumentation if the target compiler supports it (default=no)]),
780  aros_config_coverage="$enableval",aros_config_coverage="no")
781 if test "$aros_config_coverage" != "no"; then
782     aros_config_coverage="yes"
784 AC_MSG_RESULT($aros_config_coverage)
786 use_ld_wrapper=yes
788 case "$aros_toolchain" in
789     *llvm*)
790         toolchain_c_compiler="clang"
791         toolchain_cxx_compiler="clang++"
792         toolchain_cpp_preprocessor="clang -E"
793         toolchain_ld="ld.lld"
794         aros_ld="ld"
795         toolchain_as="llvm-as"
796         toolchain_ar="llvm-ar"
797         toolchain_ranlib="llvm-ranlib"
798         toolchain_nm="llvm-nm"
799         toolchain_strip="true"
800         toolchain_objcopy="llvm-objcopy"
801         toolchain_objdump="llvm-objdump"
802         use_libatomic=yes
803         ;;
804     *gnu*)
805         toolchain_c_compiler="gcc"
806         toolchain_cxx_compiler="g++"
807         toolchain_cpp_preprocessor="gcc -E"
808         toolchain_as="as"
809         aros_ld="ld"
810         if test "$aros_config_lto" != "yes"; then
811             toolchain_ld="ld"
812             toolchain_ar="ar"
813             toolchain_ranlib="ranlib"
814             toolchain_nm="nm"
815         else
816             toolchain_ld="ld.bfd"
817             toolchain_ar="gcc-ar"
818             toolchain_ranlib="gcc-ranlib"
819             toolchain_nm="gcc-nm"
820         fi
821         toolchain_strip="strip"
822         toolchain_objcopy="objcopy"
823         toolchain_objdump="objdump"
824         use_libatomic=yes
825         ;;
826     *)
827         AC_MSG_WARN("Unknown toolchain family!")
828         toolchain_c_compiler="cc"
829         toolchain_cxx_compiler="c++"
830         toolchain_cpp_preprocessor="cpp"
831         toolchain_ld="ld"
832         aros_ld="ld"
833         toolchain_as="as"
834         toolchain_ar="ar"
835         toolchain_ranlib="ranlib"
836         toolchain_nm="nm"
837         toolchain_strip="strip"
838         toolchain_objcopy="objcopy"
839         toolchain_objdump="objdump"
840         ;;
841 esac
843 #-----------------------------------------------------------------------------
845 AC_MSG_CHECKING([which type of build to do])
846 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")
848 if test "$build_type" = "nightly"; then
849     build_type_string="NIGHTLY"
850 elif test "$build_type" = "snapshot"; then
851     build_type_string="SNAPSHOT"
852 elif test "$build_type" = "milestone"; then
853     build_type_string="MILESTONE"
854 elif test "$build_type" = "release"; then
855     build_type_string="RELEASE"
856 else
857     build_type_string="PERSONAL"
858     build_type="personal"
861 aros_config_cppflags="$aros_config_cppflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
863 AC_MSG_RESULT($build_type)
865 #-----------------------------------------------------------------------------
866 all_debug_types="messages stack modules mungwall symbols"
868 AC_MSG_CHECKING([which debug types to enable])
869 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)]),
870  debug="$enableval",debug="")
872 if test "$debug" = "" -o "$debug" = "no"; then
873     debug="none"
874 elif test "$debug" = "yes"; then
875     debug="all"
878 if test "$debug" = "all" ; then
879     debug="messages stack modules symbols"
880     for d in $all_debug_types; do
881         export aros_${d}_debug="1"
882     done
883 else
884     for d in $all_debug_types; do
885         export aros_${d}_debug="0"
886     done
889 if test "$debug" != "none"; then
890     debug=`echo $debug | sed s/,/\ /g`
891     for d in $debug; do
892         found="0"
893         for d2 in $all_debug_types; do
894             if test "$d2" = "$d"; then
895                 found="1"
896                 break
897             fi
898         done
899         if test "$found" = "0"; then
900             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
901         fi
902         export aros_${d}_debug="1"
903     done
904     aros_debug="yes"
906 AC_MSG_RESULT($debug)
908 if test "$aros_messages_debug" = "1"; then
909     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
910 else
911     aros_messages_debug=""
913 if test "$aros_symbols_debug" = "1"; then
914     aros_symbols_debug="-g"
915 else
916     aros_symbols_debug=""
919 # These are the flags to pass when compiling debugged programs
920 aros_debug_cppflags="$aros_messages_debug"
921 aros_debug_cflags="$aros_symbols_debug"
922 aros_debug_cxxflags=
923 aros_debug_aflags=""
924 aros_debug_ldflags="$aros_symbols_debug"
926 #-----------------------------------------------------------------------------
927 #   Checking for distcc and ccache.
929 #   Always apply the transforms in this particular order. Basically you should
930 #   always run 'ccache distcc compiler' in that order for the best performance.
932 AC_MSG_CHECKING([whether to enable distcc])
933 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
934 if test "$distcc" != "" -a "$distcc" != "no"; then
935     # AC_CHECK_PROG will print out the result in this case
936     AC_PATH_PROG(DISTCC,[distcc],distcc,)
937 else
938     AC_MSG_RESULT(no)
941 AC_MSG_CHECKING([whether to enable ccache])
942 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
943 if test "$ccache" != "" -a "$ccache" != "no"; then
944     # AC_CHECK_PROG will print out the result in this case
945     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
946 else
947     AC_MSG_RESULT(no)
950 #-----------------------------------------------------------------------------
951 AC_MSG_CHECKING([what specific host gcc version to use])
952 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="")
953 if test "$kernel_tool_version" != "" ; then
954     msg_result=$kernel_tool_version
955 else
956     msg_result="default"
958 AC_MSG_RESULT($msg_result)
960 #-----------------------------------------------------------------------------
961 AC_MSG_CHECKING([what optimization flags to use])
962 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (e.g --with-optimization=-O2).]),optimization_level="$withval",optimization_level="unknown")
963 if test "$optimization_level" = "unknown"; then
964     dnl default is -O2 for normal builds, -O0 for debug builds
965     optimization="default"
966     if test "$debug" != "none"; then
967         optimization_level="-O0"
968     else
969         optimization_level="-O2"
970     fi
971 else
972     optimization="$optimization_level"
974 AC_MSG_RESULT($optimization)
976 paranoia_default=yes
977 #-----------------------------------------------------------------------------
978 AC_MSG_CHECKING([which paranoia flags to use])
979 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"])
980 if test "$paranoia_flags" = "no"; then
981         paranoia_flags="$""(WARN_ALL) -Werror-implicit-function-declaration"
982         msg_result="none"
983 else
984     if test "$paranoia_flags" = "yes"; then
985         paranoia_flags="$""(WARN_ALL) $""(WARN_ERROR)"
986     fi
987     msg_result="$paranoia_flags"
989 AC_MSG_RESULT($msg_result)
990 aros_warn_flags="$aros_warn_flags $paranoia_flags"
992 #-----------------------------------------------------------------------------
993 AC_MSG_CHECKING([what target variant to enable])
994 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
995 if test "$target_variant" = ""; then
996     aros_target_variant=""
997     aros_target_suffix=""
998     enableval="none"
999 else
1000     aros_target_variant="$target_variant"
1001     aros_target_suffix="-$target_variant"
1003 AC_MSG_RESULT($enableval)
1005 #-----------------------------------------------------------------------------
1006 # Target-specific defaults. You can override then on a per-target basis.
1008 # Bootloader name. Currently used by PC target.
1009 target_bootloader="none"
1010 PLATFORM_EXECSMP=
1011 ENABLE_EXECSMP=
1013 #-----------------------------------------------------------------------------
1014 # Additional options for some specific targets
1016 case "$aros_target_variant" in
1017 ios)
1018     AC_MSG_CHECKING([XCode path])
1019     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")
1020     AC_MSG_RESULT($aros_xcode_path)
1022     AC_MSG_CHECKING([what iOS SDK version to use])
1023     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")
1024     AC_MSG_RESULT($aros_sdk_version)
1026     ;;
1028 "android")
1029     AC_MSG_CHECKING([Android SDK path])
1030     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)
1031     AC_MSG_RESULT($aros_android_sdk)
1033     AC_MSG_CHECKING([Android NDK path])
1034     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
1035     AC_MSG_RESULT($aros_android_ndk)
1037     AC_MSG_CHECKING([what Android SDK version to use])
1038     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")
1039     AC_MSG_RESULT($aros_sdk_version)
1041     aros_android_level=android-$aros_sdk_version
1042     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
1043         echo "Platform $aros_android_level is not installed in your SDK"
1044         echo "Use --with-sdk-version=<API level number> to select another platform version"
1045         echo "You can check what plaform versions are installed in your SDK"
1046         echo "by examining contents of $aros_android_sdk/platforms directory"
1047         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
1048     fi
1050     export PATH="$aros_android_sdk/tools:$PATH"
1051     AC_PATH_PROG(android_tool, $android_tool)
1052     AROS_REQUIRED(android,$android_tool)
1054     if test "$aros_android_ndk" != "none"; then
1055         AC_MSG_CHECKING([what Android NDK version to use])
1056         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")
1057         AC_MSG_RESULT($aros_ndk_version)
1058     fi
1060     AC_PATH_PROG(ant, ant)
1061     if test "$ant" = ""; then
1062         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
1063     fi
1065     AC_MSG_CHECKING([Build debug or release apk])
1066     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)
1067     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
1068         AC_MSG_ERROR([apk-version has to be release or debug])
1069     fi
1070     AC_MSG_RESULT($aros_android_antapk)
1072     target_extra_cfg+="$export_newline""# Android$export_newline""AROS_ANDROID_ANTAPK           := $aros_android_antapk$export_newline"
1073     host_extra_cfg+="$export_newline""# Android-specific$export_newline""ANDROID                       := $android_tool$export_newline""ANT                                   := $ant$export_newline"
1074     aros_target_options+="$export_newline""# Enable Android Gfx Driver$export_newline""OPT_HOST_ANDROIDGFX           := yes$export_newline"
1076     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
1077     if test "$host_os" = "mingw32"; then
1078         android_tool="cmd //c $android_tool"
1079     fi
1081     need_dlopen="no"
1083     ;;
1084 esac
1086 #-----------------------------------------------------------------------------
1087 # External toolchains
1088 kernel_tool_prefix="none"
1089 aros_tool_prefix="none"
1090 elf_tool_prefix="${target_cpu}-elf-"
1092 # Base target cpu ISA configuration switch.
1093 case "$target_cpu" in
1094     *aarch64*)
1095         ;;
1096     *arm*)
1097         ;;
1098     *m68k*)
1099         m68k_isa_extra="ISA_MC68000_FLAGS             = -march=68000"
1100         m68k_020_isa_extra="ISA_MC68020_FLAGS             = -march=68020"
1101         m68k_030_isa_extra="ISA_MC68030_FLAGS             = -march=68030"
1102         m68k_040_isa_extra="ISA_MC68040_FLAGS             = -march=68040"
1103         m68k_060_isa_extra="ISA_MC68060_FLAGS             = -march=68060"
1104         m68k_ac080_isa_extra="ISA_AC68080_FLAGS             = -march=68040"
1105         m68k_020_ext="ISA_MC68020_EXT               :=020"
1106         m68k_030_ext="ISA_MC68030_EXT               :=030"
1107         m68k_040_ext="ISA_MC68040_EXT               :=040"
1108         m68k_060_ext="ISA_MC68060_EXT               :=060"
1109         m68k_020_cflags="ISA_MC68020_CFLAGS            ="
1110         m68k_030_cflags="ISA_MC68030_CFLAGS            ="
1111         m68k_040_cflags="ISA_MC68040_CFLAGS            ="
1112         m68k_060_cflags="ISA_MC68060_CFLAGS            ="
1113         m68k_020_cppflags="ISA_MC68020_CPPFLAGS          ="
1114         m68k_030_cppflags="ISA_MC68030_CPPFLAGS          ="
1115         m68k_040_cppflags="ISA_MC68040_CPPFLAGS          ="
1116         m68k_060_cppflags="ISA_MC68060_CPPFLAGS          ="
1117         m68k_020_ldflags="ISA_MC68020_LDFLAGS           ="
1118         m68k_030_ldflags="ISA_MC68030_LDFLAGS           ="
1119         m68k_040_ldflags="ISA_MC68040_LDFLAGS           ="
1120         m68k_060_ldflags="ISA_MC68060_LDFLAGS           ="
1121         ;;
1122     *x86_64* | *i?86*)
1123         x86_isa_extra="ISA_X86_FLAGS                 = -m32 -march=i486"
1124         x86_64_isa_extra="ISA_X8664_FLAGS               = -mcmodel=large"
1125         ;;
1126     *powerpc*)
1127         ;;
1128 esac
1130 # This is the target configuration switch.
1131 case "$target_os" in
1132     linux*)
1133         aros_target_arch="linux"
1134         aros_target_family="unix"
1135         case "$target_cpu" in
1136             *m68k*)
1137                 aros_target_cpu="m68k"
1138                 aros_object_format="m68kelf"
1139                 aros_flavour="emulcompat"
1140                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1141                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1142                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1143                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1144                 gcc_target_cpu="mc68000"
1145                 ;;
1146             *i?86*)
1147                 aros_target_cpu="i386"
1148                 aros_object_format="elf_i386"
1149                 aros_flavour="emulation"
1150                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1151                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1152                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1153                 aros_kernel_ldflags="-Wl,-melf_i386"
1154                 aros_nominal_depth=8
1155                 gcc_target_cpu="i386"
1156                 pci_hidd_target="hidd-pci-linux"
1157                 android_tool_dir_prefix="x86"
1158                 android_tool_prefix="i686-android-linux"
1159                 android_ndk_arch="x86"
1160                 ;;
1161             *x86_64*)
1162                 aros_target_cpu="x86_64"
1163                 aros_object_format="elf_x86_64"
1164                 aros_flavour="emulation"
1165                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1166                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1167                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1168                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1169                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1170                 aros_nominal_depth=8
1171                 pci_hidd_target="hidd-pci-linux"
1172                 ;;
1173             *powerpc*)
1174                 aros_target_cpu="ppc"
1175                 aros_object_format="elf32ppc"
1176                 aros_flavour="emulation"
1177                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1178                 aros_nominal_depth=8
1179                 gcc_target_cpu="ppc"
1180                 ;;
1181 # TODO
1182 # Same as powerpc, but I need this for the nightly build to work again.
1183 # Actually, the nightly should be made working with powerpc target.
1184 # That just was too much work for the moment, another week or two.
1185             *ppc*)
1186                 aros_target_cpu="ppc"
1187                 aros_object_format="elf32ppc"
1188                 aros_flavour="emulation"
1189                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1190                 aros_nominal_depth=8
1191                 gcc_target_cpu="ppc"
1192                 ;;
1193             *aarch64*)
1194                 aros_target_cpu="aarch64"
1195                 target_cpu="aarch64"
1196                 aros_object_format="aarch64elf_aros"
1197                 aros_flavour="emulation"
1198                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1199                 gcc_target_cpu="aarch64"
1200                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1201                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1202                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1203                 aros_c_libs="$aros_c_libs -laeabi"
1204                 gcc_default_float_abi="hard"
1205                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1206                 ;;
1207             *armhf*)
1208                 aros_target_cpu="arm"
1209                 target_cpu="arm"
1210                 aros_object_format="armelf_aros"
1211                 aros_flavour="emulation"
1212                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1213                 gcc_target_cpu="arm"
1214                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1215                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1216                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1217                 aros_c_libs="$aros_c_libs -laeabi"
1218                 gcc_default_float_abi="hard"
1219                 android_tool_dir_prefix="arm-linux-androideabi"
1220                 android_tool_prefix="arm-linux-androideabi"
1221                 android_ndk_arch="arm"
1222                 kernel_tool_prefix="arm-linux-gnueabihf-"
1223                 ;;
1224             *arm*)
1225                 aros_target_cpu="arm"
1226                 aros_object_format="armelf_aros"
1227                 aros_flavour="emulation"
1228                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1229                 gcc_target_cpu="arm"
1230                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1231                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1232                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1233                 aros_c_libs="$aros_c_libs -laeabi"
1234                 android_tool_dir_prefix="arm-linux-androideabi"
1235                 android_tool_prefix="arm-linux-androideabi"
1236                 android_ndk_arch="arm"
1237                 kernel_tool_prefix="arm-linux-gnueabi-"
1238                 ;;
1239             *)
1240                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1241                 ;;
1242         esac
1243         case "$aros_target_variant" in
1244             android)
1246                 dnl Not all Linux CPUs are supported by Android
1247                 if test "$android_ndk_arch" = ""; then
1248                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1249                 fi
1251                 aros_nominal_width=320
1252                 aros_nominal_height=480
1253                 if test "$aros_android_ndk" = "none"; then
1254                     dnl Use standalone toolchain, don't adjust paths
1255                     aros_kernel_cflags="-mandroid"
1256                     aros_kernel_ldflags="-mandroid"
1257                     CFLAGS="-mandroid"
1258                 else
1259                     dnl In Android NDK toolchains are placed in own directories,
1260                     dnl but tool names are not suffixed with version 
1261                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1262                     kernel_tool_version=""
1263                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1264                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1265                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1266                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1267                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1268                 fi
1269                 need_x11=no
1270                 # Disable implicit PIC mode
1271                 aros_config_cflags="$aros_config_cflags -fno-pic"
1272                 kernel_tool_prefix="$android_tool_prefix-"
1273             ;;
1274         esac
1275     ;;
1277     pc)
1278         aros_target_arch="pc"
1279         aros_shared_default="no"
1280         target_bootloader="grub2"
1281         case "$target_cpu" in
1282             *i?86*)
1283                 aros_target_cpu="i386"
1285                 dnl If somebody hasn't already set the target object
1286                 dnl format, then use this value. Mostly to support
1287                 dnl FreeBSD cross-compilation.
1288                 dnl TODO: Remove when we always use our compiler.
1290                 if test "$aros_object_format" = "" ; then
1291                     aros_object_format="elf_i386"
1292                 fi
1293                 aros_flavour="standalone"
1294                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1295                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1296                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1297                 aros_kernel_ldflags="-Wl,-melf_i386"
1298                 aros_nominal_width=640
1299                 aros_nominal_height=480
1300                 gcc_target_cpu="i386"
1301                 ;;
1302             *x86_64*)
1303                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1304                 aros_target_cpu="x86_64"
1305                 aros_serial_debug=1
1306                 if test "$aros_object_format" = "" ; then
1307                     aros_object_format="elf_x86_64"
1308                 fi
1309                 aros_flavour="standalone"
1310                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1311                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1312                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1313                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1314                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1315                 aros_kernel_ldflags=""
1316                 aros_nominal_width=640
1317                 aros_nominal_height=480
1318                 case "$aros_target_variant" in
1319                     smp)
1320                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1321                     ;;
1322                 esac
1323                 ;;
1324             *)
1325                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1326                 ;;
1327         esac
1328         ;;
1330     prep)
1331         aros_target_arch="prep"
1332         aros_shared_default="no"
1333         aros_target_cpu="ppc"
1334         aros_object_format="elf32ppc"
1335         aros_flavour="ppcnative"
1336         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1337         aros_kernel_ldflags=""
1338         aros_nominal_width=640
1339         aros_nominal_height=480
1340         gcc_target_cpu="ppc"
1341         ;;
1343     freebsd*)
1344         aros_target_arch="freebsd"
1345         aros_target_family="unix"
1346         aros_target_cpu="i386"
1347         aros_flavour="emulation"
1348         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1349         gcc_target_cpu="i386"
1351         aros_target_strip_flags="-x"
1352         ;;
1354     darwin*)
1355         aros_target_arch="darwin"
1356         aros_target_family="unix"
1357         aros_flavour="emulation"
1358         case "$target_cpu" in
1359             *i?86*)
1360                 aros_ios_platform="iPhoneSimulator"
1361                 aros_target_cpu="i386"
1362                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1363                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1364                 aros_kernel_ldflags=""
1365                 aros_macosx_version="10.4"
1366                 aros_nominal_depth=8
1367                 gcc_target_cpu="i386"
1368                 aros_object_format="elf_i386"
1369                 aros_kernel_ar_flags="-cr"
1370                 aros_target_strip_flags="-x"
1371                 kernel_tool_flags="-m32"
1372                 ;;
1373             *x86_64*)
1374                 aros_target_cpu="x86_64"
1375                 aros_object_format="elf_x86_64"
1376                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1377                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1378                 aros_macosx_version="10.6"
1379                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1380                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1381                 aros_kernel_cflags="-m64"
1382                 aros_kernel_ldflags="-m64"
1383                 aros_nominal_depth=8
1384                 aros_kernel_rs="$toolchain_ar"
1385                 aros_kernel_ar_flags="-cr"
1386                 aros_kernel_ld="$toolchain_ld"
1387                 aros_kernel_as="$toolchain_as"
1388                 aros_kernel_ranlib="$toolchain_ranlib"
1389                 aros_kernel_nm="$toolchain_nm"
1390                 aros_kernel_strip="strip"
1391                 kernel_tool_prefix="i686-apple-darwin10-"
1392                 ;;
1393             *ppc*)
1394                 aros_target_cpu="ppc"
1395                 aros_object_format="elf32ppc"
1396                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1397                 aros_kernel_ldflags=""
1398                 aros_macosx_version="10.0"
1399                 aros_nominal_depth=8
1400                 gcc_target_cpu="ppc"
1401                 aros_kernel_rs="$toolchain_ar"
1402                 aros_kernel_ar_flags="-cr"
1403                 aros_kernel_ld="$toolchain_ld -arch ppc"
1404                 aros_kernel_as="$toolchain_as -arch ppc"
1405                 aros_kernel_ranlib="$toolchain_ranlib -arch ppc"
1406                 aros_kernel_nm="$toolchain_nm -arch ppc"
1407                 aros_kernel_strip="strip -arch ppc"
1408                 kernel_tool_prefix="powerpc-apple-darwin10-"
1409                 ;;
1410             *arm*)
1411                 aros_ios_platform="iPhoneOS"
1412                 aros_target_cpu="arm"
1413                 aros_object_format="armelf_aros"
1414                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1415                 aros_c_libs="$aros_c_libs -laeabi"
1416                 aros_nominal_depth=8
1417                 gcc_target_cpu="arm"
1418                 aros_kernel_rs="$toolchain_ar"
1419                 aros_kernel_ar_flags="-cr"
1420                 aros_kernel_ld="$toolchain_ld -arch arm"
1421                 aros_kernel_ranlib="$toolchain_ranlib -arch arm"
1422                 kernel_tool_prefix="arm-apple-darwin10-" 
1423                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1424                 ;;
1425             *)
1426                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1427                 ;;
1428         esac
1429         case "$aros_target_variant" in
1430             ios)
1431                 make_extra_targetcfg="$export_newline""# Apple iOS stuff for gcc$export_newline""IOS_LDFLAGS  := -F$""(IOS_SDK_PATH)/System/Library/Frameworks$export_newline"
1432                 aros_ios_version="3.0"
1433                 aros_nominal_width=320
1434                 aros_nominal_height=480
1435                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1436                 target_extra_cfg+="$export_newline""# Apple iOS specific$export_newline""IOS_PLATFORM            := $aros_ios_platform$export_newline""IOS_OS_VERSION          := $aros_ios_version$export_newline""IOS_SDK_PATH            := $aros_ios_sdk$export_newline"
1437                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1438                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1439                 need_x11=no
1440                 # This is here because it may depend on iOS or SDK version
1441                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1442                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1443                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1444             ;;
1445             *)
1446                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1447                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1448             ;;
1449         esac
1450         ;;
1452     dragonfly*)
1453         aros_target_arch="dragonfly"
1454         aros_target_family="unix"
1455         aros_flavour="emulation"
1456         case "$target_cpu" in
1457             *i?86*)
1458                 aros_target_cpu="i386"
1459                 aros_object_format="elf_i386"
1460                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1461                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1462                 ;;
1463             *x86_64*)
1464                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1465                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1466                 aros_target_cpu="x86_64"
1467                 aros_object_format="elf_x86_64"
1468                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1469                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1470                 ;;
1471             *)
1472                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1473                 ;;
1474         esac
1475         ;;
1477     netbsd*)
1478         aros_target_arch="netbsd"
1479         aros_target_family="unix"
1480         case "$target_cpu" in
1481             *m68k*)
1482                 aros_target_cpu="m68k"
1483                 aros_object_format="m68kelf"
1484                 aros_flavour="emulcompat"
1485                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1486                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1487                 gcc_target_cpu="mc68000"
1488                 ;;
1489             *i?86*)
1490                 aros_target_cpu="i386"
1491                 aros_object_format="elf_i386"
1492                 aros_flavour="emulation"
1493                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1494                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1495                 aros_nominal_depth=8
1496                 gcc_target_cpu="i386"
1497                 ;;
1498             *)
1499                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1500                 ;;
1501         esac
1502         aros_target_genmap="-Wl,-M -Xlinker >"
1503         aros_flavour="emulation"
1504         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1505         ;;   
1507     openbsd*)
1508         aros_target_arch="openbsd"
1509         aros_target_family="unix"
1510         case "$target_cpu" in
1511             *i?86*)
1512                 aros_target_cpu="i386"
1513                 aros_object_format="elf_i386"
1514                 aros_flavour="emulation"
1515                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1516                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1517                 gcc_target_cpu="i386"
1518                 ;;
1519             *)
1520                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1521                 ;;
1522         esac
1523         aros_target_genmap="-Wl,-M -Xlinker >"
1524         aros_target_nm_flags="-u"
1525         aros_flavour="emulation"
1526         ;;
1528     solaris*)
1529         aros_target_arch="solaris"
1530         aros_target_family="unix"
1531         case "$target_cpu" in
1532            *i?86*)
1533                aros_target_cpu="i386"
1534                aros_object_format="elf_i386"
1535                aros_flavour="emulation"
1536                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1537                aros_isa_flags="$""(ISA_X86_FLAGS)"
1538                aros_nominal_depth=8
1539                gcc_target_cpu="i386"
1540                ;;
1541             *sparc*)
1542                 aros_target_cpu="sparc"
1543                 aros_object_format="elf_sparc"
1544                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1545                 gcc_target_cpu="sparc"
1546                 ;;
1547             *)
1548                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1549                 ;;
1550         esac
1551         aros_config_cppflags="$aros_config_cppflags -D$aros_target_cpu"
1552         aros_flavour="emulation"
1553         ;;
1555     morphos*)
1556         aros_target_arch="morphos"
1557         aros_shared_default="no"
1558         aros_target_cpu="ppc"
1559         aros_object_format="elf_ppc"
1560         aros_flavour="nativecompat"
1561         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1562         gcc_target_cpu="ppc"
1563         ;;
1565     sam440)
1566         aros_target_arch="sam440"
1567         aros_shared_default="no"
1568         aros_target_cpu="ppc"
1569         aros_object_format="elf32ppc"
1570         aros_flavour="ppcnative"
1571         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1572         aros_kernel_ldflags=""
1573         aros_nominal_width=1024
1574         aros_nominal_height=768
1575         aros_nominal_depth=24
1576         aros_isa_flags="$aros_isa_flags -mcpu=440fp -mno-toc"
1577         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1578         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1579         gcc_target_cpu="powerpc"
1580         ;;
1582     efika)
1583         aros_target_arch="efika"
1584         aros_shared_default="no"
1585         aros_target_cpu="arm"
1586         aros_object_format="armelf_aros"
1587         aros_flavour="standalone"
1588         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1589         aros_kernel_ldflags=""
1590         aros_nominal_width=1024
1591         aros_nominal_height=600
1592         aros_c_libs="$aros_c_libs -laeabi"
1593         gcc_default_cpu="armv7-a"
1594         gcc_default_fpu="vfpv3"
1595         aros_isa_flags="$aros_isa_flags -mtune=cortex-a8"
1596         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1597         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1598         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1599         if test "$optimization" = "default"; then
1600             optimization_level="-Os"
1601         fi
1602         case "$target_cpu" in
1603             *armhf*)
1604                 gcc_default_float_abi="hard"
1605                 target_cpu=arm
1606                 aros_target_cpu=arm
1607                 ;;
1608             *arm*)
1609                 gcc_default_float_abi="softfp"
1610                 ;;
1611             *)
1612                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1613                 ;;
1614         esac
1615         ;;
1616         
1617     chrp)
1618         aros_target_arch="chrp"
1619         aros_shared_default="no"
1620         aros_target_cpu="ppc"
1621         aros_object_format="elf32ppc"
1622         aros_flavour="ppcnative"
1623         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1624         aros_kernel_ldflags=""
1625         aros_nominal_width=640
1626         aros_nominal_height=480
1627         aros_isa_flags="$aros_isa_flags -mno-toc"
1628         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1629         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1630         gcc_target_cpu="powerpc"
1631         case "$aros_target_variant" in
1632             efika)
1633                 aros_isa_flags="$aros_isa_flags -mcpu=603e"
1634                 aros_config_cppflags="$aros_config_cppflags -DBIG_ENDIAN_OHCI=1"
1635             ;;
1636         esac
1637         ;;
1639     r*pi)
1640         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1641         aros_flavour="standalone"
1642         aros_target_arch="raspi"
1644         aros_shared_default="no"
1646         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1647         
1648         case "$target_cpu" in
1649             *aarch64*)
1650                 aros_target_cpu="aarch64"
1651                 gcc_default_cpu="aarch64"
1652                 aros_object_format="aarch64elf_aros"
1653                 ;;
1654             *armhf*)
1655                 aros_target_cpu="arm"
1656                 gcc_default_cpu="armv6zk"
1657                 gcc_default_cpu_tune="arm1176jzf-s"
1658                 aros_object_format="armelf_aros"
1659                 aros_isa_flags="$aros_isa_flags -marm"
1660                 aros_config_cflags="$aros_config_cflags"
1661                 aros_config_cxxflags="$aros_config_cxxflags"
1662                 aros_config_aflags="$aros_config_aflags -marm"
1663                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1664                 aros_target_mkdep="$aros_target_mkdep -Darm"
1665                 aros_c_libs="$aros_c_libs -laeabi"
1666                 ;;
1667             *armeb*)
1668                 aros_flavour="standcompat"
1669                 aros_target_cpu="armeb"
1670                 gcc_default_float_abi="hard"
1671                 gcc_default_cpu="armv7ve"
1672                 gcc_default_cpu_tune="cortex-a7"
1673                 aros_object_format="armelfb_aros"
1674                 aros_isa_flags="$aros_isa_flags -marm"
1675                 aros_config_cflags="$aros_config_cflags"
1676                 aros_config_cxxflags="$aros_config_cxxflags"
1677                 aros_config_aflags="$aros_config_aflags -marm"
1678                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1679                 aros_target_mkdep="$aros_target_mkdep -Darm"
1680                 aros_c_libs="$aros_c_libs -laeabi"
1681                 ;;
1682             *arm*)
1683                 aros_target_cpu="arm"
1684                 gcc_default_cpu="armv6zk"
1685                 gcc_default_cpu_tune="arm1176jzf-s"
1686                 aros_object_format="armelf_aros"
1687                 aros_isa_flags="$aros_isa_flags -marm"
1688                 aros_config_cflags="$aros_config_cflags"
1689                 aros_config_cxxflags="$aros_config_cxxflags"
1690                 aros_config_aflags="$aros_config_aflags -marm"
1691                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1692                 aros_target_mkdep="$aros_target_mkdep -Darm"
1693                 aros_c_libs="$aros_c_libs -laeabi"
1694                 ;;
1695             *)
1696                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1697                 ;;
1698         esac
1700         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1701         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1702         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1703         aros_kernel_cflags="$aros_kernel_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1705         case "$aros_target_variant" in
1706             smp)
1707                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1708             ;;
1709         esac
1710         ;;
1712     stm32f7_discovery)
1713         aros_flavour="standalone"
1714         aros_target_arch="stm32f7_discovery"
1715         aros_target_cpu="arm"
1716         aros_target_cpu_mode="thumb2"
1717         aros_object_format="armelf_aros"
1718         aros_shared_default="no"
1720         gcc_default_cpu="armv7e-m"
1721         gcc_default_cpu_tune="cortex-m7"
1722         gcc_default_fpu="fpv5-sp-d16"
1723         gcc_default_float_abi="hard"
1725         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1726         ;;
1728     amiga*)
1729         aros_elf_translate="$""(ELF2HUNK)"
1730         make_extra_commands="$export_newline""ELF2HUNK  := $""(TOOLDIR)/elf2hunk$""(HOST_EXE_SUFFIX)$export_newline"
1731         aros_target_arch="amiga"
1732         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1733         aros_shared_default="no"
1735         case "$target_cpu" in
1736             *m68k*)
1737                 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")
1738                 aros_enable_mmu=no
1739                 aros_target_cpu="m68k"
1740                 aros_object_format="m68kelf"
1741                 aros_flavour="standcompat"
1742                 gcc_target_cpu="m68000"
1743                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1744                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1745                 aros_config_cppflags="$aros_config_cppflags -DNOLIBINLINE"
1746                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1747                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1748                 if test "$optimization" = "default"; then
1749                     optimization_level="-Os"
1750                 fi
1751                 aros_config_aflags="$aros_config_aflags"
1752                 aros_target_strip_flags="-R.comment --strip-debug"
1753                 aros_nominal_width=640
1754                 aros_nominal_height=256
1755                 aros_nominal_depth=2
1756                 ;;
1757             *ppc*)
1758                 aros_cpu="ppc"
1759                 aros_flavour="native"
1760                 gcc_target_cpu="ppc"
1761                 ;;
1762             *)
1763                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1764                 ;;
1765         esac
1766         ;;
1768     mingw*)
1769         aros_target_arch="mingw32"
1770         aros_shared_default="no"
1771         aros_flavour="emulation"
1772         aros_shared_cflags=""
1773         need_crosstools="yes"
1774         need_dlopen="no"
1775         rescomp="windres"
1776         case "$target_cpu" in
1777             *i?86*)
1778                 aros_target_cpu="i386"
1779                 aros_object_format="elf_i386"
1780                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1781                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1782                 aros_nominal_depth=8
1783                 gcc_target_cpu="i386"
1785                 kernel_tool_prefix="i386-mingw32-"
1786                 ;;
1787             *x86_64*)
1788                 aros_target_cpu="x86_64"
1789                 aros_object_format="elf_x86_64"
1790                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1791                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1792                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1793                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1794                 aros_nominal_depth=8
1795                 kernel_tool_prefix="x86_64-w64-mingw32-"
1796                 ;;
1797             *arm*)
1798                 aros_target_cpu="arm"
1799                 aros_object_format="armelf_aros"
1800                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1801                 aros_c_libs="$aros_c_libs -laeabi"
1802                 aros_nominal_depth=8
1803                 gcc_target_cpu="arm"
1804                 gcc_default_float_abi="soft"
1805                 kernel_tool_prefix="arm-mingw32ce-"
1806                 aros_nominal_width=160
1807                 aros_nominal_height=160
1808                 ;;
1809             *)
1810                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1811                 ;;
1812         esac
1813         if test $host_os = "cygwin"; then
1814                 aros_kernel_cflags="-mno-cygwin"
1815         fi
1816     ;;
1817     pp*)
1818         aros_target_arch="pp"
1819         aros_shared_default="no"
1820         case "$target_cpu" in
1821             *m68k*)
1822                 aros_target_cpu="m68k"
1823                 aros_object_format="m68kelf"
1824                 aros_flavour="palmnative"
1825                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1826                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1827                 aros_nominal_width=160
1828                 aros_nominal_height=160
1829                 aros_nominal_depth=1
1830                 aros_target_ar_flags="cru"
1831                 aros_c_libs="$aros_c_libs -lgcc1"
1832                 aros_shared_default=no
1833                 aros_shared_cflags="-fpic"
1834                 aros_shared_aflags=""
1835                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1836                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1837                 aros_debug_cppflags="$aros_messages_debug"
1838                 aros_debug_cflags="$aros_symbols_debug"
1839                 aros_debug_aflags=""
1840                 aros_debug_ldflags="$aros_symbols_debug"
1841                 aros_mungwall_debug="0"
1842                 aros_modules_debug="0"
1843                 gcc_target_cpu="mc68000"
1844                 ignore_undefined_symbols="-ius"
1845                 ;;
1846            *)
1847                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1848                 ;;
1849         esac
1850         ;;
1852     mac*)
1853         aros_target_arch="mac"
1854         aros_shared_default="no"
1855         case "$target_cpu" in
1856             *m68k*)
1857                 aros_target_cpu="m68k"
1858                 aros_object_format="m68kelf"
1859                 aros_flavour="mac68knative"
1860                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1861                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1862                 aros_nominal_width=512
1863                 aros_nominal_height=384
1864                 aros_nominal_depth=8
1865                 aros_target_ar_flags="cru"
1866                 aros_c_libs="$aros_c_libs -lgcc1"
1867                 aros_shared_default=no
1868                 aros_shared_cflags="-fpic"
1869                 aros_shared_aflags=""
1870                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1871                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1872                 aros_debug_cppflags="$aros_messages_debug"
1873                 aros_debug_cflags="$aros_symbols_debug"
1874                 aros_debug_aflags=""
1875                 aros_debug_ldflags="$aros_symbols_debug"
1876                 aros_mungwall_debug="0"
1877                 aros_modules_debug="0"
1878                 gcc_target_cpu="mc68000"
1879                 ignore_undefined_symbols="-ius"
1880                 ;;
1881            *)
1882                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1883                 ;;
1884         esac
1885         ;;
1887     *)
1888         AC_MSG_ERROR([Unsupported target architecture $target])
1889         ;;
1890 esac
1892 #-----------------------------------------------------------------------------
1893 crosstools_guess="yes"
1894 aros_target_toolchain="no"
1895 aros_kernel_sysroot=""
1897 AC_MSG_CHECKING([Kernel toolchain prefix])
1898 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1899 AC_MSG_RESULT($kernel_tool_prefix)
1901 AC_MSG_CHECKING([ELF toolchain prefix])
1902 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"
1903                                                  crosstools_guess="no"])
1904 AC_MSG_RESULT($elf_tool_prefix)
1906 AC_MSG_CHECKING([AROS toolchain prefix])
1907 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"
1908                 crosstools_guess="no"])
1909 if test "$aros_tool_prefix" = "yes" ; then
1910     aros_tool_prefix=$aros_target_cpu-aros-
1912 AC_MSG_RESULT($aros_tool_prefix)
1914 #-----------------------------------------------------------------------------
1915 #   Checking if we should build crosstools..
1916 AC_MSG_CHECKING([whether to build crosstools])
1917 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1918 AC_MSG_RESULT($crosstools)
1920 if test "${crosstools}" = "yes"; then
1921     if test "${crosstools_guess}" = "no"; then
1922         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1923     fi
1926 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1927     aros_target_toolchain="yes"
1930 AC_MSG_CHECKING([where to install the crosstools binaries])
1931 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])
1932 if test "x$aros_toolchain_install" = "x"; then
1933     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1934 else
1935     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1936     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1937     if test "$crosstools_guess" = "no" ; then
1938         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1939             aros_kernel_sysroot="$""(TARGET_SYSROOT)"
1940         fi
1941     fi
1943 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1945 #-----------------------------------------------------------------------------
1946 if test "$aros_toolchain" = "gnu" ; then
1947     AC_MSG_CHECKING([what specific target binutils version to use])
1949 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="")
1950 if test "$use_binutils_version" = ""; then
1951         target_binutils_version="$default_binutils_version"
1952 else
1953     target_binutils_version="$use_binutils_version"
1955 if test "$aros_toolchain" = "gnu" ; then
1956     AC_MSG_RESULT($target_binutils_version)
1960 # Helper to identify gcc version
1961 AC_DEFUN([CROSS_GCC_VERSION], [
1962   target_gcc_version=""
1963   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1964     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1965     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1966       ax_cv_gcc_version=""
1967     ])
1968   ])
1969   target_gcc_version=$ax_cv_gcc_version
1970   AC_SUBST([target_gcc_version])
1973 #-----------------------------------------------------------------------------
1974 if test "$aros_toolchain" = "gnu" ; then
1975     AC_MSG_CHECKING([what specific target gcc version to use])
1977 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1978 if test "$use_gcc_version" = ""; then
1979     if test "${crosstools}" = "no"; then
1980       if test "x$aros_toolchain_install" != "x"; then
1981           CROSS_GCC_VERSION
1982       fi
1983     fi
1984     if test "$use_gcc_version" = ""; then
1985         target_gcc_version="$default_gcc_version"
1986     fi
1987 else
1988     target_gcc_version="$use_gcc_version"
1990 if test "$aros_toolchain" = "gnu" ; then
1991     AC_MSG_RESULT($target_gcc_version)
1993     AC_MSG_CHECKING([version string style])
1994     if test "${target_gcc_version#*$'-'}" != "$target_gcc_version" ; then
1995         AC_MSG_RESULT(snapshot)
1996         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'-' -f1)
1997         GCC_VERSION_MINOR=-1
1998         GCC_VERSION_PATCH=-1
1999     else
2000         AC_MSG_RESULT(release)
2001         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
2002         GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
2003         GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
2004     fi
2006     gcc_fix_bitfields="false"
2007     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
2008         gcc_fix_bitfields="true"
2009     else
2010         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
2011             if test "$GCC_VERSION_MINOR" -gt "6" ; then
2012                 gcc_fix_bitfields="true"
2013             fi
2014         fi
2015     fi
2017     if test "$gcc_fix_bitfields" = "true" ; then
2018         case "$aros_target_cpu" in
2019         *x86_64* | *i?86*)
2020             x86_isa_extra="$x86_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2021             x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2022             ;;
2023         esac
2024     fi
2027 AC_MSG_CHECKING([whether to enable Objective-C suppport])
2028 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
2029 AC_MSG_RESULT($objc)
2030 if test "x$objc" = "xyes"; then
2031     objc_target="$objc"
2032 else
2033     objc_target="no-objc"
2036 AC_MSG_CHECKING([whether to enable Java suppport])
2037 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
2038 AC_MSG_RESULT($java)
2039 if test "x$java" != "xno"; then
2040     java_target="$java"
2041 else
2042     java_target="no-java"
2045 spec_obj_format="-m $aros_object_format"
2046 # Now process extra architecture-specific options.
2047 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
2048 # as well as floating-point ABI.
2049 case "$aros_target_cpu" in
2050     *m68k*)
2051         aros_isa_targets="M68K_ISA_TARGETS              :=MC68020 MC68040"
2052         aros_isa_extra="$aros_isa_extra$export_newline$aros_isa_targets$export_newline"
2053         aros_isa_extra="$aros_isa_extra$m68k_isa_extra$export_newline$m68k_020_isa_extra$export_newline$m68k_030_isa_extra$export_newline$m68k_040_isa_extra$export_newline$m68k_060_isa_extra$export_newline$m68k_ac080_isa_extra$export_newline"
2054         aros_isa_extra="$aros_isa_extra$m68k_020_cppflags$export_newline$m68k_030_cppflags$export_newline$m68k_040_cppflags$export_newline$m68k_060_cppflags$export_newline"
2055         aros_isa_extra="$aros_isa_extra$m68k_020_cflags$export_newline$m68k_030_cflags$export_newline$m68k_040_cflags$export_newline$m68k_060_cflags$export_newline"
2056         aros_isa_extra="$aros_isa_extra$m68k_020_ldflags$export_newline$m68k_030_ldflags$export_newline$m68k_040_ldflags$export_newline$m68k_060_ldflags$export_newline"
2057         aros_isa_extra="$aros_isa_extra$m68k_020_ext$export_newline$m68k_030_ext$export_newline$m68k_040_ext$export_newline$m68k_060_ext$export_newline"
2058         ;;
2059     *x86_64*)
2060         aros_isa_extra="$export_newline$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2061         dnl x86_64 can build 32 or 64bit code
2062         spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
2063         ;;
2064     arm*)
2065         dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
2066         if test "$gcc_default_cpu" = ""; then
2067             gcc_default_cpu="armv6"
2068         fi
2069         if test "$gcc_default_fpu" = ""; then
2070             gcc_default_fpu="vfp"
2071         fi
2072         if test "$gcc_default_endian" = ""; then
2073             if test "$target_cpu" = "armeb"; then
2074                 gcc_default_endian="big-endian"
2075             else
2076                 gcc_default_endian="little-endian"
2077             fi
2078         fi
2079         if test "$gcc_default_float_abi" = ""; then
2080             if test "$target_cpu" = "armhf"; then
2081                 gcc_default_float_abi="hard"
2082             else
2083                 gcc_default_float_abi="softfp"
2084             fi
2085         fi
2087         AC_MSG_CHECKING([Which minimum CPU to use])
2088         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)
2089         AC_MSG_RESULT($aros_gcc_cpu)
2091         AC_MSG_CHECKING([Which minimum FPU to use])
2092         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)
2093         AC_MSG_RESULT($aros_gcc_fpu)
2095         AC_MSG_CHECKING([Which floating point ABI to use])
2096         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)
2097         AC_MSG_RESULT($aros_gcc_float_abi)
2099         AC_MSG_CHECKING([Which ARM mode to use])
2100         if test "$aros_target_cpu_mode" = ""; then
2101             aros_target_cpu_mode="arm32"
2102             AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
2103         else
2104             AC_MSG_RESULT([$aros_target_cpu_mode])
2105         fi
2107         case "$aros_target_cpu_mode" in
2108         arm32)
2109             gcc_default_mode="arm"
2110             aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -m$gcc_default_endian -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
2111         ;;
2112         arm64)
2113             AC_MSG_ERROR([ARM 64-bit mode is unsupported])
2114         ;;
2115         thumb)
2116             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2117         ;;
2118         thumb1)
2119             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2120         ;;
2121         thumb2)
2122             gcc_default_mode="thumb"
2123             # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
2124             aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -$gcc_default_endian -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
2125         ;;
2126         *)
2127             AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
2128         ;;
2129         esac
2131         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2132         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2133         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2134         ;;
2135     i386)
2136         aros_isa_extra="$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2137         aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
2138         ;;
2139 esac
2141 # Some architectures may need custom ELF specs.
2142 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
2143     elf_specs_in=config/${aros_object_format}-specs.in
2144 else
2145     elf_specs_in=config/elf-specs.in
2148 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
2149 # Since we override specs, we may need to put these defines there
2150 if test "$gcc_target_cpu" != ""; then
2151     gcc_target_cpu="-D__${gcc_target_cpu}__"
2154 AC_MSG_CHECKING([where to download sourcecode for external ports])
2155 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
2156 if test "$with_portssrcdir" = "default"; then
2157     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
2158 else
2159     AROS_PORTSSRCDIR="$with_portssrcdir"
2161 AC_MSG_RESULT($AROS_PORTSSRCDIR)
2163 AC_MSG_CHECKING([which bootloader to use])
2164 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
2165 if test "$target_bootloader" = "none"; then
2166     aros_target_bootloader=""
2167 else
2168     aros_target_bootloader="$target_bootloader"
2170 AC_MSG_RESULT($target_bootloader)
2172 AC_MSG_CHECKING([which icon-set to use])
2173 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
2174 if test "$target_iconset" = "default"; then
2175     aros_target_iconset="Gorilla"
2176     target_iconset="default (Gorilla)"
2177 else
2178     aros_target_iconset="$target_iconset"
2180 AC_MSG_RESULT($target_iconset)
2182 AC_MSG_CHECKING([which GUI Theme to use])
2183 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2184 if test "$target_guitheme" = "default"; then
2185     aros_target_guitheme="Ice"
2186 else
2187     aros_target_guitheme="$target_guitheme"
2189 AC_MSG_RESULT($aros_target_guitheme)
2191 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2192 # for target code)
2193 cross_compiling=no
2195 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2196 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2197     cross_compiling=yes
2200 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2201 dnl The flag itself is given in per-target section, because some targets require to pass it
2202 dnl in a different manner, otherwise some tests fail.
2203 dnl TODO: Justify this.
2204 if test "$aros_host_cpu" == "x86_64" ; then
2205     if test "$aros_target_cpu" == "i386" ; then
2206         cross_compiling=no
2207     fi
2210 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2211     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2212     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2213     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2214     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2215     dnl used to build bootstrap for target arch in either case.
2216     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2217     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2218     dnl perhaps introducing aros_host_variant
2219     if test "$aros_host_arch" != "$aros_target_arch" ; then
2220         cross_compiling=yes
2221     fi
2222 else
2223     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2224     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2225     dnl if test "$host_cc_elf" = "no" ; then
2226         cross_compiling=yes
2227     dnl fi
2230 if test "$cross_compiling" = "no" ; then
2231     kernel_tool_prefix=""
2232     if test "$host_cc_elf" = "yes" ; then
2233         elf_tool_prefix=""
2234     fi
2237 if test "$kernel_tool_version" != ""; then
2238     kernel_tool_version="-$kernel_tool_version"
2241 #######################################################################
2242 ## Compute what toolchains to use, and their paths                   ##
2243 #######################################################################
2245 # This takes, as input:
2246 #   crosstools             {yes,no}
2247 #   kernel_tool_version    {"",[version]}
2248 #   target_tool_version    {"",[version]}
2249 #   kernel_tool_prefix     {none,[some-arch-os-]}
2250 #   gnu-toolchain -:
2251 #     target_tool_prefix     ${aros_target_cpu}-aros-
2252 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2254 # The output is
2255 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2256 #        Where the 'kernel' binaries are located
2257 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2258 #        Where the 'target' binaries are located
2259 #        (not the symlink farm - that is aros_target_*!)
2261 # The rules are:
2262 #   if crosstools then
2263 #      if kernel_tools_prefix = "no-kernel-prefix-"
2264 #          aros_kernel_* = crosstools cc paths
2265 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2266 #      else
2267 #          VALIDATE(${kernel_tools_prefix}*)
2268 #          aros_kernel_* = ${kernel_tools_prefix}*
2269 #          if ${kernel_tools_prefix}cc is an AROS gcc
2270 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2271 #          else
2272 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2273 #          fi
2274 #      fi
2276 #      orig_target_* = aros built crosstools
2277 #      orig_target_cc = elf cc wrapper around crosstools cc
2278 #   else
2279 #      VALIDATE(${kernel_tools_prefix}*)
2281 #      orig_target_* = aros_kernel_*
2282 #      if aros_kernel_cc is an AROS gcc
2283 #          orig_target_cc = aros_kernel_cc
2284 #      else
2285 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2286 #      fi
2287 #   fi
2289 if test "$aros_toolchain" = "gnu" ; then
2290     target_tool_prefix="${aros_target_cpu}-aros-"
2291 elif test "$aros_toolchain" = "llvm" ; then
2292     target_tool_prefix="bin/"
2295 if test "$kernel_tool_prefix" != "" ; then
2296     AC_MSG_CHECKING([which kernel tools])
2297     AC_MSG_RESULT([$kernel_tool_prefix]);
2300 if test "$kernel_tool_prefix" = "none" ; then
2301     dnl ELF wrapper can be used only for native bootstrap
2302     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2303         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2304     fi
2305 else
2306     if test "x-$aros_flavour" != "x-standalone" -o "x-$aros_flavour" != "x-standcompat" ; then
2307         # Kernel tools required - find them
2308         # Note that 'normally', aros_kernel_* overrides will be
2309         # empty, unless specified in the per-arch sections above.
2310         test_kernel_cc=yes
2311         if test "x$aros_kernel_cpp" = "x"; then
2312             aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2313         fi
2314         AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2315         AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2316         AROS_REQUIRED(cpp,$aros_kernel_cpp)
2318         if test "x$aros_kernel_cc" = "x"; then
2319             aros_kernel_cc=${kernel_tool_prefix}${CC}
2320         fi
2321         AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2322         AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2323         AROS_REQUIRED(cc,$aros_kernel_cc)
2325         if test "x$aros_kernel_cxx" = "x"; then
2326             aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2327         fi
2328         AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2329         AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2330         # If it's set, make sure it's really there
2331         if test "x$aros_kernel_cxx" != "x" ; then
2332             AROS_REQUIRED(cxx,$aros_kernel_cxx)
2333         fi
2334         if test "x$aros_kernel_ld" = "x"; then
2335             aros_kernel_ld=$aros_host_ld
2336         fi
2337         AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2338         AROS_REQUIRED(ld,$aros_kernel_ld)
2339         if test "x$aros_kernel_as" = "x"; then
2340             aros_kernel_as=$aros_host_as
2341             if test "x$aros_kernel_as" = "x"; then
2342                 aros_kernel_as=${HOST_TOOLCHAIN_PREFIX}as${HOST_TOOLCHAIN_SUFFIX}
2343             fi
2344         fi
2345         AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2346         AROS_REQUIRED(as,$aros_kernel_as)
2347         if test "x$aros_kernel_ar" = "x"; then
2348             aros_kernel_ar=$aros_host_ar
2349         fi
2350         AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2351         AROS_REQUIRED(ar,$aros_kernel_ar)
2352         if test "x$aros_kernel_ranlib" = "x"; then
2353             aros_kernel_ranlib=$aros_host_ranlib
2354         fi
2355         AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2356         AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2357         if test "x$aros_kernel_nm" = "x"; then
2358             aros_kernel_nm=$aros_host_nm
2359             if test "x$aros_kernel_nm" = "x"; then
2360                 aros_kernel_nm=${HOST_TOOLCHAIN_PREFIX}nm${HOST_TOOLCHAIN_SUFFIX}
2361             fi
2362         fi
2363         AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2364         AROS_REQUIRED(nm,$aros_kernel_nm)
2365         AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2366         AROS_REQUIRED(strip,$aros_kernel_strip)
2368         # Objcopy and objdump are not required for the kernel
2369         # toolchain on many architectures.
2370         # So we'll look for them, but not make them strictly required.
2371         if test "x$aros_kernel_objcopy" = "x"; then
2372             aros_kernel_objcopy=$aros_host_objcopy
2373             if test "x$aros_kernel_objcopy" = "x"; then
2374                 aros_kernel_objcopy=${HOST_TOOLCHAIN_PREFIX}objcopy${HOST_TOOLCHAIN_SUFFIX}
2375             fi
2376         fi
2377         AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2378         if test "x$aros_kernel_objdump" = "x"; then
2379             aros_kernel_objdump=$aros_host_objdump
2380             if test "x$aros_kernel_objdump" = "x"; then
2381                 aros_kernel_objdump=${HOST_TOOLCHAIN_PREFIX}objdump${HOST_TOOLCHAIN_SUFFIX}
2382             fi
2383         fi
2384         AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2385         if test "x${crosstools}" != "xyes" ; then
2386             AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2387             AROS_REQUIRED(objdump,$aros_kernel_objdump)
2388         fi
2389     fi
2392 AC_MSG_CHECKING([which target tools to use])
2393 if test "$aros_target_toolchain" = "yes"; then
2394     if test "$aros_toolchain" = "llvm" ; then
2395         msg_result="llvm"
2396     else
2397         msg_result=$target_tool_prefix
2398     fi
2399     AC_MSG_RESULT([$msg_result])
2400     # We are building AROS crosstools
2401     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2402     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2403     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2404     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2405     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2406     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2407     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2408     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2409     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2410     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2411     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2412     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2413 else
2414     # Determine whether AROS or ELF tools should be used
2415     if test "$aros_tool_prefix" = "none"; then
2416         aros_tool_prefix="${elf_tool_prefix}"
2417     fi
2419     AC_MSG_RESULT([$aros_tool_prefix])
2420     # We are *not* building AROS crosstools - use the AROS or ELF tools
2421     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2422     AROS_REQUIRED(cpp,$orig_target_cpp)
2423     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2424     AROS_REQUIRED(cc,$orig_target_cc)
2425     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2426     AROS_REQUIRED(cxx,$orig_target_cxx)
2427     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2428     AROS_REQUIRED(ld,$orig_target_ld)
2429     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2430     AROS_REQUIRED(as,$orig_target_as)
2431     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2432     AROS_REQUIRED(ar,$orig_target_ar)
2433     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2434     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2435     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2436     AROS_REQUIRED(nm,$orig_target_nm)
2437     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2438     AROS_REQUIRED(strip,$orig_target_strip)
2439     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2440     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2441     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2442     AROS_REQUIRED(objdump,$orig_target_objdump)
2445 if test "$kernel_tool_prefix" = "none" ; then
2446     # No kernel tools specified
2447     # Assume target tools == kernel tools with ELF wrapper
2448     aros_kernel_cc=$orig_target_cc
2449     aros_kernel_cxx=$orig_target_cxx
2450     aros_kernel_cpp=$orig_target_cpp
2451     aros_kernel_ld=$orig_target_ld
2452     aros_kernel_as=$orig_target_as
2453     aros_kernel_ar=$orig_target_ar
2454     aros_kernel_ranlib=$orig_target_ranlib
2455     aros_kernel_nm=$orig_target_nm
2456     aros_kernel_strip=$orig_target_strip
2457     aros_kernel_objcopy=$orig_target_objcopy
2458     aros_kernel_objdump=$orig_target_objdump
2459     use_kernel_cc_wrapper=yes
2462 # At this point, all aros_kernel_* and aros_target_* 
2463 # tools should be set up correctly
2465 CC="$aros_kernel_cc $kernel_tool_flags"
2466 CPP="$aros_kernel_cpp"
2468 #-----------------------------------------------------------------------------
2470 # Find all the tools we need to compile. This could be cross-compiling
2471 # though! If that is the case we use the GNU form of the target and
2472 # simply add this to the front of the binary name. This is rather simple,
2473 # but it should work under most circumstances.
2475 # The default tools are to use the same as the host, but only if the
2476 # host and target CPU are the same. With GCC this is normally enough.
2479 aros_cc_pre=""
2480 aros_shared_ld="$aros_host_ld"
2482 aros_target_mkdep="$aros_host_mkdep"
2484 # The default tools executables to be linked to.
2485 if test "$rescomp" != ""; then
2486     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2487     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2490 # Set up the sources for the symlink farm
2491 if test "$crosstools" = "yes"; then
2492     crosstools_target=tools-crosstools
2495 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2496 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2498 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2499 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2500 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2501 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2502 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2503 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2504 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2506 # aros_cc_pre is a variable that is added to the front of the compiler name
2507 # in the generated aros-gcc shell script. We need this to enable the cache
2508 # to work across cleaned builds. Also, support DISTCC using the correct
2509 # environment variable.
2512 if test "x${DISTCC}" != "x" ; then
2513     if test "x${CCACHE}" != "x" ; then
2514         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2515     else
2516         aros_cc_pre="${DISTCC} "
2517     fi
2518 else
2519     if test "x${CCACHE}" != "x" ; then
2520         aros_cc_pre="${CCACHE} "
2521     fi
2524 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2525 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2526 AC_SUBST(aros_target_nix_ldflags,-nix)
2527 AC_SUBST(aros_target_detach_ldflags,-detach)
2528 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2530 aros_target_cc_path=
2532 # Target tools
2533 AC_SUBST(aros_toolchain)
2534 if test "$aros_target_toolchain" != "yes"; then
2535     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2536     if test "$GCC" = "yes"; then
2537         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2538     fi
2539 else
2540     # We do not know which c compiler version we are going to build and what we need to know
2541     # here is different for different versions so this will be set later during the
2542     # build of crosstools.
2543     if test "$aros_toolchain" = "gnu" ; then
2544         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2545     elif test "$aros_toolchain" = "llvm" ; then
2546         prefix="$AROS_CROSSTOOLSDIR/bin/"
2547     fi
2548     aros_target_cc_path=@aros_target_cc_path@
2550 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2551 aros_target_cc="${prefix}${toolchain_c_compiler}"
2552 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2553 aros_target_as="${prefix}${toolchain_as}"
2554 if test "${use_ld_wrapper}" = "yes"; then
2555     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2556 else
2557     aros_target_ld="${prefix}${toolchain_ld}"
2559 aros_toolchain_ld="${prefix}${toolchain_ld}"
2561 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2562 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2563 aros_target_objdump="${prefix}${toolchain_objdump}"
2564 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2565 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2566 aros_target_strip="${prefix}${toolchain_strip}"
2567 aros_plain_nm="${prefix}${toolchain_nm}"
2568 aros_plain_ar="${prefix}${toolchain_ar}"
2570 AC_ARG_ENABLE(includes,
2571 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2572 [aros_target_incl=$enable_includes], [aros_target_incl=no])
2574 if test "x$aros_target_incl" = "xno"; then
2575     if test "x$test_kernel_cc" != "xno"; then
2576         aros_target_incl=`$aros_kernel_cc -print-sysroot 2>/dev/null`/`$aros_kernel_cc --print-sysroot-headers-suffix 2>/dev/null || echo usr/include`
2577     else
2578         aros_target_incl=
2579     fi
2582 if test "x$aros_kernel_includes" = "x"; then
2583     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2584         if test "x$aros_target_incl" != "x"; then
2585             aros_kernel_includes="-isystem $aros_target_incl"
2586         fi
2587     fi
2590 if test "x$test_kernel_cc" != "xno"; then
2591     if test "$aros_kernel_includes" != "" ; then
2592         dnl find out about the kernel cc's include path
2593         AC_MSG_CHECKING([for the kernel compiler's include path])
2594         if test "$aros_kernel_cc_includes" = "" ; then
2595             # Try to guess where the directory is.
2596             aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2597             if test -d $aros_kernel_cc_includes; then
2598                 # Check if there is also an include-fixed directory and add it
2599                 # to kernel compiler's include path as it may contain some of
2600                 # the headers we need.
2601                 if test -d "$aros_kernel_cc_includes"-fixed; then
2602                     aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2603                 fi
2604                 # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2605                 if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2606                     aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2607                 fi
2608             else
2609                 # The directory doesn't exist, we need to do some more work.
2610                 aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2612                 # These are the headers we're looking for.
2613                 headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2614                          stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2615                          zutil.h stdint.h"
2617                 dirs=
2618                 for h in $headers; do
2619                     # Which other headers are needed by each of the above?
2620                     deps=$(echo "#include <$h>" | \
2621                            $aros_kernel_cc -E -M - 2>/dev/null | \
2622                            sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2624                     # Copy all the needed headers to a directory beneath gendir.
2625                     for d in $deps; do
2626                         h=$(basename $d)
2627                         dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2628                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2629                         ! test -d $dir && mkdir -p $dir
2630                         ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2631                     done
2632                 done            
2633             fi
2634         fi
2635         AC_MSG_RESULT($aros_kernel_cc_includes)
2636         # Adding -nostdinc to kernel includes as they are always used together.
2637         aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2638     fi
2641 if test "$crosstools" != "yes"; then
2642     dnl find out about the target cc's include path
2643     AC_MSG_CHECKING([for the target compiler's include path])
2644     if test "$aros_target_cc_includes" = "" ; then
2645         #try to guess where the directory is
2646         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2647         if ! test -d $aros_target_cc_includes; then
2648             #the directory doesn't exist, we need to do some more work
2649             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2650         
2651             #these are the headers we're looking for
2652             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2653                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2654                     zutil.h"
2656             dirs=
2657             for h in $headers; do
2658                 #which other headers each of the above headers needs?
2659                 deps=$(echo "#include <$h>" | \
2660                     $orig_target_cc -E -M - 2>/dev/null | \
2661                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2662             
2663                 #copy all the needed headers to a directory beneath gendir
2664                 for d in $deps; do
2665                     h=$(basename $d)
2666                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2667                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2668                     ! test -d $dir && mkdir -p $dir
2669                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2670                 done
2671             done
2672         fi
2673     fi
2674     AC_MSG_RESULT($aros_target_cc_includes)
2675 else
2676     # We do not know which c compiler version we are going to build and what we need to know
2677     # here is different for different versions so this will be set later during the
2678     # build of crosstools.
2679     aros_target_cc_includes=@aros_target_cc_includes@
2683 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2684 # On GCC >= 4.0 -iquote should be used
2687 save_cc="$CC"
2688 save_cflags="$CFLAGS"
2689 if test "x$test_kernel_cc" != "xno"; then
2690     CFLAGS="-iquote."
2691     kernel_cflags_iquote=$host_cflags_iquote
2692     kernel_cflags_iquote_end=$host_cflags_iquote_end
2693     if test "x-$cross_compiling" = "x-yes"; then
2694         CC="$aros_kernel_cc"
2695         AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2696         if test "x-$crosstools" != "x-yes"; then
2697             AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2698         else
2699             # we do know it is supported for the smallest version of gcc we are going to build
2700             # we assume it's also supported by later versions
2701             use_no_stack_protector=yes
2702         fi
2703         AC_MSG_RESULT($use_no_stack_protector)
2704         AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2705         if test "x-$crosstools" != "x-yes"; then
2706             AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2707         else
2708             # we do know it is supported for the smallest version of gcc we are going to build
2709             # we assume it's also supported by later versions
2710             has_iquote=yes
2711         fi
2712         AC_MSG_RESULT($has_iquote)
2713         if test "x-$has_iquote" = "x-yes" ; then
2714             kernel_cflags_iquote=-iquote
2715             kernel_cflags_iquote_end=
2716         else
2717             kernel_cflags_iquote=-I
2718             kernel_cflags_iquote_end=-I-
2719         fi
2720     fi
2721     if test "x-$use_no_stack_protector" = "x-yes" ; then
2722         aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2723     fi
2725     #-----------------------------------------------------------------------------
2727     # Check if we can explicitly choose older version of symbol hashing
2729     CFLAGS="save_cflags -Wl,--hash-style=sysv"
2730     CC="$aros_kernel_cc"
2731     AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2732     AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2733     AC_MSG_RESULT($use_hash_style)
2734     if test "x-$use_hash_style" = "x-yes" ; then
2735         aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2736     fi
2737 else
2738     kernel_cflags_iquote="$""(CFLAGS_IQUOTE)"
2739     kernel_cflags_iquote_end="$""(CFLAGS_IQUOTE_END)"
2741 CC="$save_cc"
2742 CFLAGS="$save_cflags"
2744 AC_SUBST(host_cflags_iquote)
2745 AC_SUBST(host_cflags_iquote_end)
2746 AC_SUBST(kernel_cflags_iquote)
2747 AC_SUBST(kernel_cflags_iquote_end)
2750 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2751 AC_MSG_CHECKING([for default resolution of WBScreen])
2752 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2753 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2754 if test "$resolution" = "yes" ; then
2755     resolution="none"
2757 if test "$resolution" = "no" ; then
2758     resolution="none"
2760 if test "$resolution" != "none" ; then
2761     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2762     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2763     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2765 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2766 aros_cv_nominal_width=$aros_nominal_width
2767 aros_cv_nominal_height=$aros_nominal_height
2768 aros_cv_nominal_depth=$aros_nominal_depth
2770 dnl See if the user wants the serial debug output for native flavour
2771 AC_MSG_CHECKING([whether serial debug is enabled])
2772 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)
2773 if test "$aros_serial_debug" = 0 ; then
2774     serial_debug_forced=""
2775     if test "$serial_debug" = "yes" ; then
2776         serial_debug="1"
2777     fi
2778     if test "$serial_debug" = "no" ; then
2779         serial_debug="none"
2780     fi
2781 else
2782     serial_debug_forced="(forced)"
2783     serial_debug=$aros_serial_debug
2785 if test "$serial_debug" != "none" ; then
2786     aros_serial_debug=$serial_debug
2787     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2788 else
2789     AC_MSG_RESULT(no)
2792 dnl See if the user wants the palm debug output hack for palm native flavour
2793 AC_MSG_CHECKING([whether palm debug hack is enabled])
2794 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")
2795 if test "$palm_debug_hack" = "yes" ; then
2796     aros_palm_debug_hack="1"
2798 AC_MSG_RESULT($palm_debug_hack)
2800 dnl See if dev wants the usb3.0 code
2801 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2802 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2803 if test "$usb30_code" = "yes" ; then
2804     aros_config_cppflags="$aros_config_cppflags -DAROS_USB30_CODE"
2805     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2807 AC_MSG_RESULT($usb30_code)
2809 dnl See if the user wants nesting supervisor activated for unix flavour
2810 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2811 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")
2812 if test "$nesting_supervisor" = "yes" ; then
2813     aros_nesting_supervisor="1"
2815 AC_MSG_RESULT($nesting_supervisor)
2817 dnl See if the user wants to disable MMU support
2818 dnl This can be overriden on per-target basis,
2819 dnl set $aros_enable_mmu to "yes" or "no" to do this
2820 if test "$aros_enable_mmu" = "" ; then
2821     AC_MSG_CHECKING([whether MMU support is enabled])
2822     dnl Enabled by default
2823     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2824     if test "$aros_enable_mmu" = "" ; then
2825         aros_enable_mmu="yes"
2826     fi
2827     AC_MSG_RESULT($aros_enable_mmu)
2829 if test "$aros_enable_mmu" = "no" ; then
2830     aros_enable_mmu="0"
2831 else
2832     aros_enable_mmu="1"
2834     
2836 dnl things specifically required for hosted flavours
2837 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2839     if test "x-$need_dlopen" != "x-no" ; then
2840       save_libs="$LIBS"
2841       LIBS=""
2842       dnl some kind of dynamic library access system is required for hostlib.resource
2843       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2844       if test "x-$have_dl" = "x-no" ; then
2845           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2846                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2847                                     have_dl="no")
2848       fi
2849       if test "x-$have_dl" = "x-no" ; then
2850           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2851       fi
2852       LIBS="$save_libs"
2853     fi
2856     dnl x11 hidd
2857     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2858                                            [build X11 hidd for hosted (default=auto)]),
2859                                            x11_hidd="$enableval",
2860                                            x11_hidd="$need_x11")
2861     case "x-$x11_hidd" in
2862         x-yes|x-no|x-auto)                 ;;
2863         *)                 x11_hidd="$need_x11" ;;
2864     esac
2866     ENABLE_X11=0
2868     dnl they want it
2869     if test "x-$x11_hidd" != "x-no" ; then
2871         dnl find x11 stuff
2872         AC_PATH_X
2874         if test -n "$x_includes"; then
2875             X_CFLAGS="$X_CFLAGS -I$x_includes"
2876         fi
2878         if test -n "$x_libraries"; then
2879             X_LIBS="$X_LIBS -L$x_libraries"
2880         fi
2882         if test "x-$no_x" = "x-yes" ; then
2884             dnl didn't find it
2885             if test "x-$x11_hidd" != "x-auto" ; then
2886                 dnl and they explicitly asked for it, bail out
2887                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2888             fi
2889         
2890         else
2891             dnl found it, setup the metatarget
2892             aros_target_options+="$export_newline""# Enable X11 Gfx Driver$export_newline""OPT_HOST_X11GFX               := yes$export_newline"
2893             if test "x-$host_feature_glx" != "x-no" ; then
2894                 aros_target_options+="$export_newline""# Enable X11 HostGL 3D Passthrough$export_newline""OPT_HOST_X11_HOSTGL           := yes$export_newline"
2895             fi
2896             ENABLE_X11=1
2898             aros_host_x11_cflags="$X_CFLAGS"
2899             aros_host_x11_ldflags="$X_LIBS  -lX11"
2901             dnl setup shared memory extensions
2902             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2903                                                   [use X11 shared memory (default=auto)]),
2904                                                   x11_hidd_shm="$enableval",
2905                                                   x11_hidd_shm="auto")
2906             case "x-$x11_hidd_shm" in
2907                 x-yes|x-no|x-auto)                     ;;
2908                 *)                 x11_hidd_shm="auto" ;;
2909             esac
2911             have_xshm=no
2913             dnl they want it
2914             if test "x-$x11_hidd_shm" != "x-no" ; then
2916                 dnl system shm headers
2917                 AC_CHECK_HEADERS(sys/ipc.h)
2918                 AC_CHECK_HEADERS(sys/shm.h)
2920                 dnl got them
2921                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2923                     dnl make sure X libs have shm functions
2924                     save_cflags="$CFLAGS"
2925                     save_ldflags="$LDFLAGS"
2926                     CFLAGS="$CFLAGS $X_CFLAGS"
2927                     LDFLAGS="$LDFLAGS $X_LIBS"
2928                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2929                     CFLAGS="$save_cflags"
2930                     LDFLAGS="$save_ldflags"
2931                 fi
2932             fi
2934             dnl detection done, prepare output
2935             if test "x-$have_xshm" = "x-yes" ; then
2936                 dnl we can do shm
2937                 DO_XSHM_SUPPORT="1"
2938             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2939                 dnl they explicitly asked for it, but we can't do it
2940                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2941             else
2942                 dnl otherwise just disable it
2943                 DO_XSHM_SUPPORT="0"
2944             fi
2946             
2947             dnl setup vidmode (fullscreen) extensions
2948             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2949                                                       [use X11 vidmode extension (default=auto)]),
2950                                                       x11_hidd_vidmode="$enableval",
2951                                                       x11_hidd_vidmode="auto")
2952             case "x-$x11_hidd_vidmode" in
2953                 x-yes|x-no|x-auto)                         ;;
2954                 *)                 x11_hidd_vidmode="auto" ;;
2955             esac
2957             have_vidmode=no
2959             dnl they want it
2960             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2962                 dnl make sure X libs have vidmode functions
2963                 save_cflags="$CFLAGS"
2964                 save_ldflags="$LDFLAGS"
2965                 CFLAGS="$CFLAGS $X_CFLAGS"
2966                 LDFLAGS="$LDFLAGS $X_LIBS"
2967                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2968                 CFLAGS="$save_cflags"
2969                 LDFLAGS="$save_ldflags"
2970             fi
2972             dnl detection done, prepare output
2973             if test "x-$have_vidmode" = "x-yes" ; then
2974                 dnl we can do vidmode
2975                 DO_VIDMODE_SUPPORT="1"
2976             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2977                 dnl they explicitly asked for it, but we can't do it
2978                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2979             else
2980                 dnl otherwise just disable it
2981                 DO_VIDMODE_SUPPORT="0"
2982             fi
2983         fi
2984     fi
2986     dnl sdl hidd
2987     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2988                                            [build SDL hidd for hosted (default=auto)]),
2989                                            sdl_hidd="$enableval",
2990                                            sdl_hidd="auto")
2991     case "x-$sdl_hidd" in
2992         x-yes|x-no|x-auto)                 ;;
2993         *)                 sdl_hidd="auto" ;;
2994     esac
2996     dnl they want it
2997     if test "x-$sdl_hidd" != "x-no" ; then
2999         dnl find sdl
3000         SDL_VERSION=1.2.5
3001         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
3002             [have_sdl="no"])
3004         if test "x-$have_sdl" != "x-yes" ; then
3006             dnl didn't find it
3007             if test "x-$sdl_hidd" != "x-auto" ; then
3008                 dnl and they explicitly asked for it, bail out
3009                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
3010             fi
3012         else
3013             dnl found it, enable the build
3014             aros_target_options+="$export_newline""# Enable SDL Gfx Driver$export_newline""OPT_HOST_SDLGFX               := yes$export_newline"
3015             aros_host_sdl_cflags=$SDL_CFLAGS
3016             aros_host_sdl_libs=$SDL_LIBS
3017         fi
3018     fi
3023 dnl See if the user wants dbus.library
3024 AC_MSG_CHECKING([whether building of dbus.library is enabled])
3025 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
3026 if test "$dbus" = "yes" ; then
3027     ENABLE_DBUS=1
3028     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
3029     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
3030     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
3031     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
3032 else
3033     ENABLE_DBUS=0
3035 AC_MSG_RESULT($dbus)
3037 if test "$use_kernel_cc_wrapper" = "yes" ; then
3038     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
3041 aros_kernel_cppflags=$aros_config_cppflags
3042 aros_optimization_cflags="$optimization_level"
3043 if test "$optimization" = "default"; then
3044 AC_MSG_CHECKING([default optimization level to use])
3045 AC_MSG_RESULT($optimization_level)
3048 if ! test "$gcc_default_cpu" = "" ; then
3049     target_extra_cfg+="$export_newline""# ARM gcc default target$export_newline""GCC_DEFAULT_CPU         := $gcc_default_cpu$export_newline""GCC_DEFAULT_FPU         := $gcc_default_fpu$export_newline""GCC_DEFAULT_FLOAT_ABI   := $gcc_default_float_abi$export_newline""GCC_DEFAULT_MODE        := $gcc_default_mode$export_newline"
3052 if test "$use_libatomic" = "yes" ; then
3053     aros_cxx_libs="$aros_cxx_libs  -latomic"
3056 dnl --------------------------------------------------------------------
3057 dnl Configuration Output Section
3058 dnl --------------------------------------------------------------------
3060 # Generic
3061 AC_SUBST(aros_arch)
3062 AC_SUBST(aros_cpu)
3063 AC_SUBST(aros_flavour)
3064 AC_SUBST(aros_flavour_uc)
3065 AC_SUBST(aros_target_toolchain)
3066 AC_SUBST(aros_toolchain_ld)
3067 AC_SUBST(aros_build_host)
3068 AC_SUBST(AROS_BUILDDIR)
3069 AC_SUBST(AROS_BUILDDIR_UNIX)
3070 AC_SUBST(SRCDIR)
3071 AC_SUBST(AROS_CROSSTOOLSDIR)
3072 AC_SUBST(AROS_PORTSSRCDIR)
3074 # Compatability with other Amiga-like operating systems
3075 AC_SUBST(aros_amigaos_compliance)
3077 # Host Related ###########################
3078 AC_SUBST(host_stat_h__unused_used)
3079 AC_SUBST(ax_cv_flex_version)
3080 AC_SUBST(host_extra_cfg)
3081 AC_SUBST(aros_cc_pre)
3082 AC_SUBST(aros_host_strip)
3083 AC_SUBST(aros_host_arch)
3084 AC_SUBST(aros_host_cpu)
3085 AC_SUBST(aros_host_cpp)
3086 AC_SUBST(aros_host_def_cc)
3087 AC_SUBST(aros_host_cc)
3088 AC_SUBST(aros_host_cxx)
3089 AC_SUBST(aros_host_ar)
3090 AC_SUBST(aros_host_ranlib)
3091 AC_SUBST(aros_host_ld)
3092 AC_SUBST(aros_host_make)
3093 AC_SUBST(aros_host_cppflags)
3094 AC_SUBST(aros_host_cflags)
3095 AC_SUBST(aros_host_cxxflags)
3096 AC_SUBST(gnu89_inline)
3097 AC_SUBST(aros_host_ldflags)
3098 AC_SUBST(aros_host_debug)
3099 AC_SUBST(aros_host_mkdep)
3100 AC_SUBST(aros_host_mkargs)
3101 AC_SUBST(aros_host_exe_suffix)
3102 AC_SUBST(aros_host_lib_suffix)
3103 AC_SUBST(aros_tools_dir)
3104 AC_SUBST(aros_host_aclocal)
3105 AC_SUBST(aros_host_autoconf)
3106 AC_SUBST(aros_host_autoheader)
3107 AC_SUBST(aros_host_automake)
3109 # Target Related #########################
3110 AC_SUBST(aros_elf_translate)
3111 AC_SUBST(make_extra_commands)
3112 AC_SUBST(make_extra_targetcfg)
3113 AC_SUBST(target_extra_cfg)
3114 AC_SUBST(aros_target_options)
3116 AC_SUBST(aros_target_guitheme)
3117 AC_SUBST(aros_target_iconset)
3118 AC_SUBST(aros_target_bootloader)
3119 AC_SUBST(aros_target_arch)
3120 AC_SUBST(aros_target_family)
3121 AC_SUBST(aros_target_cpu)
3122 AC_SUBST(aros_target_cpu_mode)
3123 AC_SUBST(aros_target_variant)
3124 AC_SUBST(aros_target_suffix)
3125 AC_SUBST(aros_target_ar)
3126 AC_SUBST(aros_target_ranlib)
3127 AC_SUBST(aros_plain_nm)
3128 AC_SUBST(aros_plain_ar)
3129 AC_SUBST(aros_kernel_ar)
3130 AC_SUBST(aros_kernel_ranlib)
3131 AC_SUBST(orig_target_cc)
3132 AC_SUBST(aros_target_cc)
3133 AC_SUBST(aros_kernel_cc)
3134 AC_SUBST(orig_target_cxx)
3135 AC_SUBST(aros_target_cxx)
3136 AC_SUBST(aros_kernel_cxx)
3137 AC_SUBST(orig_target_cpp)
3138 AC_SUBST(aros_target_cpp)
3139 AC_SUBST(aros_kernel_cpp)
3140 AC_SUBST(orig_target_as)
3141 AC_SUBST(aros_target_as)
3142 AC_SUBST(aros_kernel_as)
3143 AC_SUBST(orig_target_ld)
3144 AC_SUBST(aros_target_ld)
3145 AC_SUBST(aros_kernel_ld)
3146 AC_SUBST(aros_target_cc_includes)
3147 AC_SUBST(aros_target_cc_path)
3148 AC_SUBST(aros_target_objdump)
3149 AC_SUBST(aros_target_objcopy)
3150 AC_SUBST(aros_target_strip)
3151 AC_SUBST(aros_target_nm)
3152 AC_SUBST(aros_kernel_rescomp)
3153 AC_SUBST(aros_shared_default)
3154 AC_SUBST(aros_shared_ld)
3155 AC_SUBST(aros_object_format)
3156 AC_SUBST(spec_obj_format)
3157 AC_SUBST(aros_c_libs)
3158 AC_SUBST(aros_cxx_libs)
3160 AC_SUBST(aros_shared_cflags)
3161 AC_SUBST(aros_shared_aflags)
3162 AC_SUBST(aros_shared_ldflags)
3164 AC_SUBST(aros_warn_flags)
3165 AC_SUBST(aros_nowarn_flags)
3166 AC_SUBST(aros_config_cppflags)
3167 AC_SUBST(aros_config_cflags)
3168 AC_SUBST(aros_config_cxxflags)
3169 AC_SUBST(aros_config_aflags)
3170 AC_SUBST(aros_config_ldflags)
3172 AC_SUBST(aros_kernel_sysroot)
3173 AC_SUBST(aros_kernel_cppflags)
3174 AC_SUBST(aros_kernel_cflags)
3175 AC_SUBST(aros_kernel_includes)
3176 AC_SUBST(aros_kernel_objcflags)
3177 AC_SUBST(aros_kernel_ldflags)
3178 AC_SUBST(aros_debug_cppflags)
3179 AC_SUBST(aros_debug_cflags)
3180 AC_SUBST(aros_debug_cxxflags)
3181 AC_SUBST(aros_debug_aflags)
3182 AC_SUBST(aros_debug_ldflags)
3183 AC_SUBST(aros_target_genmap)
3184 AC_SUBST(aros_target_strip_flags)
3185 AC_SUBST(aros_config_lto)
3186 AC_SUBST(aros_config_coverage)
3187 AC_SUBST(aros_optimization_cflags)
3188 AC_SUBST(aros_isa_extra)
3189 AC_SUBST(aros_isa_flags)
3191 AC_SUBST(crosstools_target)
3192 AC_SUBST(crosstools_cxx_target)
3194 AC_SUBST(use_libatomic)
3196 AC_SUBST(pci_hidd_target)
3198 AC_SUBST(aros_nominal_width)
3199 AC_SUBST(aros_nominal_height)
3200 AC_SUBST(aros_nominal_depth)
3202 # Native version related
3203 AC_SUBST(aros_serial_debug)
3204 AC_SUBST(PLATFORM_EXECSMP)
3205 AC_SUBST(ENABLE_EXECSMP)
3207 # MMU related
3208 AC_SUBST(aros_enable_mmu)
3210 # Bootloader related
3211 AC_SUBST(target_grub2_version)
3213 # Unix/Hosted version related
3214 AC_SUBST(aros_nesting_supervisor)
3216 # ARM default GCC target related
3217 AC_SUBST(gcc_default_cpu)
3218 AC_SUBST(gcc_default_cpu_tune)
3219 AC_SUBST(gcc_default_fpu)
3220 AC_SUBST(gcc_default_float_abi)
3221 AC_SUBST(gcc_default_mode)
3223 # Palm native version related
3224 AC_SUBST(aros_palm_debug_hack)
3226 # Apple iOS related
3227 AC_SUBST(aros_ios_platform)
3228 AC_SUBST(aros_ios_version)
3229 AC_SUBST(aros_ios_sdk)
3231 # Android related
3232 AC_SUBST(ant)
3233 AC_SUBST(android_tool)
3234 AC_SUBST(aros_android_level)
3235 AC_SUBST(aros_android_antapk)
3237 # Debug related
3238 AC_SUBST(aros_debug)
3239 AC_SUBST(aros_mungwall_debug)
3240 AC_SUBST(aros_stack_debug)
3241 AC_SUBST(aros_modules_debug)
3243 # Collect-aros stuff: "-ius" to ignore undefined symbols
3244 AC_SUBST(ignore_undefined_symbols)
3246 # C compiler related
3247 AC_SUBST(gcc_target_cpu)
3248 AC_SUBST(target_binutils_version)
3249 AC_SUBST(target_gcc_version)
3251 #ObjC compiler related
3252 AC_SUBST(objc_target)
3254 #Java related
3255 AC_SUBST(java_target)
3257 # DBUS related
3258 AC_SUBST(ENABLE_DBUS)
3259 AC_SUBST(DBUS_CFLAGS)
3260 AC_SUBST(DBUS_LIBFLAGS)
3261 AC_SUBST(KERNEL_DBUS_KOBJ)
3262 AC_SUBST(KERNEL_DBUS_INCLUDES)
3264 #X11 related
3265 AC_SUBST(ENABLE_X11)
3266 AC_SUBST(DO_XSHM_SUPPORT)
3267 AC_SUBST(DO_VIDMODE_SUPPORT)
3269 AC_SUBST(aros_host_x11_cflags)
3270 AC_SUBST(aros_host_x11_ldflags)
3272 #X11 related
3273 AC_SUBST(aros_host_sdl_cflags)
3274 AC_SUBST(aros_host_sdl_libs)
3276 # USB3.0 code
3277 AC_SUBST(aros_usb30_code)
3279 dnl Prepare for output, make up all the generated patches
3280 case "$aros_flavour" in
3281 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3282                 aros_flavour="emulation" ;;
3283 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3284                 aros_flavour="emulation" ;;
3285 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3286                 aros_flavour="standalone";;
3287 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3288                 aros_flavour="standalone";;
3289 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3290                 aros_flavour="native" ;;
3291 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3292                 aros_flavour="native" ;;
3293 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3294                 aros_flavour="linklib" ;;
3295 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3296                 aros_flavour="palmnative" ;;
3297 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3298                 aros_flavour="mac68knative" ;;
3299 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3300                 aros_flavour="ppcnative" ;;
3301 esac
3303 if test ! -d ${aros_inc_dir} ; then
3304     ${MKDIR} ${aros_inc_dir}
3306 if test ! -d ${aros_geninc_dir} ; then
3307     ${MKDIR} ${aros_geninc_dir}
3309 if test ! -d ${aros_hostcfg_dir} ; then
3310     ${MKDIR} ${aros_hostcfg_dir}
3312 if test ! -d ${aros_targetcfg_dir} ; then
3313     ${MKDIR} ${aros_targetcfg_dir}
3315 if test ! -d ${aros_tools_dir} ; then
3316     ${MKDIR} ${aros_tools_dir}
3318 if test ! -d ${aros_scripts_dir} ; then
3319     ${MKDIR} ${aros_scripts_dir}
3322 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3324 # Generic build tools (metamake, etc)
3325 AC_CONFIG_COMMANDS([genmf-executable-support],
3326     [
3327         chmod a+x ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname
3328         chmod a+x ${aros_tools_dir}/genmf.py
3329     ],
3330     [
3331         AROS_CROSSTOOLSDIR=${AROS_CROSSTOOLSDIR}
3332         aros_tools_dir=${aros_tools_dir}
3333     ]
3335 AC_CONFIG_FILES(
3336     Makefile
3337     config/make.cfg
3338     ${aros_inc_dir}/config.h:config/config.h.in
3339     ${aros_geninc_dir}/config.h:config/config.h.in
3340     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3341     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3342     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3343     mmake.config
3344     compiler/include/geninc.cfg:compiler/include/geninc.cfg.in
3345     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3346     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3347     ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname:scripts/uname.in
3348     tools/collect-aros/env.h
3351 # Binutils
3352 AC_CONFIG_COMMANDS([binutils-support],
3353     [
3354         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3355         mkdir -p $prefix
3356         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3358         chmod a+x ${prefix2}-ld
3360         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3361         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3362         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3363         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3364         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3365         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3366         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3367     ],
3368     [
3369         aros_host_exe_suffix=${aros_host_exe_suffix}
3370         aros_tools_dir=${aros_tools_dir}
3371         aros_target_cpu=${aros_target_cpu}
3372         aros_target_arch=${aros_target_arch}
3373         aros_target_suffix=${aros_target_suffix}
3374         orig_target_nm=${orig_target_nm}
3375         orig_target_as=${orig_target_as}
3376         orig_target_ar=${orig_target_ar}
3377         orig_target_ranlib=${orig_target_ranlib}
3378         orig_target_objdump=${orig_target_objdump}
3379         orig_target_objcopy=${orig_target_objcopy}
3380         orig_target_strip=${orig_target_strip}
3381         aros_kernel_ld=${aros_kernel_ld}
3382     ]
3384 if test "${use_ld_wrapper}" = "yes"; then
3385     AC_CONFIG_FILES(
3386         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3387     )
3389 # Bare Elf support script and spec
3390 if test "${use_kernel_cc_wrapper}" = "yes"; then
3391     AC_CONFIG_COMMANDS([elf-compiler-support],
3392         [
3393             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3394             mkdir -p $prefix
3395             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3397             chmod a+x ${prefix2}-gcc
3399             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3400         ],
3401         [
3402             aros_host_exe_suffix=${aros_host_exe_suffix}
3403             aros_tools_dir=${aros_tools_dir}
3404             aros_target_cpu=${aros_target_cpu}
3405             aros_target_arch=${aros_target_arch}
3406             aros_target_suffix=${aros_target_suffix}
3407             aros_kernel_ld=${aros_kernel_ld}
3408         ]
3409     )
3410     AC_CONFIG_FILES(
3411         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3412         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3413     )
3416 # Host compiler support scripts and spec
3417 if test "${aros_target_toolchain}" = "no"; then
3418     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3419         [
3420             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3421             mkdir -p $prefix
3422             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3424             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3425         ],
3426         [
3427             aros_host_exe_suffix=${aros_host_exe_suffix}
3428             aros_tools_dir=${aros_tools_dir}
3429             aros_target_cpu=${aros_target_cpu}
3430             aros_target_arch=${aros_target_arch}
3431             aros_target_suffix=${aros_target_suffix}
3432         ]
3433     )
3434     AC_CONFIG_FILES(
3435         ${aros_targetcfg_dir}/specs:config/specs.in
3436         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3437         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3438         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3439     )
3442 # Android support
3443 if test "$aros_target_variant" == "android"; then
3444     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3447 # cmake helper
3448 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3450 AC_OUTPUT
3452 dnl This is in order to not define SHARED_CFLAGS sometimes
3453 dnl We don't always do aros_shared_ar, aros_shared_cflags
3455 #XXX compatability...
3456 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3458 if test -n "$aros_shared_cflags" ; then
3459     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3460     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg