use toolchain defined default optimization levels
[AROS.git] / configure.in
blob4bdc92542b45857d3ee598b669fee98dc6a49fbc
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         toolchain_def_opt_lvl="-O2"
814         toolchain_debug_opt_lvl="-O0"
815         toolchain_size_opt_lvl="-Os"
816         ;;
817     *gnu*)
818         toolchain_c_compiler="gcc"
819         toolchain_cxx_compiler="g++"
820         toolchain_cpp_preprocessor="gcc"
821         toolchain_cpp_opts=" -E"
822         toolchain_as="as"
823         aros_ld="ld"
824         if test "$aros_config_lto" != "yes"; then
825             toolchain_ld="ld"
826             toolchain_ar="ar"
827             toolchain_ranlib="ranlib"
828             toolchain_nm="nm"
829         else
830             toolchain_ld="ld.bfd"
831             toolchain_ar="gcc-ar"
832             toolchain_ranlib="gcc-ranlib"
833             toolchain_nm="gcc-nm"
834         fi
835         toolchain_strip="strip"
836         toolchain_objcopy="objcopy"
837         toolchain_objdump="objdump"
838         use_libatomic=yes
839         toolchain_def_opt_lvl="-O2"
840         toolchain_debug_opt_lvl="-O0"
841         toolchain_size_opt_lvl="-Os"
842         ;;
843     *)
844         AC_MSG_WARN("Unknown toolchain family!")
845         toolchain_c_compiler="cc"
846         toolchain_cxx_compiler="c++"
847         toolchain_cpp_preprocessor="cpp"
848         toolchain_cpp_opts=
849         toolchain_ld="ld"
850         aros_ld="ld"
851         toolchain_as="as"
852         toolchain_ar="ar"
853         toolchain_ranlib="ranlib"
854         toolchain_nm="nm"
855         toolchain_strip="strip"
856         toolchain_objcopy="objcopy"
857         toolchain_objdump="objdump"
858         ;;
859 esac
861 #-----------------------------------------------------------------------------
863 AC_MSG_CHECKING([which type of build to do])
864 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")
866 if test "$build_type" = "nightly"; then
867     build_type_string="NIGHTLY"
868 elif test "$build_type" = "snapshot"; then
869     build_type_string="SNAPSHOT"
870 elif test "$build_type" = "milestone"; then
871     build_type_string="MILESTONE"
872 elif test "$build_type" = "release"; then
873     build_type_string="RELEASE"
874 else
875     build_type_string="PERSONAL"
876     build_type="personal"
879 aros_config_cppflags="$aros_config_cppflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
881 AC_MSG_RESULT($build_type)
883 #-----------------------------------------------------------------------------
884 all_debug_types="messages stack modules mungwall symbols"
886 AC_MSG_CHECKING([which debug types to enable])
887 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)]),
888  debug="$enableval",debug="")
890 if test "$debug" = "" -o "$debug" = "no"; then
891     debug="none"
892 elif test "$debug" = "yes"; then
893     debug="all"
896 if test "$debug" = "all" ; then
897     debug="messages stack modules symbols"
898     for d in $all_debug_types; do
899         export aros_${d}_debug="1"
900     done
901 else
902     for d in $all_debug_types; do
903         export aros_${d}_debug="0"
904     done
907 if test "$debug" != "none"; then
908     debug=`echo $debug | sed s/,/\ /g`
909     for d in $debug; do
910         found="0"
911         for d2 in $all_debug_types; do
912             if test "$d2" = "$d"; then
913                 found="1"
914                 break
915             fi
916         done
917         if test "$found" = "0"; then
918             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
919         fi
920         export aros_${d}_debug="1"
921     done
922     aros_debug="yes"
924 AC_MSG_RESULT($debug)
926 if test "$aros_messages_debug" = "1"; then
927     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
928 else
929     aros_messages_debug=""
931 if test "$aros_symbols_debug" = "1"; then
932     aros_symbols_debug="-g"
933 else
934     aros_symbols_debug=""
937 # These are the flags to pass when compiling debugged programs
938 aros_debug_cppflags="$aros_messages_debug"
939 aros_debug_cflags="$aros_symbols_debug"
940 aros_debug_cxxflags=
941 aros_debug_aflags=""
942 aros_debug_ldflags="$aros_symbols_debug"
944 #-----------------------------------------------------------------------------
945 #   Checking for distcc and ccache.
947 #   Always apply the transforms in this particular order. Basically you should
948 #   always run 'ccache distcc compiler' in that order for the best performance.
950 AC_MSG_CHECKING([whether to enable distcc])
951 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
952 if test "$distcc" != "" -a "$distcc" != "no"; then
953     # AC_CHECK_PROG will print out the result in this case
954     AC_PATH_PROG(DISTCC,[distcc],distcc,)
955 else
956     AC_MSG_RESULT(no)
959 AC_MSG_CHECKING([whether to enable ccache])
960 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
961 if test "$ccache" != "" -a "$ccache" != "no"; then
962     # AC_CHECK_PROG will print out the result in this case
963     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
964 else
965     AC_MSG_RESULT(no)
968 #-----------------------------------------------------------------------------
969 AC_MSG_CHECKING([what specific host gcc version to use])
970 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="")
971 if test "$kernel_tool_version" != "" ; then
972     msg_result=$kernel_tool_version
973 else
974     msg_result="default"
976 AC_MSG_RESULT($msg_result)
978 #-----------------------------------------------------------------------------
979 AC_MSG_CHECKING([what optimization flags to use])
980 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")
981 if test "$optimization_level" = "unknown"; then
982     dnl use the toolchain defaults for normal and debug builds
983     optimization="default"
984     if test "$debug" != "none"; then
985         optimization_level=$toolchain_debug_opt_lvl
986     else
987         optimization_level=$toolchain_def_opt_lvl
988     fi
989 else
990     optimization="$optimization_level"
992 AC_MSG_RESULT($optimization)
994 paranoia_default=yes
995 #-----------------------------------------------------------------------------
996 AC_MSG_CHECKING([which paranoia flags to use])
997 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"])
998 if test "$paranoia_flags" = "no"; then
999         paranoia_flags="$""(WARN_ALL) -Werror-implicit-function-declaration"
1000         msg_result="none"
1001 else
1002     if test "$paranoia_flags" = "yes"; then
1003         paranoia_flags="$""(WARN_ALL) $""(WARN_ERROR)"
1004     fi
1005     msg_result="$paranoia_flags"
1007 AC_MSG_RESULT($msg_result)
1008 aros_warn_flags="$aros_warn_flags $paranoia_flags"
1010 #-----------------------------------------------------------------------------
1011 AC_MSG_CHECKING([what target variant to enable])
1012 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
1013 if test "$target_variant" = ""; then
1014     aros_target_variant=""
1015     aros_target_suffix=""
1016     enableval="none"
1017 else
1018     aros_target_variant="$target_variant"
1019     aros_target_suffix="-$target_variant"
1021 AC_MSG_RESULT($enableval)
1023 #-----------------------------------------------------------------------------
1024 # Target-specific defaults. You can override then on a per-target basis.
1026 # Bootloader name. Currently used by PC target.
1027 target_bootloader="none"
1028 PLATFORM_EXECSMP=
1029 ENABLE_EXECSMP=
1031 #-----------------------------------------------------------------------------
1032 # Additional options for some specific targets
1034 case "$aros_target_variant" in
1035 ios)
1036     AC_MSG_CHECKING([XCode path])
1037     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")
1038     AC_MSG_RESULT($aros_xcode_path)
1040     AC_MSG_CHECKING([what iOS SDK version to use])
1041     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")
1042     AC_MSG_RESULT($aros_sdk_version)
1044     ;;
1046 "android")
1047     AC_MSG_CHECKING([Android SDK path])
1048     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)
1049     AC_MSG_RESULT($aros_android_sdk)
1051     AC_MSG_CHECKING([Android NDK path])
1052     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
1053     AC_MSG_RESULT($aros_android_ndk)
1055     AC_MSG_CHECKING([what Android SDK version to use])
1056     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")
1057     AC_MSG_RESULT($aros_sdk_version)
1059     aros_android_level=android-$aros_sdk_version
1060     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
1061         echo "Platform $aros_android_level is not installed in your SDK"
1062         echo "Use --with-sdk-version=<API level number> to select another platform version"
1063         echo "You can check what plaform versions are installed in your SDK"
1064         echo "by examining contents of $aros_android_sdk/platforms directory"
1065         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
1066     fi
1068     export PATH="$aros_android_sdk/tools:$PATH"
1069     AC_PATH_PROG(android_tool, $android_tool)
1070     AROS_REQUIRED(android,$android_tool)
1072     if test "$aros_android_ndk" != "none"; then
1073         AC_MSG_CHECKING([what Android NDK version to use])
1074         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")
1075         AC_MSG_RESULT($aros_ndk_version)
1076     fi
1078     AC_PATH_PROG(ant, ant)
1079     if test "$ant" = ""; then
1080         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
1081     fi
1083     AC_MSG_CHECKING([Build debug or release apk])
1084     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)
1085     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
1086         AC_MSG_ERROR([apk-version has to be release or debug])
1087     fi
1088     AC_MSG_RESULT($aros_android_antapk)
1090     target_extra_cfg+="$export_newline""# Android$export_newline""AROS_ANDROID_ANTAPK           := $aros_android_antapk$export_newline"
1091     host_extra_cfg+="$export_newline""# Android-specific$export_newline""ANDROID                       := $android_tool$export_newline""ANT                                   := $ant$export_newline"
1092     aros_target_options+="$export_newline""# Enable Android Gfx Driver$export_newline""OPT_HOST_ANDROIDGFX           := yes$export_newline"
1094     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
1095     if test "$host_os" = "mingw32"; then
1096         android_tool="cmd //c $android_tool"
1097     fi
1099     need_dlopen="no"
1101     ;;
1102 esac
1104 #-----------------------------------------------------------------------------
1105 # External toolchains
1106 kernel_tool_prefix="none"
1107 aros_tool_prefix="none"
1108 elf_tool_prefix="${target_cpu}-elf-"
1110 # Base target cpu ISA configuration switch.
1111 case "$target_cpu" in
1112     *aarch64*)
1113         ;;
1114     *arm*)
1115         ;;
1116     *m68k*)
1117         m68k_isa_extra="ISA_MC68000_FLAGS             = -march=68000"
1118         m68k_020_isa_extra="ISA_MC68020_FLAGS             = -march=68020"
1119         m68k_030_isa_extra="ISA_MC68030_FLAGS             = -march=68030"
1120         m68k_040_isa_extra="ISA_MC68040_FLAGS             = -march=68040"
1121         m68k_060_isa_extra="ISA_MC68060_FLAGS             = -march=68060"
1122         m68k_ac080_isa_extra="ISA_AC68080_FLAGS             = -march=68040"
1123         m68k_020_ext="ISA_MC68020_EXT               :=020"
1124         m68k_030_ext="ISA_MC68030_EXT               :=030"
1125         m68k_040_ext="ISA_MC68040_EXT               :=040"
1126         m68k_060_ext="ISA_MC68060_EXT               :=060"
1127         m68k_020_cflags="ISA_MC68020_CFLAGS            ="
1128         m68k_030_cflags="ISA_MC68030_CFLAGS            ="
1129         m68k_040_cflags="ISA_MC68040_CFLAGS            ="
1130         m68k_060_cflags="ISA_MC68060_CFLAGS            ="
1131         m68k_020_cppflags="ISA_MC68020_CPPFLAGS          ="
1132         m68k_030_cppflags="ISA_MC68030_CPPFLAGS          ="
1133         m68k_040_cppflags="ISA_MC68040_CPPFLAGS          ="
1134         m68k_060_cppflags="ISA_MC68060_CPPFLAGS          ="
1135         m68k_020_ldflags="ISA_MC68020_LDFLAGS           ="
1136         m68k_030_ldflags="ISA_MC68030_LDFLAGS           ="
1137         m68k_040_ldflags="ISA_MC68040_LDFLAGS           ="
1138         m68k_060_ldflags="ISA_MC68060_LDFLAGS           ="
1139         ;;
1140     *x86_64* | *i?86*)
1141         x86_isa_extra="ISA_X86_FLAGS                 = -m32 -march=i486"
1142         x86_64_isa_extra="ISA_X8664_FLAGS               = -mcmodel=large"
1143         ;;
1144     *powerpc*)
1145         ;;
1146 esac
1148 # This is the target configuration switch.
1149 case "$target_os" in
1150     linux*)
1151         HOST_WANTS_X11=yes
1152         HOST_WANTS_GLX=yes
1153         HOST_WANTS_SDL=yes
1154         HOST_WANTS_DBUS=yes
1155         HOST_WANTS_DLOPEN=yes
1156         aros_target_arch="linux"
1157         aros_target_family="unix"
1158         case "$target_cpu" in
1159             *m68k*)
1160                 aros_target_cpu="m68k"
1161                 aros_object_format="m68kelf"
1162                 aros_flavour="emulcompat"
1163                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1164                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1165                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1166                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1167                 gcc_target_cpu="mc68000"
1168                 ;;
1169             *i?86*)
1170                 aros_target_cpu="i386"
1171                 aros_object_format="elf_i386"
1172                 aros_flavour="emulation"
1173                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1174                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1175                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1176                 aros_kernel_ldflags="-Wl,-melf_i386"
1177                 aros_nominal_depth=8
1178                 gcc_target_cpu="i386"
1179                 pci_hidd_target="hidd-pci-linux"
1180                 android_tool_dir_prefix="x86"
1181                 android_tool_prefix="i686-android-linux"
1182                 android_ndk_arch="x86"
1183                 ;;
1184             *x86_64*)
1185                 aros_target_cpu="x86_64"
1186                 aros_object_format="elf_x86_64"
1187                 aros_flavour="emulation"
1188                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1189                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1190                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1191                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1192                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1193                 aros_nominal_depth=8
1194                 pci_hidd_target="hidd-pci-linux"
1195                 ;;
1196             *powerpc*)
1197                 aros_target_cpu="ppc"
1198                 aros_object_format="elf32ppc"
1199                 aros_flavour="emulation"
1200                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1201                 aros_nominal_depth=8
1202                 gcc_target_cpu="ppc"
1203                 ;;
1204 # TODO
1205 # Same as powerpc, but I need this for the nightly build to work again.
1206 # Actually, the nightly should be made working with powerpc target.
1207 # That just was too much work for the moment, another week or two.
1208             *ppc*)
1209                 aros_target_cpu="ppc"
1210                 aros_object_format="elf32ppc"
1211                 aros_flavour="emulation"
1212                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1213                 aros_nominal_depth=8
1214                 gcc_target_cpu="ppc"
1215                 ;;
1216             *aarch64*)
1217                 aros_target_cpu="aarch64"
1218                 target_cpu="aarch64"
1219                 aros_object_format="aarch64elf_aros"
1220                 aros_flavour="emulation"
1221                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1222                 gcc_target_cpu="aarch64"
1223                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1224                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1225                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1226                 aros_c_libs="$aros_c_libs -laeabi"
1227                 gcc_default_float_abi="hard"
1228                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1229                 ;;
1230             *armhf*)
1231                 aros_target_cpu="arm"
1232                 target_cpu="arm"
1233                 aros_object_format="armelf_aros"
1234                 aros_flavour="emulation"
1235                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1236                 gcc_target_cpu="arm"
1237                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1238                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1239                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1240                 aros_c_libs="$aros_c_libs -laeabi"
1241                 gcc_default_float_abi="hard"
1242                 android_tool_dir_prefix="arm-linux-androideabi"
1243                 android_tool_prefix="arm-linux-androideabi"
1244                 android_ndk_arch="arm"
1245                 kernel_tool_prefix="arm-linux-gnueabihf-"
1246                 ;;
1247             *arm*)
1248                 aros_target_cpu="arm"
1249                 aros_object_format="armelf_aros"
1250                 aros_flavour="emulation"
1251                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1252                 gcc_target_cpu="arm"
1253                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1254                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1255                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1256                 aros_c_libs="$aros_c_libs -laeabi"
1257                 android_tool_dir_prefix="arm-linux-androideabi"
1258                 android_tool_prefix="arm-linux-androideabi"
1259                 android_ndk_arch="arm"
1260                 kernel_tool_prefix="arm-linux-gnueabi-"
1261                 ;;
1262             *)
1263                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1264                 ;;
1265         esac
1266         case "$aros_target_variant" in
1267             android)
1269                 dnl Not all Linux CPUs are supported by Android
1270                 if test "$android_ndk_arch" = ""; then
1271                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1272                 fi
1274                 aros_nominal_width=320
1275                 aros_nominal_height=480
1276                 if test "$aros_android_ndk" = "none"; then
1277                     dnl Use standalone toolchain, don't adjust paths
1278                     aros_kernel_cflags="-mandroid"
1279                     aros_kernel_ldflags="-mandroid"
1280                     CFLAGS="-mandroid"
1281                 else
1282                     dnl In Android NDK toolchains are placed in own directories,
1283                     dnl but tool names are not suffixed with version 
1284                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1285                     kernel_tool_version=""
1286                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1287                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1288                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1289                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1290                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1291                 fi
1292                 need_x11=no
1293                 # Disable implicit PIC mode
1294                 aros_config_cflags="$aros_config_cflags -fno-pic"
1295                 kernel_tool_prefix="$android_tool_prefix-"
1296             ;;
1297         esac
1298     ;;
1300     pc)
1301         aros_target_arch="pc"
1302         aros_shared_default="no"
1303         target_bootloader="grub2"
1304         case "$target_cpu" in
1305             *i?86*)
1306                 aros_target_cpu="i386"
1308                 dnl If somebody hasn't already set the target object
1309                 dnl format, then use this value. Mostly to support
1310                 dnl FreeBSD cross-compilation.
1311                 dnl TODO: Remove when we always use our compiler.
1313                 if test "$aros_object_format" = "" ; then
1314                     aros_object_format="elf_i386"
1315                 fi
1316                 aros_flavour="standalone"
1317                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1318                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1319                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1320                 aros_kernel_ldflags="-Wl,-melf_i386"
1321                 aros_nominal_width=640
1322                 aros_nominal_height=480
1323                 gcc_target_cpu="i386"
1324                 ;;
1325             *x86_64*)
1326                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1327                 aros_target_cpu="x86_64"
1328                 aros_serial_debug=1
1329                 if test "$aros_object_format" = "" ; then
1330                     aros_object_format="elf_x86_64"
1331                 fi
1332                 aros_flavour="standalone"
1333                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1334                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1335                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1336                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1337                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1338                 aros_kernel_ldflags=""
1339                 aros_nominal_width=640
1340                 aros_nominal_height=480
1341                 case "$aros_target_variant" in
1342                     smp)
1343                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1344                     ;;
1345                 esac
1346                 ;;
1347             *)
1348                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1349                 ;;
1350         esac
1351         ;;
1353     prep)
1354         aros_target_arch="prep"
1355         aros_shared_default="no"
1356         aros_target_cpu="ppc"
1357         aros_object_format="elf32ppc"
1358         aros_flavour="ppcnative"
1359         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1360         aros_kernel_ldflags=""
1361         aros_nominal_width=640
1362         aros_nominal_height=480
1363         gcc_target_cpu="ppc"
1364         ;;
1366     freebsd*)
1367         HOST_WANTS_X11=yes
1368         HOST_WANTS_GLX=yes
1369         HOST_WANTS_SDL=yes
1370         HOST_WANTS_DBUS=yes
1371         HOST_WANTS_DLOPEN=yes
1372         aros_target_arch="freebsd"
1373         aros_target_family="unix"
1374         aros_target_cpu="i386"
1375         aros_flavour="emulation"
1376         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1377         gcc_target_cpu="i386"
1379         aros_target_strip_flags="-x"
1380         ;;
1382     darwin*)
1383         HOST_WANTS_X11=yes
1384         HOST_WANTS_GLX=yes
1385         HOST_WANTS_SDL=yes
1386         HOST_WANTS_DBUS=yes
1387         HOST_WANTS_DLOPEN=yes
1388         aros_target_arch="darwin"
1389         aros_target_family="unix"
1390         aros_flavour="emulation"
1391         case "$target_cpu" in
1392             *i?86*)
1393                 aros_ios_platform="iPhoneSimulator"
1394                 aros_target_cpu="i386"
1395                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1396                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1397                 aros_kernel_ldflags=""
1398                 aros_macosx_version="10.4"
1399                 aros_nominal_depth=8
1400                 gcc_target_cpu="i386"
1401                 aros_object_format="elf_i386"
1402                 aros_kernel_ar_flags="-cr"
1403                 aros_target_strip_flags="-x"
1404                 kernel_tool_flags="-m32"
1405                 ;;
1406             *x86_64*)
1407                 aros_target_cpu="x86_64"
1408                 aros_object_format="elf_x86_64"
1409                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1410                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1411                 aros_macosx_version="10.6"
1412                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1413                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1414                 aros_kernel_cflags="-m64"
1415                 aros_kernel_ldflags="-m64"
1416                 aros_nominal_depth=8
1417                 aros_kernel_rs="$toolchain_ar"
1418                 aros_kernel_ar_flags="-cr"
1419                 aros_kernel_ld="$toolchain_ld"
1420                 aros_kernel_as="$toolchain_as"
1421                 aros_kernel_ranlib="$toolchain_ranlib"
1422                 aros_kernel_nm="$toolchain_nm"
1423                 aros_kernel_strip="strip"
1424                 kernel_tool_prefix="i686-apple-darwin10-"
1425                 ;;
1426             *ppc*)
1427                 aros_target_cpu="ppc"
1428                 aros_object_format="elf32ppc"
1429                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1430                 aros_kernel_ldflags=""
1431                 aros_macosx_version="10.0"
1432                 aros_nominal_depth=8
1433                 gcc_target_cpu="ppc"
1434                 aros_kernel_rs="$toolchain_ar"
1435                 aros_kernel_ar_flags="-cr"
1436                 aros_kernel_ld="$toolchain_ld -arch ppc"
1437                 aros_kernel_as="$toolchain_as -arch ppc"
1438                 aros_kernel_ranlib="$toolchain_ranlib -arch ppc"
1439                 aros_kernel_nm="$toolchain_nm -arch ppc"
1440                 aros_kernel_strip="strip -arch ppc"
1441                 kernel_tool_prefix="powerpc-apple-darwin10-"
1442                 ;;
1443             *arm*)
1444                 aros_ios_platform="iPhoneOS"
1445                 aros_target_cpu="arm"
1446                 aros_object_format="armelf_aros"
1447                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1448                 aros_c_libs="$aros_c_libs -laeabi"
1449                 aros_nominal_depth=8
1450                 gcc_target_cpu="arm"
1451                 aros_kernel_rs="$toolchain_ar"
1452                 aros_kernel_ar_flags="-cr"
1453                 aros_kernel_ld="$toolchain_ld -arch arm"
1454                 aros_kernel_ranlib="$toolchain_ranlib -arch arm"
1455                 kernel_tool_prefix="arm-apple-darwin10-" 
1456                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1457                 ;;
1458             *)
1459                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1460                 ;;
1461         esac
1462         case "$aros_target_variant" in
1463             ios)
1464                 make_extra_targetcfg="$export_newline""# Apple iOS stuff for gcc$export_newline""IOS_LDFLAGS  := -F$""(IOS_SDK_PATH)/System/Library/Frameworks$export_newline"
1465                 aros_ios_version="3.0"
1466                 aros_nominal_width=320
1467                 aros_nominal_height=480
1468                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1469                 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"
1470                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1471                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1472                 need_x11=no
1473                 # This is here because it may depend on iOS or SDK version
1474                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1475                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1476                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1477             ;;
1478             *)
1479                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1480                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1481             ;;
1482         esac
1483         ;;
1485     dragonfly*)
1486         HOST_WANTS_X11=yes
1487         HOST_WANTS_GLX=yes
1488         HOST_WANTS_SDL=yes
1489         HOST_WANTS_DBUS=yes
1490         HOST_WANTS_DLOPEN=yes
1491         aros_target_arch="dragonfly"
1492         aros_target_family="unix"
1493         aros_flavour="emulation"
1494         case "$target_cpu" in
1495             *i?86*)
1496                 aros_target_cpu="i386"
1497                 aros_object_format="elf_i386"
1498                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1499                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1500                 ;;
1501             *x86_64*)
1502                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1503                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1504                 aros_target_cpu="x86_64"
1505                 aros_object_format="elf_x86_64"
1506                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1507                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1508                 ;;
1509             *)
1510                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1511                 ;;
1512         esac
1513         ;;
1515     netbsd*)
1516         HOST_WANTS_X11=yes
1517         HOST_WANTS_GLX=yes
1518         HOST_WANTS_SDL=yes
1519         HOST_WANTS_DBUS=yes
1520         HOST_WANTS_DLOPEN=yes
1521         aros_target_arch="netbsd"
1522         aros_target_family="unix"
1523         case "$target_cpu" in
1524             *m68k*)
1525                 aros_target_cpu="m68k"
1526                 aros_object_format="m68kelf"
1527                 aros_flavour="emulcompat"
1528                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1529                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1530                 gcc_target_cpu="mc68000"
1531                 ;;
1532             *i?86*)
1533                 aros_target_cpu="i386"
1534                 aros_object_format="elf_i386"
1535                 aros_flavour="emulation"
1536                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1537                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1538                 aros_nominal_depth=8
1539                 gcc_target_cpu="i386"
1540                 ;;
1541             *)
1542                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1543                 ;;
1544         esac
1545         aros_target_genmap="-Wl,-M -Xlinker >"
1546         aros_flavour="emulation"
1547         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1548         ;;   
1550     openbsd*)
1551         HOST_WANTS_X11=yes
1552         HOST_WANTS_GLX=yes
1553         HOST_WANTS_SDL=yes
1554         HOST_WANTS_DBUS=yes
1555         HOST_WANTS_DLOPEN=yes
1556         aros_target_arch="openbsd"
1557         aros_target_family="unix"
1558         case "$target_cpu" in
1559             *i?86*)
1560                 aros_target_cpu="i386"
1561                 aros_object_format="elf_i386"
1562                 aros_flavour="emulation"
1563                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1564                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1565                 gcc_target_cpu="i386"
1566                 ;;
1567             *)
1568                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1569                 ;;
1570         esac
1571         aros_target_genmap="-Wl,-M -Xlinker >"
1572         aros_target_nm_flags="-u"
1573         aros_flavour="emulation"
1574         ;;
1576     solaris*)
1577         aros_target_arch="solaris"
1578         aros_target_family="unix"
1579         case "$target_cpu" in
1580            *i?86*)
1581                aros_target_cpu="i386"
1582                aros_object_format="elf_i386"
1583                aros_flavour="emulation"
1584                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1585                aros_isa_flags="$""(ISA_X86_FLAGS)"
1586                aros_nominal_depth=8
1587                gcc_target_cpu="i386"
1588                ;;
1589             *sparc*)
1590                 aros_target_cpu="sparc"
1591                 aros_object_format="elf_sparc"
1592                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1593                 gcc_target_cpu="sparc"
1594                 ;;
1595             *)
1596                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1597                 ;;
1598         esac
1599         aros_config_cppflags="$aros_config_cppflags -D$aros_target_cpu"
1600         aros_flavour="emulation"
1601         ;;
1603     morphos*)
1604         aros_target_arch="morphos"
1605         aros_shared_default="no"
1606         aros_target_cpu="ppc"
1607         aros_object_format="elf_ppc"
1608         aros_flavour="nativecompat"
1609         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1610         gcc_target_cpu="ppc"
1611         ;;
1613     sam440)
1614         aros_target_arch="sam440"
1615         aros_shared_default="no"
1616         aros_target_cpu="ppc"
1617         aros_object_format="elf32ppc"
1618         aros_flavour="ppcnative"
1619         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1620         aros_kernel_ldflags=""
1621         aros_nominal_width=1024
1622         aros_nominal_height=768
1623         aros_nominal_depth=24
1624         aros_isa_flags="$aros_isa_flags -mcpu=440fp -mno-toc"
1625         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1626         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1627         gcc_target_cpu="powerpc"
1628         ;;
1630     efika)
1631         aros_target_arch="efika"
1632         aros_shared_default="no"
1633         aros_target_cpu="arm"
1634         aros_object_format="armelf_aros"
1635         aros_flavour="standalone"
1636         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1637         aros_kernel_ldflags=""
1638         aros_nominal_width=1024
1639         aros_nominal_height=600
1640         aros_c_libs="$aros_c_libs -laeabi"
1641         gcc_default_cpu="armv7-a"
1642         gcc_default_fpu="vfpv3"
1643         aros_isa_flags="$aros_isa_flags -mtune=cortex-a8"
1644         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1645         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1646         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1647         if test "$optimization" = "default"; then
1648             optimization_level=$toolchain_size_opt_lvl
1649         fi
1650         case "$target_cpu" in
1651             *armhf*)
1652                 gcc_default_float_abi="hard"
1653                 target_cpu=arm
1654                 aros_target_cpu=arm
1655                 ;;
1656             *arm*)
1657                 gcc_default_float_abi="softfp"
1658                 ;;
1659             *)
1660                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1661                 ;;
1662         esac
1663         ;;
1664         
1665     chrp)
1666         aros_target_arch="chrp"
1667         aros_shared_default="no"
1668         aros_target_cpu="ppc"
1669         aros_object_format="elf32ppc"
1670         aros_flavour="ppcnative"
1671         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1672         aros_kernel_ldflags=""
1673         aros_nominal_width=640
1674         aros_nominal_height=480
1675         aros_isa_flags="$aros_isa_flags -mno-toc"
1676         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1677         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1678         gcc_target_cpu="powerpc"
1679         case "$aros_target_variant" in
1680             efika)
1681                 aros_isa_flags="$aros_isa_flags -mcpu=603e"
1682                 aros_config_cppflags="$aros_config_cppflags -DBIG_ENDIAN_OHCI=1"
1683             ;;
1684         esac
1685         ;;
1687     r*pi)
1688         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1689         aros_flavour="standalone"
1690         aros_target_arch="raspi"
1692         aros_shared_default="no"
1694         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1695         
1696         case "$target_cpu" in
1697             *aarch64*)
1698                 aros_target_cpu="aarch64"
1699                 gcc_default_cpu="aarch64"
1700                 aros_object_format="aarch64elf_aros"
1701                 ;;
1702             *armhf*)
1703                 aros_target_cpu="arm"
1704                 gcc_default_cpu="armv6zk"
1705                 gcc_default_cpu_tune="arm1176jzf-s"
1706                 aros_object_format="armelf_aros"
1707                 aros_isa_flags="$aros_isa_flags -marm"
1708                 aros_config_cflags="$aros_config_cflags"
1709                 aros_config_cxxflags="$aros_config_cxxflags"
1710                 aros_config_aflags="$aros_config_aflags -marm"
1711                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1712                 aros_target_mkdep="$aros_target_mkdep -Darm"
1713                 aros_c_libs="$aros_c_libs -laeabi"
1714                 ;;
1715             *armeb*)
1716                 aros_flavour="standcompat"
1717                 aros_target_cpu="armeb"
1718                 gcc_default_float_abi="hard"
1719                 gcc_default_cpu="armv7ve"
1720                 gcc_default_cpu_tune="cortex-a7"
1721                 aros_object_format="armelfb_aros"
1722                 aros_isa_flags="$aros_isa_flags -marm"
1723                 aros_config_cflags="$aros_config_cflags"
1724                 aros_config_cxxflags="$aros_config_cxxflags"
1725                 aros_config_aflags="$aros_config_aflags -marm"
1726                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1727                 aros_target_mkdep="$aros_target_mkdep -Darm"
1728                 aros_c_libs="$aros_c_libs -laeabi"
1729                 ;;
1730             *arm*)
1731                 aros_target_cpu="arm"
1732                 gcc_default_cpu="armv6zk"
1733                 gcc_default_cpu_tune="arm1176jzf-s"
1734                 aros_object_format="armelf_aros"
1735                 aros_isa_flags="$aros_isa_flags -marm"
1736                 aros_config_cflags="$aros_config_cflags"
1737                 aros_config_cxxflags="$aros_config_cxxflags"
1738                 aros_config_aflags="$aros_config_aflags -marm"
1739                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1740                 aros_target_mkdep="$aros_target_mkdep -Darm"
1741                 aros_c_libs="$aros_c_libs -laeabi"
1742                 ;;
1743             *)
1744                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1745                 ;;
1746         esac
1748         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1749         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1750         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1751         aros_kernel_cflags="$aros_kernel_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1753         case "$aros_target_variant" in
1754             smp)
1755                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1756             ;;
1757         esac
1758         ;;
1760     stm32f7_discovery)
1761         aros_flavour="standalone"
1762         aros_target_arch="stm32f7_discovery"
1763         aros_target_cpu="arm"
1764         aros_target_cpu_mode="thumb2"
1765         aros_object_format="armelf_aros"
1766         aros_shared_default="no"
1768         gcc_default_cpu="armv7e-m"
1769         gcc_default_cpu_tune="cortex-m7"
1770         gcc_default_fpu="fpv5-sp-d16"
1771         gcc_default_float_abi="hard"
1773         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1774         ;;
1776     amiga*)
1777         aros_elf_translate="$""(ELF2HUNK)"
1778         make_extra_commands="$export_newline""ELF2HUNK  := $""(TOOLDIR)/elf2hunk$""(HOST_EXE_SUFFIX)$export_newline"
1779         aros_target_arch="amiga"
1780         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1781         aros_shared_default="no"
1783         case "$target_cpu" in
1784             *m68k*)
1785                 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")
1786                 aros_enable_mmu=no
1787                 aros_target_cpu="m68k"
1788                 aros_object_format="m68kelf"
1789                 aros_flavour="standcompat"
1790                 gcc_target_cpu="m68000"
1791                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1792                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1793                 aros_config_cppflags="$aros_config_cppflags -DNOLIBINLINE"
1794                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1795                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1796                 if test "$optimization" = "default"; then
1797                     optimization_level=$toolchain_size_opt_lvl
1798                 fi
1799                 aros_config_aflags="$aros_config_aflags"
1800                 aros_target_strip_flags="-R.comment --strip-debug"
1801                 aros_nominal_width=640
1802                 aros_nominal_height=256
1803                 aros_nominal_depth=2
1804                 ;;
1805             *ppc*)
1806                 aros_cpu="ppc"
1807                 aros_flavour="native"
1808                 gcc_target_cpu="ppc"
1809                 ;;
1810             *)
1811                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1812                 ;;
1813         esac
1814         ;;
1816     mingw*)
1817         aros_target_arch="mingw32"
1818         aros_shared_default="no"
1819         aros_flavour="emulation"
1820         aros_shared_cflags=""
1821         need_crosstools="yes"
1822         need_dlopen="no"
1823         rescomp="windres"
1824         case "$target_cpu" in
1825             *i?86*)
1826                 aros_target_cpu="i386"
1827                 aros_object_format="elf_i386"
1828                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1829                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1830                 aros_nominal_depth=8
1831                 gcc_target_cpu="i386"
1833                 kernel_tool_prefix="i386-mingw32-"
1834                 ;;
1835             *x86_64*)
1836                 aros_target_cpu="x86_64"
1837                 aros_object_format="elf_x86_64"
1838                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1839                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1840                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1841                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1842                 aros_nominal_depth=8
1843                 kernel_tool_prefix="x86_64-w64-mingw32-"
1844                 ;;
1845             *arm*)
1846                 aros_target_cpu="arm"
1847                 aros_object_format="armelf_aros"
1848                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1849                 aros_c_libs="$aros_c_libs -laeabi"
1850                 aros_nominal_depth=8
1851                 gcc_target_cpu="arm"
1852                 gcc_default_float_abi="soft"
1853                 kernel_tool_prefix="arm-mingw32ce-"
1854                 aros_nominal_width=160
1855                 aros_nominal_height=160
1856                 ;;
1857             *)
1858                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1859                 ;;
1860         esac
1861         if test $host_os = "cygwin"; then
1862                 aros_kernel_cflags="-mno-cygwin"
1863         fi
1864     ;;
1865     pp*)
1866         aros_target_arch="pp"
1867         aros_shared_default="no"
1868         case "$target_cpu" in
1869             *m68k*)
1870                 aros_target_cpu="m68k"
1871                 aros_object_format="m68kelf"
1872                 aros_flavour="palmnative"
1873                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1874                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1875                 aros_nominal_width=160
1876                 aros_nominal_height=160
1877                 aros_nominal_depth=1
1878                 aros_target_ar_flags="cru"
1879                 aros_c_libs="$aros_c_libs -lgcc1"
1880                 aros_shared_default=no
1881                 aros_shared_cflags="-fpic"
1882                 aros_shared_aflags=""
1883                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1884                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1885                 aros_debug_cppflags="$aros_messages_debug"
1886                 aros_debug_cflags="$aros_symbols_debug"
1887                 aros_debug_aflags=""
1888                 aros_debug_ldflags="$aros_symbols_debug"
1889                 aros_mungwall_debug="0"
1890                 aros_modules_debug="0"
1891                 gcc_target_cpu="mc68000"
1892                 ignore_undefined_symbols="-ius"
1893                 ;;
1894            *)
1895                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1896                 ;;
1897         esac
1898         ;;
1900     mac*)
1901         aros_target_arch="mac"
1902         aros_shared_default="no"
1903         case "$target_cpu" in
1904             *m68k*)
1905                 aros_target_cpu="m68k"
1906                 aros_object_format="m68kelf"
1907                 aros_flavour="mac68knative"
1908                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1909                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1910                 aros_nominal_width=512
1911                 aros_nominal_height=384
1912                 aros_nominal_depth=8
1913                 aros_target_ar_flags="cru"
1914                 aros_c_libs="$aros_c_libs -lgcc1"
1915                 aros_shared_default=no
1916                 aros_shared_cflags="-fpic"
1917                 aros_shared_aflags=""
1918                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1919                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1920                 aros_debug_cppflags="$aros_messages_debug"
1921                 aros_debug_cflags="$aros_symbols_debug"
1922                 aros_debug_aflags=""
1923                 aros_debug_ldflags="$aros_symbols_debug"
1924                 aros_mungwall_debug="0"
1925                 aros_modules_debug="0"
1926                 gcc_target_cpu="mc68000"
1927                 ignore_undefined_symbols="-ius"
1928                 ;;
1929            *)
1930                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1931                 ;;
1932         esac
1933         ;;
1935     *)
1936         AC_MSG_ERROR([Unsupported target architecture $target])
1937         ;;
1938 esac
1940 #-----------------------------------------------------------------------------
1941 crosstools_guess="yes"
1942 aros_target_toolchain="no"
1943 aros_kernel_sysroot=""
1945 AC_MSG_CHECKING([Kernel toolchain prefix])
1946 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1947 AC_MSG_RESULT($kernel_tool_prefix)
1949 AC_MSG_CHECKING([ELF toolchain prefix])
1950 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"
1951                                                  crosstools_guess="no"])
1952 AC_MSG_RESULT($elf_tool_prefix)
1954 AC_MSG_CHECKING([AROS toolchain prefix])
1955 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"
1956                 crosstools_guess="no"])
1957 if test "$aros_tool_prefix" = "yes" ; then
1958     aros_tool_prefix=$aros_target_cpu-aros-
1960 AC_MSG_RESULT($aros_tool_prefix)
1962 #-----------------------------------------------------------------------------
1963 #   Checking if we should build crosstools..
1964 AC_MSG_CHECKING([whether to build crosstools])
1965 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1966 AC_MSG_RESULT($crosstools)
1968 if test "${crosstools}" = "yes"; then
1969     if test "${crosstools_guess}" = "no"; then
1970         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1971     fi
1974 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1975     aros_target_toolchain="yes"
1978 AC_MSG_CHECKING([where to install the crosstools binaries])
1979 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])
1980 if test "x$aros_toolchain_install" = "x"; then
1981     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1982 else
1983     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1984     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1985     if test "$crosstools_guess" = "no" ; then
1986         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1987             aros_kernel_sysroot="$""(TARGET_SYSROOT)"
1988         fi
1989     fi
1991 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1993 #-----------------------------------------------------------------------------
1994 if test "$aros_toolchain" = "gnu" ; then
1995     AC_MSG_CHECKING([what specific target binutils version to use])
1997 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="")
1998 if test "$use_binutils_version" = ""; then
1999         target_binutils_version="$default_binutils_version"
2000 else
2001     target_binutils_version="$use_binutils_version"
2003 if test "$aros_toolchain" = "gnu" ; then
2004     AC_MSG_RESULT($target_binutils_version)
2008 # Helper to identify gcc version
2009 AC_DEFUN([CROSS_GCC_VERSION], [
2010   target_gcc_version=""
2011   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
2012     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} $(toolchain_cpp_opts) -dumpversion`"
2013     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
2014       ax_cv_gcc_version=""
2015     ])
2016   ])
2017   target_gcc_version=$ax_cv_gcc_version
2018   AC_SUBST([target_gcc_version])
2021 #-----------------------------------------------------------------------------
2022 if test "$aros_toolchain" = "gnu" ; then
2023     AC_MSG_CHECKING([what specific target gcc version to use])
2025 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
2026 if test "$use_gcc_version" = ""; then
2027     if test "${crosstools}" = "no"; then
2028       if test "x$aros_toolchain_install" != "x"; then
2029           CROSS_GCC_VERSION
2030       fi
2031     fi
2032     if test "$use_gcc_version" = ""; then
2033         target_gcc_version="$default_gcc_version"
2034     fi
2035 else
2036     target_gcc_version="$use_gcc_version"
2038 if test "$aros_toolchain" = "gnu" ; then
2039     AC_MSG_RESULT($target_gcc_version)
2041     AC_MSG_CHECKING([version string style])
2042     if test "${target_gcc_version#*$'-'}" != "$target_gcc_version" ; then
2043         AC_MSG_RESULT(snapshot)
2044         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'-' -f1)
2045         GCC_VERSION_MINOR=-1
2046         GCC_VERSION_PATCH=-1
2047     else
2048         AC_MSG_RESULT(release)
2049         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
2050         GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
2051         GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
2052     fi
2054     gcc_fix_bitfields="false"
2055     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
2056         gcc_fix_bitfields="true"
2057     else
2058         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
2059             if test "$GCC_VERSION_MINOR" -gt "6" ; then
2060                 gcc_fix_bitfields="true"
2061             fi
2062         fi
2063     fi
2065     if test "$gcc_fix_bitfields" = "true" ; then
2066         case "$aros_target_cpu" in
2067         *x86_64* | *i?86*)
2068             x86_isa_extra="$x86_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2069             x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2070             ;;
2071         esac
2072     fi
2075 AC_MSG_CHECKING([whether to enable Objective-C suppport])
2076 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
2077 AC_MSG_RESULT($objc)
2078 if test "x$objc" = "xyes"; then
2079     objc_target="$objc"
2080 else
2081     objc_target="no-objc"
2084 AC_MSG_CHECKING([whether to enable Java suppport])
2085 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
2086 AC_MSG_RESULT($java)
2087 if test "x$java" != "xno"; then
2088     java_target="$java"
2089 else
2090     java_target="no-java"
2093 spec_obj_format="-m $aros_object_format"
2094 # Now process extra architecture-specific options.
2095 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
2096 # as well as floating-point ABI.
2097 case "$aros_target_cpu" in
2098     *m68k*)
2099         aros_isa_targets="M68K_ISA_TARGETS              :=MC68020 MC68040"
2100         aros_isa_extra="$aros_isa_extra$export_newline$aros_isa_targets$export_newline"
2101         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"
2102         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"
2103         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"
2104         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"
2105         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"
2106         ;;
2107     *x86_64*)
2108         aros_isa_extra="$export_newline$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2109         dnl x86_64 can build 32 or 64bit code
2110         spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
2111         ;;
2112     arm*)
2113         dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
2114         if test "$gcc_default_cpu" = ""; then
2115             gcc_default_cpu="armv6"
2116         fi
2117         if test "$gcc_default_fpu" = ""; then
2118             gcc_default_fpu="vfp"
2119         fi
2120         if test "$gcc_default_endian" = ""; then
2121             if test "$target_cpu" = "armeb"; then
2122                 gcc_default_endian="big-endian"
2123             else
2124                 gcc_default_endian="little-endian"
2125             fi
2126         fi
2127         if test "$gcc_default_float_abi" = ""; then
2128             if test "$target_cpu" = "armhf"; then
2129                 gcc_default_float_abi="hard"
2130             else
2131                 gcc_default_float_abi="softfp"
2132             fi
2133         fi
2135         AC_MSG_CHECKING([Which minimum CPU to use])
2136         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)
2137         AC_MSG_RESULT($aros_gcc_cpu)
2139         AC_MSG_CHECKING([Which minimum FPU to use])
2140         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)
2141         AC_MSG_RESULT($aros_gcc_fpu)
2143         AC_MSG_CHECKING([Which floating point ABI to use])
2144         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)
2145         AC_MSG_RESULT($aros_gcc_float_abi)
2147         AC_MSG_CHECKING([Which ARM mode to use])
2148         if test "$aros_target_cpu_mode" = ""; then
2149             aros_target_cpu_mode="arm32"
2150             AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
2151         else
2152             AC_MSG_RESULT([$aros_target_cpu_mode])
2153         fi
2155         case "$aros_target_cpu_mode" in
2156         arm32)
2157             gcc_default_mode="arm"
2158             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"
2159         ;;
2160         arm64)
2161             AC_MSG_ERROR([ARM 64-bit mode is unsupported])
2162         ;;
2163         thumb)
2164             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2165         ;;
2166         thumb1)
2167             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2168         ;;
2169         thumb2)
2170             gcc_default_mode="thumb"
2171             # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
2172             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"
2173         ;;
2174         *)
2175             AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
2176         ;;
2177         esac
2179         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2180         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2181         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2182         ;;
2183     i386)
2184         aros_isa_extra="$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2185         aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
2186         ;;
2187 esac
2189 # Some architectures may need custom ELF specs.
2190 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
2191     elf_specs_in=config/${aros_object_format}-specs.in
2192 else
2193     elf_specs_in=config/elf-specs.in
2196 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
2197 # Since we override specs, we may need to put these defines there
2198 if test "$gcc_target_cpu" != ""; then
2199     gcc_target_cpu="-D__${gcc_target_cpu}__"
2202 AC_MSG_CHECKING([where to download sourcecode for external ports])
2203 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
2204 if test "$with_portssrcdir" = "default"; then
2205     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
2206 else
2207     AROS_PORTSSRCDIR="$with_portssrcdir"
2209 AC_MSG_RESULT($AROS_PORTSSRCDIR)
2211 AC_MSG_CHECKING([which bootloader to use])
2212 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
2213 if test "$target_bootloader" = "none"; then
2214     aros_target_bootloader=""
2215 else
2216     aros_target_bootloader="$target_bootloader"
2218 AC_MSG_RESULT($target_bootloader)
2220 AC_MSG_CHECKING([which icon-set to use])
2221 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
2222 if test "$target_iconset" = "default"; then
2223     aros_target_iconset="Gorilla"
2224     target_iconset="default (Gorilla)"
2225 else
2226     aros_target_iconset="$target_iconset"
2228 AC_MSG_RESULT($target_iconset)
2230 AC_MSG_CHECKING([which GUI Theme to use])
2231 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2232 if test "$target_guitheme" = "default"; then
2233     aros_target_guitheme="Ice"
2234 else
2235     aros_target_guitheme="$target_guitheme"
2237 AC_MSG_RESULT($aros_target_guitheme)
2239 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2240 # for target code)
2241 cross_compiling=no
2243 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2244 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2245     cross_compiling=yes
2248 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2249 dnl The flag itself is given in per-target section, because some targets require to pass it
2250 dnl in a different manner, otherwise some tests fail.
2251 dnl TODO: Justify this.
2252 if test "$aros_host_cpu" == "x86_64" ; then
2253     if test "$aros_target_cpu" == "i386" ; then
2254         cross_compiling=no
2255     fi
2258 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2259     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2260     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2261     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2262     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2263     dnl used to build bootstrap for target arch in either case.
2264     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2265     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2266     dnl perhaps introducing aros_host_variant
2267     if test "$aros_host_arch" != "$aros_target_arch" ; then
2268         cross_compiling=yes
2269     fi
2270 else
2271     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2272     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2273     dnl if test "$host_cc_elf" = "no" ; then
2274         cross_compiling=yes
2275     dnl fi
2278 if test "$cross_compiling" = "no" ; then
2279     kernel_tool_prefix=""
2280     if test "$host_cc_elf" = "yes" ; then
2281         elf_tool_prefix=""
2282     fi
2285 if test "$kernel_tool_version" != ""; then
2286     kernel_tool_version="-$kernel_tool_version"
2289 #######################################################################
2290 ## Compute what toolchains to use, and their paths                   ##
2291 #######################################################################
2293 # This takes, as input:
2294 #   crosstools             {yes,no}
2295 #   kernel_tool_version    {"",[version]}
2296 #   target_tool_version    {"",[version]}
2297 #   kernel_tool_prefix     {none,[some-arch-os-]}
2298 #   gnu-toolchain -:
2299 #     target_tool_prefix     ${aros_target_cpu}-aros-
2300 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2302 # The output is
2303 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2304 #        Where the 'kernel' binaries are located
2305 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2306 #        Where the 'target' binaries are located
2307 #        (not the symlink farm - that is aros_target_*!)
2309 # The rules are:
2310 #   if crosstools then
2311 #      if kernel_tools_prefix = "no-kernel-prefix-"
2312 #          aros_kernel_* = crosstools cc paths
2313 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2314 #      else
2315 #          VALIDATE(${kernel_tools_prefix}*)
2316 #          aros_kernel_* = ${kernel_tools_prefix}*
2317 #          if ${kernel_tools_prefix}cc is an AROS gcc
2318 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2319 #          else
2320 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2321 #          fi
2322 #      fi
2324 #      orig_target_* = aros built crosstools
2325 #      orig_target_cc = elf cc wrapper around crosstools cc
2326 #   else
2327 #      VALIDATE(${kernel_tools_prefix}*)
2329 #      orig_target_* = aros_kernel_*
2330 #      if aros_kernel_cc is an AROS gcc
2331 #          orig_target_cc = aros_kernel_cc
2332 #      else
2333 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2334 #      fi
2335 #   fi
2337 if test "$aros_toolchain" = "gnu" ; then
2338     target_tool_prefix="${aros_target_cpu}-aros-"
2339 elif test "$aros_toolchain" = "llvm" ; then
2340     target_tool_prefix="bin/"
2343 if test "$kernel_tool_prefix" != "" ; then
2344     AC_MSG_CHECKING([which kernel tools])
2345     AC_MSG_RESULT([$kernel_tool_prefix]);
2348 if test "$kernel_tool_prefix" = "none" ; then
2349     dnl ELF wrapper can be used only for native bootstrap
2350     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2351         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2352     fi
2353 else
2354     if test "x-$aros_flavour" != "x-standalone" -o "x-$aros_flavour" != "x-standcompat" ; then
2355         # Kernel tools required - find them
2356         # Note that 'normally', aros_kernel_* overrides will be
2357         # empty, unless specified in the per-arch sections above.
2358         test_kernel_cc=yes
2359         if test "x$aros_kernel_cpp" = "x"; then
2360             aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2361         fi
2362         AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2363         AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2364         AROS_REQUIRED(cpp,$aros_kernel_cpp)
2366         if test "x$aros_kernel_cc" = "x"; then
2367             aros_kernel_cc=${kernel_tool_prefix}${CC}
2368         fi
2369         AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2370         AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2371         AROS_REQUIRED(cc,$aros_kernel_cc)
2373         if test "x$aros_kernel_cxx" = "x"; then
2374             aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2375         fi
2376         AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2377         AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2378         # If it's set, make sure it's really there
2379         if test "x$aros_kernel_cxx" != "x" ; then
2380             AROS_REQUIRED(cxx,$aros_kernel_cxx)
2381         fi
2382         if test "x$aros_kernel_ld" = "x"; then
2383             aros_kernel_ld=$aros_host_ld
2384         fi
2385         AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2386         AROS_REQUIRED(ld,$aros_kernel_ld)
2387         if test "x$aros_kernel_as" = "x"; then
2388             aros_kernel_as=$aros_host_as
2389             if test "x$aros_kernel_as" = "x"; then
2390                 aros_kernel_as=${HOST_TOOLCHAIN_PREFIX}as${HOST_TOOLCHAIN_SUFFIX}
2391             fi
2392         fi
2393         AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2394         AROS_REQUIRED(as,$aros_kernel_as)
2395         if test "x$aros_kernel_ar" = "x"; then
2396             aros_kernel_ar=$aros_host_full_ar
2397         fi
2398         AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2399         AROS_REQUIRED(ar,$aros_kernel_ar)
2400         if test "x$aros_kernel_ranlib" = "x"; then
2401             aros_kernel_ranlib=$aros_host_ranlib
2402         fi
2403         AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2404         AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2405         if test "x$aros_kernel_nm" = "x"; then
2406             aros_kernel_nm=$aros_host_nm
2407             if test "x$aros_kernel_nm" = "x"; then
2408                 aros_kernel_nm=${HOST_TOOLCHAIN_PREFIX}nm${HOST_TOOLCHAIN_SUFFIX}
2409             fi
2410         fi
2411         AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2412         AROS_REQUIRED(nm,$aros_kernel_nm)
2413         AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2414         AROS_REQUIRED(strip,$aros_kernel_strip)
2416         # Objcopy and objdump are not required for the kernel
2417         # toolchain on many architectures.
2418         # So we'll look for them, but not make them strictly required.
2419         if test "x$aros_kernel_objcopy" = "x"; then
2420             aros_kernel_objcopy=$aros_host_objcopy
2421             if test "x$aros_kernel_objcopy" = "x"; then
2422                 aros_kernel_objcopy=${HOST_TOOLCHAIN_PREFIX}objcopy${HOST_TOOLCHAIN_SUFFIX}
2423             fi
2424         fi
2425         AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2426         if test "x$aros_kernel_objdump" = "x"; then
2427             aros_kernel_objdump=$aros_host_objdump
2428             if test "x$aros_kernel_objdump" = "x"; then
2429                 aros_kernel_objdump=${HOST_TOOLCHAIN_PREFIX}objdump${HOST_TOOLCHAIN_SUFFIX}
2430             fi
2431         fi
2432         AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2433         if test "x${crosstools}" != "xyes" ; then
2434             AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2435             AROS_REQUIRED(objdump,$aros_kernel_objdump)
2436         fi
2437     fi
2440 AC_MSG_CHECKING([which target tools to use])
2441 if test "$aros_target_toolchain" = "yes"; then
2442     if test "$aros_toolchain" = "llvm" ; then
2443         msg_result="llvm"
2444     else
2445         msg_result=$target_tool_prefix
2446     fi
2447     AC_MSG_RESULT([$msg_result])
2448     # We are building AROS crosstools
2449     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2450     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2451     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2452     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}${toolchain_cpp_opts}"
2453     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2454     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2455     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2456     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2457     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2458     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2459     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2460     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2461 else
2462     # Determine whether AROS or ELF tools should be used
2463     if test "$aros_tool_prefix" = "none"; then
2464         aros_tool_prefix="${elf_tool_prefix}"
2465     fi
2467     AC_MSG_RESULT([$aros_tool_prefix])
2468     # We are *not* building AROS crosstools - use the AROS or ELF tools
2469     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version}${toolchain_cpp_opts})
2470     AROS_REQUIRED(cpp,$orig_target_cpp)
2471     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2472     AROS_REQUIRED(cc,$orig_target_cc)
2473     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2474     AROS_REQUIRED(cxx,$orig_target_cxx)
2475     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2476     AROS_REQUIRED(ld,$orig_target_ld)
2477     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2478     AROS_REQUIRED(as,$orig_target_as)
2479     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2480     AROS_REQUIRED(ar,$orig_target_ar)
2481     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2482     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2483     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2484     AROS_REQUIRED(nm,$orig_target_nm)
2485     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2486     AROS_REQUIRED(strip,$orig_target_strip)
2487     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2488     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2489     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2490     AROS_REQUIRED(objdump,$orig_target_objdump)
2493 if test "$kernel_tool_prefix" = "none" ; then
2494     # No kernel tools specified
2495     # Assume kernel tools == target tools with ELF wrapper
2496     aros_kernel_cc=$orig_target_cc
2497     aros_kernel_cxx=$orig_target_cxx
2498     aros_kernel_cpp="$orig_target_cpp"
2499     aros_kernel_ld=$orig_target_ld
2500     aros_kernel_as=$orig_target_as
2501     aros_kernel_ar=$orig_target_ar
2502     aros_kernel_ranlib=$orig_target_ranlib
2503     aros_kernel_nm=$orig_target_nm
2504     aros_kernel_strip=$orig_target_strip
2505     aros_kernel_objcopy=$orig_target_objcopy
2506     aros_kernel_objdump=$orig_target_objdump
2507     aros_kernel_isa_flags=$aros_isa_flags
2508     use_kernel_cc_wrapper=yes
2511 # At this point, all aros_kernel_* and aros_target_* 
2512 # tools should be set up correctly
2514 CC="$aros_kernel_cc $kernel_tool_flags"
2515 CPP="$aros_kernel_cpp"
2517 #-----------------------------------------------------------------------------
2519 # Find all the tools we need to compile. This could be cross-compiling
2520 # though! If that is the case we use the GNU form of the target and
2521 # simply add this to the front of the binary name. This is rather simple,
2522 # but it should work under most circumstances.
2524 # The default tools are to use the same as the host, but only if the
2525 # host and target CPU are the same. With GCC this is normally enough.
2528 aros_cc_pre=""
2529 aros_shared_ld="$aros_host_ld"
2531 aros_target_mkdep="$aros_host_mkdep"
2533 # The default tools executables to be linked to.
2534 if test "$rescomp" != ""; then
2535     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2536     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2539 # Set up the sources for the symlink farm
2540 if test "$crosstools" = "yes"; then
2541     crosstools_target=tools-crosstools
2544 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2545 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2547 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2548 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2549 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2550 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2551 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2552 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2553 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2555 # aros_cc_pre is a variable that is added to the front of the compiler name
2556 # in the generated aros-gcc shell script. We need this to enable the cache
2557 # to work across cleaned builds. Also, support DISTCC using the correct
2558 # environment variable.
2561 if test "x${DISTCC}" != "x" ; then
2562     if test "x${CCACHE}" != "x" ; then
2563         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2564     else
2565         aros_cc_pre="${DISTCC} "
2566     fi
2567 else
2568     if test "x${CCACHE}" != "x" ; then
2569         aros_cc_pre="${CCACHE} "
2570     fi
2573 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2574 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2575 AC_SUBST(aros_target_nix_ldflags,-nix)
2576 AC_SUBST(aros_target_detach_ldflags,-detach)
2577 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2579 aros_target_cc_path=
2581 # Target tools
2582 AC_SUBST(aros_toolchain)
2583 if test "$aros_target_toolchain" != "yes"; then
2584     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2585     if test "$GCC" = "yes"; then
2586         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2587     fi
2588 else
2589     # We do not know which c compiler version we are going to build and what we need to know
2590     # here is different for different versions so this will be set later during the
2591     # build of crosstools.
2592     if test "$aros_toolchain" = "gnu" ; then
2593         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2594     elif test "$aros_toolchain" = "llvm" ; then
2595         prefix="$AROS_CROSSTOOLSDIR/bin/"
2596     fi
2597     aros_target_cc_path=@aros_target_cc_path@
2599 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}${toolchain_cpp_opts}"
2600 aros_target_cc="${prefix}${toolchain_c_compiler}"
2601 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2602 aros_target_as="${prefix}${toolchain_as}"
2603 if test "${use_ld_wrapper}" = "yes"; then
2604     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2605 else
2606     aros_target_ld="${prefix}${toolchain_ld}"
2608 aros_toolchain_ld="${prefix}${toolchain_ld}"
2610 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2611 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2612 aros_target_objdump="${prefix}${toolchain_objdump}"
2613 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2614 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2615 aros_target_strip="${prefix}${toolchain_strip}"
2616 aros_plain_nm="${prefix}${toolchain_nm}"
2617 aros_plain_ar="${prefix}${toolchain_ar}"
2619 AC_ARG_ENABLE(includes,
2620 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2621 [aros_target_incl=$enable_includes], [aros_target_incl=no])
2623 if test "x$aros_target_incl" = "xno"; then
2624     if test "x$test_kernel_cc" != "xno"; then
2625         aros_target_incl=`$aros_kernel_cc -print-sysroot 2>/dev/null`/`$aros_kernel_cc --print-sysroot-headers-suffix 2>/dev/null || echo usr/include`
2626     else
2627         aros_target_incl=
2628     fi
2631 if test "x$aros_kernel_includes" = "x"; then
2632     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2633         if test "x$aros_target_incl" != "x"; then
2634             aros_kernel_includes="-isystem $aros_target_incl"
2635         fi
2636     fi
2639 if test "x$test_kernel_cc" != "xno"; then
2640     if test "$aros_kernel_includes" != "" ; then
2641         dnl find out about the kernel cc's include path
2642         AC_MSG_CHECKING([for the kernel compiler's include path])
2643         if test "$aros_kernel_cc_includes" = "" ; then
2644             # Try to guess where the directory is.
2645             aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2646             if test -d $aros_kernel_cc_includes; then
2647                 # Check if there is also an include-fixed directory and add it
2648                 # to kernel compiler's include path as it may contain some of
2649                 # the headers we need.
2650                 if test -d "$aros_kernel_cc_includes"-fixed; then
2651                     aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2652                 fi
2653                 # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2654                 if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2655                     aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2656                 fi
2657             else
2658                 # The directory doesn't exist, we need to do some more work.
2659                 aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2661                 # These are the headers we're looking for.
2662                 headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2663                          stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2664                          zutil.h stdint.h"
2666                 dirs=
2667                 for h in $headers; do
2668                     # Which other headers are needed by each of the above?
2669                     deps=$(echo "#include <$h>" | \
2670                            $aros_kernel_cc -E -M - 2>/dev/null | \
2671                            sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2673                     # Copy all the needed headers to a directory beneath gendir.
2674                     for d in $deps; do
2675                         h=$(basename $d)
2676                         dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2677                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2678                         ! test -d $dir && mkdir -p $dir
2679                         ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2680                     done
2681                 done            
2682             fi
2683         fi
2684         AC_MSG_RESULT($aros_kernel_cc_includes)
2685         # Adding -nostdinc to kernel includes as they are always used together.
2686         aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2687     fi
2690 if test "$crosstools" != "yes"; then
2691     dnl find out about the target cc's include path
2692     AC_MSG_CHECKING([for the target compiler's include path])
2693     if test "$aros_target_cc_includes" = "" ; then
2694         #try to guess where the directory is
2695         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2696         if ! test -d $aros_target_cc_includes; then
2697             #the directory doesn't exist, we need to do some more work
2698             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2699         
2700             #these are the headers we're looking for
2701             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2702                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2703                     zutil.h"
2705             dirs=
2706             for h in $headers; do
2707                 #which other headers each of the above headers needs?
2708                 deps=$(echo "#include <$h>" | \
2709                     $orig_target_cc -E -M - 2>/dev/null | \
2710                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2711             
2712                 #copy all the needed headers to a directory beneath gendir
2713                 for d in $deps; do
2714                     h=$(basename $d)
2715                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2716                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2717                     ! test -d $dir && mkdir -p $dir
2718                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2719                 done
2720             done
2721         fi
2722     fi
2723     AC_MSG_RESULT($aros_target_cc_includes)
2724 else
2725     # We do not know which c compiler version we are going to build and what we need to know
2726     # here is different for different versions so this will be set later during the
2727     # build of crosstools.
2728     aros_target_cc_includes=@aros_target_cc_includes@
2732 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2733 # On GCC >= 4.0 -iquote should be used
2736 save_cc="$CC"
2737 save_cflags="$CFLAGS"
2738 if test "x$test_kernel_cc" != "xno"; then
2739     CFLAGS="-iquote."
2740     kernel_cflags_iquote=$host_cflags_iquote
2741     kernel_cflags_iquote_end=$host_cflags_iquote_end
2742     if test "x-$cross_compiling" = "x-yes"; then
2743         CC="$aros_kernel_cc"
2744         AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2745         if test "x-$crosstools" != "x-yes"; then
2746             AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2747         else
2748             # we do know it is supported for the smallest version of gcc we are going to build
2749             # we assume it's also supported by later versions
2750             use_no_stack_protector=yes
2751         fi
2752         AC_MSG_RESULT($use_no_stack_protector)
2753         AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2754         if test "x-$crosstools" != "x-yes"; then
2755             AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2756         else
2757             # we do know it is supported for the smallest version of gcc we are going to build
2758             # we assume it's also supported by later versions
2759             has_iquote=yes
2760         fi
2761         AC_MSG_RESULT($has_iquote)
2762         if test "x-$has_iquote" = "x-yes" ; then
2763             kernel_cflags_iquote=-iquote
2764             kernel_cflags_iquote_end=
2765         else
2766             kernel_cflags_iquote=-I
2767             kernel_cflags_iquote_end=-I-
2768         fi
2769     fi
2770     if test "x-$use_no_stack_protector" = "x-yes" ; then
2771         aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2772     fi
2774     #-----------------------------------------------------------------------------
2776     # Check if we can explicitly choose older version of symbol hashing
2778     CFLAGS="save_cflags -Wl,--hash-style=sysv"
2779     CC="$aros_kernel_cc"
2780     AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2781     AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2782     AC_MSG_RESULT($use_hash_style)
2783     if test "x-$use_hash_style" = "x-yes" ; then
2784         aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2785     fi
2786 else
2787     kernel_cflags_iquote="$""(CFLAGS_IQUOTE)"
2788     kernel_cflags_iquote_end="$""(CFLAGS_IQUOTE_END)"
2790 CC="$save_cc"
2791 CFLAGS="$save_cflags"
2793 AC_SUBST(host_cflags_iquote)
2794 AC_SUBST(host_cflags_iquote_end)
2795 AC_SUBST(kernel_cflags_iquote)
2796 AC_SUBST(kernel_cflags_iquote_end)
2799 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2800 AC_MSG_CHECKING([for default resolution of WBScreen])
2801 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2802 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2803 if test "$resolution" = "yes" ; then
2804     resolution="none"
2806 if test "$resolution" = "no" ; then
2807     resolution="none"
2809 if test "$resolution" != "none" ; then
2810     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2811     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2812     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2814 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2815 aros_cv_nominal_width=$aros_nominal_width
2816 aros_cv_nominal_height=$aros_nominal_height
2817 aros_cv_nominal_depth=$aros_nominal_depth
2819 dnl See if the user wants the serial debug output for native flavour
2820 AC_MSG_CHECKING([whether serial debug is enabled])
2821 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)
2822 if test "$aros_serial_debug" = 0 ; then
2823     serial_debug_forced=""
2824     if test "$serial_debug" = "yes" ; then
2825         serial_debug="1"
2826     fi
2827     if test "$serial_debug" = "no" ; then
2828         serial_debug="none"
2829     fi
2830 else
2831     serial_debug_forced="(forced)"
2832     serial_debug=$aros_serial_debug
2834 if test "$serial_debug" != "none" ; then
2835     aros_serial_debug=$serial_debug
2836     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2837 else
2838     AC_MSG_RESULT(no)
2841 dnl See if the user wants the palm debug output hack for palm native flavour
2842 AC_MSG_CHECKING([whether palm debug hack is enabled])
2843 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")
2844 if test "$palm_debug_hack" = "yes" ; then
2845     aros_palm_debug_hack="1"
2847 AC_MSG_RESULT($palm_debug_hack)
2849 dnl See if dev wants the usb3.0 code
2850 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2851 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2852 if test "$usb30_code" = "yes" ; then
2853     aros_config_cppflags="$aros_config_cppflags -DAROS_USB30_CODE"
2854     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2856 AC_MSG_RESULT($usb30_code)
2858 dnl See if the user wants nesting supervisor activated for unix flavour
2859 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2860 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")
2861 if test "$nesting_supervisor" = "yes" ; then
2862     aros_nesting_supervisor="1"
2864 AC_MSG_RESULT($nesting_supervisor)
2866 dnl See if the user wants to disable MMU support
2867 dnl This can be overriden on per-target basis,
2868 dnl set $aros_enable_mmu to "yes" or "no" to do this
2869 if test "$aros_enable_mmu" = "" ; then
2870     AC_MSG_CHECKING([whether MMU support is enabled])
2871     dnl Enabled by default
2872     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2873     if test "$aros_enable_mmu" = "" ; then
2874         aros_enable_mmu="yes"
2875     fi
2876     AC_MSG_RESULT($aros_enable_mmu)
2878 if test "$aros_enable_mmu" = "no" ; then
2879     aros_enable_mmu="0"
2880 else
2881     aros_enable_mmu="1"
2883     
2885 dnl things specifically required for hosted flavours
2886 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2888     if test "x-$need_dlopen" != "x-no" ; then
2889       save_libs="$LIBS"
2890       LIBS=""
2891       dnl some kind of dynamic library access system is required for hostlib.resource
2892       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2893       if test "x-$have_dl" = "x-no" ; then
2894           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2895                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2896                                     have_dl="no")
2897       fi
2898       if test "x-$have_dl" = "x-no" ; then
2899           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2900       fi
2901       LIBS="$save_libs"
2902     fi
2905     dnl x11 hidd
2906     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2907                                            [build X11 hidd for hosted (default=auto)]),
2908                                            x11_hidd="$enableval",
2909                                            x11_hidd="$need_x11")
2910     case "x-$x11_hidd" in
2911         x-yes|x-no|x-auto)                 ;;
2912         *)                 x11_hidd="$need_x11" ;;
2913     esac
2915     ENABLE_X11=0
2917     dnl they want it
2918     if test "x-$x11_hidd" != "x-no" ; then
2920         dnl find x11 stuff
2921         AC_PATH_X
2923         if test -n "$x_includes"; then
2924             X_CFLAGS="$X_CFLAGS -I$x_includes"
2925         fi
2927         if test -n "$x_libraries"; then
2928             X_LIBS="$X_LIBS -L$x_libraries"
2929         fi
2931         if test "x-$no_x" = "x-yes" ; then
2933             dnl didn't find it
2934             if test "x-$x11_hidd" != "x-auto" ; then
2935                 dnl and they explicitly asked for it, bail out
2936                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2937             fi
2938         
2939         else
2940             dnl found it, setup the metatarget
2941             aros_target_options+="$export_newline""# Enable X11 Gfx Driver$export_newline""OPT_HOST_X11GFX               := yes$export_newline"
2942             if test "x-$host_feature_glx" != "x-no" ; then
2943                 aros_target_options+="$export_newline""# Enable X11 HostGL 3D Passthrough$export_newline""OPT_HOST_X11_HOSTGL           := yes$export_newline"
2944             fi
2945             ENABLE_X11=1
2947             aros_host_x11_cflags="$X_CFLAGS"
2948             aros_host_x11_ldflags="$X_LIBS  -lX11"
2950             dnl setup shared memory extensions
2951             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2952                                                   [use X11 shared memory (default=auto)]),
2953                                                   x11_hidd_shm="$enableval",
2954                                                   x11_hidd_shm="auto")
2955             case "x-$x11_hidd_shm" in
2956                 x-yes|x-no|x-auto)                     ;;
2957                 *)                 x11_hidd_shm="auto" ;;
2958             esac
2960             have_xshm=no
2962             dnl they want it
2963             if test "x-$x11_hidd_shm" != "x-no" ; then
2965                 dnl system shm headers
2966                 AC_CHECK_HEADERS(sys/ipc.h)
2967                 AC_CHECK_HEADERS(sys/shm.h)
2969                 dnl got them
2970                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2972                     dnl make sure X libs have shm functions
2973                     save_cflags="$CFLAGS"
2974                     save_ldflags="$LDFLAGS"
2975                     CFLAGS="$CFLAGS $X_CFLAGS"
2976                     LDFLAGS="$LDFLAGS $X_LIBS"
2977                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2978                     CFLAGS="$save_cflags"
2979                     LDFLAGS="$save_ldflags"
2980                 fi
2981             fi
2983             dnl detection done, prepare output
2984             if test "x-$have_xshm" = "x-yes" ; then
2985                 dnl we can do shm
2986                 DO_XSHM_SUPPORT="1"
2987             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2988                 dnl they explicitly asked for it, but we can't do it
2989                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2990             else
2991                 dnl otherwise just disable it
2992                 DO_XSHM_SUPPORT="0"
2993             fi
2995             
2996             dnl setup vidmode (fullscreen) extensions
2997             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2998                                                       [use X11 vidmode extension (default=auto)]),
2999                                                       x11_hidd_vidmode="$enableval",
3000                                                       x11_hidd_vidmode="auto")
3001             case "x-$x11_hidd_vidmode" in
3002                 x-yes|x-no|x-auto)                         ;;
3003                 *)                 x11_hidd_vidmode="auto" ;;
3004             esac
3006             have_vidmode=no
3008             dnl they want it
3009             if test "x-$x11_hidd_vidmode" != "x-no" ; then
3011                 dnl make sure X libs have vidmode functions
3012                 save_cflags="$CFLAGS"
3013                 save_ldflags="$LDFLAGS"
3014                 CFLAGS="$CFLAGS $X_CFLAGS"
3015                 LDFLAGS="$LDFLAGS $X_LIBS"
3016                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
3017                 CFLAGS="$save_cflags"
3018                 LDFLAGS="$save_ldflags"
3019             fi
3021             dnl detection done, prepare output
3022             if test "x-$have_vidmode" = "x-yes" ; then
3023                 dnl we can do vidmode
3024                 DO_VIDMODE_SUPPORT="1"
3025             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
3026                 dnl they explicitly asked for it, but we can't do it
3027                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
3028             else
3029                 dnl otherwise just disable it
3030                 DO_VIDMODE_SUPPORT="0"
3031             fi
3032         fi
3033     fi
3035     dnl sdl hidd
3036     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
3037                                            [build SDL hidd for hosted (default=auto)]),
3038                                            sdl_hidd="$enableval",
3039                                            sdl_hidd="auto")
3040     case "x-$sdl_hidd" in
3041         x-yes|x-no|x-auto)                 ;;
3042         *)                 sdl_hidd="auto" ;;
3043     esac
3045     dnl they want it
3046     if test "x-$sdl_hidd" != "x-no" ; then
3048         dnl find sdl
3049         SDL_VERSION=1.2.5
3050         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
3051             [have_sdl="no"])
3053         if test "x-$have_sdl" != "x-yes" ; then
3055             dnl didn't find it
3056             if test "x-$sdl_hidd" != "x-auto" ; then
3057                 dnl and they explicitly asked for it, bail out
3058                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
3059             fi
3061         else
3062             dnl found it, enable the build
3063             aros_target_options+="$export_newline""# Enable SDL Gfx Driver$export_newline""OPT_HOST_SDLGFX               := yes$export_newline"
3064             aros_host_sdl_cflags=$SDL_CFLAGS
3065             aros_host_sdl_libs=$SDL_LIBS
3066         fi
3067     fi
3072 dnl See if the user wants dbus.library
3073 AC_MSG_CHECKING([whether building of dbus.library is enabled])
3074 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
3075 if test "$dbus" = "yes" ; then
3076     ENABLE_DBUS=1
3077     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
3078     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
3079     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
3080     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
3081 else
3082     ENABLE_DBUS=0
3084 AC_MSG_RESULT($dbus)
3086 if test "$use_kernel_cc_wrapper" = "yes" ; then
3087     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
3090 aros_kernel_cppflags=$aros_config_cppflags
3091 aros_optimization_cflags="$optimization_level"
3092 if test "$optimization" = "default"; then
3093 AC_MSG_CHECKING([default optimization level to use])
3094 AC_MSG_RESULT($optimization_level)
3097 if ! test "$gcc_default_cpu" = "" ; then
3098     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"
3101 if test "$use_libatomic" = "yes" ; then
3102     aros_cxx_libs="$aros_cxx_libs  -latomic"
3105 dnl --------------------------------------------------------------------
3106 dnl Configuration Output Section
3107 dnl --------------------------------------------------------------------
3109 # Generic
3110 AC_SUBST(aros_arch)
3111 AC_SUBST(aros_cpu)
3112 AC_SUBST(aros_flavour)
3113 AC_SUBST(aros_flavour_uc)
3114 AC_SUBST(aros_target_toolchain)
3115 AC_SUBST(aros_toolchain_ld)
3116 AC_SUBST(aros_build_host)
3117 AC_SUBST(AROS_BUILDDIR)
3118 AC_SUBST(AROS_BUILDDIR_UNIX)
3119 AC_SUBST(SRCDIR)
3120 AC_SUBST(AROS_CROSSTOOLSDIR)
3121 AC_SUBST(AROS_PORTSSRCDIR)
3123 # Compatability with other Amiga-like operating systems
3124 AC_SUBST(aros_amigaos_compliance)
3126 # Host Related ###########################
3127 AC_SUBST(host_stat_h__unused_used)
3128 AC_SUBST(ax_cv_flex_version)
3129 AC_SUBST(host_extra_cfg)
3130 AC_SUBST(aros_cc_pre)
3131 AC_SUBST(aros_host_strip)
3132 AC_SUBST(aros_host_arch)
3133 AC_SUBST(aros_host_cpu)
3134 AC_SUBST(aros_host_cpp)
3135 AC_SUBST(aros_host_def_cc)
3136 AC_SUBST(aros_host_cc)
3137 AC_SUBST(aros_host_cxx)
3138 AC_SUBST(aros_host_ar)
3139 AC_SUBST(aros_host_ranlib)
3140 AC_SUBST(aros_host_ld)
3141 AC_SUBST(aros_host_make)
3142 AC_SUBST(aros_host_cppflags)
3143 AC_SUBST(aros_host_cflags)
3144 AC_SUBST(aros_host_cxxflags)
3145 AC_SUBST(gnu89_inline)
3146 AC_SUBST(aros_host_ldflags)
3147 AC_SUBST(aros_host_debug)
3148 AC_SUBST(aros_host_mkdep)
3149 AC_SUBST(aros_host_mkargs)
3150 AC_SUBST(aros_host_exe_suffix)
3151 AC_SUBST(aros_host_lib_suffix)
3152 AC_SUBST(aros_tools_dir)
3153 AC_SUBST(aros_host_aclocal)
3154 AC_SUBST(aros_host_autoconf)
3155 AC_SUBST(aros_host_autoheader)
3156 AC_SUBST(aros_host_automake)
3158 # Target Related #########################
3159 AC_SUBST(aros_elf_translate)
3160 AC_SUBST(make_extra_commands)
3161 AC_SUBST(make_extra_targetcfg)
3162 AC_SUBST(target_extra_cfg)
3163 AC_SUBST(aros_target_options)
3165 AC_SUBST(aros_target_guitheme)
3166 AC_SUBST(aros_target_iconset)
3167 AC_SUBST(aros_target_bootloader)
3168 AC_SUBST(aros_target_arch)
3169 AC_SUBST(aros_target_family)
3170 AC_SUBST(aros_target_cpu)
3171 AC_SUBST(aros_target_cpu_mode)
3172 AC_SUBST(aros_target_variant)
3173 AC_SUBST(aros_target_suffix)
3174 AC_SUBST(aros_target_ar)
3175 AC_SUBST(aros_target_ranlib)
3176 AC_SUBST(aros_plain_nm)
3177 AC_SUBST(aros_plain_ar)
3178 AC_SUBST(aros_kernel_ar)
3179 AC_SUBST(aros_kernel_ranlib)
3180 AC_SUBST(orig_target_cc)
3181 AC_SUBST(aros_target_cc)
3182 AC_SUBST(aros_kernel_cc)
3183 AC_SUBST(orig_target_cxx)
3184 AC_SUBST(aros_target_cxx)
3185 AC_SUBST(aros_kernel_cxx)
3186 AC_SUBST(orig_target_cpp)
3187 AC_SUBST(aros_target_cpp)
3188 AC_SUBST(aros_kernel_cpp)
3189 AC_SUBST(orig_target_as)
3190 AC_SUBST(aros_target_as)
3191 AC_SUBST(aros_kernel_as)
3192 AC_SUBST(orig_target_ld)
3193 AC_SUBST(aros_target_ld)
3194 AC_SUBST(aros_kernel_ld)
3195 AC_SUBST(aros_target_cc_includes)
3196 AC_SUBST(aros_target_cc_path)
3197 AC_SUBST(aros_target_objdump)
3198 AC_SUBST(aros_target_objcopy)
3199 AC_SUBST(aros_target_strip)
3200 AC_SUBST(aros_target_nm)
3201 AC_SUBST(aros_kernel_rescomp)
3202 AC_SUBST(aros_shared_default)
3203 AC_SUBST(aros_shared_ld)
3204 AC_SUBST(aros_object_format)
3205 AC_SUBST(spec_obj_format)
3206 AC_SUBST(aros_c_libs)
3207 AC_SUBST(aros_cxx_libs)
3209 AC_SUBST(aros_shared_cflags)
3210 AC_SUBST(aros_shared_aflags)
3211 AC_SUBST(aros_shared_ldflags)
3213 AC_SUBST(aros_warn_flags)
3214 AC_SUBST(aros_nowarn_flags)
3215 AC_SUBST(aros_config_cppflags)
3216 AC_SUBST(aros_config_cflags)
3217 AC_SUBST(aros_config_cxxflags)
3218 AC_SUBST(aros_config_aflags)
3219 AC_SUBST(aros_config_ldflags)
3221 AC_SUBST(aros_kernel_sysroot)
3222 AC_SUBST(aros_kernel_cppflags)
3223 AC_SUBST(aros_kernel_cflags)
3224 AC_SUBST(aros_kernel_includes)
3225 AC_SUBST(aros_kernel_objcflags)
3226 AC_SUBST(aros_kernel_ldflags)
3227 AC_SUBST(aros_debug_cppflags)
3228 AC_SUBST(aros_debug_cflags)
3229 AC_SUBST(aros_debug_cxxflags)
3230 AC_SUBST(aros_debug_aflags)
3231 AC_SUBST(aros_debug_ldflags)
3232 AC_SUBST(aros_target_genmap)
3233 AC_SUBST(aros_target_strip_flags)
3234 AC_SUBST(aros_config_lto)
3235 AC_SUBST(aros_config_coverage)
3236 AC_SUBST(aros_optimization_cflags)
3237 AC_SUBST(aros_kernel_isa_flags)
3238 AC_SUBST(aros_isa_extra)
3239 AC_SUBST(aros_isa_flags)
3241 AC_SUBST(crosstools_target)
3242 AC_SUBST(crosstools_cxx_target)
3244 AC_SUBST(use_libatomic)
3246 AC_SUBST(pci_hidd_target)
3248 AC_SUBST(aros_nominal_width)
3249 AC_SUBST(aros_nominal_height)
3250 AC_SUBST(aros_nominal_depth)
3252 # Native version related
3253 AC_SUBST(aros_serial_debug)
3254 AC_SUBST(PLATFORM_EXECSMP)
3255 AC_SUBST(ENABLE_EXECSMP)
3257 # MMU related
3258 AC_SUBST(aros_enable_mmu)
3260 # Bootloader related
3261 AC_SUBST(target_grub2_version)
3263 # Unix/Hosted version related
3264 AC_SUBST(aros_nesting_supervisor)
3266 # ARM default GCC target related
3267 AC_SUBST(gcc_default_cpu)
3268 AC_SUBST(gcc_default_cpu_tune)
3269 AC_SUBST(gcc_default_fpu)
3270 AC_SUBST(gcc_default_float_abi)
3271 AC_SUBST(gcc_default_mode)
3273 # Palm native version related
3274 AC_SUBST(aros_palm_debug_hack)
3276 # Apple iOS related
3277 AC_SUBST(aros_ios_platform)
3278 AC_SUBST(aros_ios_version)
3279 AC_SUBST(aros_ios_sdk)
3281 # Android related
3282 AC_SUBST(ant)
3283 AC_SUBST(android_tool)
3284 AC_SUBST(aros_android_level)
3285 AC_SUBST(aros_android_antapk)
3287 # Debug related
3288 AC_SUBST(aros_debug)
3289 AC_SUBST(aros_mungwall_debug)
3290 AC_SUBST(aros_stack_debug)
3291 AC_SUBST(aros_modules_debug)
3293 # Collect-aros stuff: "-ius" to ignore undefined symbols
3294 AC_SUBST(ignore_undefined_symbols)
3296 # C compiler related
3297 AC_SUBST(gcc_target_cpu)
3298 AC_SUBST(target_binutils_version)
3299 AC_SUBST(target_gcc_version)
3301 #ObjC compiler related
3302 AC_SUBST(objc_target)
3304 #Java related
3305 AC_SUBST(java_target)
3307 # DBUS related
3308 AC_SUBST(ENABLE_DBUS)
3309 AC_SUBST(DBUS_CFLAGS)
3310 AC_SUBST(DBUS_LIBFLAGS)
3311 AC_SUBST(KERNEL_DBUS_KOBJ)
3312 AC_SUBST(KERNEL_DBUS_INCLUDES)
3314 #X11 related
3315 AC_SUBST(ENABLE_X11)
3316 AC_SUBST(DO_XSHM_SUPPORT)
3317 AC_SUBST(DO_VIDMODE_SUPPORT)
3319 AC_SUBST(aros_host_x11_cflags)
3320 AC_SUBST(aros_host_x11_ldflags)
3322 #SDL related
3323 AC_SUBST(aros_host_sdl_cflags)
3324 AC_SUBST(aros_host_sdl_libs)
3326 # USB3.0 code
3327 AC_SUBST(aros_usb30_code)
3329 dnl Prepare for output, make up all the generated patches
3330 case "$aros_flavour" in
3331 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3332                 aros_flavour="emulation" ;;
3333 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3334                 aros_flavour="emulation" ;;
3335 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3336                 aros_flavour="standalone";;
3337 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3338                 aros_flavour="standalone";;
3339 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3340                 aros_flavour="native" ;;
3341 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3342                 aros_flavour="native" ;;
3343 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3344                 aros_flavour="linklib" ;;
3345 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3346                 aros_flavour="palmnative" ;;
3347 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3348                 aros_flavour="mac68knative" ;;
3349 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3350                 aros_flavour="ppcnative" ;;
3351 esac
3353 if test ! -d ${aros_inc_dir} ; then
3354     ${MKDIR} ${aros_inc_dir}
3356 if test ! -d ${aros_geninc_dir} ; then
3357     ${MKDIR} ${aros_geninc_dir}
3359 if test ! -d ${aros_hostcfg_dir} ; then
3360     ${MKDIR} ${aros_hostcfg_dir}
3362 if test ! -d ${aros_targetcfg_dir} ; then
3363     ${MKDIR} ${aros_targetcfg_dir}
3365 if test ! -d ${aros_tools_dir} ; then
3366     ${MKDIR} ${aros_tools_dir}
3368 if test ! -d ${aros_scripts_dir} ; then
3369     ${MKDIR} ${aros_scripts_dir}
3372 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3374 # Generic build tools (metamake, etc)
3375 AC_CONFIG_COMMANDS([genmf-executable-support],
3376     [
3377         chmod a+x ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname
3378         chmod a+x ${aros_tools_dir}/genmf.py
3379     ],
3380     [
3381         AROS_CROSSTOOLSDIR=${AROS_CROSSTOOLSDIR}
3382         aros_tools_dir=${aros_tools_dir}
3383     ]
3385 AC_CONFIG_FILES(
3386     Makefile
3387     config/make.cfg
3388     ${aros_inc_dir}/config.h:config/config.h.in
3389     ${aros_geninc_dir}/config.h:config/config.h.in
3390     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3391     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3392     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3393     mmake.config
3394     compiler/include/geninc.cfg:compiler/include/geninc.cfg.in
3395     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3396     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3397     ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname:scripts/uname.in
3398     tools/collect-aros/env.h
3401 # Binutils
3402 AC_CONFIG_COMMANDS([binutils-support],
3403     [
3404         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3405         mkdir -p $prefix
3406         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3408         chmod a+x ${prefix2}-ld
3410         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3411         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3412         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3413         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3414         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3415         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3416         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3417     ],
3418     [
3419         aros_host_exe_suffix=${aros_host_exe_suffix}
3420         aros_tools_dir=${aros_tools_dir}
3421         aros_target_cpu=${aros_target_cpu}
3422         aros_target_arch=${aros_target_arch}
3423         aros_target_suffix=${aros_target_suffix}
3424         orig_target_nm=${orig_target_nm}
3425         orig_target_as=${orig_target_as}
3426         orig_target_ar=${orig_target_ar}
3427         orig_target_ranlib=${orig_target_ranlib}
3428         orig_target_objdump=${orig_target_objdump}
3429         orig_target_objcopy=${orig_target_objcopy}
3430         orig_target_strip=${orig_target_strip}
3431         aros_kernel_ld=${aros_kernel_ld}
3432     ]
3434 if test "${use_ld_wrapper}" = "yes"; then
3435     AC_CONFIG_FILES(
3436         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3437     )
3439 # Bare Elf support script and spec
3440 if test "${use_kernel_cc_wrapper}" = "yes"; then
3441     AC_CONFIG_COMMANDS([elf-compiler-support],
3442         [
3443             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3444             mkdir -p $prefix
3445             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3447             chmod a+x ${prefix2}-gcc
3449             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3450         ],
3451         [
3452             aros_host_exe_suffix=${aros_host_exe_suffix}
3453             aros_tools_dir=${aros_tools_dir}
3454             aros_target_cpu=${aros_target_cpu}
3455             aros_target_arch=${aros_target_arch}
3456             aros_target_suffix=${aros_target_suffix}
3457             aros_kernel_ld=${aros_kernel_ld}
3458         ]
3459     )
3460     AC_CONFIG_FILES(
3461         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3462         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3463     )
3466 # Host compiler support scripts and spec
3467 if test "${aros_target_toolchain}" = "no"; then
3468     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3469         [
3470             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3471             mkdir -p $prefix
3472             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3474             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3475         ],
3476         [
3477             aros_host_exe_suffix=${aros_host_exe_suffix}
3478             aros_tools_dir=${aros_tools_dir}
3479             aros_target_cpu=${aros_target_cpu}
3480             aros_target_arch=${aros_target_arch}
3481             aros_target_suffix=${aros_target_suffix}
3482         ]
3483     )
3484     AC_CONFIG_FILES(
3485         ${aros_targetcfg_dir}/specs:config/specs.in
3486         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3487         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3488         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3489     )
3492 # Android support
3493 if test "$aros_target_variant" == "android"; then
3494     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3497 # cmake helper
3498 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3500 AC_OUTPUT
3502 dnl This is in order to not define SHARED_CFLAGS sometimes
3503 dnl We don't always do aros_shared_ar, aros_shared_cflags
3505 #XXX compatability...
3506 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3508 if test -n "$aros_shared_cflags" ; then
3509     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3510     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg