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