try not to display "blank" results if possible
[AROS.git] / configure.in
blob9e5371418b8a5aaee7f6416def05845e3ee83309
1 dnl Copyright © 1997-2016, The AROS Development Team. All rights reserved.
2 dnl $Id$
3 dnl
4 dnl Desc: Autoconf source for configuration file
5 dnl Lang: english 
7 # Note: After file changes, generate configure anew and commit _both_ files.
9 #TODO
10 # method of getting shared/non-shared ld/ar tool for target.
12 # ------------------------------------------------------------------------
13 # Here starts the first section of the configure.in file.
14 # ------------------------------------------------------------------------
16 AC_INIT(mmakefile)
17 AC_PREREQ(2.61)
18 AC_CONFIG_AUX_DIR(scripts/autoconf)
20 # Check what host we are running on.
21 # If a target is not suggested, we use this one.
22 # Note that what we call a target, Autoconf calls a host.
23 AC_CANONICAL_HOST
25 # Default versions for the gnu tools we build
26 default_gcc_version="4.6.4"
27 default_binutils_version="2.23.2"
29 # The AROS target is slightly different to the normal GNU style
30 # format. We don't have the middle part, and we reverse the order
31 # of the $(CPU) and $(OS) bits.
33 # Don't strip the version of the target yet, it might be
34 # useful on some systems.
36 AC_MSG_CHECKING([for AROS style target])
38 if test "$target" = "NONE" ; then
39     target=$host_os-$host_cpu
40 else
41     if test "$target" = "" ; then
42         target=$host_os-$host_cpu
43     fi
45 AC_MSG_RESULT($target)
47 if test "$host_os" = "mingw32" ; then
48     PWDCMD="pwd -W"
51 # Don't know where else to put this...
52 AC_MSG_CHECKING([building AROS in])
53 AROS_BUILDDIR=`${PWDCMD-pwd}`
54 AROS_BUILDDIR_UNIX=${PWD}
55 AC_MSG_RESULT($AROS_BUILDDIR)
57 AC_MSG_CHECKING([AROS source in])
58 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
59 SRCDIR=${srcpwd}
60 AC_MSG_RESULT($SRCDIR)
62 # Parse the target field into something useful.
63 changequote(<<,>>)
64 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
65 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
66 changequote([,])
68 # Some debug output, to be removed again.
69 AC_MSG_CHECKING([for target system (debug output)])
70 AC_MSG_RESULT($target_os)
71 AC_MSG_CHECKING([for target cpu (debug output)])
72 AC_MSG_RESULT($target_cpu)
74 dnl --------------------------------------------------------------------
75 dnl Set the default Workbench resolution
76 dnl --------------------------------------------------------------------
77 aros_nominal_width=800
78 aros_nominal_height=600
79 aros_nominal_depth=4
81 dnl --------------------------------------------------------------------
82 dnl Host Configuration Section
83 dnl --------------------------------------------------------------------
84 dnl
85 dnl The idea here is to find out all the information we need about the
86 dnl host. This means things like tools for building directory structures,
87 dnl copying files around and the like.
89 default_c_compilers="gcc clang cc"
90 AC_ARG_WITH(c-compiler,AC_HELP_STRING([--with-c-compiler=VERSION],[Use specified c compiler for building AROS]),use_c_compiler="$withval",use_c_compiler="")
91 if test "$use_c_compiler" = ""; then
92     host_c_compilers="$default_c_compilers"
93 else
94     host_c_compilers="$use_c_compiler"
97 default_cxx_compilers="g++ clang++ c++"
98 AC_ARG_WITH(cxx-compiler,AC_HELP_STRING([--with-cxx-compiler=VERSION],[Use specified c++ compiler building AROS]),use_cxx_compiler="$withval",use_cxx_compiler="")
99 if test "$use_cxx_compiler" = ""; then
100         host_cxx_compilers="$default_cxx_compilers"
101 else
102     host_cxx_compilers="$use_cxx_compiler"
106 # The first step is to find the host binaries.
107 # Check for a compiler.
108 # Due to a bug in autoconf check for c++ compiler first.
109 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
110 AC_PROG_CXX([${host_cxx_compilers}])
111 AC_PROG_CC([${host_c_compilers}])
112 aros_host_def_cc="$CC"
113 AC_PROG_CC_STDC
114 AC_PROG_CPP
116 # Check for a compatible awk
117 AC_CHECK_PROGS(AWK,[gawk nawk])
118 AROS_REQUIRED(gawk,$AWK)
119 AROS_PROG(MMAKE,mmake)
121 # Perform some default variable assignments. Note all of these will be
122 # Regenerated from the script, so there is no need to cache them.
124 aros_build_host=$host
125 aros_host_cpp="$CPP"
126 aros_host_cc="$CC"
127 aros_host_cxx="$CXX"
128 AROS_TOOL_CCPATH(aros_host_ld,ld)
129 AROS_REQUIRED(ld,$aros_host_ld)
130 aros_host_make="make"
131 aros_host_cflags="$CFLAGS"
132 aros_host_cxxflags="$CXXFLAGS"
133 aros_host_ldflags="$LDFLAGS"
134 aros_host_debug="-g -O0"
135 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
136 aros_host_mkargs="--no-print-directory"
137 aros_host_exe_suffix="$EXEEXT"
138 aros_host_lib_suffix=""
140 # Ignore all compliance, AROS ROMs = 0
141 # KickStart v1.0 = 30
142 # KickStart v1.3 = 34
143 # KickStart v2.0 = 37
144 # KickStart v3.0 = 39
145 # KickStart v3.1 = 40
146 # AmigaOS   v3.5 = 44
147 aros_amigaos_compliance=0
149 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
150 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
151 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
152 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
154 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
155 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
157 case "$aros_host_cc" in
158     *clang*)
159         aros_host_cc_pipe=""
160         ;;
161     *gcc*)
162         aros_host_cc_pipe="-pipe"
163         ;;
164     icc)
165         aros_host_cc_pipe=""
166         ;;
167     *)
168         aros_host_cc_pipe=""
169         ;;
170 esac
172 aros_kernel_cc_includes=""
173 aros_target_cc_includes=""
174 host_cc_elf=yes
176 # ----------------------------------------------------------------------------------------
177 # Host-specific defaults
179 # This is the main host configuration section. It is where the host
180 # can change the values of any variables it needs to change. We do
181 # not look at anything that compiles to the target yet, we'll get
182 # to that later.
184 case "$host_os" in
185     aros*)
186         aros_host_arch="aros"
187         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
188         case "$host_cpu" in
189             *i?86*)
190                 aros_host_cpu="i386"
191                 ;;
192             *x86_64*)
193                 aros_host_cpu="x86_64"
194                 ;;
195             *powerpc*)
196                 aros_host_cpu="ppc"
197                 ;;
198             *)
199                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
200                 aros_host_cpu="$host_cpu"
201                 ;;
202         esac
203         ;;
205     linux*)
206         aros_host_arch="linux"
207         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
208         android_build_os="linux-x86"
209         android_tool="android"
210         default_android_sdk="/opt/android-sdk-linux_x86"
211         case "$host_cpu" in
212             *i?86*)
213                 aros_host_cpu="i386"
214                 ;;
215             *x86_64*)
216                 aros_host_cpu="x86_64"
217                 ;;
218             *m68k*)
219                 aros_host_cpu="m68k"
220                 ;;
221             *powerpc*)
222                 aros_host_cpu="ppc"
223                 ;;
224             *arm*)
225                 aros_host_cpu="arm"
226                 ;;
227             *)
228                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
229                 aros_host_cpu="$host_cpu"
230                 ;;
231         esac
232         ;;
234     freebsd*)
235         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe -I/usr/local/include"
236         aros_host_make="gmake"
237         aros_host_arch="freebsd"
238         aros_host_cpu="i386"
240         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
242         dnl FreeBSD 5.x (and later) has changed the default object format.
243         dnl The double [[]] is necessary to get around m4's quoting rules.
244         case $host_os in
245             freebsd[[234]]*)
246                 aros_object_format="elf_i386"
247                 ;;
249             *)
250                 aros_object_format="elf_i386_fbsd"
251                 ;;
252         esac
254         ;;
256     darwin*)
257         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
258         aros_host_arch="darwin"
259         host_cc_elf=no
260         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
261         android_build_os="darwin-x86"
262         android_tool="android"
263         default_android_sdk="/android-sdk-mac_x86"
264         case "$host_cpu" in
265             *i?86*)
266                 aros_host_cpu="i386"
267                 ;;
268             *x86_64*)
269                 aros_host_cpu="x86_64"
270                 ;;
271             *powerpc*)
272                 aros_host_cpu="ppc"
273                 ;;
274             *)
275                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
276                 aros_host_cpu="$host_cpu"
277                 ;;
278         esac
280         aros_host_ldflags="$aros_host_ldflags -liconv"
282         ;;
284     dragonfly*)
285         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
286         aros_host_make="gmake"
287         aros_host_arch="dragonfly"
288         case $host_cpu in
289             *i?86*)
290                 aros_host_cpu="i386"
291                 ;;
292             *amd64*)
293                 aros_host_cpu="x86_64"
294                 ;;
295             *)
296                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
297                 aros_host_cpu="$host_cpu"
298                 ;;
299         esac
300         ;;
302     netbsd*)
303         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
304         aros_host_make="gmake"
305         aros_host_arch="netbsd"
306         case "$host_cpu" in
307             *i?86*)
308                 aros_host_cpu="i386"
309                 ;;
310             *m68k*)
311                 aros_host_cpu="m68k"
312                 ;;
313             *)
314                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
315                 aros_host_cpu="$host_cpu"
316                 ;;
317         esac    
318         aros_host_lib_suffix=".0.0"
319         ;;
321     openbsd*)
322         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
323         aros_host_make="gmake"
324         aros_host_arch="openbsd"
325         case "$host_cpu" in
326             *i?86*)
327                 aros_host_cpu="i386"
328                 ;;
329             *)
330                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
331                 aros_host_cpu="$host_cpu"
332                 ;;
333         esac
334         ;;
335         
336     solaris*)
337         aros_host_arch="solaris"
338         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
339         case "$host_cpu" in
340             *i?86*)
341                 aros_host_cpu="i386"
342                 ;;
343             *sparc*)
344                 aros_host_cpu="sparc"
345                 ;;
346             *)
347                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
348                 aros_host_cpu="$host_cpu"
349                 ;;
350         esac
351         ;;
353     morphos*)
354         aros_host_arch="morphos"
355         aros_host_cpu="ppc"
356         host_cc_elf=no
357         ;;
359     amiga*)
360         aros_host_arch="amiga"
361         host_cc_elf=no
362         SORT="/gg/bin/sort"
363         TEST="/gg/bin/test"
364         UNIQ="/gg/bin/uniq"
365         FOR="for"
366         TOUCH="/gg/bin/touch"
367         case "$host_cpu" in
368             *m68k*)
369                 aros_host_cpu="m68k"
370                 ;;
371             *powerpc*)
372                 aros_host_cpu="ppc"
373                 ;;
374             *)
375                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
376                 aros_host_cpu="$host_cpu"
377                 ;;
378         esac
379         ;;
381     cygwin*)
382         aros_host_arch="cygwin"
383         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
384         host_cc_elf=no
385         android_build_os="windows"
386         android_tool="android.bat"
387         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
389         case "$host_cpu" in
390             *i?86*)
391                 aros_host_cpu="i386"
392                 ;;
393             *)
394                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
395                 aros_host_cpu="$host_cpu"
396                 ;;
397         esac
398         ;;
400     mingw32*)
401         aros_host_arch="mingw32"
402         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
403         host_cc_elf=no
404         android_build_os="windows"
405         android_tool="android.bat"
406         default_android_sdk="/c/android-sdk-windows-1.6_r1"
408         libpng_libextra="-lws2_32"
410         case "$host_cpu" in
411         *i?86*)
412             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
413             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
414             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
415             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
417             AC_MSG_CHECKING([for Windows native gcc target])
418             host_cpu=`gcc -dumpmachine`
419             AC_MSG_RESULT($host_cpu)
420             ;;
422         esac
424         case "$host_cpu" in
425         *i?86*)
426             aros_host_cpu="i386"
427             ;;
429         mingw32*)
430             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
431             aros_host_cpu="i386"
432             ;;
434         *x86_64*)
435             aros_host_cpu="x86_64"
436             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
437             dnl directory, so we have to add it explicitly here.
438             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
439             ;;
441         *)
442             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
443             aros_host_cpu="$host_cpu"
444             ;;
445         esac
446         ;;
447     *)
448         AC_MSG_ERROR([Unsupported host architecture $host])
449         ;;
450 esac
452 AROS_PROG(aros_host_ar,[ar],[cr])
453 AROS_REQUIRED(ar,$aros_host_ar)
454 AROS_PROG(aros_host_ranlib,ranlib)
455 AROS_REQUIRED(ranlib,$aros_host_ranlib)
456 AROS_PROG(aros_host_strip,strip)
457 AROS_REQUIRED(strip,$aros_host_strip)
459 AROS_PROG(RM,[rm],[-rf])
460 AROS_REQUIRED(rm,$RM)
461 AROS_PROG(CP,[cp])
462 AROS_REQUIRED(cp,$CP)
463 AROS_PROG(MV,[mv])
464 AROS_REQUIRED(mv,$MV)
465 AROS_PROG(ECHO,[echo])
466 AROS_REQUIRED(echo,$ECHO)
467 AROS_PROG(MKDIR,[mkdir],[-p])
468 AROS_REQUIRED(mkdir,$MKDIR)
469 AROS_PROG(TOUCH,[touch])
470 AROS_REQUIRED(touch,$TOUCH)
471 AROS_PROG(SORT,[sort])
472 AROS_REQUIRED(sort,$SORT)
473 AROS_PROG(UNIQ,[uniq])
474 AROS_REQUIRED(uniq,$UNIQ)
475 AROS_PROG(NOP,[true])
476 AROS_REQUIRED(true,$NOP)
477 AROS_PROG(CAT,[cat])
478 AROS_REQUIRED(cat,$CAT)
479 AROS_PROG(BISON,[bison])
480 AROS_REQUIRED(bison,$BISON)
481 AROS_PROG(FLEX,[flex])
482 AROS_REQUIRED(flex,$FLEX)
483 AROS_PROG(PNGTOPNM,[pngtopnm])
484 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
485 AROS_PROG(PPMTOILBM,[ppmtoilbm])
486 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
487 AROS_PROG(SED,[sed])
488 AROS_REQUIRED(sed,$SED)
489 AROS_PROG(CHMOD,[chmod])
490 AROS_REQUIRED(chmod,$CHMOD)
491 AROS_PROG(PATCH,[patch])
492 AROS_REQUIRED(patch,$PATCH)
494 AM_PATH_PYTHON(2.5)
496 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
497 if test "$enable_libpng_config" != "no"; then
498   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
500 if test "$arosconfig_use_libpngconfig" = "yes"; then
501     AC_MSG_CHECKING([libpng-config library])
502     libpng_incdir="`libpng-config --cflags`"
503     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
504     libpng="`libpng-config --libs`"
505     AC_MSG_RESULT($libpng)
506 else
507     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
508     if test "$libpng_libextra" != ""; then
509         if test "$libpng" != "no"; then
510             libpng_libextra="$libpng_libextra $libpng"
511         fi
512     fi
514 AROS_REQUIRED(libpng, $libpng)
515 AC_SUBST(libpng)
516 AC_SUBST(libpng_libextra)
517 AC_SUBST(libpng_incdir)
519 AC_SUBST(FOR, for)
520 AC_SUBST(IF, if)
521 AC_SUBST(TEST, test)
522 AC_SUBST(CMP, cmp)
524 dnl ---------------------------------------------------------------------------
525 dnl Look for things about the host system, good for hosted targets.
526 dnl ---------------------------------------------------------------------------
528 # Check for some includes for the X11 HIDD and the kernel
529 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
530     sys/mmap.h sys/mman.h sysexits.h \
531     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
534 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
536 AC_HEADER_DIRENT
537 AC_HEADER_STAT
538 AC_HEADER_STDC
539 AC_HEADER_SYS_WAIT
540 AC_HEADER_TIME
541 AC_STRUCT_ST_BLKSIZE
542 AC_STRUCT_ST_BLOCKS
543 AC_STRUCT_ST_RDEV
544 AC_STRUCT_TM
545 AC_STRUCT_TIMEZONE
546 AC_TYPE_OFF_T
547 AC_TYPE_PID_T
548 AC_TYPE_SIZE_T
549 AC_TYPE_UID_T
551 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
553 # Look for some functions
554 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
555     clone kse_create rfork_thread thr_create sa_register \
556     getcontext makecontext setcontext sigaltstack swapcontext])
558 AC_FUNC_MMAP
560 #-----------------------------------------------------------------------------
563 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
564 # it switched on by default, and we use the host compiler, so it compiles AROS
565 # code with this enabled resulting in link failures as we don't have support
566 # for it.
568 # We use two methods to disable it. For the host compiler (used to compile
569 # some hosted modules), we test to see if the compiler supports stack
570 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
571 # work on all platforms.
574 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
575 save_cflags="$CFLAGS"
576 CFLAGS="$CFLAGS -fno-stack-protector"
577 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
578 AC_MSG_RESULT($use_no_stack_protector)
579 if test "x-$use_no_stack_protector" = "x-yes" ; then
580     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
582 CFLAGS="$save_cflags"
584 #-----------------------------------------------------------------------------
586 # Disable pointer-signedness warnings if the compiler recognises the option
587 # (this only works for the host compiler at the moment)
589 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
590 save_cflags="$CFLAGS"
591 CFLAGS="$CFLAGS -Wno-pointer-sign"
592 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
593 AC_MSG_RESULT($use_no_sign_warning)
594 if test "x-$use_no_sign_warning" = "x-yes" ; then
595     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
597 CFLAGS="$save_cflags"
599 #-----------------------------------------------------------------------------
601 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
603 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
604 save_cflags="$CFLAGS"
605 CFLAGS="$CFLAGS -fgnu89-inline"
606 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
607 AC_MSG_RESULT($use_gnu89_inline)
608 if test "x-$use_gnu89_inline" = "x-yes" ; then
609     gnu89_inline="-fgnu89-inline"
611 CFLAGS="$save_cflags"
614 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
615 # On GCC >= 4.0 -iquote should be used
617 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
618 CFLAGS="$CFLAGS -iquote."
619 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
620 AC_MSG_RESULT($has_iquote)
621 if test "x-$has_iquote" = "x-yes" ; then
622     host_cflags_iquote=-iquote
623     host_cflags_iquote_end=
624 else
625     host_cflags_iquote=-I
626     host_cflags_iquote_end=-I-
629 AC_MSG_NOTICE([Performing target configuration...])
631 dnl --------------------------------------------------------------------
632 dnl Target Configuration Section
633 dnl --------------------------------------------------------------------
635 dnl The target configuration section is responsible for setting up all
636 dnl the paths for includes, and tools required to build AROS to some
637 dnl particular target.
639 aros_nowarn_flags="NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
641 toolchain_needs_sysroot=no
643 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
644 aros_config_aflags="-Wall -x assembler-with-cpp -c"
645 aros_config_ldflags=""
647 aros_shared_default=yes
649 aros_shared_cflags="-fPIC"
650 aros_shared_aflags=""
651 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
652 aros_kernel_ldflags="-Wl,-rpath,./lib"
654 aros_kernel_ar_flags="cr"
655 aros_target_ar_flags="cr"
656 aros_target_nm_flags="-C -ul"
657 aros_target_strip_flags="--strip-unneeded -R.comment"
659 aros_compiler_libs=
660 aros_arch_libs=
662 aros_target_genmap="-Wl,-Map -Xlinker"
664 # Native flavour stuff
665 aros_serial_debug="0"
667 # Palm native flavour stuff
668 aros_palm_debug_hack="0"
670 # Unix flavour stuff
671 aros_nesting_supervisor="0"
673 # Collect-aros stuff: "-ius" to ignore undefined symbols
674 ignore_undefined_symbols=""
676 # Check for X11 by default
677 need_x11="auto"
679 host_x_gfx=no
680 host_sdl_gfx=no
681 host_android_gfx=no
684 AC_MSG_CHECKING([Which toolchain family to use ...])
685 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")
686 AC_MSG_RESULT($aros_toolchain)
688 case "$aros_toolchain" in
689     *llvm*)
690         # toolchain_needs_sysroot=yes
691         toolchain_c_compiler="clang"
692         toolchain_cxx_compiler="clang++"
693         toolchain_cpp_preprocessor="clang -E"
694         toolchain_ld="lld"
695         toolchain_as="llvm-as"
696         toolchain_ar="llvm-ar"
697         toolchain_ranlib="llvm-ranlib"
698         toolchain_nm="llvm-nm"
699         toolchain_strip="true"
700         toolchain_objcopy="llvm-objcopy"
701         toolchain_objdump="llvm-objdump"
702         ;;
703     *gnu*)
704         toolchain_c_compiler="gcc"
705         toolchain_cxx_compiler="g++"
706         toolchain_cpp_preprocessor="cpp"
707         toolchain_ld="ld"
708         toolchain_as="as"
709         toolchain_ar="ar"
710         toolchain_ranlib="ranlib"
711         toolchain_nm="nm"
712         toolchain_strip="strip"
713         toolchain_objcopy="objcopy"
714         toolchain_objdump="objdump"
715         ;;
716     *)
717         AC_MSG_WARN("Unknown toolchain family!")
718         toolchain_c_compiler="cc"
719         toolchain_cxx_compiler="c++"
720         toolchain_cpp_preprocessor="cpp"
721         toolchain_ld="ld"
722         toolchain_as="as"
723         toolchain_ar="ar"
724         toolchain_ranlib="ranlib"
725         toolchain_nm="nm"
726         toolchain_strip="strip"
727         toolchain_objcopy="objcopy"
728         toolchain_objdump="objdump"
729         ;;
730 esac
732 #-----------------------------------------------------------------------------
734 AC_MSG_CHECKING([which type of build to do])
735 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")
737 if test "$build_type" = "nightly"; then
738     build_type_string="NIGHTLY"
739 elif test "$build_type" = "snapshot"; then
740     build_type_string="SNAPSHOT"
741 elif test "$build_type" = "milestone"; then
742     build_type_string="MILESTONE"
743 elif test "$build_type" = "release"; then
744     build_type_string="RELEASE"
745 else
746     build_type_string="PERSONAL"
747     build_type="personal"
750 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
752 AC_MSG_RESULT($build_type)
754 #-----------------------------------------------------------------------------
755 all_debug_types="messages stack modules mungwall symbols"
757 AC_MSG_CHECKING([which debug types to enable])
758 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)]),
759  debug="$enableval",debug="")
761 if test "$debug" = "" -o "$debug" = "no"; then
762     debug="none"
763 elif test "$debug" = "yes"; then
764     debug="all"
767 if test "$debug" = "all" ; then
768     debug="messages stack modules symbols"
769     for d in $all_debug_types; do
770         export aros_${d}_debug="1"
771     done
772 else
773     for d in $all_debug_types; do
774         export aros_${d}_debug="0"
775     done
778 if test "$debug" != "none"; then
779     debug=`echo $debug | sed s/,/\ /g`
780     for d in $debug; do
781         found="0"
782         for d2 in $all_debug_types; do
783             if test "$d2" = "$d"; then
784                 found="1"
785                 break
786             fi
787         done
788         if test "$found" = "0"; then
789             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
790         fi
791         export aros_${d}_debug="1"
792     done
793     aros_debug="yes"
795 AC_MSG_RESULT($debug)
797 if test "$aros_messages_debug" = "1"; then
798     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
799 else
800     aros_messages_debug=""
802 if test "$aros_symbols_debug" = "1"; then
803     aros_symbols_debug="-g"
804 else
805     aros_symbols_debug=""
808 # These are the flags to pass when compiling debugged programs
809 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
810 aros_debug_aflags=""
811 aros_debug_ldflags="$aros_symbols_debug"
813 #-----------------------------------------------------------------------------
814 #   Checking for distcc and ccache.
816 #   Always apply the transforms in this particular order. Basically you should
817 #   always run 'ccache distcc compiler' in that order for the best performance.
819 AC_MSG_CHECKING([whether to enable distcc])
820 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
821 if test "$distcc" != "" -a "$distcc" != "no"; then
822     # AC_CHECK_PROG will print out the result in this case
823     AC_PATH_PROG(DISTCC,[distcc],distcc,)
824 else
825     AC_MSG_RESULT(no)
828 AC_MSG_CHECKING([whether to enable ccache])
829 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
830 if test "$ccache" != "" -a "$ccache" != "no"; then
831     # AC_CHECK_PROG will print out the result in this case
832     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
833 else
834     AC_MSG_RESULT(no)
837 #-----------------------------------------------------------------------------
838 AC_MSG_CHECKING([what specific host gcc version to use])
839 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="")
840 if test "$kernel_tool_version" != "" ; then
841     msg_result=$kernel_tool_version
842 else
843     msg_result="default"
845 AC_MSG_RESULT($msg_result)
847 #-----------------------------------------------------------------------------
848 AC_MSG_CHECKING([what optimization flags to use])
849 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
850 if test "$optimization" = "unknown"; then
851     dnl default is -O2 for normal builds, -O0 for debug builds
852     if test "$debug" != "none"; then
853         optimization="-O0"
854     else
855         optimization="-O2"
856     fi
858 aros_optimization_cflags="$optimization"
859 AC_MSG_RESULT($optimization)
861 #-----------------------------------------------------------------------------
862 AC_MSG_CHECKING([which paranoia flags to use])
863 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[compiler warning flags to enable for paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
864 if test "$paranoia_flags" = "default"; then
865         paranoia_flags=""
866         msg_result="none"
867 else if test "$paranoia_flags" = "yes"; then
868         paranoia_flags="-Wall -Werror"
869         msg_result="$paranoia_flags"
870 fi fi
871 AC_MSG_RESULT($msg_result)
872 aros_config_cflags="$aros_config_cflags $paranoia_flags"
874 #-----------------------------------------------------------------------------
875 AC_MSG_CHECKING([what target variant to enable])
876 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
877 if test "$target_variant" = ""; then
878     aros_target_variant=""
879     aros_target_suffix=""
880     enableval="none"
881 else
882     aros_target_variant="$target_variant"
883     aros_target_suffix="-$target_variant"
885 AC_MSG_RESULT($enableval)
887 #-----------------------------------------------------------------------------
888 # Target-specific defaults. You can override then on a per-target basis.
890 # Bootloader name. Currently used by PC target.
891 target_bootloader="none"
892 ENABLE_EXECSMP=
894 #-----------------------------------------------------------------------------
895 # Additional options for some specific targets
897 case "$aros_target_variant" in
898 ios)
899     AC_MSG_CHECKING([XCode path])
900     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")
901     AC_MSG_RESULT($aros_xcode_path)
903     AC_MSG_CHECKING([what iOS SDK version to use])
904     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")
905     AC_MSG_RESULT($aros_sdk_version)
907     ;;
909 "android")
910     AC_MSG_CHECKING([Android SDK path])
911     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)
912     AC_MSG_RESULT($aros_android_sdk)
914     AC_MSG_CHECKING([Android NDK path])
915     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
916     AC_MSG_RESULT($aros_android_ndk)
918     AC_MSG_CHECKING([what Android SDK version to use])
919     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")
920     AC_MSG_RESULT($aros_sdk_version)
922     aros_android_level=android-$aros_sdk_version
923     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
924         echo "Platform $aros_android_level is not installed in your SDK"
925         echo "Use --with-sdk-version=<API level number> to select another platform version"
926         echo "You can check what plaform versions are installed in your SDK"
927         echo "by examining contents of $aros_android_sdk/platforms directory"
928         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
929     fi
931     export PATH="$aros_android_sdk/tools:$PATH"
932     AC_PATH_PROG(android_tool, $android_tool)
933     AROS_REQUIRED(android,$android_tool)
935     if test "$aros_android_ndk" != "none"; then
936         AC_MSG_CHECKING([what Android NDK version to use])
937         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")
938         AC_MSG_RESULT($aros_ndk_version)
939     fi
941     AC_PATH_PROG(ant, ant)
942     if test "$ant" = ""; then
943         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
944     fi
946     AC_MSG_CHECKING([Build debug or release apk])
947     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)
948     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
949         AC_MSG_ERROR([apk-version has to be release or debug])
950     fi
951     AC_MSG_RESULT($aros_android_antapk)
953     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
954     if test "$host_os" = "mingw32"; then
955         android_tool="cmd //c $android_tool"
956     fi
958     need_dlopen="no"
960     ;;
961 esac
963 #-----------------------------------------------------------------------------
964 # External toolchains
965 kernel_tool_prefix="none"
966 aros_tool_prefix="none"
967 elf_tool_prefix="${target_cpu}-elf-"
969 # This is the target configuration switch.
970 case "$target_os" in
971     linux*)
972         aros_target_arch="linux"
973         aros_target_family="unix"
974         case "$target_cpu" in
975             *m68k*)
976                 aros_target_cpu="m68k"
977                 aros_object_format="m68kelf"
978                 aros_flavour="emulcompat"
979                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
980                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
981                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
982                 gcc_target_cpu="mc68000"
983                 ;;
984             *i?86*)
985                 aros_target_cpu="i386"
986                 aros_object_format="elf_i386"
987                 aros_flavour="emulation"
988                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
989                 aros_kernel_ldflags="-Wl,-melf_i386"
990                 aros_nominal_depth=8
991                 gcc_target_cpu="i386"
992                 pci_hidd_target="hidd-pci-linux"
993                 android_tool_dir_prefix="x86"
994                 android_tool_prefix="i686-android-linux"
995                 android_ndk_arch="x86"
996                 ;;
997             *x86_64*)
998                 aros_target_cpu="x86_64"
999                 aros_object_format="elf_x86_64"
1000                 aros_flavour="emulation"
1001                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1002                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1003                 aros_nominal_depth=8
1004                 pci_hidd_target="hidd-pci-linux"
1005                 ;;
1006             *powerpc*)
1007                 aros_target_cpu="ppc"
1008                 aros_object_format="elf32ppc"
1009                 aros_flavour="emulation"
1010                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1011                 aros_nominal_depth=8
1012                 gcc_target_cpu="ppc"
1013                 ;;
1014 # TODO
1015 # Same as powerpc, but I need this for the nightly build to work again.
1016 # Actually, the nightly should be made working with powerpc target.
1017 # That just was too much work for the moment, another week or two.
1018             *ppc*)
1019                 aros_target_cpu="ppc"
1020                 aros_object_format="elf32ppc"
1021                 aros_flavour="emulation"
1022                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1023                 aros_nominal_depth=8
1024                 gcc_target_cpu="ppc"
1025                 ;;
1026             *aarch64*)
1027                 aros_target_cpu="aarch64"
1028                 target_cpu="aarch64"
1029                 aros_object_format="aarch64elf_aros"
1030                 aros_flavour="emulation"
1031                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1032                 gcc_target_cpu="aarch64"
1033                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1034                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1035                 aros_arch_libs="-laeabi"
1036                 gcc_default_float_abi="hard"
1037                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1038                 ;;
1039             *armhf*)
1040                 aros_target_cpu="arm"
1041                 target_cpu="arm"
1042                 aros_object_format="armelf_aros"
1043                 aros_flavour="emulation"
1044                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1045                 gcc_target_cpu="arm"
1046                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1047                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1048                 aros_arch_libs="-laeabi"
1049                 gcc_default_float_abi="hard"
1050                 android_tool_dir_prefix="arm-linux-androideabi"
1051                 android_tool_prefix="arm-linux-androideabi"
1052                 android_ndk_arch="arm"
1053                 kernel_tool_prefix="arm-linux-gnueabihf-"
1054                 ;;
1055             *arm*)
1056                 aros_target_cpu="arm"
1057                 aros_object_format="armelf_aros"
1058                 aros_flavour="emulation"
1059                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1060                 gcc_target_cpu="arm"
1061                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1062                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1063                 aros_arch_libs="-laeabi"
1064                 android_tool_dir_prefix="arm-linux-androideabi"
1065                 android_tool_prefix="arm-linux-androideabi"
1066                 android_ndk_arch="arm"
1067                 kernel_tool_prefix="arm-linux-gnueabi-"
1068                 ;;
1069             *)
1070                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1071                 ;;
1072         esac
1073         case "$aros_target_variant" in
1074             android)
1076                 dnl Not all Linux CPUs are supported by Android
1077                 if test "$android_ndk_arch" = ""; then
1078                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1079                 fi
1081                 aros_nominal_width=320
1082                 aros_nominal_height=480
1083                 if test "$aros_android_ndk" = "none"; then
1084                     dnl Use standalone toolchain, don't adjust paths
1085                     aros_kernel_cflags="-mandroid"
1086                     aros_kernel_ldflags="-mandroid"
1087                     CFLAGS="-mandroid"
1088                 else
1089                     dnl In Android NDK toolchains are placed in own directories,
1090                     dnl but tool names are not suffixed with version 
1091                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1092                     kernel_tool_version=""
1093                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1094                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1095                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1096                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1097                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1098                 fi
1099                 need_x11=no
1100                 host_android_gfx=yes
1101                 # Disable implicit PIC mode
1102                 aros_target_cflags="$aros_target_cflags -fno-pic"
1103                 kernel_tool_prefix="$android_tool_prefix-"
1104             ;;
1105         esac
1106     ;;
1108     pc)
1109         aros_target_arch="pc"
1110         aros_shared_default="no"
1111         target_bootloader="grub2"
1112         case "$target_cpu" in
1113             *i?86*)
1114                 aros_target_cpu="i386"
1116                 dnl If somebody hasn't already set the target object
1117                 dnl format, then use this value. Mostly to support
1118                 dnl FreeBSD cross-compilation.
1119                 dnl TODO: Remove when we always use our compiler.
1121                 if test "$aros_object_format" = "" ; then
1122                     aros_object_format="elf_i386"
1123                 fi
1124                 aros_flavour="standalone"
1125                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1126                 aros_kernel_ldflags="-Wl,-melf_i386"
1127                 aros_nominal_width=640
1128                 aros_nominal_height=480
1129                 gcc_target_cpu="i386"
1130                 ;;
1131             *x86_64*)
1132                 aros_target_cpu="x86_64"
1133                 aros_serial_debug=1
1134                 if test "$aros_object_format" = "" ; then
1135                     aros_object_format="elf_x86_64"
1136                 fi
1137                 aros_flavour="standalone"
1138                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1139                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1140                 aros_kernel_ldflags=""
1141                 aros_nominal_width=640
1142                 aros_nominal_height=480
1143                 case "$aros_target_variant" in
1144                     smp)
1145                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1146                     ;;
1147                 esac
1148                 ;;
1149             *)
1150                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1151                 ;;
1152         esac
1153         ;;
1155     prep)
1156         aros_target_arch="prep"
1157         aros_shared_default="no"
1158         aros_target_cpu="ppc"
1159         aros_object_format="elf32ppc"
1160         aros_flavour="ppcnative"
1161         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1162         aros_kernel_ldflags=""
1163         aros_nominal_width=640
1164         aros_nominal_height=480
1165         gcc_target_cpu="ppc"
1166         ;;
1168     freebsd*)
1169         aros_target_arch="freebsd"
1170         aros_target_family="unix"
1171         aros_target_cpu="i386"
1172         aros_flavour="emulation"
1173         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1174         gcc_target_cpu="i386"
1176         aros_target_strip_flags="-x"
1177         ;;
1179     darwin*)
1180         aros_target_arch="darwin"
1181         aros_target_family="unix"
1182         aros_flavour="emulation"
1183         case "$target_cpu" in
1184             *i?86*)
1185                 aros_ios_platform="iPhoneSimulator"
1186                 aros_target_cpu="i386"
1187                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1188                 aros_kernel_ldflags=""
1189                 aros_macosx_version="10.4"
1190                 aros_nominal_depth=8
1191                 gcc_target_cpu="i386"
1192                 aros_object_format="elf_i386"
1193                 aros_kernel_ar_flags="-cr"
1194                 aros_target_strip_flags="-x"
1195                 kernel_tool_flags="-m32"
1196                 ;;
1197             *x86_64*)
1198                 aros_target_cpu="x86_64"
1199                 aros_object_format="elf_x86_64"
1200                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1201                 aros_macosx_version="10.6"
1202                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1203                 aros_kernel_cflags="-m64"
1204                 aros_kernel_ldflags="-m64"
1205                 aros_target_cflags="-mcmodel=large"
1206                 aros_nominal_depth=8
1207                 aros_kernel_ar="ar"
1208                 aros_kernel_ar_flags="-cr"
1209                 aros_kernel_ld="ld"
1210                 aros_kernel_as="as"
1211                 aros_kernel_ranlib="ranlib"
1212                 aros_kernel_nm="nm"
1213                 aros_kernel_strip="strip"
1214                 kernel_tool_prefix="i686-apple-darwin10-"
1215                 ;;
1216             *ppc*)
1217                 aros_target_cpu="ppc"
1218                 aros_object_format="elf32ppc"
1219                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1220                 aros_kernel_ldflags=""
1221                 aros_macosx_version="10.0"
1222                 aros_nominal_depth=8
1223                 gcc_target_cpu="ppc"
1224                 aros_kernel_ar="ar"
1225                 aros_kernel_ar_flags="-cr"
1226                 aros_kernel_ld="ld -arch ppc"
1227                 aros_kernel_as="as -arch ppc"
1228                 aros_kernel_ranlib="ranlib -arch ppc"
1229                 aros_kernel_nm="nm -arch ppc"
1230                 aros_kernel_strip="strip -arch ppc"
1231                 kernel_tool_prefix="powerpc-apple-darwin10-"
1232                 ;;
1233             *arm*)
1234                 aros_ios_platform="iPhoneOS"
1235                 aros_target_cpu="arm"
1236                 aros_object_format="armelf_aros"
1237                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1238                 aros_arch_libs="-laeabi"
1239                 aros_nominal_depth=8
1240                 gcc_target_cpu="arm"
1241                 aros_kernel_ar="ar"
1242                 aros_kernel_ar_flags="-cr"
1243                 aros_kernel_ld="ld -arch arm"
1244                 aros_kernel_ranlib="ranlib -arch arm"
1245                 kernel_tool_prefix="arm-apple-darwin10-" 
1246                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1247                 ;;
1248             *)
1249                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1250                 ;;
1251         esac
1252         case "$aros_target_variant" in
1253             ios)
1254                 aros_ios_version="3.0"
1255                 aros_nominal_width=320
1256                 aros_nominal_height=480
1257                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1258                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1259                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1260                 need_x11=no
1261                 # This is here because it may depend on iOS or SDK version
1262                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1263                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1264                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1265             ;;
1266             *)
1267                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1268                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1269             ;;
1270         esac
1271         ;;
1273     dragonfly*)
1274         aros_target_arch="dragonfly"
1275         aros_target_family="unix"
1276         aros_flavour="emulation"
1277         case "$target_cpu" in
1278             *i?86*)
1279                 aros_target_cpu="i386"
1280                 aros_object_format="elf_i386"
1281                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1282                 ;;
1283             *x86_64*)
1284                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1285                 aros_target_cpu="x86_64"
1286                 aros_object_format="elf_x86_64"
1287                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1288                 ;;
1289             *)
1290                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1291                 ;;
1292         esac
1293         ;;
1295     netbsd*)
1296         aros_target_arch="netbsd"
1297         aros_target_family="unix"
1298         case "$target_cpu" in
1299             *m68k*)
1300                 aros_target_cpu="m68k"
1301                 aros_object_format="m68kelf"
1302                 aros_flavour="emulcompat"
1303                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1304                 gcc_target_cpu="mc68000"
1305                 ;;
1306             *i?86*)
1307                 aros_target_cpu="i386"
1308                 aros_object_format="elf_i386"
1309                 aros_flavour="emulation"
1310                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1311                 aros_nominal_depth=8
1312                 gcc_target_cpu="i386"
1313                 ;;
1314             *)
1315                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1316                 ;;
1317         esac
1318         aros_target_genmap="-Wl,-M -Xlinker >"
1319         aros_flavour="emulation"
1320         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1321         ;;   
1323     openbsd*)
1324         aros_target_arch="openbsd"
1325         aros_target_family="unix"
1326         case "$target_cpu" in
1327             *i?86*)
1328                 aros_target_cpu="i386"
1329                 aros_object_format="elf_i386"
1330                 aros_flavour="emulation"
1331                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1332                 gcc_target_cpu="i386"
1333                 ;;
1334             *)
1335                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1336                 ;;
1337         esac
1338         aros_target_genmap="-Wl,-M -Xlinker >"
1339         aros_target_nm_flags="-u"
1340         aros_flavour="emulation"
1341         ;;
1343     solaris*)
1344         aros_target_arch="solaris"
1345         aros_target_family="unix"
1346         case "$target_cpu" in
1347            *i?86*)
1348                aros_target_cpu="i386"
1349                aros_object_format="elf_i386"
1350                aros_flavour="emulation"
1351                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1352                aros_nominal_depth=8
1353                gcc_target_cpu="i386"
1354                ;;
1355             *sparc*)
1356                 aros_target_cpu="sparc"
1357                 aros_object_format="elf_sparc"
1358                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1359                 gcc_target_cpu="sparc"
1360                 ;;
1361             *)
1362                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1363                 ;;
1364         esac
1365         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1366         aros_flavour="emulation"
1367         ;;
1369     morphos*)
1370         aros_target_arch="morphos"
1371         aros_shared_default="no"
1372         aros_target_cpu="ppc"
1373         aros_object_format="elf_ppc"
1374         aros_flavour="nativecompat"
1375         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1376         gcc_target_cpu="ppc"
1377         ;;
1379     sam440)
1380         aros_target_arch="sam440"
1381         aros_shared_default="no"
1382         aros_target_cpu="ppc"
1383         aros_object_format="elf32ppc"
1384         aros_flavour="ppcnative"
1385         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1386         aros_kernel_ldflags=""
1387         aros_nominal_width=1024
1388         aros_nominal_height=768
1389         aros_nominal_depth=24
1390         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1391         gcc_target_cpu="powerpc"
1392         ;;
1394     efika)
1395         aros_target_arch="efika"
1396         aros_shared_default="no"
1397         aros_target_cpu="arm"
1398         aros_object_format="armelf_aros"
1399         aros_flavour="standalone"
1400         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1401         aros_kernel_ldflags=""
1402         aros_nominal_width=1024
1403         aros_nominal_height=600
1404         aros_arch_libs="-laeabi"
1405         gcc_default_cpu="armv7-a"
1406         gcc_default_fpu="vfpv3"
1407         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1408         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1409         aros_optimization_cflags="$aros_optimization_cflags -Os"
1410         case "$target_cpu" in
1411             *armhf*)
1412                 gcc_default_float_abi="hard"
1413                 target_cpu=arm
1414                 aros_target_cpu=arm
1415                 ;;
1416             *arm*)
1417                 gcc_default_float_abi="softfp"
1418                 ;;
1419             *)
1420                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1421                 ;;
1422         esac
1423         ;;
1424         
1425     chrp)
1426         aros_target_arch="chrp"
1427         aros_shared_default="no"
1428         aros_target_cpu="ppc"
1429         aros_object_format="elf32ppc"
1430         aros_flavour="ppcnative"
1431         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1432         aros_kernel_ldflags=""
1433         aros_nominal_width=640
1434         aros_nominal_height=480
1435         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1436         gcc_target_cpu="powerpc"
1437         case "$aros_target_variant" in
1438             efika)
1439                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1440             ;;
1441         esac
1442         ;;
1444     r*pi)
1445         aros_flavour="standalone"
1446         aros_target_arch="raspi"
1448         aros_shared_default="no"
1450         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1451         
1452         case "$target_cpu" in
1453             *aarch64*)
1454                 aros_target_cpu="aarch64"
1455                 gcc_default_cpu="aarch64"
1456                 aros_object_format="aarch64elf_aros"
1457                 ;;
1458             *armhf*)
1459                 aros_target_cpu="arm"
1460                 gcc_default_cpu="armv6zk"
1461                 gcc_default_cpu_tune="arm1176jzf-s"
1462                 aros_object_format="armelf_aros"
1463                 aros_config_cflags="$aros_config_cflags -marm"
1464                 aros_config_aflags="$aros_config_aflags -marm"
1465                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1466                 aros_target_cflags="$aros_kernel_cflags -marm"
1467                 aros_target_mkdep="$aros_target_mkdep -Darm"
1468                 aros_arch_libs="-laeabi"
1469                 ;;
1470             *arm*)
1471                 aros_target_cpu="arm"
1472                 gcc_default_cpu="armv6zk"
1473                 gcc_default_cpu_tune="arm1176jzf-s"
1474                 aros_object_format="armelf_aros"
1475                 aros_config_cflags="$aros_config_cflags -marm"
1476                 aros_config_aflags="$aros_config_aflags -marm"
1477                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1478                 aros_target_cflags="$aros_kernel_cflags -marm"
1479                 aros_target_mkdep="$aros_target_mkdep -Darm"
1480                 aros_arch_libs="-laeabi"
1481                 ;;
1482             *)
1483                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1484                 ;;
1485         esac
1487         aros_config_cflags="$aros_config_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1488         aros_config_aflags="$aros_config_aflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1489         aros_kernel_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1490         aros_target_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1492         case "$aros_target_variant" in
1493             smp)
1494                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1495             ;;
1496         esac
1497         ;;
1499     stm32f7_discovery)
1500         aros_flavour="standalone"
1501         aros_target_arch="stm32f7_discovery"
1502         aros_target_cpu="arm"
1503         aros_target_cpu_mode="thumb2"
1504         aros_object_format="armelf_aros"
1505         aros_shared_default="no"
1507         # stm32f7 has DSP opcode support
1508         gcc_default_cpu="armv7e-m"
1509         # gcc_default_cpu="armv7-m"
1510         gcc_default_cpu_tune="cortex-m7"
1511         gcc_default_fpu="fpv4-sp-d16"
1512         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1513         # gcc_default_fpu="fpv5-sp-d16"
1514                 gcc_default_float_abi="hard"
1516         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1517         ;;
1519     amiga*)
1520         aros_target_arch="amiga"
1521         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1522         aros_shared_default="no"
1524         case "$target_cpu" in
1525             *m68k*)
1526                 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")
1527                 aros_enable_mmu=no
1528                 aros_target_cpu="m68k"
1529                 aros_object_format="m68kelf"
1530                 aros_flavour="standcompat"
1531                 gcc_target_cpu="m68000"
1532                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1533                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1534                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1535                 aros_config_aflags="$aros_config_aflags"
1536                 aros_target_strip_flags="-R.comment --strip-debug"
1537                 aros_nominal_width=640
1538                 aros_nominal_height=256
1539                 aros_nominal_depth=2
1540                 ;;
1541             *ppc*)
1542                 aros_cpu="ppc"
1543                 aros_flavour="native"
1544                 gcc_target_cpu="ppc"
1545                 ;;
1546             *)
1547                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1548                 ;;
1549         esac
1550         ;;
1552     mingw*)
1553         aros_target_arch="mingw32"
1554         aros_shared_default="no"
1555         aros_flavour="emulation"
1556         aros_shared_cflags=""
1557         need_crosstools="yes"
1558         need_dlopen="no"
1559         rescomp="windres"
1560         case "$target_cpu" in
1561             *i?86*)
1562                 aros_target_cpu="i386"
1563                 aros_object_format="elf_i386"
1564                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1565                 aros_nominal_depth=8
1566                 gcc_target_cpu="i386"
1568                 kernel_tool_prefix="i386-mingw32-"
1569                 ;;
1570             *x86_64*)
1571                 aros_target_cpu="x86_64"
1572                 aros_object_format="elf_x86_64"
1573                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1574                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1575                 aros_nominal_depth=8
1576                 kernel_tool_prefix="x86_64-w64-mingw32-"
1577                 ;;
1578             *arm*)
1579                 aros_target_cpu="arm"
1580                 aros_object_format="armelf_aros"
1581                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1582                 aros_arch_libs="-laeabi"
1583                 aros_nominal_depth=8
1584                 gcc_target_cpu="arm"
1585                 gcc_default_float_abi="soft"
1586                 kernel_tool_prefix="arm-mingw32ce-"
1587                 aros_nominal_width=160
1588                 aros_nominal_height=160
1589                 ;;
1590             *)
1591                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1592                 ;;
1593         esac
1594         if test $host_os = "cygwin"; then
1595                 aros_kernel_cflags="-mno-cygwin"
1596         fi
1597     ;;
1598     pp*)
1599         aros_target_arch="pp"
1600         aros_shared_default="no"
1601         case "$target_cpu" in
1602             *m68k*)
1603                 aros_target_cpu="m68k"
1604                 aros_object_format="m68kelf"
1605                 aros_flavour="palmnative"
1606                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1607                 aros_nominal_width=160
1608                 aros_nominal_height=160
1609                 aros_nominal_depth=1
1610                 aros_target_ar_flags="cru"
1611                 aros_compiler_libs="-lgcc1"
1612                 aros_shared_default=no
1613                 aros_shared_cflags="-fpic"
1614                 aros_shared_aflags=""
1615                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1616                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1617                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1618                 aros_debug_aflags=""
1619                 aros_debug_ldflags="$aros_symbols_debug"
1620                 aros_mungwall_debug="0"
1621                 aros_modules_debug="0"
1622                 gcc_target_cpu="mc68000"
1623                 ignore_undefined_symbols="-ius"
1624                 ;;
1625            *)
1626                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1627                 ;;
1628         esac
1629         ;;
1631     mac*)
1632         aros_target_arch="mac"
1633         aros_shared_default="no"
1634         case "$target_cpu" in
1635             *m68k*)
1636                 aros_target_cpu="m68k"
1637                 aros_object_format="m68kelf"
1638                 aros_flavour="mac68knative"
1639                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1640                 aros_nominal_width=512
1641                 aros_nominal_height=384
1642                 aros_nominal_depth=8
1643                 aros_target_ar_flags="cru"
1644                 aros_compiler_libs="-lgcc1"
1645                 aros_shared_default=no
1646                 aros_shared_cflags="-fpic"
1647                 aros_shared_aflags=""
1648                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1649                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1650                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1651                 aros_debug_aflags=""
1652                 aros_debug_ldflags="$aros_symbols_debug"
1653                 aros_mungwall_debug="0"
1654                 aros_modules_debug="0"
1655                 gcc_target_cpu="mc68000"
1656                 ignore_undefined_symbols="-ius"
1657                 ;;
1658            *)
1659                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1660                 ;;
1661         esac
1662         ;;
1664     *)
1665         AC_MSG_ERROR([Unsupported target architecture $target])
1666         ;;
1667 esac
1669 #-----------------------------------------------------------------------------
1670 crosstools_guess="yes"
1671 aros_target_toolchain="no"
1672 aros_config_sysroot=""
1673 aros_kernel_sysroot=""
1675 AC_MSG_CHECKING([Kernel toolchain prefix])
1676 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1677 AC_MSG_RESULT($kernel_tool_prefix)
1679 AC_MSG_CHECKING([ELF toolchain prefix])
1680 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"
1681                                                  crosstools_guess="no"])
1682 AC_MSG_RESULT($elf_tool_prefix)
1684 AC_MSG_CHECKING([AROS toolchain prefix])
1685 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"
1686                 crosstools_guess="no"])
1687 if test "$aros_tool_prefix" = "yes" ; then
1688     aros_tool_prefix=$aros_target_cpu-aros-
1690 AC_MSG_RESULT($aros_tool_prefix)
1692 #-----------------------------------------------------------------------------
1693 #   Checking if we should build crosstools..
1694 AC_MSG_CHECKING([whether to build crosstools])
1695 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1696 AC_MSG_RESULT($crosstools)
1698 if test "${crosstools}" = "yes"; then
1699     if test "${crosstools_guess}" = "no"; then
1700         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1701     fi
1704 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1705     aros_target_toolchain="yes"
1708 AC_MSG_CHECKING([where to install the crosstools binaries])
1709 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])
1710 if test "x$aros_toolchain_install" = "x"; then
1711     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1712 else
1713     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1714     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1715     if test "$crosstools_guess" = "no" ; then
1716         toolchain_needs_sysroot=yes
1718         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1719             aros_kernel_sysroot = $aros_config_sysroot
1720         fi
1721     fi
1723 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1725 AC_MSG_CHECKING([If we need to use --sysroot])
1726 if test "$toolchain_needs_sysroot" = "yes" ; then
1727     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1729 AC_MSG_RESULT($toolchain_needs_sysroot)
1731 #-----------------------------------------------------------------------------
1732 if test "$aros_toolchain" = "gnu" ; then
1733     AC_MSG_CHECKING([what specific target binutils version to use])
1735 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="")
1736 if test "$use_binutils_version" = ""; then
1737         target_binutils_version="$default_binutils_version"
1738 else
1739     target_binutils_version="$use_binutils_version"
1741 if test "$aros_toolchain" = "gnu" ; then
1742     AC_MSG_RESULT($target_binutils_version)
1746 # Helper to identify gcc version
1747 AC_DEFUN([CROSS_GCC_VERSION], [
1748   target_gcc_version=""
1749   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1750     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1751     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1752       ax_cv_gcc_version=""
1753     ])
1754   ])
1755   target_gcc_version=$ax_cv_gcc_version
1756   AC_SUBST([target_gcc_version])
1759 #-----------------------------------------------------------------------------
1760 if test "$aros_toolchain" = "gnu" ; then
1761     AC_MSG_CHECKING([what specific target gcc version to use])
1763 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1764 if test "$use_gcc_version" = ""; then
1765     if test "${crosstools}" = "no"; then
1766       if test "x$aros_toolchain_install" != "x"; then
1767           CROSS_GCC_VERSION
1768       fi
1769     fi
1770     if test "$use_gcc_version" = ""; then
1771         target_gcc_version="$default_gcc_version"
1772     fi
1773 else
1774     target_gcc_version="$use_gcc_version"
1776 if test "$aros_toolchain" = "gnu" ; then
1777     AC_MSG_RESULT($target_gcc_version)
1779     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1780     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1781     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1783     gcc_fix_bitfields="false"
1784     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1785         gcc_fix_bitfields="true"
1786     else
1787         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1788             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1789                 gcc_fix_bitfields="true"
1790             fi
1791         fi
1792     fi
1794     if test "$gcc_fix_bitfields" = "true" ; then
1795         case "$aros_target_cpu" in
1796         *x86_64*)
1797             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1798             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1799             ;;
1800         i386)
1801             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1802             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1803             ;;
1804         esac
1805     fi
1808 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1809 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1810 AC_MSG_RESULT($objc)
1811 if test "x$objc" = "xyes"; then
1812     objc_target="$objc"
1813 else
1814     objc_target="no-objc"
1817 AC_MSG_CHECKING([whether to enable Java suppport])
1818 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1819 AC_MSG_RESULT($java)
1820 if test "x$java" != "xno"; then
1821     java_target="$java"
1822 else
1823     java_target="no-java"
1826 spec_obj_format="-m $aros_object_format"
1827 # Now process extra architecture-specific options.
1828 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1829 # as well as floating-point ABI.
1830 case "$aros_target_cpu" in
1831 *x86_64*)
1832     dnl x86_64 can build 32 or 64bit code
1833     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1834     ;;
1835 arm*)
1836     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1837     if test "$gcc_default_cpu" = ""; then
1838         gcc_default_cpu="armv6"
1839     fi
1840     if test "$gcc_default_fpu" = ""; then
1841         gcc_default_fpu="vfp"
1842     fi
1843     if test "$gcc_default_float_abi" = ""; then
1844         if test "$target_cpu" = "armhf"; then
1845             gcc_default_float_abi="hard"
1846         else
1847             gcc_default_float_abi="softfp"
1848         fi
1849     fi
1851     AC_MSG_CHECKING([Which minimum CPU to use])
1852     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)
1853     AC_MSG_RESULT($aros_gcc_cpu)
1855     AC_MSG_CHECKING([Which minimum FPU to use])
1856     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)
1857     AC_MSG_RESULT($aros_gcc_fpu)
1859     AC_MSG_CHECKING([Which floating point ABI to use])
1860     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)
1861     AC_MSG_RESULT($aros_gcc_float_abi)
1863     AC_MSG_CHECKING([Which ARM mode to use])
1864     if test "$aros_target_cpu_mode" = ""; then
1865         aros_target_cpu_mode="arm32"
1866         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1867     else
1868         AC_MSG_RESULT([$aros_target_cpu_mode])
1869     fi
1871     case "$aros_target_cpu_mode" in
1872     arm32)
1873         gcc_default_mode="arm"
1874         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1875     ;;
1876     arm64)
1877         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1878     ;;
1879     thumb)
1880         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1881     ;;
1882     thumb1)
1883         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1884     ;;
1885     thumb2)
1886         gcc_default_mode="thumb"
1887         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1888         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1889     ;;
1890     *)
1891         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1892     ;;
1893     esac
1895     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1896     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1897     ;;
1898 i386)
1899     aros_isa_flags="-m32 -march=i486"
1900     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1901     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1902     ;;
1903 esac
1905 # Some architectures may need custom ELF specs.
1906 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1907     elf_specs_in=config/${aros_object_format}-specs.in
1908 else
1909     elf_specs_in=config/elf-specs.in
1912 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1913 # Since we override specs, we may need to put these defines there
1914 if test "$gcc_target_cpu" != ""; then
1915     gcc_target_cpu="-D__${gcc_target_cpu}__"
1918 AC_MSG_CHECKING([where to download sourcecode for external ports])
1919 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1920 if test "$with_portssrcdir" = "default"; then
1921     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1922 else
1923     AROS_PORTSSRCDIR="$with_portssrcdir"
1925 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1927 AC_MSG_CHECKING([which bootloader to use])
1928 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1929 if test "$target_bootloader" = "none"; then
1930     aros_target_bootloader=""
1931 else
1932     aros_target_bootloader="$target_bootloader"
1934 AC_MSG_RESULT($target_bootloader)
1936 AC_MSG_CHECKING([which icon-set to use])
1937 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1938 if test "$target_iconset" = "default"; then
1939     aros_target_iconset="Gorilla"
1940     target_iconset="default (Gorilla)"
1941 else
1942     aros_target_iconset="$target_iconset"
1944 AC_MSG_RESULT($target_iconset)
1946 AC_MSG_CHECKING([which GUI Theme to use])
1947 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1948 if test "$target_guitheme" = "default"; then
1949     aros_target_guitheme="Ice"
1950 else
1951     aros_target_guitheme="$target_guitheme"
1953 AC_MSG_RESULT($aros_target_guitheme)
1955 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1956 # for target code)
1957 cross_compiling=no
1959 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1960 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1961     cross_compiling=yes
1964 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1965 dnl The flag itself is given in per-target section, because some targets require to pass it
1966 dnl in a different manner, otherwise some tests fail.
1967 dnl TODO: Justify this.
1968 if test "$aros_host_cpu" == "x86_64" ; then
1969     if test "$aros_target_cpu" == "i386" ; then
1970         cross_compiling=no
1971     fi
1974 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1975     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1976     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1977     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1978     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1979     dnl used to build bootstrap for target arch in either case.
1980     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1981     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1982     dnl perhaps introducing aros_host_variant
1983     if test "$aros_host_arch" != "$aros_target_arch" ; then
1984         cross_compiling=yes
1985     fi
1986 else
1987     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1988     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1989     if test "$host_cc_elf" = "no" ; then
1990         cross_compiling=yes
1991     fi
1994 if test "$cross_compiling" = "no" ; then
1995     kernel_tool_prefix=""
1996     if test "$host_cc_elf" = "yes" ; then
1997         elf_tool_prefix=""
1998     fi
2001 if test "$kernel_tool_version" != ""; then
2002     kernel_tool_version="-$kernel_tool_version"
2005 #######################################################################
2006 ## Compute what toolchains to use, and their paths                   ##
2007 #######################################################################
2009 # This takes, as input:
2010 #   crosstools             {yes,no}
2011 #   kernel_tool_version    {"",[version]}
2012 #   target_tool_version    {"",[version]}
2013 #   kernel_tool_prefix     {none,[some-arch-os-]}
2014 #   gnu-toolchain -:
2015 #     target_tool_prefix     ${aros_target_cpu}-aros-
2016 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2018 # The output is
2019 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2020 #        Where the 'kernel' binaries are located
2021 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2022 #        Where the 'target' binaries are located
2023 #        (not the symlink farm - that is aros_target_*!)
2025 # The rules are:
2026 #   if crosstools then
2027 #      if kernel_tools_prefix = "no-kernel-prefix-"
2028 #          aros_kernel_* = crosstools cc paths
2029 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2030 #      else
2031 #          VALIDATE(${kernel_tools_prefix}*)
2032 #          aros_kernel_* = ${kernel_tools_prefix}*
2033 #          if ${kernel_tools_prefix}cc is an AROS gcc
2034 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2035 #          else
2036 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2037 #          fi
2038 #      fi
2040 #      orig_target_* = aros built crosstools
2041 #      orig_target_cc = elf cc wrapper around crosstools cc
2042 #   else
2043 #      VALIDATE(${kernel_tools_prefix}*)
2045 #      orig_target_* = aros_kernel_*
2046 #      if aros_kernel_cc is an AROS gcc
2047 #          orig_target_cc = aros_kernel_cc
2048 #      else
2049 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2050 #      fi
2051 #   fi
2053 if test "$aros_toolchain" = "gnu" ; then
2054     target_tool_prefix="${aros_target_cpu}-aros-"
2055 elif test "$aros_toolchain" = "llvm" ; then
2056     target_tool_prefix="bin/"
2059 if test "$kernel_tool_prefix" != "" ; then
2060     AC_MSG_CHECKING([which kernel tools])
2061     AC_MSG_RESULT([$kernel_tool_prefix]);
2064 if test "$kernel_tool_prefix" = "none" ; then
2065     dnl ELF wrapper can be used only for native bootstrap
2066     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2067         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2068     fi
2069 else
2070     # Kernel tools required - find them
2071     # Note that 'normally', aros_kernel_* overrides will be
2072     # empty, unless specified in the per-arch sections above.
2073     if test "x$aros_kernel_cpp" = "x"; then
2074         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2075     fi
2076     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
2077     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2078     if test "x$aros_kernel_cc" = "x"; then
2079         aros_kernel_cc=${kernel_tool_prefix}${CC}
2080     fi
2081     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
2082     AROS_REQUIRED(cc,$aros_kernel_cc)
2083     if test "x$aros_kernel_cxx" = "x"; then
2084         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2085     fi
2086     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
2087     # If it's set, make sure it's really there
2088     if test "x$aros_kernel_cxx" != "x" ; then
2089         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2090     fi
2091     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2092     AROS_REQUIRED(ld,$aros_kernel_ld)
2093     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2094     AROS_REQUIRED(as,$aros_kernel_as)
2095     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2096     AROS_REQUIRED(ar,$aros_kernel_ar)
2097     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2098     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2099     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2100     AROS_REQUIRED(nm,$aros_kernel_nm)
2101     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2102     AROS_REQUIRED(strip,$aros_kernel_strip)
2104     # Objcopy and objdump are not required for the kernel
2105     # toolchain on many architectures.
2106     # So we'll look for them, but not make them strictly required.
2107     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2108     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2109     if test "x${crosstools}" != "xyes" ; then
2110         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2111         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2112     fi
2115 AC_MSG_CHECKING([which target tools to use])
2116 if test "$aros_target_toolchain" = "yes"; then
2117     if test "$aros_toolchain" = "llvm" ; then
2118         msg_result="llvm"
2119     else
2120         msg_result=$target_tool_prefix
2121     fi
2122     AC_MSG_RESULT([$msg_result])
2123     # We are building AROS crosstools
2124     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2125     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2126     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2127     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2128     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2129     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2130     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2131     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2132     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2133     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2134     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2135     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2136 else
2137     # Determine whether AROS or ELF tools should be used
2138     if test "$aros_tool_prefix" = "none"; then
2139         aros_tool_prefix="${elf_tool_prefix}"
2140     fi
2142     AC_MSG_RESULT([$aros_tool_prefix])
2143     # We are *not* building AROS crosstools - use the AROS or ELF tools
2144     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2145     AROS_REQUIRED(cpp,$orig_target_cpp)
2146     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2147     AROS_REQUIRED(cc,$orig_target_cc)
2148     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2149     AROS_REQUIRED(cxx,$orig_target_cxx)
2150     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2151     AROS_REQUIRED(ld,$orig_target_ld)
2152     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2153     AROS_REQUIRED(as,$orig_target_as)
2154     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2155     AROS_REQUIRED(ar,$orig_target_ar)
2156     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2157     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2158     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2159     AROS_REQUIRED(nm,$orig_target_nm)
2160     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2161     AROS_REQUIRED(strip,$orig_target_strip)
2162     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2163     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2164     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2165     AROS_REQUIRED(objdump,$orig_target_objdump)
2168 if test "$kernel_tool_prefix" = "none" ; then
2169     # No kernel tools specified
2170     # Assume target tools == kernel tools with ELF wrapper
2171     aros_kernel_cc=$orig_target_cc
2172     aros_kernel_cxx=$orig_target_cxx
2173     aros_kernel_cpp=$orig_target_cpp
2174     aros_kernel_ld=$orig_target_ld
2175     aros_kernel_as=$orig_target_as
2176     aros_kernel_ar=$orig_target_ar
2177     aros_kernel_ranlib=$orig_target_ranlib
2178     aros_kernel_nm=$orig_target_nm
2179     aros_kernel_strip=$orig_target_strip
2180     aros_kernel_objcopy=$orig_target_objcopy
2181     aros_kernel_objdump=$orig_target_objdump
2182     use_kernel_cc_wrapper=yes
2185 # At this point, all aros_kernel_* and aros_target_* 
2186 # tools should be set up correctly
2188 CC="$aros_kernel_cc $kernel_tool_flags"
2189 CPP="$aros_kernel_cpp"
2191 #-----------------------------------------------------------------------------
2193 # Find all the tools we need to compile. This could be cross-compiling
2194 # though! If that is the case we use the GNU form of the target and
2195 # simply add this to the front of the binary name. This is rather simple,
2196 # but it should work under most circumstances.
2198 # The default tools are to use the same as the host, but only if the
2199 # host and target CPU are the same. With GCC this is normally enough.
2202 aros_cc_pre=""
2203 aros_shared_ld="$aros_host_ld"
2205 aros_target_mkdep="$aros_host_mkdep"
2207 # The default tools executables to be linked to.
2208 if test "$rescomp" != ""; then
2209     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2210     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2213 # Set up the sources for the symlink farm
2214 if test "$crosstools" = "yes"; then
2215     crosstools_target=tools-crosstools
2218 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2219 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2221 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2222 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2223 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2224 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2225 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2226 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2227 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2229 # aros_cc_pre is a variable that is added to the front of the compiler name
2230 # in the generated aros-gcc shell script. We need this to enable the cache
2231 # to work across cleaned builds. Also, support DISTCC using the correct
2232 # environment variable.
2235 if test "x${DISTCC}" != "x" ; then
2236     if test "x${CCACHE}" != "x" ; then
2237         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2238     else
2239         aros_cc_pre="${DISTCC} "
2240     fi
2241 else
2242     if test "x${CCACHE}" != "x" ; then
2243         aros_cc_pre="${CCACHE} "
2244     fi
2247 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2248 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2249 AC_SUBST(aros_target_nix_ldflags,-nix)
2250 AC_SUBST(aros_target_detach_ldflags,-detach)
2251 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2253 # Target tools
2254 AC_SUBST(aros_toolchain)
2255 if test "$aros_target_toolchain" != "yes"; then
2256     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2257     if test "$GCC" = "yes"; then
2258         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2259     fi
2260 else
2261     # We do not know which c compiler version we are going to build and what we need to know
2262     # here is different for different versions so this will be set later during the
2263     # build of crosstools.
2264     if test "$aros_toolchain" = "gnu" ; then
2265         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2266     elif test "$aros_toolchain" = "llvm" ; then
2267         prefix="$AROS_CROSSTOOLSDIR/bin/"
2268     fi
2269     aros_target_cc_path=@aros_target_cc_path@
2271 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2272 aros_target_cc="${prefix}${toolchain_c_compiler}"
2273 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2274 aros_target_as="${prefix}${toolchain_as}"
2275 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_ld}"
2276 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2277 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2278 aros_target_objdump="${prefix}${toolchain_objdump}"
2279 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2280 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2281 aros_target_strip="${prefix}${toolchain_strip}"
2282 aros_plain_nm="${prefix}${toolchain_nm}"
2283 aros_plain_ar="${prefix}${toolchain_ar}"
2285 AC_ARG_ENABLE(includes,
2286 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2287 [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`])
2289 if test "$aros_kernel_includes" = ""; then
2290     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2291         aros_kernel_includes="-isystem $aros_target_incl"
2292     fi
2295 if test "$aros_kernel_includes" != "" ; then
2296     dnl find out about the kernel cc's include path
2297     AC_MSG_CHECKING([for the kernel compiler's include path])
2298     if test "$aros_kernel_cc_includes" = "" ; then
2299         # Try to guess where the directory is.
2300         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2301         if test -d $aros_kernel_cc_includes; then
2302             # Check if there is also an include-fixed directory and add it
2303             # to kernel compiler's include path as it may contain some of
2304             # the headers we need.
2305             if test -d "$aros_kernel_cc_includes"-fixed; then
2306                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2307             fi
2308             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2309             case ${host_cpu} in
2310                 i[[3456]]86)
2311                     host_cpu_glibc=i386
2312                     ;;
2313                 *)
2314                     host_cpu_glibc=${host_cpu}
2315                     ;;
2316             esac
2317             if test -d "/usr/include/${host_cpu_glibc}-linux-gnu"; then
2318                 aros_kernel_cc_includes+=" -isystem /usr/include/${host_cpu_glibc}-linux-gnu"
2319             fi
2320         else
2321             # The directory doesn't exist, we need to do some more work.
2322             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2324             # These are the headers we're looking for.
2325             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2326                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2327                      zutil.h stdint.h"
2329             dirs=
2330             for h in $headers; do
2331                 # Which other headers are needed by each of the above?
2332                 deps=$(echo "#include <$h>" | \
2333                        $aros_kernel_cc -E -M - 2>/dev/null | \
2334                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2336                 # Copy all the needed headers to a directory beneath gendir.
2337                 for d in $deps; do
2338                     h=$(basename $d)
2339                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2340                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2341                     ! test -d $dir && mkdir -p $dir
2342                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2343                 done
2344             done            
2345         fi
2346     fi
2347     AC_MSG_RESULT($aros_kernel_cc_includes)
2348     # Adding -nostdinc to kernel includes as they are always used together.
2349     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2352 if test "$crosstools" != "yes"; then
2353     dnl find out about the target cc's include path
2354     AC_MSG_CHECKING([for the target compiler's include path])
2355     if test "$aros_target_cc_includes" = "" ; then
2356         #try to guess where the directory is
2357         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2358         if ! test -d $aros_target_cc_includes; then
2359             #the directory doesn't exist, we need to do some more work
2360             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2361         
2362             #these are the headers we're looking for
2363             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2364                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2365                     zutil.h"
2367             dirs=
2368             for h in $headers; do
2369                 #which other headers each of the above headers needs?
2370                 deps=$(echo "#include <$h>" | \
2371                     $orig_target_cc -E -M - 2>/dev/null | \
2372                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2373             
2374                 #copy all the needed headers to a directory beneath gendir
2375                 for d in $deps; do
2376                     h=$(basename $d)
2377                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2378                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2379                     ! test -d $dir && mkdir -p $dir
2380                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2381                 done
2382             done
2383         fi
2384     fi
2385     AC_MSG_RESULT($aros_target_cc_includes)
2386 else
2387     # We do not know which c compiler version we are going to build and what we need to know
2388     # here is different for different versions so this will be set later during the
2389     # build of crosstools.
2390     aros_target_cc_includes=@aros_target_cc_includes@
2394 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2395 # On GCC >= 4.0 -iquote should be used
2398 save_cc="$CC"
2399 save_cflags="$CFLAGS"
2400 CFLAGS="-iquote."
2401 kernel_cflags_iquote=$host_cflags_iquote
2402 kernel_cflags_iquote_end=$host_cflags_iquote_end
2403 if test "x-$cross_compiling" = "x-yes"; then
2404     CC="$aros_kernel_cc"
2405     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2406     if test "x-$crosstools" != "x-yes"; then
2407         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2408     else
2409         # we do know it is supported for the smallest version of gcc we are going to build
2410         # we assume it's also supported by later versions
2411         use_no_stack_protector=yes
2412     fi
2413     AC_MSG_RESULT($use_no_stack_protector)
2414     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2415     if test "x-$crosstools" != "x-yes"; then
2416         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2417     else
2418         # we do know it is supported for the smallest version of gcc we are going to build
2419         # we assume it's also supported by later versions
2420         has_iquote=yes
2421     fi
2422     AC_MSG_RESULT($has_iquote)
2423     if test "x-$has_iquote" = "x-yes" ; then
2424         kernel_cflags_iquote=-iquote
2425         kernel_cflags_iquote_end=
2426     else
2427         kernel_cflags_iquote=-I
2428         kernel_cflags_iquote_end=-I-
2429     fi
2431 if test "x-$use_no_stack_protector" = "x-yes" ; then
2432     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2435 #-----------------------------------------------------------------------------
2437 # Check if we can explicitly choose older version of symbol hashing
2439 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2440 CC="$aros_kernel_cc"
2441 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2442 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2443 AC_MSG_RESULT($use_hash_style)
2444 if test "x-$use_hash_style" = "x-yes" ; then
2445     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2447 CC="$save_cc"
2448 CFLAGS="$save_cflags"
2450 AC_SUBST(host_cflags_iquote)
2451 AC_SUBST(host_cflags_iquote_end)
2452 AC_SUBST(kernel_cflags_iquote)
2453 AC_SUBST(kernel_cflags_iquote_end)
2454 AC_SUBST(aros_cflags_iquote)
2455 AC_SUBST(aros_cflags_iquote_end)
2458 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2459 AC_MSG_CHECKING([for default resolution of WBScreen])
2460 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2461 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2462 if test "$resolution" = "yes" ; then
2463     resolution="none"
2465 if test "$resolution" = "no" ; then
2466     resolution="none"
2468 if test "$resolution" != "none" ; then
2469     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2470     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2471     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2473 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2474 aros_cv_nominal_width=$aros_nominal_width
2475 aros_cv_nominal_height=$aros_nominal_height
2476 aros_cv_nominal_depth=$aros_nominal_depth
2478 dnl See if the user wants the serial debug output for native flavour
2479 AC_MSG_CHECKING([whether serial debug is enabled])
2480 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)
2481 if test "$aros_serial_debug" = 0 ; then
2482     serial_debug_forced=""
2483     if test "$serial_debug" = "yes" ; then
2484         serial_debug="1"
2485     fi
2486     if test "$serial_debug" = "no" ; then
2487         serial_debug="none"
2488     fi
2489 else
2490     serial_debug_forced="(forced)"
2491     serial_debug=$aros_serial_debug
2493 if test "$serial_debug" != "none" ; then
2494     aros_serial_debug=$serial_debug
2495     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2496 else
2497     AC_MSG_RESULT(no)
2500 dnl See if the user wants the palm debug output hack for palm native flavour
2501 AC_MSG_CHECKING([whether palm debug hack is enabled])
2502 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")
2503 if test "$palm_debug_hack" = "yes" ; then
2504     aros_palm_debug_hack="1"
2506 AC_MSG_RESULT($palm_debug_hack)
2508 dnl See if dev wants the usb3.0 code
2509 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2510 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2511 if test "$usb30_code" = "yes" ; then
2512     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2513     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2515 AC_MSG_RESULT($usb30_code)
2517 dnl See if the user wants nesting supervisor activated for unix flavour
2518 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2519 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")
2520 if test "$nesting_supervisor" = "yes" ; then
2521     aros_nesting_supervisor="1"
2523 AC_MSG_RESULT($nesting_supervisor)
2525 dnl See if the user wants to disable MMU support
2526 dnl This can be overriden on per-target basis,
2527 dnl set $aros_enable_mmu to "yes" or "no" to do this
2528 if test "$aros_enable_mmu" = "" ; then
2529     AC_MSG_CHECKING([whether MMU support is enabled])
2530     dnl Enabled by default
2531     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2532     if test "$aros_enable_mmu" = "" ; then
2533         aros_enable_mmu="yes"
2534     fi
2535     AC_MSG_RESULT($aros_enable_mmu)
2537 if test "$aros_enable_mmu" = "no" ; then
2538     aros_enable_mmu="0"
2539 else
2540     aros_enable_mmu="1"
2542     
2544 dnl things specifically required for hosted flavours
2545 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2547     if test "x-$need_dlopen" != "x-no" ; then
2548       save_libs="$LIBS"
2549       LIBS=""
2550       dnl some kind of dynamic library access system is required for hostlib.resource
2551       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2552       if test "x-$have_dl" = "x-no" ; then
2553           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2554                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2555                                     have_dl="no")
2556       fi
2557       if test "x-$have_dl" = "x-no" ; then
2558           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2559       fi
2560       LIBS="$save_libs"
2561     fi
2564     dnl x11 hidd
2565     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2566                                            [build X11 hidd for hosted (default=auto)]),
2567                                            x11_hidd="$enableval",
2568                                            x11_hidd="$need_x11")
2569     case "x-$x11_hidd" in
2570         x-yes|x-no|x-auto)                 ;;
2571         *)                 x11_hidd="$need_x11" ;;
2572     esac
2574     ENABLE_X11=0
2576     dnl they want it
2577     if test "x-$x11_hidd" != "x-no" ; then
2579         dnl find x11 stuff
2580         AC_PATH_X
2582         x_cflags=
2583         for path in $x_libraries
2584         do
2585             x_cflags="$x_cflags -L$path"
2586         done
2588         for path in $x_includes
2589         do
2590             x_cflags="$x_cflags -I$path"
2591         done
2592         
2593         if test "x-$no_x" = "x-yes" ; then
2595             dnl didn't find it
2596             if test "x-$x11_hidd" != "x-auto" ; then
2597                 dnl and they explicitly asked for it, bail out
2598                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2599             fi
2600         
2601         else
2602             dnl found it, setup the metatarget
2603             host_x_gfx=yes
2604             ENABLE_X11=1
2606             dnl setup shared memory extensions
2607             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2608                                                   [use X11 shared memory (default=auto)]),
2609                                                   x11_hidd_shm="$enableval",
2610                                                   x11_hidd_shm="auto")
2611             case "x-$x11_hidd_shm" in
2612                 x-yes|x-no|x-auto)                     ;;
2613                 *)                 x11_hidd_shm="auto" ;;
2614             esac
2616             have_xshm=no
2618             dnl they want it
2619             if test "x-$x11_hidd_shm" != "x-no" ; then
2621                 dnl system shm headers
2622                 AC_CHECK_HEADERS(sys/ipc.h)
2623                 AC_CHECK_HEADERS(sys/shm.h)
2625                 dnl got them
2626                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2628                     dnl make sure X libs have shm functions
2629                     save_cflags="$CFLAGS"
2630                     CFLAGS="$CFLAGS $x_cflags"
2631                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2632                     CFLAGS="$save_cflags"
2633                 fi
2634             fi
2636             dnl detection done, prepare output
2637             if test "x-$have_xshm" = "x-yes" ; then
2638                 dnl we can do shm
2639                 DO_XSHM_SUPPORT="1"
2640             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2641                 dnl they explicitly asked for it, but we can't do it
2642                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2643             else
2644                 dnl otherwise just disable it
2645                 DO_XSHM_SUPPORT="0"
2646             fi
2648             
2649             dnl setup vidmode (fullscreen) extensions
2650             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2651                                                       [use X11 vidmode extension (default=auto)]),
2652                                                       x11_hidd_vidmode="$enableval",
2653                                                       x11_hidd_vidmode="auto")
2654             case "x-$x11_hidd_vidmode" in
2655                 x-yes|x-no|x-auto)                         ;;
2656                 *)                 x11_hidd_vidmode="auto" ;;
2657             esac
2659             have_vidmode=no
2661             dnl they want it
2662             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2664                 dnl make sure X libs have vidmode functions
2665                 save_cflags="$CFLAGS"
2666                 CFLAGS="$CFLAGS $x_cflags"
2667                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2668                 CFLAGS="$save_cflags"
2669             fi
2671             dnl detection done, prepare output
2672             if test "x-$have_vidmode" = "x-yes" ; then
2673                 dnl we can do vidmode
2674                 DO_VIDMODE_SUPPORT="1"
2675             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2676                 dnl they explicitly asked for it, but we can't do it
2677                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2678             else
2679                 dnl otherwise just disable it
2680                 DO_VIDMODE_SUPPORT="0"
2681             fi
2682         fi
2684         aros_host_x11_includes=$x_includes 
2685         aros_host_x11_libdirs=$x_libraries
2686     fi
2689     dnl sdl hidd
2690     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2691                                            [build SDL hidd for hosted (default=auto)]),
2692                                            sdl_hidd="$enableval",
2693                                            sdl_hidd="auto")
2694     case "x-$sdl_hidd" in
2695         x-yes|x-no|x-auto)                 ;;
2696         *)                 sdl_hidd="auto" ;;
2697     esac
2699     dnl they want it
2700     if test "x-$sdl_hidd" != "x-no" ; then
2702         dnl find sdl
2703         SDL_VERSION=1.2.5
2704         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2705             [have_sdl="no"])
2707         if test "x-$have_sdl" != "x-yes" ; then
2709             dnl didn't find it
2710             if test "x-$sdl_hidd" != "x-auto" ; then
2711                 dnl and they explicitly asked for it, bail out
2712                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2713             fi
2715         else
2716             dnl found it, enable the build
2717             host_sdl_gfx=yes
2718             aros_host_sdl_cflags=$SDL_CFLAGS
2719             aros_host_sdl_libs=$SDL_LIBS
2720         fi
2721     fi
2726 dnl See if the user wants dbus.library
2727 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2728 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2729 if test "$dbus" = "yes" ; then
2730     ENABLE_DBUS=1
2731     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2732     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2733     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2734     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2735 else
2736     ENABLE_DBUS=0
2738 AC_MSG_RESULT($dbus)
2740 if test "$use_kernel_cc_wrapper" = "yes" ; then
2741     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2744 dnl --------------------------------------------------------------------
2745 dnl Configuration Output Section
2746 dnl --------------------------------------------------------------------
2748 # Generic
2749 AC_SUBST(aros_arch)
2750 AC_SUBST(aros_cpu)
2751 AC_SUBST(aros_flavour)
2752 AC_SUBST(aros_flavour_uc)
2753 AC_SUBST(aros_target_toolchain)
2754 AC_SUBST(aros_build_host)
2755 AC_SUBST(AROS_BUILDDIR)
2756 AC_SUBST(AROS_BUILDDIR_UNIX)
2757 AC_SUBST(SRCDIR)
2758 AC_SUBST(AROS_CROSSTOOLSDIR)
2759 AC_SUBST(AROS_PORTSSRCDIR)
2761 # Compatability with other Amiga-like operation systems
2762 AC_SUBST(aros_amigaos_compliance)
2764 # Host related
2765 AC_SUBST(aros_cc_pre)
2766 AC_SUBST(aros_host_strip)
2767 AC_SUBST(aros_host_arch)
2768 AC_SUBST(aros_host_cpu)
2769 AC_SUBST(aros_host_cpp)
2770 AC_SUBST(aros_host_def_cc)
2771 AC_SUBST(aros_host_cc)
2772 AC_SUBST(aros_host_cxx)
2773 AC_SUBST(aros_host_ar)
2774 AC_SUBST(aros_host_ranlib)
2775 AC_SUBST(aros_host_ld)
2776 AC_SUBST(aros_host_make)
2777 AC_SUBST(aros_host_cflags)
2778 AC_SUBST(aros_host_cxxflags)
2779 AC_SUBST(gnu89_inline)
2780 AC_SUBST(aros_host_ldflags)
2781 AC_SUBST(aros_host_debug)
2782 AC_SUBST(aros_host_mkdep)
2783 AC_SUBST(aros_host_mkargs)
2784 AC_SUBST(aros_host_exe_suffix)
2785 AC_SUBST(aros_host_lib_suffix)
2786 AC_SUBST(aros_tools_dir)
2787 AC_SUBST(aros_host_aclocal)
2788 AC_SUBST(aros_host_autoconf)
2789 AC_SUBST(aros_host_autoheader)
2790 AC_SUBST(aros_host_automake)
2791 AC_SUBST(ant)
2793 # Target Related
2794 AC_SUBST(aros_target_guitheme)
2795 AC_SUBST(aros_target_iconset)
2796 AC_SUBST(aros_target_bootloader)
2797 AC_SUBST(aros_target_arch)
2798 AC_SUBST(aros_target_family)
2799 AC_SUBST(aros_target_cpu)
2800 AC_SUBST(aros_target_cpu_mode)
2801 AC_SUBST(aros_target_variant)
2802 AC_SUBST(aros_target_suffix)
2803 AC_SUBST(aros_target_ar)
2804 AC_SUBST(aros_target_ranlib)
2805 AC_SUBST(aros_plain_nm)
2806 AC_SUBST(aros_plain_ar)
2807 AC_SUBST(aros_kernel_ar)
2808 AC_SUBST(aros_kernel_ranlib)
2809 AC_SUBST(orig_target_cc)
2810 AC_SUBST(aros_target_cc)
2811 AC_SUBST(aros_kernel_cc)
2812 AC_SUBST(orig_target_cxx)
2813 AC_SUBST(aros_target_cxx)
2814 AC_SUBST(aros_kernel_cxx)
2815 AC_SUBST(orig_target_cpp)
2816 AC_SUBST(aros_target_cpp)
2817 AC_SUBST(aros_kernel_cpp)
2818 AC_SUBST(orig_target_as)
2819 AC_SUBST(aros_target_as)
2820 AC_SUBST(aros_kernel_as)
2821 AC_SUBST(orig_target_ld)
2822 AC_SUBST(aros_target_ld)
2823 AC_SUBST(aros_kernel_ld)
2824 AC_SUBST(aros_target_cc_includes)
2825 AC_SUBST(aros_target_cc_path)
2826 AC_SUBST(aros_target_objdump)
2827 AC_SUBST(aros_target_objcopy)
2828 AC_SUBST(aros_target_strip)
2829 AC_SUBST(aros_target_nm)
2830 AC_SUBST(aros_kernel_rescomp)
2831 AC_SUBST(aros_shared_default)
2832 AC_SUBST(aros_shared_ld)
2833 AC_SUBST(aros_object_format)
2834 AC_SUBST(spec_obj_format)
2835 AC_SUBST(aros_compiler_libs)
2836 AC_SUBST(aros_arch_libs)
2838 AC_SUBST(aros_shared_cflags)
2839 AC_SUBST(aros_shared_aflags)
2840 AC_SUBST(aros_shared_ldflags)
2842 AC_SUBST(aros_config_sysroot)
2843 AC_SUBST(aros_nowarn_flags)
2844 AC_SUBST(aros_config_cflags)
2845 AC_SUBST(aros_config_aflags)
2846 AC_SUBST(aros_config_ldflags)
2848 AC_SUBST(aros_kernel_sysroot)
2849 AC_SUBST(aros_kernel_cflags)
2850 AC_SUBST(aros_kernel_includes)
2851 AC_SUBST(aros_kernel_objcflags)
2852 AC_SUBST(aros_kernel_ldflags)
2853 AC_SUBST(aros_target_cflags)
2854 AC_SUBST(aros_debug_cflags)
2855 AC_SUBST(aros_debug_aflags)
2856 AC_SUBST(aros_debug_ldflags)
2857 AC_SUBST(aros_target_genmap)
2858 AC_SUBST(aros_target_strip_flags)
2859 AC_SUBST(aros_optimization_cflags)
2860 AC_SUBST(aros_isa_flags)
2862 AC_SUBST(crosstools_target)
2863 AC_SUBST(crosstools_cxx_target)
2865 # Hosted Graphics Related
2866 AC_SUBST(host_x_gfx)
2867 AC_SUBST(host_sdl_gfx)
2868 AC_SUBST(host_android_gfx)
2870 AC_SUBST(pci_hidd_target)
2872 AC_SUBST(aros_nominal_width)
2873 AC_SUBST(aros_nominal_height)
2874 AC_SUBST(aros_nominal_depth)
2875 AC_SUBST(DO_XSHM_SUPPORT)
2876 AC_SUBST(DO_VIDMODE_SUPPORT)
2878 AC_SUBST(aros_host_x11_includes)
2879 AC_SUBST(aros_host_x11_libdirs)
2880 AC_SUBST(aros_host_sdl_cflags)
2881 AC_SUBST(aros_host_sdl_libs)
2883 # Native version related
2884 AC_SUBST(aros_serial_debug)
2885 AC_SUBST(ENABLE_EXECSMP)
2887 # Palm native version related
2888 AC_SUBST(aros_palm_debug_hack)
2890 # Unix/Hosted version related
2891 AC_SUBST(aros_nesting_supervisor)
2893 # MMU related
2894 AC_SUBST(aros_enable_mmu)
2896 # Apple iOS related
2897 AC_SUBST(aros_ios_platform)
2898 AC_SUBST(aros_ios_version)
2899 AC_SUBST(aros_ios_sdk)
2901 # ARM default GCC target related
2902 AC_SUBST(gcc_default_cpu)
2903 AC_SUBST(gcc_default_cpu_tune)
2904 AC_SUBST(gcc_default_fpu)
2905 AC_SUBST(gcc_default_float_abi)
2906 AC_SUBST(gcc_default_mode)
2908 # Android related
2909 AC_SUBST(android_tool)
2910 AC_SUBST(aros_android_level)
2911 AC_SUBST(aros_android_antapk)
2913 # DBUS related
2914 AC_SUBST(ENABLE_DBUS)
2915 AC_SUBST(DBUS_CFLAGS)
2916 AC_SUBST(DBUS_LIBFLAGS)
2917 AC_SUBST(KERNEL_DBUS_KOBJ)
2918 AC_SUBST(KERNEL_DBUS_INCLUDES)
2920 #X11 related
2921 AC_SUBST(ENABLE_X11)
2923 # Debug related
2924 AC_SUBST(aros_debug)
2925 AC_SUBST(aros_mungwall_debug)
2926 AC_SUBST(aros_stack_debug)
2927 AC_SUBST(aros_modules_debug)
2929 # Collect-aros stuff: "-ius" to ignore undefined symbols
2930 AC_SUBST(ignore_undefined_symbols)
2932 # C compiler related
2933 AC_SUBST(gcc_target_cpu)
2934 AC_SUBST(target_binutils_version)
2935 AC_SUBST(target_gcc_version)
2937 #ObjC compiler related
2938 AC_SUBST(objc_target)
2940 #Java related
2941 AC_SUBST(java_target)
2943 # USB3.0 code
2944 AC_SUBST(aros_usb30_code)
2946 dnl Prepare for output, make up all the generated patches
2947 case "$aros_flavour" in
2948 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2949                 aros_flavour="emulation" ;;
2950 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2951                 aros_flavour="emulation" ;;
2952 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2953                 aros_flavour="standalone";;
2954 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2955                 aros_flavour="standalone";;
2956 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2957                 aros_flavour="native" ;;
2958 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2959                 aros_flavour="native" ;;
2960 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2961                 aros_flavour="linklib" ;;
2962 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2963                 aros_flavour="palmnative" ;;
2964 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2965                 aros_flavour="mac68knative" ;;
2966 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2967                 aros_flavour="ppcnative" ;;
2968 esac
2970 if test ! -d ${aros_inc_dir} ; then
2971     ${MKDIR} ${aros_inc_dir}
2973 if test ! -d ${aros_geninc_dir} ; then
2974     ${MKDIR} ${aros_geninc_dir}
2976 if test ! -d ${aros_hostcfg_dir} ; then
2977     ${MKDIR} ${aros_hostcfg_dir}
2979 if test ! -d ${aros_targetcfg_dir} ; then
2980     ${MKDIR} ${aros_targetcfg_dir}
2982 if test ! -d ${aros_tools_dir} ; then
2983     ${MKDIR} ${aros_tools_dir}
2985 if test ! -d ${aros_scripts_dir} ; then
2986     ${MKDIR} ${aros_scripts_dir}
2989 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2991 # Generic build tools (metamake, etc)
2992 AC_CONFIG_COMMANDS([genmf-executable-support],
2993     [chmod a+x ${aros_tools_dir}/genmf.py],
2994     [aros_tools_dir=${aros_tools_dir}]
2996 AC_CONFIG_FILES(
2997     Makefile
2998     config/make.cfg
2999     ${aros_inc_dir}/config.h:config/config.h.in
3000     ${aros_geninc_dir}/config.h:config/config.h.in
3001     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3002     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3003     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3004     mmake.config
3005     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3006     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3007     tools/collect-aros/env.h
3010 # Binutils
3011 AC_CONFIG_COMMANDS([binutils-support],
3012     [
3013         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3014         mkdir -p $prefix
3015         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3017         chmod a+x ${prefix2}-ld
3019         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3020         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3021         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3022         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3023         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3024         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3025         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3026     ],
3027     [
3028         aros_host_exe_suffix=${aros_host_exe_suffix}
3029         aros_tools_dir=${aros_tools_dir}
3030         aros_target_cpu=${aros_target_cpu}
3031         aros_target_arch=${aros_target_arch}
3032         aros_target_suffix=${aros_target_suffix}
3033         orig_target_nm=${orig_target_nm}
3034         orig_target_as=${orig_target_as}
3035         orig_target_ar=${orig_target_ar}
3036         orig_target_ranlib=${orig_target_ranlib}
3037         orig_target_objdump=${orig_target_objdump}
3038         orig_target_objcopy=${orig_target_objcopy}
3039         orig_target_strip=${orig_target_strip}
3040         aros_kernel_ld=${aros_kernel_ld}
3041     ]
3043 AC_CONFIG_FILES(
3044     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
3047 # Bare Elf support script and spec
3048 if test "${use_kernel_cc_wrapper}" = "yes"; then
3049     AC_CONFIG_COMMANDS([elf-compiler-support],
3050         [
3051             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3052             mkdir -p $prefix
3053             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3055             chmod a+x ${prefix2}-gcc
3057             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3058         ],
3059         [
3060             aros_host_exe_suffix=${aros_host_exe_suffix}
3061             aros_tools_dir=${aros_tools_dir}
3062             aros_target_cpu=${aros_target_cpu}
3063             aros_target_arch=${aros_target_arch}
3064             aros_target_suffix=${aros_target_suffix}
3065             aros_kernel_ld=${aros_kernel_ld}
3066         ]
3067     )
3068     AC_CONFIG_FILES(
3069         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3070         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3071     )
3074 # Host compiler support scripts and spec
3075 if test "${aros_target_toolchain}" = "no"; then
3076     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3077         [
3078             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3079             mkdir -p $prefix
3080             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3082             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3083         ],
3084         [
3085             aros_host_exe_suffix=${aros_host_exe_suffix}
3086             aros_tools_dir=${aros_tools_dir}
3087             aros_target_cpu=${aros_target_cpu}
3088             aros_target_arch=${aros_target_arch}
3089             aros_target_suffix=${aros_target_suffix}
3090         ]
3091     )
3092     AC_CONFIG_FILES(
3093         ${aros_targetcfg_dir}/specs:config/specs.in
3094         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3095         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3096         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3097     )
3100 # Android support
3101 if test "$aros_target_variant" == "android"; then
3102     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3105 # cmake helper
3106 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3108 AC_OUTPUT
3110 dnl This is in order to not define SHARED_CFLAGS sometimes
3111 dnl We don't always do aros_shared_ar, aros_shared_cflags
3113 #XXX compatability...
3114 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3116 if test -n "$aros_shared_cflags" ; then
3117     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3118     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg