if the compiler supports it, don't warn about unused command line options by default
[AROS.git] / configure.in
blob39b2766ac4a0c01446ec47b16b6a442471a58f13
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         AC_CHECK_FILE(/usr/include/stddef.h,,
258                 AC_MSG_ERROR([XCode incorrectly configured!
259 please run 'xcode-select --install' before
260 re-running configure])
261         )
262         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
263         aros_host_arch="darwin"
264         host_cc_elf=no
265         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
266         android_build_os="darwin-x86"
267         android_tool="android"
268         default_android_sdk="/android-sdk-mac_x86"
269         case "$host_cpu" in
270             *i?86*)
271                 aros_host_cpu="i386"
272                 ;;
273             *x86_64*)
274                 aros_host_cpu="x86_64"
275                 ;;
276             *powerpc*)
277                 aros_host_cpu="ppc"
278                 ;;
279             *)
280                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
281                 aros_host_cpu="$host_cpu"
282                 ;;
283         esac
285         aros_host_ldflags="$aros_host_ldflags -liconv"
287         ;;
289     dragonfly*)
290         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
291         aros_host_make="gmake"
292         aros_host_arch="dragonfly"
293         case $host_cpu in
294             *i?86*)
295                 aros_host_cpu="i386"
296                 ;;
297             *amd64*)
298                 aros_host_cpu="x86_64"
299                 ;;
300             *)
301                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
302                 aros_host_cpu="$host_cpu"
303                 ;;
304         esac
305         ;;
307     netbsd*)
308         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
309         aros_host_make="gmake"
310         aros_host_arch="netbsd"
311         case "$host_cpu" in
312             *i?86*)
313                 aros_host_cpu="i386"
314                 ;;
315             *m68k*)
316                 aros_host_cpu="m68k"
317                 ;;
318             *)
319                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
320                 aros_host_cpu="$host_cpu"
321                 ;;
322         esac    
323         aros_host_lib_suffix=".0.0"
324         ;;
326     openbsd*)
327         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
328         aros_host_make="gmake"
329         aros_host_arch="openbsd"
330         case "$host_cpu" in
331             *i?86*)
332                 aros_host_cpu="i386"
333                 ;;
334             *)
335                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
336                 aros_host_cpu="$host_cpu"
337                 ;;
338         esac
339         ;;
340         
341     solaris*)
342         aros_host_arch="solaris"
343         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
344         case "$host_cpu" in
345             *i?86*)
346                 aros_host_cpu="i386"
347                 ;;
348             *sparc*)
349                 aros_host_cpu="sparc"
350                 ;;
351             *)
352                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
353                 aros_host_cpu="$host_cpu"
354                 ;;
355         esac
356         ;;
358     morphos*)
359         aros_host_arch="morphos"
360         aros_host_cpu="ppc"
361         host_cc_elf=no
362         ;;
364     amiga*)
365         aros_host_arch="amiga"
366         host_cc_elf=no
367         SORT="/gg/bin/sort"
368         TEST="/gg/bin/test"
369         UNIQ="/gg/bin/uniq"
370         FOR="for"
371         TOUCH="/gg/bin/touch"
372         case "$host_cpu" in
373             *m68k*)
374                 aros_host_cpu="m68k"
375                 ;;
376             *powerpc*)
377                 aros_host_cpu="ppc"
378                 ;;
379             *)
380                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
381                 aros_host_cpu="$host_cpu"
382                 ;;
383         esac
384         ;;
386     cygwin*)
387         aros_host_arch="cygwin"
388         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
389         host_cc_elf=no
390         android_build_os="windows"
391         android_tool="android.bat"
392         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
394         case "$host_cpu" in
395             *i?86*)
396                 aros_host_cpu="i386"
397                 ;;
398             *)
399                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
400                 aros_host_cpu="$host_cpu"
401                 ;;
402         esac
403         ;;
405     mingw32*)
406         aros_host_arch="mingw32"
407         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
408         host_cc_elf=no
409         android_build_os="windows"
410         android_tool="android.bat"
411         default_android_sdk="/c/android-sdk-windows-1.6_r1"
413         libpng_libextra="-lws2_32"
415         case "$host_cpu" in
416         *i?86*)
417             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
418             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
419             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
420             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
422             AC_MSG_CHECKING([for Windows native gcc target])
423             host_cpu=`gcc -dumpmachine`
424             AC_MSG_RESULT($host_cpu)
425             ;;
427         esac
429         case "$host_cpu" in
430         *i?86*)
431             aros_host_cpu="i386"
432             ;;
434         mingw32*)
435             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
436             aros_host_cpu="i386"
437             ;;
439         *x86_64*)
440             aros_host_cpu="x86_64"
441             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
442             dnl directory, so we have to add it explicitly here.
443             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
444             ;;
446         *)
447             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
448             aros_host_cpu="$host_cpu"
449             ;;
450         esac
451         ;;
452     *)
453         AC_MSG_ERROR([Unsupported host architecture $host])
454         ;;
455 esac
457 AROS_PROG(aros_host_ar,[ar],[cr])
458 AROS_REQUIRED(ar,$aros_host_ar)
459 AROS_PROG(aros_host_ranlib,ranlib)
460 AROS_REQUIRED(ranlib,$aros_host_ranlib)
461 AROS_PROG(aros_host_strip,strip)
462 AROS_REQUIRED(strip,$aros_host_strip)
464 AROS_PROG(RM,[rm],[-rf])
465 AROS_REQUIRED(rm,$RM)
466 AROS_PROG(CP,[cp])
467 AROS_REQUIRED(cp,$CP)
468 AROS_PROG(MV,[mv])
469 AROS_REQUIRED(mv,$MV)
470 AROS_PROG(ECHO,[echo])
471 AROS_REQUIRED(echo,$ECHO)
472 AROS_PROG(MKDIR,[mkdir],[-p])
473 AROS_REQUIRED(mkdir,$MKDIR)
474 AROS_PROG(TOUCH,[touch])
475 AROS_REQUIRED(touch,$TOUCH)
476 AROS_PROG(SORT,[sort])
477 AROS_REQUIRED(sort,$SORT)
478 AROS_PROG(UNIQ,[uniq])
479 AROS_REQUIRED(uniq,$UNIQ)
480 AROS_PROG(NOP,[true])
481 AROS_REQUIRED(true,$NOP)
482 AROS_PROG(CAT,[cat])
483 AROS_REQUIRED(cat,$CAT)
484 AROS_PROG(BISON,[bison])
485 AROS_REQUIRED(bison,$BISON)
486 AROS_PROG(FLEX,[flex])
487 AROS_REQUIRED(flex,$FLEX)
488 AROS_PROG(PNGTOPNM,[pngtopnm])
489 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
490 AROS_PROG(PPMTOILBM,[ppmtoilbm])
491 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
492 AROS_PROG(SED,[sed])
493 AROS_REQUIRED(sed,$SED)
494 AROS_PROG(CHMOD,[chmod])
495 AROS_REQUIRED(chmod,$CHMOD)
496 AROS_PROG(PATCH,[patch])
497 AROS_REQUIRED(patch,$PATCH)
499 AM_PATH_PYTHON(2.5)
501 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
502 if test "$enable_libpng_config" != "no"; then
503   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
505 if test "$arosconfig_use_libpngconfig" = "yes"; then
506     AC_MSG_CHECKING([libpng-config library])
507     libpng_incdir="`libpng-config --cflags`"
508     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
509     libpng="`libpng-config --libs`"
510     AC_MSG_RESULT($libpng)
511 else
512     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
513     if test "$libpng_libextra" != ""; then
514         if test "$libpng" != "no"; then
515             libpng_libextra="$libpng_libextra $libpng"
516         fi
517     fi
519 AROS_REQUIRED(libpng, $libpng)
520 AC_SUBST(libpng)
521 AC_SUBST(libpng_libextra)
522 AC_SUBST(libpng_incdir)
524 AC_SUBST(FOR, for)
525 AC_SUBST(IF, if)
526 AC_SUBST(TEST, test)
527 AC_SUBST(CMP, cmp)
529 dnl ---------------------------------------------------------------------------
530 dnl Look for things about the host system, good for hosted targets.
531 dnl ---------------------------------------------------------------------------
533 # Check for some includes for the X11 HIDD and the kernel
534 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
535     sys/mmap.h sys/mman.h sysexits.h \
536     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
539 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
541 AC_HEADER_DIRENT
542 AC_HEADER_STAT
543 AC_HEADER_STDC
544 AC_HEADER_SYS_WAIT
545 AC_HEADER_TIME
546 AC_STRUCT_ST_BLKSIZE
547 AC_STRUCT_ST_BLOCKS
548 AC_STRUCT_ST_RDEV
549 AC_STRUCT_TM
550 AC_STRUCT_TIMEZONE
551 AC_TYPE_OFF_T
552 AC_TYPE_PID_T
553 AC_TYPE_SIZE_T
554 AC_TYPE_UID_T
556 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
558 # Look for some functions
559 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
560     clone kse_create rfork_thread thr_create sa_register \
561     getcontext makecontext setcontext sigaltstack swapcontext])
563 AC_FUNC_MMAP
565 #-----------------------------------------------------------------------------
568 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
569 # it switched on by default, and we use the host compiler, so it compiles AROS
570 # code with this enabled resulting in link failures as we don't have support
571 # for it.
573 # We use two methods to disable it. For the host compiler (used to compile
574 # some hosted modules), we test to see if the compiler supports stack
575 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
576 # work on all platforms.
579 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
580 save_cflags="$CFLAGS"
581 CFLAGS="$CFLAGS -fno-stack-protector"
582 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
583 AC_MSG_RESULT($use_no_stack_protector)
584 if test "x-$use_no_stack_protector" = "x-yes" ; then
585     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
587 CFLAGS="$save_cflags"
589 #-----------------------------------------------------------------------------
591 # Disable pointer-signedness warnings if the compiler recognises the option
592 # (this only works for the host compiler at the moment)
594 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
595 save_cflags="$CFLAGS"
596 CFLAGS="$CFLAGS -Wno-pointer-sign"
597 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
598 AC_MSG_RESULT($use_no_sign_warning)
599 if test "x-$use_no_sign_warning" = "x-yes" ; then
600     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
602 CFLAGS="$save_cflags"
604 #-----------------------------------------------------------------------------
606 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
608 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
609 save_cflags="$CFLAGS"
610 CFLAGS="$CFLAGS -fgnu89-inline"
611 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
612 AC_MSG_RESULT($use_gnu89_inline)
613 if test "x-$use_gnu89_inline" = "x-yes" ; then
614     gnu89_inline="-fgnu89-inline"
616 CFLAGS="$save_cflags"
619 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
620 # On GCC >= 4.0 -iquote should be used
622 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
623 CFLAGS="$CFLAGS -iquote."
624 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
625 AC_MSG_RESULT($has_iquote)
626 if test "x-$has_iquote" = "x-yes" ; then
627     host_cflags_iquote=-iquote
628     host_cflags_iquote_end=
629 else
630     host_cflags_iquote=-I
631     host_cflags_iquote_end=-I-
634 AC_MSG_NOTICE([Performing target configuration...])
636 dnl --------------------------------------------------------------------
637 dnl Target Configuration Section
638 dnl --------------------------------------------------------------------
640 dnl The target configuration section is responsible for setting up all
641 dnl the paths for includes, and tools required to build AROS to some
642 dnl particular target.
644 aros_nowarn_flags="NOWARN_UNUSED_COMMAND_LINE_ARGUMENT NOWARN_UNKNOWN_WARNING_OPTION NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
646 toolchain_needs_sysroot=no
648 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
649 aros_config_aflags="-Wall -x assembler-with-cpp -c"
650 aros_config_ldflags=""
652 aros_shared_default=yes
654 aros_shared_cflags="-fPIC"
655 aros_shared_aflags=""
656 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
657 aros_kernel_ldflags="-Wl,-rpath,./lib"
659 aros_kernel_ar_flags="cr"
660 aros_target_ar_flags="cr"
661 aros_target_nm_flags="-C -ul"
662 aros_target_strip_flags="--strip-unneeded -R.comment"
664 aros_compiler_libs=
665 aros_arch_libs=
667 aros_target_genmap="-Wl,-Map -Xlinker"
669 # Native flavour stuff
670 aros_serial_debug="0"
672 # Palm native flavour stuff
673 aros_palm_debug_hack="0"
675 # Unix flavour stuff
676 aros_nesting_supervisor="0"
678 # Collect-aros stuff: "-ius" to ignore undefined symbols
679 ignore_undefined_symbols=""
681 # Check for X11 by default
682 need_x11="auto"
684 host_x_gfx=no
685 host_sdl_gfx=no
686 host_android_gfx=no
689 AC_MSG_CHECKING([Which toolchain family to use ...])
690 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")
691 AC_MSG_RESULT($aros_toolchain)
693 case "$aros_toolchain" in
694     *llvm*)
695         # toolchain_needs_sysroot=yes
696         toolchain_c_compiler="clang"
697         toolchain_cxx_compiler="clang++"
698         toolchain_cpp_preprocessor="clang -E"
699         toolchain_ld="lld"
700         toolchain_as="llvm-as"
701         toolchain_ar="llvm-ar"
702         toolchain_ranlib="llvm-ranlib"
703         toolchain_nm="llvm-nm"
704         toolchain_strip="true"
705         toolchain_objcopy="llvm-objcopy"
706         toolchain_objdump="llvm-objdump"
707         ;;
708     *gnu*)
709         toolchain_c_compiler="gcc"
710         toolchain_cxx_compiler="g++"
711         toolchain_cpp_preprocessor="cpp"
712         toolchain_ld="ld"
713         toolchain_as="as"
714         toolchain_ar="ar"
715         toolchain_ranlib="ranlib"
716         toolchain_nm="nm"
717         toolchain_strip="strip"
718         toolchain_objcopy="objcopy"
719         toolchain_objdump="objdump"
720         ;;
721     *)
722         AC_MSG_WARN("Unknown toolchain family!")
723         toolchain_c_compiler="cc"
724         toolchain_cxx_compiler="c++"
725         toolchain_cpp_preprocessor="cpp"
726         toolchain_ld="ld"
727         toolchain_as="as"
728         toolchain_ar="ar"
729         toolchain_ranlib="ranlib"
730         toolchain_nm="nm"
731         toolchain_strip="strip"
732         toolchain_objcopy="objcopy"
733         toolchain_objdump="objdump"
734         ;;
735 esac
737 #-----------------------------------------------------------------------------
739 AC_MSG_CHECKING([which type of build to do])
740 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")
742 if test "$build_type" = "nightly"; then
743     build_type_string="NIGHTLY"
744 elif test "$build_type" = "snapshot"; then
745     build_type_string="SNAPSHOT"
746 elif test "$build_type" = "milestone"; then
747     build_type_string="MILESTONE"
748 elif test "$build_type" = "release"; then
749     build_type_string="RELEASE"
750 else
751     build_type_string="PERSONAL"
752     build_type="personal"
755 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
757 AC_MSG_RESULT($build_type)
759 #-----------------------------------------------------------------------------
760 all_debug_types="messages stack modules mungwall symbols"
762 AC_MSG_CHECKING([which debug types to enable])
763 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)]),
764  debug="$enableval",debug="")
766 if test "$debug" = "" -o "$debug" = "no"; then
767     debug="none"
768 elif test "$debug" = "yes"; then
769     debug="all"
772 if test "$debug" = "all" ; then
773     debug="messages stack modules symbols"
774     for d in $all_debug_types; do
775         export aros_${d}_debug="1"
776     done
777 else
778     for d in $all_debug_types; do
779         export aros_${d}_debug="0"
780     done
783 if test "$debug" != "none"; then
784     debug=`echo $debug | sed s/,/\ /g`
785     for d in $debug; do
786         found="0"
787         for d2 in $all_debug_types; do
788             if test "$d2" = "$d"; then
789                 found="1"
790                 break
791             fi
792         done
793         if test "$found" = "0"; then
794             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
795         fi
796         export aros_${d}_debug="1"
797     done
798     aros_debug="yes"
800 AC_MSG_RESULT($debug)
802 if test "$aros_messages_debug" = "1"; then
803     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
804 else
805     aros_messages_debug=""
807 if test "$aros_symbols_debug" = "1"; then
808     aros_symbols_debug="-g"
809 else
810     aros_symbols_debug=""
813 # These are the flags to pass when compiling debugged programs
814 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
815 aros_debug_aflags=""
816 aros_debug_ldflags="$aros_symbols_debug"
818 #-----------------------------------------------------------------------------
819 #   Checking for distcc and ccache.
821 #   Always apply the transforms in this particular order. Basically you should
822 #   always run 'ccache distcc compiler' in that order for the best performance.
824 AC_MSG_CHECKING([whether to enable distcc])
825 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
826 if test "$distcc" != "" -a "$distcc" != "no"; then
827     # AC_CHECK_PROG will print out the result in this case
828     AC_PATH_PROG(DISTCC,[distcc],distcc,)
829 else
830     AC_MSG_RESULT(no)
833 AC_MSG_CHECKING([whether to enable ccache])
834 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
835 if test "$ccache" != "" -a "$ccache" != "no"; then
836     # AC_CHECK_PROG will print out the result in this case
837     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
838 else
839     AC_MSG_RESULT(no)
842 #-----------------------------------------------------------------------------
843 AC_MSG_CHECKING([what specific host gcc version to use])
844 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="")
845 if test "$kernel_tool_version" != "" ; then
846     msg_result=$kernel_tool_version
847 else
848     msg_result="default"
850 AC_MSG_RESULT($msg_result)
852 #-----------------------------------------------------------------------------
853 AC_MSG_CHECKING([what optimization flags to use])
854 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
855 if test "$optimization" = "unknown"; then
856     dnl default is -O2 for normal builds, -O0 for debug builds
857     if test "$debug" != "none"; then
858         optimization="-O0"
859     else
860         optimization="-O2"
861     fi
863 aros_optimization_cflags="$optimization"
864 AC_MSG_RESULT($optimization)
866 #-----------------------------------------------------------------------------
867 AC_MSG_CHECKING([which paranoia flags to use])
868 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[compiler warning flags to enable for paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
869 if test "$paranoia_flags" = "default"; then
870         paranoia_flags=""
871         msg_result="none"
872 else if test "$paranoia_flags" = "yes"; then
873         paranoia_flags="-Wall -Werror"
874         msg_result="$paranoia_flags"
875 fi fi
876 AC_MSG_RESULT($msg_result)
877 aros_config_cflags="$aros_config_cflags $paranoia_flags"
879 #-----------------------------------------------------------------------------
880 AC_MSG_CHECKING([what target variant to enable])
881 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
882 if test "$target_variant" = ""; then
883     aros_target_variant=""
884     aros_target_suffix=""
885     enableval="none"
886 else
887     aros_target_variant="$target_variant"
888     aros_target_suffix="-$target_variant"
890 AC_MSG_RESULT($enableval)
892 #-----------------------------------------------------------------------------
893 # Target-specific defaults. You can override then on a per-target basis.
895 # Bootloader name. Currently used by PC target.
896 target_bootloader="none"
897 ENABLE_EXECSMP=
899 #-----------------------------------------------------------------------------
900 # Additional options for some specific targets
902 case "$aros_target_variant" in
903 ios)
904     AC_MSG_CHECKING([XCode path])
905     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")
906     AC_MSG_RESULT($aros_xcode_path)
908     AC_MSG_CHECKING([what iOS SDK version to use])
909     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")
910     AC_MSG_RESULT($aros_sdk_version)
912     ;;
914 "android")
915     AC_MSG_CHECKING([Android SDK path])
916     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)
917     AC_MSG_RESULT($aros_android_sdk)
919     AC_MSG_CHECKING([Android NDK path])
920     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
921     AC_MSG_RESULT($aros_android_ndk)
923     AC_MSG_CHECKING([what Android SDK version to use])
924     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")
925     AC_MSG_RESULT($aros_sdk_version)
927     aros_android_level=android-$aros_sdk_version
928     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
929         echo "Platform $aros_android_level is not installed in your SDK"
930         echo "Use --with-sdk-version=<API level number> to select another platform version"
931         echo "You can check what plaform versions are installed in your SDK"
932         echo "by examining contents of $aros_android_sdk/platforms directory"
933         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
934     fi
936     export PATH="$aros_android_sdk/tools:$PATH"
937     AC_PATH_PROG(android_tool, $android_tool)
938     AROS_REQUIRED(android,$android_tool)
940     if test "$aros_android_ndk" != "none"; then
941         AC_MSG_CHECKING([what Android NDK version to use])
942         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")
943         AC_MSG_RESULT($aros_ndk_version)
944     fi
946     AC_PATH_PROG(ant, ant)
947     if test "$ant" = ""; then
948         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
949     fi
951     AC_MSG_CHECKING([Build debug or release apk])
952     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)
953     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
954         AC_MSG_ERROR([apk-version has to be release or debug])
955     fi
956     AC_MSG_RESULT($aros_android_antapk)
958     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
959     if test "$host_os" = "mingw32"; then
960         android_tool="cmd //c $android_tool"
961     fi
963     need_dlopen="no"
965     ;;
966 esac
968 #-----------------------------------------------------------------------------
969 # External toolchains
970 kernel_tool_prefix="none"
971 aros_tool_prefix="none"
972 elf_tool_prefix="${target_cpu}-elf-"
974 # This is the target configuration switch.
975 case "$target_os" in
976     linux*)
977         aros_target_arch="linux"
978         aros_target_family="unix"
979         case "$target_cpu" in
980             *m68k*)
981                 aros_target_cpu="m68k"
982                 aros_object_format="m68kelf"
983                 aros_flavour="emulcompat"
984                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
985                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
986                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
987                 gcc_target_cpu="mc68000"
988                 ;;
989             *i?86*)
990                 aros_target_cpu="i386"
991                 aros_object_format="elf_i386"
992                 aros_flavour="emulation"
993                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
994                 aros_kernel_ldflags="-Wl,-melf_i386"
995                 aros_nominal_depth=8
996                 gcc_target_cpu="i386"
997                 pci_hidd_target="hidd-pci-linux"
998                 android_tool_dir_prefix="x86"
999                 android_tool_prefix="i686-android-linux"
1000                 android_ndk_arch="x86"
1001                 ;;
1002             *x86_64*)
1003                 aros_target_cpu="x86_64"
1004                 aros_object_format="elf_x86_64"
1005                 aros_flavour="emulation"
1006                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1007                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1008                 aros_nominal_depth=8
1009                 pci_hidd_target="hidd-pci-linux"
1010                 ;;
1011             *powerpc*)
1012                 aros_target_cpu="ppc"
1013                 aros_object_format="elf32ppc"
1014                 aros_flavour="emulation"
1015                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1016                 aros_nominal_depth=8
1017                 gcc_target_cpu="ppc"
1018                 ;;
1019 # TODO
1020 # Same as powerpc, but I need this for the nightly build to work again.
1021 # Actually, the nightly should be made working with powerpc target.
1022 # That just was too much work for the moment, another week or two.
1023             *ppc*)
1024                 aros_target_cpu="ppc"
1025                 aros_object_format="elf32ppc"
1026                 aros_flavour="emulation"
1027                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1028                 aros_nominal_depth=8
1029                 gcc_target_cpu="ppc"
1030                 ;;
1031             *aarch64*)
1032                 aros_target_cpu="aarch64"
1033                 target_cpu="aarch64"
1034                 aros_object_format="aarch64elf_aros"
1035                 aros_flavour="emulation"
1036                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1037                 gcc_target_cpu="aarch64"
1038                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1039                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1040                 aros_arch_libs="-laeabi"
1041                 gcc_default_float_abi="hard"
1042                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1043                 ;;
1044             *armhf*)
1045                 aros_target_cpu="arm"
1046                 target_cpu="arm"
1047                 aros_object_format="armelf_aros"
1048                 aros_flavour="emulation"
1049                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1050                 gcc_target_cpu="arm"
1051                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1052                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1053                 aros_arch_libs="-laeabi"
1054                 gcc_default_float_abi="hard"
1055                 android_tool_dir_prefix="arm-linux-androideabi"
1056                 android_tool_prefix="arm-linux-androideabi"
1057                 android_ndk_arch="arm"
1058                 kernel_tool_prefix="arm-linux-gnueabihf-"
1059                 ;;
1060             *arm*)
1061                 aros_target_cpu="arm"
1062                 aros_object_format="armelf_aros"
1063                 aros_flavour="emulation"
1064                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1065                 gcc_target_cpu="arm"
1066                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1067                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1068                 aros_arch_libs="-laeabi"
1069                 android_tool_dir_prefix="arm-linux-androideabi"
1070                 android_tool_prefix="arm-linux-androideabi"
1071                 android_ndk_arch="arm"
1072                 kernel_tool_prefix="arm-linux-gnueabi-"
1073                 ;;
1074             *)
1075                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1076                 ;;
1077         esac
1078         case "$aros_target_variant" in
1079             android)
1081                 dnl Not all Linux CPUs are supported by Android
1082                 if test "$android_ndk_arch" = ""; then
1083                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1084                 fi
1086                 aros_nominal_width=320
1087                 aros_nominal_height=480
1088                 if test "$aros_android_ndk" = "none"; then
1089                     dnl Use standalone toolchain, don't adjust paths
1090                     aros_kernel_cflags="-mandroid"
1091                     aros_kernel_ldflags="-mandroid"
1092                     CFLAGS="-mandroid"
1093                 else
1094                     dnl In Android NDK toolchains are placed in own directories,
1095                     dnl but tool names are not suffixed with version 
1096                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1097                     kernel_tool_version=""
1098                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1099                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1100                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1101                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1102                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1103                 fi
1104                 need_x11=no
1105                 host_android_gfx=yes
1106                 # Disable implicit PIC mode
1107                 aros_target_cflags="$aros_target_cflags -fno-pic"
1108                 kernel_tool_prefix="$android_tool_prefix-"
1109             ;;
1110         esac
1111     ;;
1113     pc)
1114         aros_target_arch="pc"
1115         aros_shared_default="no"
1116         target_bootloader="grub2"
1117         case "$target_cpu" in
1118             *i?86*)
1119                 aros_target_cpu="i386"
1121                 dnl If somebody hasn't already set the target object
1122                 dnl format, then use this value. Mostly to support
1123                 dnl FreeBSD cross-compilation.
1124                 dnl TODO: Remove when we always use our compiler.
1126                 if test "$aros_object_format" = "" ; then
1127                     aros_object_format="elf_i386"
1128                 fi
1129                 aros_flavour="standalone"
1130                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1131                 aros_kernel_ldflags="-Wl,-melf_i386"
1132                 aros_nominal_width=640
1133                 aros_nominal_height=480
1134                 gcc_target_cpu="i386"
1135                 ;;
1136             *x86_64*)
1137                 aros_target_cpu="x86_64"
1138                 aros_serial_debug=1
1139                 if test "$aros_object_format" = "" ; then
1140                     aros_object_format="elf_x86_64"
1141                 fi
1142                 aros_flavour="standalone"
1143                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1144                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1145                 aros_kernel_ldflags=""
1146                 aros_nominal_width=640
1147                 aros_nominal_height=480
1148                 case "$aros_target_variant" in
1149                     smp)
1150                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1151                     ;;
1152                 esac
1153                 ;;
1154             *)
1155                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1156                 ;;
1157         esac
1158         ;;
1160     prep)
1161         aros_target_arch="prep"
1162         aros_shared_default="no"
1163         aros_target_cpu="ppc"
1164         aros_object_format="elf32ppc"
1165         aros_flavour="ppcnative"
1166         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1167         aros_kernel_ldflags=""
1168         aros_nominal_width=640
1169         aros_nominal_height=480
1170         gcc_target_cpu="ppc"
1171         ;;
1173     freebsd*)
1174         aros_target_arch="freebsd"
1175         aros_target_family="unix"
1176         aros_target_cpu="i386"
1177         aros_flavour="emulation"
1178         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1179         gcc_target_cpu="i386"
1181         aros_target_strip_flags="-x"
1182         ;;
1184     darwin*)
1185         aros_target_arch="darwin"
1186         aros_target_family="unix"
1187         aros_flavour="emulation"
1188         case "$target_cpu" in
1189             *i?86*)
1190                 aros_ios_platform="iPhoneSimulator"
1191                 aros_target_cpu="i386"
1192                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1193                 aros_kernel_ldflags=""
1194                 aros_macosx_version="10.4"
1195                 aros_nominal_depth=8
1196                 gcc_target_cpu="i386"
1197                 aros_object_format="elf_i386"
1198                 aros_kernel_ar_flags="-cr"
1199                 aros_target_strip_flags="-x"
1200                 kernel_tool_flags="-m32"
1201                 ;;
1202             *x86_64*)
1203                 aros_target_cpu="x86_64"
1204                 aros_object_format="elf_x86_64"
1205                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1206                 aros_macosx_version="10.6"
1207                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1208                 aros_kernel_cflags="-m64"
1209                 aros_kernel_ldflags="-m64"
1210                 aros_target_cflags="-mcmodel=large"
1211                 aros_nominal_depth=8
1212                 aros_kernel_ar="ar"
1213                 aros_kernel_ar_flags="-cr"
1214                 aros_kernel_ld="ld"
1215                 aros_kernel_as="as"
1216                 aros_kernel_ranlib="ranlib"
1217                 aros_kernel_nm="nm"
1218                 aros_kernel_strip="strip"
1219                 kernel_tool_prefix="i686-apple-darwin10-"
1220                 ;;
1221             *ppc*)
1222                 aros_target_cpu="ppc"
1223                 aros_object_format="elf32ppc"
1224                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1225                 aros_kernel_ldflags=""
1226                 aros_macosx_version="10.0"
1227                 aros_nominal_depth=8
1228                 gcc_target_cpu="ppc"
1229                 aros_kernel_ar="ar"
1230                 aros_kernel_ar_flags="-cr"
1231                 aros_kernel_ld="ld -arch ppc"
1232                 aros_kernel_as="as -arch ppc"
1233                 aros_kernel_ranlib="ranlib -arch ppc"
1234                 aros_kernel_nm="nm -arch ppc"
1235                 aros_kernel_strip="strip -arch ppc"
1236                 kernel_tool_prefix="powerpc-apple-darwin10-"
1237                 ;;
1238             *arm*)
1239                 aros_ios_platform="iPhoneOS"
1240                 aros_target_cpu="arm"
1241                 aros_object_format="armelf_aros"
1242                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1243                 aros_arch_libs="-laeabi"
1244                 aros_nominal_depth=8
1245                 gcc_target_cpu="arm"
1246                 aros_kernel_ar="ar"
1247                 aros_kernel_ar_flags="-cr"
1248                 aros_kernel_ld="ld -arch arm"
1249                 aros_kernel_ranlib="ranlib -arch arm"
1250                 kernel_tool_prefix="arm-apple-darwin10-" 
1251                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1252                 ;;
1253             *)
1254                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1255                 ;;
1256         esac
1257         case "$aros_target_variant" in
1258             ios)
1259                 aros_ios_version="3.0"
1260                 aros_nominal_width=320
1261                 aros_nominal_height=480
1262                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1263                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1264                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1265                 need_x11=no
1266                 # This is here because it may depend on iOS or SDK version
1267                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1268                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1269                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1270             ;;
1271             *)
1272                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1273                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1274             ;;
1275         esac
1276         ;;
1278     dragonfly*)
1279         aros_target_arch="dragonfly"
1280         aros_target_family="unix"
1281         aros_flavour="emulation"
1282         case "$target_cpu" in
1283             *i?86*)
1284                 aros_target_cpu="i386"
1285                 aros_object_format="elf_i386"
1286                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1287                 ;;
1288             *x86_64*)
1289                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1290                 aros_target_cpu="x86_64"
1291                 aros_object_format="elf_x86_64"
1292                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1293                 ;;
1294             *)
1295                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1296                 ;;
1297         esac
1298         ;;
1300     netbsd*)
1301         aros_target_arch="netbsd"
1302         aros_target_family="unix"
1303         case "$target_cpu" in
1304             *m68k*)
1305                 aros_target_cpu="m68k"
1306                 aros_object_format="m68kelf"
1307                 aros_flavour="emulcompat"
1308                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1309                 gcc_target_cpu="mc68000"
1310                 ;;
1311             *i?86*)
1312                 aros_target_cpu="i386"
1313                 aros_object_format="elf_i386"
1314                 aros_flavour="emulation"
1315                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1316                 aros_nominal_depth=8
1317                 gcc_target_cpu="i386"
1318                 ;;
1319             *)
1320                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1321                 ;;
1322         esac
1323         aros_target_genmap="-Wl,-M -Xlinker >"
1324         aros_flavour="emulation"
1325         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1326         ;;   
1328     openbsd*)
1329         aros_target_arch="openbsd"
1330         aros_target_family="unix"
1331         case "$target_cpu" in
1332             *i?86*)
1333                 aros_target_cpu="i386"
1334                 aros_object_format="elf_i386"
1335                 aros_flavour="emulation"
1336                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1337                 gcc_target_cpu="i386"
1338                 ;;
1339             *)
1340                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1341                 ;;
1342         esac
1343         aros_target_genmap="-Wl,-M -Xlinker >"
1344         aros_target_nm_flags="-u"
1345         aros_flavour="emulation"
1346         ;;
1348     solaris*)
1349         aros_target_arch="solaris"
1350         aros_target_family="unix"
1351         case "$target_cpu" in
1352            *i?86*)
1353                aros_target_cpu="i386"
1354                aros_object_format="elf_i386"
1355                aros_flavour="emulation"
1356                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1357                aros_nominal_depth=8
1358                gcc_target_cpu="i386"
1359                ;;
1360             *sparc*)
1361                 aros_target_cpu="sparc"
1362                 aros_object_format="elf_sparc"
1363                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1364                 gcc_target_cpu="sparc"
1365                 ;;
1366             *)
1367                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1368                 ;;
1369         esac
1370         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1371         aros_flavour="emulation"
1372         ;;
1374     morphos*)
1375         aros_target_arch="morphos"
1376         aros_shared_default="no"
1377         aros_target_cpu="ppc"
1378         aros_object_format="elf_ppc"
1379         aros_flavour="nativecompat"
1380         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1381         gcc_target_cpu="ppc"
1382         ;;
1384     sam440)
1385         aros_target_arch="sam440"
1386         aros_shared_default="no"
1387         aros_target_cpu="ppc"
1388         aros_object_format="elf32ppc"
1389         aros_flavour="ppcnative"
1390         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1391         aros_kernel_ldflags=""
1392         aros_nominal_width=1024
1393         aros_nominal_height=768
1394         aros_nominal_depth=24
1395         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1396         gcc_target_cpu="powerpc"
1397         ;;
1399     efika)
1400         aros_target_arch="efika"
1401         aros_shared_default="no"
1402         aros_target_cpu="arm"
1403         aros_object_format="armelf_aros"
1404         aros_flavour="standalone"
1405         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1406         aros_kernel_ldflags=""
1407         aros_nominal_width=1024
1408         aros_nominal_height=600
1409         aros_arch_libs="-laeabi"
1410         gcc_default_cpu="armv7-a"
1411         gcc_default_fpu="vfpv3"
1412         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1413         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1414         aros_optimization_cflags="$aros_optimization_cflags -Os"
1415         case "$target_cpu" in
1416             *armhf*)
1417                 gcc_default_float_abi="hard"
1418                 target_cpu=arm
1419                 aros_target_cpu=arm
1420                 ;;
1421             *arm*)
1422                 gcc_default_float_abi="softfp"
1423                 ;;
1424             *)
1425                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1426                 ;;
1427         esac
1428         ;;
1429         
1430     chrp)
1431         aros_target_arch="chrp"
1432         aros_shared_default="no"
1433         aros_target_cpu="ppc"
1434         aros_object_format="elf32ppc"
1435         aros_flavour="ppcnative"
1436         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1437         aros_kernel_ldflags=""
1438         aros_nominal_width=640
1439         aros_nominal_height=480
1440         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1441         gcc_target_cpu="powerpc"
1442         case "$aros_target_variant" in
1443             efika)
1444                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1445             ;;
1446         esac
1447         ;;
1449     r*pi)
1450         aros_flavour="standalone"
1451         aros_target_arch="raspi"
1453         aros_shared_default="no"
1455         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1456         
1457         case "$target_cpu" in
1458             *aarch64*)
1459                 aros_target_cpu="aarch64"
1460                 gcc_default_cpu="aarch64"
1461                 aros_object_format="aarch64elf_aros"
1462                 ;;
1463             *armhf*)
1464                 aros_target_cpu="arm"
1465                 gcc_default_cpu="armv6zk"
1466                 gcc_default_cpu_tune="arm1176jzf-s"
1467                 aros_object_format="armelf_aros"
1468                 aros_config_cflags="$aros_config_cflags -marm"
1469                 aros_config_aflags="$aros_config_aflags -marm"
1470                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1471                 aros_target_cflags="$aros_kernel_cflags -marm"
1472                 aros_target_mkdep="$aros_target_mkdep -Darm"
1473                 aros_arch_libs="-laeabi"
1474                 ;;
1475             *arm*)
1476                 aros_target_cpu="arm"
1477                 gcc_default_cpu="armv6zk"
1478                 gcc_default_cpu_tune="arm1176jzf-s"
1479                 aros_object_format="armelf_aros"
1480                 aros_config_cflags="$aros_config_cflags -marm"
1481                 aros_config_aflags="$aros_config_aflags -marm"
1482                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1483                 aros_target_cflags="$aros_kernel_cflags -marm"
1484                 aros_target_mkdep="$aros_target_mkdep -Darm"
1485                 aros_arch_libs="-laeabi"
1486                 ;;
1487             *)
1488                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1489                 ;;
1490         esac
1492         aros_config_cflags="$aros_config_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1493         aros_config_aflags="$aros_config_aflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1494         aros_kernel_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1495         aros_target_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1497         case "$aros_target_variant" in
1498             smp)
1499                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1500             ;;
1501         esac
1502         ;;
1504     stm32f7_discovery)
1505         aros_flavour="standalone"
1506         aros_target_arch="stm32f7_discovery"
1507         aros_target_cpu="arm"
1508         aros_target_cpu_mode="thumb2"
1509         aros_object_format="armelf_aros"
1510         aros_shared_default="no"
1512         # stm32f7 has DSP opcode support
1513         gcc_default_cpu="armv7e-m"
1514         # gcc_default_cpu="armv7-m"
1515         gcc_default_cpu_tune="cortex-m7"
1516         gcc_default_fpu="fpv4-sp-d16"
1517         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1518         # gcc_default_fpu="fpv5-sp-d16"
1519                 gcc_default_float_abi="hard"
1521         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1522         ;;
1524     amiga*)
1525         aros_target_arch="amiga"
1526         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1527         aros_shared_default="no"
1529         case "$target_cpu" in
1530             *m68k*)
1531                 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")
1532                 aros_enable_mmu=no
1533                 aros_target_cpu="m68k"
1534                 aros_object_format="m68kelf"
1535                 aros_flavour="standcompat"
1536                 gcc_target_cpu="m68000"
1537                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1538                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1539                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1540                 aros_config_aflags="$aros_config_aflags"
1541                 aros_target_strip_flags="-R.comment --strip-debug"
1542                 aros_nominal_width=640
1543                 aros_nominal_height=256
1544                 aros_nominal_depth=2
1545                 ;;
1546             *ppc*)
1547                 aros_cpu="ppc"
1548                 aros_flavour="native"
1549                 gcc_target_cpu="ppc"
1550                 ;;
1551             *)
1552                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1553                 ;;
1554         esac
1555         ;;
1557     mingw*)
1558         aros_target_arch="mingw32"
1559         aros_shared_default="no"
1560         aros_flavour="emulation"
1561         aros_shared_cflags=""
1562         need_crosstools="yes"
1563         need_dlopen="no"
1564         rescomp="windres"
1565         case "$target_cpu" in
1566             *i?86*)
1567                 aros_target_cpu="i386"
1568                 aros_object_format="elf_i386"
1569                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1570                 aros_nominal_depth=8
1571                 gcc_target_cpu="i386"
1573                 kernel_tool_prefix="i386-mingw32-"
1574                 ;;
1575             *x86_64*)
1576                 aros_target_cpu="x86_64"
1577                 aros_object_format="elf_x86_64"
1578                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1579                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1580                 aros_nominal_depth=8
1581                 kernel_tool_prefix="x86_64-w64-mingw32-"
1582                 ;;
1583             *arm*)
1584                 aros_target_cpu="arm"
1585                 aros_object_format="armelf_aros"
1586                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1587                 aros_arch_libs="-laeabi"
1588                 aros_nominal_depth=8
1589                 gcc_target_cpu="arm"
1590                 gcc_default_float_abi="soft"
1591                 kernel_tool_prefix="arm-mingw32ce-"
1592                 aros_nominal_width=160
1593                 aros_nominal_height=160
1594                 ;;
1595             *)
1596                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1597                 ;;
1598         esac
1599         if test $host_os = "cygwin"; then
1600                 aros_kernel_cflags="-mno-cygwin"
1601         fi
1602     ;;
1603     pp*)
1604         aros_target_arch="pp"
1605         aros_shared_default="no"
1606         case "$target_cpu" in
1607             *m68k*)
1608                 aros_target_cpu="m68k"
1609                 aros_object_format="m68kelf"
1610                 aros_flavour="palmnative"
1611                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1612                 aros_nominal_width=160
1613                 aros_nominal_height=160
1614                 aros_nominal_depth=1
1615                 aros_target_ar_flags="cru"
1616                 aros_compiler_libs="-lgcc1"
1617                 aros_shared_default=no
1618                 aros_shared_cflags="-fpic"
1619                 aros_shared_aflags=""
1620                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1621                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1622                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1623                 aros_debug_aflags=""
1624                 aros_debug_ldflags="$aros_symbols_debug"
1625                 aros_mungwall_debug="0"
1626                 aros_modules_debug="0"
1627                 gcc_target_cpu="mc68000"
1628                 ignore_undefined_symbols="-ius"
1629                 ;;
1630            *)
1631                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1632                 ;;
1633         esac
1634         ;;
1636     mac*)
1637         aros_target_arch="mac"
1638         aros_shared_default="no"
1639         case "$target_cpu" in
1640             *m68k*)
1641                 aros_target_cpu="m68k"
1642                 aros_object_format="m68kelf"
1643                 aros_flavour="mac68knative"
1644                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1645                 aros_nominal_width=512
1646                 aros_nominal_height=384
1647                 aros_nominal_depth=8
1648                 aros_target_ar_flags="cru"
1649                 aros_compiler_libs="-lgcc1"
1650                 aros_shared_default=no
1651                 aros_shared_cflags="-fpic"
1652                 aros_shared_aflags=""
1653                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1654                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1655                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1656                 aros_debug_aflags=""
1657                 aros_debug_ldflags="$aros_symbols_debug"
1658                 aros_mungwall_debug="0"
1659                 aros_modules_debug="0"
1660                 gcc_target_cpu="mc68000"
1661                 ignore_undefined_symbols="-ius"
1662                 ;;
1663            *)
1664                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1665                 ;;
1666         esac
1667         ;;
1669     *)
1670         AC_MSG_ERROR([Unsupported target architecture $target])
1671         ;;
1672 esac
1674 #-----------------------------------------------------------------------------
1675 crosstools_guess="yes"
1676 aros_target_toolchain="no"
1677 aros_config_sysroot=""
1678 aros_kernel_sysroot=""
1680 AC_MSG_CHECKING([Kernel toolchain prefix])
1681 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1682 AC_MSG_RESULT($kernel_tool_prefix)
1684 AC_MSG_CHECKING([ELF toolchain prefix])
1685 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"
1686                                                  crosstools_guess="no"])
1687 AC_MSG_RESULT($elf_tool_prefix)
1689 AC_MSG_CHECKING([AROS toolchain prefix])
1690 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"
1691                 crosstools_guess="no"])
1692 if test "$aros_tool_prefix" = "yes" ; then
1693     aros_tool_prefix=$aros_target_cpu-aros-
1695 AC_MSG_RESULT($aros_tool_prefix)
1697 #-----------------------------------------------------------------------------
1698 #   Checking if we should build crosstools..
1699 AC_MSG_CHECKING([whether to build crosstools])
1700 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1701 AC_MSG_RESULT($crosstools)
1703 if test "${crosstools}" = "yes"; then
1704     if test "${crosstools_guess}" = "no"; then
1705         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1706     fi
1709 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1710     aros_target_toolchain="yes"
1713 AC_MSG_CHECKING([where to install the crosstools binaries])
1714 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])
1715 if test "x$aros_toolchain_install" = "x"; then
1716     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1717 else
1718     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1719     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1720     if test "$crosstools_guess" = "no" ; then
1721         toolchain_needs_sysroot=yes
1723         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1724             aros_kernel_sysroot = $aros_config_sysroot
1725         fi
1726     fi
1728 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1730 AC_MSG_CHECKING([If we need to use --sysroot])
1731 if test "$toolchain_needs_sysroot" = "yes" ; then
1732     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1734 AC_MSG_RESULT($toolchain_needs_sysroot)
1736 #-----------------------------------------------------------------------------
1737 if test "$aros_toolchain" = "gnu" ; then
1738     AC_MSG_CHECKING([what specific target binutils version to use])
1740 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="")
1741 if test "$use_binutils_version" = ""; then
1742         target_binutils_version="$default_binutils_version"
1743 else
1744     target_binutils_version="$use_binutils_version"
1746 if test "$aros_toolchain" = "gnu" ; then
1747     AC_MSG_RESULT($target_binutils_version)
1751 # Helper to identify gcc version
1752 AC_DEFUN([CROSS_GCC_VERSION], [
1753   target_gcc_version=""
1754   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1755     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1756     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1757       ax_cv_gcc_version=""
1758     ])
1759   ])
1760   target_gcc_version=$ax_cv_gcc_version
1761   AC_SUBST([target_gcc_version])
1764 #-----------------------------------------------------------------------------
1765 if test "$aros_toolchain" = "gnu" ; then
1766     AC_MSG_CHECKING([what specific target gcc version to use])
1768 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1769 if test "$use_gcc_version" = ""; then
1770     if test "${crosstools}" = "no"; then
1771       if test "x$aros_toolchain_install" != "x"; then
1772           CROSS_GCC_VERSION
1773       fi
1774     fi
1775     if test "$use_gcc_version" = ""; then
1776         target_gcc_version="$default_gcc_version"
1777     fi
1778 else
1779     target_gcc_version="$use_gcc_version"
1781 if test "$aros_toolchain" = "gnu" ; then
1782     AC_MSG_RESULT($target_gcc_version)
1784     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1785     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1786     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1788     gcc_fix_bitfields="false"
1789     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1790         gcc_fix_bitfields="true"
1791     else
1792         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1793             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1794                 gcc_fix_bitfields="true"
1795             fi
1796         fi
1797     fi
1799     if test "$gcc_fix_bitfields" = "true" ; then
1800         case "$aros_target_cpu" in
1801         *x86_64*)
1802             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1803             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1804             ;;
1805         i386)
1806             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1807             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1808             ;;
1809         esac
1810     fi
1813 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1814 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1815 AC_MSG_RESULT($objc)
1816 if test "x$objc" = "xyes"; then
1817     objc_target="$objc"
1818 else
1819     objc_target="no-objc"
1822 AC_MSG_CHECKING([whether to enable Java suppport])
1823 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1824 AC_MSG_RESULT($java)
1825 if test "x$java" != "xno"; then
1826     java_target="$java"
1827 else
1828     java_target="no-java"
1831 spec_obj_format="-m $aros_object_format"
1832 # Now process extra architecture-specific options.
1833 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1834 # as well as floating-point ABI.
1835 case "$aros_target_cpu" in
1836 *x86_64*)
1837     dnl x86_64 can build 32 or 64bit code
1838     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1839     ;;
1840 arm*)
1841     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1842     if test "$gcc_default_cpu" = ""; then
1843         gcc_default_cpu="armv6"
1844     fi
1845     if test "$gcc_default_fpu" = ""; then
1846         gcc_default_fpu="vfp"
1847     fi
1848     if test "$gcc_default_float_abi" = ""; then
1849         if test "$target_cpu" = "armhf"; then
1850             gcc_default_float_abi="hard"
1851         else
1852             gcc_default_float_abi="softfp"
1853         fi
1854     fi
1856     AC_MSG_CHECKING([Which minimum CPU to use])
1857     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)
1858     AC_MSG_RESULT($aros_gcc_cpu)
1860     AC_MSG_CHECKING([Which minimum FPU to use])
1861     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)
1862     AC_MSG_RESULT($aros_gcc_fpu)
1864     AC_MSG_CHECKING([Which floating point ABI to use])
1865     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)
1866     AC_MSG_RESULT($aros_gcc_float_abi)
1868     AC_MSG_CHECKING([Which ARM mode to use])
1869     if test "$aros_target_cpu_mode" = ""; then
1870         aros_target_cpu_mode="arm32"
1871         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1872     else
1873         AC_MSG_RESULT([$aros_target_cpu_mode])
1874     fi
1876     case "$aros_target_cpu_mode" in
1877     arm32)
1878         gcc_default_mode="arm"
1879         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1880     ;;
1881     arm64)
1882         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1883     ;;
1884     thumb)
1885         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1886     ;;
1887     thumb1)
1888         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1889     ;;
1890     thumb2)
1891         gcc_default_mode="thumb"
1892         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1893         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1894     ;;
1895     *)
1896         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1897     ;;
1898     esac
1900     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1901     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1902     ;;
1903 i386)
1904     aros_isa_flags="-m32 -march=i486"
1905     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1906     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1907     ;;
1908 esac
1910 # Some architectures may need custom ELF specs.
1911 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1912     elf_specs_in=config/${aros_object_format}-specs.in
1913 else
1914     elf_specs_in=config/elf-specs.in
1917 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1918 # Since we override specs, we may need to put these defines there
1919 if test "$gcc_target_cpu" != ""; then
1920     gcc_target_cpu="-D__${gcc_target_cpu}__"
1923 AC_MSG_CHECKING([where to download sourcecode for external ports])
1924 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1925 if test "$with_portssrcdir" = "default"; then
1926     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1927 else
1928     AROS_PORTSSRCDIR="$with_portssrcdir"
1930 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1932 AC_MSG_CHECKING([which bootloader to use])
1933 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1934 if test "$target_bootloader" = "none"; then
1935     aros_target_bootloader=""
1936 else
1937     aros_target_bootloader="$target_bootloader"
1939 AC_MSG_RESULT($target_bootloader)
1941 AC_MSG_CHECKING([which icon-set to use])
1942 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1943 if test "$target_iconset" = "default"; then
1944     aros_target_iconset="Gorilla"
1945     target_iconset="default (Gorilla)"
1946 else
1947     aros_target_iconset="$target_iconset"
1949 AC_MSG_RESULT($target_iconset)
1951 AC_MSG_CHECKING([which GUI Theme to use])
1952 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1953 if test "$target_guitheme" = "default"; then
1954     aros_target_guitheme="Ice"
1955 else
1956     aros_target_guitheme="$target_guitheme"
1958 AC_MSG_RESULT($aros_target_guitheme)
1960 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1961 # for target code)
1962 cross_compiling=no
1964 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1965 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1966     cross_compiling=yes
1969 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1970 dnl The flag itself is given in per-target section, because some targets require to pass it
1971 dnl in a different manner, otherwise some tests fail.
1972 dnl TODO: Justify this.
1973 if test "$aros_host_cpu" == "x86_64" ; then
1974     if test "$aros_target_cpu" == "i386" ; then
1975         cross_compiling=no
1976     fi
1979 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1980     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1981     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1982     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1983     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1984     dnl used to build bootstrap for target arch in either case.
1985     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1986     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1987     dnl perhaps introducing aros_host_variant
1988     if test "$aros_host_arch" != "$aros_target_arch" ; then
1989         cross_compiling=yes
1990     fi
1991 else
1992     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1993     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1994     if test "$host_cc_elf" = "no" ; then
1995         cross_compiling=yes
1996     fi
1999 if test "$cross_compiling" = "no" ; then
2000     kernel_tool_prefix=""
2001     if test "$host_cc_elf" = "yes" ; then
2002         elf_tool_prefix=""
2003     fi
2006 if test "$kernel_tool_version" != ""; then
2007     kernel_tool_version="-$kernel_tool_version"
2010 #######################################################################
2011 ## Compute what toolchains to use, and their paths                   ##
2012 #######################################################################
2014 # This takes, as input:
2015 #   crosstools             {yes,no}
2016 #   kernel_tool_version    {"",[version]}
2017 #   target_tool_version    {"",[version]}
2018 #   kernel_tool_prefix     {none,[some-arch-os-]}
2019 #   gnu-toolchain -:
2020 #     target_tool_prefix     ${aros_target_cpu}-aros-
2021 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2023 # The output is
2024 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2025 #        Where the 'kernel' binaries are located
2026 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2027 #        Where the 'target' binaries are located
2028 #        (not the symlink farm - that is aros_target_*!)
2030 # The rules are:
2031 #   if crosstools then
2032 #      if kernel_tools_prefix = "no-kernel-prefix-"
2033 #          aros_kernel_* = crosstools cc paths
2034 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2035 #      else
2036 #          VALIDATE(${kernel_tools_prefix}*)
2037 #          aros_kernel_* = ${kernel_tools_prefix}*
2038 #          if ${kernel_tools_prefix}cc is an AROS gcc
2039 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2040 #          else
2041 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2042 #          fi
2043 #      fi
2045 #      orig_target_* = aros built crosstools
2046 #      orig_target_cc = elf cc wrapper around crosstools cc
2047 #   else
2048 #      VALIDATE(${kernel_tools_prefix}*)
2050 #      orig_target_* = aros_kernel_*
2051 #      if aros_kernel_cc is an AROS gcc
2052 #          orig_target_cc = aros_kernel_cc
2053 #      else
2054 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2055 #      fi
2056 #   fi
2058 if test "$aros_toolchain" = "gnu" ; then
2059     target_tool_prefix="${aros_target_cpu}-aros-"
2060 elif test "$aros_toolchain" = "llvm" ; then
2061     target_tool_prefix="bin/"
2064 if test "$kernel_tool_prefix" != "" ; then
2065     AC_MSG_CHECKING([which kernel tools])
2066     AC_MSG_RESULT([$kernel_tool_prefix]);
2069 if test "$kernel_tool_prefix" = "none" ; then
2070     dnl ELF wrapper can be used only for native bootstrap
2071     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2072         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2073     fi
2074 else
2075     # Kernel tools required - find them
2076     # Note that 'normally', aros_kernel_* overrides will be
2077     # empty, unless specified in the per-arch sections above.
2078     if test "x$aros_kernel_cpp" = "x"; then
2079         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2080     fi
2081     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
2082     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2083     if test "x$aros_kernel_cc" = "x"; then
2084         aros_kernel_cc=${kernel_tool_prefix}${CC}
2085     fi
2086     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
2087     AROS_REQUIRED(cc,$aros_kernel_cc)
2088     if test "x$aros_kernel_cxx" = "x"; then
2089         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2090     fi
2091     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
2092     # If it's set, make sure it's really there
2093     if test "x$aros_kernel_cxx" != "x" ; then
2094         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2095     fi
2096     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2097     AROS_REQUIRED(ld,$aros_kernel_ld)
2098     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2099     AROS_REQUIRED(as,$aros_kernel_as)
2100     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2101     AROS_REQUIRED(ar,$aros_kernel_ar)
2102     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2103     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2104     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2105     AROS_REQUIRED(nm,$aros_kernel_nm)
2106     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2107     AROS_REQUIRED(strip,$aros_kernel_strip)
2109     # Objcopy and objdump are not required for the kernel
2110     # toolchain on many architectures.
2111     # So we'll look for them, but not make them strictly required.
2112     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2113     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2114     if test "x${crosstools}" != "xyes" ; then
2115         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2116         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2117     fi
2120 AC_MSG_CHECKING([which target tools to use])
2121 if test "$aros_target_toolchain" = "yes"; then
2122     if test "$aros_toolchain" = "llvm" ; then
2123         msg_result="llvm"
2124     else
2125         msg_result=$target_tool_prefix
2126     fi
2127     AC_MSG_RESULT([$msg_result])
2128     # We are building AROS crosstools
2129     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2130     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2131     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2132     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2133     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2134     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2135     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2136     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2137     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2138     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2139     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2140     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2141 else
2142     # Determine whether AROS or ELF tools should be used
2143     if test "$aros_tool_prefix" = "none"; then
2144         aros_tool_prefix="${elf_tool_prefix}"
2145     fi
2147     AC_MSG_RESULT([$aros_tool_prefix])
2148     # We are *not* building AROS crosstools - use the AROS or ELF tools
2149     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2150     AROS_REQUIRED(cpp,$orig_target_cpp)
2151     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2152     AROS_REQUIRED(cc,$orig_target_cc)
2153     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2154     AROS_REQUIRED(cxx,$orig_target_cxx)
2155     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2156     AROS_REQUIRED(ld,$orig_target_ld)
2157     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2158     AROS_REQUIRED(as,$orig_target_as)
2159     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2160     AROS_REQUIRED(ar,$orig_target_ar)
2161     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2162     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2163     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2164     AROS_REQUIRED(nm,$orig_target_nm)
2165     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2166     AROS_REQUIRED(strip,$orig_target_strip)
2167     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2168     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2169     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2170     AROS_REQUIRED(objdump,$orig_target_objdump)
2173 if test "$kernel_tool_prefix" = "none" ; then
2174     # No kernel tools specified
2175     # Assume target tools == kernel tools with ELF wrapper
2176     aros_kernel_cc=$orig_target_cc
2177     aros_kernel_cxx=$orig_target_cxx
2178     aros_kernel_cpp=$orig_target_cpp
2179     aros_kernel_ld=$orig_target_ld
2180     aros_kernel_as=$orig_target_as
2181     aros_kernel_ar=$orig_target_ar
2182     aros_kernel_ranlib=$orig_target_ranlib
2183     aros_kernel_nm=$orig_target_nm
2184     aros_kernel_strip=$orig_target_strip
2185     aros_kernel_objcopy=$orig_target_objcopy
2186     aros_kernel_objdump=$orig_target_objdump
2187     use_kernel_cc_wrapper=yes
2190 # At this point, all aros_kernel_* and aros_target_* 
2191 # tools should be set up correctly
2193 CC="$aros_kernel_cc $kernel_tool_flags"
2194 CPP="$aros_kernel_cpp"
2196 #-----------------------------------------------------------------------------
2198 # Find all the tools we need to compile. This could be cross-compiling
2199 # though! If that is the case we use the GNU form of the target and
2200 # simply add this to the front of the binary name. This is rather simple,
2201 # but it should work under most circumstances.
2203 # The default tools are to use the same as the host, but only if the
2204 # host and target CPU are the same. With GCC this is normally enough.
2207 aros_cc_pre=""
2208 aros_shared_ld="$aros_host_ld"
2210 aros_target_mkdep="$aros_host_mkdep"
2212 # The default tools executables to be linked to.
2213 if test "$rescomp" != ""; then
2214     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2215     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2218 # Set up the sources for the symlink farm
2219 if test "$crosstools" = "yes"; then
2220     crosstools_target=tools-crosstools
2223 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2224 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2226 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2227 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2228 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2229 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2230 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2231 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2232 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2234 # aros_cc_pre is a variable that is added to the front of the compiler name
2235 # in the generated aros-gcc shell script. We need this to enable the cache
2236 # to work across cleaned builds. Also, support DISTCC using the correct
2237 # environment variable.
2240 if test "x${DISTCC}" != "x" ; then
2241     if test "x${CCACHE}" != "x" ; then
2242         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2243     else
2244         aros_cc_pre="${DISTCC} "
2245     fi
2246 else
2247     if test "x${CCACHE}" != "x" ; then
2248         aros_cc_pre="${CCACHE} "
2249     fi
2252 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2253 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2254 AC_SUBST(aros_target_nix_ldflags,-nix)
2255 AC_SUBST(aros_target_detach_ldflags,-detach)
2256 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2258 # Target tools
2259 AC_SUBST(aros_toolchain)
2260 if test "$aros_target_toolchain" != "yes"; then
2261     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2262     if test "$GCC" = "yes"; then
2263         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2264     fi
2265 else
2266     # We do not know which c compiler version we are going to build and what we need to know
2267     # here is different for different versions so this will be set later during the
2268     # build of crosstools.
2269     if test "$aros_toolchain" = "gnu" ; then
2270         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2271     elif test "$aros_toolchain" = "llvm" ; then
2272         prefix="$AROS_CROSSTOOLSDIR/bin/"
2273     fi
2274     aros_target_cc_path=@aros_target_cc_path@
2276 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2277 aros_target_cc="${prefix}${toolchain_c_compiler}"
2278 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2279 aros_target_as="${prefix}${toolchain_as}"
2280 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_ld}"
2281 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2282 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2283 aros_target_objdump="${prefix}${toolchain_objdump}"
2284 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2285 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2286 aros_target_strip="${prefix}${toolchain_strip}"
2287 aros_plain_nm="${prefix}${toolchain_nm}"
2288 aros_plain_ar="${prefix}${toolchain_ar}"
2290 AC_ARG_ENABLE(includes,
2291 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2292 [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`])
2294 if test "$aros_kernel_includes" = ""; then
2295     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2296         aros_kernel_includes="-isystem $aros_target_incl"
2297     fi
2300 if test "$aros_kernel_includes" != "" ; then
2301     dnl find out about the kernel cc's include path
2302     AC_MSG_CHECKING([for the kernel compiler's include path])
2303     if test "$aros_kernel_cc_includes" = "" ; then
2304         # Try to guess where the directory is.
2305         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2306         if test -d $aros_kernel_cc_includes; then
2307             # Check if there is also an include-fixed directory and add it
2308             # to kernel compiler's include path as it may contain some of
2309             # the headers we need.
2310             if test -d "$aros_kernel_cc_includes"-fixed; then
2311                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2312             fi
2313             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2314             case ${host_cpu} in
2315                 i[[3456]]86)
2316                     host_cpu_glibc=i386
2317                     ;;
2318                 *)
2319                     host_cpu_glibc=${host_cpu}
2320                     ;;
2321             esac
2322             if test -d "/usr/include/${host_cpu_glibc}-linux-gnu"; then
2323                 aros_kernel_cc_includes+=" -isystem /usr/include/${host_cpu_glibc}-linux-gnu"
2324             fi
2325         else
2326             # The directory doesn't exist, we need to do some more work.
2327             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2329             # These are the headers we're looking for.
2330             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2331                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2332                      zutil.h stdint.h"
2334             dirs=
2335             for h in $headers; do
2336                 # Which other headers are needed by each of the above?
2337                 deps=$(echo "#include <$h>" | \
2338                        $aros_kernel_cc -E -M - 2>/dev/null | \
2339                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2341                 # Copy all the needed headers to a directory beneath gendir.
2342                 for d in $deps; do
2343                     h=$(basename $d)
2344                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2345                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2346                     ! test -d $dir && mkdir -p $dir
2347                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2348                 done
2349             done            
2350         fi
2351     fi
2352     AC_MSG_RESULT($aros_kernel_cc_includes)
2353     # Adding -nostdinc to kernel includes as they are always used together.
2354     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2357 if test "$crosstools" != "yes"; then
2358     dnl find out about the target cc's include path
2359     AC_MSG_CHECKING([for the target compiler's include path])
2360     if test "$aros_target_cc_includes" = "" ; then
2361         #try to guess where the directory is
2362         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2363         if ! test -d $aros_target_cc_includes; then
2364             #the directory doesn't exist, we need to do some more work
2365             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2366         
2367             #these are the headers we're looking for
2368             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2369                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2370                     zutil.h"
2372             dirs=
2373             for h in $headers; do
2374                 #which other headers each of the above headers needs?
2375                 deps=$(echo "#include <$h>" | \
2376                     $orig_target_cc -E -M - 2>/dev/null | \
2377                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2378             
2379                 #copy all the needed headers to a directory beneath gendir
2380                 for d in $deps; do
2381                     h=$(basename $d)
2382                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2383                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2384                     ! test -d $dir && mkdir -p $dir
2385                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2386                 done
2387             done
2388         fi
2389     fi
2390     AC_MSG_RESULT($aros_target_cc_includes)
2391 else
2392     # We do not know which c compiler version we are going to build and what we need to know
2393     # here is different for different versions so this will be set later during the
2394     # build of crosstools.
2395     aros_target_cc_includes=@aros_target_cc_includes@
2399 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2400 # On GCC >= 4.0 -iquote should be used
2403 save_cc="$CC"
2404 save_cflags="$CFLAGS"
2405 CFLAGS="-iquote."
2406 kernel_cflags_iquote=$host_cflags_iquote
2407 kernel_cflags_iquote_end=$host_cflags_iquote_end
2408 if test "x-$cross_compiling" = "x-yes"; then
2409     CC="$aros_kernel_cc"
2410     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2411     if test "x-$crosstools" != "x-yes"; then
2412         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2413     else
2414         # we do know it is supported for the smallest version of gcc we are going to build
2415         # we assume it's also supported by later versions
2416         use_no_stack_protector=yes
2417     fi
2418     AC_MSG_RESULT($use_no_stack_protector)
2419     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2420     if test "x-$crosstools" != "x-yes"; then
2421         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2422     else
2423         # we do know it is supported for the smallest version of gcc we are going to build
2424         # we assume it's also supported by later versions
2425         has_iquote=yes
2426     fi
2427     AC_MSG_RESULT($has_iquote)
2428     if test "x-$has_iquote" = "x-yes" ; then
2429         kernel_cflags_iquote=-iquote
2430         kernel_cflags_iquote_end=
2431     else
2432         kernel_cflags_iquote=-I
2433         kernel_cflags_iquote_end=-I-
2434     fi
2436 if test "x-$use_no_stack_protector" = "x-yes" ; then
2437     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2440 #-----------------------------------------------------------------------------
2442 # Check if we can explicitly choose older version of symbol hashing
2444 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2445 CC="$aros_kernel_cc"
2446 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2447 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2448 AC_MSG_RESULT($use_hash_style)
2449 if test "x-$use_hash_style" = "x-yes" ; then
2450     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2452 CC="$save_cc"
2453 CFLAGS="$save_cflags"
2455 AC_SUBST(host_cflags_iquote)
2456 AC_SUBST(host_cflags_iquote_end)
2457 AC_SUBST(kernel_cflags_iquote)
2458 AC_SUBST(kernel_cflags_iquote_end)
2461 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2462 AC_MSG_CHECKING([for default resolution of WBScreen])
2463 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2464 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2465 if test "$resolution" = "yes" ; then
2466     resolution="none"
2468 if test "$resolution" = "no" ; then
2469     resolution="none"
2471 if test "$resolution" != "none" ; then
2472     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2473     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2474     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2476 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2477 aros_cv_nominal_width=$aros_nominal_width
2478 aros_cv_nominal_height=$aros_nominal_height
2479 aros_cv_nominal_depth=$aros_nominal_depth
2481 dnl See if the user wants the serial debug output for native flavour
2482 AC_MSG_CHECKING([whether serial debug is enabled])
2483 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)
2484 if test "$aros_serial_debug" = 0 ; then
2485     serial_debug_forced=""
2486     if test "$serial_debug" = "yes" ; then
2487         serial_debug="1"
2488     fi
2489     if test "$serial_debug" = "no" ; then
2490         serial_debug="none"
2491     fi
2492 else
2493     serial_debug_forced="(forced)"
2494     serial_debug=$aros_serial_debug
2496 if test "$serial_debug" != "none" ; then
2497     aros_serial_debug=$serial_debug
2498     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2499 else
2500     AC_MSG_RESULT(no)
2503 dnl See if the user wants the palm debug output hack for palm native flavour
2504 AC_MSG_CHECKING([whether palm debug hack is enabled])
2505 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")
2506 if test "$palm_debug_hack" = "yes" ; then
2507     aros_palm_debug_hack="1"
2509 AC_MSG_RESULT($palm_debug_hack)
2511 dnl See if dev wants the usb3.0 code
2512 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2513 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2514 if test "$usb30_code" = "yes" ; then
2515     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2516     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2518 AC_MSG_RESULT($usb30_code)
2520 dnl See if the user wants nesting supervisor activated for unix flavour
2521 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2522 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")
2523 if test "$nesting_supervisor" = "yes" ; then
2524     aros_nesting_supervisor="1"
2526 AC_MSG_RESULT($nesting_supervisor)
2528 dnl See if the user wants to disable MMU support
2529 dnl This can be overriden on per-target basis,
2530 dnl set $aros_enable_mmu to "yes" or "no" to do this
2531 if test "$aros_enable_mmu" = "" ; then
2532     AC_MSG_CHECKING([whether MMU support is enabled])
2533     dnl Enabled by default
2534     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2535     if test "$aros_enable_mmu" = "" ; then
2536         aros_enable_mmu="yes"
2537     fi
2538     AC_MSG_RESULT($aros_enable_mmu)
2540 if test "$aros_enable_mmu" = "no" ; then
2541     aros_enable_mmu="0"
2542 else
2543     aros_enable_mmu="1"
2545     
2547 dnl things specifically required for hosted flavours
2548 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2550     if test "x-$need_dlopen" != "x-no" ; then
2551       save_libs="$LIBS"
2552       LIBS=""
2553       dnl some kind of dynamic library access system is required for hostlib.resource
2554       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2555       if test "x-$have_dl" = "x-no" ; then
2556           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2557                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2558                                     have_dl="no")
2559       fi
2560       if test "x-$have_dl" = "x-no" ; then
2561           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2562       fi
2563       LIBS="$save_libs"
2564     fi
2567     dnl x11 hidd
2568     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2569                                            [build X11 hidd for hosted (default=auto)]),
2570                                            x11_hidd="$enableval",
2571                                            x11_hidd="$need_x11")
2572     case "x-$x11_hidd" in
2573         x-yes|x-no|x-auto)                 ;;
2574         *)                 x11_hidd="$need_x11" ;;
2575     esac
2577     ENABLE_X11=0
2579     dnl they want it
2580     if test "x-$x11_hidd" != "x-no" ; then
2582         dnl find x11 stuff
2583         AC_PATH_X
2584         AC_PATH_XTRA
2586         if test "x-$no_x" = "x-yes" ; then
2588             dnl didn't find it
2589             if test "x-$x11_hidd" != "x-auto" ; then
2590                 dnl and they explicitly asked for it, bail out
2591                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2592             fi
2593         
2594         else
2595             dnl found it, setup the metatarget
2596             host_x_gfx=yes
2597             ENABLE_X11=1
2599             aros_host_x11_cflags="$X_CFLAGS"
2600             aros_host_x11_ldflags="$X_LIBS  -lX11"
2602             dnl setup shared memory extensions
2603             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2604                                                   [use X11 shared memory (default=auto)]),
2605                                                   x11_hidd_shm="$enableval",
2606                                                   x11_hidd_shm="auto")
2607             case "x-$x11_hidd_shm" in
2608                 x-yes|x-no|x-auto)                     ;;
2609                 *)                 x11_hidd_shm="auto" ;;
2610             esac
2612             have_xshm=no
2614             dnl they want it
2615             if test "x-$x11_hidd_shm" != "x-no" ; then
2617                 dnl system shm headers
2618                 AC_CHECK_HEADERS(sys/ipc.h)
2619                 AC_CHECK_HEADERS(sys/shm.h)
2621                 dnl got them
2622                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2624                     dnl make sure X libs have shm functions
2625                     save_cflags="$CFLAGS"
2626                     save_ldflags="$LDFLAGS"
2627                     CFLAGS="$CFLAGS $X_CFLAGS"
2628                     LDFLAGS="$LDFLAGS $X_LIBS"
2629                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2630                     CFLAGS="$save_cflags"
2631                     LDFLAGS="$save_ldflags"
2632                 fi
2633             fi
2635             dnl detection done, prepare output
2636             if test "x-$have_xshm" = "x-yes" ; then
2637                 dnl we can do shm
2638                 DO_XSHM_SUPPORT="1"
2639             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2640                 dnl they explicitly asked for it, but we can't do it
2641                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2642             else
2643                 dnl otherwise just disable it
2644                 DO_XSHM_SUPPORT="0"
2645             fi
2647             
2648             dnl setup vidmode (fullscreen) extensions
2649             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2650                                                       [use X11 vidmode extension (default=auto)]),
2651                                                       x11_hidd_vidmode="$enableval",
2652                                                       x11_hidd_vidmode="auto")
2653             case "x-$x11_hidd_vidmode" in
2654                 x-yes|x-no|x-auto)                         ;;
2655                 *)                 x11_hidd_vidmode="auto" ;;
2656             esac
2658             have_vidmode=no
2660             dnl they want it
2661             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2663                 dnl make sure X libs have vidmode functions
2664                 save_cflags="$CFLAGS"
2665                 save_ldflags="$LDFLAGS"
2666                 CFLAGS="$CFLAGS $X_CFLAGS"
2667                 LDFLAGS="$LDFLAGS $X_LIBS"
2668                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2669                 CFLAGS="$save_cflags"
2670                 LDFLAGS="$save_ldflags"
2671             fi
2673             dnl detection done, prepare output
2674             if test "x-$have_vidmode" = "x-yes" ; then
2675                 dnl we can do vidmode
2676                 DO_VIDMODE_SUPPORT="1"
2677             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2678                 dnl they explicitly asked for it, but we can't do it
2679                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2680             else
2681                 dnl otherwise just disable it
2682                 DO_VIDMODE_SUPPORT="0"
2683             fi
2684         fi
2685     fi
2687     dnl sdl hidd
2688     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2689                                            [build SDL hidd for hosted (default=auto)]),
2690                                            sdl_hidd="$enableval",
2691                                            sdl_hidd="auto")
2692     case "x-$sdl_hidd" in
2693         x-yes|x-no|x-auto)                 ;;
2694         *)                 sdl_hidd="auto" ;;
2695     esac
2697     dnl they want it
2698     if test "x-$sdl_hidd" != "x-no" ; then
2700         dnl find sdl
2701         SDL_VERSION=1.2.5
2702         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2703             [have_sdl="no"])
2705         if test "x-$have_sdl" != "x-yes" ; then
2707             dnl didn't find it
2708             if test "x-$sdl_hidd" != "x-auto" ; then
2709                 dnl and they explicitly asked for it, bail out
2710                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2711             fi
2713         else
2714             dnl found it, enable the build
2715             host_sdl_gfx=yes
2716             aros_host_sdl_cflags=$SDL_CFLAGS
2717             aros_host_sdl_libs=$SDL_LIBS
2718         fi
2719     fi
2724 dnl See if the user wants dbus.library
2725 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2726 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2727 if test "$dbus" = "yes" ; then
2728     ENABLE_DBUS=1
2729     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2730     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2731     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2732     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2733 else
2734     ENABLE_DBUS=0
2736 AC_MSG_RESULT($dbus)
2738 if test "$use_kernel_cc_wrapper" = "yes" ; then
2739     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2742 dnl --------------------------------------------------------------------
2743 dnl Configuration Output Section
2744 dnl --------------------------------------------------------------------
2746 # Generic
2747 AC_SUBST(aros_arch)
2748 AC_SUBST(aros_cpu)
2749 AC_SUBST(aros_flavour)
2750 AC_SUBST(aros_flavour_uc)
2751 AC_SUBST(aros_target_toolchain)
2752 AC_SUBST(aros_build_host)
2753 AC_SUBST(AROS_BUILDDIR)
2754 AC_SUBST(AROS_BUILDDIR_UNIX)
2755 AC_SUBST(SRCDIR)
2756 AC_SUBST(AROS_CROSSTOOLSDIR)
2757 AC_SUBST(AROS_PORTSSRCDIR)
2759 # Compatability with other Amiga-like operation systems
2760 AC_SUBST(aros_amigaos_compliance)
2762 # Host related
2763 AC_SUBST(aros_cc_pre)
2764 AC_SUBST(aros_host_strip)
2765 AC_SUBST(aros_host_arch)
2766 AC_SUBST(aros_host_cpu)
2767 AC_SUBST(aros_host_cpp)
2768 AC_SUBST(aros_host_def_cc)
2769 AC_SUBST(aros_host_cc)
2770 AC_SUBST(aros_host_cxx)
2771 AC_SUBST(aros_host_ar)
2772 AC_SUBST(aros_host_ranlib)
2773 AC_SUBST(aros_host_ld)
2774 AC_SUBST(aros_host_make)
2775 AC_SUBST(aros_host_cflags)
2776 AC_SUBST(aros_host_cxxflags)
2777 AC_SUBST(gnu89_inline)
2778 AC_SUBST(aros_host_ldflags)
2779 AC_SUBST(aros_host_debug)
2780 AC_SUBST(aros_host_mkdep)
2781 AC_SUBST(aros_host_mkargs)
2782 AC_SUBST(aros_host_exe_suffix)
2783 AC_SUBST(aros_host_lib_suffix)
2784 AC_SUBST(aros_tools_dir)
2785 AC_SUBST(aros_host_aclocal)
2786 AC_SUBST(aros_host_autoconf)
2787 AC_SUBST(aros_host_autoheader)
2788 AC_SUBST(aros_host_automake)
2789 AC_SUBST(ant)
2791 # Target Related
2792 AC_SUBST(aros_target_guitheme)
2793 AC_SUBST(aros_target_iconset)
2794 AC_SUBST(aros_target_bootloader)
2795 AC_SUBST(aros_target_arch)
2796 AC_SUBST(aros_target_family)
2797 AC_SUBST(aros_target_cpu)
2798 AC_SUBST(aros_target_cpu_mode)
2799 AC_SUBST(aros_target_variant)
2800 AC_SUBST(aros_target_suffix)
2801 AC_SUBST(aros_target_ar)
2802 AC_SUBST(aros_target_ranlib)
2803 AC_SUBST(aros_plain_nm)
2804 AC_SUBST(aros_plain_ar)
2805 AC_SUBST(aros_kernel_ar)
2806 AC_SUBST(aros_kernel_ranlib)
2807 AC_SUBST(orig_target_cc)
2808 AC_SUBST(aros_target_cc)
2809 AC_SUBST(aros_kernel_cc)
2810 AC_SUBST(orig_target_cxx)
2811 AC_SUBST(aros_target_cxx)
2812 AC_SUBST(aros_kernel_cxx)
2813 AC_SUBST(orig_target_cpp)
2814 AC_SUBST(aros_target_cpp)
2815 AC_SUBST(aros_kernel_cpp)
2816 AC_SUBST(orig_target_as)
2817 AC_SUBST(aros_target_as)
2818 AC_SUBST(aros_kernel_as)
2819 AC_SUBST(orig_target_ld)
2820 AC_SUBST(aros_target_ld)
2821 AC_SUBST(aros_kernel_ld)
2822 AC_SUBST(aros_target_cc_includes)
2823 AC_SUBST(aros_target_cc_path)
2824 AC_SUBST(aros_target_objdump)
2825 AC_SUBST(aros_target_objcopy)
2826 AC_SUBST(aros_target_strip)
2827 AC_SUBST(aros_target_nm)
2828 AC_SUBST(aros_kernel_rescomp)
2829 AC_SUBST(aros_shared_default)
2830 AC_SUBST(aros_shared_ld)
2831 AC_SUBST(aros_object_format)
2832 AC_SUBST(spec_obj_format)
2833 AC_SUBST(aros_compiler_libs)
2834 AC_SUBST(aros_arch_libs)
2836 AC_SUBST(aros_shared_cflags)
2837 AC_SUBST(aros_shared_aflags)
2838 AC_SUBST(aros_shared_ldflags)
2840 AC_SUBST(aros_config_sysroot)
2841 AC_SUBST(aros_nowarn_flags)
2842 AC_SUBST(aros_config_cflags)
2843 AC_SUBST(aros_config_aflags)
2844 AC_SUBST(aros_config_ldflags)
2846 AC_SUBST(aros_kernel_sysroot)
2847 AC_SUBST(aros_kernel_cflags)
2848 AC_SUBST(aros_kernel_includes)
2849 AC_SUBST(aros_kernel_objcflags)
2850 AC_SUBST(aros_kernel_ldflags)
2851 AC_SUBST(aros_target_cflags)
2852 AC_SUBST(aros_debug_cflags)
2853 AC_SUBST(aros_debug_aflags)
2854 AC_SUBST(aros_debug_ldflags)
2855 AC_SUBST(aros_target_genmap)
2856 AC_SUBST(aros_target_strip_flags)
2857 AC_SUBST(aros_optimization_cflags)
2858 AC_SUBST(aros_isa_flags)
2860 AC_SUBST(crosstools_target)
2861 AC_SUBST(crosstools_cxx_target)
2863 # Hosted Graphics Related
2864 AC_SUBST(host_x_gfx)
2865 AC_SUBST(host_sdl_gfx)
2866 AC_SUBST(host_android_gfx)
2868 AC_SUBST(pci_hidd_target)
2870 AC_SUBST(aros_nominal_width)
2871 AC_SUBST(aros_nominal_height)
2872 AC_SUBST(aros_nominal_depth)
2873 AC_SUBST(DO_XSHM_SUPPORT)
2874 AC_SUBST(DO_VIDMODE_SUPPORT)
2876 AC_SUBST(aros_host_x11_cflags)
2877 AC_SUBST(aros_host_x11_ldflags)
2878 AC_SUBST(aros_host_sdl_cflags)
2879 AC_SUBST(aros_host_sdl_libs)
2881 # Native version related
2882 AC_SUBST(aros_serial_debug)
2883 AC_SUBST(ENABLE_EXECSMP)
2885 # Palm native version related
2886 AC_SUBST(aros_palm_debug_hack)
2888 # Unix/Hosted version related
2889 AC_SUBST(aros_nesting_supervisor)
2891 # MMU related
2892 AC_SUBST(aros_enable_mmu)
2894 # Apple iOS related
2895 AC_SUBST(aros_ios_platform)
2896 AC_SUBST(aros_ios_version)
2897 AC_SUBST(aros_ios_sdk)
2899 # ARM default GCC target related
2900 AC_SUBST(gcc_default_cpu)
2901 AC_SUBST(gcc_default_cpu_tune)
2902 AC_SUBST(gcc_default_fpu)
2903 AC_SUBST(gcc_default_float_abi)
2904 AC_SUBST(gcc_default_mode)
2906 # Android related
2907 AC_SUBST(android_tool)
2908 AC_SUBST(aros_android_level)
2909 AC_SUBST(aros_android_antapk)
2911 # DBUS related
2912 AC_SUBST(ENABLE_DBUS)
2913 AC_SUBST(DBUS_CFLAGS)
2914 AC_SUBST(DBUS_LIBFLAGS)
2915 AC_SUBST(KERNEL_DBUS_KOBJ)
2916 AC_SUBST(KERNEL_DBUS_INCLUDES)
2918 #X11 related
2919 AC_SUBST(ENABLE_X11)
2921 # Debug related
2922 AC_SUBST(aros_debug)
2923 AC_SUBST(aros_mungwall_debug)
2924 AC_SUBST(aros_stack_debug)
2925 AC_SUBST(aros_modules_debug)
2927 # Collect-aros stuff: "-ius" to ignore undefined symbols
2928 AC_SUBST(ignore_undefined_symbols)
2930 # C compiler related
2931 AC_SUBST(gcc_target_cpu)
2932 AC_SUBST(target_binutils_version)
2933 AC_SUBST(target_gcc_version)
2935 #ObjC compiler related
2936 AC_SUBST(objc_target)
2938 #Java related
2939 AC_SUBST(java_target)
2941 # USB3.0 code
2942 AC_SUBST(aros_usb30_code)
2944 dnl Prepare for output, make up all the generated patches
2945 case "$aros_flavour" in
2946 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2947                 aros_flavour="emulation" ;;
2948 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2949                 aros_flavour="emulation" ;;
2950 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2951                 aros_flavour="standalone";;
2952 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2953                 aros_flavour="standalone";;
2954 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2955                 aros_flavour="native" ;;
2956 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2957                 aros_flavour="native" ;;
2958 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2959                 aros_flavour="linklib" ;;
2960 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2961                 aros_flavour="palmnative" ;;
2962 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2963                 aros_flavour="mac68knative" ;;
2964 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2965                 aros_flavour="ppcnative" ;;
2966 esac
2968 if test ! -d ${aros_inc_dir} ; then
2969     ${MKDIR} ${aros_inc_dir}
2971 if test ! -d ${aros_geninc_dir} ; then
2972     ${MKDIR} ${aros_geninc_dir}
2974 if test ! -d ${aros_hostcfg_dir} ; then
2975     ${MKDIR} ${aros_hostcfg_dir}
2977 if test ! -d ${aros_targetcfg_dir} ; then
2978     ${MKDIR} ${aros_targetcfg_dir}
2980 if test ! -d ${aros_tools_dir} ; then
2981     ${MKDIR} ${aros_tools_dir}
2983 if test ! -d ${aros_scripts_dir} ; then
2984     ${MKDIR} ${aros_scripts_dir}
2987 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2989 # Generic build tools (metamake, etc)
2990 AC_CONFIG_COMMANDS([genmf-executable-support],
2991     [chmod a+x ${aros_tools_dir}/genmf.py],
2992     [aros_tools_dir=${aros_tools_dir}]
2994 AC_CONFIG_FILES(
2995     Makefile
2996     config/make.cfg
2997     ${aros_inc_dir}/config.h:config/config.h.in
2998     ${aros_geninc_dir}/config.h:config/config.h.in
2999     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3000     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3001     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3002     mmake.config
3003     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3004     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3005     tools/collect-aros/env.h
3008 # Binutils
3009 AC_CONFIG_COMMANDS([binutils-support],
3010     [
3011         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3012         mkdir -p $prefix
3013         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3015         chmod a+x ${prefix2}-ld
3017         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3018         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3019         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3020         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3021         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3022         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3023         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3024     ],
3025     [
3026         aros_host_exe_suffix=${aros_host_exe_suffix}
3027         aros_tools_dir=${aros_tools_dir}
3028         aros_target_cpu=${aros_target_cpu}
3029         aros_target_arch=${aros_target_arch}
3030         aros_target_suffix=${aros_target_suffix}
3031         orig_target_nm=${orig_target_nm}
3032         orig_target_as=${orig_target_as}
3033         orig_target_ar=${orig_target_ar}
3034         orig_target_ranlib=${orig_target_ranlib}
3035         orig_target_objdump=${orig_target_objdump}
3036         orig_target_objcopy=${orig_target_objcopy}
3037         orig_target_strip=${orig_target_strip}
3038         aros_kernel_ld=${aros_kernel_ld}
3039     ]
3041 AC_CONFIG_FILES(
3042     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
3045 # Bare Elf support script and spec
3046 if test "${use_kernel_cc_wrapper}" = "yes"; then
3047     AC_CONFIG_COMMANDS([elf-compiler-support],
3048         [
3049             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3050             mkdir -p $prefix
3051             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3053             chmod a+x ${prefix2}-gcc
3055             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3056         ],
3057         [
3058             aros_host_exe_suffix=${aros_host_exe_suffix}
3059             aros_tools_dir=${aros_tools_dir}
3060             aros_target_cpu=${aros_target_cpu}
3061             aros_target_arch=${aros_target_arch}
3062             aros_target_suffix=${aros_target_suffix}
3063             aros_kernel_ld=${aros_kernel_ld}
3064         ]
3065     )
3066     AC_CONFIG_FILES(
3067         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3068         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3069     )
3072 # Host compiler support scripts and spec
3073 if test "${aros_target_toolchain}" = "no"; then
3074     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3075         [
3076             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3077             mkdir -p $prefix
3078             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3080             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3081         ],
3082         [
3083             aros_host_exe_suffix=${aros_host_exe_suffix}
3084             aros_tools_dir=${aros_tools_dir}
3085             aros_target_cpu=${aros_target_cpu}
3086             aros_target_arch=${aros_target_arch}
3087             aros_target_suffix=${aros_target_suffix}
3088         ]
3089     )
3090     AC_CONFIG_FILES(
3091         ${aros_targetcfg_dir}/specs:config/specs.in
3092         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3093         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3094         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3095     )
3098 # Android support
3099 if test "$aros_target_variant" == "android"; then
3100     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3103 # cmake helper
3104 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3106 AC_OUTPUT
3108 dnl This is in order to not define SHARED_CFLAGS sometimes
3109 dnl We don't always do aros_shared_ar, aros_shared_cflags
3111 #XXX compatability...
3112 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3114 if test -n "$aros_shared_cflags" ; then
3115     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3116     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg