White space fixes, detab.
[AROS.git] / configure.in
blob8dc19675bebb19f970f1676e77744380e61308d3
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                 if test "$aros_host_cpu" != "arm" ; then
899                     kernel_tool_prefix="arm-linux-gnueabi-"
900                 fi
901                 ;;
902             *)
903                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
904                 ;;
905         esac
906         case "$aros_target_variant" in
907             android)
909                 dnl Not all Linux CPUs are supported by Android
910                 if test "$android_ndk_arch" = ""; then
911                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
912                 fi
914                 aros_default_wbwidth=320
915                 aros_default_wbheight=480
916                 if test "$aros_android_ndk" = "none"; then
917                     dnl Use standalone toolchain, don't adjust paths
918                     aros_kernel_cflags="-mandroid"
919                     aros_kernel_ldflags="-mandroid"
920                     CFLAGS="-mandroid"
921                 else
922                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$target_tool_version/prebuilt/$android_build_os/bin:$PATH"
923                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
924                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
925                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
926                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
927                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
928                 fi
929                 need_x11=no
930                 dnl (Ab)use $(X11_HIDD_TARGET) as "Default display driver target"
931                 dnl in order not to fill mmakefiles with garbage
932                 x11_hidd_target=kernel-hidd-androidgfx-kobj
933                 # Disable implicit PIC mode
934                 aros_kernel_cflags="$aros_kernel_cflags -fno-pic"
935                 aros_target_cflags="$aros_target_cflags -fno-pic"
936                 kernel_tool_prefix="$android_tool_prefix-"
937             ;;
938         esac
939     ;;
941     pc)
942         aros_target_arch="pc"
943         aros_shared_default="no"
944         target_bootloader="grub2"
945         case "$target_cpu" in
946             *i?86*)
947                 aros_target_cpu="i386"
949                 dnl If somebody hasn't already set the target object
950                 dnl format, then use this value. Mostly to support
951                 dnl FreeBSD cross-compilation.
952                 dnl TODO: Remove when we always use our compiler.
954                 if test "$aros_object_format" = "" ; then
955                     aros_object_format="elf_i386"
956                 fi
957                 aros_flavour="standalone"
958                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
959                 aros_config_cflags="$aros_config_cflags -m32 -march=i486"
960                 aros_kernel_cflags="$aros_kernel_cflags -m32 -march=i486"
961                 aros_config_aflags="$aros_config_aflags -m32 -march=i486"
962                 aros_config_ldflags="-m32 -march=i486"
963                 aros_kernel_ldflags="-melf_i386"
964                 aros_default_wbwidth=640
965                 aros_default_wbheight=480
966                 gcc_target_cpu="i386"
967                 ;;
968             *x86_64*)
969                 aros_target_cpu="x86_64"
970                 aros_serial_debug=1
971                 if test "$aros_object_format" = "" ; then
972                     aros_object_format="elf_x86_64"
973                 fi
974                 aros_flavour="standalone"
975                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
976                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
977                 aros_kernel_ldflags=""
978                 aros_default_wbwidth=640
979                 aros_default_wbheight=480
980                 ;;
981             *)
982                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
983                 ;;
984         esac
985         ;;
987     prep)
988         aros_target_arch="prep"
989         aros_shared_default="no"
990         aros_target_cpu="ppc"
991         aros_object_format="elf32ppc"
992         aros_flavour="ppcnative"
993         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
994         aros_kernel_ldflags=""
995         aros_default_wbwidth=640
996         aros_default_wbheight=480
997         gcc_target_cpu="ppc"
998         ;;
1000     freebsd*)
1001         aros_target_arch="freebsd"
1002         aros_target_family="unix"
1003         aros_target_cpu="i386"
1004         aros_flavour="emulation"
1005         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1006         gcc_target_cpu="i386"
1008         aros_target_strip_flags="-x"
1009         ;;
1011     darwin*)
1012         aros_target_arch="darwin"
1013         aros_target_family="unix"
1014         aros_flavour="emulation"
1015         case "$target_cpu" in
1016             *i?86*)
1017                 aros_ios_platform="iPhoneSimulator"
1018                 aros_target_cpu="i386"
1019                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1020                 aros_kernel_ldflags=""
1021                 aros_macosx_version="10.4"
1022                 aros_default_wbdepth=8
1023                 gcc_target_cpu="i386"
1024                 aros_object_format="elf_i386"
1025                 aros_kernel_ar_flags="-cr"
1026                 aros_target_strip_flags="-x"
1027                 kernel_tool_flags="-m32"
1028                 ;;
1029             *x86_64*)
1030                 aros_target_cpu="x86_64"
1031                 aros_object_format="elf_x86_64"
1032                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1033                 aros_macosx_version="10.6"
1034                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1035                 aros_kernel_cflags="-m64"
1036                 aros_kernel_ldflags="-m64"
1037                 aros_target_cflags="-mcmodel=large"
1038                 aros_default_wbdepth=8
1039                 aros_kernel_ar="ar"
1040                 aros_kernel_ar_flags="-cr"
1041                 aros_kernel_ld="ld"
1042                 aros_kernel_ranlib="ranlib"
1043                 ;;
1044             *ppc*)
1045                 aros_target_cpu="ppc"
1046                 aros_object_format="elf32ppc"
1047                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1048                 aros_kernel_ldflags=""
1049                 aros_macosx_version="10.0"
1050                 aros_default_wbdepth=8
1051                 gcc_target_cpu="ppc"
1052                 aros_kernel_ar="ar"
1053                 aros_kernel_ar_flags="-cr"
1054                 aros_kernel_ld="ld -arch ppc"
1055                 aros_kernel_ranlib="ranlib -arch ppc"
1056                 kernel_tool_prefix="powerpc-apple-darwin10-"
1057                 ;;
1058             *arm*)
1059                 aros_ios_platform="iPhoneOS"
1060                 aros_target_cpu="arm"
1061                 aros_object_format="armelf_linux_eabi"
1062                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1063                 aros_arch_libs="-laeabi"
1064                 aros_default_wbdepth=8
1065                 gcc_target_cpu="arm"
1066                 aros_kernel_ar="ar"
1067                 aros_kernel_ar_flags="-cr"
1068                 aros_kernel_ld="ld -arch arm"
1069                 aros_kernel_ranlib="ranlib -arch arm"
1070                 kernel_tool_prefix="arm-apple-darwin10-" 
1071                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1072                 ;;
1073             *)
1074                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1075                 ;;
1076         esac
1077         case "$aros_target_variant" in
1078             ios)
1079                 aros_ios_version="3.0"
1080                 aros_default_wbwidth=320
1081                 aros_default_wbheight=480
1082                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1083                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1084                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1085                 need_x11=no
1086                 # This is here because it may depend on iOS or SDK version
1087                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1088                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1089                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1090             ;;
1091             *)
1092                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1093                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1094             ;;
1095         esac
1096         ;;
1098     dragonfly*)
1099         aros_target_arch="dragonfly"
1100         aros_target_family="unix"
1101         aros_flavour="emulation"
1102         case "$target_cpu" in
1103             *i?86*)
1104                 aros_target_cpu="i386"
1105                 aros_object_format="elf_i386"
1106                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1107                 ;;
1108             *x86_64*)
1109                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1110                 aros_target_cpu="x86_64"
1111                 aros_object_format="elf_x86_64"
1112                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1113                 ;;
1114             *)
1115                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1116                 ;;
1117         esac
1118         ;;
1120     netbsd*)
1121         aros_target_arch="netbsd"
1122         aros_target_family="unix"
1123         case "$target_cpu" in
1124             *m68k*)
1125                 aros_target_cpu="m68k"
1126                 aros_object_format="m68kelf"
1127                 aros_flavour="emulcompat"
1128                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1129                 gcc_target_cpu="mc68000"
1130                 ;;
1131             *i?86*)
1132                 aros_target_cpu="i386"
1133                 aros_object_format="elf_i386"
1134                 aros_flavour="emulation"
1135                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1136                 aros_default_wbdepth=8
1137                 gcc_target_cpu="i386"
1138                 ;;
1139             *)
1140                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1141                 ;;
1142         esac
1143         aros_target_genmap="-Wl,-M -Xlinker >"
1144         aros_flavour="emulation"
1145         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1146         ;;   
1148     openbsd*)
1149         aros_target_arch="openbsd"
1150         aros_target_family="unix"
1151         case "$target_cpu" in
1152             *i?86*)
1153                 aros_target_cpu="i386"
1154                 aros_object_format="elf_i386"
1155                 aros_flavour="emulation"
1156                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1157                 gcc_target_cpu="i386"
1158                 ;;
1159             *)
1160                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1161                 ;;
1162         esac
1163         aros_target_genmap="-Wl,-M -Xlinker >"
1164         aros_target_nm_flags="-u"
1165         aros_flavour="emulation"
1166         ;;
1168     solaris*)
1169         aros_target_arch="solaris"
1170         aros_target_family="unix"
1171         case "$target_cpu" in
1172            *i?86*)
1173                aros_target_cpu="i386"
1174                aros_object_format="elf_i386"
1175                aros_flavour="emulation"
1176                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1177                aros_default_wbdepth=8
1178                gcc_target_cpu="i386"
1179                ;;
1180             *sparc*)
1181                 aros_target_cpu="sparc"
1182                 aros_object_format="elf_sparc"
1183                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1184                 gcc_target_cpu="sparc"
1185                 ;;
1186             *)
1187                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1188                 ;;
1189         esac
1190         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1191         aros_flavour="emulation"
1192         ;;
1194     morphos*)
1195         aros_target_arch="morphos"
1196         aros_shared_default="no"
1197         aros_target_cpu="ppc"
1198         aros_object_format="elf_ppc"
1199         aros_flavour="nativecompat"
1200         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1201         gcc_target_cpu="ppc"
1202         ;;
1204     sam440)
1205         aros_target_arch="sam440"
1206         aros_shared_default="no"
1207         aros_target_cpu="ppc"
1208         aros_object_format="elf32ppc"
1209         aros_flavour="ppcnative"
1210         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1211         aros_kernel_ldflags=""
1212         aros_default_wbwidth=1024
1213         aros_default_wbheight=768
1214         aros_default_wbdepth=24
1215         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1216         gcc_target_cpu="powerpc"
1217         ;;
1219     efika)
1220         aros_target_arch="efika"
1221         aros_shared_default="no"
1222         aros_target_cpu="arm"
1223         aros_object_format="armelf_linux_eabi"
1224         aros_flavour="standalone"
1225         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1226         aros_kernel_ldflags=""
1227         aros_default_wbwidth=1024
1228         aros_default_wbheight=600
1229         aros_arch_libs="-laeabi"
1230         gcc_default_cpu="armv7-a"
1231         gcc_default_fpu="vfpv3"
1232         gcc_default_float_abi="softfp"
1233         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing"
1234         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing"
1235         ;;
1236         
1237     chrp)
1238     aros_target_arch="chrp"
1239     aros_shared_default="no"
1240     aros_target_cpu="ppc"
1241     aros_object_format="elf32ppc"
1242     aros_flavour="ppcnative"
1243     aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1244     aros_kernel_ldflags=""
1245     aros_default_wbwidth=640
1246     aros_default_wbheight=480
1247     aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1248     gcc_target_cpu="powerpc"
1249         case "$aros_target_variant" in
1250             efika)
1251             aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1252             ;;
1253         esac
1254     ;;
1256     amiga*)
1257         aros_target_arch="amiga"
1258         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1259         aros_shared_default="no"
1261         case "$target_cpu" in
1262             *m68k*)
1263                 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")
1264                 aros_enable_mmu=no
1265                 aros_target_cpu="m68k"
1266                 aros_object_format="m68kelf"
1267                 aros_flavour="standcompat"
1268                 gcc_target_cpu="m68000"
1269                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -${gcc_target_cpu} -fbuiltin -Wno-volatile-register-var -Os"
1270                 aros_config_aflags="$aros_config_aflags -${gcc_target_cpu}"
1271                 # Needed to get the correct multilib
1272                 aros_config_ldflags="-${gcc_target_cpu}"
1273                 aros_shared_ldflags="-${gcc_target_cpu}"
1274                 aros_kernel_ldflags="-${gcc_target_cpu}"
1275                 aros_target_nostdlib_ldflags="-${gcc_target_cpu}"
1276                 aros_target_strip_flags="-R.comment --strip-debug"
1277                 aros_default_wbwidth=640
1278                 aros_default_wbheight=256
1279                 aros_default_wbdepth=2
1280                 ;;
1281             *ppc*)
1282                 aros_cpu="ppc"
1283                 aros_flavour="native"
1284                 gcc_target_cpu="ppc"
1285                 ;;
1286             *)
1287                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1288                 ;;
1289         esac
1290         ;;
1292     mingw*)
1293         aros_target_arch="mingw32"
1294         aros_shared_default="no"
1295         aros_flavour="emulation"
1296         aros_shared_cflags=""
1297         need_dlopen="no"
1298         rescomp="windres"
1299         case "$target_cpu" in
1300             *i?86*)
1301                 aros_target_cpu="i386"
1302                 aros_object_format="elf_i386"
1303                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1304                 aros_default_wbdepth=8
1305                 gcc_target_cpu="i386"
1307                 kernel_tool_prefix="i386-mingw32-"
1308                 ;;
1309             *x86_64*)
1310                 aros_target_cpu="x86_64"
1311                 aros_object_format="elf_x86_64"
1312                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1313                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1314                 aros_default_wbdepth=8
1315                 kernel_tool_prefix="x86_64-w64-mingw32-"
1316                 ;;
1317             *arm*)
1318                 aros_target_cpu="arm"
1319                 aros_object_format="armelf_linux_eabi"
1320                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1321                 aros_arch_libs="-laeabi"
1322                 aros_default_wbdepth=8
1323                 gcc_target_cpu="arm"
1324                 gcc_default_float_abi="soft"
1325                 kernel_tool_prefix="arm-mingw32ce-"
1326                 aros_default_wbwidth=160
1327                 aros_default_wbheight=160
1328                 ;;
1329             *)
1330                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1331                 ;;
1332         esac
1333         if test $host_os = "cygwin"; then
1334                 aros_kernel_cflags="-mno-cygwin"
1335         fi
1336     ;;
1337     pp*)
1338         aros_target_arch="pp"
1339         aros_shared_default="no"
1340         case "$target_cpu" in
1341             *m68k*)
1342                 aros_target_cpu="m68k"
1343                 aros_object_format="m68kelf"
1344                 aros_flavour="palmnative"
1345                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1346                 aros_default_wbwidth=160
1347                 aros_default_wbheight=160
1348                 aros_default_wbdepth=1
1349                 aros_target_ar_flags="cru"
1350                 aros_compiler_libs="-lgcc1"
1351                 aros_shared_default=no
1352                 aros_shared_cflags="-fpic"
1353                 aros_shared_aflags=""
1354                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1355                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1356                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
1357                 aros_debug_aflags=""
1358                 aros_debug_ldflags="$aros_symbols_debug"
1359                 aros_mungwall_debug="0"
1360                 aros_modules_debug="0"
1361                 gcc_target_cpu="mc68000"
1362                 ignore_undefined_symbols="-ius"
1363                 ;;
1364            *)
1365                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1366                 ;;
1367         esac
1368         ;;
1370     mac*)
1371         aros_target_arch="mac"
1372         aros_shared_default="no"
1373         case "$target_cpu" in
1374             *m68k*)
1375                 aros_target_cpu="m68k"
1376                 aros_object_format="m68kelf"
1377                 aros_flavour="mac68knative"
1378                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1379                 aros_default_wbwidth=512
1380                 aros_default_wbheight=384
1381                 aros_default_wbdepth=8
1382                 aros_target_ar_flags="cru"
1383                 aros_compiler_libs="-lgcc1"
1384                 aros_shared_default=no
1385                 aros_shared_cflags="-fpic"
1386                 aros_shared_aflags=""
1387                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1388                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1389                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug -mc68000"
1390                 aros_debug_aflags=""
1391                 aros_debug_ldflags="$aros_symbols_debug"
1392                 aros_mungwall_debug="0"
1393                 aros_modules_debug="0"
1394                 gcc_target_cpu="mc68000"
1395                 ignore_undefined_symbols="-ius"
1396                 ;;
1397            *)
1398                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1399                 ;;
1400         esac
1401         ;;
1403     *)
1404         AC_MSG_ERROR([Unsupported target architecture $target])
1405         ;;
1406 esac
1408 #-----------------------------------------------------------------------------
1409 AC_MSG_CHECKING([where to install or search for cross tools binaries])
1410 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")
1411 if test "$with_crosstools" = "default"; then
1412     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1413 else
1414     # Disable building crosstools if we are using an external set - otherwise
1415     # we may attempt to overwrite them if the tools-crosstools target is made!
1416     crosstools=no
1417     AROS_CROSSTOOLSDIR="$with_crosstools"
1418     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1420 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1422 AC_MSG_CHECKING([Kernel tool prefix])
1423 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"])
1424 AC_MSG_RESULT($kernel_tool_prefix)
1426 target_tool_prefix=${target_cpu}-aros-
1428 # Now process extra architecture-specific options.
1429 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1430 # as well as floating-point ABI.
1431 case "$aros_target_cpu" in
1432 arm)
1433     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1434     if test "$gcc_default_cpu" = ""; then
1435         gcc_default_cpu="armv6"
1436     fi
1437     if test "$gcc_default_fpu" = ""; then
1438         gcc_default_fpu="vfp"
1439     fi
1440     if test "$gcc_default_float_abi" = ""; then
1441         gcc_default_float_abi="softfp"
1442     fi
1444     AC_MSG_CHECKING([Which minimum CPU to use])
1445     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)
1446     AC_MSG_RESULT($aros_gcc_cpu)
1448     AC_MSG_CHECKING([Which minimum FPU to use])
1449     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)
1450     AC_MSG_RESULT($aros_gcc_fpu)
1452     AC_MSG_CHECKING([Which floating point ABI to use])
1453     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)
1454     AC_MSG_RESULT($aros_gcc_float_abi)
1456     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"
1457     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"
1458     ;;
1459 esac
1461 # Some formats need custom ELF specs.
1462 # For example for x86_64 it is needed in order for -m32 switch to work correctly.
1463 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1464     elf_specs_in=config/${aros_object_format}-specs.in
1465 else
1466     elf_specs_in=config/elf-specs.in
1469 AC_MSG_CHECKING([what specific AROS gcc version to use])
1470 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="")
1471 AC_MSG_RESULT($aros_gcc_version)
1473 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1474 # Since we override specs, we may need to put these defines there
1475 if test "$gcc_target_cpu" != ""; then
1476     gcc_target_cpu="-D__${gcc_target_cpu}__"
1479 AC_MSG_CHECKING([where to download sourcecode for external ports])
1480 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1481 if test "$with_portssrcdir" = "default"; then
1482     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1483 else
1484     AROS_PORTSSRCDIR="$with_portssrcdir"
1486 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1488 AC_MSG_CHECKING([which bootloader to use])
1489 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1490 if test "$target_bootloader" = "none"; then
1491     aros_target_bootloader=""
1492 else
1493     aros_target_bootloader="$target_bootloader"
1495 AC_MSG_RESULT($target_bootloader)
1497 AC_MSG_CHECKING([which icon-set to use])
1498 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1499 if test "$target_iconset" = "default"; then
1500     aros_target_iconset="Gorilla"
1501     target_iconset="default (Gorilla)"
1502 else
1503     aros_target_iconset="$target_iconset"
1505 AC_MSG_RESULT($target_iconset)
1507 AC_MSG_CHECKING([which GUI Theme to use])
1508 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1509 if test "$target_guitheme" = "default"; then
1510     aros_target_guitheme="Ice"
1511 else
1512     aros_target_guitheme="$target_guitheme"
1514 AC_MSG_RESULT($aros_target_guitheme)
1516 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1517 # for target code)
1518 cross_compiling=no
1519 if test "$aros_host_cpu" = "$aros_target_cpu" ; then
1520     # If host = target CPU, let's try to use the
1521     # host's toolchains if no others were requested
1522     if test "$kernel_tool_prefix" = "none" ; then
1523         kernel_tool_prefix=""
1524     fi
1525 else
1526     cross_compiling=yes
1529 dnl Native x86-64 Linux toolchain can also produce i386 binaries, given -m32 flag.
1530 if test "$aros_host_cpu" == "x86_64" ; then
1531     if test "$aros_target_cpu" == "i386" ; then
1532         if test "$aros_target_arch" != "mingw32"; then
1533             cross_compiling=no
1534             kernel_tool_prefix=""
1535         fi
1536     fi
1539 dnl Enforce cross-compile if we are on Darwin, but our target is not Darwin.
1540 dnl If target is Darwin disable cross-compiling otherwise kernel 
1541 dnl not setup correctly.
1542 if test "$aros_host_arch" == "darwin" ; then
1543     if test "$aros_target_arch" != "darwin" ; then
1544         cross_compiling=yes
1545     else
1546         cross_compiling=no
1547         kernel_tool_prefix=""
1548     fi
1551 dnl The same for MinGW
1552 if test "$aros_host_arch" == "mingw32" ; then
1553     if test "$aros_target_arch" != "mingw32" ; then
1554         cross_compiling=yes
1555     fi
1558 #######################################################################
1559 ## Compute what toolchains to use, and their paths                   ##
1560 #######################################################################
1562 # This takes, as input:
1563 #   crosstools             {yes,no}
1564 #   aros_gcc_version       {default,[version]}
1565 #   kernel_tool_prefix     {none,[some-arch-os-]}
1566 #   target_tool_prefix     ${target_cpu}-aros-
1568 # The output is
1569 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1570 #        Where the 'kernel' binaries are located
1571 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1572 #        Where the 'target' binaries are located
1573 #        (not the symlink farm - that is aros_target_*!)
1575 # The rules are:
1576 #   if crosstools then
1577 #      if kernel_tools_prefix = "no-kernel-prefix-"
1578 #          aros_kernel_* = crosstools cc paths
1579 #          aros_kernel_cc = elf cc wrapper around crosstools cc
1580 #      else
1581 #          VALIDATE(${kernel_tools_prefix}*)
1582 #          aros_kernel_* = ${kernel_tools_prefix}*
1583 #          if ${kernel_tools_prefix}cc is an AROS gcc
1584 #              aros_kernel_cc = ${kernel_tools_prefix}cc
1585 #          else
1586 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
1587 #          fi
1588 #      fi
1590 #      orig_target_* = aros built crosstools
1591 #      orig_target_cc = elf cc wrapper around crosstools cc
1592 #   else
1593 #      VALIDATE(${kernel_tools_prefix}*)
1595 #      orig_target_* = aros_kernel_*
1596 #      if aros_kernel_cc is an AROS gcc
1597 #          orig_target_cc = aros_kernel_cc
1598 #      else
1599 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
1600 #      fi
1601 #   fi
1604 AC_MSG_CHECKING([whether to use external toolchain])
1605 if test "$kernel_tool_prefix" = "none" ; then
1606     AC_MSG_RESULT([no]);
1607     if test "$crosstools" != "yes"; then
1608         AC_MSG_ERROR([--disable-crosstools requires --with-kernel-tool-prefix= for this arch])
1609     fi
1610     # We are building AROS crosstools, and no kernel
1611     # tools specified - assume target tools == kernel tools
1612     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
1613     aros_kernel_cc="${tmp_tool_prefix}gcc${aros_gcc_version}"
1614     aros_kernel_cxx="${tmp_tool_prefix}g++${aros_gcc_version}"
1615     aros_kernel_cpp="${tmp_tool_prefix}cpp"
1616     aros_kernel_ld="${tmp_tool_prefix}ld"
1617     aros_kernel_as="${tmp_tool_prefix}as"
1618     aros_kernel_ar="${tmp_tool_prefix}ar"
1619     aros_kernel_ranlib="${tmp_tool_prefix}ranlib"
1620     aros_kernel_nm="${tmp_tool_prefix}nm"
1621     aros_kernel_strip="${tmp_tool_prefix}strip"
1622     aros_kernel_objcopy="${tmp_tool_prefix}objcopy"
1623     aros_kernel_objdump="${tmp_tool_prefix}objdump"
1624 else
1625     AC_MSG_RESULT([yes]);
1626     # Kernel tools specified - find them
1627     # Note that 'normally', aros_kernel_* overrides will
1628     # empty, unless specified in the per-arch sections above.
1630     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
1631     AROS_REQUIRED(cpp,$aros_kernel_cpp)
1632     if test "x$aros_kernel_cc" = "x"; then
1633         aros_kernel_cc=${kernel_tool_prefix}gcc
1634     fi
1635     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${aros_gcc_version})
1636     AROS_REQUIRED(cc,$aros_kernel_cc)
1637     if test "x$aros_kernel_cxx" = "x"; then
1638         aros_kernel_cxx=${kernel_tool_prefix}g++
1639     fi
1640     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${aros_gcc_version})
1641     # If it's set, make sure it's really there
1642     if test "x$aros_kernel_cxx" != "x" ; then
1643         AROS_REQUIRED(cxx,$aros_kernel_cxx)
1644     fi
1645     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
1646     AROS_REQUIRED(ld,$aros_kernel_ld)
1647     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
1648     AROS_REQUIRED(as,$aros_kernel_as)
1649     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
1650     AROS_REQUIRED(ar,$aros_kernel_ar)
1651     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1652     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
1653     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
1654     AROS_REQUIRED(nm,$aros_kernel_nm)
1655     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
1656     AROS_REQUIRED(strip,$aros_kernel_strip)
1658     # Objcopy and objdump are not required for the kernel
1659     # toolchain on many architectures.
1660     # So we'll look for them, but not make them strictly required.
1661     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
1662     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
1663     if test "x${crosstools}" != "xyes" ; then
1664         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
1665         AROS_REQUIRED(objdump,$aros_kernel_objdump)
1666     fi
1669 AC_MSG_CHECKING([which target tools])
1670 if test "$crosstools" = "yes"; then
1671     AC_MSG_RESULT([$target_tool_prefix])
1672     # We are are building AROS crosstools
1673     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
1674     orig_target_cc="${tmp_tool_prefix}gcc${aros_gcc_version}"
1675     orig_target_cxx="${tmp_tool_prefix}g++${aros_gcc_version}"
1676     orig_target_cpp="${tmp_tool_prefix}cpp"
1677     orig_target_ld="${tmp_tool_prefix}ld"
1678     orig_target_as="${tmp_tool_prefix}as"
1679     orig_target_ar="${tmp_tool_prefix}ar"
1680     orig_target_ranlib="${tmp_tool_prefix}ranlib"
1681     orig_target_nm="${tmp_tool_prefix}nm"
1682     orig_target_strip="${tmp_tool_prefix}strip"
1683     orig_target_objcopy="${tmp_tool_prefix}objcopy"
1684     orig_target_objdump="${tmp_tool_prefix}objdump"
1685 else
1686     AC_MSG_RESULT([$kernel_tool_prefix])
1687     # We are *not* building AROS crosstools - use the kernel tools
1688     orig_target_cpp="${aros_kernel_cpp}"
1689     AROS_REQUIRED(cpp,$orig_target_cpp)
1690     orig_target_cc="${aros_kernel_cc}"
1691     AROS_REQUIRED(cc,$orig_target_cc)
1692     orig_target_cxx="${aros_kernel_cxx}"
1693     if test "x$orig_target_cxx" != "x" ; then
1694         AROS_REQUIRED(cxx,$orig_target_cxx)
1695     fi
1696     orig_target_ld="${aros_kernel_ld}"
1697     AROS_REQUIRED(ld,$orig_target_ld)
1698     orig_target_as="${aros_kernel_as}"
1699     AROS_REQUIRED(as,$orig_target_as)
1700     orig_target_ar="${aros_kernel_ar}"
1701     AROS_REQUIRED(ar,$orig_target_ar)
1702     orig_target_ranlib="${aros_kernel_ranlib}"
1703     AROS_REQUIRED(ranlib,$orig_target_ranlib)
1704     orig_target_nm="${aros_kernel_nm}"
1705     AROS_REQUIRED(nm,$orig_target_nm)
1706     orig_target_strip="${aros_kernel_strip}"
1707     AROS_REQUIRED(strip,$orig_target_strip)
1708     orig_target_objcopy="${aros_kernel_objcopy}"
1709     AROS_REQUIRED(objcopy,$orig_target_objcopy)
1710     orig_target_objdump="${aros_kernel_objdump}"
1711     AROS_REQUIRED(objdump,$orig_target_objdump)
1714 # At this point, all aros_kernel_* and aros_target_* 
1715 # tools should be set up correctly
1717 CC="$aros_kernel_cc $kernel_tool_flags"
1718 CPP="$aros_kernel_cpp"
1720 #-----------------------------------------------------------------------------
1722 # Disable pointer-signedness warnings if the compiler recognises the option
1724 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
1725 save_cflags="$CFLAGS"
1726 if test "$crosstools" != "yes" ; then
1727     CFLAGS="$CFLAGS -Wno-pointer-sign"
1728     AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
1729 else
1730     # we do know it is supported for the smallest version of gcc we are going to build
1731     # we assume it's also supported by later versions
1732     use_no_sign_warning=yes
1734 AC_MSG_RESULT($use_no_sign_warning)
1735 if test "x-$use_no_sign_warning" = "x-yes" ; then
1736     aros_config_cflags="$aros_config_cflags -Wno-pointer-sign"
1738 CFLAGS="$save_cflags"
1740 #-----------------------------------------------------------------------------
1742 # Find all the tools we need to compile. This could be cross-compiling
1743 # though! If that is the case we use the GNU form of the target and
1744 # simply add this to the front of the binary name. This is rather simple,
1745 # but it should work under most circumstances.
1747 # The default tools are to use the same as the host, but only if the
1748 # host and target CPU are the same. With GCC this is normally enough.
1751 aros_cc_pre=""
1752 aros_shared_ld="$aros_host_ld"
1754 aros_target_mkdep="$aros_host_mkdep"
1756 # The default tools executables to be linked to.
1757 if test "$rescomp" != ""; then
1758     AROS_TOOL_KERNEL(aros_kernel_rescomp,$rescomp)
1759     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
1762 # Set up the sources for the symlink farm
1763 if test "$crosstools" = "yes"; then
1764     crosstools_target=tools-crosstools
1765 else
1766     crosstools_cxx_target=tools-crosstools
1769 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
1770 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
1773 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1774 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1775 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1776 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1777 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1778 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1779 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1781 # aros_cc_pre is a variable that is added to the front of the compiler name
1782 # in the generated aros-gcc shell script. We need this to enable the cache
1783 # to work across cleaned builds. Also, support DISTCC using the correct
1784 # environment variable.
1787 if test "x${DISTCC}" != "x" ; then
1788     if test "x${CCACHE}" != "x" ; then
1789         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1790     else
1791         aros_cc_pre="${DISTCC} "
1792     fi
1793 else
1794     if test "x${CCACHE}" != "x" ; then
1795         aros_cc_pre="${CCACHE} "
1796     fi
1799 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
1801 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1802 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1803 AC_SUBST(aros_target_nix_ldflags,-nix)
1804 AC_SUBST(aros_target_detach_ldflags,-detach)
1805 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1807 # Target tools
1808 if test "$crosstools" != "yes"; then
1809     if test "$GCC" = "yes"; then
1810         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1811     fi
1812 else
1813     # We do not know which gcc version we are going to build and what we need to know
1814     # here is different for different versions so this will be set later during the
1815     # build of crosstools.
1816     aros_target_cc_path=@aros_target_cc_path@
1818 aros_target_cpp="${prefix}cpp"
1819 aros_target_cc="${prefix}gcc"
1820 aros_target_cxx="${prefix}g++"
1821 aros_target_as="${prefix}as"
1822 aros_target_ld="${prefix}ld"
1823 aros_target_ar="${prefix}ar $aros_target_ar_flags"
1824 aros_target_objcopy="${prefix}objcopy"
1825 aros_target_objdump="${prefix}objdump"
1826 aros_target_ranlib="${prefix}ranlib $aros_target_ranlib_flags"
1827 aros_target_nm="${prefix}nm $aros_target_nm_flags"
1828 aros_target_strip="${prefix}strip"
1829 aros_plain_nm="${prefix}nm"
1830 aros_plain_ar="${prefix}ar"
1832 if test "$aros_kernel_includes" != "" ; then
1833     dnl find out about the kernel cc's include path
1834     AC_MSG_CHECKING([for the kernel compiler's include path])
1835     if test "$aros_kernel_cc_includes" = "" ; then
1836         # Try to guess where the directory is.
1837         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
1838         if test -d $aros_kernel_cc_includes; then
1839             # Check if there is also an include-fixed directory and add it
1840             # to kernel compiler's include path as it may contain some of
1841             # the headers we need.
1842             if test -d "$aros_kernel_cc_includes"-fixed; then
1843                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
1844             fi
1845             # Check for specific includes directory. Neede for Ubuntu 11.10
1846             if test -d "/usr/include/i386-linux-gnu"; then
1847                 aros_kernel_cc_includes+=" -isystem /usr/include/i386-linux-gnu"
1848             fi
1849         else
1850             # The directory doesn't exist, we need to do some more work.
1851             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
1853             # These are the headers we're looking for.
1854             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1855                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1856                      zutil.h stdint.h"
1858             dirs=
1859             for h in $headers; do
1860                 # Which other headers are needed by each of the above?
1861                 deps=$(echo "#include <$h>" | \
1862                        $aros_kernel_cc -E -M - 2>/dev/null | \
1863                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1865                 # Copy all the needed headers to a directory beneath gendir.
1866                 for d in $deps; do
1867                     h=$(basename $d)
1868                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
1869                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1870                     ! test -d $dir && mkdir -p $dir
1871                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1872                 done
1873             done            
1874         fi
1875     fi
1876     AC_MSG_RESULT($aros_kernel_cc_includes)
1877     # Adding -nostdinc to kernel includes as they are always used together.
1878     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
1881 if test "$crosstools" != "yes"; then
1882     dnl find out about the target cc's include path
1883     AC_MSG_CHECKING([for the target compiler's include path])
1884     if test "$aros_target_cc_includes" = "" ; then
1885         #try to guess where the directory is
1886         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
1887         if ! test -d $aros_target_cc_includes; then
1888             #the directory doesn't exist, we need to do some more work
1889             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1890         
1891             #these are the headers we're looking for
1892             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1893                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1894                     zutil.h"
1896             dirs=
1897             for h in $headers; do
1898                 #which other headers each of the above headers needs?
1899                 deps=$(echo "#include <$h>" | \
1900                     $orig_target_cc -E -M - 2>/dev/null | \
1901                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1902             
1903                 #copy all the needed headers to a directory beneath gendir
1904                 for d in $deps; do
1905                     h=$(basename $d)
1906                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1907                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1908                     ! test -d $dir && mkdir -p $dir
1909                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1910                 done
1911             done
1912         fi
1913     fi
1914     AC_MSG_RESULT($aros_target_cc_includes)
1915 else
1916     # We do not know which gcc version we are going to build and what we need to know
1917     # here is different for different versions so this will be set later during the
1918     # build of crosstools.
1919     aros_target_cc_includes=@aros_target_cc_includes@
1923 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
1924 # On GCC >= 4.0 -iquote should be used
1927 save_cc="$CC"
1928 save_cflags="$CFLAGS"
1929 CFLAGS="-iquote."
1930 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
1931 if test "x-$crosstools" != "x-yes"; then
1932     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
1933 else
1934     # we do know it is supported for the smallest version of gcc we are going to build
1935     # we assume it's also supported by later versions
1936     has_iquote=yes
1938 AC_MSG_RESULT($has_iquote)
1939 if test "x-$has_iquote" = "x-yes" ; then
1940     host_cflags_iquote=-iquote
1941     host_cflags_iquote_end=
1942 else
1943     host_cflags_iquote=-I
1944     host_cflags_iquote_end=-I-
1946 kernel_cflags_iquote=$host_cflags_iquote
1947 kernel_cflags_iquote_end=$host_cflags_iquote_end
1948 if test "x-$cross_compiling" = "x-yes"; then
1949     CC="$aros_kernel_cc"
1950     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
1951     if test "x-$crosstools" != "x-yes"; then
1952         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
1953     else
1954         # we do know it is supported for the smallest version of gcc we are going to build
1955         # we assume it's also supported by later versions
1956         use_no_stack_protector=yes
1957     fi
1958     AC_MSG_RESULT($use_no_stack_protector)
1959     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
1960     if test "x-$crosstools" != "x-yes"; then
1961         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
1962     else
1963         # we do know it is supported for the smallest version of gcc we are going to build
1964         # we assume it's also supported by later versions
1965         has_iquote=yes
1966     fi
1967     AC_MSG_RESULT($has_iquote)
1968     if test "x-$has_iquote" = "x-yes" ; then
1969         kernel_cflags_iquote=-iquote
1970         kernel_cflags_iquote_end=
1971     else
1972         kernel_cflags_iquote=-I
1973         kernel_cflags_iquote_end=-I-
1974     fi
1976 aros_cflags_iquote=$kernel_cflags_iquote
1977 aros_cflags_iquote_end=$kernel_cflags_iquote_end
1978 if test "$orig_target_cc" != "$aros_kernel_cc"; then
1979     CC="$orig_target_cc"
1980     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
1981     if test "x-$crosstools" != "x-yes"; then
1982         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
1983     else
1984         # we do know it is supported for the smallest version of gcc we are going to build
1985         # we assume it's also supported by later versions
1986         has_iquote=yes
1987     fi
1988     AC_MSG_RESULT($has_iquote)
1989     if test "x-$has_iquote" = "x-yes" ; then
1990         aros_cflags_iquote=-iquote
1991         aros_cflags_iquote_end=
1992     else
1993         aros_cflags_iquote=-I
1994         aros_cflags_iquote_end=-I-
1995     fi
1997 if test "x-$use_no_stack_protector" = "x-yes" ; then
1998     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2002 #-----------------------------------------------------------------------------
2004 # Check if the target compiler supports some options used for delinting:
2005 #  -Wunused-but-set-variable
2006 #  -Warray-bounds
2007 #  -Wenum-compare
2008 #  -Wstrict-overflow
2009 #  -Wformat-security
2011 if test "x-$crosstools" != "x-yes"; then
2012     if test "$orig_target_cc" != "$aros_kernel_cc"; then
2013         CC="$orig_target_cc"
2014     fi
2015     AC_MSG_CHECKING([whether ${CC} accepts -Wunused-but-set-variable])
2016     CFLAGS=-Wunused-but-set-variable
2017     AC_TRY_COMPILE(,, aros_unused_but_set_variable="yes", aros_unused_but_set_variable="no")
2018     AC_MSG_RESULT($aros_unused_but_set_variable)
2019     if test "x-$aros_unused_but_set_variable" = "x-yes" ; then
2020         aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable
2021     fi
2023     AC_MSG_CHECKING([whether ${CC} accepts -Warray-bounds])
2024     CFLAGS=-Warray-bounds
2025     AC_TRY_COMPILE(,, aros_array_bounds="yes", aros_array_bounds="no")
2026     AC_MSG_RESULT($aros_array_bounds)
2027     if test "x-$aros_array_bounds" = "x-yes" ; then
2028         aros_cflags_array_bounds=-Wno-array-bounds
2029     fi
2031     AC_MSG_CHECKING([whether ${CC} accepts -Wenum-compare])
2032     CFLAGS=-Wenum-compare
2033     AC_TRY_COMPILE(,, aros_enum_compare="yes", aros_enum_compare="no")
2034     AC_MSG_RESULT($aros_enum_compare)
2035     if test "x-$aros_enum_compare" = "x-yes" ; then
2036         aros_cflags_enum_compare=-Wno-enum-compare
2037     fi
2039     AC_MSG_CHECKING([whether ${CC} accepts -Wstrict-overflow])
2040     CFLAGS=-Wstrict-overflow
2041     AC_TRY_COMPILE(,, aros_strict_overflow="yes", aros_strict_overflow="no")
2042     AC_MSG_RESULT($aros_strict_overflow)
2043     if test "x-$aros_strict_overflow" = "x-yes" ; then
2044         aros_cflags_strict_overflow=-Wno-strict-overflow
2045     fi
2047     AC_MSG_CHECKING([whether ${CC} accepts -Wformat-security])
2048     CFLAGS=-Wformat-security
2049     AC_TRY_COMPILE(,, aros_format_security="yes", aros_format_security="no")
2050     AC_MSG_RESULT($aros_format_security)
2051     if test "x-$aros_format_security" = "x-yes" ; then
2052         aros_cflags_format_security=-Wno-format-security
2053     fi
2054 else
2055     # We do not know which gcc version we are going to build and what we need to know
2056     # here is different for different versions so this will be set later during the
2057     # build of crosstools.
2058     aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@
2059     aros_cflags_array_bounds=@aros_cflags_array_bounds@
2060     aros_cflags_enum_compare=@aros_cflags_enum_compare@
2061     aros_cflags_strict_overflow=@aros_cflags_strict_overflow@
2062     aros_cflags_format_security=@aros_cflags_format_security@
2065 #-----------------------------------------------------------------------------
2067 # Check if we can explicitly choose older version of symbol hashing
2069 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2070 CC="$aros_kernel_cc"
2071 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2072 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2073 AC_MSG_RESULT($use_hash_style)
2074 if test "x-$use_hash_style" = "x-yes" ; then
2075     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2077 CC="$save_cc"
2078 CFLAGS="$save_cflags"
2080 AC_SUBST(host_cflags_iquote)
2081 AC_SUBST(host_cflags_iquote_end)
2082 AC_SUBST(kernel_cflags_iquote)
2083 AC_SUBST(kernel_cflags_iquote_end)
2084 AC_SUBST(aros_cflags_iquote)
2085 AC_SUBST(aros_cflags_iquote_end)
2088 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2089 AC_MSG_CHECKING([for default resolution of WBScreen])
2090 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2091 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2092 if test "$resolution" = "yes" ; then
2093     resolution="none"
2095 if test "$resolution" = "no" ; then
2096     resolution="none"
2098 if test "$resolution" != "none" ; then
2099     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
2100     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
2101     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
2103 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
2104 aros_cv_default_wbwidth=$aros_default_wbwidth
2105 aros_cv_default_wbheight=$aros_default_wbheight
2106 aros_cv_default_wbdepth=$aros_default_wbdepth
2108 dnl See if the user wants the serial debug output for native flavour
2109 AC_MSG_CHECKING([if serial debug is enabled])
2110 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)
2111 if test "$aros_serial_debug" = 0 ; then
2112     serial_debug_forced=""
2113     if test "$serial_debug" = "yes" ; then
2114         serial_debug="1"
2115     fi
2116     if test "$serial_debug" = "no" ; then
2117         serial_debug="none"
2118     fi
2119 else
2120     serial_debug_forced="(forced)"
2121     serial_debug=$aros_serial_debug
2123 if test "$serial_debug" != "none" ; then
2124     aros_serial_debug=$serial_debug
2125     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2126 else
2127     AC_MSG_RESULT(no)
2130 dnl See if the user wants the palm debug output hack for palm native flavour
2131 AC_MSG_CHECKING([if palm debug hack is enabled])
2132 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")
2133 if test "$palm_debug_hack" = "yes" ; then
2134     aros_palm_debug_hack="1"
2136 AC_MSG_RESULT($palm_debug_hack)
2138 dnl See if the user wants the usb3.0 code
2139 AC_MSG_CHECKING([if usb3.0 code is enabled])
2140 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2141 if test "$usb30_code" = "yes" ; then
2142     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2143     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2145 AC_MSG_RESULT($usb30_code)
2147 dnl See if the user wants nesting supervisor activated for unix flavour
2148 AC_MSG_CHECKING([if nesting supervisor support is enabled])
2149 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")
2150 if test "$nesting_supervisor" = "yes" ; then
2151     aros_nesting_supervisor="1"
2153 AC_MSG_RESULT($nesting_supervisor)
2155 dnl See if the user wants to disable MMU support
2156 dnl This can be overriden on per-target basis,
2157 dnl set $aros_enable_mmu to "yes" or "no" to do this
2158 if test "$aros_enable_mmu" = "" ; then
2159     AC_MSG_CHECKING([if MMU support is enabled])
2160     dnl Enabled by default
2161     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2162     if test "$aros_enable_mmu" = "" ; then
2163         aros_enable_mmu="yes"
2164     fi
2165     AC_MSG_RESULT($aros_enable_mmu)
2167 if test "$aros_enable_mmu" = "no" ; then
2168     aros_enable_mmu="0"
2169 else
2170     aros_enable_mmu="1"
2172     
2174 dnl things specifically required for hosted flavours
2175 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2177     if test "x-$need_dlopen" != "x-no" ; then
2178       dnl some kind of dynamic library access system is required for hostlib.resource
2179       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2180       if test "x-$have_dl" = "x-no" ; then
2181           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2182                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2183                                     have_dl="no")
2184       fi
2185       if test "x-$have_dl" = "x-no" ; then
2186           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2187       fi
2188     fi
2191     dnl x11 hidd
2192     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2193                                            [build X11 hidd for hosted (default=auto)]),
2194                                            x11_hidd="$enableval",
2195                                            x11_hidd="$need_x11")
2196     case "x-$x11_hidd" in
2197         x-yes|x-no|x-auto)                 ;;
2198         *)                 x11_hidd="$need_x11" ;;
2199     esac
2201     ENABLE_X11=0
2203     dnl they want it
2204     if test "x-$x11_hidd" != "x-no" ; then
2206         dnl find x11 stuff
2207         AC_PATH_X
2209         x_cflags=
2210         for path in $x_libraries
2211         do
2212             x_cflags="$x_cflags -L$path"
2213         done
2215         for path in $x_includes
2216         do
2217             x_cflags="$x_cflags -I$path"
2218         done
2219         
2220         if test "x-$no_x" = "x-yes" ; then
2222             dnl didn't find it
2223             if test "x-$x11_hidd" != "x-auto" ; then
2224                 dnl and they explicitly asked for it, bail out
2225                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2226             fi
2227         
2228         else
2229             dnl found it, setup the metatarget
2230             x11_hidd_target=kernel-x11gfx-kobj
2231             ENABLE_X11=1
2233             dnl setup shared memory extensions
2234             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2235                                                   [use X11 shared memory (default=auto)]),
2236                                                   x11_hidd_shm="$enableval",
2237                                                   x11_hidd_shm="auto")
2238             case "x-$x11_hidd_shm" in
2239                 x-yes|x-no|x-auto)                     ;;
2240                 *)                 x11_hidd_shm="auto" ;;
2241             esac
2243             have_xshm=no
2245             dnl they want it
2246             if test "x-$x11_hidd_shm" != "x-no" ; then
2248                 dnl system shm headers
2249                 AC_CHECK_HEADERS(sys/ipc.h)
2250                 AC_CHECK_HEADERS(sys/shm.h)
2252                 dnl got them
2253                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2255                     dnl make sure X libs have shm functions
2256                     save_cflags="$CFLAGS"
2257                     CFLAGS="$CFLAGS $x_cflags"
2258                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2259                     CFLAGS="$save_cflags"
2260                 fi
2261             fi
2263             dnl detection done, prepare output
2264             if test "x-$have_xshm" = "x-yes" ; then
2265                 dnl we can do shm
2266                 DO_XSHM_SUPPORT="1"
2267             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2268                 dnl they explicitly asked for it, but we can't do it
2269                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2270             else
2271                 dnl otherwise just disable it
2272                 DO_XSHM_SUPPORT="0"
2273             fi
2275             
2276             dnl setup vidmode (fullscreen) extensions
2277             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2278                                                       [use X11 vidmode extension (default=auto)]),
2279                                                       x11_hidd_vidmode="$enableval",
2280                                                       x11_hidd_vidmode="auto")
2281             case "x-$x11_hidd_vidmode" in
2282                 x-yes|x-no|x-auto)                         ;;
2283                 *)                 x11_hidd_vidmode="auto" ;;
2284             esac
2286             have_vidmode=no
2288             dnl they want it
2289             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2291                 dnl make sure X libs have vidmode functions
2292                 save_cflags="$CFLAGS"
2293                 CFLAGS="$CFLAGS $x_cflags"
2294                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2295                 CFLAGS="$save_cflags"
2296             fi
2298             dnl detection done, prepare output
2299             if test "x-$have_vidmode" = "x-yes" ; then
2300                 dnl we can do vidmode
2301                 DO_VIDMODE_SUPPORT="1"
2302             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2303                 dnl they explicitly asked for it, but we can't do it
2304                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2305             else
2306                 dnl otherwise just disable it
2307                 DO_VIDMODE_SUPPORT="0"
2308             fi
2309         fi
2311         aros_host_x11_includes=$x_includes 
2312         aros_host_x11_libdirs=$x_libraries
2313     fi
2316     dnl sdl hidd
2317     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2318                                            [build SDL hidd for hosted (default=auto)]),
2319                                            sdl_hidd="$enableval",
2320                                            sdl_hidd="auto")
2321     case "x-$sdl_hidd" in
2322         x-yes|x-no|x-auto)                 ;;
2323         *)                 sdl_hidd="auto" ;;
2324     esac
2326     dnl they want it
2327     if test "x-$sdl_hidd" != "x-no" ; then
2329         dnl find sdl
2330         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
2332         if test "x-$have_sdl" != "x-yes" ; then
2334             dnl didn't find it
2335             if test "x-$sdl_hidd" != "x-auto" ; then
2336                 dnl and they explicitly asked for it, bail out
2337                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2338             fi
2340         else
2341             dnl found it, set up the metatarget
2342             sdl_hidd_target=kernel-hidd-sdl
2343             aros_host_sdl_cflags=SDL_CFLAGS
2344             aros_host_sdl_libs=SDL_LIBS
2345         fi
2346     fi
2348     dnl oss.library
2349     AC_CHECK_HEADER(sys/soundcard.h)
2350     if test "x-$ac_cv_header_sys_soundcard_h" = "x-yes" ; then
2351         oss_library_target=workbench-libs-oss-unix
2352     fi
2356 dnl See if the user wants dbus.library
2357 AC_MSG_CHECKING([if building of dbus.library is enabled])
2358 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2359 if test "$dbus" = "yes" ; then
2360     ENABLE_DBUS=1
2361     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2362     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2363     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2364     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2365 else
2366     ENABLE_DBUS=0
2368 AC_MSG_RESULT($dbus)
2370 if test "$use_kernel_cc_wrapper" = "yes" ; then
2371     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc"
2374 if test "${crosstools}" != "yes" ; then
2375     aros_target_toolchain=no
2376 else
2377     aros_target_toolchain=yes
2380 dnl --------------------------------------------------------------------
2381 dnl Configuration Output Section
2382 dnl --------------------------------------------------------------------
2384 # Generic
2385 AC_SUBST(aros_arch)
2386 AC_SUBST(aros_cpu)
2387 AC_SUBST(aros_flavour)
2388 AC_SUBST(aros_flavour_uc)
2389 AC_SUBST(aros_target_toolchain)
2390 AC_SUBST(AROS_BUILDDIR)
2391 AC_SUBST(AROS_BUILDDIR_UNIX)
2392 AC_SUBST(SRCDIR)
2393 AC_SUBST(AROS_CROSSTOOLSDIR)
2394 AC_SUBST(AROS_PORTSSRCDIR)
2396 # Compatability with other Amiga-like operation systems
2397 AC_SUBST(aros_amigaos_compliance)
2399 # Host related
2400 AC_SUBST(aros_cc_pre)
2401 AC_SUBST(aros_host_strip)
2402 AC_SUBST(aros_host_arch)
2403 AC_SUBST(aros_host_cpu)
2404 AC_SUBST(aros_host_cpp)
2405 AC_SUBST(aros_host_cc)
2406 AC_SUBST(aros_host_cxx)
2407 AC_SUBST(aros_host_ar)
2408 AC_SUBST(aros_host_ranlib)
2409 AC_SUBST(aros_host_ld)
2410 AC_SUBST(aros_host_make)
2411 AC_SUBST(aros_host_cflags)
2412 AC_SUBST(aros_host_cxxflags)
2413 AC_SUBST(gnu89_inline)
2414 AC_SUBST(aros_host_ldflags)
2415 AC_SUBST(aros_host_debug)
2416 AC_SUBST(aros_host_mkdep)
2417 AC_SUBST(aros_host_mkargs)
2418 AC_SUBST(aros_host_exe_suffix)
2419 AC_SUBST(aros_host_lib_suffix)
2420 AC_SUBST(aros_tools_dir)
2421 AC_SUBST(aros_host_aclocal)
2422 AC_SUBST(aros_host_autoconf)
2423 AC_SUBST(aros_host_autoheader)
2424 AC_SUBST(aros_host_automake)
2425 AC_SUBST(ant)
2427 # Target Related
2428 AC_SUBST(aros_target_guitheme)
2429 AC_SUBST(aros_target_iconset)
2430 AC_SUBST(aros_target_bootloader)
2431 AC_SUBST(aros_target_arch)
2432 AC_SUBST(aros_target_family)
2433 AC_SUBST(aros_target_cpu)
2434 AC_SUBST(aros_target_variant)
2435 AC_SUBST(aros_target_suffix)
2436 AC_SUBST(aros_target_ar)
2437 AC_SUBST(aros_target_ranlib)
2438 AC_SUBST(aros_plain_nm)
2439 AC_SUBST(aros_plain_ar)
2440 AC_SUBST(aros_kernel_ar)
2441 AC_SUBST(aros_kernel_ranlib)
2442 AC_SUBST(orig_target_cc)
2443 AC_SUBST(aros_target_cc)
2444 AC_SUBST(aros_kernel_cc)
2445 AC_SUBST(orig_target_cxx)
2446 AC_SUBST(aros_target_cxx)
2447 AC_SUBST(aros_kernel_cxx)
2448 AC_SUBST(orig_target_cpp)
2449 AC_SUBST(aros_target_cpp)
2450 AC_SUBST(aros_kernel_cpp)
2451 AC_SUBST(orig_target_as)
2452 AC_SUBST(aros_target_as)
2453 AC_SUBST(aros_kernel_as)
2454 AC_SUBST(orig_target_ld)
2455 AC_SUBST(aros_target_ld)
2456 AC_SUBST(aros_kernel_ld)
2457 AC_SUBST(aros_target_cc_includes)
2458 AC_SUBST(aros_target_cc_path)
2459 AC_SUBST(aros_target_objdump)
2460 AC_SUBST(aros_target_objcopy)
2461 AC_SUBST(aros_target_strip)
2462 AC_SUBST(aros_target_nm)
2463 AC_SUBST(aros_kernel_rescomp)
2464 AC_SUBST(aros_shared_default)
2465 AC_SUBST(aros_shared_ld)
2466 AC_SUBST(aros_object_format)
2467 AC_SUBST(aros_compiler_libs)
2468 AC_SUBST(aros_arch_libs)
2470 AC_SUBST(aros_config_cflags)
2471 AC_SUBST(aros_config_aflags)
2472 AC_SUBST(aros_config_ldflags)
2474 AC_SUBST(aros_shared_cflags)
2475 AC_SUBST(aros_shared_aflags)
2476 AC_SUBST(aros_shared_ldflags)
2477 AC_SUBST(aros_kernel_cflags)
2478 AC_SUBST(aros_kernel_includes)
2479 AC_SUBST(aros_kernel_objcflags)
2480 AC_SUBST(aros_kernel_ldflags)
2481 AC_SUBST(aros_target_cflags)
2482 AC_SUBST(aros_debug_cflags)
2483 AC_SUBST(aros_debug_aflags)
2484 AC_SUBST(aros_debug_ldflags)
2485 AC_SUBST(aros_target_genmap)
2486 AC_SUBST(aros_target_strip_flags)
2488 AC_SUBST(crosstools_target)
2489 AC_SUBST(crosstools_cxx_target)
2491 # Delinting target compiler flags
2492 AC_SUBST(aros_cflags_unused_but_set_variable)
2493 AC_SUBST(aros_cflags_array_bounds)
2494 AC_SUBST(aros_cflags_enum_compare)
2495 AC_SUBST(aros_cflags_strict_overflow)
2496 AC_SUBST(aros_cflags_format_security)
2498 # Graphics Related
2499 AC_SUBST(x11_hidd_target)
2500 AC_SUBST(sdl_hidd_target)
2501 AC_SUBST(pci_hidd_target)
2502 AC_SUBST(oss_library_target)
2504 AC_SUBST(aros_default_wbwidth)
2505 AC_SUBST(aros_default_wbheight)
2506 AC_SUBST(aros_default_wbdepth)
2507 AC_SUBST(DO_XSHM_SUPPORT)
2508 AC_SUBST(DO_VIDMODE_SUPPORT)
2510 AC_SUBST(aros_host_x11_includes)
2511 AC_SUBST(aros_host_x11_libdirs)
2512 AC_SUBST(aros_host_sdl_cflags)
2513 AC_SUBST(aros_host_sdl_libs)
2515 # Native version related
2516 AC_SUBST(aros_serial_debug)
2518 # Palm native version related
2519 AC_SUBST(aros_palm_debug_hack)
2521 # USB3.0 code
2522 AC_SUBST(aros_usb30_code)
2524 # Unix/Hosted version related
2525 AC_SUBST(aros_nesting_supervisor)
2527 # MMU related
2528 AC_SUBST(aros_enable_mmu)
2530 # Apple iOS related
2531 AC_SUBST(aros_ios_platform)
2532 AC_SUBST(aros_ios_version)
2533 AC_SUBST(aros_ios_sdk)
2535 # Android related
2536 AC_SUBST(android_tool)
2537 AC_SUBST(aros_android_level)
2539 # DBUS related
2540 AC_SUBST(ENABLE_DBUS)
2541 AC_SUBST(DBUS_CFLAGS)
2542 AC_SUBST(DBUS_LIBFLAGS)
2543 AC_SUBST(KERNEL_DBUS_KOBJ)
2544 AC_SUBST(KERNEL_DBUS_INCLUDES)
2546 #X11 related
2547 AC_SUBST(ENABLE_X11)
2549 # Debug related
2550 AC_SUBST(aros_debug)
2551 AC_SUBST(aros_mungwall_debug)
2552 AC_SUBST(aros_stack_debug)
2553 AC_SUBST(aros_modules_debug)
2555 # Collect-aros stuff: "-ius" to ignore undefined symbols
2556 AC_SUBST(ignore_undefined_symbols)
2558 # C compiler related
2559 AC_SUBST(gcc_target_cpu)
2561 dnl Prepare for output, make up all the generated patches
2562 case "$aros_flavour" in
2563 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2564                 aros_flavour="emulation" ;;
2565 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2566                 aros_flavour="emulation" ;;
2567 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2568                 aros_flavour="standalone";;
2569 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2570                 aros_flavour="standalone";;
2571 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2572                 aros_flavour="native" ;;
2573 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2574                 aros_flavour="native" ;;
2575 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2576                 aros_flavour="linklib" ;;
2577 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2578                 aros_flavour="palmnative" ;;
2579 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2580                 aros_flavour="mac68knative" ;;
2581 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2582                 aros_flavour="ppcnative" ;;
2583 esac
2585 if test ! -d ${aros_inc_dir} ; then
2586     ${MKDIR} ${aros_inc_dir}
2588 if test ! -d ${aros_geninc_dir} ; then
2589     ${MKDIR} ${aros_geninc_dir}
2591 if test ! -d ${aros_hostcfg_dir} ; then
2592     ${MKDIR} ${aros_hostcfg_dir}
2594 if test ! -d ${aros_targetcfg_dir} ; then
2595     ${MKDIR} ${aros_targetcfg_dir}
2597 if test ! -d ${aros_tools_dir} ; then
2598     ${MKDIR} ${aros_tools_dir}
2600 if test ! -d ${aros_scripts_dir} ; then
2601     ${MKDIR} ${aros_scripts_dir}
2604 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2606 AC_CONFIG_COMMANDS([compiler_executable],
2607     [
2608         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2609         mkdir -p $prefix
2610         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2611         prefix3=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
2613         echo ${prefix2}
2614         echo ${prefix3}
2615         chmod a+x ${prefix2}-gcc ${prefix2}-g++ ${prefix2}-ld ${prefix2}-cpp ${prefix3}-gcc
2617         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
2618         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
2619         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
2620         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
2621         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
2622         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
2623         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
2625         ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix3}-ld$aros_host_exe_suffix
2626     ],
2627     [
2628         aros_host_exe_suffix=${aros_host_exe_suffix}
2629         aros_tools_dir=${aros_tools_dir}
2630         aros_target_cpu=${aros_target_cpu}
2631         aros_target_arch=${aros_target_arch}
2632         aros_target_suffix=${aros_target_suffix}
2633         orig_target_nm=${orig_target_nm}
2634         orig_target_as=${orig_target_as}
2635         orig_target_ar=${orig_target_ar}
2636         orig_target_ranlib=${orig_target_ranlib}
2637         orig_target_objdump=${orig_target_objdump}
2638         orig_target_objcopy=${orig_target_objcopy}
2639         orig_target_strip=${orig_target_strip}
2640         aros_kernel_ld=${aros_kernel_ld}
2641     ]
2643 AC_CONFIG_COMMANDS([genmf_executable],
2644     [chmod a+x ${aros_tools_dir}/genmf.py],
2645     [aros_tools_dir=${aros_tools_dir}]
2648 AC_CONFIG_FILES(
2649     Makefile
2650     config/make.cfg
2651     ${aros_inc_dir}/config.h:config/config.h.in
2652     ${aros_geninc_dir}/config.h:config/config.h.in
2653     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2654     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2655     mmake.config
2656     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2657     ${aros_targetcfg_dir}/specs:config/specs.in
2658     ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
2659     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-cpp:scripts/aros-cpp.in
2660     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
2661     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-g++:scripts/aros-g++.in
2662     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
2663     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
2664     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2665     tools/collect-aros/env.h
2666     ${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in
2669 AC_OUTPUT
2671 dnl This is in order to not define SHARED_CFLAGS sometimes
2672 dnl We don't always do aros_shared_ar, aros_shared_cflags
2674 #XXX compatability...
2675 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
2677 if test -n "$aros_shared_cflags" ; then
2678     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
2679     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg