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