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