Experimental scons files removed. It should somehow be possible to build AROS with...
[AROS.git] / configure.in
blob8546a55307811f19e3fecd303d6de1658c0045f4
1 dnl Copyright © 1997-2011, 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 dnl --------------------------------------------------------------------
65 dnl Set the default Workbench resolution
66 dnl --------------------------------------------------------------------
67 aros_default_wbwidth=800
68 aros_default_wbheight=600
69 aros_default_wbdepth=4
71 dnl --------------------------------------------------------------------
72 dnl Host Configuration Section
73 dnl --------------------------------------------------------------------
74 dnl
75 dnl The idea here is to find out all the information we need about the
76 dnl host. This means things like tools for building directory structures,
77 dnl copying files around and the like.
79 # The first step is to find the host binaries.
80 # Check for a compiler.
81 AC_PROG_CC
82 AC_PROG_CC_STDC
83 AC_PROG_CPP
85 # Check for a compatible awk
86 AC_CHECK_PROGS(AWK,[gawk nawk])
87 AROS_REQUIRED(gawk,$AWK)
88 AROS_PROG(MMAKE,mmake)
90 # Perform some default variable assignments. Note all of these will be
91 # Regenerated from the script, so there is no need to cache them.
93 aros_host_cc="$CC"
94 AROS_TOOL_CCPATH(aros_host_ld,ld)
95 AROS_REQUIRED(ld,$aros_host_ld)
96 aros_host_make="make"
97 aros_host_cflags=$CFLAGS
98 aros_host_ldflags=$LDFLAGS
99 aros_host_debug="-g -O0"
100 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
101 aros_host_mkargs="--no-print-directory"
102 aros_host_incl="/usr/include"
103 aros_host_exe_suffix="$EXEEXT"
104 aros_host_lib_suffix=""
106 # Ignore all compliance, AROS ROMs = 0
107 # KickStart v1.0 = 30
108 # KickStart v1.3 = 34
109 # KickStart v2.0 = 37
110 # KickStart v3.0 = 39
111 # KickStart v3.1 = 40
112 # AmigaOS   v3.5 = 44
113 aros_amigaos_compliance=0
115 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
116 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
117 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
118 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
120 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
121 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
123 case "$aros_host_cc" in
124     *gcc*)
125         aros_host_cc_pipe="-pipe"
126         ;;
127     icc)
128         aros_host_cc_pipe=""
129         ;;
130     *)
131         aros_host_cc_pipe=""
132         ;;
133 esac
135 aros_kernel_cc_includes=""
136 aros_target_cc_includes=""
138 # ----------------------------------------------------------------------------------------
139 # Host-specific defaults
141 # Override this to "yes" in order to force a specific build to use real AROS crosscompiler
142 # instead of a wrapper script.
143 # Useful for non-ELF hosts (like Windows and Darwin).
144 # Can also be overriden in target section below
145 use_aros_gcc="no"
147 # This is the main host configuration section. It is where the host
148 # can change the values of any variables it needs to change. We do
149 # not look at anything that compiles to the target yet, we'll get
150 # to that later.
152 case "$host_os" in
153     aros*)
154         aros_host_arch="aros"
155         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
156         case "$host_cpu" in
157             *i?86*)
158                 aros_host_cpu="i386"
159                 ;;
160             *x86_64*)
161                 aros_host_cpu="x86_64"
162                 ;;
163             *powerpc*)
164                 aros_host_cpu="ppc"
165                 ;;
166             *)
167                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
168                 aros_host_cpu="$host_cpu"
169                 ;;
170         esac
171         ;;
173     linux*)
174         aros_host_arch="linux"
175         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
176         android_build_os="linux-x86"
177         android_tool="android"
178         default_android_sdk="/opt/android-sdk-linux_x86"
179         case "$host_cpu" in
180             *i?86*)
181                 aros_host_cpu="i386"
182                 ;;
183             *x86_64*)
184                 aros_host_cpu="x86_64"
185                 ;;
186             *m68k*)
187                 aros_host_cpu="m68k"
188                 ;;
189             *powerpc*)
190                 aros_host_cpu="ppc"
191                 ;;
192             *arm*)
193                 aros_host_cpu="arm"
194                 ;;
195             *)
196                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
197                 aros_host_cpu="$host_cpu"
198                 ;;
199         esac
200         ;;
202     freebsd*)
203         aros_host_cc="$aros_host_cc $aros_host_cc_pipe -I/usr/local/include"
204         aros_host_make="gmake"
205         aros_host_arch="freebsd"
206         aros_host_cpu="i386"
208         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
210         dnl FreeBSD 5.x (and later) has changed the default object format.
211         dnl The double [[]] is necessary to get around m4's quoting rules.
212         case $host_os in
213             freebsd[[234]]*)
214                 aros_object_format="elf_i386"
215                 ;;
217             *)
218                 aros_object_format="elf_i386_fbsd"
219                 ;;
220         esac
222         ;;
224     darwin*)
225         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
226         aros_host_arch="darwin"
227         use_aros_gcc="yes"
228         android_build_os="darwin-x86"
229         android_tool="android"
230         default_android_sdk="/android-sdk-mac_x86"
231         case "$host_cpu" in
232             *i?86*)
233                 aros_host_cpu="i386"
234                 ;;
235             *x86_64*)
236                 aros_host_cpu="x86_64"
237                 ;;
238             *powerpc*)
239                 aros_host_cpu="ppc"
240                 ;;
241             *)
242                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
243                 aros_host_cpu="$host_cpu"
244                 ;;
245         esac
247         aros_host_ldflags="$aros_host_ldflags -liconv"
249         ;;
251     dragonfly*)
252         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
253         aros_host_make="gmake"
254         aros_host_arch="dragonfly"
255         case $host_cpu in
256             *i?86*)
257                 aros_host_cpu="i386"
258                 ;;
259             *amd64*)
260                 aros_host_cpu="x86_64"
261                 ;;
262             *)
263                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
264                 aros_host_cpu="$host_cpu"
265                 ;;
266         esac
267         ;;
269     netbsd*)
270         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
271         aros_host_make="gmake"
272         aros_host_arch="netbsd"
273         case "$host_cpu" in
274             *i?86*)
275                 aros_host_cpu="i386"
276                 ;;
277             *m68k*)
278                 aros_host_cpu="m68k"
279                 ;;
280             *)
281                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
282                 aros_host_cpu="$host_cpu"
283                 ;;
284         esac    
285         aros_host_lib_suffix=".0.0"
286         ;;
288     openbsd*)
289         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
290         aros_host_make="gmake"
291         aros_host_arch="openbsd"
292         case "$host_cpu" in
293             *i?86*)
294                 aros_host_cpu="i386"
295                 ;;
296             *)
297                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
298                 aros_host_cpu="$host_cpu"
299                 ;;
300         esac
301         ;;
302         
303     solaris*)
304         aros_host_arch="solaris"
305         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
306         case "$host_cpu" in
307             *i?86*)
308                 aros_host_cpu="i386"
309                 ;;
310             *sparc*)
311                 aros_host_cpu="sparc"
312                 ;;
313             *)
314                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
315                 aros_host_cpu="$host_cpu"
316                 ;;
317         esac
318         ;;
320     morphos*)
321         aros_host_arch="morphos"
322         aros_host_cpu="ppc"
323         ;;
325     amiga*)
326         aros_host_arch="amiga"
327         SORT="/gg/bin/sort"
328         TEST="/gg/bin/test"
329         UNIQ="/gg/bin/uniq"
330         FOR="for"
331         TOUCH="/gg/bin/touch"
332         case "$host_cpu" in
333             *m68k*)
334                 aros_host_cpu="m68k"
335                 ;;
336             *powerpc*)
337                 aros_host_cpu="ppc"
338                 ;;
339             *)
340                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
341                 aros_host_cpu="$host_cpu"
342                 ;;
343         esac
344         ;;
346     cygwin*)
347         aros_host_arch="cygwin"
348         use_aros_gcc="yes"
349         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
350         android_build_os="windows"
351         android_tool="android.bat"
352         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
354         case "$host_cpu" in
355             *i?86*)
356                 aros_host_cpu="i386"
357                 ;;
358             *)
359                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
360                 aros_host_cpu="$host_cpu"
361                 ;;
362         esac
363         ;;
365     mingw32*)
366         aros_host_arch="mingw32"
367         use_aros_gcc="yes"
368         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
369         android_build_os="windows"
370         android_tool="android.bat"
371         default_android_sdk="/c/android-sdk-windows-1.6_r1"
373         case "$host_cpu" in
374         *i?86*)
375             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
376             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
377             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
378             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
380             AC_MSG_CHECKING([for Windows native gcc target])
381             host_cpu=`gcc -dumpmachine`
382             AC_MSG_RESULT($host_cpu)
383             ;;
385         esac
387         case "$host_cpu" in
388         *i?86*)
389             aros_host_cpu="i386"
390             ;;
392         *x86_64*)
393             aros_host_cpu="x86_64"
394             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
395             dnl directory, so we have to add it explicitly here.
396             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
397             ;;
399         *)
400             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
401             aros_host_cpu="$host_cpu"
402             ;;
403         esac
404         ;;
405     *)
406         AC_MSG_ERROR([Unsupported host architecture $host])
407         ;;
408 esac
410 AROS_PROG(aros_host_ar,[ar],[cr])
411 AROS_REQUIRED(ar,$aros_host_ar)
412 AROS_PROG(aros_host_ranlib,ranlib)
413 AROS_REQUIRED(ranlib,$aros_host_ranlib)
414 AROS_PROG(aros_host_strip,strip)
415 AROS_REQUIRED(strip,$aros_host_strip)
417 AROS_PROG(RM,[rm],[-rf])
418 AROS_REQUIRED(rm,$RM)
419 AROS_PROG(CP,[cp])
420 AROS_REQUIRED(cp,$CP)
421 AROS_PROG(MV,[mv])
422 AROS_REQUIRED(mv,$MV)
423 AROS_PROG(ECHO,[echo])
424 AROS_REQUIRED(echo,$ECHO)
425 AROS_PROG(MKDIR,[mkdir],[-p])
426 AROS_REQUIRED(mkdir,$MKDIR)
427 AROS_PROG(TOUCH,[touch])
428 AROS_REQUIRED(touch,$TOUCH)
429 AROS_PROG(SORT,[sort])
430 AROS_REQUIRED(sort,$SORT)
431 AROS_PROG(UNIQ,[uniq])
432 AROS_REQUIRED(uniq,$UNIQ)
433 AROS_PROG(NOP,[true])
434 AROS_REQUIRED(true,$NOP)
435 AROS_PROG(CAT,[cat])
436 AROS_REQUIRED(cat,$CAT)
437 AROS_PROG(BISON,[bison])
438 AROS_REQUIRED(bison,$BISON)
439 AROS_PROG(FLEX,[flex])
440 AROS_REQUIRED(flex,$FLEX)
441 AROS_PROG(PNGTOPNM,[pngtopnm])
442 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
443 AROS_PROG(PPMTOILBM,[ppmtoilbm])
444 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
445 AROS_PROG(SED,[sed])
446 AROS_REQUIRED(sed,$SED)
447 AROS_PROG(CHMOD,[chmod])
448 AROS_REQUIRED(chmod,$CHMOD)
449 AROS_PROG(PATCH,[patch])
450 AROS_REQUIRED(patch,$PATCH)
452 AM_PATH_PYTHON(2.5)
454 AC_SUBST(FOR, for)
455 AC_SUBST(IF, if)
456 AC_SUBST(TEST, test)
457 AC_SUBST(CMP, cmp)
459 dnl ---------------------------------------------------------------------------
460 dnl Look for things about the host system, good for hosted targets.
461 dnl ---------------------------------------------------------------------------
463 # Check for some includes for the X11 HIDD and the kernel
464 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
465     sys/mmap.h sys/mman.h sysexits.h \
466     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
469 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
471 AC_HEADER_DIRENT
472 AC_HEADER_STAT
473 AC_HEADER_STDC
474 AC_HEADER_SYS_WAIT
475 AC_HEADER_TIME
476 AC_STRUCT_ST_BLKSIZE
477 AC_STRUCT_ST_BLOCKS
478 AC_STRUCT_ST_RDEV
479 AC_STRUCT_TM
480 AC_STRUCT_TIMEZONE
481 AC_TYPE_OFF_T
482 AC_TYPE_PID_T
483 AC_TYPE_SIZE_T
484 AC_TYPE_UID_T
486 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
488 # Look for some functions
489 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
490     clone kse_create rfork_thread thr_create sa_register \
491     getcontext makecontext setcontext sigaltstack swapcontext])
493 AC_FUNC_MMAP
496 dnl --------------------------------------------------------------------
497 dnl Target Configuration Section
498 dnl --------------------------------------------------------------------
500 dnl The target configuration section is responsible for setting up all
501 dnl the paths for includes, and tools required to build AROS to some
502 dnl particular target.
504 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
505 aros_config_aflags="-Wall -x assembler-with-cpp -c"
506 aros_config_ldflags=""
508 aros_shared_default=yes
510 aros_shared_cflags="-fPIC"
511 aros_shared_aflags=""
512 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
513 aros_kernel_ldflags="-Wl,-rpath,./lib"
515 aros_kernel_ar_flags="cr"
516 aros_target_ar_flags="cr"
517 aros_target_nm_flags="-C -ul"
518 aros_target_strip_flags="--strip-unneeded -R.comment"
520 aros_compiler_libs=
521 aros_arch_libs=
523 aros_target_genmap="-Wl,-Map -Xlinker"
525 # Native flavour stuff
526 aros_serial_debug="0"
528 # Palm native flavour stuff
529 aros_palm_debug_hack="0"
531 # Unix flavour stuff
532 aros_nesting_supervisor="0"
534 # Collect-aros stuff: "-ius" to ignore undefined symbols
535 ignore_undefined_symbols=""
537 # Check for X11 by default
538 need_x11="auto"
540 #-----------------------------------------------------------------------------
543 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
544 # it switched on by default, and we use the host compiler, so it compiles AROS
545 # code with this enabled resulting in link failures as we don't have support
546 # for it.
548 # We use two methods to disable it. For the host compiler (used to compile
549 # some hosted modules), we test to see if the compiler supports stack
550 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
551 # work on all platforms.
553 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
554 # (this is done unconditionally, as it should have no effect on compilers
555 # without the stack protection feature). This may be specific to the way that
556 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
557 # strong enough to disable it in a generic way though, so we'll live with it
558 # until another vendor ships GCC with it enabled in a different way, and deal
559 # with it then.
562 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
563 save_cflags="$CFLAGS"
564 CFLAGS="$CFLAGS -fno-stack-protector"
565 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
566 AC_MSG_RESULT($use_no_stack_protector)
567 if test "x-$use_no_stack_protector" = "x-yes" ; then
568     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
570 CFLAGS="$save_cflags"
572 #-----------------------------------------------------------------------------
574 # Disable pointer-signedness warnings if the compiler recognises the option
575 # (this only works for the host compiler at the moment)
577 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
578 save_cflags="$CFLAGS"
579 CFLAGS="$CFLAGS -Wno-pointer-sign"
580 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
581 AC_MSG_RESULT($use_no_sign_warning)
582 if test "x-$use_no_sign_warning" = "x-yes" ; then
583     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
585 CFLAGS="$save_cflags"
587 #-----------------------------------------------------------------------------
589 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
591 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
592 save_cflags="$CFLAGS"
593 CFLAGS="$CFLAGS -fgnu89-inline"
594 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
595 AC_MSG_RESULT($use_gnu89_inline)
596 if test "x-$use_gnu89_inline" = "x-yes" ; then
597     gnu89_inline="-fgnu89-inline"
599 CFLAGS="$save_cflags"
601 #-----------------------------------------------------------------------------
603 AC_MSG_CHECKING([for type of build])
604 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")
606 if test "$build_type" = "nightly"; then
607     build_type_string="NIGHTLY"
608 elif test "$build_type" = "snapshot"; then
609     build_type_string="SNAPSHOT"
610 elif test "$build_type" = "milestone"; then
611     build_type_string="MILESTONE"
612 elif test "$build_type" = "release"; then
613     build_type_string="RELEASE"
614 else
615     build_type_string="PERSONAL"
616     build_type="personal"
619 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
621 AC_MSG_RESULT($build_type)
623 #-----------------------------------------------------------------------------
624 all_debug_types="messages stack modules mungwall symbols"
626 AC_MSG_CHECKING([which debug types to enable])
627 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)]),
628  debug="$enableval",debug="")
630 if test "$debug" = "" -o "$debug" = "no"; then
631     debug="none"
632 elif test "$debug" = "yes"; then
633     debug="all"
636 if test "$debug" = "all" ; then
637     debug="messages stack modules symbols"
638     for d in $all_debug_types; do
639         export aros_${d}_debug="1"
640     done
641 else
642     for d in $all_debug_types; do
643         export aros_${d}_debug="0"
644     done
647 if test "$debug" != "none"; then
648     debug=`echo $debug | sed s/,/\ /g`
649     for d in $debug; do
650         found="0"
651         for d2 in $all_debug_types; do
652             if test "$d2" = "$d"; then
653                 found="1"
654                 break
655             fi
656         done
657         if test "$found" = "0"; then
658             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
659         fi
660         export aros_${d}_debug="1"
661     done
662     aros_debug="yes"
664 AC_MSG_RESULT($debug)
666 if test "$aros_messages_debug" = "1"; then
667     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
668 else
669     aros_messages_debug=""
671 if test "$aros_symbols_debug" = "1"; then
672     aros_symbols_debug="-g"
673 else
674     aros_symbols_debug=""
677 # These are the flags to pass when compiling debugged programs
678 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
679 aros_debug_aflags=""
680 aros_debug_ldflags="$aros_symbols_debug"
682 #-----------------------------------------------------------------------------
683 #   Checking if we should build crosstools..
684 AC_MSG_CHECKING([whether to build crosstools])
685 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--enable-crosstools],[Build cross-compiler toolchains if necessary (default=no).]),crosstools="$enableval",crosstools="no")
686 AC_MSG_RESULT($crosstools)
688 #-----------------------------------------------------------------------------
689 #   Checking for distcc and ccache.
691 #   Always apply the transforms in this particular order. Basically you should
692 #   always run 'ccache distcc compiler' in that order for the best performance.
694 AC_MSG_CHECKING([whether to enable distcc])
695 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
696 if test "$distcc" != "" -a "$distcc" != "no"; then
697     # AC_CHECK_PROG will print out the result in this case
698     AC_PATH_PROG(DISTCC,[distcc],distcc,)
699 else
700     AC_MSG_RESULT(no)
703 AC_MSG_CHECKING([whether to enable ccache])
704 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
705 if test "$ccache" != "" -a "$ccache" != "no"; then
706     # AC_CHECK_PROG will print out the result in this case
707     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
708 else
709     AC_MSG_RESULT(no)
712 #-----------------------------------------------------------------------------
713 AC_MSG_CHECKING([what specific host gcc version to use])
714 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Use host gcc-VERSION for building AROS]),target_tool_version="$withval",target_tool_version="default")
715 AC_MSG_RESULT($target_tool_version)
717 #-----------------------------------------------------------------------------
718 AC_MSG_CHECKING([what optimization flags to use])
719 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
720 if test "$optimization" = "unknown"; then
721     dnl default is -O2 for normal builds, -O0 for debug builds
722     if test "$debug" != "none"; then
723         optimization="-O0"
724     else
725         optimization="-O2"
726     fi
728 aros_config_cflags="$aros_config_cflags $optimization"
729 AC_MSG_RESULT($optimization)
731 #-----------------------------------------------------------------------------
732 AC_MSG_CHECKING([what paranoia flags to use])
733 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[CC flags to enable paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
734 if test "$paranoia_flags" = "default"; then
735         paranoia_flags=""
736 else if test "$paranoia_flags" = "yes"; then
737         paranoia_flags="-Wall -Werror"
738 fi fi
739 AC_MSG_RESULT($paranoia_flags)
740 aros_config_cflags="$aros_config_cflags $paranoia_flags"
742 #-----------------------------------------------------------------------------
743 AC_MSG_CHECKING([what target variant to enable])
744 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
745 if test "$target_variant" = ""; then
746     aros_target_variant=""
747     aros_target_suffix=""
748     enableval="none"
749 else
750     aros_target_variant="$target_variant"
751     aros_target_suffix="-$target_variant"
753 AC_MSG_RESULT($enableval)
755 #-----------------------------------------------------------------------------
756 # Target-specific defaults. You can override then on a per-target basis.
758 # Bootloader name. Currently used by PC target.
759 target_bootloader="none"
761 # Prefix for toolchain used to build bootstrap. For hosted ports, this should be a toolchain for target host OS.
762 # (i. e. when building mingw32-i386 port this should be set to "i386-mingw32-").
763 # For native ports this toolchain is used to build a bootloader and second-level bootstrap (if present).
764 if test "$crosstools" != "yes"; then
765     target_tool_prefix=${target_cpu}-elf-
766 else
767     target_tool_prefix=${target_cpu}-aros-
770 #-----------------------------------------------------------------------------
771 # Additional options for some specific targets
773 case "$aros_target_variant" in
774 ios)
775     AC_MSG_CHECKING([XCode path])
776     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")
777     AC_MSG_RESULT($aros_xcode_path)
779     AC_MSG_CHECKING([what iOS SDK version to use])
780     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")
781     AC_MSG_RESULT($aros_sdk_version)
783     ;;
785 "android")
786     AC_MSG_CHECKING([Android SDK path])
787     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)
788     AC_MSG_RESULT($aros_android_sdk)
790     AC_MSG_CHECKING([Android NDK path])
791     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
792     AC_MSG_RESULT($aros_android_ndk)
794     AC_MSG_CHECKING([what Android SDK version to use])
795     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")
796     AC_MSG_RESULT($aros_sdk_version)
798     if test "$aros_android_ndk" != "none"; then
799         AC_MSG_CHECKING([what Android NDK version to use])
800         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")
801         AC_MSG_RESULT($aros_ndk_version)
802     fi
804     export PATH="$aros_android_sdk/tools:$PATH"
805     AC_PATH_PROG(android_tool, $android_tool)
806     AROS_REQUIRED(android,$android_tool)
808     aros_android_level=android-$aros_sdk_version
809     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
810         echo "Platform $aros_android_level is not installed in your SDK"
811         echo "Use --with-sdk-version=<API level number> to select another platform version"
812         echo "You can check what plaform versions are installed in your SDK"
813         echo "by examining contents of $aros_android_sdk/platforms directory"
814         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
815     fi
817     AC_PATH_PROG(ant, ant)
818     if test "$ant" = ""; then
819         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
820     fi
822     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
823     if test "$host_os" = "mingw32"; then
824         android_tool="cmd //c $android_tool"
825     fi
827     ;;
828 esac
830 #-----------------------------------------------------------------------------
832 # This is the target configuration switch.
833 case "$target_os" in
834     linux*)
835         aros_target_arch="linux"
836         aros_target_family="unix"
837         case "$target_cpu" in
838             *m68k*)
839                 aros_target_cpu="m68k"
840                 aros_object_format="m68kelf"
841                 aros_flavour="emulcompat"
842                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
843                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
844                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
845                 gcc_target_cpu="mc68000"
846                 ;;
847             *i?86*)
848                 aros_target_cpu="i386"
849                 aros_object_format="elf_i386"
850                 aros_flavour="emulation"
851                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
852                 aros_config_cflags="$aros_config_cflags -m32 -march=i486"
853                 aros_kernel_cflags="$aros_kernel_cflags -m32 -march=i486"
854                 aros_config_aflags="$aros_config_aflags -m32 -march=i486"
855                 aros_config_ldflags="-m32 -march=i486"
856                 aros_kernel_ldflags="-melf_i386"
857                 aros_default_wbdepth=8
858                 gcc_target_cpu="i386"
859                 pci_hidd_target="hidd-pci-linux"
860                 android_tool_dir_prefix="x86"
861                 android_tool_prefix="i686-android-linux"
862                 android_ndk_arch="x86"
863                 ;;
864             *x86_64*)
865                 aros_target_cpu="x86_64"
866                 aros_object_format="elf_x86_64"
867                 aros_flavour="emulation"
868                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
869                 aros_config_cflags="$aros_config_cflags -mno-red-zone -fno-omit-frame-pointer"
870                 aros_default_wbdepth=8
871                 pci_hidd_target="hidd-pci-linux"
872                 ;;
873             *powerpc*)
874                 aros_target_cpu="ppc"
875                 aros_object_format="elf32ppc"
876                 aros_flavour="emulation"
877                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
878                 aros_default_wbdepth=8
879                 gcc_target_cpu="ppc"
880                 ;;
881 # TODO
882 # Same as powerpc, but I need this for the nightly build to work again.
883 # Actually, the nightly should be made working with powerpc target.
884 # That just was too much work for the moment, another week or two.
885             *ppc*)
886                 aros_target_cpu="ppc"
887                 aros_object_format="elf32ppc"
888                 aros_flavour="emulation"
889                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
890                 aros_default_wbdepth=8
891                 gcc_target_cpu="ppc"
892                 ;;
893             *arm*)
894                 aros_target_cpu="arm"
895                 aros_object_format="armelf_linux_eabi"
896                 aros_flavour="emulation"
897                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
898                 gcc_target_cpu="arm"
899                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
900                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
901                 aros_arch_libs="-laeabi"
902                 android_tool_dir_prefix="arm-linux-androideabi"
903                 android_tool_prefix="arm-linux-androideabi"
904                 android_ndk_arch="arm"
905                 ;;
906             *)
907                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
908                 ;;
909         esac
910         case "$aros_target_variant" in
911             android)
913                 dnl Not all Linux CPUs are supported by Android
914                 if test "$android_ndk_arch" = ""; then
915                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
916                 fi
918                 aros_default_wbwidth=320
919                 aros_default_wbheight=480
920                 if test "$aros_android_ndk" = "none"; then
921                     dnl Use standalone toolchain, don't adjust paths
922                     aros_kernel_cflags="-mandroid"
923                     aros_kernel_ldflags="-mandroid"
924                     CFLAGS="-mandroid"
925                 else
926                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$target_tool_version/prebuilt/$android_build_os/bin:$PATH"
927                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
928                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
929                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
930                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
931                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
932                 fi
933                 need_x11=no
934                 dnl (Ab)use $(X11_HIDD_TARGET) as "Default display driver target"
935                 dnl in order not to fill mmakefiles with garbage
936                 x11_hidd_target=kernel-hidd-androidgfx-kobj
937                 target_tool_prefix="$android_tool_prefix-"
938             ;;
939         esac
940     ;;
942     pc)
943         aros_target_arch="pc"
944         aros_shared_default="no"
945         target_bootloader="grub2"
946         case "$target_cpu" in
947             *i?86*)
948                 aros_target_cpu="i386"
950                 dnl If somebody hasn't already set the target object
951                 dnl format, then use this value. Mostly to support
952                 dnl FreeBSD cross-compilation.
953                 dnl TODO: Remove when we always use our compiler.
955                 if test "$aros_object_format" = "" ; then
956                     aros_object_format="elf_i386"
957                 fi
958                 aros_flavour="standalone"
959                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
960                 aros_config_cflags="$aros_config_cflags -m32 -march=i486"
961                 aros_kernel_cflags="$aros_kernel_cflags -m32 -march=i486"
962                 aros_config_aflags="$aros_config_aflags -m32 -march=i486"
963                 aros_config_ldflags="-m32 -march=i486"
964                 aros_kernel_ldflags="-melf_i386"
965                 aros_default_wbwidth=640
966                 aros_default_wbheight=480
967                 gcc_target_cpu="i386"
968                 ;;
969             *x86_64*)
970                 aros_target_cpu="x86_64"
971                 aros_serial_debug=1
972                 if test "$aros_object_format" = "" ; then
973                     aros_object_format="elf_x86_64"
974                 fi
975                 aros_flavour="standalone"
976                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
977                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
978                 aros_kernel_ldflags=""
979                 aros_default_wbwidth=640
980                 aros_default_wbheight=480
981                 ;;
982             *)
983                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
984                 ;;
985         esac
986         ;;
988     prep)
989         aros_target_arch="prep"
990         aros_shared_default="no"
991         aros_target_cpu="ppc"
992         aros_object_format="elf32ppc"
993         aros_flavour="ppcnative"
994         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
995         aros_kernel_ldflags=""
996         aros_default_wbwidth=640
997         aros_default_wbheight=480
998         gcc_target_cpu="ppc"
999         ;;
1001     freebsd*)
1002         aros_target_arch="freebsd"
1003         aros_target_family="unix"
1004         aros_target_cpu="i386"
1005         aros_flavour="emulation"
1006         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1007         gcc_target_cpu="i386"
1009         aros_target_strip_flags="-x"
1010         ;;
1012     darwin*)
1013         aros_target_arch="darwin"
1014         aros_target_family="unix"
1015         aros_flavour="emulation"
1016         case "$target_cpu" in
1017             *i?86*)
1018                 aros_ios_platform="iPhoneSimulator"
1019                 aros_target_cpu="i386"
1020                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1021                 aros_kernel_ldflags=""
1022                 aros_macosx_version="10.4"
1023                 aros_default_wbdepth=8
1024                 gcc_target_cpu="i386"
1025                 aros_object_format="elf_i386"
1026                 aros_kernel_ar_flags="-cr"
1027                 aros_target_strip_flags="-x"
1028                 target_tool_prefix="i686-apple-darwin10-"
1029                 target_tool_flags="-m32"
1030                 ;;
1031             *x86_64*)
1032                 aros_target_cpu="x86_64"
1033                 aros_object_format="elf_x86_64"
1034                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1035                 aros_macosx_version="10.6"
1036                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1037                 aros_kernel_cflags="-m64"
1038                 aros_kernel_ldflags="-m64"
1039                 aros_target_cflags="-mcmodel=large"
1040                 aros_default_wbdepth=8
1041                 aros_kernel_ar="ar"
1042                 aros_kernel_ar_flags="-cr"
1043                 aros_kernel_ld="ld"
1044                 aros_kernel_ranlib="ranlib"
1045                 target_tool_prefix="i686-apple-darwin10-"
1046                 ;;
1047             *ppc*)
1048                 aros_target_cpu="ppc"
1049                 aros_object_format="elf32ppc"
1050                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1051                 aros_kernel_ldflags=""
1052                 aros_macosx_version="10.0"
1053                 aros_default_wbdepth=8
1054                 gcc_target_cpu="ppc"
1055                 aros_kernel_ar="ar"
1056                 aros_kernel_ar_flags="-cr"
1057                 aros_kernel_ld="ld -arch ppc"
1058                 aros_kernel_ranlib="ranlib -arch ppc"
1059                 target_tool_prefix="powerpc-apple-darwin10-"
1060                 ;;
1061             *arm*)
1062                 aros_ios_platform="iPhoneOS"
1063                 aros_target_cpu="arm"
1064                 aros_object_format="armelf_linux_eabi"
1065                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1066                 aros_arch_libs="-laeabi"
1067                 aros_default_wbdepth=8
1068                 gcc_target_cpu="arm"
1069                 aros_kernel_ar="ar"
1070                 aros_kernel_ar_flags="-cr"
1071                 aros_kernel_ld="ld -arch arm"
1072                 aros_kernel_ranlib="ranlib -arch arm"
1073                 target_tool_prefix="arm-apple-darwin10-" 
1074                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1075                 ;;
1076             *)
1077                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1078                 ;;
1079         esac
1080         case "$aros_target_variant" in
1081             ios)
1082                 aros_ios_version="3.0"
1083                 aros_default_wbwidth=320
1084                 aros_default_wbheight=480
1085                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1086                 target_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1087                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1088                 need_x11=no
1089                 # This is here because it may depend on iOS or SDK version
1090                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1091                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1092                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1093             ;;
1094             *)
1095                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1096                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1097             ;;
1098         esac
1099         ;;
1101     dragonfly*)
1102         aros_target_arch="dragonfly"
1103         aros_target_family="unix"
1104         aros_flavour="emulation"
1105         case "$target_cpu" in
1106             *i?86*)
1107                 aros_target_cpu="i386"
1108                 aros_object_format="elf_i386"
1109                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1110                 ;;
1111             *x86_64*)
1112                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1113                 aros_target_cpu="x86_64"
1114                 aros_object_format="elf_x86_64"
1115                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1116                 ;;
1117             *)
1118                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1119                 ;;
1120         esac
1121         ;;
1123     netbsd*)
1124         aros_target_arch="netbsd"
1125         aros_target_family="unix"
1126         case "$target_cpu" in
1127             *m68k*)
1128                 aros_target_cpu="m68k"
1129                 aros_object_format="m68kelf"
1130                 aros_flavour="emulcompat"
1131                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1132                 gcc_target_cpu="mc68000"
1133                 ;;
1134             *i?86*)
1135                 aros_target_cpu="i386"
1136                 aros_object_format="elf_i386"
1137                 aros_flavour="emulation"
1138                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1139                 aros_default_wbdepth=8
1140                 gcc_target_cpu="i386"
1141                 ;;
1142             *)
1143                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1144                 ;;
1145         esac
1146         aros_target_genmap="-Wl,-M -Xlinker >"
1147         aros_flavour="emulation"
1148         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1149         ;;   
1151     openbsd*)
1152         aros_target_arch="openbsd"
1153         aros_target_family="unix"
1154         case "$target_cpu" in
1155             *i?86*)
1156                 aros_target_cpu="i386"
1157                 aros_object_format="elf_i386"
1158                 aros_flavour="emulation"
1159                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1160                 gcc_target_cpu="i386"
1161                 ;;
1162             *)
1163                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1164                 ;;
1165         esac
1166         aros_target_genmap="-Wl,-M -Xlinker >"
1167         aros_target_nm_flags="-u"
1168         aros_flavour="emulation"
1169         ;;
1171     solaris*)
1172         aros_target_arch="solaris"
1173         aros_target_family="unix"
1174         case "$target_cpu" in
1175            *i?86*)
1176                aros_target_cpu="i386"
1177                aros_object_format="elf_i386"
1178                aros_flavour="emulation"
1179                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1180                aros_default_wbdepth=8
1181                gcc_target_cpu="i386"
1182                ;;
1183             *sparc*)
1184                 aros_target_cpu="sparc"
1185                 aros_object_format="elf_sparc"
1186                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1187                 gcc_target_cpu="sparc"
1188                 ;;
1189             *)
1190                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1191                 ;;
1192         esac
1193         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1194         aros_flavour="emulation"
1195         ;;
1197     morphos*)
1198         aros_target_arch="morphos"
1199         aros_shared_default="no"
1200         aros_target_cpu="ppc"
1201         aros_object_format="elf_ppc"
1202         aros_flavour="nativecompat"
1203         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1204         gcc_target_cpu="ppc"
1205         ;;
1207     sam440)
1208         aros_target_arch="sam440"
1209         aros_shared_default="no"
1210         aros_target_cpu="ppc"
1211         aros_object_format="elf32ppc"
1212         aros_flavour="ppcnative"
1213         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1214         aros_kernel_ldflags=""
1215         aros_default_wbwidth=1024
1216         aros_default_wbheight=768
1217         aros_default_wbdepth=24
1218         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1219         gcc_target_cpu="powerpc"
1220         ;;
1222     efika)
1223         aros_target_arch="efika"
1224         aros_shared_default="no"
1225         aros_target_cpu="arm"
1226         aros_object_format="armelf_linux_eabi"
1227         aros_flavour="standalone"
1228         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1229         aros_kernel_ldflags=""
1230         aros_default_wbwidth=1024
1231         aros_default_wbheight=600
1232         aros_arch_libs="-laeabi"
1233         gcc_default_cpu="armv7-a"
1234         gcc_default_fpu="vfpv3"
1235         gcc_default_float_abi="hard"
1236         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing"
1237         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing"
1238         ;;
1239         
1240     chrp)
1241     aros_target_arch="chrp"
1242     aros_shared_default="no"
1243     aros_target_cpu="ppc"
1244     aros_object_format="elf32ppc"
1245     aros_flavour="ppcnative"
1246     aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1247     aros_kernel_ldflags=""
1248     aros_default_wbwidth=640
1249     aros_default_wbheight=480
1250     aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1251     gcc_target_cpu="powerpc"
1252         case "$aros_target_variant" in
1253             efika)
1254             aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1255             ;;
1256         esac
1257     ;;
1259     amiga*)
1260         aros_target_arch="amiga"
1261         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1262         aros_shared_default="no"
1264         case "$target_cpu" in
1265             *m68k*)
1266                 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")
1267                 aros_enable_mmu=no
1268                 aros_target_cpu="m68k"
1269                 aros_object_format="m68kelf"
1270                 aros_flavour="standcompat"
1271                 gcc_target_cpu="m68000"
1272                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -${gcc_target_cpu} -fbuiltin -Wno-volatile-register-var -Os"
1273                 aros_config_aflags="$aros_config_aflags -${gcc_target_cpu}"
1274                 target_tool_prefix="m68k-elf-"
1275                 # Needed to get the correct multilib
1276                 aros_config_ldflags="-${gcc_target_cpu}"
1277                 aros_shared_ldflags="-${gcc_target_cpu}"
1278                 aros_kernel_ldflags="-${gcc_target_cpu}"
1279                 aros_target_nostdlib_ldflags="-${gcc_target_cpu}"
1280                 aros_target_strip_flags="-R.comment --strip-debug"
1281                 aros_default_wbwidth=640
1282                 aros_default_wbheight=256
1283                 aros_default_wbdepth=2
1284                 ;;
1285             *ppc*)
1286                 aros_cpu="ppc"
1287                 aros_flavour="native"
1288                 gcc_target_cpu="ppc"
1289                 ;;
1290             *)
1291                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1292                 ;;
1293         esac
1294         ;;
1296     mingw*)
1297         aros_target_arch="mingw32"
1298         aros_shared_default="no"
1299         aros_flavour="emulation"
1300         aros_shared_cflags=""
1301         need_dlopen="no"
1302         rescomp="windres"
1303         case "$target_cpu" in
1304             *i?86*)
1305                 aros_target_cpu="i386"
1306                 aros_object_format="elf_i386"
1307                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1308                 aros_default_wbdepth=8
1309                 gcc_target_cpu="i386"
1311                 dnl Temporary hack, needed to get nightly build working
1312                 aros_target_as="i386-aros-as"
1313                 aros_target_ar="i386-aros-ar"
1314                 aros_target_ranlib="i386-aros-ranlib"
1315                 aros_target_nm="i386-aros-nm"
1316                 aros_target_strip="i386-aros-strip"
1317                 aros_target_objcopy="i386-aros-objcopy"
1318                 aros_target_objdump="i386-aros-objdump"
1320                 target_tool_prefix="i386-mingw32-"
1321                 ;;
1322             *x86_64*)
1323                 aros_target_cpu="x86_64"
1324                 aros_object_format="elf_x86_64"
1325                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1326                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1327                 aros_default_wbdepth=8
1328                 target_tool_prefix="x86_64-w64-mingw32-"
1329                 ;;
1330             *arm*)
1331                 aros_target_cpu="arm"
1332                 aros_object_format="armelf_linux_eabi"
1333                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1334                 aros_arch_libs="-laeabi"
1335                 aros_default_wbdepth=8
1336                 gcc_target_cpu="arm"
1337                 gcc_default_float_abi="soft"
1338                 target_tool_prefix="arm-mingw32ce-"
1339                 aros_default_wbwidth=160
1340                 aros_default_wbheight=160
1341                 ;;
1342             *)
1343                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1344                 ;;
1345         esac
1346         if test $host_os = "cygwin"; then
1347                 aros_kernel_cflags="-mno-cygwin"
1348         fi
1349     ;;
1350     pp*)
1351         aros_target_arch="pp"
1352         aros_shared_default="no"
1353         case "$target_cpu" in
1354             *m68k*)
1355                 aros_target_cpu="m68k"
1356                 aros_object_format="m68kelf"
1357                 aros_flavour="palmnative"
1358                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1359                 aros_default_wbwidth=160
1360                 aros_default_wbheight=160
1361                 aros_default_wbdepth=1
1362                 aros_target_ar_flags="cru"
1363                 aros_compiler_libs="-lgcc1"
1364                 aros_shared_default=no
1365                 aros_shared_cflags="-fpic"
1366                 aros_shared_aflags=""
1367                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1368                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1369                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
1370                 aros_debug_aflags=""
1371                 aros_debug_ldflags="$aros_symbols_debug"
1372                 aros_mungwall_debug="0"
1373                 aros_modules_debug="0"
1374                 gcc_target_cpu="mc68000"
1375                 ignore_undefined_symbols="-ius"
1376                 ;;
1377            *)
1378                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1379                 ;;
1380         esac
1381         ;;
1383     mac*)
1384         aros_target_arch="mac"
1385         aros_shared_default="no"
1386         case "$target_cpu" in
1387             *m68k*)
1388                 aros_target_cpu="m68k"
1389                 aros_object_format="m68kelf"
1390                 aros_flavour="mac68knative"
1391                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1392                 aros_default_wbwidth=512
1393                 aros_default_wbheight=384
1394                 aros_default_wbdepth=8
1395                 aros_target_ar_flags="cru"
1396                 aros_compiler_libs="-lgcc1"
1397                 aros_shared_default=no
1398                 aros_shared_cflags="-fpic"
1399                 aros_shared_aflags=""
1400                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1401                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1402                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug -mc68000"
1403                 aros_debug_aflags=""
1404                 aros_debug_ldflags="$aros_symbols_debug"
1405                 aros_mungwall_debug="0"
1406                 aros_modules_debug="0"
1407                 gcc_target_cpu="mc68000"
1408                 ignore_undefined_symbols="-ius"
1409                 ;;
1410            *)
1411                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1412                 ;;
1413         esac
1414         ;;
1416     *)
1417         AC_MSG_ERROR([Unsupported target architecture $target])
1418         ;;
1419 esac
1421 # Now process extra architecture-specific options.
1422 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1423 # as well as floating-point ABI.
1424 case "$aros_target_cpu" in
1425 arm)
1426     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1427     if test "$gcc_default_cpu" = ""; then
1428         gcc_default_cpu="armv6"
1429     fi
1430     if test "$gcc_default_fpu" = ""; then
1431         gcc_default_fpu="vfp"
1432     fi
1433     if test "$gcc_default_float_abi" = ""; then
1434         gcc_default_float_abi="softfp"
1435     fi
1437     AC_MSG_CHECKING([Which minimum CPU to use])
1438     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)
1439     AC_MSG_RESULT($aros_gcc_cpu)
1441     AC_MSG_CHECKING([Which minimum FPU to use])
1442     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)
1443     AC_MSG_RESULT($aros_gcc_fpu)
1445     AC_MSG_CHECKING([Which floating point ABI to use])
1446     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)
1447     AC_MSG_RESULT($aros_gcc_float_abi)
1449     aros_config_cflags="$aros_config_cflags -marm -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi -fno-asynchronous-unwind-tables -fno-exceptions"
1450     aros_config_aflags="$aros_config_aflags -marm -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi -fno-asynchronous-unwind-tables -fno-exceptions"
1451     ;;
1452 esac
1454 # Some formats need custom ELF specs.
1455 # For example for x86_64 it is needed in order for -m32 switch to work correctly.
1456 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1457     elf_specs_in=config/${aros_object_format}-specs.in
1458 else
1459     elf_specs_in=config/elf-specs.in
1462 #-----------------------------------------------------------------------------
1463 AC_MSG_CHECKING([where to install or search for cross tools binaries])
1464 AC_ARG_WITH(crosstools,AC_HELP_STRING([--with-crosstools=DIR],[Where to install or search for cross tools binaries]),with_crosstools=$withval,with_crosstools="default")
1465 if test "$with_crosstools" = "default"; then
1466     crosstools=yes
1467     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1468 else
1469     AROS_CROSSTOOLSDIR="$with_crosstools"
1471 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1473 if test "$crosstools" != "no" -o "$with_crosstools" != "default"; then
1475     dnl --with-crosstools with no --enable-crosstools implies --with-aros-gcc with no version specified
1476     dnl The same is about --enable-crosstools
1478     use_aros_gcc=yes
1479     PATH=$AROS_CROSSTOOLSDIR:$PATH
1482 AC_MSG_CHECKING([what specific AROS gcc version to use])
1483 AC_ARG_WITH(aros-gcc,AC_HELP_STRING([--with-aros-gcc=VERSION],[Use aros-gcc-VERSION for building AROS]),aros_gcc_version="$withval",aros_gcc_version="$use_aros_gcc")
1484 case "$aros_gcc_version" in
1485 yes)
1486     aros_gcc_version="default"
1487     ;;
1489     aros_gcc_version="none"
1490     ;;
1491 esac
1492 AC_MSG_RESULT($aros_gcc_version)
1494 if test "$aros_gcc_version" != "none"; then
1496     dnl Here we either build own crosstools, or use preinstalled ones
1497     dnl Check for specific version requested, and append suffix if needed
1499     if test "$aros_gcc_version" != "default"; then
1500         aros_target_cc="$aros_target_cpu-aros-gcc-$aros_gcc_version"
1501         aros_target_cxx="$aros_target_cpu-aros-g++-$aros_gcc_version"
1502     else
1503         aros_target_cc="$aros_target_cpu-aros-gcc"
1504         aros_target_cxx="$aros_target_cpu-aros-g++"
1505     fi
1507     aros_target_ld="$aros_target_cpu-aros-ld"
1508     aros_target_as="$aros_target_cpu-aros-as"
1509     aros_target_ar="$aros_target_cpu-aros-ar"
1510     aros_target_ranlib="$aros_target_cpu-aros-ranlib"
1511     aros_target_nm="$aros_target_cpu-aros-nm"
1512     aros_target_strip="$aros_target_cpu-aros-strip"
1513     aros_target_objcopy="$aros_target_cpu-aros-objcopy"
1514     aros_target_objdump="$aros_target_cpu-aros-objdump"
1517 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1518 # Since we override specs, we may need to put these defines there
1519 if test "$gcc_target_cpu" != ""; then
1520     gcc_target_cpu="-D__${gcc_target_cpu}__"
1523 AC_MSG_CHECKING([where to download sourcecode for external ports])
1524 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1525 if test "$with_portssrcdir" = "default"; then
1526     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1527 else
1528     AROS_PORTSSRCDIR="$with_portssrcdir"
1530 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1532 AC_MSG_CHECKING([which bootloader to use])
1533 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1534 if test "$target_bootloader" = "none"; then
1535     aros_target_bootloader=""
1536 else
1537     aros_target_bootloader="$target_bootloader"
1539 AC_MSG_RESULT($target_bootloader)
1541 AC_MSG_CHECKING([which icon-set to use])
1542 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1543 if test "$target_iconset" = "default"; then
1544     aros_target_iconset="Gorilla"
1545     target_iconset="default (Gorilla)"
1546 else
1547     aros_target_iconset="$target_iconset"
1549 AC_MSG_RESULT($target_iconset)
1551 AC_MSG_CHECKING([which GUI Theme to use])
1552 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1553 if test "$target_guitheme" = "default"; then
1554     aros_target_guitheme="Ice"
1555 else
1556     aros_target_guitheme="$target_guitheme"
1558 AC_MSG_RESULT($aros_target_guitheme)
1560 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1561 # for target code)
1562 cross_compiling=no
1563 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1564     cross_compiling=yes
1567 dnl Native x86-64 Linux toolchain can also produce i386 binaries, given -m32 flag.
1568 if test "$aros_host_cpu" == "x86_64" ; then
1569     if test "$aros_target_cpu" == "i386" ; then
1570         if test "$aros_target_arch" != "mingw32"; then
1571             cross_compiling=no
1572         fi
1573     fi
1576 dnl Enforce cross-compile if we are on Darwin, but our target is not Darwin.
1577 if test "$aros_host_arch" == "darwin" ; then
1578     if test "$aros_target_arch" != "darwin" ; then
1579         cross_compiling=yes
1580     fi
1583 dnl The same for MinGW
1584 if test "$aros_host_arch" == "mingw32" ; then
1585     if test "$aros_target_arch" != "mingw32" ; then
1586         cross_compiling=yes
1587     fi
1590 # I want to have this information in configure output, although it might be
1591 # misleading, e.g. for darwin hosted you cannot compile target code without a
1592 # cross compiler, but here it says no.
1594 # Note: it says 'yes' only if bootstrap ("kernel") is cross-compiled.
1595 # Target code is a little bit different thing.
1596 #                                                sonic
1597 echo "checking wether we are (AROS style) cross compiling... $cross_compiling"
1599 # Set prefix for target compiler etc. if we're cross-compiling
1600 # (should possibly be earlier but needs to be after AC_PROG_CC)
1601 if test "$cross_compiling" = "yes" ; then
1603     if test "x-$aros_flavour" = "x-standalone" -o "x-$aros_flavour" = "x-standcompat" ; then
1604         if test "$aros_gcc_version" != "none"; then
1606             dnl If we are cross-compiling a native port with AROS compiler, we can reuse
1607             dnl AROS compiler for bootstrap ("kernel"). This eliminates a need for one more
1608             dnl ELF compiler.
1610             dnl Use target toolchain as bootstrap one.
1611             target_tool_prefix=${target_cpu}-aros-
1612             target_tool_version=$aros_gcc_version
1613             use_kernel_cc_wrapper=yes
1615             dnl Cancel explicit AROS tools assignment. This will cause configure
1616             dnl to select the same tools for bootstrap and AROS.
1617             if test "$crosstools" != yes; then
1618                 aros_target_cc=
1619                 aros_target_ld=
1620                 aros_target_as=
1621                 aros_target_ar=
1622                 aros_target_ranlib=
1623                 aros_target_nm=
1624                 aros_target_strip=
1625                 aros_target_objcopy=
1626                 aros_target_objdump=
1627             fi
1628         fi
1629     fi
1631     CC=${target_tool_prefix}gcc
1632     dnl CPP is needed for AC_CHECK_HEADER to work correctly
1633     CPP=${target_tool_prefix}cpp
1634     if test "$target_tool_version" != "default"; then
1635         CC="$CC-$target_tool_version"
1636         CPP="$CC-$target_tool_version"
1637     fi
1638     if test "$crosstools" != "yes" ; then
1639         AC_PATH_PROG(CC,$CC)
1640         AROS_REQUIRED(gcc,$CC)
1641     else
1642         CC=$AROS_CROSSTOOLSDIR/$CC
1643     fi
1645 CC="$CC $target_tool_flags"
1647 #-----------------------------------------------------------------------------
1649 # Disable pointer-signedness warnings if the compiler recognises the option
1651 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
1652 save_cflags="$CFLAGS"
1653 if test "$crosstools" != "yes" ; then
1654     CFLAGS="$CFLAGS -Wno-pointer-sign"
1655     AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
1656 else
1657     # we do know it is supported for the smallest version of gcc we are going to build
1658     # we assume it's also supported by later versions
1659     use_no_sign_warning=yes
1661 AC_MSG_RESULT($use_no_sign_warning)
1662 if test "x-$use_no_sign_warning" = "x-yes" ; then
1663     aros_config_cflags="$aros_config_cflags -Wno-pointer-sign"
1665 CFLAGS="$save_cflags"
1667 #-----------------------------------------------------------------------------
1669 # Find all the tools we need to compile. This could be cross-compiling
1670 # though! If that is the case we use the GNU form of the target and
1671 # simply add this to the front of the binary name. This is rather simple,
1672 # but it should work under most circumstances.
1674 # The default tools are to use the same as the host, but only if the
1675 # host and target CPU are the same. With GCC this is normally enough.
1678 aros_cc_pre=""
1679 aros_shared_ld="$aros_host_ld"
1681 aros_target_mkdep="$aros_host_mkdep"
1682 aros_target_incl_def="$aros_host_incl"
1684 aros_kernel_cc="$CC"
1686 # The default tools executables to be linked to.
1687 if test "$rescomp" != ""; then
1688     if test "$cross_compiling" = "yes" ; then
1689         rescomp=${target_tool_prefix}${rescomp}
1690     fi
1691     AC_PATH_PROG(aros_kernel_rescomp,$rescomp)
1692     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
1695 if test "$crosstools" != "yes"; then
1696     AROS_TOOL_TARGET(aros_kernel_ld,ld,$aros_kernel_ld)
1697     AROS_REQUIRED(ld,$aros_kernel_ld)
1698     AROS_TOOL_TARGET(aros_kernel_ar,ar,$aros_kernel_ar)
1699     AROS_REQUIRED(ld,$aros_kernel_ar)
1700     AROS_TOOL_TARGET(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1701     AROS_REQUIRED(ld,$aros_kernel_ranlib)
1703     dnl For non-ELF hosts we additionally have to look up ELF toolchain for AROS binaries
1704     dnl It can be either AROS toolchain selected earlier or generic ELF toolchain we select here.
1705     dnl This catches also Android-hosted case. Android gcc is a ELF compiler, but it can't be used
1706     dnl to build AROS binaries, at least on ARM. Android EABI is different from AROS EABI
1707     dnl (at least enum size is known to be different).
1708     if test "$target_tool_prefix" != "${target_cpu}-elf-" -a "$target_tool_prefix" != "${target_cpu}-aros-" ; then
1709         target_tool_prefix=${target_cpu}-elf-
1710         if test "$aros_target_cc" == ""; then
1711            aros_target_cc="${target_tool_prefix}gcc"
1712         fi
1713         if test "$aros_target_ld" == ""; then
1714            aros_target_ld="${target_tool_prefix}ld"
1715         fi
1716     fi
1717     AROS_TOOL_TARGET(aros_target_as_ln,as,$aros_target_as)
1718     AROS_REQUIRED(as,$aros_target_as_ln)
1719     AROS_TOOL_TARGET(aros_target_ar_ln,ar,$aros_target_ar)
1720     AROS_REQUIRED(ar,$aros_target_ar_ln)
1721     AROS_TOOL_TARGET(aros_target_nm_ln,nm,$aros_target_nm)
1722     AROS_REQUIRED(nm,$aros_target_nm_ln)
1723     AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy,$aros_target_objcopy)
1724     AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
1725     AROS_TOOL_TARGET(aros_target_objdump_ln,objdump,$aros_target_objdump)
1726     AROS_REQUIRED(objdump,$aros_target_objdump_ln)
1727     AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib,$aros_target_ranlib)
1728     AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
1729     AROS_TOOL_TARGET(aros_target_strip_ln,strip,$aros_target_strip)
1730     AROS_REQUIRED(strip,$aros_target_strip_ln)
1731     if test "$aros_target_cxx" != ""; then
1732         AC_PATH_PROG(aros_target_cxx,$aros_target_cxx)
1733         AROS_REQUIRED(c++,$aros_target_cxx)
1734     fi
1735 else
1736     aros_target_cc=$AROS_CROSSTOOLSDIR/$aros_target_cc
1737     aros_target_cxx=$AROS_CROSSTOOLSDIR/$aros_target_cxx
1738     aros_target_as_ln=$AROS_CROSSTOOLSDIR/$aros_target_as
1739     aros_target_ar_ln=$AROS_CROSSTOOLSDIR/$aros_target_ar
1740     aros_target_nm_ln=$AROS_CROSSTOOLSDIR/$aros_target_nm
1741     aros_target_objcopy_ln=$AROS_CROSSTOOLSDIR/$aros_target_objcopy
1742     aros_target_objdump_ln=$AROS_CROSSTOOLSDIR/$aros_target_objdump
1743     aros_target_ranlib_ln=$AROS_CROSSTOOLSDIR/$aros_target_ranlib
1744     aros_target_strip_ln=$AROS_CROSSTOOLSDIR/$aros_target_strip
1746     if test "$target_tool_prefix" != "${target_cpu}-aros-" ; then
1747         AROS_TOOL_TARGET(aros_kernel_ld,ld,$aros_kernel_ld)
1748         AROS_REQUIRED(ld,$aros_kernel_ld)
1749         AROS_TOOL_TARGET(aros_kernel_ar,ar,$aros_kernel_ar)
1750         AROS_REQUIRED(ld,$aros_kernel_ar)
1751         AROS_TOOL_TARGET(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1752         AROS_REQUIRED(ld,$aros_kernel_ranlib)
1753     else
1754         aros_kernel_ar=$AROS_CROSSTOOLSDIR/$aros_target_ar
1755         aros_kernel_ld=$AROS_CROSSTOOLSDIR/$aros_target_ld
1756         aros_kernel_ranlib=$AROS_CROSSTOOLSDIR/$aros_target_ranlib
1757     fi
1759     crosstools_target=tools-crosstools
1762 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
1764 orig_target_cc=$aros_kernel_cc
1765 orig_target_ld=$aros_kernel_ld
1767 if test "$crosstools" != "yes"; then
1768     if test "$aros_target_cc" != ""; then
1769         AC_PATH_PROG(aros_target_cc,$aros_target_cc)
1770         AROS_REQUIRED(gcc,$aros_target_cc)
1771         orig_target_cc=$aros_target_cc
1772     fi
1773     if test "$aros_target_ld" != ""; then
1774         AC_PATH_PROG(aros_target_ld,$aros_target_ld)
1775         AROS_REQUIRED(ld,$aros_target_ld)
1776         orig_target_ld=$aros_target_ld
1777     fi
1778 else
1779     orig_target_cc=$aros_target_cc
1780     orig_target_ld=$aros_target_ld
1783 # Build crosstools if we have no C++ - temporary thing 
1784 if test "$aros_target_cxx" = "" -a "$crosstools" != "yes"; then
1785     crosstools_cxx_target=tools-crosstools
1788 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1789 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1790 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1791 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1792 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1793 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1794 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1796 # aros_cc_pre is a variable that is added to the front of the compiler name
1797 # in the generated aros-gcc shell script. We need this to enable the cache
1798 # to work across cleaned builds. Also, support DISTCC using the correct
1799 # environment variable.
1802 if test "x${DISTCC}" != "x" ; then
1803     if test "x${CCACHE}" != "x" ; then
1804         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1805     else
1806         aros_cc_pre="${DISTCC} "
1807     fi
1808 else
1809     if test "x${CCACHE}" != "x" ; then
1810         aros_cc_pre="${CCACHE} "
1811     fi
1814 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1816 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1817 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1818 AC_SUBST(aros_target_nix_ldflags,-nix)
1819 AC_SUBST(aros_target_detach_ldflags,-detach)
1820 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1822 # Target tools
1823 if test "$crosstools" != "yes"; then
1824     if test "$GCC" = "yes"; then
1825         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1826     fi
1827 else
1828     # We do not know which gcc version we are going to build and what we need to know
1829     # here is different for different versions so this will be set later during the
1830     # build of crosstools.
1831     aros_target_cc_path=@aros_target_cc_path@
1833 aros_target_cc="${prefix}-gcc"
1834 aros_target_as="${prefix}-as"
1835 aros_target_ld="${prefix}-ld"
1836 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1837 aros_target_objcopy=${prefix}-objcopy
1838 aros_target_objdump=${prefix}-objdump
1839 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1840 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1841 aros_target_strip=${prefix}-strip
1842 aros_plain_nm="${prefix}-nm"
1843 aros_plain_ar="${prefix}-ar"
1845 # Find the system include path. We can suggest that an alternative is
1846 # used if we don't get it correct. The default is to use /usr/include.
1847 # Which is set in the aros_target_incl_def variable.
1849 AC_ARG_ENABLE(includes,
1850 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1851 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1853 if test "$aros_kernel_includes" = ""; then
1854     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1855         # FIXME: for cross-compiling this should point to another location
1856         aros_kernel_includes="-isystem $aros_target_incl"
1857     fi
1860 if test "$aros_kernel_includes" != "" ; then
1861     dnl find out about the kernel cc's include path
1862     AC_MSG_CHECKING([for the kernel compiler's include path])
1863     if test "$aros_kernel_cc_includes" = "" ; then
1864         # Try to guess where the directory is.
1865         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
1866         if test -d $aros_kernel_cc_includes; then
1867             # Check if there is also an include-fixed directory and add it
1868             # to kernel compiler's include path as it may contain some of
1869             # the headers we need.
1870             if test -d "$aros_kernel_cc_includes"-fixed; then
1871                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
1872             fi
1873             # Check for specific includes directory. Neede for Ubuntu 11.10
1874             if test -d "/usr/include/i386-linux-gnu"; then
1875                 aros_kernel_cc_includes+=" -isystem /usr/include/i386-linux-gnu"
1876             fi
1877         else
1878             # The directory doesn't exist, we need to do some more work.
1879             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
1881             # These are the headers we're looking for.
1882             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1883                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1884                      zutil.h"
1886             dnl This is for Darwin.
1887             dnl With XCode4.1 Apple thought it's a nice idea to move stdint.h away
1888             dnl to some very specific location
1889             if test ! -f $aros_target_incl/stdint.h; then
1890                 headers="$headers stdint.h"
1891             fi
1893             dirs=
1894             for h in $headers; do
1895                 # Which other headers are needed by each of the above?
1896                 deps=$(echo "#include <$h>" | \
1897                        $aros_kernel_cc -E -M - 2>/dev/null | \
1898                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1900                 # Copy all the needed headers to a directory beneath gendir.
1901                 for d in $deps; do
1902                     h=$(basename $d)
1903                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
1904                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1905                     ! test -d $dir && mkdir -p $dir
1906                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1907                 done
1908             done            
1909         fi
1910     fi
1911     AC_MSG_RESULT($aros_kernel_cc_includes)
1912     # Adding -nostdinc to kernel includes as they are always used together.
1913     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
1916 if test "$crosstools" != "yes"; then
1917     dnl find out about the target cc's include path
1918     AC_MSG_CHECKING([for the target compiler's include path])
1919     if test "$aros_target_cc_includes" = "" ; then
1920         #try to guess where the directory is
1921         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
1922         if ! test -d $aros_target_cc_includes; then
1923             #the directory doesn't exist, we need to do some more work
1924             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1925         
1926             #these are the headers we're looking for
1927             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1928                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1929                     zutil.h"
1931             dirs=
1932             for h in $headers; do
1933                 #which other headers each of the above headers needs?
1934                 deps=$(echo "#include <$h>" | \
1935                     $orig_target_cc -E -M - 2>/dev/null | \
1936                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1937             
1938                 #copy all the needed headers to a directory beneath gendir
1939                 for d in $deps; do
1940                     h=$(basename $d)
1941                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1942                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1943                     ! test -d $dir && mkdir -p $dir
1944                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1945                 done
1946             done
1947         fi
1948     fi
1949     AC_MSG_RESULT($aros_target_cc_includes)
1950 else
1951     # We do not know which gcc version we are going to build and what we need to know
1952     # here is different for different versions so this will be set later during the
1953     # build of crosstools.
1954     aros_target_cc_includes=@aros_target_cc_includes@
1958 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
1959 # On GCC >= 4.0 -iquote should be used
1962 save_cc="$CC"
1963 save_cflags="$CFLAGS"
1964 CFLAGS="-iquote."
1965 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
1966 if test "x-$crosstools" != "x-yes"; then
1967     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
1968 else
1969     # we do know it is supported for the smallest version of gcc we are going to build
1970     # we assume it's also supported by later versions
1971     has_iquote=yes
1973 AC_MSG_RESULT($has_iquote)
1974 if test "x-$has_iquote" = "x-yes" ; then
1975     host_cflags_iquote=-iquote
1976     host_cflags_iquote_end=
1977 else
1978     host_cflags_iquote=-I
1979     host_cflags_iquote_end=-I-
1981 kernel_cflags_iquote=$host_cflags_iquote
1982 kernel_cflags_iquote_end=$host_cflags_iquote_end
1983 if test "x-$cross_compiling" = "x-yes"; then
1984     CC="$aros_kernel_cc"
1985     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
1986     if test "x-$crosstools" != "x-yes"; then
1987         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
1988     else
1989         # we do know it is supported for the smallest version of gcc we are going to build
1990         # we assume it's also supported by later versions
1991         use_no_stack_protector=yes
1992     fi
1993     AC_MSG_RESULT($use_no_stack_protector)
1994     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
1995     if test "x-$crosstools" != "x-yes"; then
1996         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
1997     else
1998         # we do know it is supported for the smallest version of gcc we are going to build
1999         # we assume it's also supported by later versions
2000         has_iquote=yes
2001     fi
2002     AC_MSG_RESULT($has_iquote)
2003     if test "x-$has_iquote" = "x-yes" ; then
2004         kernel_cflags_iquote=-iquote
2005         kernel_cflags_iquote_end=
2006     else
2007         kernel_cflags_iquote=-I
2008         kernel_cflags_iquote_end=-I-
2009     fi
2011 aros_cflags_iquote=$kernel_cflags_iquote
2012 aros_cflags_iquote_end=$kernel_cflags_iquote_end
2013 if test "$orig_target_cc" != "$aros_kernel_cc"; then
2014     CC="$orig_target_cc"
2015     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2016     if test "x-$crosstools" != "x-yes"; then
2017         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2018     else
2019         # we do know it is supported for the smallest version of gcc we are going to build
2020         # we assume it's also supported by later versions
2021         has_iquote=yes
2022     fi
2023     AC_MSG_RESULT($has_iquote)
2024     if test "x-$has_iquote" = "x-yes" ; then
2025         aros_cflags_iquote=-iquote
2026         aros_cflags_iquote_end=
2027     else
2028         aros_cflags_iquote=-I
2029         aros_cflags_iquote_end=-I-
2030     fi
2032 if test "x-$use_no_stack_protector" = "x-yes" ; then
2033     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2037 #-----------------------------------------------------------------------------
2039 # Check if the target compiler supports some options used for delinting:
2040 #  -Wunused-but-set-variable
2041 #  -Warray-bounds
2042 #  -Wenum-compare
2043 #  -Wstrict-overflow
2044 #  -Wformat-security
2046 if test "x-$crosstools" != "x-yes"; then
2047     if test "$orig_target_cc" != "$aros_kernel_cc"; then
2048         CC="$orig_target_cc"
2049     fi
2050     AC_MSG_CHECKING([whether ${CC} accepts -Wunused-but-set-variable])
2051     CFLAGS=-Wunused-but-set-variable
2052     AC_TRY_COMPILE(,, aros_unused_but_set_variable="yes", aros_unused_but_set_variable="no")
2053     AC_MSG_RESULT($aros_unused_but_set_variable)
2054     if test "x-$aros_unused_but_set_variable" = "x-yes" ; then
2055         aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable
2056     fi
2058     AC_MSG_CHECKING([whether ${CC} accepts -Warray-bounds])
2059     CFLAGS=-Warray-bounds
2060     AC_TRY_COMPILE(,, aros_array_bounds="yes", aros_array_bounds="no")
2061     AC_MSG_RESULT($aros_array_bounds)
2062     if test "x-$aros_array_bounds" = "x-yes" ; then
2063         aros_cflags_array_bounds=-Wno-array-bounds
2064     fi
2066     AC_MSG_CHECKING([whether ${CC} accepts -Wenum-compare])
2067     CFLAGS=-Wenum-compare
2068     AC_TRY_COMPILE(,, aros_enum_compare="yes", aros_enum_compare="no")
2069     AC_MSG_RESULT($aros_enum_compare)
2070     if test "x-$aros_enum_compare" = "x-yes" ; then
2071         aros_cflags_enum_compare=-Wno-enum-compare
2072     fi
2074     AC_MSG_CHECKING([whether ${CC} accepts -Wstrict-overflow])
2075     CFLAGS=-Wstrict-overflow
2076     AC_TRY_COMPILE(,, aros_strict_overflow="yes", aros_strict_overflow="no")
2077     AC_MSG_RESULT($aros_strict_overflow)
2078     if test "x-$aros_strict_overflow" = "x-yes" ; then
2079         aros_cflags_strict_overflow=-Wno-strict-overflow
2080     fi
2082     AC_MSG_CHECKING([whether ${CC} accepts -Wformat-security])
2083     CFLAGS=-Wformat-security
2084     AC_TRY_COMPILE(,, aros_format_security="yes", aros_format_security="no")
2085     AC_MSG_RESULT($aros_format_security)
2086     if test "x-$aros_format_security" = "x-yes" ; then
2087         aros_cflags_format_security=-Wno-format-security
2088     fi
2089 else
2090     # We do not know which gcc version we are going to build and what we need to know
2091     # here is different for different versions so this will be set later during the
2092     # build of crosstools.
2093     aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@
2094     aros_cflags_array_bounds=@aros_cflags_array_bounds@
2095     aros_cflags_enum_compare=@aros_cflags_enum_compare@
2096     aros_cflags_strict_overflow=@aros_cflags_strict_overflow@
2097     aros_cflags_format_security=@aros_cflags_format_security@
2100 #-----------------------------------------------------------------------------
2102 # Check if we can explicitly choose older version of symbol hashing
2104 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2105 CC="$aros_kernel_cc"
2106 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2107 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2108 AC_MSG_RESULT($use_hash_style)
2109 if test "x-$use_hash_style" = "x-yes" ; then
2110     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2112 CC="$save_cc"
2113 CFLAGS="$save_cflags"
2115 AC_SUBST(host_cflags_iquote)
2116 AC_SUBST(host_cflags_iquote_end)
2117 AC_SUBST(kernel_cflags_iquote)
2118 AC_SUBST(kernel_cflags_iquote_end)
2119 AC_SUBST(aros_cflags_iquote)
2120 AC_SUBST(aros_cflags_iquote_end)
2123 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2124 AC_MSG_CHECKING([for default resolution of WBScreen])
2125 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2126 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2127 if test "$resolution" = "yes" ; then
2128     resolution="none"
2130 if test "$resolution" = "no" ; then
2131     resolution="none"
2133 if test "$resolution" != "none" ; then
2134     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
2135     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
2136     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
2138 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
2139 aros_cv_default_wbwidth=$aros_default_wbwidth
2140 aros_cv_default_wbheight=$aros_default_wbheight
2141 aros_cv_default_wbdepth=$aros_default_wbdepth
2143 dnl See if the user wants the serial debug output for native flavour
2144 AC_MSG_CHECKING([if serial debug is enabled])
2145 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)
2146 if test "$aros_serial_debug" = 0 ; then
2147     serial_debug_forced=""
2148     if test "$serial_debug" = "yes" ; then
2149         serial_debug="1"
2150     fi
2151     if test "$serial_debug" = "no" ; then
2152         serial_debug="none"
2153     fi
2154 else
2155     serial_debug_forced="(forced)"
2156     serial_debug=$aros_serial_debug
2158 if test "$serial_debug" != "none" ; then
2159     aros_serial_debug=$serial_debug
2160     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2161 else
2162     AC_MSG_RESULT(no)
2165 dnl See if the user wants the palm debug output hack for palm native flavour
2166 AC_MSG_CHECKING([if palm debug hack is enabled])
2167 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")
2168 if test "$palm_debug_hack" = "yes" ; then
2169     aros_palm_debug_hack="1"
2171 AC_MSG_RESULT($palm_debug_hack)
2173 dnl See if the user wants the usb3.0 code
2174 AC_MSG_CHECKING([if usb3.0 code is enabled])
2175 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2176 if test "$usb30_code" = "yes" ; then
2177     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2178     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2180 AC_MSG_RESULT($usb30_code)
2182 dnl See if the user wants nesting supervisor activated for unix flavour
2183 AC_MSG_CHECKING([if nesting supervisor support is enabled])
2184 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")
2185 if test "$nesting_supervisor" = "yes" ; then
2186     aros_nesting_supervisor="1"
2188 AC_MSG_RESULT($nesting_supervisor)
2190 dnl See if the user wants to disable MMU support
2191 dnl This can be overriden on per-target basis,
2192 dnl set $aros_enable_mmu to "yes" or "no" to do this
2193 if test "$aros_enable_mmu" = "" ; then
2194     AC_MSG_CHECKING([if MMU support is enabled])
2195     dnl Enabled by default
2196     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2197     if test "$aros_enable_mmu" = "" ; then
2198         aros_enable_mmu="yes"
2199     fi
2200     AC_MSG_RESULT($aros_enable_mmu)
2202 if test "$aros_enable_mmu" = "no" ; then
2203     aros_enable_mmu="0"
2204 else
2205     aros_enable_mmu="1"
2207     
2209 dnl things specifically required for hosted flavours
2210 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2212     if test "x-$need_dlopen" != "x-no" ; then
2213       dnl some kind of dynamic library access system is required for hostlib.resource
2214       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2215       if test "x-$have_dl" = "x-no" ; then
2216           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2217                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2218                                     have_dl="no")
2219       fi
2220       if test "x-$have_dl" = "x-no" ; then
2221           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2222       fi
2223     fi
2226     dnl x11 hidd
2227     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2228                                            [build X11 hidd for hosted (default=auto)]),
2229                                            x11_hidd="$enableval",
2230                                            x11_hidd="$need_x11")
2231     case "x-$x11_hidd" in
2232         x-yes|x-no|x-auto)                 ;;
2233         *)                 x11_hidd="$need_x11" ;;
2234     esac
2236     ENABLE_X11=0
2238     dnl they want it
2239     if test "x-$x11_hidd" != "x-no" ; then
2241         dnl find x11 stuff
2242         AC_PATH_X
2244         x_cflags=
2245         for path in $x_libraries
2246         do
2247             x_cflags="$x_cflags -L$path"
2248         done
2250         for path in $x_includes
2251         do
2252             x_cflags="$x_cflags -I$path"
2253         done
2254         
2255         if test "x-$no_x" = "x-yes" ; then
2257             dnl didn't find it
2258             if test "x-$x11_hidd" != "x-auto" ; then
2259                 dnl and they explicitly asked for it, bail out
2260                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2261             fi
2262         
2263         else
2264             dnl found it, setup the metatarget
2265             x11_hidd_target=kernel-x11gfx-kobj
2266             ENABLE_X11=1
2268             dnl setup shared memory extensions
2269             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2270                                                   [use X11 shared memory (default=auto)]),
2271                                                   x11_hidd_shm="$enableval",
2272                                                   x11_hidd_shm="auto")
2273             case "x-$x11_hidd_shm" in
2274                 x-yes|x-no|x-auto)                     ;;
2275                 *)                 x11_hidd_shm="auto" ;;
2276             esac
2278             have_xshm=no
2280             dnl they want it
2281             if test "x-$x11_hidd_shm" != "x-no" ; then
2283                 dnl system shm headers
2284                 AC_CHECK_HEADERS(sys/ipc.h)
2285                 AC_CHECK_HEADERS(sys/shm.h)
2287                 dnl got them
2288                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2290                     dnl make sure X libs have shm functions
2291                     save_cflags="$CFLAGS"
2292                     CFLAGS="$CFLAGS $x_cflags"
2293                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2294                     CFLAGS="$save_cflags"
2295                 fi
2296             fi
2298             dnl detection done, prepare output
2299             if test "x-$have_xshm" = "x-yes" ; then
2300                 dnl we can do shm
2301                 DO_XSHM_SUPPORT="1"
2302             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2303                 dnl they explicitly asked for it, but we can't do it
2304                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2305             else
2306                 dnl otherwise just disable it
2307                 DO_XSHM_SUPPORT="0"
2308             fi
2310             
2311             dnl setup vidmode (fullscreen) extensions
2312             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2313                                                       [use X11 vidmode extension (default=auto)]),
2314                                                       x11_hidd_vidmode="$enableval",
2315                                                       x11_hidd_vidmode="auto")
2316             case "x-$x11_hidd_vidmode" in
2317                 x-yes|x-no|x-auto)                         ;;
2318                 *)                 x11_hidd_vidmode="auto" ;;
2319             esac
2321             have_vidmode=no
2323             dnl they want it
2324             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2326                 dnl make sure X libs have vidmode functions
2327                 save_cflags="$CFLAGS"
2328                 CFLAGS="$CFLAGS $x_cflags"
2329                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2330                 CFLAGS="$save_cflags"
2331             fi
2333             dnl detection done, prepare output
2334             if test "x-$have_vidmode" = "x-yes" ; then
2335                 dnl we can do vidmode
2336                 DO_VIDMODE_SUPPORT="1"
2337             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2338                 dnl they explicitly asked for it, but we can't do it
2339                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2340             else
2341                 dnl otherwise just disable it
2342                 DO_VIDMODE_SUPPORT="0"
2343             fi
2344         fi
2346         aros_host_x11_includes=$x_includes 
2347         aros_host_x11_libdirs=$x_libraries
2348     fi
2351     dnl sdl hidd
2352     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2353                                            [build SDL hidd for hosted (default=auto)]),
2354                                            sdl_hidd="$enableval",
2355                                            sdl_hidd="auto")
2356     case "x-$sdl_hidd" in
2357         x-yes|x-no|x-auto)                 ;;
2358         *)                 sdl_hidd="auto" ;;
2359     esac
2361     dnl they want it
2362     if test "x-$sdl_hidd" != "x-no" ; then
2364         dnl find sdl
2365         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
2367         if test "x-$have_sdl" != "x-yes" ; then
2369             dnl didn't find it
2370             if test "x-$sdl_hidd" != "x-auto" ; then
2371                 dnl and they explicitly asked for it, bail out
2372                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2373             fi
2375         else
2376             dnl found it, set up the metatarget
2377             sdl_hidd_target=kernel-hidd-sdl
2378             aros_host_sdl_cflags=SDL_CFLAGS
2379             aros_host_sdl_libs=SDL_LIBS
2380         fi
2381     fi
2383     dnl oss.library
2384     AC_CHECK_HEADER(sys/soundcard.h)
2385     if test "x-$ac_cv_header_sys_soundcard_h" = "x-yes" ; then
2386         oss_library_target=workbench-libs-oss-unix
2387     fi
2391 dnl See if the user wants dbus.library
2392 AC_MSG_CHECKING([if building of dbus.library is enabled])
2393 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2394 if test "$dbus" = "yes" ; then
2395     ENABLE_DBUS=1
2396     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2397     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2398     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2399     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2400 else
2401     ENABLE_DBUS=0
2403 AC_MSG_RESULT($dbus)
2405 if test "$use_kernel_cc_wrapper" = "yes" ; then
2406     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc"
2409 dnl --------------------------------------------------------------------
2410 dnl Configuration Output Section
2411 dnl --------------------------------------------------------------------
2413 # Generic
2414 AC_SUBST(aros_arch)
2415 AC_SUBST(aros_cpu)
2416 AC_SUBST(aros_flavour)
2417 AC_SUBST(aros_flavour_uc)
2418 AC_SUBST(AROS_BUILDDIR)
2419 AC_SUBST(AROS_BUILDDIR_UNIX)
2420 AC_SUBST(SRCDIR)
2421 AC_SUBST(AROS_CROSSTOOLSDIR)
2422 AC_SUBST(AROS_PORTSSRCDIR)
2424 # Compatability with other Amiga-like operation systems
2425 AC_SUBST(aros_amigaos_compliance)
2427 # Host related
2428 AC_SUBST(aros_cc_pre)
2429 AC_SUBST(aros_host_strip)
2430 AC_SUBST(aros_host_arch)
2431 AC_SUBST(aros_host_cpu)
2432 AC_SUBST(aros_host_cc)
2433 AC_SUBST(aros_host_ar)
2434 AC_SUBST(aros_host_ranlib)
2435 AC_SUBST(aros_host_ld)
2436 AC_SUBST(aros_host_make)
2437 AC_SUBST(aros_host_cflags)
2438 AC_SUBST(gnu89_inline)
2439 AC_SUBST(aros_host_ldflags)
2440 AC_SUBST(aros_host_debug)
2441 AC_SUBST(aros_host_mkdep)
2442 AC_SUBST(aros_host_mkargs)
2443 AC_SUBST(aros_host_exe_suffix)
2444 AC_SUBST(aros_host_lib_suffix)
2445 AC_SUBST(aros_tools_dir)
2446 AC_SUBST(aros_host_aclocal)
2447 AC_SUBST(aros_host_autoconf)
2448 AC_SUBST(aros_host_autoheader)
2449 AC_SUBST(aros_host_automake)
2450 AC_SUBST(ant)
2452 # Target Related
2453 AC_SUBST(aros_target_guitheme)
2454 AC_SUBST(aros_target_iconset)
2455 AC_SUBST(aros_target_bootloader)
2456 AC_SUBST(aros_target_arch)
2457 AC_SUBST(aros_target_family)
2458 AC_SUBST(aros_target_cpu)
2459 AC_SUBST(aros_target_variant)
2460 AC_SUBST(aros_target_suffix)
2461 AC_SUBST(aros_target_incl)
2462 AC_SUBST(aros_target_ar)
2463 AC_SUBST(aros_target_ranlib)
2464 AC_SUBST(aros_plain_nm)
2465 AC_SUBST(aros_plain_ar)
2466 AC_SUBST(aros_kernel_ar)
2467 AC_SUBST(aros_kernel_ranlib)
2468 AC_SUBST(orig_target_cc)
2469 AC_SUBST(aros_target_cc)
2470 AC_SUBST(aros_target_cxx)
2471 AC_SUBST(aros_kernel_cc)
2472 AC_SUBST(aros_target_as)
2473 AC_SUBST(orig_target_ld)
2474 AC_SUBST(aros_target_ld)
2475 AC_SUBST(aros_kernel_ld)
2476 AC_SUBST(aros_target_cc_includes)
2477 AC_SUBST(aros_target_cc_path)
2478 AC_SUBST(aros_target_objdump)
2479 AC_SUBST(aros_target_objcopy)
2480 AC_SUBST(aros_target_strip)
2481 AC_SUBST(aros_target_nm)
2482 AC_SUBST(aros_kernel_rescomp)
2483 AC_SUBST(aros_shared_default)
2484 AC_SUBST(aros_shared_ld)
2485 AC_SUBST(aros_object_format)
2486 AC_SUBST(aros_compiler_libs)
2487 AC_SUBST(aros_arch_libs)
2489 AC_SUBST(aros_config_cflags)
2490 AC_SUBST(aros_config_aflags)
2491 AC_SUBST(aros_config_ldflags)
2493 AC_SUBST(aros_shared_cflags)
2494 AC_SUBST(aros_shared_aflags)
2495 AC_SUBST(aros_shared_ldflags)
2496 AC_SUBST(aros_kernel_cflags)
2497 AC_SUBST(aros_kernel_includes)
2498 AC_SUBST(aros_kernel_objcflags)
2499 AC_SUBST(aros_kernel_ldflags)
2500 AC_SUBST(aros_target_cflags)
2501 AC_SUBST(aros_debug_cflags)
2502 AC_SUBST(aros_debug_aflags)
2503 AC_SUBST(aros_debug_ldflags)
2504 AC_SUBST(aros_target_genmap)
2505 AC_SUBST(aros_target_strip_flags)
2507 AC_SUBST(crosstools_target)
2508 AC_SUBST(crosstools_cxx_target)
2510 # Delinting target compiler flags
2511 AC_SUBST(aros_cflags_unused_but_set_variable)
2512 AC_SUBST(aros_cflags_array_bounds)
2513 AC_SUBST(aros_cflags_enum_compare)
2514 AC_SUBST(aros_cflags_strict_overflow)
2515 AC_SUBST(aros_cflags_format_security)
2517 # Graphics Related
2518 AC_SUBST(x11_hidd_target)
2519 AC_SUBST(sdl_hidd_target)
2520 AC_SUBST(pci_hidd_target)
2521 AC_SUBST(oss_library_target)
2523 AC_SUBST(aros_default_wbwidth)
2524 AC_SUBST(aros_default_wbheight)
2525 AC_SUBST(aros_default_wbdepth)
2526 AC_SUBST(DO_XSHM_SUPPORT)
2527 AC_SUBST(DO_VIDMODE_SUPPORT)
2529 AC_SUBST(aros_host_x11_includes)
2530 AC_SUBST(aros_host_x11_libdirs)
2531 AC_SUBST(aros_host_sdl_cflags)
2532 AC_SUBST(aros_host_sdl_libs)
2534 # Native version related
2535 AC_SUBST(aros_serial_debug)
2537 # Palm native version related
2538 AC_SUBST(aros_palm_debug_hack)
2540 # USB3.0 code
2541 AC_SUBST(aros_usb30_code)
2543 # Unix/Hosted version related
2544 AC_SUBST(aros_nesting_supervisor)
2546 # MMU related
2547 AC_SUBST(aros_enable_mmu)
2549 # Apple iOS related
2550 AC_SUBST(aros_ios_platform)
2551 AC_SUBST(aros_ios_version)
2552 AC_SUBST(aros_ios_sdk)
2554 # Android related
2555 AC_SUBST(android_tool)
2556 AC_SUBST(aros_android_level)
2558 # DBUS related
2559 AC_SUBST(ENABLE_DBUS)
2560 AC_SUBST(DBUS_CFLAGS)
2561 AC_SUBST(DBUS_LIBFLAGS)
2562 AC_SUBST(KERNEL_DBUS_KOBJ)
2563 AC_SUBST(KERNEL_DBUS_INCLUDES)
2565 #X11 related
2566 AC_SUBST(ENABLE_X11)
2568 # Debug related
2569 AC_SUBST(aros_debug)
2570 AC_SUBST(aros_mungwall_debug)
2571 AC_SUBST(aros_stack_debug)
2572 AC_SUBST(aros_modules_debug)
2574 # Collect-aros stuff: "-ius" to ignore undefined symbols
2575 AC_SUBST(ignore_undefined_symbols)
2577 # C compiler related
2578 AC_SUBST(gcc_target_cpu)
2580 dnl Prepare for output, make up all the generated patches
2581 case "$aros_flavour" in
2582 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2583                 aros_flavour="emulation" ;;
2584 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2585                 aros_flavour="emulation" ;;
2586 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2587                 aros_flavour="standalone";;
2588 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2589                 aros_flavour="standalone";;
2590 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2591                 aros_flavour="native" ;;
2592 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2593                 aros_flavour="native" ;;
2594 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2595                 aros_flavour="linklib" ;;
2596 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2597                 aros_flavour="palmnative" ;;
2598 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2599                 aros_flavour="mac68knative" ;;
2600 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2601                 aros_flavour="ppcnative" ;;
2602 esac
2604 if test ! -d ${aros_inc_dir} ; then
2605     ${MKDIR} ${aros_inc_dir}
2607 if test ! -d ${aros_geninc_dir} ; then
2608     ${MKDIR} ${aros_geninc_dir}
2610 if test ! -d ${aros_hostcfg_dir} ; then
2611     ${MKDIR} ${aros_hostcfg_dir}
2613 if test ! -d ${aros_targetcfg_dir} ; then
2614     ${MKDIR} ${aros_targetcfg_dir}
2616 if test ! -d ${aros_tools_dir} ; then
2617     ${MKDIR} ${aros_tools_dir}
2619 if test ! -d ${aros_scripts_dir} ; then
2620     ${MKDIR} ${aros_scripts_dir}
2623 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2625 AC_CONFIG_COMMANDS([compiler_executable],
2626     [
2627         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2628         mkdir -p $prefix
2629         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2630         prefix3=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
2632         echo ${prefix2}
2633         echo ${prefix3}
2634         chmod a+x ${prefix2}-gcc ${prefix2}-ld ${prefix3}-gcc
2636         ln -sf $aros_target_as_ln$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
2637         ln -sf $aros_target_nm_ln$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
2638         ln -sf $aros_target_ar_ln$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
2639         ln -sf $aros_target_ranlib_ln$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
2640         ln -sf $aros_target_objcopy_ln$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
2641         ln -sf $aros_target_objdump_ln$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
2642         ln -sf $aros_target_strip_ln$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
2644         ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix3}-ld$aros_host_exe_suffix
2645     ],
2646     [
2647         aros_host_exe_suffix=${aros_host_exe_suffix}
2648         aros_tools_dir=${aros_tools_dir}
2649         aros_target_cpu=${aros_target_cpu}
2650         aros_target_arch=${aros_target_arch}
2651         aros_target_suffix=${aros_target_suffix}
2652         aros_target_nm_ln=${aros_target_nm_ln}
2653         aros_target_as_ln=${aros_target_as_ln}
2654         aros_target_ar_ln=${aros_target_ar_ln}
2655         aros_target_ranlib_ln=${aros_target_ranlib_ln}
2656         aros_target_objdump_ln=${aros_target_objdump_ln}
2657         aros_target_objcopy_ln=${aros_target_objcopy_ln}
2658         aros_target_strip_ln=${aros_target_strip_ln}
2659         aros_kernel_ld=${aros_kernel_ld}
2660     ]
2662 AC_CONFIG_COMMANDS([genmf_executable],
2663     [chmod a+x ${aros_tools_dir}/genmf.py],
2664     [aros_tools_dir=${aros_tools_dir}]
2667 AC_CONFIG_FILES(
2668     Makefile
2669     config/make.cfg
2670     ${aros_inc_dir}/config.h:config/config.h.in
2671     ${aros_geninc_dir}/config.h:config/config.h.in
2672     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2673     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2674     mmake.config
2675     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2676     ${aros_targetcfg_dir}/specs:config/specs.in
2677     ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
2678     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
2679     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
2680     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
2681     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2682     tools/collect-aros/env.h
2683     ${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in
2686 AC_OUTPUT
2688 dnl This is in order to not define SHARED_CFLAGS sometimes
2689 dnl We don't always do aros_shared_ar, aros_shared_cflags
2691 #XXX compatability...
2692 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
2694 if test -n "$aros_shared_cflags" ; then
2695     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
2696     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg