make sure the linker is only set as necessary (and so it doesn't try to replace a...
[AROS.git] / configure.in
bloba066b539839d3e4f015cbeaf8b5e60000f3cab84
1 dnl Copyright © 1997-2014, 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 # The AROS target is slightly different to the normal GNU style
26 # format. We don't have the middle part, and we reverse the order
27 # of the $(CPU) and $(OS) bits.
29 # Don't strip the version of the target yet, it might be
30 # useful on some systems.
32 AC_MSG_CHECKING([for AROS style target])
34 if test "$target" = "NONE" ; then
35     target=$host_os-$host_cpu
36 else
37     if test "$target" = "" ; then
38         target=$host_os-$host_cpu
39     fi
41 AC_MSG_RESULT($target)
43 if test "$host_os" = "mingw32" ; then
44     PWDCMD="pwd -W"
47 # Don't know where else to put this...
48 AC_MSG_CHECKING([building AROS in])
49 AROS_BUILDDIR=`${PWDCMD-pwd}`
50 AROS_BUILDDIR_UNIX=${PWD}
51 AC_MSG_RESULT($AROS_BUILDDIR)
53 AC_MSG_CHECKING([AROS source in])
54 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
55 SRCDIR=${srcpwd}
56 AC_MSG_RESULT($SRCDIR)
58 # Parse the target field into something useful.
59 changequote(<<,>>)
60 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
61 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
62 changequote([,])
64 # Some debug output, to be removed again.
65 AC_MSG_CHECKING([for target system (debug output)])
66 AC_MSG_RESULT($target_os)
67 AC_MSG_CHECKING([for target cpu (debug output)])
68 AC_MSG_RESULT($target_cpu)
70 dnl --------------------------------------------------------------------
71 dnl Set the default Workbench resolution
72 dnl --------------------------------------------------------------------
73 aros_default_wbwidth=800
74 aros_default_wbheight=600
75 aros_default_wbdepth=4
77 dnl --------------------------------------------------------------------
78 dnl Host Configuration Section
79 dnl --------------------------------------------------------------------
80 dnl
81 dnl The idea here is to find out all the information we need about the
82 dnl host. This means things like tools for building directory structures,
83 dnl copying files around and the like.
85 # The first step is to find the host binaries.
86 # Check for a compiler.
87 # Due to a bug in autoconf check for c++ compiler first.
88 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
89 AC_PROG_CXX
90 AC_PROG_CC
91 AC_PROG_CC_STDC
92 AC_PROG_CPP
94 # Check for a compatible awk
95 AC_CHECK_PROGS(AWK,[gawk nawk])
96 AROS_REQUIRED(gawk,$AWK)
97 AROS_PROG(MMAKE,mmake)
99 # Perform some default variable assignments. Note all of these will be
100 # Regenerated from the script, so there is no need to cache them.
102 aros_host_cpp="$CPP"
103 aros_host_cc="$CC"
104 aros_host_cxx="$CXX"
105 AROS_TOOL_CCPATH(aros_host_ld,ld)
106 AROS_REQUIRED(ld,$aros_host_ld)
107 aros_host_make="make"
108 aros_host_cflags="$CFLAGS"
109 aros_host_cxxflags="$CXXFLAGS"
110 aros_host_ldflags="$LDFLAGS"
111 aros_host_debug="-g -O0"
112 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
113 aros_host_mkargs="--no-print-directory"
114 aros_host_exe_suffix="$EXEEXT"
115 aros_host_lib_suffix=""
117 # Ignore all compliance, AROS ROMs = 0
118 # KickStart v1.0 = 30
119 # KickStart v1.3 = 34
120 # KickStart v2.0 = 37
121 # KickStart v3.0 = 39
122 # KickStart v3.1 = 40
123 # AmigaOS   v3.5 = 44
124 aros_amigaos_compliance=0
126 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
127 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
128 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
129 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
131 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
132 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
134 case "$aros_host_cc" in
135     *clang*)
136         aros_host_cc_pipe=""
137         ;;
138     *gcc*)
139         aros_host_cc_pipe="-pipe"
140         ;;
141     icc)
142         aros_host_cc_pipe=""
143         ;;
144     *)
145         aros_host_cc_pipe=""
146         ;;
147 esac
149 aros_kernel_cc_includes=""
150 aros_target_cc_includes=""
151 host_cc_elf=yes
153 # ----------------------------------------------------------------------------------------
154 # Host-specific defaults
156 # This is the main host configuration section. It is where the host
157 # can change the values of any variables it needs to change. We do
158 # not look at anything that compiles to the target yet, we'll get
159 # to that later.
161 case "$host_os" in
162     aros*)
163         aros_host_arch="aros"
164         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
165         case "$host_cpu" in
166             *i?86*)
167                 aros_host_cpu="i386"
168                 ;;
169             *x86_64*)
170                 aros_host_cpu="x86_64"
171                 ;;
172             *powerpc*)
173                 aros_host_cpu="ppc"
174                 ;;
175             *)
176                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
177                 aros_host_cpu="$host_cpu"
178                 ;;
179         esac
180         ;;
182     linux*)
183         aros_host_arch="linux"
184         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
185         android_build_os="linux-x86"
186         android_tool="android"
187         default_android_sdk="/opt/android-sdk-linux_x86"
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             *m68k*)
196                 aros_host_cpu="m68k"
197                 ;;
198             *powerpc*)
199                 aros_host_cpu="ppc"
200                 ;;
201             *arm*)
202                 aros_host_cpu="arm"
203                 ;;
204             *)
205                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
206                 aros_host_cpu="$host_cpu"
207                 ;;
208         esac
209         ;;
211     freebsd*)
212         aros_host_cc="$aros_host_cc $aros_host_cc_pipe -I/usr/local/include"
213         aros_host_make="gmake"
214         aros_host_arch="freebsd"
215         aros_host_cpu="i386"
217         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
219         dnl FreeBSD 5.x (and later) has changed the default object format.
220         dnl The double [[]] is necessary to get around m4's quoting rules.
221         case $host_os in
222             freebsd[[234]]*)
223                 aros_object_format="elf_i386"
224                 ;;
226             *)
227                 aros_object_format="elf_i386_fbsd"
228                 ;;
229         esac
231         ;;
233     darwin*)
234         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
235         aros_host_arch="darwin"
236         host_cc_elf=no
237         SED="gsed"
238         android_build_os="darwin-x86"
239         android_tool="android"
240         default_android_sdk="/android-sdk-mac_x86"
241         case "$host_cpu" in
242             *i?86*)
243                 aros_host_cpu="i386"
244                 ;;
245             *x86_64*)
246                 aros_host_cpu="x86_64"
247                 ;;
248             *powerpc*)
249                 aros_host_cpu="ppc"
250                 ;;
251             *)
252                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
253                 aros_host_cpu="$host_cpu"
254                 ;;
255         esac
257         aros_host_ldflags="$aros_host_ldflags -liconv"
259         ;;
261     dragonfly*)
262         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
263         aros_host_make="gmake"
264         aros_host_arch="dragonfly"
265         case $host_cpu in
266             *i?86*)
267                 aros_host_cpu="i386"
268                 ;;
269             *amd64*)
270                 aros_host_cpu="x86_64"
271                 ;;
272             *)
273                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
274                 aros_host_cpu="$host_cpu"
275                 ;;
276         esac
277         ;;
279     netbsd*)
280         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
281         aros_host_make="gmake"
282         aros_host_arch="netbsd"
283         case "$host_cpu" in
284             *i?86*)
285                 aros_host_cpu="i386"
286                 ;;
287             *m68k*)
288                 aros_host_cpu="m68k"
289                 ;;
290             *)
291                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
292                 aros_host_cpu="$host_cpu"
293                 ;;
294         esac    
295         aros_host_lib_suffix=".0.0"
296         ;;
298     openbsd*)
299         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
300         aros_host_make="gmake"
301         aros_host_arch="openbsd"
302         case "$host_cpu" in
303             *i?86*)
304                 aros_host_cpu="i386"
305                 ;;
306             *)
307                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
308                 aros_host_cpu="$host_cpu"
309                 ;;
310         esac
311         ;;
312         
313     solaris*)
314         aros_host_arch="solaris"
315         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
316         case "$host_cpu" in
317             *i?86*)
318                 aros_host_cpu="i386"
319                 ;;
320             *sparc*)
321                 aros_host_cpu="sparc"
322                 ;;
323             *)
324                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
325                 aros_host_cpu="$host_cpu"
326                 ;;
327         esac
328         ;;
330     morphos*)
331         aros_host_arch="morphos"
332         aros_host_cpu="ppc"
333         host_cc_elf=no
334         ;;
336     amiga*)
337         aros_host_arch="amiga"
338         host_cc_elf=no
339         SORT="/gg/bin/sort"
340         TEST="/gg/bin/test"
341         UNIQ="/gg/bin/uniq"
342         FOR="for"
343         TOUCH="/gg/bin/touch"
344         case "$host_cpu" in
345             *m68k*)
346                 aros_host_cpu="m68k"
347                 ;;
348             *powerpc*)
349                 aros_host_cpu="ppc"
350                 ;;
351             *)
352                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
353                 aros_host_cpu="$host_cpu"
354                 ;;
355         esac
356         ;;
358     cygwin*)
359         aros_host_arch="cygwin"
360         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
361         host_cc_elf=no
362         android_build_os="windows"
363         android_tool="android.bat"
364         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
366         case "$host_cpu" in
367             *i?86*)
368                 aros_host_cpu="i386"
369                 ;;
370             *)
371                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
372                 aros_host_cpu="$host_cpu"
373                 ;;
374         esac
375         ;;
377     mingw32*)
378         aros_host_arch="mingw32"
379         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
380         host_cc_elf=no
381         android_build_os="windows"
382         android_tool="android.bat"
383         default_android_sdk="/c/android-sdk-windows-1.6_r1"
385         case "$host_cpu" in
386         *i?86*)
387             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
388             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
389             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
390             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
392             AC_MSG_CHECKING([for Windows native gcc target])
393             host_cpu=`gcc -dumpmachine`
394             AC_MSG_RESULT($host_cpu)
395             ;;
397         esac
399         case "$host_cpu" in
400         *i?86*)
401             aros_host_cpu="i386"
402             ;;
404         mingw32*)
405             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
406             aros_host_cpu="i386"
407             ;;
409         *x86_64*)
410             aros_host_cpu="x86_64"
411             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
412             dnl directory, so we have to add it explicitly here.
413             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
414             ;;
416         *)
417             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
418             aros_host_cpu="$host_cpu"
419             ;;
420         esac
421         ;;
422     *)
423         AC_MSG_ERROR([Unsupported host architecture $host])
424         ;;
425 esac
427 AROS_PROG(aros_host_ar,[ar],[cr])
428 AROS_REQUIRED(ar,$aros_host_ar)
429 AROS_PROG(aros_host_ranlib,ranlib)
430 AROS_REQUIRED(ranlib,$aros_host_ranlib)
431 AROS_PROG(aros_host_strip,strip)
432 AROS_REQUIRED(strip,$aros_host_strip)
434 AROS_PROG(RM,[rm],[-rf])
435 AROS_REQUIRED(rm,$RM)
436 AROS_PROG(CP,[cp])
437 AROS_REQUIRED(cp,$CP)
438 AROS_PROG(MV,[mv])
439 AROS_REQUIRED(mv,$MV)
440 AROS_PROG(ECHO,[echo])
441 AROS_REQUIRED(echo,$ECHO)
442 AROS_PROG(MKDIR,[mkdir],[-p])
443 AROS_REQUIRED(mkdir,$MKDIR)
444 AROS_PROG(TOUCH,[touch])
445 AROS_REQUIRED(touch,$TOUCH)
446 AROS_PROG(SORT,[sort])
447 AROS_REQUIRED(sort,$SORT)
448 AROS_PROG(UNIQ,[uniq])
449 AROS_REQUIRED(uniq,$UNIQ)
450 AROS_PROG(NOP,[true])
451 AROS_REQUIRED(true,$NOP)
452 AROS_PROG(CAT,[cat])
453 AROS_REQUIRED(cat,$CAT)
454 AROS_PROG(BISON,[bison])
455 AROS_REQUIRED(bison,$BISON)
456 AROS_PROG(FLEX,[flex])
457 AROS_REQUIRED(flex,$FLEX)
458 AROS_PROG(PNGTOPNM,[pngtopnm])
459 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
460 AROS_PROG(PPMTOILBM,[ppmtoilbm])
461 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
462 AROS_PROG(SED,[sed])
463 AROS_REQUIRED(sed,$SED)
464 AROS_PROG(CHMOD,[chmod])
465 AROS_REQUIRED(chmod,$CHMOD)
466 AROS_PROG(PATCH,[patch])
467 AROS_REQUIRED(patch,$PATCH)
469 AM_PATH_PYTHON(2.5)
471 AC_CHECK_LIB(png, png_read_png)
472 AROS_REQUIRED(libpng, $ac_cv_lib_png_png_read_png)
474 AC_SUBST(FOR, for)
475 AC_SUBST(IF, if)
476 AC_SUBST(TEST, test)
477 AC_SUBST(CMP, cmp)
479 dnl ---------------------------------------------------------------------------
480 dnl Look for things about the host system, good for hosted targets.
481 dnl ---------------------------------------------------------------------------
483 # Check for some includes for the X11 HIDD and the kernel
484 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
485     sys/mmap.h sys/mman.h sysexits.h \
486     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
489 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
491 AC_HEADER_DIRENT
492 AC_HEADER_STAT
493 AC_HEADER_STDC
494 AC_HEADER_SYS_WAIT
495 AC_HEADER_TIME
496 AC_STRUCT_ST_BLKSIZE
497 AC_STRUCT_ST_BLOCKS
498 AC_STRUCT_ST_RDEV
499 AC_STRUCT_TM
500 AC_STRUCT_TIMEZONE
501 AC_TYPE_OFF_T
502 AC_TYPE_PID_T
503 AC_TYPE_SIZE_T
504 AC_TYPE_UID_T
506 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
508 # Look for some functions
509 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
510     clone kse_create rfork_thread thr_create sa_register \
511     getcontext makecontext setcontext sigaltstack swapcontext])
513 AC_FUNC_MMAP
516 dnl --------------------------------------------------------------------
517 dnl Target Configuration Section
518 dnl --------------------------------------------------------------------
520 dnl The target configuration section is responsible for setting up all
521 dnl the paths for includes, and tools required to build AROS to some
522 dnl particular target.
524 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
525 aros_config_aflags="-Wall -x assembler-with-cpp -c"
526 aros_config_ldflags=""
528 aros_shared_default=yes
530 aros_shared_cflags="-fPIC"
531 aros_shared_aflags=""
532 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
533 aros_kernel_ldflags="-Wl,-rpath,./lib"
535 aros_kernel_ar_flags="cr"
536 aros_target_ar_flags="cr"
537 aros_target_nm_flags="-C -ul"
538 aros_target_strip_flags="--strip-unneeded -R.comment"
540 aros_compiler_libs=
541 aros_arch_libs=
543 aros_target_genmap="-Wl,-Map -Xlinker"
545 # Native flavour stuff
546 aros_serial_debug="0"
548 # Palm native flavour stuff
549 aros_palm_debug_hack="0"
551 # Unix flavour stuff
552 aros_nesting_supervisor="0"
554 # Collect-aros stuff: "-ius" to ignore undefined symbols
555 ignore_undefined_symbols=""
557 # Check for X11 by default
558 need_x11="auto"
560 #-----------------------------------------------------------------------------
563 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
564 # it switched on by default, and we use the host compiler, so it compiles AROS
565 # code with this enabled resulting in link failures as we don't have support
566 # for it.
568 # We use two methods to disable it. For the host compiler (used to compile
569 # some hosted modules), we test to see if the compiler supports stack
570 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
571 # work on all platforms.
573 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
574 # (this is done unconditionally, as it should have no effect on compilers
575 # without the stack protection feature). This may be specific to the way that
576 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
577 # strong enough to disable it in a generic way though, so we'll live with it
578 # until another vendor ships GCC with it enabled in a different way, and deal
579 # with it then.
582 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
583 save_cflags="$CFLAGS"
584 CFLAGS="$CFLAGS -fno-stack-protector"
585 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
586 AC_MSG_RESULT($use_no_stack_protector)
587 if test "x-$use_no_stack_protector" = "x-yes" ; then
588     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
590 CFLAGS="$save_cflags"
592 #-----------------------------------------------------------------------------
594 # Disable pointer-signedness warnings if the compiler recognises the option
595 # (this only works for the host compiler at the moment)
597 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
598 save_cflags="$CFLAGS"
599 CFLAGS="$CFLAGS -Wno-pointer-sign"
600 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
601 AC_MSG_RESULT($use_no_sign_warning)
602 if test "x-$use_no_sign_warning" = "x-yes" ; then
603     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
605 CFLAGS="$save_cflags"
607 #-----------------------------------------------------------------------------
609 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
611 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
612 save_cflags="$CFLAGS"
613 CFLAGS="$CFLAGS -fgnu89-inline"
614 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
615 AC_MSG_RESULT($use_gnu89_inline)
616 if test "x-$use_gnu89_inline" = "x-yes" ; then
617     gnu89_inline="-fgnu89-inline"
619 CFLAGS="$save_cflags"
621 #-----------------------------------------------------------------------------
623 AC_MSG_CHECKING([for type of build])
624 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")
626 if test "$build_type" = "nightly"; then
627     build_type_string="NIGHTLY"
628 elif test "$build_type" = "snapshot"; then
629     build_type_string="SNAPSHOT"
630 elif test "$build_type" = "milestone"; then
631     build_type_string="MILESTONE"
632 elif test "$build_type" = "release"; then
633     build_type_string="RELEASE"
634 else
635     build_type_string="PERSONAL"
636     build_type="personal"
639 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
641 AC_MSG_RESULT($build_type)
643 #-----------------------------------------------------------------------------
644 all_debug_types="messages stack modules mungwall symbols"
646 AC_MSG_CHECKING([which debug types to enable])
647 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)]),
648  debug="$enableval",debug="")
650 if test "$debug" = "" -o "$debug" = "no"; then
651     debug="none"
652 elif test "$debug" = "yes"; then
653     debug="all"
656 if test "$debug" = "all" ; then
657     debug="messages stack modules symbols"
658     for d in $all_debug_types; do
659         export aros_${d}_debug="1"
660     done
661 else
662     for d in $all_debug_types; do
663         export aros_${d}_debug="0"
664     done
667 if test "$debug" != "none"; then
668     debug=`echo $debug | sed s/,/\ /g`
669     for d in $debug; do
670         found="0"
671         for d2 in $all_debug_types; do
672             if test "$d2" = "$d"; then
673                 found="1"
674                 break
675             fi
676         done
677         if test "$found" = "0"; then
678             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
679         fi
680         export aros_${d}_debug="1"
681     done
682     aros_debug="yes"
684 AC_MSG_RESULT($debug)
686 if test "$aros_messages_debug" = "1"; then
687     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
688 else
689     aros_messages_debug=""
691 if test "$aros_symbols_debug" = "1"; then
692     aros_symbols_debug="-g"
693 else
694     aros_symbols_debug=""
697 # These are the flags to pass when compiling debugged programs
698 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
699 aros_debug_aflags=""
700 aros_debug_ldflags="$aros_symbols_debug"
702 #-----------------------------------------------------------------------------
703 #   Checking for distcc and ccache.
705 #   Always apply the transforms in this particular order. Basically you should
706 #   always run 'ccache distcc compiler' in that order for the best performance.
708 AC_MSG_CHECKING([whether to enable distcc])
709 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
710 if test "$distcc" != "" -a "$distcc" != "no"; then
711     # AC_CHECK_PROG will print out the result in this case
712     AC_PATH_PROG(DISTCC,[distcc],distcc,)
713 else
714     AC_MSG_RESULT(no)
717 AC_MSG_CHECKING([whether to enable ccache])
718 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
719 if test "$ccache" != "" -a "$ccache" != "no"; then
720     # AC_CHECK_PROG will print out the result in this case
721     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
722 else
723     AC_MSG_RESULT(no)
726 #-----------------------------------------------------------------------------
727 AC_MSG_CHECKING([what specific host gcc version to use])
728 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="")
729 AC_MSG_RESULT($kernel_tool_version)
731 #-----------------------------------------------------------------------------
732 AC_MSG_CHECKING([what optimization flags to use])
733 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
734 if test "$optimization" = "unknown"; then
735     dnl default is -O2 for normal builds, -O0 for debug builds
736     if test "$debug" != "none"; then
737         optimization="-O0"
738     else
739         optimization="-O2"
740     fi
742 aros_optimization_cflags="$optimization"
743 AC_MSG_RESULT($optimization)
745 #-----------------------------------------------------------------------------
746 AC_MSG_CHECKING([what paranoia flags to use])
747 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[CC flags to enable paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
748 if test "$paranoia_flags" = "default"; then
749         paranoia_flags=""
750 else if test "$paranoia_flags" = "yes"; then
751         paranoia_flags="-Wall -Werror"
752 fi fi
753 AC_MSG_RESULT($paranoia_flags)
754 aros_config_cflags="$aros_config_cflags $paranoia_flags"
756 #-----------------------------------------------------------------------------
757 AC_MSG_CHECKING([what target variant to enable])
758 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
759 if test "$target_variant" = ""; then
760     aros_target_variant=""
761     aros_target_suffix=""
762     enableval="none"
763 else
764     aros_target_variant="$target_variant"
765     aros_target_suffix="-$target_variant"
767 AC_MSG_RESULT($enableval)
769 #-----------------------------------------------------------------------------
770 # Target-specific defaults. You can override then on a per-target basis.
772 # Bootloader name. Currently used by PC target.
773 target_bootloader="none"
775 #-----------------------------------------------------------------------------
776 # Additional options for some specific targets
778 case "$aros_target_variant" in
779 ios)
780     AC_MSG_CHECKING([XCode path])
781     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")
782     AC_MSG_RESULT($aros_xcode_path)
784     AC_MSG_CHECKING([what iOS SDK version to use])
785     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")
786     AC_MSG_RESULT($aros_sdk_version)
788     ;;
790 "android")
791     AC_MSG_CHECKING([Android SDK path])
792     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)
793     AC_MSG_RESULT($aros_android_sdk)
795     AC_MSG_CHECKING([Android NDK path])
796     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
797     AC_MSG_RESULT($aros_android_ndk)
799     AC_MSG_CHECKING([what Android SDK version to use])
800     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")
801     AC_MSG_RESULT($aros_sdk_version)
803     aros_android_level=android-$aros_sdk_version
804     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
805         echo "Platform $aros_android_level is not installed in your SDK"
806         echo "Use --with-sdk-version=<API level number> to select another platform version"
807         echo "You can check what plaform versions are installed in your SDK"
808         echo "by examining contents of $aros_android_sdk/platforms directory"
809         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
810     fi
812     export PATH="$aros_android_sdk/tools:$PATH"
813     AC_PATH_PROG(android_tool, $android_tool)
814     AROS_REQUIRED(android,$android_tool)
816     if test "$aros_android_ndk" != "none"; then
817         AC_MSG_CHECKING([what Android NDK version to use])
818         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")
819         AC_MSG_RESULT($aros_ndk_version)
820     fi
822     AC_PATH_PROG(ant, ant)
823     if test "$ant" = ""; then
824         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
825     fi
827     AC_MSG_CHECKING([Build debug or release apk])
828     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)
829     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
830         AC_MSG_ERROR([apk-version has to be release or debug])
831     fi
832     AC_MSG_RESULT($aros_android_antapk)
834     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
835     if test "$host_os" = "mingw32"; then
836         android_tool="cmd //c $android_tool"
837     fi
839     need_dlopen="no"
841     ;;
842 esac
844 #-----------------------------------------------------------------------------
845 # External toolchains
846 kernel_tool_prefix="none"
847 aros_tool_prefix="none"
848 elf_tool_prefix="${target_cpu}-elf-"
850 # This is the target configuration switch.
851 case "$target_os" in
852     linux*)
853         aros_target_arch="linux"
854         aros_target_family="unix"
855         case "$target_cpu" in
856             *m68k*)
857                 aros_target_cpu="m68k"
858                 aros_object_format="m68kelf"
859                 aros_flavour="emulcompat"
860                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
861                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
862                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
863                 gcc_target_cpu="mc68000"
864                 ;;
865             *i?86*)
866                 aros_target_cpu="i386"
867                 aros_object_format="elf_i386"
868                 aros_flavour="emulation"
869                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
870                 aros_kernel_ldflags="-Wl,-melf_i386"
871                 aros_default_wbdepth=8
872                 gcc_target_cpu="i386"
873                 pci_hidd_target="hidd-pci-linux"
874                 android_tool_dir_prefix="x86"
875                 android_tool_prefix="i686-android-linux"
876                 android_ndk_arch="x86"
877                 ;;
878             *x86_64*)
879                 aros_target_cpu="x86_64"
880                 aros_object_format="elf_x86_64"
881                 aros_flavour="emulation"
882                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
883                 aros_config_cflags="$aros_config_cflags -mno-red-zone -fno-omit-frame-pointer"
884                 aros_default_wbdepth=8
885                 pci_hidd_target="hidd-pci-linux"
886                 ;;
887             *powerpc*)
888                 aros_target_cpu="ppc"
889                 aros_object_format="elf32ppc"
890                 aros_flavour="emulation"
891                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
892                 aros_default_wbdepth=8
893                 gcc_target_cpu="ppc"
894                 ;;
895 # TODO
896 # Same as powerpc, but I need this for the nightly build to work again.
897 # Actually, the nightly should be made working with powerpc target.
898 # That just was too much work for the moment, another week or two.
899             *ppc*)
900                 aros_target_cpu="ppc"
901                 aros_object_format="elf32ppc"
902                 aros_flavour="emulation"
903                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
904                 aros_default_wbdepth=8
905                 gcc_target_cpu="ppc"
906                 ;;
907             *armhf*)
908                 aros_target_cpu="arm"
909                 target_cpu="arm"
910                 aros_object_format="armelf_aros"
911                 aros_flavour="emulation"
912                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
913                 gcc_target_cpu="arm"
914                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
915                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
916                 aros_arch_libs="-laeabi"
917                 gcc_default_float_abi="hard"
918                 android_tool_dir_prefix="arm-linux-androideabi"
919                 android_tool_prefix="arm-linux-androideabi"
920                 android_ndk_arch="arm"
921                 kernel_tool_prefix="arm-linux-gnueabihf-"
922                 ;;
923             *arm*)
924                 aros_target_cpu="arm"
925                 aros_object_format="armelf_aros"
926                 aros_flavour="emulation"
927                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
928                 gcc_target_cpu="arm"
929                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
930                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
931                 aros_arch_libs="-laeabi"
932                 android_tool_dir_prefix="arm-linux-androideabi"
933                 android_tool_prefix="arm-linux-androideabi"
934                 android_ndk_arch="arm"
935                 kernel_tool_prefix="arm-linux-gnueabi-"
936                 ;;
937             *)
938                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
939                 ;;
940         esac
941         case "$aros_target_variant" in
942             android)
944                 dnl Not all Linux CPUs are supported by Android
945                 if test "$android_ndk_arch" = ""; then
946                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
947                 fi
949                 aros_default_wbwidth=320
950                 aros_default_wbheight=480
951                 if test "$aros_android_ndk" = "none"; then
952                     dnl Use standalone toolchain, don't adjust paths
953                     aros_kernel_cflags="-mandroid"
954                     aros_kernel_ldflags="-mandroid"
955                     CFLAGS="-mandroid"
956                 else
957                     dnl In Android NDK toolchains are placed in own directories,
958                     dnl but tool names are not suffixed with version 
959                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
960                     kernel_tool_version=""
961                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
962                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
963                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
964                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
965                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
966                 fi
967                 need_x11=no
968                 unixgfx_hidd_target=kernel-hidd-androidgfx
969                 # Disable implicit PIC mode
970                 aros_target_cflags="$aros_target_cflags -fno-pic"
971                 kernel_tool_prefix="$android_tool_prefix-"
972             ;;
973         esac
974     ;;
976     pc)
977         aros_target_arch="pc"
978         aros_shared_default="no"
979         target_bootloader="grub2"
980         case "$target_cpu" in
981             *i?86*)
982                 aros_target_cpu="i386"
984                 dnl If somebody hasn't already set the target object
985                 dnl format, then use this value. Mostly to support
986                 dnl FreeBSD cross-compilation.
987                 dnl TODO: Remove when we always use our compiler.
989                 if test "$aros_object_format" = "" ; then
990                     aros_object_format="elf_i386"
991                 fi
992                 aros_flavour="standalone"
993                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
994                 aros_kernel_ldflags="-Wl,-melf_i386"
995                 aros_default_wbwidth=640
996                 aros_default_wbheight=480
997                 gcc_target_cpu="i386"
998                 ;;
999             *x86_64*)
1000                 aros_target_cpu="x86_64"
1001                 aros_serial_debug=1
1002                 if test "$aros_object_format" = "" ; then
1003                     aros_object_format="elf_x86_64"
1004                 fi
1005                 aros_flavour="standalone"
1006                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1007                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1008                 aros_kernel_ldflags=""
1009                 aros_default_wbwidth=640
1010                 aros_default_wbheight=480
1011                 ;;
1012             *)
1013                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1014                 ;;
1015         esac
1016         ;;
1018     prep)
1019         aros_target_arch="prep"
1020         aros_shared_default="no"
1021         aros_target_cpu="ppc"
1022         aros_object_format="elf32ppc"
1023         aros_flavour="ppcnative"
1024         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1025         aros_kernel_ldflags=""
1026         aros_default_wbwidth=640
1027         aros_default_wbheight=480
1028         gcc_target_cpu="ppc"
1029         ;;
1031     freebsd*)
1032         aros_target_arch="freebsd"
1033         aros_target_family="unix"
1034         aros_target_cpu="i386"
1035         aros_flavour="emulation"
1036         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1037         gcc_target_cpu="i386"
1039         aros_target_strip_flags="-x"
1040         ;;
1042     darwin*)
1043         aros_target_arch="darwin"
1044         aros_target_family="unix"
1045         aros_flavour="emulation"
1046         case "$target_cpu" in
1047             *i?86*)
1048                 aros_ios_platform="iPhoneSimulator"
1049                 aros_target_cpu="i386"
1050                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1051                 aros_kernel_ldflags=""
1052                 aros_macosx_version="10.4"
1053                 aros_default_wbdepth=8
1054                 gcc_target_cpu="i386"
1055                 aros_object_format="elf_i386"
1056                 aros_kernel_ar_flags="-cr"
1057                 aros_target_strip_flags="-x"
1058                 kernel_tool_flags="-m32"
1059                 ;;
1060             *x86_64*)
1061                 aros_target_cpu="x86_64"
1062                 aros_object_format="elf_x86_64"
1063                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1064                 aros_macosx_version="10.6"
1065                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1066                 aros_kernel_cflags="-m64"
1067                 aros_kernel_ldflags="-m64"
1068                 aros_target_cflags="-mcmodel=large"
1069                 aros_default_wbdepth=8
1070                 aros_kernel_ar="ar"
1071                 aros_kernel_ar_flags="-cr"
1072                 aros_kernel_ld="ld"
1073                 aros_kernel_as="as"
1074                 aros_kernel_ranlib="ranlib"
1075                 aros_kernel_nm="nm"
1076                 aros_kernel_strip="strip"
1077                 kernel_tool_prefix="i686-apple-darwin10-"
1078                 ;;
1079             *ppc*)
1080                 aros_target_cpu="ppc"
1081                 aros_object_format="elf32ppc"
1082                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1083                 aros_kernel_ldflags=""
1084                 aros_macosx_version="10.0"
1085                 aros_default_wbdepth=8
1086                 gcc_target_cpu="ppc"
1087                 aros_kernel_ar="ar"
1088                 aros_kernel_ar_flags="-cr"
1089                 aros_kernel_ld="ld -arch ppc"
1090                 aros_kernel_as="as -arch ppc"
1091                 aros_kernel_ranlib="ranlib -arch ppc"
1092                 aros_kernel_nm="nm -arch ppc"
1093                 aros_kernel_strip="strip -arch ppc"
1094                 kernel_tool_prefix="powerpc-apple-darwin10-"
1095                 ;;
1096             *arm*)
1097                 aros_ios_platform="iPhoneOS"
1098                 aros_target_cpu="arm"
1099                 aros_object_format="armelf_aros"
1100                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1101                 aros_arch_libs="-laeabi"
1102                 aros_default_wbdepth=8
1103                 gcc_target_cpu="arm"
1104                 aros_kernel_ar="ar"
1105                 aros_kernel_ar_flags="-cr"
1106                 aros_kernel_ld="ld -arch arm"
1107                 aros_kernel_ranlib="ranlib -arch arm"
1108                 kernel_tool_prefix="arm-apple-darwin10-" 
1109                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1110                 ;;
1111             *)
1112                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1113                 ;;
1114         esac
1115         case "$aros_target_variant" in
1116             ios)
1117                 aros_ios_version="3.0"
1118                 aros_default_wbwidth=320
1119                 aros_default_wbheight=480
1120                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1121                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1122                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1123                 need_x11=no
1124                 # This is here because it may depend on iOS or SDK version
1125                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1126                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1127                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1128             ;;
1129             *)
1130                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1131                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1132             ;;
1133         esac
1134         ;;
1136     dragonfly*)
1137         aros_target_arch="dragonfly"
1138         aros_target_family="unix"
1139         aros_flavour="emulation"
1140         case "$target_cpu" in
1141             *i?86*)
1142                 aros_target_cpu="i386"
1143                 aros_object_format="elf_i386"
1144                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1145                 ;;
1146             *x86_64*)
1147                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1148                 aros_target_cpu="x86_64"
1149                 aros_object_format="elf_x86_64"
1150                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1151                 ;;
1152             *)
1153                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1154                 ;;
1155         esac
1156         ;;
1158     netbsd*)
1159         aros_target_arch="netbsd"
1160         aros_target_family="unix"
1161         case "$target_cpu" in
1162             *m68k*)
1163                 aros_target_cpu="m68k"
1164                 aros_object_format="m68kelf"
1165                 aros_flavour="emulcompat"
1166                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1167                 gcc_target_cpu="mc68000"
1168                 ;;
1169             *i?86*)
1170                 aros_target_cpu="i386"
1171                 aros_object_format="elf_i386"
1172                 aros_flavour="emulation"
1173                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1174                 aros_default_wbdepth=8
1175                 gcc_target_cpu="i386"
1176                 ;;
1177             *)
1178                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1179                 ;;
1180         esac
1181         aros_target_genmap="-Wl,-M -Xlinker >"
1182         aros_flavour="emulation"
1183         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1184         ;;   
1186     openbsd*)
1187         aros_target_arch="openbsd"
1188         aros_target_family="unix"
1189         case "$target_cpu" in
1190             *i?86*)
1191                 aros_target_cpu="i386"
1192                 aros_object_format="elf_i386"
1193                 aros_flavour="emulation"
1194                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1195                 gcc_target_cpu="i386"
1196                 ;;
1197             *)
1198                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1199                 ;;
1200         esac
1201         aros_target_genmap="-Wl,-M -Xlinker >"
1202         aros_target_nm_flags="-u"
1203         aros_flavour="emulation"
1204         ;;
1206     solaris*)
1207         aros_target_arch="solaris"
1208         aros_target_family="unix"
1209         case "$target_cpu" in
1210            *i?86*)
1211                aros_target_cpu="i386"
1212                aros_object_format="elf_i386"
1213                aros_flavour="emulation"
1214                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1215                aros_default_wbdepth=8
1216                gcc_target_cpu="i386"
1217                ;;
1218             *sparc*)
1219                 aros_target_cpu="sparc"
1220                 aros_object_format="elf_sparc"
1221                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1222                 gcc_target_cpu="sparc"
1223                 ;;
1224             *)
1225                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1226                 ;;
1227         esac
1228         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1229         aros_flavour="emulation"
1230         ;;
1232     morphos*)
1233         aros_target_arch="morphos"
1234         aros_shared_default="no"
1235         aros_target_cpu="ppc"
1236         aros_object_format="elf_ppc"
1237         aros_flavour="nativecompat"
1238         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1239         gcc_target_cpu="ppc"
1240         ;;
1242     sam440)
1243         aros_target_arch="sam440"
1244         aros_shared_default="no"
1245         aros_target_cpu="ppc"
1246         aros_object_format="elf32ppc"
1247         aros_flavour="ppcnative"
1248         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1249         aros_kernel_ldflags=""
1250         aros_default_wbwidth=1024
1251         aros_default_wbheight=768
1252         aros_default_wbdepth=24
1253         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1254         gcc_target_cpu="powerpc"
1255         ;;
1257     efika)
1258         aros_target_arch="efika"
1259         aros_shared_default="no"
1260         aros_target_cpu="arm"
1261         aros_object_format="armelf_aros"
1262         aros_flavour="standalone"
1263         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1264         aros_kernel_ldflags=""
1265         aros_default_wbwidth=1024
1266         aros_default_wbheight=600
1267         aros_arch_libs="-laeabi"
1268         gcc_default_cpu="armv7-a"
1269         gcc_default_fpu="vfpv3"
1270         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1271         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1272         aros_optimization_cflags="$aros_optimization_cflags -Os"
1273         case "$target_cpu" in
1274             *armhf*)
1275                 gcc_default_float_abi="hard"
1276                 target_cpu=arm
1277                 aros_target_cpu=arm
1278                 ;;
1279             *arm*)
1280                 gcc_default_float_abi="softfp"
1281                 ;;
1282             *)
1283                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1284                 ;;
1285         esac
1286         ;;
1287         
1288     chrp)
1289     aros_target_arch="chrp"
1290     aros_shared_default="no"
1291     aros_target_cpu="ppc"
1292     aros_object_format="elf32ppc"
1293     aros_flavour="ppcnative"
1294     aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1295     aros_kernel_ldflags=""
1296     aros_default_wbwidth=640
1297     aros_default_wbheight=480
1298     aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1299     gcc_target_cpu="powerpc"
1300         case "$aros_target_variant" in
1301             efika)
1302             aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1303             ;;
1304         esac
1305     ;;
1307     r*pi)
1308         aros_flavour="standalone"
1309         aros_target_arch="raspi"
1310         aros_target_cpu="arm"
1311         aros_object_format="armelf_aros"
1312         aros_shared_default="no"
1313         aros_arch_libs="-laeabi"
1315         gcc_default_cpu="armv6"
1316         gcc_default_cpu_tune="arm1176jzf-s"
1317         case "$target_cpu" in
1318             *armhf*)
1319                 gcc_default_float_abi="hard"
1320                 ;;
1321             *arm*)
1322                 gcc_default_float_abi="softfp"
1323                 ;;
1324             *)
1325                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1326                 ;;
1327         esac
1329         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1330         aros_config_cflags="$aros_config_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1331         aros_config_aflags="$aros_config_aflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1332         aros_kernel_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1333         aros_target_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1334         ;;
1336     sun4i)
1337         aros_flavour="standalone"
1338         aros_target_arch="sun4i"
1339         aros_target_cpu="arm"
1340         aros_object_format="armelf_aros"
1341         aros_shared_default="no"
1342         aros_arch_libs="-laeabi"
1344                 gcc_default_cpu="armv7-a"
1345         gcc_default_fpu="neon"
1346         gcc_default_cpu_tune="cortex-a8"
1347                 gcc_default_float_abi="hard"
1349         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1350         aros_optimization_cflags=""
1351         aros_config_cflags="$aros_config_cflags -mcpu=cortex-a8 -mtune=cortex-a8 -fno-strict-aliasing"
1352         aros_config_aflags="$aros_config_aflags -mcpu=cortex-a8 -mtune=cortex-a8 -fno-strict-aliasing"
1353         ;;
1355     amiga*)
1356         aros_target_arch="amiga"
1357         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1358         aros_shared_default="no"
1360         case "$target_cpu" in
1361             *m68k*)
1362                 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")
1363                 aros_enable_mmu=no
1364                 aros_target_cpu="m68k"
1365                 aros_object_format="m68kelf"
1366                 aros_flavour="standcompat"
1367                 gcc_target_cpu="m68000"
1368                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -Wno-volatile-register-var -DNOLIBINLINE"
1369                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1370                 aros_config_aflags="$aros_config_aflags"
1371                 aros_target_strip_flags="-R.comment --strip-debug"
1372                 aros_default_wbwidth=640
1373                 aros_default_wbheight=256
1374                 aros_default_wbdepth=2
1375                 ;;
1376             *ppc*)
1377                 aros_cpu="ppc"
1378                 aros_flavour="native"
1379                 gcc_target_cpu="ppc"
1380                 ;;
1381             *)
1382                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1383                 ;;
1384         esac
1385         ;;
1387     mingw*)
1388         aros_target_arch="mingw32"
1389         aros_shared_default="no"
1390         aros_flavour="emulation"
1391         aros_shared_cflags=""
1392         need_crosstools="yes"
1393         need_dlopen="no"
1394         rescomp="windres"
1395         case "$target_cpu" in
1396             *i?86*)
1397                 aros_target_cpu="i386"
1398                 aros_object_format="elf_i386"
1399                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1400                 aros_default_wbdepth=8
1401                 gcc_target_cpu="i386"
1403                 kernel_tool_prefix="i386-mingw32-"
1404                 ;;
1405             *x86_64*)
1406                 aros_target_cpu="x86_64"
1407                 aros_object_format="elf_x86_64"
1408                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1409                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1410                 aros_default_wbdepth=8
1411                 kernel_tool_prefix="x86_64-w64-mingw32-"
1412                 ;;
1413             *arm*)
1414                 aros_target_cpu="arm"
1415                 aros_object_format="armelf_aros"
1416                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1417                 aros_arch_libs="-laeabi"
1418                 aros_default_wbdepth=8
1419                 gcc_target_cpu="arm"
1420                 gcc_default_float_abi="soft"
1421                 kernel_tool_prefix="arm-mingw32ce-"
1422                 aros_default_wbwidth=160
1423                 aros_default_wbheight=160
1424                 ;;
1425             *)
1426                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1427                 ;;
1428         esac
1429         if test $host_os = "cygwin"; then
1430                 aros_kernel_cflags="-mno-cygwin"
1431         fi
1432     ;;
1433     pp*)
1434         aros_target_arch="pp"
1435         aros_shared_default="no"
1436         case "$target_cpu" in
1437             *m68k*)
1438                 aros_target_cpu="m68k"
1439                 aros_object_format="m68kelf"
1440                 aros_flavour="palmnative"
1441                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1442                 aros_default_wbwidth=160
1443                 aros_default_wbheight=160
1444                 aros_default_wbdepth=1
1445                 aros_target_ar_flags="cru"
1446                 aros_compiler_libs="-lgcc1"
1447                 aros_shared_default=no
1448                 aros_shared_cflags="-fpic"
1449                 aros_shared_aflags=""
1450                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1451                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1452                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1453                 aros_debug_aflags=""
1454                 aros_debug_ldflags="$aros_symbols_debug"
1455                 aros_mungwall_debug="0"
1456                 aros_modules_debug="0"
1457                 gcc_target_cpu="mc68000"
1458                 ignore_undefined_symbols="-ius"
1459                 ;;
1460            *)
1461                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1462                 ;;
1463         esac
1464         ;;
1466     mac*)
1467         aros_target_arch="mac"
1468         aros_shared_default="no"
1469         case "$target_cpu" in
1470             *m68k*)
1471                 aros_target_cpu="m68k"
1472                 aros_object_format="m68kelf"
1473                 aros_flavour="mac68knative"
1474                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1475                 aros_default_wbwidth=512
1476                 aros_default_wbheight=384
1477                 aros_default_wbdepth=8
1478                 aros_target_ar_flags="cru"
1479                 aros_compiler_libs="-lgcc1"
1480                 aros_shared_default=no
1481                 aros_shared_cflags="-fpic"
1482                 aros_shared_aflags=""
1483                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1484                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1485                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1486                 aros_debug_aflags=""
1487                 aros_debug_ldflags="$aros_symbols_debug"
1488                 aros_mungwall_debug="0"
1489                 aros_modules_debug="0"
1490                 gcc_target_cpu="mc68000"
1491                 ignore_undefined_symbols="-ius"
1492                 ;;
1493            *)
1494                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1495                 ;;
1496         esac
1497         ;;
1499     *)
1500         AC_MSG_ERROR([Unsupported target architecture $target])
1501         ;;
1502 esac
1504 #-----------------------------------------------------------------------------
1505 crosstools_guess="yes"
1506 aros_target_toolchain="no"
1508 AC_MSG_CHECKING([Kernel toolchain prefix])
1509 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1510 AC_MSG_RESULT($kernel_tool_prefix)
1512 AC_MSG_CHECKING([ELF toolchain prefix])
1513 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"
1514                                                  crosstools_guess="no"])
1515 AC_MSG_RESULT($elf_tool_prefix)
1517 AC_MSG_CHECKING([AROS toolchain prefix])
1518 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"
1519                 crosstools_guess="no"])
1520 if test "$aros_tool_prefix" = "yes" ; then
1521     aros_tool_prefix=$aros_target_cpu-aros-
1523 AC_MSG_RESULT($aros_tool_prefix)
1525 #-----------------------------------------------------------------------------
1526 #   Checking if we should build crosstools..
1527 AC_MSG_CHECKING([whether to build crosstools])
1528 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1529 AC_MSG_RESULT($crosstools)
1531 if test "${crosstools}" = "yes"; then
1532     if test "${crosstools_guess}" = "no"; then
1533         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1534     fi
1537 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1538     aros_target_toolchain="yes"
1541 AC_MSG_CHECKING([where to install the crosstools binaries])
1542 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])
1543 if test "x$aros_toolchain_install" = "x"; then
1544     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1545 else
1546     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1547     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1548     aros_config_ldflags="$aros_config_ldflags -L$AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/lib"
1549     aros_config_cflags="$aros_config_cflags -isystem$AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include"
1551 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1553 # Helper to identify gcc version
1554 AC_DEFUN([CROSS_GCC_VERSION], [
1555   target_gcc_version=""
1556   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1557     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}cpp -dumpversion`"
1558     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1559       ax_cv_gcc_version=""
1560     ])
1561   ])
1562   target_gcc_version=$ax_cv_gcc_version
1563   AC_SUBST([target_gcc_version])
1566 #-----------------------------------------------------------------------------
1567 AC_MSG_CHECKING([what specific target gcc version to use])
1568 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Use gcc-VERSION for building AROS]),use_gcc_version="$withval",use_gcc_version="")
1569 if test "$use_gcc_version" = ""; then
1570     if test "${crosstools}" = "no"; then
1571       if test "x$aros_toolchain_install" != "x"; then
1572           CROSS_GCC_VERSION
1573       fi
1574     fi
1575     if test "$use_gcc_version" = ""; then
1576         target_gcc_version="4.6.4"
1577     fi
1578 else
1579     target_gcc_version="$use_gcc_version"
1581 AC_MSG_RESULT($target_gcc_version)
1583 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1584 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=yes)]),objc="$enableval",objc="yes")
1585 AC_MSG_RESULT($objc)
1586 if test "x$objc" = "xyes"; then
1587     objc_target="$objc"
1588 else
1589     objc_target="no-objc"
1592 AC_MSG_CHECKING([whether to enable Java suppport])
1593 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1594 AC_MSG_RESULT($java)
1595 if test "x$java" != "xno"; then
1596     java_target="$java"
1597 else
1598     java_target="no-java"
1601 spec_obj_format="-m $aros_object_format"
1602 # Now process extra architecture-specific options.
1603 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1604 # as well as floating-point ABI.
1605 case "$aros_target_cpu" in
1606 *x86_64*)
1607     dnl x86_64 can build 32 or 64bit code
1608     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1609     ;;
1610 arm)
1611     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1612     if test "$gcc_default_cpu" = ""; then
1613         gcc_default_cpu="armv6"
1614     fi
1615     if test "$gcc_default_fpu" = ""; then
1616         gcc_default_fpu="vfp"
1617     fi
1618     if test "$gcc_default_float_abi" = ""; then
1619         gcc_default_float_abi="softfp"
1620     fi
1622     AC_MSG_CHECKING([Which minimum CPU to use])
1623     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)
1624     AC_MSG_RESULT($aros_gcc_cpu)
1626     AC_MSG_CHECKING([Which minimum FPU to use])
1627     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)
1628     AC_MSG_RESULT($aros_gcc_fpu)
1630     AC_MSG_CHECKING([Which floating point ABI to use])
1631     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)
1632     AC_MSG_RESULT($aros_gcc_float_abi)
1634     aros_isa_flags="-marm -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1635     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1636     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1637     ;;
1638 i386)
1639     aros_isa_flags="-m32 -march=i486"
1640     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1641     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1642     ;;
1643 esac
1645 # Some architectures may need custom ELF specs.
1646 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1647     elf_specs_in=config/${aros_object_format}-specs.in
1648 else
1649     elf_specs_in=config/elf-specs.in
1652 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1653 # Since we override specs, we may need to put these defines there
1654 if test "$gcc_target_cpu" != ""; then
1655     gcc_target_cpu="-D__${gcc_target_cpu}__"
1658 AC_MSG_CHECKING([where to download sourcecode for external ports])
1659 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1660 if test "$with_portssrcdir" = "default"; then
1661     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1662 else
1663     AROS_PORTSSRCDIR="$with_portssrcdir"
1665 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1667 AC_MSG_CHECKING([which bootloader to use])
1668 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1669 if test "$target_bootloader" = "none"; then
1670     aros_target_bootloader=""
1671 else
1672     aros_target_bootloader="$target_bootloader"
1674 AC_MSG_RESULT($target_bootloader)
1676 AC_MSG_CHECKING([which icon-set to use])
1677 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1678 if test "$target_iconset" = "default"; then
1679     aros_target_iconset="Gorilla"
1680     target_iconset="default (Gorilla)"
1681 else
1682     aros_target_iconset="$target_iconset"
1684 AC_MSG_RESULT($target_iconset)
1686 AC_MSG_CHECKING([which GUI Theme to use])
1687 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1688 if test "$target_guitheme" = "default"; then
1689     aros_target_guitheme="Ice"
1690 else
1691     aros_target_guitheme="$target_guitheme"
1693 AC_MSG_RESULT($aros_target_guitheme)
1695 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1696 # for target code)
1697 cross_compiling=no
1699 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1700 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1701     cross_compiling=yes
1704 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1705 dnl The flag itself is given in per-target section, because some targets require to pass it
1706 dnl in a different manner, otherwise some tests fail.
1707 dnl TODO: Justify this.
1708 if test "$aros_host_cpu" == "x86_64" ; then
1709     if test "$aros_target_cpu" == "i386" ; then
1710         cross_compiling=no
1711     fi
1714 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1715     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1716     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1717     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1718     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1719     dnl used to build bootstrap for target arch in either case.
1720     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1721     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1722     dnl perhaps introducing aros_host_variant
1723     if test "$aros_host_arch" != "$aros_target_arch" ; then
1724         cross_compiling=yes
1725     fi
1726 else
1727     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1728     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1729     if test "$host_cc_elf" = "no" ; then
1730         cross_compiling=yes
1731     fi
1734 if test "$cross_compiling" = "no" ; then
1735     kernel_tool_prefix=""
1736     if test "$host_cc_elf" = "yes" ; then
1737         elf_tool_prefix=""
1738     fi
1741 if test "$kernel_tool_version" != ""; then
1742     kernel_tool_version="-$kernel_tool_version"
1745 #######################################################################
1746 ## Compute what toolchains to use, and their paths                   ##
1747 #######################################################################
1749 # This takes, as input:
1750 #   crosstools             {yes,no}
1751 #   kernel_tool_version    {"",[version]}
1752 #   target_tool_version    {"",[version]}
1753 #   kernel_tool_prefix     {none,[some-arch-os-]}
1754 #   target_tool_prefix     ${aros_target_cpu}-aros-
1755 #   aros_tool_prefix       ${aros_target_cpu}-aros-
1757 # The output is
1758 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1759 #        Where the 'kernel' binaries are located
1760 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1761 #        Where the 'target' binaries are located
1762 #        (not the symlink farm - that is aros_target_*!)
1764 # The rules are:
1765 #   if crosstools then
1766 #      if kernel_tools_prefix = "no-kernel-prefix-"
1767 #          aros_kernel_* = crosstools cc paths
1768 #          aros_kernel_cc = elf cc wrapper around crosstools cc
1769 #      else
1770 #          VALIDATE(${kernel_tools_prefix}*)
1771 #          aros_kernel_* = ${kernel_tools_prefix}*
1772 #          if ${kernel_tools_prefix}cc is an AROS gcc
1773 #              aros_kernel_cc = ${kernel_tools_prefix}cc
1774 #          else
1775 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
1776 #          fi
1777 #      fi
1779 #      orig_target_* = aros built crosstools
1780 #      orig_target_cc = elf cc wrapper around crosstools cc
1781 #   else
1782 #      VALIDATE(${kernel_tools_prefix}*)
1784 #      orig_target_* = aros_kernel_*
1785 #      if aros_kernel_cc is an AROS gcc
1786 #          orig_target_cc = aros_kernel_cc
1787 #      else
1788 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
1789 #      fi
1790 #   fi
1792 target_tool_prefix="${aros_target_cpu}-aros-"
1794 AC_MSG_CHECKING([which kernel tools])
1795 AC_MSG_RESULT([$kernel_tool_prefix]);
1797 if test "$kernel_tool_prefix" = "none" ; then
1798     dnl ELF wrapper can be used only for native bootstrap
1799     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1800         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
1801     fi
1802 else
1803     # Kernel tools required - find them
1804     # Note that 'normally', aros_kernel_* overrides will be
1805     # empty, unless specified in the per-arch sections above.
1806     if test "x$aros_kernel_cpp" = "x"; then
1807         aros_kernel_cpp=${kernel_tool_prefix}cpp
1808     fi
1809     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
1810     AROS_REQUIRED(cpp,$aros_kernel_cpp)
1811     if test "x$aros_kernel_cc" = "x"; then
1812         aros_kernel_cc=${kernel_tool_prefix}gcc
1813     fi
1814     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
1815     AROS_REQUIRED(cc,$aros_kernel_cc)
1816     if test "x$aros_kernel_cxx" = "x"; then
1817         aros_kernel_cxx=${kernel_tool_prefix}g++
1818     fi
1819     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
1820     # If it's set, make sure it's really there
1821     if test "x$aros_kernel_cxx" != "x" ; then
1822         AROS_REQUIRED(cxx,$aros_kernel_cxx)
1823     fi
1824     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
1825     AROS_REQUIRED(ld,$aros_kernel_ld)
1826     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
1827     AROS_REQUIRED(as,$aros_kernel_as)
1828     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
1829     AROS_REQUIRED(ar,$aros_kernel_ar)
1830     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1831     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
1832     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
1833     AROS_REQUIRED(nm,$aros_kernel_nm)
1834     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
1835     AROS_REQUIRED(strip,$aros_kernel_strip)
1837     # Objcopy and objdump are not required for the kernel
1838     # toolchain on many architectures.
1839     # So we'll look for them, but not make them strictly required.
1840     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
1841     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
1842     if test "x${crosstools}" != "xyes" ; then
1843         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
1844         AROS_REQUIRED(objdump,$aros_kernel_objdump)
1845     fi
1848 AC_MSG_CHECKING([which target tools to use])
1849 if test "$aros_target_toolchain" = "yes"; then
1850     AC_MSG_RESULT([$target_tool_prefix])
1851     # We are building AROS crosstools
1852     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
1853     orig_target_cc="${tmp_tool_prefix}gcc${target_tool_version}"
1854     orig_target_cxx="${tmp_tool_prefix}g++${target_tool_version}"
1855     orig_target_cpp="${tmp_tool_prefix}cpp"
1856     orig_target_ld="${tmp_tool_prefix}ld"
1857     orig_target_as="${tmp_tool_prefix}as"
1858     orig_target_ar="${tmp_tool_prefix}ar"
1859     orig_target_ranlib="${tmp_tool_prefix}ranlib"
1860     orig_target_nm="${tmp_tool_prefix}nm"
1861     orig_target_strip="${tmp_tool_prefix}strip"
1862     orig_target_objcopy="${tmp_tool_prefix}objcopy"
1863     orig_target_objdump="${tmp_tool_prefix}objdump"
1864 else
1865     # Determine whether AROS or ELF tools should be used
1866     if test "$aros_tool_prefix" = "none"; then
1867         aros_tool_prefix="${elf_tool_prefix}"
1868     fi
1870     AC_MSG_RESULT([$aros_tool_prefix])
1871     # We are *not* building AROS crosstools - use the AROS or ELF tools
1872     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}cpp${target_tool_version})
1873     AROS_REQUIRED(cpp,$orig_target_cpp)
1874     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}gcc${target_tool_version})
1875     AROS_REQUIRED(cc,$orig_target_cc)
1876     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}g++${target_tool_version})
1877     AROS_REQUIRED(cxx,$orig_target_cxx)
1878     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}ld)
1879     AROS_REQUIRED(ld,$orig_target_ld)
1880     AROS_TOOL_TARGET(orig_target_as,as,${aros_tool_prefix}as)
1881     AROS_REQUIRED(as,$orig_target_as)
1882     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}ar)
1883     AROS_REQUIRED(ar,$orig_target_ar)
1884     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}ranlib)
1885     AROS_REQUIRED(ranlib,$orig_target_ranlib)
1886     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}nm)
1887     AROS_REQUIRED(nm,$orig_target_nm)
1888     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}strip)
1889     AROS_REQUIRED(strip,$orig_target_strip)
1890     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}objcopy)
1891     AROS_REQUIRED(objcopy,$orig_target_objcopy)
1892     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}objdump)
1893     AROS_REQUIRED(objdump,$orig_target_objdump)
1896 if test "$kernel_tool_prefix" = "none" ; then
1897     # No kernel tools specified
1898     # Assume target tools == kernel tools with ELF wrapper
1899     aros_kernel_cc=$orig_target_cc
1900     aros_kernel_cxx=$orig_target_cxx
1901     aros_kernel_cpp=$orig_target_cpp
1902     aros_kernel_ld=$orig_target_ld
1903     aros_kernel_as=$orig_target_as
1904     aros_kernel_ar=$orig_target_ar
1905     aros_kernel_ranlib=$orig_target_ranlib
1906     aros_kernel_nm=$orig_target_nm
1907     aros_kernel_strip=$orig_target_strip
1908     aros_kernel_objcopy=$orig_target_objcopy
1909     aros_kernel_objdump=$orig_target_objdump
1910     use_kernel_cc_wrapper=yes
1913 # At this point, all aros_kernel_* and aros_target_* 
1914 # tools should be set up correctly
1916 CC="$aros_kernel_cc $kernel_tool_flags"
1917 CPP="$aros_kernel_cpp"
1919 #-----------------------------------------------------------------------------
1921 # Disable pointer-signedness warnings if the compiler recognises the option
1923 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
1924 save_cflags="$CFLAGS"
1925 if test "$crosstools" != "yes" ; then
1926     CFLAGS="$CFLAGS -Wno-pointer-sign"
1927     AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
1928 else
1929     # we do know it is supported for the smallest version of gcc we are going to build
1930     # we assume it's also supported by later versions
1931     use_no_sign_warning=yes
1933 AC_MSG_RESULT($use_no_sign_warning)
1934 if test "x-$use_no_sign_warning" = "x-yes" ; then
1935     aros_config_cflags="$aros_config_cflags -Wno-pointer-sign"
1937 CFLAGS="$save_cflags"
1939 #-----------------------------------------------------------------------------
1941 # Find all the tools we need to compile. This could be cross-compiling
1942 # though! If that is the case we use the GNU form of the target and
1943 # simply add this to the front of the binary name. This is rather simple,
1944 # but it should work under most circumstances.
1946 # The default tools are to use the same as the host, but only if the
1947 # host and target CPU are the same. With GCC this is normally enough.
1950 aros_cc_pre=""
1951 aros_shared_ld="$aros_host_ld"
1953 aros_target_mkdep="$aros_host_mkdep"
1955 # The default tools executables to be linked to.
1956 if test "$rescomp" != ""; then
1957     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
1958     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
1961 # Set up the sources for the symlink farm
1962 if test "$crosstools" = "yes"; then
1963     crosstools_target=tools-crosstools
1966 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
1967 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
1969 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1970 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1971 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1972 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1973 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1974 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1975 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1977 # aros_cc_pre is a variable that is added to the front of the compiler name
1978 # in the generated aros-gcc shell script. We need this to enable the cache
1979 # to work across cleaned builds. Also, support DISTCC using the correct
1980 # environment variable.
1983 if test "x${DISTCC}" != "x" ; then
1984     if test "x${CCACHE}" != "x" ; then
1985         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1986     else
1987         aros_cc_pre="${DISTCC} "
1988     fi
1989 else
1990     if test "x${CCACHE}" != "x" ; then
1991         aros_cc_pre="${CCACHE} "
1992     fi
1995 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1996 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1997 AC_SUBST(aros_target_nix_ldflags,-nix)
1998 AC_SUBST(aros_target_detach_ldflags,-detach)
1999 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2001 # Target tools
2002 if test "$aros_target_toolchain" != "yes"; then
2003     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2004     if test "$GCC" = "yes"; then
2005         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2006     fi
2007 else
2008     # We do not know which gcc version we are going to build and what we need to know
2009     # here is different for different versions so this will be set later during the
2010     # build of crosstools.
2011     prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2012     aros_target_cc_path=@aros_target_cc_path@
2014 aros_target_cpp="${prefix}cpp"
2015 aros_target_cc="${prefix}gcc"
2016 aros_target_cxx="${prefix}g++"
2017 aros_target_as="${prefix}as"
2018 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld"
2019 aros_target_ar="${prefix}ar $aros_target_ar_flags"
2020 aros_target_objcopy="${prefix}objcopy"
2021 aros_target_objdump="${prefix}objdump"
2022 aros_target_ranlib="${prefix}ranlib $aros_target_ranlib_flags"
2023 aros_target_nm="${prefix}nm $aros_target_nm_flags"
2024 aros_target_strip="${prefix}strip"
2025 aros_plain_nm="${prefix}nm"
2026 aros_plain_ar="${prefix}ar"
2028 AC_ARG_ENABLE(includes,
2029 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2030 [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`])
2032 if test "$aros_kernel_includes" = ""; then
2033     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2034         aros_kernel_includes="-isystem $aros_target_incl"
2035     fi
2038 if test "$aros_kernel_includes" != "" ; then
2039     dnl find out about the kernel cc's include path
2040     AC_MSG_CHECKING([for the kernel compiler's include path])
2041     if test "$aros_kernel_cc_includes" = "" ; then
2042         # Try to guess where the directory is.
2043         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2044         if test -d $aros_kernel_cc_includes; then
2045             # Check if there is also an include-fixed directory and add it
2046             # to kernel compiler's include path as it may contain some of
2047             # the headers we need.
2048             if test -d "$aros_kernel_cc_includes"-fixed; then
2049                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2050             fi
2051             # Check for specific includes directory. Neede for Ubuntu 11.10
2052             if test -d "/usr/include/i386-linux-gnu"; then
2053                 aros_kernel_cc_includes+=" -isystem /usr/include/i386-linux-gnu"
2054             fi
2055         else
2056             # The directory doesn't exist, we need to do some more work.
2057             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2059             # These are the headers we're looking for.
2060             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2061                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2062                      zutil.h stdint.h"
2064             dirs=
2065             for h in $headers; do
2066                 # Which other headers are needed by each of the above?
2067                 deps=$(echo "#include <$h>" | \
2068                        $aros_kernel_cc -E -M - 2>/dev/null | \
2069                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2071                 # Copy all the needed headers to a directory beneath gendir.
2072                 for d in $deps; do
2073                     h=$(basename $d)
2074                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2075                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2076                     ! test -d $dir && mkdir -p $dir
2077                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2078                 done
2079             done            
2080         fi
2081     fi
2082     AC_MSG_RESULT($aros_kernel_cc_includes)
2083     # Adding -nostdinc to kernel includes as they are always used together.
2084     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2087 if test "$crosstools" != "yes"; then
2088     dnl find out about the target cc's include path
2089     AC_MSG_CHECKING([for the target compiler's include path])
2090     if test "$aros_target_cc_includes" = "" ; then
2091         #try to guess where the directory is
2092         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2093         if ! test -d $aros_target_cc_includes; then
2094             #the directory doesn't exist, we need to do some more work
2095             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2096         
2097             #these are the headers we're looking for
2098             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2099                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2100                     zutil.h"
2102             dirs=
2103             for h in $headers; do
2104                 #which other headers each of the above headers needs?
2105                 deps=$(echo "#include <$h>" | \
2106                     $orig_target_cc -E -M - 2>/dev/null | \
2107                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2108             
2109                 #copy all the needed headers to a directory beneath gendir
2110                 for d in $deps; do
2111                     h=$(basename $d)
2112                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2113                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2114                     ! test -d $dir && mkdir -p $dir
2115                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2116                 done
2117             done
2118         fi
2119     fi
2120     AC_MSG_RESULT($aros_target_cc_includes)
2121 else
2122     # We do not know which gcc version we are going to build and what we need to know
2123     # here is different for different versions so this will be set later during the
2124     # build of crosstools.
2125     aros_target_cc_includes=@aros_target_cc_includes@
2129 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2130 # On GCC >= 4.0 -iquote should be used
2133 save_cc="$CC"
2134 save_cflags="$CFLAGS"
2135 CFLAGS="-iquote."
2136 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2137 if test "x-$crosstools" != "x-yes"; then
2138     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2139 else
2140     # we do know it is supported for the smallest version of gcc we are going to build
2141     # we assume it's also supported by later versions
2142     has_iquote=yes
2144 AC_MSG_RESULT($has_iquote)
2145 if test "x-$has_iquote" = "x-yes" ; then
2146     host_cflags_iquote=-iquote
2147     host_cflags_iquote_end=
2148 else
2149     host_cflags_iquote=-I
2150     host_cflags_iquote_end=-I-
2152 kernel_cflags_iquote=$host_cflags_iquote
2153 kernel_cflags_iquote_end=$host_cflags_iquote_end
2154 if test "x-$cross_compiling" = "x-yes"; then
2155     CC="$aros_kernel_cc"
2156     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2157     if test "x-$crosstools" != "x-yes"; then
2158         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2159     else
2160         # we do know it is supported for the smallest version of gcc we are going to build
2161         # we assume it's also supported by later versions
2162         use_no_stack_protector=yes
2163     fi
2164     AC_MSG_RESULT($use_no_stack_protector)
2165     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2166     if test "x-$crosstools" != "x-yes"; then
2167         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2168     else
2169         # we do know it is supported for the smallest version of gcc we are going to build
2170         # we assume it's also supported by later versions
2171         has_iquote=yes
2172     fi
2173     AC_MSG_RESULT($has_iquote)
2174     if test "x-$has_iquote" = "x-yes" ; then
2175         kernel_cflags_iquote=-iquote
2176         kernel_cflags_iquote_end=
2177     else
2178         kernel_cflags_iquote=-I
2179         kernel_cflags_iquote_end=-I-
2180     fi
2182 aros_cflags_iquote=$kernel_cflags_iquote
2183 aros_cflags_iquote_end=$kernel_cflags_iquote_end
2184 if test "$orig_target_cc" != "$aros_kernel_cc"; then
2185     CC="$orig_target_cc"
2186     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2187     if test "x-$crosstools" != "x-yes"; then
2188         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2189     else
2190         # we do know it is supported for the smallest version of gcc we are going to build
2191         # we assume it's also supported by later versions
2192         has_iquote=yes
2193     fi
2194     AC_MSG_RESULT($has_iquote)
2195     if test "x-$has_iquote" = "x-yes" ; then
2196         aros_cflags_iquote=-iquote
2197         aros_cflags_iquote_end=
2198     else
2199         aros_cflags_iquote=-I
2200         aros_cflags_iquote_end=-I-
2201     fi
2203 if test "x-$use_no_stack_protector" = "x-yes" ; then
2204     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2208 #-----------------------------------------------------------------------------
2210 # Check if the target compiler supports some options used for delinting:
2211 #  -Wunused-but-set-variable
2212 #  -Warray-bounds
2213 #  -Wenum-compare
2214 #  -Wstrict-overflow
2215 #  -Wformat-security
2217 if test "x-$crosstools" != "x-yes"; then
2218     if test "$orig_target_cc" != "$aros_kernel_cc"; then
2219         CC="$orig_target_cc"
2220     fi
2221     AC_MSG_CHECKING([whether ${CC} accepts -Wunused-but-set-variable])
2222     CFLAGS=-Wunused-but-set-variable
2223     AC_TRY_COMPILE(,, aros_unused_but_set_variable="yes", aros_unused_but_set_variable="no")
2224     AC_MSG_RESULT($aros_unused_but_set_variable)
2225     if test "x-$aros_unused_but_set_variable" = "x-yes" ; then
2226         aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable
2227     fi
2229     AC_MSG_CHECKING([whether ${CC} accepts -Warray-bounds])
2230     CFLAGS=-Warray-bounds
2231     AC_TRY_COMPILE(,, aros_array_bounds="yes", aros_array_bounds="no")
2232     AC_MSG_RESULT($aros_array_bounds)
2233     if test "x-$aros_array_bounds" = "x-yes" ; then
2234         aros_cflags_array_bounds=-Wno-array-bounds
2235     fi
2237     AC_MSG_CHECKING([whether ${CC} accepts -Wenum-compare])
2238     CFLAGS=-Wenum-compare
2239     AC_TRY_COMPILE(,, aros_enum_compare="yes", aros_enum_compare="no")
2240     AC_MSG_RESULT($aros_enum_compare)
2241     if test "x-$aros_enum_compare" = "x-yes" ; then
2242         aros_cflags_enum_compare=-Wno-enum-compare
2243     fi
2245     AC_MSG_CHECKING([whether ${CC} accepts -Wstrict-overflow])
2246     CFLAGS=-Wstrict-overflow
2247     AC_TRY_COMPILE(,, aros_strict_overflow="yes", aros_strict_overflow="no")
2248     AC_MSG_RESULT($aros_strict_overflow)
2249     if test "x-$aros_strict_overflow" = "x-yes" ; then
2250         aros_cflags_strict_overflow=-Wno-strict-overflow
2251     fi
2253     AC_MSG_CHECKING([whether ${CC} accepts -Wformat-security])
2254     CFLAGS=-Wformat-security
2255     AC_TRY_COMPILE(,, aros_format_security="yes", aros_format_security="no")
2256     AC_MSG_RESULT($aros_format_security)
2257     if test "x-$aros_format_security" = "x-yes" ; then
2258         aros_cflags_format_security=-Wno-format-security
2259     fi
2260 else
2261     # We do not know which gcc version we are going to build and what we need to know
2262     # here is different for different versions so this will be set later during the
2263     # build of crosstools.
2264     aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@
2265     aros_cflags_array_bounds=@aros_cflags_array_bounds@
2266     aros_cflags_enum_compare=@aros_cflags_enum_compare@
2267     aros_cflags_strict_overflow=@aros_cflags_strict_overflow@
2268     aros_cflags_format_security=@aros_cflags_format_security@
2271 #-----------------------------------------------------------------------------
2273 # Check if we can explicitly choose older version of symbol hashing
2275 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2276 CC="$aros_kernel_cc"
2277 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2278 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2279 AC_MSG_RESULT($use_hash_style)
2280 if test "x-$use_hash_style" = "x-yes" ; then
2281     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2283 CC="$save_cc"
2284 CFLAGS="$save_cflags"
2286 AC_SUBST(host_cflags_iquote)
2287 AC_SUBST(host_cflags_iquote_end)
2288 AC_SUBST(kernel_cflags_iquote)
2289 AC_SUBST(kernel_cflags_iquote_end)
2290 AC_SUBST(aros_cflags_iquote)
2291 AC_SUBST(aros_cflags_iquote_end)
2294 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2295 AC_MSG_CHECKING([for default resolution of WBScreen])
2296 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2297 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2298 if test "$resolution" = "yes" ; then
2299     resolution="none"
2301 if test "$resolution" = "no" ; then
2302     resolution="none"
2304 if test "$resolution" != "none" ; then
2305     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
2306     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
2307     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
2309 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
2310 aros_cv_default_wbwidth=$aros_default_wbwidth
2311 aros_cv_default_wbheight=$aros_default_wbheight
2312 aros_cv_default_wbdepth=$aros_default_wbdepth
2314 dnl See if the user wants the serial debug output for native flavour
2315 AC_MSG_CHECKING([if serial debug is enabled])
2316 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)
2317 if test "$aros_serial_debug" = 0 ; then
2318     serial_debug_forced=""
2319     if test "$serial_debug" = "yes" ; then
2320         serial_debug="1"
2321     fi
2322     if test "$serial_debug" = "no" ; then
2323         serial_debug="none"
2324     fi
2325 else
2326     serial_debug_forced="(forced)"
2327     serial_debug=$aros_serial_debug
2329 if test "$serial_debug" != "none" ; then
2330     aros_serial_debug=$serial_debug
2331     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2332 else
2333     AC_MSG_RESULT(no)
2336 dnl See if the user wants the palm debug output hack for palm native flavour
2337 AC_MSG_CHECKING([if palm debug hack is enabled])
2338 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")
2339 if test "$palm_debug_hack" = "yes" ; then
2340     aros_palm_debug_hack="1"
2342 AC_MSG_RESULT($palm_debug_hack)
2344 dnl See if dev wants the usb3.0 code
2345 AC_MSG_CHECKING([if usb3.0 code is enabled])
2346 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2347 if test "$usb30_code" = "yes" ; then
2348     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2349     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2351 AC_MSG_RESULT($usb30_code)
2353 dnl See if the user wants nesting supervisor activated for unix flavour
2354 AC_MSG_CHECKING([if nesting supervisor support is enabled])
2355 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")
2356 if test "$nesting_supervisor" = "yes" ; then
2357     aros_nesting_supervisor="1"
2359 AC_MSG_RESULT($nesting_supervisor)
2361 dnl See if the user wants to disable MMU support
2362 dnl This can be overriden on per-target basis,
2363 dnl set $aros_enable_mmu to "yes" or "no" to do this
2364 if test "$aros_enable_mmu" = "" ; then
2365     AC_MSG_CHECKING([if MMU support is enabled])
2366     dnl Enabled by default
2367     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2368     if test "$aros_enable_mmu" = "" ; then
2369         aros_enable_mmu="yes"
2370     fi
2371     AC_MSG_RESULT($aros_enable_mmu)
2373 if test "$aros_enable_mmu" = "no" ; then
2374     aros_enable_mmu="0"
2375 else
2376     aros_enable_mmu="1"
2378     
2380 dnl things specifically required for hosted flavours
2381 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2383     if test "x-$need_dlopen" != "x-no" ; then
2384       save_libs="$LIBS"
2385       LIBS=""
2386       dnl some kind of dynamic library access system is required for hostlib.resource
2387       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2388       if test "x-$have_dl" = "x-no" ; then
2389           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2390                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2391                                     have_dl="no")
2392       fi
2393       if test "x-$have_dl" = "x-no" ; then
2394           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2395       fi
2396       LIBS="$save_libs"
2397     fi
2400     dnl x11 hidd
2401     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2402                                            [build X11 hidd for hosted (default=auto)]),
2403                                            x11_hidd="$enableval",
2404                                            x11_hidd="$need_x11")
2405     case "x-$x11_hidd" in
2406         x-yes|x-no|x-auto)                 ;;
2407         *)                 x11_hidd="$need_x11" ;;
2408     esac
2410     ENABLE_X11=0
2412     dnl they want it
2413     if test "x-$x11_hidd" != "x-no" ; then
2415         dnl find x11 stuff
2416         AC_PATH_X
2418         x_cflags=
2419         for path in $x_libraries
2420         do
2421             x_cflags="$x_cflags -L$path"
2422         done
2424         for path in $x_includes
2425         do
2426             x_cflags="$x_cflags -I$path"
2427         done
2428         
2429         if test "x-$no_x" = "x-yes" ; then
2431             dnl didn't find it
2432             if test "x-$x11_hidd" != "x-auto" ; then
2433                 dnl and they explicitly asked for it, bail out
2434                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2435             fi
2436         
2437         else
2438             dnl found it, setup the metatarget
2439             unixgfx_hidd_target=kernel-x11gfx
2440             ENABLE_X11=1
2442             dnl setup shared memory extensions
2443             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2444                                                   [use X11 shared memory (default=auto)]),
2445                                                   x11_hidd_shm="$enableval",
2446                                                   x11_hidd_shm="auto")
2447             case "x-$x11_hidd_shm" in
2448                 x-yes|x-no|x-auto)                     ;;
2449                 *)                 x11_hidd_shm="auto" ;;
2450             esac
2452             have_xshm=no
2454             dnl they want it
2455             if test "x-$x11_hidd_shm" != "x-no" ; then
2457                 dnl system shm headers
2458                 AC_CHECK_HEADERS(sys/ipc.h)
2459                 AC_CHECK_HEADERS(sys/shm.h)
2461                 dnl got them
2462                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2464                     dnl make sure X libs have shm functions
2465                     save_cflags="$CFLAGS"
2466                     CFLAGS="$CFLAGS $x_cflags"
2467                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2468                     CFLAGS="$save_cflags"
2469                 fi
2470             fi
2472             dnl detection done, prepare output
2473             if test "x-$have_xshm" = "x-yes" ; then
2474                 dnl we can do shm
2475                 DO_XSHM_SUPPORT="1"
2476             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2477                 dnl they explicitly asked for it, but we can't do it
2478                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2479             else
2480                 dnl otherwise just disable it
2481                 DO_XSHM_SUPPORT="0"
2482             fi
2484             
2485             dnl setup vidmode (fullscreen) extensions
2486             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2487                                                       [use X11 vidmode extension (default=auto)]),
2488                                                       x11_hidd_vidmode="$enableval",
2489                                                       x11_hidd_vidmode="auto")
2490             case "x-$x11_hidd_vidmode" in
2491                 x-yes|x-no|x-auto)                         ;;
2492                 *)                 x11_hidd_vidmode="auto" ;;
2493             esac
2495             have_vidmode=no
2497             dnl they want it
2498             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2500                 dnl make sure X libs have vidmode functions
2501                 save_cflags="$CFLAGS"
2502                 CFLAGS="$CFLAGS $x_cflags"
2503                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2504                 CFLAGS="$save_cflags"
2505             fi
2507             dnl detection done, prepare output
2508             if test "x-$have_vidmode" = "x-yes" ; then
2509                 dnl we can do vidmode
2510                 DO_VIDMODE_SUPPORT="1"
2511             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2512                 dnl they explicitly asked for it, but we can't do it
2513                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2514             else
2515                 dnl otherwise just disable it
2516                 DO_VIDMODE_SUPPORT="0"
2517             fi
2518         fi
2520         aros_host_x11_includes=$x_includes 
2521         aros_host_x11_libdirs=$x_libraries
2522     fi
2525     dnl sdl hidd
2526     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2527                                            [build SDL hidd for hosted (default=auto)]),
2528                                            sdl_hidd="$enableval",
2529                                            sdl_hidd="auto")
2530     case "x-$sdl_hidd" in
2531         x-yes|x-no|x-auto)                 ;;
2532         *)                 sdl_hidd="auto" ;;
2533     esac
2535     dnl they want it
2536     if test "x-$sdl_hidd" != "x-no" ; then
2538         dnl find sdl
2539         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
2541         if test "x-$have_sdl" != "x-yes" ; then
2543             dnl didn't find it
2544             if test "x-$sdl_hidd" != "x-auto" ; then
2545                 dnl and they explicitly asked for it, bail out
2546                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2547             fi
2549         else
2550             dnl found it, set up the metatarget
2551             sdl_hidd_target=kernel-hidd-sdl
2552             aros_host_sdl_cflags=SDL_CFLAGS
2553             aros_host_sdl_libs=SDL_LIBS
2554         fi
2555     fi
2557     dnl oss.library
2558     AC_CHECK_HEADER(sys/soundcard.h)
2559     if test "x-$ac_cv_header_sys_soundcard_h" = "x-yes" ; then
2560         oss_library_target=workbench-libs-oss-unix
2561     fi
2565 dnl See if the user wants dbus.library
2566 AC_MSG_CHECKING([if building of dbus.library is enabled])
2567 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2568 if test "$dbus" = "yes" ; then
2569     ENABLE_DBUS=1
2570     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2571     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2572     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2573     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2574 else
2575     ENABLE_DBUS=0
2577 AC_MSG_RESULT($dbus)
2579 if test "$use_kernel_cc_wrapper" = "yes" ; then
2580     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc"
2583 dnl --------------------------------------------------------------------
2584 dnl Configuration Output Section
2585 dnl --------------------------------------------------------------------
2587 # Generic
2588 AC_SUBST(aros_arch)
2589 AC_SUBST(aros_cpu)
2590 AC_SUBST(aros_flavour)
2591 AC_SUBST(aros_flavour_uc)
2592 AC_SUBST(aros_target_toolchain)
2593 AC_SUBST(AROS_BUILDDIR)
2594 AC_SUBST(AROS_BUILDDIR_UNIX)
2595 AC_SUBST(SRCDIR)
2596 AC_SUBST(AROS_CROSSTOOLSDIR)
2597 AC_SUBST(AROS_PORTSSRCDIR)
2599 # Compatability with other Amiga-like operation systems
2600 AC_SUBST(aros_amigaos_compliance)
2602 # Host related
2603 AC_SUBST(aros_cc_pre)
2604 AC_SUBST(aros_host_strip)
2605 AC_SUBST(aros_host_arch)
2606 AC_SUBST(aros_host_cpu)
2607 AC_SUBST(aros_host_cpp)
2608 AC_SUBST(aros_host_cc)
2609 AC_SUBST(aros_host_cxx)
2610 AC_SUBST(aros_host_ar)
2611 AC_SUBST(aros_host_ranlib)
2612 AC_SUBST(aros_host_ld)
2613 AC_SUBST(aros_host_make)
2614 AC_SUBST(aros_host_cflags)
2615 AC_SUBST(aros_host_cxxflags)
2616 AC_SUBST(gnu89_inline)
2617 AC_SUBST(aros_host_ldflags)
2618 AC_SUBST(aros_host_debug)
2619 AC_SUBST(aros_host_mkdep)
2620 AC_SUBST(aros_host_mkargs)
2621 AC_SUBST(aros_host_exe_suffix)
2622 AC_SUBST(aros_host_lib_suffix)
2623 AC_SUBST(aros_tools_dir)
2624 AC_SUBST(aros_host_aclocal)
2625 AC_SUBST(aros_host_autoconf)
2626 AC_SUBST(aros_host_autoheader)
2627 AC_SUBST(aros_host_automake)
2628 AC_SUBST(ant)
2630 # Target Related
2631 AC_SUBST(aros_target_guitheme)
2632 AC_SUBST(aros_target_iconset)
2633 AC_SUBST(aros_target_bootloader)
2634 AC_SUBST(aros_target_arch)
2635 AC_SUBST(aros_target_family)
2636 AC_SUBST(aros_target_cpu)
2637 AC_SUBST(aros_target_variant)
2638 AC_SUBST(aros_target_suffix)
2639 AC_SUBST(aros_target_ar)
2640 AC_SUBST(aros_target_ranlib)
2641 AC_SUBST(aros_plain_nm)
2642 AC_SUBST(aros_plain_ar)
2643 AC_SUBST(aros_kernel_ar)
2644 AC_SUBST(aros_kernel_ranlib)
2645 AC_SUBST(orig_target_cc)
2646 AC_SUBST(aros_target_cc)
2647 AC_SUBST(aros_kernel_cc)
2648 AC_SUBST(orig_target_cxx)
2649 AC_SUBST(aros_target_cxx)
2650 AC_SUBST(aros_kernel_cxx)
2651 AC_SUBST(orig_target_cpp)
2652 AC_SUBST(aros_target_cpp)
2653 AC_SUBST(aros_kernel_cpp)
2654 AC_SUBST(orig_target_as)
2655 AC_SUBST(aros_target_as)
2656 AC_SUBST(aros_kernel_as)
2657 AC_SUBST(orig_target_ld)
2658 AC_SUBST(aros_target_ld)
2659 AC_SUBST(aros_kernel_ld)
2660 AC_SUBST(aros_target_cc_includes)
2661 AC_SUBST(aros_target_cc_path)
2662 AC_SUBST(aros_target_objdump)
2663 AC_SUBST(aros_target_objcopy)
2664 AC_SUBST(aros_target_strip)
2665 AC_SUBST(aros_target_nm)
2666 AC_SUBST(aros_kernel_rescomp)
2667 AC_SUBST(aros_shared_default)
2668 AC_SUBST(aros_shared_ld)
2669 AC_SUBST(aros_object_format)
2670 AC_SUBST(spec_obj_format)
2671 AC_SUBST(aros_compiler_libs)
2672 AC_SUBST(aros_arch_libs)
2674 AC_SUBST(aros_config_cflags)
2675 AC_SUBST(aros_config_aflags)
2676 AC_SUBST(aros_config_ldflags)
2678 AC_SUBST(aros_shared_cflags)
2679 AC_SUBST(aros_shared_aflags)
2680 AC_SUBST(aros_shared_ldflags)
2681 AC_SUBST(aros_kernel_cflags)
2682 AC_SUBST(aros_kernel_includes)
2683 AC_SUBST(aros_kernel_objcflags)
2684 AC_SUBST(aros_kernel_ldflags)
2685 AC_SUBST(aros_target_cflags)
2686 AC_SUBST(aros_debug_cflags)
2687 AC_SUBST(aros_debug_aflags)
2688 AC_SUBST(aros_debug_ldflags)
2689 AC_SUBST(aros_target_genmap)
2690 AC_SUBST(aros_target_strip_flags)
2691 AC_SUBST(aros_optimization_cflags)
2692 AC_SUBST(aros_isa_flags)
2694 AC_SUBST(crosstools_target)
2695 AC_SUBST(crosstools_cxx_target)
2697 # Delinting target compiler flags
2698 AC_SUBST(aros_cflags_unused_but_set_variable)
2699 AC_SUBST(aros_cflags_array_bounds)
2700 AC_SUBST(aros_cflags_enum_compare)
2701 AC_SUBST(aros_cflags_strict_overflow)
2702 AC_SUBST(aros_cflags_format_security)
2704 # Graphics Related
2705 AC_SUBST(unixgfx_hidd_target)
2706 AC_SUBST(sdl_hidd_target)
2707 AC_SUBST(pci_hidd_target)
2708 AC_SUBST(oss_library_target)
2710 AC_SUBST(aros_default_wbwidth)
2711 AC_SUBST(aros_default_wbheight)
2712 AC_SUBST(aros_default_wbdepth)
2713 AC_SUBST(DO_XSHM_SUPPORT)
2714 AC_SUBST(DO_VIDMODE_SUPPORT)
2716 AC_SUBST(aros_host_x11_includes)
2717 AC_SUBST(aros_host_x11_libdirs)
2718 AC_SUBST(aros_host_sdl_cflags)
2719 AC_SUBST(aros_host_sdl_libs)
2721 # Native version related
2722 AC_SUBST(aros_serial_debug)
2724 # Palm native version related
2725 AC_SUBST(aros_palm_debug_hack)
2727 # Unix/Hosted version related
2728 AC_SUBST(aros_nesting_supervisor)
2730 # MMU related
2731 AC_SUBST(aros_enable_mmu)
2733 # Apple iOS related
2734 AC_SUBST(aros_ios_platform)
2735 AC_SUBST(aros_ios_version)
2736 AC_SUBST(aros_ios_sdk)
2738 # ARM default GCC target related
2739 AC_SUBST(gcc_default_cpu)
2740 AC_SUBST(gcc_default_cpu_tune)
2741 AC_SUBST(gcc_default_fpu)
2742 AC_SUBST(gcc_default_float_abi)
2744 # Android related
2745 AC_SUBST(android_tool)
2746 AC_SUBST(aros_android_level)
2747 AC_SUBST(aros_android_antapk)
2749 # DBUS related
2750 AC_SUBST(ENABLE_DBUS)
2751 AC_SUBST(DBUS_CFLAGS)
2752 AC_SUBST(DBUS_LIBFLAGS)
2753 AC_SUBST(KERNEL_DBUS_KOBJ)
2754 AC_SUBST(KERNEL_DBUS_INCLUDES)
2756 #X11 related
2757 AC_SUBST(ENABLE_X11)
2759 # Debug related
2760 AC_SUBST(aros_debug)
2761 AC_SUBST(aros_mungwall_debug)
2762 AC_SUBST(aros_stack_debug)
2763 AC_SUBST(aros_modules_debug)
2765 # Collect-aros stuff: "-ius" to ignore undefined symbols
2766 AC_SUBST(ignore_undefined_symbols)
2768 # C compiler related
2769 AC_SUBST(gcc_target_cpu)
2770 AC_SUBST(target_gcc_version)
2772 #ObjC compiler related
2773 AC_SUBST(objc_target)
2775 #Java related
2776 AC_SUBST(java_target)
2778 # USB3.0 code
2779 AC_SUBST(aros_usb30_code)
2781 dnl Prepare for output, make up all the generated patches
2782 case "$aros_flavour" in
2783 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2784                 aros_flavour="emulation" ;;
2785 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2786                 aros_flavour="emulation" ;;
2787 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2788                 aros_flavour="standalone";;
2789 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2790                 aros_flavour="standalone";;
2791 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2792                 aros_flavour="native" ;;
2793 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2794                 aros_flavour="native" ;;
2795 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2796                 aros_flavour="linklib" ;;
2797 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2798                 aros_flavour="palmnative" ;;
2799 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2800                 aros_flavour="mac68knative" ;;
2801 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2802                 aros_flavour="ppcnative" ;;
2803 esac
2805 if test ! -d ${aros_inc_dir} ; then
2806     ${MKDIR} ${aros_inc_dir}
2808 if test ! -d ${aros_geninc_dir} ; then
2809     ${MKDIR} ${aros_geninc_dir}
2811 if test ! -d ${aros_hostcfg_dir} ; then
2812     ${MKDIR} ${aros_hostcfg_dir}
2814 if test ! -d ${aros_targetcfg_dir} ; then
2815     ${MKDIR} ${aros_targetcfg_dir}
2817 if test ! -d ${aros_tools_dir} ; then
2818     ${MKDIR} ${aros_tools_dir}
2820 if test ! -d ${aros_scripts_dir} ; then
2821     ${MKDIR} ${aros_scripts_dir}
2824 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2826 # Generic build tools (metamake, etc)
2827 AC_CONFIG_COMMANDS([genmf-executable-support],
2828     [chmod a+x ${aros_tools_dir}/genmf.py],
2829     [aros_tools_dir=${aros_tools_dir}]
2831 AC_CONFIG_FILES(
2832     Makefile
2833     config/make.cfg
2834     ${aros_inc_dir}/config.h:config/config.h.in
2835     ${aros_geninc_dir}/config.h:config/config.h.in
2836     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2837     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2838     mmake.config
2839     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2840     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2841     tools/collect-aros/env.h
2844 # Binutils
2845 AC_CONFIG_COMMANDS([binutils-support],
2846     [
2847         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2848         mkdir -p $prefix
2849         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2851         chmod a+x ${prefix2}-ld
2853         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
2854         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
2855         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
2856         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
2857         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
2858         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
2859         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
2860     ],
2861     [
2862         aros_host_exe_suffix=${aros_host_exe_suffix}
2863         aros_tools_dir=${aros_tools_dir}
2864         aros_target_cpu=${aros_target_cpu}
2865         aros_target_arch=${aros_target_arch}
2866         aros_target_suffix=${aros_target_suffix}
2867         orig_target_nm=${orig_target_nm}
2868         orig_target_as=${orig_target_as}
2869         orig_target_ar=${orig_target_ar}
2870         orig_target_ranlib=${orig_target_ranlib}
2871         orig_target_objdump=${orig_target_objdump}
2872         orig_target_objcopy=${orig_target_objcopy}
2873         orig_target_strip=${orig_target_strip}
2874         aros_kernel_ld=${aros_kernel_ld}
2875     ]
2877 AC_CONFIG_FILES(
2878     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
2881 # Bare Elf support script and spec
2882 if test "${use_kernel_cc_wrapper}" = "yes"; then
2883     AC_CONFIG_COMMANDS([elf-compiler-support],
2884         [
2885             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2886             mkdir -p $prefix
2887             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
2889             chmod a+x ${prefix2}-gcc
2891             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
2892         ],
2893         [
2894             aros_host_exe_suffix=${aros_host_exe_suffix}
2895             aros_tools_dir=${aros_tools_dir}
2896             aros_target_cpu=${aros_target_cpu}
2897             aros_target_arch=${aros_target_arch}
2898             aros_target_suffix=${aros_target_suffix}
2899             aros_kernel_ld=${aros_kernel_ld}
2900         ]
2901     )
2902     AC_CONFIG_FILES(
2903         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
2904         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
2905     )
2908 # Host compiler support scripts and spec
2909 if test "${aros_target_toolchain}" = "no"; then
2910     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
2911         [
2912             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2913             mkdir -p $prefix
2914             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2916             chmod a+x ${prefix2}-gcc ${prefix2}-g++ ${prefix2}-cpp
2917         ],
2918         [
2919             aros_host_exe_suffix=${aros_host_exe_suffix}
2920             aros_tools_dir=${aros_tools_dir}
2921             aros_target_cpu=${aros_target_cpu}
2922             aros_target_arch=${aros_target_arch}
2923             aros_target_suffix=${aros_target_suffix}
2924         ]
2925     )
2926     AC_CONFIG_FILES(
2927         ${aros_targetcfg_dir}/specs:config/specs.in
2928         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-cpp:scripts/aros-cpp.in
2929         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
2930         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-g++:scripts/aros-g++.in
2931     )
2934 # Android support
2935 if test "$aros_target_variant" == "android"; then
2936     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
2939 AC_OUTPUT
2941 dnl This is in order to not define SHARED_CFLAGS sometimes
2942 dnl We don't always do aros_shared_ar, aros_shared_cflags
2944 #XXX compatability...
2945 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
2947 if test -n "$aros_shared_cflags" ; then
2948     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
2949     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg