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