finish adjust the crossbuild configuration in build_with_configure. hosted builds...
[AROS.git] / configure.in
bloba5030e64f10b4eabe6757c6a6b54d1ea387e5f31
1 dnl Copyright © 1997-2016, 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 # Default versions for the gnu tools we build
26 default_gcc_version="4.6.4"
27 default_binutils_version="2.23.2"
29 # The AROS target is slightly different to the normal GNU style
30 # format. We don't have the middle part, and we reverse the order
31 # of the $(CPU) and $(OS) bits.
33 # Don't strip the version of the target yet, it might be
34 # useful on some systems.
36 AC_MSG_CHECKING([for AROS style target])
38 if test "$target" = "NONE" ; then
39     target=$host_os-$host_cpu
40 else
41     if test "$target" = "" ; then
42         target=$host_os-$host_cpu
43     fi
45 AC_MSG_RESULT($target)
47 if test "$host_os" = "mingw32" ; then
48     PWDCMD="pwd -W"
51 # Don't know where else to put this...
52 AC_MSG_CHECKING([building AROS in])
53 AROS_BUILDDIR=`${PWDCMD-pwd}`
54 AROS_BUILDDIR_UNIX=${PWD}
55 AC_MSG_RESULT($AROS_BUILDDIR)
57 AC_MSG_CHECKING([AROS source in])
58 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
59 SRCDIR=${srcpwd}
60 AC_MSG_RESULT($SRCDIR)
62 # Parse the target field into something useful.
63 changequote(<<,>>)
64 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
65 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
66 changequote([,])
68 # Some debug output, to be removed again.
69 AC_MSG_CHECKING([for target system (debug output)])
70 AC_MSG_RESULT($target_os)
71 AC_MSG_CHECKING([for target cpu (debug output)])
72 AC_MSG_RESULT($target_cpu)
74 dnl --------------------------------------------------------------------
75 dnl Set the default Workbench resolution
76 dnl --------------------------------------------------------------------
77 aros_nominal_width=800
78 aros_nominal_height=600
79 aros_nominal_depth=4
81 dnl --------------------------------------------------------------------
82 dnl Host Configuration Section
83 dnl --------------------------------------------------------------------
84 dnl
85 dnl The idea here is to find out all the information we need about the
86 dnl host. This means things like tools for building directory structures,
87 dnl copying files around and the like.
89 default_c_compilers="gcc clang cc"
90 AC_ARG_WITH(c-compiler,AC_HELP_STRING([--with-c-compiler=VERSION],[Use specified c compiler for building AROS]),use_c_compiler="$withval",use_c_compiler="")
91 if test "$use_c_compiler" = ""; then
92     host_c_compilers="$default_c_compilers"
93 else
94     host_c_compilers="$use_c_compiler"
97 default_cxx_compilers="g++ clang++ c++"
98 AC_ARG_WITH(cxx-compiler,AC_HELP_STRING([--with-cxx-compiler=VERSION],[Use specified c++ compiler building AROS]),use_cxx_compiler="$withval",use_cxx_compiler="")
99 if test "$use_cxx_compiler" = ""; then
100         host_cxx_compilers="$default_cxx_compilers"
101 else
102     host_cxx_compilers="$use_cxx_compiler"
106 # The first step is to find the host binaries.
107 # Check for a compiler.
108 # Due to a bug in autoconf check for c++ compiler first.
109 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
110 AC_PROG_CXX([${host_cxx_compilers}])
111 AC_PROG_CC([${host_c_compilers}])
112 aros_host_def_cc="$CC"
113 AC_PROG_CC_STDC
114 AC_PROG_CPP
116 # Check for a compatible awk
117 AC_CHECK_PROGS(AWK,[gawk nawk])
118 AROS_REQUIRED(gawk,$AWK)
119 AROS_PROG(MMAKE,mmake)
121 # Perform some default variable assignments. Note all of these will be
122 # Regenerated from the script, so there is no need to cache them.
124 aros_build_host=$host
125 aros_host_cpp="$CPP"
126 aros_host_cc="$CC"
127 aros_host_cxx="$CXX"
128 AROS_TOOL_CCPATH(aros_host_ld,ld)
129 AROS_REQUIRED(ld,$aros_host_ld)
130 aros_host_make="make"
131 aros_host_cflags="$CFLAGS"
132 aros_host_cxxflags="$CXXFLAGS"
133 aros_host_ldflags="$LDFLAGS"
134 aros_host_debug="-g -O0"
135 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
136 aros_host_mkargs="--no-print-directory"
137 aros_host_exe_suffix="$EXEEXT"
138 aros_host_lib_suffix=""
140 # Ignore all compliance, AROS ROMs = 0
141 # KickStart v1.0 = 30
142 # KickStart v1.3 = 34
143 # KickStart v2.0 = 37
144 # KickStart v3.0 = 39
145 # KickStart v3.1 = 40
146 # AmigaOS   v3.5 = 44
147 aros_amigaos_compliance=0
149 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
150 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
151 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
152 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
154 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
155 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
157 case "$aros_host_cc" in
158     *clang*)
159         aros_host_cc_pipe=""
160         ;;
161     *gcc*)
162         aros_host_cc_pipe="-pipe"
163         ;;
164     icc)
165         aros_host_cc_pipe=""
166         ;;
167     *)
168         aros_host_cc_pipe=""
169         ;;
170 esac
172 aros_kernel_cc_includes=""
173 aros_target_cc_includes=""
174 host_cc_elf=yes
176 # ----------------------------------------------------------------------------------------
177 # Host-specific defaults
179 # This is the main host configuration section. It is where the host
180 # can change the values of any variables it needs to change. We do
181 # not look at anything that compiles to the target yet, we'll get
182 # to that later.
184 case "$host_os" in
185     aros*)
186         aros_host_arch="aros"
187         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
188         case "$host_cpu" in
189             *i?86*)
190                 aros_host_cpu="i386"
191                 ;;
192             *x86_64*)
193                 aros_host_cpu="x86_64"
194                 ;;
195             *powerpc*)
196                 aros_host_cpu="ppc"
197                 ;;
198             *)
199                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
200                 aros_host_cpu="$host_cpu"
201                 ;;
202         esac
203         ;;
205     linux*)
206         aros_host_arch="linux"
207         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
208         android_build_os="linux-x86"
209         android_tool="android"
210         default_android_sdk="/opt/android-sdk-linux_x86"
211         case "$host_cpu" in
212             *i?86*)
213                 aros_host_cpu="i386"
214                 ;;
215             *x86_64*)
216                 aros_host_cpu="x86_64"
217                 ;;
218             *m68k*)
219                 aros_host_cpu="m68k"
220                 ;;
221             *powerpc*)
222                 aros_host_cpu="ppc"
223                 ;;
224             *arm*)
225                 aros_host_cpu="arm"
226                 ;;
227             *)
228                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
229                 aros_host_cpu="$host_cpu"
230                 ;;
231         esac
232         ;;
234     freebsd*)
235         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe -I/usr/local/include"
236         aros_host_make="gmake"
237         aros_host_arch="freebsd"
238         aros_host_cpu="i386"
240         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
242         dnl FreeBSD 5.x (and later) has changed the default object format.
243         dnl The double [[]] is necessary to get around m4's quoting rules.
244         case $host_os in
245             freebsd[[234]]*)
246                 aros_object_format="elf_i386"
247                 ;;
249             *)
250                 aros_object_format="elf_i386_fbsd"
251                 ;;
252         esac
254         ;;
256     darwin*)
257         AC_CHECK_FILE(/usr/include/stddef.h,,
258                 AC_MSG_ERROR([XCode incorrectly configured!
259 please run 'xcode-select --install' before
260 re-running configure])
261         )
262         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
263         aros_host_arch="darwin"
264         host_cc_elf=no
265         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
266         android_build_os="darwin-x86"
267         android_tool="android"
268         default_android_sdk="/android-sdk-mac_x86"
269         case "$host_cpu" in
270             *i?86*)
271                 aros_host_cpu="i386"
272                 ;;
273             *x86_64*)
274                 aros_host_cpu="x86_64"
275                 ;;
276             *powerpc*)
277                 aros_host_cpu="ppc"
278                 ;;
279             *)
280                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
281                 aros_host_cpu="$host_cpu"
282                 ;;
283         esac
285         aros_host_ldflags="$aros_host_ldflags -liconv"
287         ;;
289     dragonfly*)
290         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
291         aros_host_make="gmake"
292         aros_host_arch="dragonfly"
293         case $host_cpu in
294             *i?86*)
295                 aros_host_cpu="i386"
296                 ;;
297             *amd64*)
298                 aros_host_cpu="x86_64"
299                 ;;
300             *)
301                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
302                 aros_host_cpu="$host_cpu"
303                 ;;
304         esac
305         ;;
307     netbsd*)
308         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
309         aros_host_make="gmake"
310         aros_host_arch="netbsd"
311         case "$host_cpu" in
312             *i?86*)
313                 aros_host_cpu="i386"
314                 ;;
315             *m68k*)
316                 aros_host_cpu="m68k"
317                 ;;
318             *)
319                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
320                 aros_host_cpu="$host_cpu"
321                 ;;
322         esac    
323         aros_host_lib_suffix=".0.0"
324         ;;
326     openbsd*)
327         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
328         aros_host_make="gmake"
329         aros_host_arch="openbsd"
330         case "$host_cpu" in
331             *i?86*)
332                 aros_host_cpu="i386"
333                 ;;
334             *)
335                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
336                 aros_host_cpu="$host_cpu"
337                 ;;
338         esac
339         ;;
340         
341     solaris*)
342         aros_host_arch="solaris"
343         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
344         case "$host_cpu" in
345             *i?86*)
346                 aros_host_cpu="i386"
347                 ;;
348             *sparc*)
349                 aros_host_cpu="sparc"
350                 ;;
351             *)
352                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
353                 aros_host_cpu="$host_cpu"
354                 ;;
355         esac
356         ;;
358     morphos*)
359         aros_host_arch="morphos"
360         aros_host_cpu="ppc"
361         host_cc_elf=no
362         ;;
364     amiga*)
365         aros_host_arch="amiga"
366         host_cc_elf=no
367         SORT="/gg/bin/sort"
368         TEST="/gg/bin/test"
369         UNIQ="/gg/bin/uniq"
370         FOR="for"
371         TOUCH="/gg/bin/touch"
372         case "$host_cpu" in
373             *m68k*)
374                 aros_host_cpu="m68k"
375                 ;;
376             *powerpc*)
377                 aros_host_cpu="ppc"
378                 ;;
379             *)
380                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
381                 aros_host_cpu="$host_cpu"
382                 ;;
383         esac
384         ;;
386     cygwin*)
387         aros_host_arch="cygwin"
388         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
389         host_cc_elf=no
390         android_build_os="windows"
391         android_tool="android.bat"
392         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
394         case "$host_cpu" in
395             *i?86*)
396                 aros_host_cpu="i386"
397                 ;;
398             *)
399                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
400                 aros_host_cpu="$host_cpu"
401                 ;;
402         esac
403         ;;
405     mingw32*)
406         aros_host_arch="mingw32"
407         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
408         host_cc_elf=no
409         android_build_os="windows"
410         android_tool="android.bat"
411         default_android_sdk="/c/android-sdk-windows-1.6_r1"
413         libpng_libextra="-lws2_32"
415         case "$host_cpu" in
416         *i?86*)
417             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
418             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
419             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
420             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
422             AC_MSG_CHECKING([for Windows native gcc target])
423             host_cpu=`gcc -dumpmachine`
424             AC_MSG_RESULT($host_cpu)
425             ;;
427         esac
429         case "$host_cpu" in
430         *i?86*)
431             aros_host_cpu="i386"
432             ;;
434         mingw32*)
435             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
436             aros_host_cpu="i386"
437             ;;
439         *x86_64*)
440             aros_host_cpu="x86_64"
441             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
442             dnl directory, so we have to add it explicitly here.
443             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
444             ;;
446         *)
447             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
448             aros_host_cpu="$host_cpu"
449             ;;
450         esac
451         ;;
452     *)
453         AC_MSG_ERROR([Unsupported host architecture $host])
454         ;;
455 esac
457 AROS_PROG(aros_host_ar,[ar],[cr])
458 AROS_REQUIRED(ar,$aros_host_ar)
459 AROS_PROG(aros_host_ranlib,ranlib)
460 AROS_REQUIRED(ranlib,$aros_host_ranlib)
461 AROS_PROG(aros_host_strip,strip)
462 AROS_REQUIRED(strip,$aros_host_strip)
464 AROS_PROG(RM,[rm],[-rf])
465 AROS_REQUIRED(rm,$RM)
466 AROS_PROG(CP,[cp])
467 AROS_REQUIRED(cp,$CP)
468 AROS_PROG(MV,[mv])
469 AROS_REQUIRED(mv,$MV)
470 AROS_PROG(ECHO,[echo])
471 AROS_REQUIRED(echo,$ECHO)
472 AROS_PROG(MKDIR,[mkdir],[-p])
473 AROS_REQUIRED(mkdir,$MKDIR)
474 AROS_PROG(TOUCH,[touch])
475 AROS_REQUIRED(touch,$TOUCH)
476 AROS_PROG(SORT,[sort])
477 AROS_REQUIRED(sort,$SORT)
478 AROS_PROG(UNIQ,[uniq])
479 AROS_REQUIRED(uniq,$UNIQ)
480 AROS_PROG(NOP,[true])
481 AROS_REQUIRED(true,$NOP)
482 AROS_PROG(CAT,[cat])
483 AROS_REQUIRED(cat,$CAT)
484 AROS_PROG(BISON,[bison])
485 AROS_REQUIRED(bison,$BISON)
486 AROS_PROG(FLEX,[flex])
487 AROS_REQUIRED(flex,$FLEX)
488 AROS_PROG(PNGTOPNM,[pngtopnm])
489 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
490 AROS_PROG(PPMTOILBM,[ppmtoilbm])
491 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
492 AROS_PROG(SED,[sed])
493 AROS_REQUIRED(sed,$SED)
494 AROS_PROG(CHMOD,[chmod])
495 AROS_REQUIRED(chmod,$CHMOD)
496 AROS_PROG(PATCH,[patch])
497 AROS_REQUIRED(patch,$PATCH)
499 AM_PATH_PYTHON(2.5)
501 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
502 if test "$enable_libpng_config" != "no"; then
503   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
505 if test "$arosconfig_use_libpngconfig" = "yes"; then
506     AC_MSG_CHECKING([libpng-config library])
507     libpng_incdir="`libpng-config --cflags`"
508     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
509     libpng="`libpng-config --libs`"
510     AC_MSG_RESULT($libpng)
511 else
512     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
513     if test "$libpng_libextra" != ""; then
514         if test "$libpng" != "no"; then
515             libpng_libextra="$libpng_libextra $libpng"
516         fi
517     fi
519 AROS_REQUIRED(libpng, $libpng)
520 AC_SUBST(libpng)
521 AC_SUBST(libpng_libextra)
522 AC_SUBST(libpng_incdir)
524 AC_SUBST(FOR, for)
525 AC_SUBST(IF, if)
526 AC_SUBST(TEST, test)
527 AC_SUBST(CMP, cmp)
529 dnl ---------------------------------------------------------------------------
530 dnl Look for things about the host system, good for hosted targets.
531 dnl ---------------------------------------------------------------------------
533 # Check for some includes for the X11 HIDD and the kernel
534 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
535     sys/mmap.h sys/mman.h sysexits.h \
536     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
539 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
541 AC_HEADER_DIRENT
542 AC_HEADER_STAT
543 AC_HEADER_STDC
544 AC_HEADER_SYS_WAIT
545 AC_HEADER_TIME
546 AC_STRUCT_ST_BLKSIZE
547 AC_STRUCT_ST_BLOCKS
548 AC_STRUCT_ST_RDEV
549 AC_STRUCT_TM
550 AC_STRUCT_TIMEZONE
551 AC_TYPE_OFF_T
552 AC_TYPE_PID_T
553 AC_TYPE_SIZE_T
554 AC_TYPE_UID_T
556 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
558 # Look for some functions
559 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
560     clone kse_create rfork_thread thr_create sa_register \
561     getcontext makecontext setcontext sigaltstack swapcontext])
563 AC_FUNC_MMAP
565 #-----------------------------------------------------------------------------
568 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
569 # it switched on by default, and we use the host compiler, so it compiles AROS
570 # code with this enabled resulting in link failures as we don't have support
571 # for it.
573 # We use two methods to disable it. For the host compiler (used to compile
574 # some hosted modules), we test to see if the compiler supports stack
575 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
576 # work on all platforms.
579 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
580 save_cflags="$CFLAGS"
581 CFLAGS="$CFLAGS -fno-stack-protector"
582 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
583 AC_MSG_RESULT($use_no_stack_protector)
584 if test "x-$use_no_stack_protector" = "x-yes" ; then
585     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
587 CFLAGS="$save_cflags"
589 #-----------------------------------------------------------------------------
591 # Disable pointer-signedness warnings if the compiler recognises the option
592 # (this only works for the host compiler at the moment)
594 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
595 save_cflags="$CFLAGS"
596 CFLAGS="$CFLAGS -Wno-pointer-sign"
597 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
598 AC_MSG_RESULT($use_no_sign_warning)
599 if test "x-$use_no_sign_warning" = "x-yes" ; then
600     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
602 CFLAGS="$save_cflags"
604 #-----------------------------------------------------------------------------
606 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
608 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
609 save_cflags="$CFLAGS"
610 CFLAGS="$CFLAGS -fgnu89-inline"
611 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
612 AC_MSG_RESULT($use_gnu89_inline)
613 if test "x-$use_gnu89_inline" = "x-yes" ; then
614     gnu89_inline="-fgnu89-inline"
616 CFLAGS="$save_cflags"
619 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
620 # On GCC >= 4.0 -iquote should be used
622 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
623 CFLAGS="$CFLAGS -iquote."
624 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
625 AC_MSG_RESULT($has_iquote)
626 if test "x-$has_iquote" = "x-yes" ; then
627     host_cflags_iquote=-iquote
628     host_cflags_iquote_end=
629 else
630     host_cflags_iquote=-I
631     host_cflags_iquote_end=-I-
634 AC_MSG_NOTICE([Performing target configuration...])
636 dnl --------------------------------------------------------------------
637 dnl Target Configuration Section
638 dnl --------------------------------------------------------------------
640 dnl The target configuration section is responsible for setting up all
641 dnl the paths for includes, and tools required to build AROS to some
642 dnl particular target.
644 aros_nowarn_flags="NOWARN_UNUSED_COMMAND_LINE_ARGUMENT NOWARN_UNKNOWN_WARNING_OPTION NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
646 toolchain_needs_sysroot=no
648 aros_warn_flags=
649 aros_isa_flags=
650 aros_config_cflags=
651 aros_config_cxxflags=
652 aros_config_aflags="-Wall -x assembler-with-cpp -c"
653 aros_config_ldflags=""
655 aros_shared_default=yes
657 aros_shared_cflags="-fPIC"
658 aros_shared_aflags=""
659 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
660 aros_kernel_ldflags="-Wl,-rpath,./lib"
662 aros_kernel_ar_flags="cr"
663 aros_target_ar_flags="cr"
664 aros_target_nm_flags="-C -ul"
665 aros_target_strip_flags="--strip-unneeded -R.comment"
667 aros_compiler_libs=
668 aros_arch_libs=
670 aros_target_genmap="-Wl,-Map -Xlinker"
672 # Native flavour stuff
673 aros_serial_debug="0"
675 # Palm native flavour stuff
676 aros_palm_debug_hack="0"
678 # Unix flavour stuff
679 aros_nesting_supervisor="0"
681 # Collect-aros stuff: "-ius" to ignore undefined symbols
682 ignore_undefined_symbols=""
684 # Check for X11 by default
685 need_x11="auto"
687 host_x_gfx=no
688 host_sdl_gfx=no
689 host_android_gfx=no
692 AC_MSG_CHECKING([Which toolchain family to use ...])
693 AC_ARG_WITH(toolchain,AC_HELP_STRING([--with-toolchain=family],[Which toolchain family to crosscompile with (defaults to gnu)]),aros_toolchain="$withval",aros_toolchain="gnu")
694 AC_MSG_RESULT($aros_toolchain)
697 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
698 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
699  aros_config_lto="$enableval",aros_config_lto="no")
700 if test "$aros_config_lto" != "no"; then
701     aros_config_lto="yes"
703 AC_MSG_RESULT($aros_config_lto)
705 use_ld_wrapper=yes
707 case "$aros_toolchain" in
708     *llvm*)
709         # toolchain_needs_sysroot=yes
710         toolchain_c_compiler="clang"
711         toolchain_cxx_compiler="clang++"
712         toolchain_cpp_preprocessor="clang -E"
713         toolchain_ld="ld.lld"
714         aros_ld="ld"
715         toolchain_as="llvm-as"
716         toolchain_ar="llvm-ar"
717         toolchain_ranlib="llvm-ranlib"
718         toolchain_nm="llvm-nm"
719         toolchain_strip="true"
720         toolchain_objcopy="llvm-objcopy"
721         toolchain_objdump="llvm-objdump"
722         ;;
723     *gnu*)
724         toolchain_c_compiler="gcc"
725         toolchain_cxx_compiler="g++"
726         toolchain_cpp_preprocessor="gcc -E"
727         toolchain_as="as"
728         aros_ld="ld"
729         if test "$aros_config_lto" != "yes"; then
730             toolchain_ld="ld"
731             toolchain_ar="ar"
732             toolchain_ranlib="ranlib"
733             toolchain_nm="nm"
734         else
735             toolchain_ld="ld.bfd"
736             toolchain_ar="gcc-ar"
737             toolchain_ranlib="gcc-ranlib"
738             toolchain_nm="gcc-nm"
739         fi
740         toolchain_strip="strip"
741         toolchain_objcopy="objcopy"
742         toolchain_objdump="objdump"
743         ;;
744     *)
745         AC_MSG_WARN("Unknown toolchain family!")
746         toolchain_c_compiler="cc"
747         toolchain_cxx_compiler="c++"
748         toolchain_cpp_preprocessor="cpp"
749         toolchain_ld="ld"
750         aros_ld="ld"
751         toolchain_as="as"
752         toolchain_ar="ar"
753         toolchain_ranlib="ranlib"
754         toolchain_nm="nm"
755         toolchain_strip="strip"
756         toolchain_objcopy="objcopy"
757         toolchain_objdump="objdump"
758         ;;
759 esac
761 #-----------------------------------------------------------------------------
763 AC_MSG_CHECKING([which type of build to do])
764 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")
766 if test "$build_type" = "nightly"; then
767     build_type_string="NIGHTLY"
768 elif test "$build_type" = "snapshot"; then
769     build_type_string="SNAPSHOT"
770 elif test "$build_type" = "milestone"; then
771     build_type_string="MILESTONE"
772 elif test "$build_type" = "release"; then
773     build_type_string="RELEASE"
774 else
775     build_type_string="PERSONAL"
776     build_type="personal"
779 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
780 aros_config_cxxflags="$aros_config_cxxflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
782 AC_MSG_RESULT($build_type)
784 #-----------------------------------------------------------------------------
785 all_debug_types="messages stack modules mungwall symbols"
787 AC_MSG_CHECKING([which debug types to enable])
788 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)]),
789  debug="$enableval",debug="")
791 if test "$debug" = "" -o "$debug" = "no"; then
792     debug="none"
793 elif test "$debug" = "yes"; then
794     debug="all"
797 if test "$debug" = "all" ; then
798     debug="messages stack modules symbols"
799     for d in $all_debug_types; do
800         export aros_${d}_debug="1"
801     done
802 else
803     for d in $all_debug_types; do
804         export aros_${d}_debug="0"
805     done
808 if test "$debug" != "none"; then
809     debug=`echo $debug | sed s/,/\ /g`
810     for d in $debug; do
811         found="0"
812         for d2 in $all_debug_types; do
813             if test "$d2" = "$d"; then
814                 found="1"
815                 break
816             fi
817         done
818         if test "$found" = "0"; then
819             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
820         fi
821         export aros_${d}_debug="1"
822     done
823     aros_debug="yes"
825 AC_MSG_RESULT($debug)
827 if test "$aros_messages_debug" = "1"; then
828     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
829 else
830     aros_messages_debug=""
832 if test "$aros_symbols_debug" = "1"; then
833     aros_symbols_debug="-g"
834 else
835     aros_symbols_debug=""
838 # These are the flags to pass when compiling debugged programs
839 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
840 aros_debug_aflags=""
841 aros_debug_ldflags="$aros_symbols_debug"
843 #-----------------------------------------------------------------------------
844 #   Checking for distcc and ccache.
846 #   Always apply the transforms in this particular order. Basically you should
847 #   always run 'ccache distcc compiler' in that order for the best performance.
849 AC_MSG_CHECKING([whether to enable distcc])
850 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
851 if test "$distcc" != "" -a "$distcc" != "no"; then
852     # AC_CHECK_PROG will print out the result in this case
853     AC_PATH_PROG(DISTCC,[distcc],distcc,)
854 else
855     AC_MSG_RESULT(no)
858 AC_MSG_CHECKING([whether to enable ccache])
859 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
860 if test "$ccache" != "" -a "$ccache" != "no"; then
861     # AC_CHECK_PROG will print out the result in this case
862     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
863 else
864     AC_MSG_RESULT(no)
867 #-----------------------------------------------------------------------------
868 AC_MSG_CHECKING([what specific host gcc version to use])
869 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="")
870 if test "$kernel_tool_version" != "" ; then
871     msg_result=$kernel_tool_version
872 else
873     msg_result="default"
875 AC_MSG_RESULT($msg_result)
877 #-----------------------------------------------------------------------------
878 AC_MSG_CHECKING([what optimization flags to use])
879 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
880 if test "$optimization" = "unknown"; then
881     dnl default is -O2 for normal builds, -O0 for debug builds
882     if test "$debug" != "none"; then
883         optimization="-O0"
884     else
885         optimization="-O2"
886     fi
888 aros_optimization_cflags="$optimization"
889 AC_MSG_RESULT($optimization)
891 paranoia_default=yes
892 #-----------------------------------------------------------------------------
893 AC_MSG_CHECKING([which paranoia flags to use])
894 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=(yes|no|FLAGS)],[Specific compiler warning FLAGS to enable for paranoia builds (default=-Wall -Werror)]),[paranoia_flags="$withval"],[paranoia_flags="$paranoia_default"])
895 if test "$paranoia_flags" = "no"; then
896         paranoia_flags="-Wall -Werror-implicit-function-declaration"
897         msg_result="none"
898 else
899     if test "$paranoia_flags" = "yes"; then
900         paranoia_flags="-Wall -Werror"
901     fi
902     msg_result="$paranoia_flags"
904 AC_MSG_RESULT($msg_result)
905 aros_warn_flags="$aros_warn_flags $paranoia_flags"
907 #-----------------------------------------------------------------------------
908 AC_MSG_CHECKING([what target variant to enable])
909 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
910 if test "$target_variant" = ""; then
911     aros_target_variant=""
912     aros_target_suffix=""
913     enableval="none"
914 else
915     aros_target_variant="$target_variant"
916     aros_target_suffix="-$target_variant"
918 AC_MSG_RESULT($enableval)
920 #-----------------------------------------------------------------------------
921 # Target-specific defaults. You can override then on a per-target basis.
923 # Bootloader name. Currently used by PC target.
924 target_bootloader="none"
925 PLATFORM_EXECSMP=
926 ENABLE_EXECSMP=
928 #-----------------------------------------------------------------------------
929 # Additional options for some specific targets
931 case "$aros_target_variant" in
932 ios)
933     AC_MSG_CHECKING([XCode path])
934     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")
935     AC_MSG_RESULT($aros_xcode_path)
937     AC_MSG_CHECKING([what iOS SDK version to use])
938     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")
939     AC_MSG_RESULT($aros_sdk_version)
941     ;;
943 "android")
944     AC_MSG_CHECKING([Android SDK path])
945     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)
946     AC_MSG_RESULT($aros_android_sdk)
948     AC_MSG_CHECKING([Android NDK path])
949     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
950     AC_MSG_RESULT($aros_android_ndk)
952     AC_MSG_CHECKING([what Android SDK version to use])
953     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")
954     AC_MSG_RESULT($aros_sdk_version)
956     aros_android_level=android-$aros_sdk_version
957     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
958         echo "Platform $aros_android_level is not installed in your SDK"
959         echo "Use --with-sdk-version=<API level number> to select another platform version"
960         echo "You can check what plaform versions are installed in your SDK"
961         echo "by examining contents of $aros_android_sdk/platforms directory"
962         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
963     fi
965     export PATH="$aros_android_sdk/tools:$PATH"
966     AC_PATH_PROG(android_tool, $android_tool)
967     AROS_REQUIRED(android,$android_tool)
969     if test "$aros_android_ndk" != "none"; then
970         AC_MSG_CHECKING([what Android NDK version to use])
971         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")
972         AC_MSG_RESULT($aros_ndk_version)
973     fi
975     AC_PATH_PROG(ant, ant)
976     if test "$ant" = ""; then
977         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
978     fi
980     AC_MSG_CHECKING([Build debug or release apk])
981     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)
982     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
983         AC_MSG_ERROR([apk-version has to be release or debug])
984     fi
985     AC_MSG_RESULT($aros_android_antapk)
987     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
988     if test "$host_os" = "mingw32"; then
989         android_tool="cmd //c $android_tool"
990     fi
992     need_dlopen="no"
994     ;;
995 esac
997 #-----------------------------------------------------------------------------
998 # External toolchains
999 kernel_tool_prefix="none"
1000 aros_tool_prefix="none"
1001 elf_tool_prefix="${target_cpu}-elf-"
1003 # This is the target configuration switch.
1004 case "$target_os" in
1005     linux*)
1006         aros_target_arch="linux"
1007         aros_target_family="unix"
1008         case "$target_cpu" in
1009             *m68k*)
1010                 aros_target_cpu="m68k"
1011                 aros_object_format="m68kelf"
1012                 aros_flavour="emulcompat"
1013                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1014                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1015                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1016                 gcc_target_cpu="mc68000"
1017                 ;;
1018             *i?86*)
1019                 aros_target_cpu="i386"
1020                 aros_object_format="elf_i386"
1021                 aros_flavour="emulation"
1022                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1023                 aros_kernel_ldflags="-Wl,-melf_i386"
1024                 aros_nominal_depth=8
1025                 gcc_target_cpu="i386"
1026                 pci_hidd_target="hidd-pci-linux"
1027                 android_tool_dir_prefix="x86"
1028                 android_tool_prefix="i686-android-linux"
1029                 android_ndk_arch="x86"
1030                 ;;
1031             *x86_64*)
1032                 aros_target_cpu="x86_64"
1033                 aros_object_format="elf_x86_64"
1034                 aros_flavour="emulation"
1035                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1036                 aros_isa_flags="$aros_isa_flags -mcmodel=large -mno-red-zone"
1037                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1038                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1039                 aros_nominal_depth=8
1040                 pci_hidd_target="hidd-pci-linux"
1041                 ;;
1042             *powerpc*)
1043                 aros_target_cpu="ppc"
1044                 aros_object_format="elf32ppc"
1045                 aros_flavour="emulation"
1046                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1047                 aros_nominal_depth=8
1048                 gcc_target_cpu="ppc"
1049                 ;;
1050 # TODO
1051 # Same as powerpc, but I need this for the nightly build to work again.
1052 # Actually, the nightly should be made working with powerpc target.
1053 # That just was too much work for the moment, another week or two.
1054             *ppc*)
1055                 aros_target_cpu="ppc"
1056                 aros_object_format="elf32ppc"
1057                 aros_flavour="emulation"
1058                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1059                 aros_nominal_depth=8
1060                 gcc_target_cpu="ppc"
1061                 ;;
1062             *aarch64*)
1063                 aros_target_cpu="aarch64"
1064                 target_cpu="aarch64"
1065                 aros_object_format="aarch64elf_aros"
1066                 aros_flavour="emulation"
1067                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1068                 gcc_target_cpu="aarch64"
1069                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1070                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1071                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1072                 aros_arch_libs="-laeabi"
1073                 gcc_default_float_abi="hard"
1074                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1075                 ;;
1076             *armhf*)
1077                 aros_target_cpu="arm"
1078                 target_cpu="arm"
1079                 aros_object_format="armelf_aros"
1080                 aros_flavour="emulation"
1081                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1082                 gcc_target_cpu="arm"
1083                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1084                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1085                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1086                 aros_arch_libs="-laeabi"
1087                 gcc_default_float_abi="hard"
1088                 android_tool_dir_prefix="arm-linux-androideabi"
1089                 android_tool_prefix="arm-linux-androideabi"
1090                 android_ndk_arch="arm"
1091                 kernel_tool_prefix="arm-linux-gnueabihf-"
1092                 ;;
1093             *arm*)
1094                 aros_target_cpu="arm"
1095                 aros_object_format="armelf_aros"
1096                 aros_flavour="emulation"
1097                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1098                 gcc_target_cpu="arm"
1099                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1100                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-omit-frame-pointer"
1101                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1102                 aros_arch_libs="-laeabi"
1103                 android_tool_dir_prefix="arm-linux-androideabi"
1104                 android_tool_prefix="arm-linux-androideabi"
1105                 android_ndk_arch="arm"
1106                 kernel_tool_prefix="arm-linux-gnueabi-"
1107                 ;;
1108             *)
1109                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1110                 ;;
1111         esac
1112         case "$aros_target_variant" in
1113             android)
1115                 dnl Not all Linux CPUs are supported by Android
1116                 if test "$android_ndk_arch" = ""; then
1117                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1118                 fi
1120                 aros_nominal_width=320
1121                 aros_nominal_height=480
1122                 if test "$aros_android_ndk" = "none"; then
1123                     dnl Use standalone toolchain, don't adjust paths
1124                     aros_kernel_cflags="-mandroid"
1125                     aros_kernel_ldflags="-mandroid"
1126                     CFLAGS="-mandroid"
1127                 else
1128                     dnl In Android NDK toolchains are placed in own directories,
1129                     dnl but tool names are not suffixed with version 
1130                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1131                     kernel_tool_version=""
1132                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1133                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1134                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1135                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1136                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1137                 fi
1138                 need_x11=no
1139                 host_android_gfx=yes
1140                 # Disable implicit PIC mode
1141                 aros_target_cflags="$aros_target_cflags -fno-pic"
1142                 kernel_tool_prefix="$android_tool_prefix-"
1143             ;;
1144         esac
1145     ;;
1147     pc)
1148         aros_target_arch="pc"
1149         aros_shared_default="no"
1150         target_bootloader="grub2"
1151         case "$target_cpu" in
1152             *i?86*)
1153                 aros_target_cpu="i386"
1155                 dnl If somebody hasn't already set the target object
1156                 dnl format, then use this value. Mostly to support
1157                 dnl FreeBSD cross-compilation.
1158                 dnl TODO: Remove when we always use our compiler.
1160                 if test "$aros_object_format" = "" ; then
1161                     aros_object_format="elf_i386"
1162                 fi
1163                 aros_flavour="standalone"
1164                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1165                 aros_kernel_ldflags="-Wl,-melf_i386"
1166                 aros_nominal_width=640
1167                 aros_nominal_height=480
1168                 gcc_target_cpu="i386"
1169                 ;;
1170             *x86_64*)
1171                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1172                 aros_target_cpu="x86_64"
1173                 aros_serial_debug=1
1174                 if test "$aros_object_format" = "" ; then
1175                     aros_object_format="elf_x86_64"
1176                 fi
1177                 aros_flavour="standalone"
1178                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1179                 aros_isa_flags="$aros_isa_flags -mcmodel=large  -mno-red-zone"
1180                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-omit-frame-pointer"
1181                 aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables -fno-omit-frame-pointer"
1182                 aros_kernel_ldflags=""
1183                 aros_nominal_width=640
1184                 aros_nominal_height=480
1185                 case "$aros_target_variant" in
1186                     smp)
1187                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1188                     ;;
1189                 esac
1190                 ;;
1191             *)
1192                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1193                 ;;
1194         esac
1195         ;;
1197     prep)
1198         aros_target_arch="prep"
1199         aros_shared_default="no"
1200         aros_target_cpu="ppc"
1201         aros_object_format="elf32ppc"
1202         aros_flavour="ppcnative"
1203         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1204         aros_kernel_ldflags=""
1205         aros_nominal_width=640
1206         aros_nominal_height=480
1207         gcc_target_cpu="ppc"
1208         ;;
1210     freebsd*)
1211         aros_target_arch="freebsd"
1212         aros_target_family="unix"
1213         aros_target_cpu="i386"
1214         aros_flavour="emulation"
1215         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1216         gcc_target_cpu="i386"
1218         aros_target_strip_flags="-x"
1219         ;;
1221     darwin*)
1222         aros_target_arch="darwin"
1223         aros_target_family="unix"
1224         aros_flavour="emulation"
1225         case "$target_cpu" in
1226             *i?86*)
1227                 aros_ios_platform="iPhoneSimulator"
1228                 aros_target_cpu="i386"
1229                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1230                 aros_kernel_ldflags=""
1231                 aros_macosx_version="10.4"
1232                 aros_nominal_depth=8
1233                 gcc_target_cpu="i386"
1234                 aros_object_format="elf_i386"
1235                 aros_kernel_ar_flags="-cr"
1236                 aros_target_strip_flags="-x"
1237                 kernel_tool_flags="-m32"
1238                 ;;
1239             *x86_64*)
1240                 aros_target_cpu="x86_64"
1241                 aros_object_format="elf_x86_64"
1242                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1243                 aros_macosx_version="10.6"
1244                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1245                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1246                 aros_kernel_cflags="-m64"
1247                 aros_kernel_ldflags="-m64"
1248                 aros_target_cflags="-mcmodel=large"
1249                 aros_nominal_depth=8
1250                 aros_kernel_ar="ar"
1251                 aros_kernel_ar_flags="-cr"
1252                 aros_kernel_ld="ld"
1253                 aros_kernel_as="as"
1254                 aros_kernel_ranlib="ranlib"
1255                 aros_kernel_nm="nm"
1256                 aros_kernel_strip="strip"
1257                 kernel_tool_prefix="i686-apple-darwin10-"
1258                 ;;
1259             *ppc*)
1260                 aros_target_cpu="ppc"
1261                 aros_object_format="elf32ppc"
1262                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1263                 aros_kernel_ldflags=""
1264                 aros_macosx_version="10.0"
1265                 aros_nominal_depth=8
1266                 gcc_target_cpu="ppc"
1267                 aros_kernel_ar="ar"
1268                 aros_kernel_ar_flags="-cr"
1269                 aros_kernel_ld="ld -arch ppc"
1270                 aros_kernel_as="as -arch ppc"
1271                 aros_kernel_ranlib="ranlib -arch ppc"
1272                 aros_kernel_nm="nm -arch ppc"
1273                 aros_kernel_strip="strip -arch ppc"
1274                 kernel_tool_prefix="powerpc-apple-darwin10-"
1275                 ;;
1276             *arm*)
1277                 aros_ios_platform="iPhoneOS"
1278                 aros_target_cpu="arm"
1279                 aros_object_format="armelf_aros"
1280                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1281                 aros_arch_libs="-laeabi"
1282                 aros_nominal_depth=8
1283                 gcc_target_cpu="arm"
1284                 aros_kernel_ar="ar"
1285                 aros_kernel_ar_flags="-cr"
1286                 aros_kernel_ld="ld -arch arm"
1287                 aros_kernel_ranlib="ranlib -arch arm"
1288                 kernel_tool_prefix="arm-apple-darwin10-" 
1289                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1290                 ;;
1291             *)
1292                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1293                 ;;
1294         esac
1295         case "$aros_target_variant" in
1296             ios)
1297                 aros_ios_version="3.0"
1298                 aros_nominal_width=320
1299                 aros_nominal_height=480
1300                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1301                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1302                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1303                 need_x11=no
1304                 # This is here because it may depend on iOS or SDK version
1305                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1306                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1307                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1308             ;;
1309             *)
1310                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1311                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1312             ;;
1313         esac
1314         ;;
1316     dragonfly*)
1317         aros_target_arch="dragonfly"
1318         aros_target_family="unix"
1319         aros_flavour="emulation"
1320         case "$target_cpu" in
1321             *i?86*)
1322                 aros_target_cpu="i386"
1323                 aros_object_format="elf_i386"
1324                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1325                 ;;
1326             *x86_64*)
1327                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1328                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1329                 aros_target_cpu="x86_64"
1330                 aros_object_format="elf_x86_64"
1331                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1332                 ;;
1333             *)
1334                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1335                 ;;
1336         esac
1337         ;;
1339     netbsd*)
1340         aros_target_arch="netbsd"
1341         aros_target_family="unix"
1342         case "$target_cpu" in
1343             *m68k*)
1344                 aros_target_cpu="m68k"
1345                 aros_object_format="m68kelf"
1346                 aros_flavour="emulcompat"
1347                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1348                 gcc_target_cpu="mc68000"
1349                 ;;
1350             *i?86*)
1351                 aros_target_cpu="i386"
1352                 aros_object_format="elf_i386"
1353                 aros_flavour="emulation"
1354                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1355                 aros_nominal_depth=8
1356                 gcc_target_cpu="i386"
1357                 ;;
1358             *)
1359                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1360                 ;;
1361         esac
1362         aros_target_genmap="-Wl,-M -Xlinker >"
1363         aros_flavour="emulation"
1364         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1365         ;;   
1367     openbsd*)
1368         aros_target_arch="openbsd"
1369         aros_target_family="unix"
1370         case "$target_cpu" in
1371             *i?86*)
1372                 aros_target_cpu="i386"
1373                 aros_object_format="elf_i386"
1374                 aros_flavour="emulation"
1375                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1376                 gcc_target_cpu="i386"
1377                 ;;
1378             *)
1379                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1380                 ;;
1381         esac
1382         aros_target_genmap="-Wl,-M -Xlinker >"
1383         aros_target_nm_flags="-u"
1384         aros_flavour="emulation"
1385         ;;
1387     solaris*)
1388         aros_target_arch="solaris"
1389         aros_target_family="unix"
1390         case "$target_cpu" in
1391            *i?86*)
1392                aros_target_cpu="i386"
1393                aros_object_format="elf_i386"
1394                aros_flavour="emulation"
1395                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1396                aros_nominal_depth=8
1397                gcc_target_cpu="i386"
1398                ;;
1399             *sparc*)
1400                 aros_target_cpu="sparc"
1401                 aros_object_format="elf_sparc"
1402                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1403                 gcc_target_cpu="sparc"
1404                 ;;
1405             *)
1406                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1407                 ;;
1408         esac
1409         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1410         aros_config_cxxflags="$aros_config_cxxflags -D$aros_target_cpu"
1411         aros_flavour="emulation"
1412         ;;
1414     morphos*)
1415         aros_target_arch="morphos"
1416         aros_shared_default="no"
1417         aros_target_cpu="ppc"
1418         aros_object_format="elf_ppc"
1419         aros_flavour="nativecompat"
1420         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1421         gcc_target_cpu="ppc"
1422         ;;
1424     sam440)
1425         aros_target_arch="sam440"
1426         aros_shared_default="no"
1427         aros_target_cpu="ppc"
1428         aros_object_format="elf32ppc"
1429         aros_flavour="ppcnative"
1430         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1431         aros_kernel_ldflags=""
1432         aros_nominal_width=1024
1433         aros_nominal_height=768
1434         aros_nominal_depth=24
1435         aros_isa_flags="$aros_isa_flags -mcpu=440fp -mno-toc"
1436         aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables"
1437         aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables"
1438         gcc_target_cpu="powerpc"
1439         ;;
1441     efika)
1442         aros_target_arch="efika"
1443         aros_shared_default="no"
1444         aros_target_cpu="arm"
1445         aros_object_format="armelf_aros"
1446         aros_flavour="standalone"
1447         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1448         aros_kernel_ldflags=""
1449         aros_nominal_width=1024
1450         aros_nominal_height=600
1451         aros_arch_libs="-laeabi"
1452         gcc_default_cpu="armv7-a"
1453         gcc_default_fpu="vfpv3"
1454         aros_isa_flags="$aros_isa_flags -mtune=cortex-a8"
1455         aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1456         aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1457         aros_config_aflags="$aros_config_aflags -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1458         aros_optimization_cflags="$aros_optimization_cflags -Os"
1459         case "$target_cpu" in
1460             *armhf*)
1461                 gcc_default_float_abi="hard"
1462                 target_cpu=arm
1463                 aros_target_cpu=arm
1464                 ;;
1465             *arm*)
1466                 gcc_default_float_abi="softfp"
1467                 ;;
1468             *)
1469                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1470                 ;;
1471         esac
1472         ;;
1473         
1474     chrp)
1475         aros_target_arch="chrp"
1476         aros_shared_default="no"
1477         aros_target_cpu="ppc"
1478         aros_object_format="elf32ppc"
1479         aros_flavour="ppcnative"
1480         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1481         aros_kernel_ldflags=""
1482         aros_nominal_width=640
1483         aros_nominal_height=480
1484         aros_isa_flags="$aros_isa_flags -mno-toc"
1485         aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables"
1486         aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables"
1487         gcc_target_cpu="powerpc"
1488         case "$aros_target_variant" in
1489             efika)
1490                 aros_isa_flags="$aros_isa_flags -mcpu=603e"
1491                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1"
1492                 aros_config_cxxflags="$aros_config_cxxflags -DBIG_ENDIAN_OHCI=1"
1493             ;;
1494         esac
1495         ;;
1497     r*pi)
1498         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1499         aros_flavour="standalone"
1500         aros_target_arch="raspi"
1502         aros_shared_default="no"
1504         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1505         
1506         case "$target_cpu" in
1507             *aarch64*)
1508                 aros_target_cpu="aarch64"
1509                 gcc_default_cpu="aarch64"
1510                 aros_object_format="aarch64elf_aros"
1511                 ;;
1512             *armhf*)
1513                 aros_target_cpu="arm"
1514                 gcc_default_cpu="armv6zk"
1515                 gcc_default_cpu_tune="arm1176jzf-s"
1516                 aros_object_format="armelf_aros"
1517                 aros_isa_flags="$aros_isa_flags -marm"
1518                 aros_config_cflags="$aros_config_cflags"
1519                 aros_config_cxxflags="$aros_config_cxxflags"
1520                 aros_config_aflags="$aros_config_aflags -marm"
1521                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1522                 aros_target_cflags="$aros_kernel_cflags -marm"
1523                 aros_target_mkdep="$aros_target_mkdep -Darm"
1524                 aros_arch_libs="-laeabi"
1525                 ;;
1526             *arm*)
1527                 aros_target_cpu="arm"
1528                 gcc_default_cpu="armv6zk"
1529                 gcc_default_cpu_tune="arm1176jzf-s"
1530                 aros_object_format="armelf_aros"
1531                 aros_isa_flags="$aros_isa_flags -marm"
1532                 aros_config_cflags="$aros_config_cflags"
1533                 aros_config_cxxflags="$aros_config_cxxflags"
1534                 aros_config_aflags="$aros_config_aflags -marm"
1535                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1536                 aros_target_cflags="$aros_kernel_cflags -marm"
1537                 aros_target_mkdep="$aros_target_mkdep -Darm"
1538                 aros_arch_libs="-laeabi"
1539                 ;;
1540             *)
1541                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1542                 ;;
1543         esac
1545         aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1546         aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables -fno-exceptions"
1547         aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1548         aros_kernel_cflags="$aros_kernel_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1549         aros_target_cflags="$aros_kernel_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1551         case "$aros_target_variant" in
1552             smp)
1553                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1554             ;;
1555         esac
1556         ;;
1558     stm32f7_discovery)
1559         aros_flavour="standalone"
1560         aros_target_arch="stm32f7_discovery"
1561         aros_target_cpu="arm"
1562         aros_target_cpu_mode="thumb2"
1563         aros_object_format="armelf_aros"
1564         aros_shared_default="no"
1566         # stm32f7 has DSP opcode support
1567         gcc_default_cpu="armv7e-m"
1568         # gcc_default_cpu="armv7-m"
1569         gcc_default_cpu_tune="cortex-m7"
1570         gcc_default_fpu="fpv4-sp-d16"
1571         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1572         # gcc_default_fpu="fpv5-sp-d16"
1573                 gcc_default_float_abi="hard"
1575         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1576         ;;
1578     amiga*)
1579         aros_target_arch="amiga"
1580         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1581         aros_shared_default="no"
1583         case "$target_cpu" in
1584             *m68k*)
1585                 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")
1586                 aros_enable_mmu=no
1587                 aros_target_cpu="m68k"
1588                 aros_object_format="m68kelf"
1589                 aros_flavour="standcompat"
1590                 gcc_target_cpu="m68000"
1591                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1592                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1593                 aros_config_cxxflags="$aros_config_cxxflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1594                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1595                 aros_config_aflags="$aros_config_aflags"
1596                 aros_target_strip_flags="-R.comment --strip-debug"
1597                 aros_nominal_width=640
1598                 aros_nominal_height=256
1599                 aros_nominal_depth=2
1600                 ;;
1601             *ppc*)
1602                 aros_cpu="ppc"
1603                 aros_flavour="native"
1604                 gcc_target_cpu="ppc"
1605                 ;;
1606             *)
1607                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1608                 ;;
1609         esac
1610         ;;
1612     mingw*)
1613         aros_target_arch="mingw32"
1614         aros_shared_default="no"
1615         aros_flavour="emulation"
1616         aros_shared_cflags=""
1617         need_crosstools="yes"
1618         need_dlopen="no"
1619         rescomp="windres"
1620         case "$target_cpu" in
1621             *i?86*)
1622                 aros_target_cpu="i386"
1623                 aros_object_format="elf_i386"
1624                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1625                 aros_nominal_depth=8
1626                 gcc_target_cpu="i386"
1628                 kernel_tool_prefix="i386-mingw32-"
1629                 ;;
1630             *x86_64*)
1631                 aros_target_cpu="x86_64"
1632                 aros_object_format="elf_x86_64"
1633                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1634                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1635                 aros_config_cxxflags="$aros_config_cxxflags -fno-omit-frame-pointer"
1636                 aros_nominal_depth=8
1637                 kernel_tool_prefix="x86_64-w64-mingw32-"
1638                 ;;
1639             *arm*)
1640                 aros_target_cpu="arm"
1641                 aros_object_format="armelf_aros"
1642                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1643                 aros_arch_libs="-laeabi"
1644                 aros_nominal_depth=8
1645                 gcc_target_cpu="arm"
1646                 gcc_default_float_abi="soft"
1647                 kernel_tool_prefix="arm-mingw32ce-"
1648                 aros_nominal_width=160
1649                 aros_nominal_height=160
1650                 ;;
1651             *)
1652                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1653                 ;;
1654         esac
1655         if test $host_os = "cygwin"; then
1656                 aros_kernel_cflags="-mno-cygwin"
1657         fi
1658     ;;
1659     pp*)
1660         aros_target_arch="pp"
1661         aros_shared_default="no"
1662         case "$target_cpu" in
1663             *m68k*)
1664                 aros_target_cpu="m68k"
1665                 aros_object_format="m68kelf"
1666                 aros_flavour="palmnative"
1667                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1668                 aros_nominal_width=160
1669                 aros_nominal_height=160
1670                 aros_nominal_depth=1
1671                 aros_target_ar_flags="cru"
1672                 aros_compiler_libs="-lgcc1"
1673                 aros_shared_default=no
1674                 aros_shared_cflags="-fpic"
1675                 aros_shared_aflags=""
1676                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1677                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1678                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1679                 aros_debug_aflags=""
1680                 aros_debug_ldflags="$aros_symbols_debug"
1681                 aros_mungwall_debug="0"
1682                 aros_modules_debug="0"
1683                 gcc_target_cpu="mc68000"
1684                 ignore_undefined_symbols="-ius"
1685                 ;;
1686            *)
1687                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1688                 ;;
1689         esac
1690         ;;
1692     mac*)
1693         aros_target_arch="mac"
1694         aros_shared_default="no"
1695         case "$target_cpu" in
1696             *m68k*)
1697                 aros_target_cpu="m68k"
1698                 aros_object_format="m68kelf"
1699                 aros_flavour="mac68knative"
1700                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1701                 aros_nominal_width=512
1702                 aros_nominal_height=384
1703                 aros_nominal_depth=8
1704                 aros_target_ar_flags="cru"
1705                 aros_compiler_libs="-lgcc1"
1706                 aros_shared_default=no
1707                 aros_shared_cflags="-fpic"
1708                 aros_shared_aflags=""
1709                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1710                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1711                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1712                 aros_debug_aflags=""
1713                 aros_debug_ldflags="$aros_symbols_debug"
1714                 aros_mungwall_debug="0"
1715                 aros_modules_debug="0"
1716                 gcc_target_cpu="mc68000"
1717                 ignore_undefined_symbols="-ius"
1718                 ;;
1719            *)
1720                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1721                 ;;
1722         esac
1723         ;;
1725     *)
1726         AC_MSG_ERROR([Unsupported target architecture $target])
1727         ;;
1728 esac
1730 #-----------------------------------------------------------------------------
1731 crosstools_guess="yes"
1732 aros_target_toolchain="no"
1733 aros_config_sysroot=""
1734 aros_kernel_sysroot=""
1736 AC_MSG_CHECKING([Kernel toolchain prefix])
1737 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1738 AC_MSG_RESULT($kernel_tool_prefix)
1740 AC_MSG_CHECKING([ELF toolchain prefix])
1741 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"
1742                                                  crosstools_guess="no"])
1743 AC_MSG_RESULT($elf_tool_prefix)
1745 AC_MSG_CHECKING([AROS toolchain prefix])
1746 AC_ARG_WITH(aros-toolchain,AC_HELP_STRING([--with-aros-toolchain=PREFIX],[Specify prebuilt AROS toolchain. Use yes for default name]),[aros_tool_prefix="$withval"
1747                 crosstools_guess="no"])
1748 if test "$aros_tool_prefix" = "yes" ; then
1749     aros_tool_prefix=$aros_target_cpu-aros-
1751 AC_MSG_RESULT($aros_tool_prefix)
1753 #-----------------------------------------------------------------------------
1754 #   Checking if we should build crosstools..
1755 AC_MSG_CHECKING([whether to build crosstools])
1756 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1757 AC_MSG_RESULT($crosstools)
1759 if test "${crosstools}" = "yes"; then
1760     if test "${crosstools_guess}" = "no"; then
1761         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1762     fi
1765 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1766     aros_target_toolchain="yes"
1769 AC_MSG_CHECKING([where to install the crosstools binaries])
1770 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])
1771 if test "x$aros_toolchain_install" = "x"; then
1772     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1773 else
1774     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1775     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1776     if test "$crosstools_guess" = "no" ; then
1777         toolchain_needs_sysroot=yes
1779         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1780             aros_kernel_sysroot = $aros_config_sysroot
1781         fi
1782     fi
1784 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1786 AC_MSG_CHECKING([If we need to use --sysroot])
1787 if test "$toolchain_needs_sysroot" = "yes" ; then
1788     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer"
1790 AC_MSG_RESULT($toolchain_needs_sysroot)
1792 #-----------------------------------------------------------------------------
1793 if test "$aros_toolchain" = "gnu" ; then
1794     AC_MSG_CHECKING([what specific target binutils version to use])
1796 AC_ARG_WITH(binutils-version,AC_HELP_STRING([--with-binutils-version=VERSION],[Use binutils-VERSION for building AROS]),use_binutils_version="$withval",use_binutils_version="")
1797 if test "$use_binutils_version" = ""; then
1798         target_binutils_version="$default_binutils_version"
1799 else
1800     target_binutils_version="$use_binutils_version"
1802 if test "$aros_toolchain" = "gnu" ; then
1803     AC_MSG_RESULT($target_binutils_version)
1807 # Helper to identify gcc version
1808 AC_DEFUN([CROSS_GCC_VERSION], [
1809   target_gcc_version=""
1810   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1811     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1812     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1813       ax_cv_gcc_version=""
1814     ])
1815   ])
1816   target_gcc_version=$ax_cv_gcc_version
1817   AC_SUBST([target_gcc_version])
1820 #-----------------------------------------------------------------------------
1821 if test "$aros_toolchain" = "gnu" ; then
1822     AC_MSG_CHECKING([what specific target gcc version to use])
1824 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1825 if test "$use_gcc_version" = ""; then
1826     if test "${crosstools}" = "no"; then
1827       if test "x$aros_toolchain_install" != "x"; then
1828           CROSS_GCC_VERSION
1829       fi
1830     fi
1831     if test "$use_gcc_version" = ""; then
1832         target_gcc_version="$default_gcc_version"
1833     fi
1834 else
1835     target_gcc_version="$use_gcc_version"
1837 if test "$aros_toolchain" = "gnu" ; then
1838     AC_MSG_RESULT($target_gcc_version)
1840     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1841     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1842     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1844     gcc_fix_bitfields="false"
1845     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1846         gcc_fix_bitfields="true"
1847     else
1848         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1849             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1850                 gcc_fix_bitfields="true"
1851             fi
1852         fi
1853     fi
1855     if test "$gcc_fix_bitfields" = "true" ; then
1856         case "$aros_target_cpu" in
1857         *x86_64*)
1858             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1859             aros_isa_flags="$aros_isa_flags -mno-ms-bitfields"
1860             ;;
1861         i386)
1862             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1863             aros_isa_flags="$aros_isa_flags -mno-ms-bitfields"
1864             ;;
1865         esac
1866     fi
1869 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1870 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1871 AC_MSG_RESULT($objc)
1872 if test "x$objc" = "xyes"; then
1873     objc_target="$objc"
1874 else
1875     objc_target="no-objc"
1878 AC_MSG_CHECKING([whether to enable Java suppport])
1879 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1880 AC_MSG_RESULT($java)
1881 if test "x$java" != "xno"; then
1882     java_target="$java"
1883 else
1884     java_target="no-java"
1887 spec_obj_format="-m $aros_object_format"
1888 # Now process extra architecture-specific options.
1889 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1890 # as well as floating-point ABI.
1891 case "$aros_target_cpu" in
1892 *x86_64*)
1893     dnl x86_64 can build 32 or 64bit code
1894     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1895     ;;
1896 arm*)
1897     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1898     if test "$gcc_default_cpu" = ""; then
1899         gcc_default_cpu="armv6"
1900     fi
1901     if test "$gcc_default_fpu" = ""; then
1902         gcc_default_fpu="vfp"
1903     fi
1904     if test "$gcc_default_float_abi" = ""; then
1905         if test "$target_cpu" = "armhf"; then
1906             gcc_default_float_abi="hard"
1907         else
1908             gcc_default_float_abi="softfp"
1909         fi
1910     fi
1912     AC_MSG_CHECKING([Which minimum CPU to use])
1913     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)
1914     AC_MSG_RESULT($aros_gcc_cpu)
1916     AC_MSG_CHECKING([Which minimum FPU to use])
1917     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)
1918     AC_MSG_RESULT($aros_gcc_fpu)
1920     AC_MSG_CHECKING([Which floating point ABI to use])
1921     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)
1922     AC_MSG_RESULT($aros_gcc_float_abi)
1924     AC_MSG_CHECKING([Which ARM mode to use])
1925     if test "$aros_target_cpu_mode" = ""; then
1926         aros_target_cpu_mode="arm32"
1927         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1928     else
1929         AC_MSG_RESULT([$aros_target_cpu_mode])
1930     fi
1932     case "$aros_target_cpu_mode" in
1933     arm32)
1934         gcc_default_mode="arm"
1935         aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1936     ;;
1937     arm64)
1938         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1939     ;;
1940     thumb)
1941         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1942     ;;
1943     thumb1)
1944         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1945     ;;
1946     thumb2)
1947         gcc_default_mode="thumb"
1948         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1949         aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1950     ;;
1951     *)
1952         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1953     ;;
1954     esac
1956     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1957     aros_config_cxxflags="$aros_config_cxxflags -fno-asynchronous-unwind-tables -fno-exceptions"
1958     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1959     ;;
1960 i386)
1961     aros_isa_flags="$aros_isa_flags -m32 -march=i486"
1962     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1963     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1964     ;;
1965 esac
1967 # Some architectures may need custom ELF specs.
1968 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1969     elf_specs_in=config/${aros_object_format}-specs.in
1970 else
1971     elf_specs_in=config/elf-specs.in
1974 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1975 # Since we override specs, we may need to put these defines there
1976 if test "$gcc_target_cpu" != ""; then
1977     gcc_target_cpu="-D__${gcc_target_cpu}__"
1980 AC_MSG_CHECKING([where to download sourcecode for external ports])
1981 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1982 if test "$with_portssrcdir" = "default"; then
1983     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1984 else
1985     AROS_PORTSSRCDIR="$with_portssrcdir"
1987 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1989 AC_MSG_CHECKING([which bootloader to use])
1990 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1991 if test "$target_bootloader" = "none"; then
1992     aros_target_bootloader=""
1993 else
1994     aros_target_bootloader="$target_bootloader"
1996 AC_MSG_RESULT($target_bootloader)
1998 AC_MSG_CHECKING([which icon-set to use])
1999 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
2000 if test "$target_iconset" = "default"; then
2001     aros_target_iconset="Gorilla"
2002     target_iconset="default (Gorilla)"
2003 else
2004     aros_target_iconset="$target_iconset"
2006 AC_MSG_RESULT($target_iconset)
2008 AC_MSG_CHECKING([which GUI Theme to use])
2009 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2010 if test "$target_guitheme" = "default"; then
2011     aros_target_guitheme="Ice"
2012 else
2013     aros_target_guitheme="$target_guitheme"
2015 AC_MSG_RESULT($aros_target_guitheme)
2017 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2018 # for target code)
2019 cross_compiling=no
2021 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2022 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2023     cross_compiling=yes
2026 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2027 dnl The flag itself is given in per-target section, because some targets require to pass it
2028 dnl in a different manner, otherwise some tests fail.
2029 dnl TODO: Justify this.
2030 if test "$aros_host_cpu" == "x86_64" ; then
2031     if test "$aros_target_cpu" == "i386" ; then
2032         cross_compiling=no
2033     fi
2036 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2037     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2038     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2039     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2040     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2041     dnl used to build bootstrap for target arch in either case.
2042     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2043     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2044     dnl perhaps introducing aros_host_variant
2045     if test "$aros_host_arch" != "$aros_target_arch" ; then
2046         cross_compiling=yes
2047     fi
2048 else
2049     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2050     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2051     if test "$host_cc_elf" = "no" ; then
2052         cross_compiling=yes
2053     fi
2056 if test "$cross_compiling" = "no" ; then
2057     kernel_tool_prefix=""
2058     if test "$host_cc_elf" = "yes" ; then
2059         elf_tool_prefix=""
2060     fi
2063 if test "$kernel_tool_version" != ""; then
2064     kernel_tool_version="-$kernel_tool_version"
2067 #######################################################################
2068 ## Compute what toolchains to use, and their paths                   ##
2069 #######################################################################
2071 # This takes, as input:
2072 #   crosstools             {yes,no}
2073 #   kernel_tool_version    {"",[version]}
2074 #   target_tool_version    {"",[version]}
2075 #   kernel_tool_prefix     {none,[some-arch-os-]}
2076 #   gnu-toolchain -:
2077 #     target_tool_prefix     ${aros_target_cpu}-aros-
2078 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2080 # The output is
2081 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2082 #        Where the 'kernel' binaries are located
2083 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2084 #        Where the 'target' binaries are located
2085 #        (not the symlink farm - that is aros_target_*!)
2087 # The rules are:
2088 #   if crosstools then
2089 #      if kernel_tools_prefix = "no-kernel-prefix-"
2090 #          aros_kernel_* = crosstools cc paths
2091 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2092 #      else
2093 #          VALIDATE(${kernel_tools_prefix}*)
2094 #          aros_kernel_* = ${kernel_tools_prefix}*
2095 #          if ${kernel_tools_prefix}cc is an AROS gcc
2096 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2097 #          else
2098 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2099 #          fi
2100 #      fi
2102 #      orig_target_* = aros built crosstools
2103 #      orig_target_cc = elf cc wrapper around crosstools cc
2104 #   else
2105 #      VALIDATE(${kernel_tools_prefix}*)
2107 #      orig_target_* = aros_kernel_*
2108 #      if aros_kernel_cc is an AROS gcc
2109 #          orig_target_cc = aros_kernel_cc
2110 #      else
2111 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2112 #      fi
2113 #   fi
2115 if test "$aros_toolchain" = "gnu" ; then
2116     target_tool_prefix="${aros_target_cpu}-aros-"
2117 elif test "$aros_toolchain" = "llvm" ; then
2118     target_tool_prefix="bin/"
2121 if test "$kernel_tool_prefix" != "" ; then
2122     AC_MSG_CHECKING([which kernel tools])
2123     AC_MSG_RESULT([$kernel_tool_prefix]);
2126 if test "$kernel_tool_prefix" = "none" ; then
2127     dnl ELF wrapper can be used only for native bootstrap
2128     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2129         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2130     fi
2131 else
2132     # Kernel tools required - find them
2133     # Note that 'normally', aros_kernel_* overrides will be
2134     # empty, unless specified in the per-arch sections above.
2135     if test "x$aros_kernel_cpp" = "x"; then
2136         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2137     fi
2138     AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2139     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2140     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2142     if test "x$aros_kernel_cc" = "x"; then
2143         aros_kernel_cc=${kernel_tool_prefix}${CC}
2144     fi
2145     AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2146     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2147     AROS_REQUIRED(cc,$aros_kernel_cc)
2149     if test "x$aros_kernel_cxx" = "x"; then
2150         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2151     fi
2152     AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2153     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2154     # If it's set, make sure it's really there
2155     if test "x$aros_kernel_cxx" != "x" ; then
2156         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2157     fi
2158     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2159     AROS_REQUIRED(ld,$aros_kernel_ld)
2160     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2161     AROS_REQUIRED(as,$aros_kernel_as)
2162     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2163     AROS_REQUIRED(ar,$aros_kernel_ar)
2164     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2165     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2166     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2167     AROS_REQUIRED(nm,$aros_kernel_nm)
2168     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2169     AROS_REQUIRED(strip,$aros_kernel_strip)
2171     # Objcopy and objdump are not required for the kernel
2172     # toolchain on many architectures.
2173     # So we'll look for them, but not make them strictly required.
2174     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2175     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2176     if test "x${crosstools}" != "xyes" ; then
2177         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2178         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2179     fi
2182 AC_MSG_CHECKING([which target tools to use])
2183 if test "$aros_target_toolchain" = "yes"; then
2184     if test "$aros_toolchain" = "llvm" ; then
2185         msg_result="llvm"
2186     else
2187         msg_result=$target_tool_prefix
2188     fi
2189     AC_MSG_RESULT([$msg_result])
2190     # We are building AROS crosstools
2191     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2192     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2193     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2194     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2195     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2196     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2197     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2198     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2199     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2200     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2201     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2202     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2203 else
2204     # Determine whether AROS or ELF tools should be used
2205     if test "$aros_tool_prefix" = "none"; then
2206         aros_tool_prefix="${elf_tool_prefix}"
2207     fi
2209     AC_MSG_RESULT([$aros_tool_prefix])
2210     # We are *not* building AROS crosstools - use the AROS or ELF tools
2211     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2212     AROS_REQUIRED(cpp,$orig_target_cpp)
2213     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2214     AROS_REQUIRED(cc,$orig_target_cc)
2215     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2216     AROS_REQUIRED(cxx,$orig_target_cxx)
2217     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2218     AROS_REQUIRED(ld,$orig_target_ld)
2219     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2220     AROS_REQUIRED(as,$orig_target_as)
2221     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2222     AROS_REQUIRED(ar,$orig_target_ar)
2223     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2224     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2225     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2226     AROS_REQUIRED(nm,$orig_target_nm)
2227     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2228     AROS_REQUIRED(strip,$orig_target_strip)
2229     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2230     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2231     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2232     AROS_REQUIRED(objdump,$orig_target_objdump)
2235 if test "$kernel_tool_prefix" = "none" ; then
2236     # No kernel tools specified
2237     # Assume target tools == kernel tools with ELF wrapper
2238     aros_kernel_cc=$orig_target_cc
2239     aros_kernel_cxx=$orig_target_cxx
2240     aros_kernel_cpp=$orig_target_cpp
2241     aros_kernel_ld=$orig_target_ld
2242     aros_kernel_as=$orig_target_as
2243     aros_kernel_ar=$orig_target_ar
2244     aros_kernel_ranlib=$orig_target_ranlib
2245     aros_kernel_nm=$orig_target_nm
2246     aros_kernel_strip=$orig_target_strip
2247     aros_kernel_objcopy=$orig_target_objcopy
2248     aros_kernel_objdump=$orig_target_objdump
2249     use_kernel_cc_wrapper=yes
2252 # At this point, all aros_kernel_* and aros_target_* 
2253 # tools should be set up correctly
2255 CC="$aros_kernel_cc $kernel_tool_flags"
2256 CPP="$aros_kernel_cpp"
2258 #-----------------------------------------------------------------------------
2260 # Find all the tools we need to compile. This could be cross-compiling
2261 # though! If that is the case we use the GNU form of the target and
2262 # simply add this to the front of the binary name. This is rather simple,
2263 # but it should work under most circumstances.
2265 # The default tools are to use the same as the host, but only if the
2266 # host and target CPU are the same. With GCC this is normally enough.
2269 aros_cc_pre=""
2270 aros_shared_ld="$aros_host_ld"
2272 aros_target_mkdep="$aros_host_mkdep"
2274 # The default tools executables to be linked to.
2275 if test "$rescomp" != ""; then
2276     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2277     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2280 # Set up the sources for the symlink farm
2281 if test "$crosstools" = "yes"; then
2282     crosstools_target=tools-crosstools
2285 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2286 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2288 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2289 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2290 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2291 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2292 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2293 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2294 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2296 # aros_cc_pre is a variable that is added to the front of the compiler name
2297 # in the generated aros-gcc shell script. We need this to enable the cache
2298 # to work across cleaned builds. Also, support DISTCC using the correct
2299 # environment variable.
2302 if test "x${DISTCC}" != "x" ; then
2303     if test "x${CCACHE}" != "x" ; then
2304         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2305     else
2306         aros_cc_pre="${DISTCC} "
2307     fi
2308 else
2309     if test "x${CCACHE}" != "x" ; then
2310         aros_cc_pre="${CCACHE} "
2311     fi
2314 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2315 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2316 AC_SUBST(aros_target_nix_ldflags,-nix)
2317 AC_SUBST(aros_target_detach_ldflags,-detach)
2318 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2320 # Target tools
2321 AC_SUBST(aros_toolchain)
2322 if test "$aros_target_toolchain" != "yes"; then
2323     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2324     if test "$GCC" = "yes"; then
2325         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2326     fi
2327 else
2328     # We do not know which c compiler version we are going to build and what we need to know
2329     # here is different for different versions so this will be set later during the
2330     # build of crosstools.
2331     if test "$aros_toolchain" = "gnu" ; then
2332         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2333     elif test "$aros_toolchain" = "llvm" ; then
2334         prefix="$AROS_CROSSTOOLSDIR/bin/"
2335     fi
2336     aros_target_cc_path=@aros_target_cc_path@
2338 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2339 aros_target_cc="${prefix}${toolchain_c_compiler}"
2340 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2341 aros_target_as="${prefix}${toolchain_as}"
2342 if test "${use_ld_wrapper}" = "yes"; then
2343     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2344 else
2345     aros_target_ld="${prefix}${toolchain_ld}"
2347 aros_toolchain_ld="${prefix}${toolchain_ld}"
2349 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2350 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2351 aros_target_objdump="${prefix}${toolchain_objdump}"
2352 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2353 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2354 aros_target_strip="${prefix}${toolchain_strip}"
2355 aros_plain_nm="${prefix}${toolchain_nm}"
2356 aros_plain_ar="${prefix}${toolchain_ar}"
2358 AC_ARG_ENABLE(includes,
2359 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2360 [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`])
2362 if test "$aros_kernel_includes" = ""; then
2363     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2364         aros_kernel_includes="-isystem $aros_target_incl"
2365     fi
2368 if test "$aros_kernel_includes" != "" ; then
2369     dnl find out about the kernel cc's include path
2370     AC_MSG_CHECKING([for the kernel compiler's include path])
2371     if test "$aros_kernel_cc_includes" = "" ; then
2372         # Try to guess where the directory is.
2373         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2374         if test -d $aros_kernel_cc_includes; then
2375             # Check if there is also an include-fixed directory and add it
2376             # to kernel compiler's include path as it may contain some of
2377             # the headers we need.
2378             if test -d "$aros_kernel_cc_includes"-fixed; then
2379                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2380             fi
2381             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2382             if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2383                 aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2384             fi
2385         else
2386             # The directory doesn't exist, we need to do some more work.
2387             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2389             # These are the headers we're looking for.
2390             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2391                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2392                      zutil.h stdint.h"
2394             dirs=
2395             for h in $headers; do
2396                 # Which other headers are needed by each of the above?
2397                 deps=$(echo "#include <$h>" | \
2398                        $aros_kernel_cc -E -M - 2>/dev/null | \
2399                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2401                 # Copy all the needed headers to a directory beneath gendir.
2402                 for d in $deps; do
2403                     h=$(basename $d)
2404                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2405                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2406                     ! test -d $dir && mkdir -p $dir
2407                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2408                 done
2409             done            
2410         fi
2411     fi
2412     AC_MSG_RESULT($aros_kernel_cc_includes)
2413     # Adding -nostdinc to kernel includes as they are always used together.
2414     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2417 if test "$crosstools" != "yes"; then
2418     dnl find out about the target cc's include path
2419     AC_MSG_CHECKING([for the target compiler's include path])
2420     if test "$aros_target_cc_includes" = "" ; then
2421         #try to guess where the directory is
2422         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2423         if ! test -d $aros_target_cc_includes; then
2424             #the directory doesn't exist, we need to do some more work
2425             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2426         
2427             #these are the headers we're looking for
2428             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2429                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2430                     zutil.h"
2432             dirs=
2433             for h in $headers; do
2434                 #which other headers each of the above headers needs?
2435                 deps=$(echo "#include <$h>" | \
2436                     $orig_target_cc -E -M - 2>/dev/null | \
2437                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2438             
2439                 #copy all the needed headers to a directory beneath gendir
2440                 for d in $deps; do
2441                     h=$(basename $d)
2442                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2443                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2444                     ! test -d $dir && mkdir -p $dir
2445                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2446                 done
2447             done
2448         fi
2449     fi
2450     AC_MSG_RESULT($aros_target_cc_includes)
2451 else
2452     # We do not know which c compiler version we are going to build and what we need to know
2453     # here is different for different versions so this will be set later during the
2454     # build of crosstools.
2455     aros_target_cc_includes=@aros_target_cc_includes@
2459 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2460 # On GCC >= 4.0 -iquote should be used
2463 save_cc="$CC"
2464 save_cflags="$CFLAGS"
2465 CFLAGS="-iquote."
2466 kernel_cflags_iquote=$host_cflags_iquote
2467 kernel_cflags_iquote_end=$host_cflags_iquote_end
2468 if test "x-$cross_compiling" = "x-yes"; then
2469     CC="$aros_kernel_cc"
2470     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2471     if test "x-$crosstools" != "x-yes"; then
2472         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2473     else
2474         # we do know it is supported for the smallest version of gcc we are going to build
2475         # we assume it's also supported by later versions
2476         use_no_stack_protector=yes
2477     fi
2478     AC_MSG_RESULT($use_no_stack_protector)
2479     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2480     if test "x-$crosstools" != "x-yes"; then
2481         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2482     else
2483         # we do know it is supported for the smallest version of gcc we are going to build
2484         # we assume it's also supported by later versions
2485         has_iquote=yes
2486     fi
2487     AC_MSG_RESULT($has_iquote)
2488     if test "x-$has_iquote" = "x-yes" ; then
2489         kernel_cflags_iquote=-iquote
2490         kernel_cflags_iquote_end=
2491     else
2492         kernel_cflags_iquote=-I
2493         kernel_cflags_iquote_end=-I-
2494     fi
2496 if test "x-$use_no_stack_protector" = "x-yes" ; then
2497     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2500 #-----------------------------------------------------------------------------
2502 # Check if we can explicitly choose older version of symbol hashing
2504 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2505 CC="$aros_kernel_cc"
2506 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2507 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2508 AC_MSG_RESULT($use_hash_style)
2509 if test "x-$use_hash_style" = "x-yes" ; then
2510     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2512 CC="$save_cc"
2513 CFLAGS="$save_cflags"
2515 AC_SUBST(host_cflags_iquote)
2516 AC_SUBST(host_cflags_iquote_end)
2517 AC_SUBST(kernel_cflags_iquote)
2518 AC_SUBST(kernel_cflags_iquote_end)
2521 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2522 AC_MSG_CHECKING([for default resolution of WBScreen])
2523 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2524 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2525 if test "$resolution" = "yes" ; then
2526     resolution="none"
2528 if test "$resolution" = "no" ; then
2529     resolution="none"
2531 if test "$resolution" != "none" ; then
2532     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2533     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2534     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2536 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2537 aros_cv_nominal_width=$aros_nominal_width
2538 aros_cv_nominal_height=$aros_nominal_height
2539 aros_cv_nominal_depth=$aros_nominal_depth
2541 dnl See if the user wants the serial debug output for native flavour
2542 AC_MSG_CHECKING([whether serial debug is enabled])
2543 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)
2544 if test "$aros_serial_debug" = 0 ; then
2545     serial_debug_forced=""
2546     if test "$serial_debug" = "yes" ; then
2547         serial_debug="1"
2548     fi
2549     if test "$serial_debug" = "no" ; then
2550         serial_debug="none"
2551     fi
2552 else
2553     serial_debug_forced="(forced)"
2554     serial_debug=$aros_serial_debug
2556 if test "$serial_debug" != "none" ; then
2557     aros_serial_debug=$serial_debug
2558     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2559 else
2560     AC_MSG_RESULT(no)
2563 dnl See if the user wants the palm debug output hack for palm native flavour
2564 AC_MSG_CHECKING([whether palm debug hack is enabled])
2565 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")
2566 if test "$palm_debug_hack" = "yes" ; then
2567     aros_palm_debug_hack="1"
2569 AC_MSG_RESULT($palm_debug_hack)
2571 dnl See if dev wants the usb3.0 code
2572 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2573 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2574 if test "$usb30_code" = "yes" ; then
2575     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2576     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2578 AC_MSG_RESULT($usb30_code)
2580 dnl See if the user wants nesting supervisor activated for unix flavour
2581 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2582 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")
2583 if test "$nesting_supervisor" = "yes" ; then
2584     aros_nesting_supervisor="1"
2586 AC_MSG_RESULT($nesting_supervisor)
2588 dnl See if the user wants to disable MMU support
2589 dnl This can be overriden on per-target basis,
2590 dnl set $aros_enable_mmu to "yes" or "no" to do this
2591 if test "$aros_enable_mmu" = "" ; then
2592     AC_MSG_CHECKING([whether MMU support is enabled])
2593     dnl Enabled by default
2594     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2595     if test "$aros_enable_mmu" = "" ; then
2596         aros_enable_mmu="yes"
2597     fi
2598     AC_MSG_RESULT($aros_enable_mmu)
2600 if test "$aros_enable_mmu" = "no" ; then
2601     aros_enable_mmu="0"
2602 else
2603     aros_enable_mmu="1"
2605     
2607 dnl things specifically required for hosted flavours
2608 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2610     if test "x-$need_dlopen" != "x-no" ; then
2611       save_libs="$LIBS"
2612       LIBS=""
2613       dnl some kind of dynamic library access system is required for hostlib.resource
2614       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2615       if test "x-$have_dl" = "x-no" ; then
2616           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2617                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2618                                     have_dl="no")
2619       fi
2620       if test "x-$have_dl" = "x-no" ; then
2621           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2622       fi
2623       LIBS="$save_libs"
2624     fi
2627     dnl x11 hidd
2628     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2629                                            [build X11 hidd for hosted (default=auto)]),
2630                                            x11_hidd="$enableval",
2631                                            x11_hidd="$need_x11")
2632     case "x-$x11_hidd" in
2633         x-yes|x-no|x-auto)                 ;;
2634         *)                 x11_hidd="$need_x11" ;;
2635     esac
2637     ENABLE_X11=0
2639     dnl they want it
2640     if test "x-$x11_hidd" != "x-no" ; then
2642         dnl find x11 stuff
2643         AC_PATH_X
2645         if test -n "$x_includes"; then
2646             X_CFLAGS="$X_CFLAGS -I$x_includes"
2647         fi
2649         if test -n "$x_libraries"; then
2650             X_LIBS="$X_LIBS -L$x_libraries"
2651         fi
2653         if test "x-$no_x" = "x-yes" ; then
2655             dnl didn't find it
2656             if test "x-$x11_hidd" != "x-auto" ; then
2657                 dnl and they explicitly asked for it, bail out
2658                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2659             fi
2660         
2661         else
2662             dnl found it, setup the metatarget
2663             host_x_gfx=yes
2664             ENABLE_X11=1
2666             aros_host_x11_cflags="$X_CFLAGS"
2667             aros_host_x11_ldflags="$X_LIBS  -lX11"
2669             dnl setup shared memory extensions
2670             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2671                                                   [use X11 shared memory (default=auto)]),
2672                                                   x11_hidd_shm="$enableval",
2673                                                   x11_hidd_shm="auto")
2674             case "x-$x11_hidd_shm" in
2675                 x-yes|x-no|x-auto)                     ;;
2676                 *)                 x11_hidd_shm="auto" ;;
2677             esac
2679             have_xshm=no
2681             dnl they want it
2682             if test "x-$x11_hidd_shm" != "x-no" ; then
2684                 dnl system shm headers
2685                 AC_CHECK_HEADERS(sys/ipc.h)
2686                 AC_CHECK_HEADERS(sys/shm.h)
2688                 dnl got them
2689                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2691                     dnl make sure X libs have shm functions
2692                     save_cflags="$CFLAGS"
2693                     save_ldflags="$LDFLAGS"
2694                     CFLAGS="$CFLAGS $X_CFLAGS"
2695                     LDFLAGS="$LDFLAGS $X_LIBS"
2696                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2697                     CFLAGS="$save_cflags"
2698                     LDFLAGS="$save_ldflags"
2699                 fi
2700             fi
2702             dnl detection done, prepare output
2703             if test "x-$have_xshm" = "x-yes" ; then
2704                 dnl we can do shm
2705                 DO_XSHM_SUPPORT="1"
2706             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2707                 dnl they explicitly asked for it, but we can't do it
2708                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2709             else
2710                 dnl otherwise just disable it
2711                 DO_XSHM_SUPPORT="0"
2712             fi
2714             
2715             dnl setup vidmode (fullscreen) extensions
2716             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2717                                                       [use X11 vidmode extension (default=auto)]),
2718                                                       x11_hidd_vidmode="$enableval",
2719                                                       x11_hidd_vidmode="auto")
2720             case "x-$x11_hidd_vidmode" in
2721                 x-yes|x-no|x-auto)                         ;;
2722                 *)                 x11_hidd_vidmode="auto" ;;
2723             esac
2725             have_vidmode=no
2727             dnl they want it
2728             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2730                 dnl make sure X libs have vidmode functions
2731                 save_cflags="$CFLAGS"
2732                 save_ldflags="$LDFLAGS"
2733                 CFLAGS="$CFLAGS $X_CFLAGS"
2734                 LDFLAGS="$LDFLAGS $X_LIBS"
2735                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2736                 CFLAGS="$save_cflags"
2737                 LDFLAGS="$save_ldflags"
2738             fi
2740             dnl detection done, prepare output
2741             if test "x-$have_vidmode" = "x-yes" ; then
2742                 dnl we can do vidmode
2743                 DO_VIDMODE_SUPPORT="1"
2744             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2745                 dnl they explicitly asked for it, but we can't do it
2746                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2747             else
2748                 dnl otherwise just disable it
2749                 DO_VIDMODE_SUPPORT="0"
2750             fi
2751         fi
2752     fi
2754     dnl sdl hidd
2755     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2756                                            [build SDL hidd for hosted (default=auto)]),
2757                                            sdl_hidd="$enableval",
2758                                            sdl_hidd="auto")
2759     case "x-$sdl_hidd" in
2760         x-yes|x-no|x-auto)                 ;;
2761         *)                 sdl_hidd="auto" ;;
2762     esac
2764     dnl they want it
2765     if test "x-$sdl_hidd" != "x-no" ; then
2767         dnl find sdl
2768         SDL_VERSION=1.2.5
2769         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2770             [have_sdl="no"])
2772         if test "x-$have_sdl" != "x-yes" ; then
2774             dnl didn't find it
2775             if test "x-$sdl_hidd" != "x-auto" ; then
2776                 dnl and they explicitly asked for it, bail out
2777                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2778             fi
2780         else
2781             dnl found it, enable the build
2782             host_sdl_gfx=yes
2783             aros_host_sdl_cflags=$SDL_CFLAGS
2784             aros_host_sdl_libs=$SDL_LIBS
2785         fi
2786     fi
2791 dnl See if the user wants dbus.library
2792 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2793 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2794 if test "$dbus" = "yes" ; then
2795     ENABLE_DBUS=1
2796     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2797     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2798     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2799     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2800 else
2801     ENABLE_DBUS=0
2803 AC_MSG_RESULT($dbus)
2805 if test "$use_kernel_cc_wrapper" = "yes" ; then
2806     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2809 dnl --------------------------------------------------------------------
2810 dnl Configuration Output Section
2811 dnl --------------------------------------------------------------------
2813 # Generic
2814 AC_SUBST(aros_arch)
2815 AC_SUBST(aros_cpu)
2816 AC_SUBST(aros_flavour)
2817 AC_SUBST(aros_flavour_uc)
2818 AC_SUBST(aros_target_toolchain)
2819 AC_SUBST(aros_toolchain_ld)
2820 AC_SUBST(aros_build_host)
2821 AC_SUBST(AROS_BUILDDIR)
2822 AC_SUBST(AROS_BUILDDIR_UNIX)
2823 AC_SUBST(SRCDIR)
2824 AC_SUBST(AROS_CROSSTOOLSDIR)
2825 AC_SUBST(AROS_PORTSSRCDIR)
2827 # Compatability with other Amiga-like operation systems
2828 AC_SUBST(aros_amigaos_compliance)
2830 # Host related
2831 AC_SUBST(aros_cc_pre)
2832 AC_SUBST(aros_host_strip)
2833 AC_SUBST(aros_host_arch)
2834 AC_SUBST(aros_host_cpu)
2835 AC_SUBST(aros_host_cpp)
2836 AC_SUBST(aros_host_def_cc)
2837 AC_SUBST(aros_host_cc)
2838 AC_SUBST(aros_host_cxx)
2839 AC_SUBST(aros_host_ar)
2840 AC_SUBST(aros_host_ranlib)
2841 AC_SUBST(aros_host_ld)
2842 AC_SUBST(aros_host_make)
2843 AC_SUBST(aros_host_cflags)
2844 AC_SUBST(aros_host_cxxflags)
2845 AC_SUBST(gnu89_inline)
2846 AC_SUBST(aros_host_ldflags)
2847 AC_SUBST(aros_host_debug)
2848 AC_SUBST(aros_host_mkdep)
2849 AC_SUBST(aros_host_mkargs)
2850 AC_SUBST(aros_host_exe_suffix)
2851 AC_SUBST(aros_host_lib_suffix)
2852 AC_SUBST(aros_tools_dir)
2853 AC_SUBST(aros_host_aclocal)
2854 AC_SUBST(aros_host_autoconf)
2855 AC_SUBST(aros_host_autoheader)
2856 AC_SUBST(aros_host_automake)
2857 AC_SUBST(ant)
2859 # Target Related
2860 AC_SUBST(aros_target_guitheme)
2861 AC_SUBST(aros_target_iconset)
2862 AC_SUBST(aros_target_bootloader)
2863 AC_SUBST(aros_target_arch)
2864 AC_SUBST(aros_target_family)
2865 AC_SUBST(aros_target_cpu)
2866 AC_SUBST(aros_target_cpu_mode)
2867 AC_SUBST(aros_target_variant)
2868 AC_SUBST(aros_target_suffix)
2869 AC_SUBST(aros_target_ar)
2870 AC_SUBST(aros_target_ranlib)
2871 AC_SUBST(aros_plain_nm)
2872 AC_SUBST(aros_plain_ar)
2873 AC_SUBST(aros_kernel_ar)
2874 AC_SUBST(aros_kernel_ranlib)
2875 AC_SUBST(orig_target_cc)
2876 AC_SUBST(aros_target_cc)
2877 AC_SUBST(aros_kernel_cc)
2878 AC_SUBST(orig_target_cxx)
2879 AC_SUBST(aros_target_cxx)
2880 AC_SUBST(aros_kernel_cxx)
2881 AC_SUBST(orig_target_cpp)
2882 AC_SUBST(aros_target_cpp)
2883 AC_SUBST(aros_kernel_cpp)
2884 AC_SUBST(orig_target_as)
2885 AC_SUBST(aros_target_as)
2886 AC_SUBST(aros_kernel_as)
2887 AC_SUBST(orig_target_ld)
2888 AC_SUBST(aros_target_ld)
2889 AC_SUBST(aros_kernel_ld)
2890 AC_SUBST(aros_target_cc_includes)
2891 AC_SUBST(aros_target_cc_path)
2892 AC_SUBST(aros_target_objdump)
2893 AC_SUBST(aros_target_objcopy)
2894 AC_SUBST(aros_target_strip)
2895 AC_SUBST(aros_target_nm)
2896 AC_SUBST(aros_kernel_rescomp)
2897 AC_SUBST(aros_shared_default)
2898 AC_SUBST(aros_shared_ld)
2899 AC_SUBST(aros_object_format)
2900 AC_SUBST(spec_obj_format)
2901 AC_SUBST(aros_compiler_libs)
2902 AC_SUBST(aros_arch_libs)
2904 AC_SUBST(aros_shared_cflags)
2905 AC_SUBST(aros_shared_aflags)
2906 AC_SUBST(aros_shared_ldflags)
2908 AC_SUBST(aros_config_sysroot)
2909 AC_SUBST(aros_warn_flags)
2910 AC_SUBST(aros_nowarn_flags)
2911 AC_SUBST(aros_config_cflags)
2912 AC_SUBST(aros_config_cxxflags)
2913 AC_SUBST(aros_config_aflags)
2914 AC_SUBST(aros_config_ldflags)
2916 AC_SUBST(aros_kernel_sysroot)
2917 AC_SUBST(aros_kernel_cflags)
2918 AC_SUBST(aros_kernel_includes)
2919 AC_SUBST(aros_kernel_objcflags)
2920 AC_SUBST(aros_kernel_ldflags)
2921 AC_SUBST(aros_target_cflags)
2922 AC_SUBST(aros_debug_cflags)
2923 AC_SUBST(aros_debug_aflags)
2924 AC_SUBST(aros_debug_ldflags)
2925 AC_SUBST(aros_target_genmap)
2926 AC_SUBST(aros_target_strip_flags)
2927 AC_SUBST(aros_config_lto)
2928 AC_SUBST(aros_optimization_cflags)
2929 AC_SUBST(aros_isa_flags)
2931 AC_SUBST(crosstools_target)
2932 AC_SUBST(crosstools_cxx_target)
2934 # Hosted Graphics Related
2935 AC_SUBST(host_x_gfx)
2936 AC_SUBST(host_sdl_gfx)
2937 AC_SUBST(host_android_gfx)
2939 AC_SUBST(pci_hidd_target)
2941 AC_SUBST(aros_nominal_width)
2942 AC_SUBST(aros_nominal_height)
2943 AC_SUBST(aros_nominal_depth)
2944 AC_SUBST(DO_XSHM_SUPPORT)
2945 AC_SUBST(DO_VIDMODE_SUPPORT)
2947 AC_SUBST(aros_host_x11_cflags)
2948 AC_SUBST(aros_host_x11_ldflags)
2949 AC_SUBST(aros_host_sdl_cflags)
2950 AC_SUBST(aros_host_sdl_libs)
2952 # Native version related
2953 AC_SUBST(aros_serial_debug)
2954 AC_SUBST(PLATFORM_EXECSMP)
2955 AC_SUBST(ENABLE_EXECSMP)
2957 # Palm native version related
2958 AC_SUBST(aros_palm_debug_hack)
2960 # Unix/Hosted version related
2961 AC_SUBST(aros_nesting_supervisor)
2963 # MMU related
2964 AC_SUBST(aros_enable_mmu)
2966 # Apple iOS related
2967 AC_SUBST(aros_ios_platform)
2968 AC_SUBST(aros_ios_version)
2969 AC_SUBST(aros_ios_sdk)
2971 # ARM default GCC target related
2972 AC_SUBST(gcc_default_cpu)
2973 AC_SUBST(gcc_default_cpu_tune)
2974 AC_SUBST(gcc_default_fpu)
2975 AC_SUBST(gcc_default_float_abi)
2976 AC_SUBST(gcc_default_mode)
2978 # Android related
2979 AC_SUBST(android_tool)
2980 AC_SUBST(aros_android_level)
2981 AC_SUBST(aros_android_antapk)
2983 # DBUS related
2984 AC_SUBST(ENABLE_DBUS)
2985 AC_SUBST(DBUS_CFLAGS)
2986 AC_SUBST(DBUS_LIBFLAGS)
2987 AC_SUBST(KERNEL_DBUS_KOBJ)
2988 AC_SUBST(KERNEL_DBUS_INCLUDES)
2990 #X11 related
2991 AC_SUBST(ENABLE_X11)
2993 # Debug related
2994 AC_SUBST(aros_debug)
2995 AC_SUBST(aros_mungwall_debug)
2996 AC_SUBST(aros_stack_debug)
2997 AC_SUBST(aros_modules_debug)
2999 # Collect-aros stuff: "-ius" to ignore undefined symbols
3000 AC_SUBST(ignore_undefined_symbols)
3002 # C compiler related
3003 AC_SUBST(gcc_target_cpu)
3004 AC_SUBST(target_binutils_version)
3005 AC_SUBST(target_gcc_version)
3007 #ObjC compiler related
3008 AC_SUBST(objc_target)
3010 #Java related
3011 AC_SUBST(java_target)
3013 # USB3.0 code
3014 AC_SUBST(aros_usb30_code)
3016 dnl Prepare for output, make up all the generated patches
3017 case "$aros_flavour" in
3018 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3019                 aros_flavour="emulation" ;;
3020 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3021                 aros_flavour="emulation" ;;
3022 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3023                 aros_flavour="standalone";;
3024 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3025                 aros_flavour="standalone";;
3026 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3027                 aros_flavour="native" ;;
3028 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3029                 aros_flavour="native" ;;
3030 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3031                 aros_flavour="linklib" ;;
3032 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3033                 aros_flavour="palmnative" ;;
3034 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3035                 aros_flavour="mac68knative" ;;
3036 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3037                 aros_flavour="ppcnative" ;;
3038 esac
3040 if test ! -d ${aros_inc_dir} ; then
3041     ${MKDIR} ${aros_inc_dir}
3043 if test ! -d ${aros_geninc_dir} ; then
3044     ${MKDIR} ${aros_geninc_dir}
3046 if test ! -d ${aros_hostcfg_dir} ; then
3047     ${MKDIR} ${aros_hostcfg_dir}
3049 if test ! -d ${aros_targetcfg_dir} ; then
3050     ${MKDIR} ${aros_targetcfg_dir}
3052 if test ! -d ${aros_tools_dir} ; then
3053     ${MKDIR} ${aros_tools_dir}
3055 if test ! -d ${aros_scripts_dir} ; then
3056     ${MKDIR} ${aros_scripts_dir}
3059 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3061 # Generic build tools (metamake, etc)
3062 AC_CONFIG_COMMANDS([genmf-executable-support],
3063     [chmod a+x ${aros_tools_dir}/genmf.py],
3064     [aros_tools_dir=${aros_tools_dir}]
3066 AC_CONFIG_FILES(
3067     Makefile
3068     config/make.cfg
3069     ${aros_inc_dir}/config.h:config/config.h.in
3070     ${aros_geninc_dir}/config.h:config/config.h.in
3071     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3072     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3073     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3074     mmake.config
3075     compiler/include/mmakefile:compiler/include/mmakefile.in
3076     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3077     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3078     tools/collect-aros/env.h
3081 # Binutils
3082 AC_CONFIG_COMMANDS([binutils-support],
3083     [
3084         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3085         mkdir -p $prefix
3086         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3088         chmod a+x ${prefix2}-ld
3090         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3091         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3092         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3093         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3094         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3095         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3096         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3097     ],
3098     [
3099         aros_host_exe_suffix=${aros_host_exe_suffix}
3100         aros_tools_dir=${aros_tools_dir}
3101         aros_target_cpu=${aros_target_cpu}
3102         aros_target_arch=${aros_target_arch}
3103         aros_target_suffix=${aros_target_suffix}
3104         orig_target_nm=${orig_target_nm}
3105         orig_target_as=${orig_target_as}
3106         orig_target_ar=${orig_target_ar}
3107         orig_target_ranlib=${orig_target_ranlib}
3108         orig_target_objdump=${orig_target_objdump}
3109         orig_target_objcopy=${orig_target_objcopy}
3110         orig_target_strip=${orig_target_strip}
3111         aros_kernel_ld=${aros_kernel_ld}
3112     ]
3114 if test "${use_ld_wrapper}" = "yes"; then
3115     AC_CONFIG_FILES(
3116         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3117     )
3119 # Bare Elf support script and spec
3120 if test "${use_kernel_cc_wrapper}" = "yes"; then
3121     AC_CONFIG_COMMANDS([elf-compiler-support],
3122         [
3123             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3124             mkdir -p $prefix
3125             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3127             chmod a+x ${prefix2}-gcc
3129             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3130         ],
3131         [
3132             aros_host_exe_suffix=${aros_host_exe_suffix}
3133             aros_tools_dir=${aros_tools_dir}
3134             aros_target_cpu=${aros_target_cpu}
3135             aros_target_arch=${aros_target_arch}
3136             aros_target_suffix=${aros_target_suffix}
3137             aros_kernel_ld=${aros_kernel_ld}
3138         ]
3139     )
3140     AC_CONFIG_FILES(
3141         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3142         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3143     )
3146 # Host compiler support scripts and spec
3147 if test "${aros_target_toolchain}" = "no"; then
3148     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3149         [
3150             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3151             mkdir -p $prefix
3152             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3154             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3155         ],
3156         [
3157             aros_host_exe_suffix=${aros_host_exe_suffix}
3158             aros_tools_dir=${aros_tools_dir}
3159             aros_target_cpu=${aros_target_cpu}
3160             aros_target_arch=${aros_target_arch}
3161             aros_target_suffix=${aros_target_suffix}
3162         ]
3163     )
3164     AC_CONFIG_FILES(
3165         ${aros_targetcfg_dir}/specs:config/specs.in
3166         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3167         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3168         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3169     )
3172 # Android support
3173 if test "$aros_target_variant" == "android"; then
3174     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3177 # cmake helper
3178 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3180 AC_OUTPUT
3182 dnl This is in order to not define SHARED_CFLAGS sometimes
3183 dnl We don't always do aros_shared_ar, aros_shared_cflags
3185 #XXX compatability...
3186 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3188 if test -n "$aros_shared_cflags" ; then
3189     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3190     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg