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