check if the compiler lets us disable the builtin floor
[AROS.git] / configure.in
blob9bc0db592af6b79656c7677f821de5a6cf4ecf88
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_config_cflags="-Wall -Werror-implicit-function-declaration"
649 aros_config_aflags="-Wall -x assembler-with-cpp -c"
650 aros_config_ldflags=""
652 aros_shared_default=yes
654 aros_shared_cflags="-fPIC"
655 aros_shared_aflags=""
656 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
657 aros_kernel_ldflags="-Wl,-rpath,./lib"
659 aros_kernel_ar_flags="cr"
660 aros_target_ar_flags="cr"
661 aros_target_nm_flags="-C -ul"
662 aros_target_strip_flags="--strip-unneeded -R.comment"
664 aros_compiler_libs=
665 aros_arch_libs=
667 aros_target_genmap="-Wl,-Map -Xlinker"
669 # Native flavour stuff
670 aros_serial_debug="0"
672 # Palm native flavour stuff
673 aros_palm_debug_hack="0"
675 # Unix flavour stuff
676 aros_nesting_supervisor="0"
678 # Collect-aros stuff: "-ius" to ignore undefined symbols
679 ignore_undefined_symbols=""
681 # Check for X11 by default
682 need_x11="auto"
684 host_x_gfx=no
685 host_sdl_gfx=no
686 host_android_gfx=no
689 AC_MSG_CHECKING([Which toolchain family to use ...])
690 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")
691 AC_MSG_RESULT($aros_toolchain)
694 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
695 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
696  aros_config_lto="$enableval",aros_config_lto="no")
697 if test "$aros_config_lto" != "no"; then
698     aros_config_lto="yes"
700 AC_MSG_RESULT($aros_config_lto)
702 use_ld_wrapper=yes
704 case "$aros_toolchain" in
705     *llvm*)
706         # toolchain_needs_sysroot=yes
707         toolchain_c_compiler="clang"
708         toolchain_cxx_compiler="clang++"
709         toolchain_cpp_preprocessor="clang -E"
710         toolchain_ld="ld.lld"
711         aros_ld="ld"
712         toolchain_as="llvm-as"
713         toolchain_ar="llvm-ar"
714         toolchain_ranlib="llvm-ranlib"
715         toolchain_nm="llvm-nm"
716         toolchain_strip="true"
717         toolchain_objcopy="llvm-objcopy"
718         toolchain_objdump="llvm-objdump"
719         ;;
720     *gnu*)
721         toolchain_c_compiler="gcc"
722         toolchain_cxx_compiler="g++"
723         toolchain_cpp_preprocessor="gcc -E"
724         toolchain_as="as"
725         aros_ld="ld"
726         if test "$aros_config_lto" != "yes"; then
727             toolchain_ld="ld"
728             toolchain_ar="ar"
729             toolchain_ranlib="ranlib"
730             toolchain_nm="nm"
731         else
732             toolchain_ld="ld.bfd"
733             toolchain_ar="gcc-ar"
734             toolchain_ranlib="gcc-ranlib"
735             toolchain_nm="gcc-nm"
736         fi
737         toolchain_strip="strip"
738         toolchain_objcopy="objcopy"
739         toolchain_objdump="objdump"
740         ;;
741     *)
742         AC_MSG_WARN("Unknown toolchain family!")
743         toolchain_c_compiler="cc"
744         toolchain_cxx_compiler="c++"
745         toolchain_cpp_preprocessor="cpp"
746         toolchain_ld="ld"
747         aros_ld="ld"
748         toolchain_as="as"
749         toolchain_ar="ar"
750         toolchain_ranlib="ranlib"
751         toolchain_nm="nm"
752         toolchain_strip="strip"
753         toolchain_objcopy="objcopy"
754         toolchain_objdump="objdump"
755         ;;
756 esac
758 #-----------------------------------------------------------------------------
760 AC_MSG_CHECKING([which type of build to do])
761 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")
763 if test "$build_type" = "nightly"; then
764     build_type_string="NIGHTLY"
765 elif test "$build_type" = "snapshot"; then
766     build_type_string="SNAPSHOT"
767 elif test "$build_type" = "milestone"; then
768     build_type_string="MILESTONE"
769 elif test "$build_type" = "release"; then
770     build_type_string="RELEASE"
771 else
772     build_type_string="PERSONAL"
773     build_type="personal"
776 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
778 AC_MSG_RESULT($build_type)
780 #-----------------------------------------------------------------------------
781 all_debug_types="messages stack modules mungwall symbols"
783 AC_MSG_CHECKING([which debug types to enable])
784 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)]),
785  debug="$enableval",debug="")
787 if test "$debug" = "" -o "$debug" = "no"; then
788     debug="none"
789 elif test "$debug" = "yes"; then
790     debug="all"
793 if test "$debug" = "all" ; then
794     debug="messages stack modules symbols"
795     for d in $all_debug_types; do
796         export aros_${d}_debug="1"
797     done
798 else
799     for d in $all_debug_types; do
800         export aros_${d}_debug="0"
801     done
804 if test "$debug" != "none"; then
805     debug=`echo $debug | sed s/,/\ /g`
806     for d in $debug; do
807         found="0"
808         for d2 in $all_debug_types; do
809             if test "$d2" = "$d"; then
810                 found="1"
811                 break
812             fi
813         done
814         if test "$found" = "0"; then
815             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
816         fi
817         export aros_${d}_debug="1"
818     done
819     aros_debug="yes"
821 AC_MSG_RESULT($debug)
823 if test "$aros_messages_debug" = "1"; then
824     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
825 else
826     aros_messages_debug=""
828 if test "$aros_symbols_debug" = "1"; then
829     aros_symbols_debug="-g"
830 else
831     aros_symbols_debug=""
834 # These are the flags to pass when compiling debugged programs
835 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
836 aros_debug_aflags=""
837 aros_debug_ldflags="$aros_symbols_debug"
839 #-----------------------------------------------------------------------------
840 #   Checking for distcc and ccache.
842 #   Always apply the transforms in this particular order. Basically you should
843 #   always run 'ccache distcc compiler' in that order for the best performance.
845 AC_MSG_CHECKING([whether to enable distcc])
846 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
847 if test "$distcc" != "" -a "$distcc" != "no"; then
848     # AC_CHECK_PROG will print out the result in this case
849     AC_PATH_PROG(DISTCC,[distcc],distcc,)
850 else
851     AC_MSG_RESULT(no)
854 AC_MSG_CHECKING([whether to enable ccache])
855 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
856 if test "$ccache" != "" -a "$ccache" != "no"; then
857     # AC_CHECK_PROG will print out the result in this case
858     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
859 else
860     AC_MSG_RESULT(no)
863 #-----------------------------------------------------------------------------
864 AC_MSG_CHECKING([what specific host gcc version to use])
865 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="")
866 if test "$kernel_tool_version" != "" ; then
867     msg_result=$kernel_tool_version
868 else
869     msg_result="default"
871 AC_MSG_RESULT($msg_result)
873 #-----------------------------------------------------------------------------
874 AC_MSG_CHECKING([what optimization flags to use])
875 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
876 if test "$optimization" = "unknown"; then
877     dnl default is -O2 for normal builds, -O0 for debug builds
878     if test "$debug" != "none"; then
879         optimization="-O0"
880     else
881         optimization="-O2"
882     fi
884 aros_optimization_cflags="$optimization"
885 AC_MSG_RESULT($optimization)
887 paranoia_default=yes
888 #-----------------------------------------------------------------------------
889 AC_MSG_CHECKING([which paranoia flags to use])
890 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"])
891 if test "$paranoia_flags" = "no"; then
892         paranoia_flags=""
893         msg_result="none"
894 else
895     if test "$paranoia_flags" = "yes"; then
896         paranoia_flags="-Wall -Werror"
897     fi
898     msg_result="$paranoia_flags"
900 AC_MSG_RESULT($msg_result)
901 aros_config_cflags="$aros_config_cflags $paranoia_flags"
903 #-----------------------------------------------------------------------------
904 AC_MSG_CHECKING([what target variant to enable])
905 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
906 if test "$target_variant" = ""; then
907     aros_target_variant=""
908     aros_target_suffix=""
909     enableval="none"
910 else
911     aros_target_variant="$target_variant"
912     aros_target_suffix="-$target_variant"
914 AC_MSG_RESULT($enableval)
916 #-----------------------------------------------------------------------------
917 # Target-specific defaults. You can override then on a per-target basis.
919 # Bootloader name. Currently used by PC target.
920 target_bootloader="none"
921 PLATFORM_EXECSMP=
922 ENABLE_EXECSMP=
924 #-----------------------------------------------------------------------------
925 # Additional options for some specific targets
927 case "$aros_target_variant" in
928 ios)
929     AC_MSG_CHECKING([XCode path])
930     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")
931     AC_MSG_RESULT($aros_xcode_path)
933     AC_MSG_CHECKING([what iOS SDK version to use])
934     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")
935     AC_MSG_RESULT($aros_sdk_version)
937     ;;
939 "android")
940     AC_MSG_CHECKING([Android SDK path])
941     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)
942     AC_MSG_RESULT($aros_android_sdk)
944     AC_MSG_CHECKING([Android NDK path])
945     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
946     AC_MSG_RESULT($aros_android_ndk)
948     AC_MSG_CHECKING([what Android SDK version to use])
949     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")
950     AC_MSG_RESULT($aros_sdk_version)
952     aros_android_level=android-$aros_sdk_version
953     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
954         echo "Platform $aros_android_level is not installed in your SDK"
955         echo "Use --with-sdk-version=<API level number> to select another platform version"
956         echo "You can check what plaform versions are installed in your SDK"
957         echo "by examining contents of $aros_android_sdk/platforms directory"
958         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
959     fi
961     export PATH="$aros_android_sdk/tools:$PATH"
962     AC_PATH_PROG(android_tool, $android_tool)
963     AROS_REQUIRED(android,$android_tool)
965     if test "$aros_android_ndk" != "none"; then
966         AC_MSG_CHECKING([what Android NDK version to use])
967         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")
968         AC_MSG_RESULT($aros_ndk_version)
969     fi
971     AC_PATH_PROG(ant, ant)
972     if test "$ant" = ""; then
973         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
974     fi
976     AC_MSG_CHECKING([Build debug or release apk])
977     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)
978     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
979         AC_MSG_ERROR([apk-version has to be release or debug])
980     fi
981     AC_MSG_RESULT($aros_android_antapk)
983     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
984     if test "$host_os" = "mingw32"; then
985         android_tool="cmd //c $android_tool"
986     fi
988     need_dlopen="no"
990     ;;
991 esac
993 #-----------------------------------------------------------------------------
994 # External toolchains
995 kernel_tool_prefix="none"
996 aros_tool_prefix="none"
997 elf_tool_prefix="${target_cpu}-elf-"
999 # This is the target configuration switch.
1000 case "$target_os" in
1001     linux*)
1002         aros_target_arch="linux"
1003         aros_target_family="unix"
1004         case "$target_cpu" in
1005             *m68k*)
1006                 aros_target_cpu="m68k"
1007                 aros_object_format="m68kelf"
1008                 aros_flavour="emulcompat"
1009                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1010                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1011                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1012                 gcc_target_cpu="mc68000"
1013                 ;;
1014             *i?86*)
1015                 aros_target_cpu="i386"
1016                 aros_object_format="elf_i386"
1017                 aros_flavour="emulation"
1018                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1019                 aros_kernel_ldflags="-Wl,-melf_i386"
1020                 aros_nominal_depth=8
1021                 gcc_target_cpu="i386"
1022                 pci_hidd_target="hidd-pci-linux"
1023                 android_tool_dir_prefix="x86"
1024                 android_tool_prefix="i686-android-linux"
1025                 android_ndk_arch="x86"
1026                 ;;
1027             *x86_64*)
1028                 aros_target_cpu="x86_64"
1029                 aros_object_format="elf_x86_64"
1030                 aros_flavour="emulation"
1031                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1032                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
1033                 aros_nominal_depth=8
1034                 pci_hidd_target="hidd-pci-linux"
1035                 ;;
1036             *powerpc*)
1037                 aros_target_cpu="ppc"
1038                 aros_object_format="elf32ppc"
1039                 aros_flavour="emulation"
1040                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1041                 aros_nominal_depth=8
1042                 gcc_target_cpu="ppc"
1043                 ;;
1044 # TODO
1045 # Same as powerpc, but I need this for the nightly build to work again.
1046 # Actually, the nightly should be made working with powerpc target.
1047 # That just was too much work for the moment, another week or two.
1048             *ppc*)
1049                 aros_target_cpu="ppc"
1050                 aros_object_format="elf32ppc"
1051                 aros_flavour="emulation"
1052                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1053                 aros_nominal_depth=8
1054                 gcc_target_cpu="ppc"
1055                 ;;
1056             *aarch64*)
1057                 aros_target_cpu="aarch64"
1058                 target_cpu="aarch64"
1059                 aros_object_format="aarch64elf_aros"
1060                 aros_flavour="emulation"
1061                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1062                 gcc_target_cpu="aarch64"
1063                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1064                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1065                 aros_arch_libs="-laeabi"
1066                 gcc_default_float_abi="hard"
1067                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1068                 ;;
1069             *armhf*)
1070                 aros_target_cpu="arm"
1071                 target_cpu="arm"
1072                 aros_object_format="armelf_aros"
1073                 aros_flavour="emulation"
1074                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1075                 gcc_target_cpu="arm"
1076                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1077                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1078                 aros_arch_libs="-laeabi"
1079                 gcc_default_float_abi="hard"
1080                 android_tool_dir_prefix="arm-linux-androideabi"
1081                 android_tool_prefix="arm-linux-androideabi"
1082                 android_ndk_arch="arm"
1083                 kernel_tool_prefix="arm-linux-gnueabihf-"
1084                 ;;
1085             *arm*)
1086                 aros_target_cpu="arm"
1087                 aros_object_format="armelf_aros"
1088                 aros_flavour="emulation"
1089                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1090                 gcc_target_cpu="arm"
1091                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
1092                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
1093                 aros_arch_libs="-laeabi"
1094                 android_tool_dir_prefix="arm-linux-androideabi"
1095                 android_tool_prefix="arm-linux-androideabi"
1096                 android_ndk_arch="arm"
1097                 kernel_tool_prefix="arm-linux-gnueabi-"
1098                 ;;
1099             *)
1100                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1101                 ;;
1102         esac
1103         case "$aros_target_variant" in
1104             android)
1106                 dnl Not all Linux CPUs are supported by Android
1107                 if test "$android_ndk_arch" = ""; then
1108                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1109                 fi
1111                 aros_nominal_width=320
1112                 aros_nominal_height=480
1113                 if test "$aros_android_ndk" = "none"; then
1114                     dnl Use standalone toolchain, don't adjust paths
1115                     aros_kernel_cflags="-mandroid"
1116                     aros_kernel_ldflags="-mandroid"
1117                     CFLAGS="-mandroid"
1118                 else
1119                     dnl In Android NDK toolchains are placed in own directories,
1120                     dnl but tool names are not suffixed with version 
1121                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1122                     kernel_tool_version=""
1123                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1124                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1125                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1126                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1127                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1128                 fi
1129                 need_x11=no
1130                 host_android_gfx=yes
1131                 # Disable implicit PIC mode
1132                 aros_target_cflags="$aros_target_cflags -fno-pic"
1133                 kernel_tool_prefix="$android_tool_prefix-"
1134             ;;
1135         esac
1136     ;;
1138     pc)
1139         aros_target_arch="pc"
1140         aros_shared_default="no"
1141         target_bootloader="grub2"
1142         case "$target_cpu" in
1143             *i?86*)
1144                 aros_target_cpu="i386"
1146                 dnl If somebody hasn't already set the target object
1147                 dnl format, then use this value. Mostly to support
1148                 dnl FreeBSD cross-compilation.
1149                 dnl TODO: Remove when we always use our compiler.
1151                 if test "$aros_object_format" = "" ; then
1152                     aros_object_format="elf_i386"
1153                 fi
1154                 aros_flavour="standalone"
1155                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1156                 aros_kernel_ldflags="-Wl,-melf_i386"
1157                 aros_nominal_width=640
1158                 aros_nominal_height=480
1159                 gcc_target_cpu="i386"
1160                 ;;
1161             *x86_64*)
1162                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1163                 aros_target_cpu="x86_64"
1164                 aros_serial_debug=1
1165                 if test "$aros_object_format" = "" ; then
1166                     aros_object_format="elf_x86_64"
1167                 fi
1168                 aros_flavour="standalone"
1169                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1170                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1171                 aros_kernel_ldflags=""
1172                 aros_nominal_width=640
1173                 aros_nominal_height=480
1174                 case "$aros_target_variant" in
1175                     smp)
1176                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1177                     ;;
1178                 esac
1179                 ;;
1180             *)
1181                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1182                 ;;
1183         esac
1184         ;;
1186     prep)
1187         aros_target_arch="prep"
1188         aros_shared_default="no"
1189         aros_target_cpu="ppc"
1190         aros_object_format="elf32ppc"
1191         aros_flavour="ppcnative"
1192         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1193         aros_kernel_ldflags=""
1194         aros_nominal_width=640
1195         aros_nominal_height=480
1196         gcc_target_cpu="ppc"
1197         ;;
1199     freebsd*)
1200         aros_target_arch="freebsd"
1201         aros_target_family="unix"
1202         aros_target_cpu="i386"
1203         aros_flavour="emulation"
1204         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1205         gcc_target_cpu="i386"
1207         aros_target_strip_flags="-x"
1208         ;;
1210     darwin*)
1211         aros_target_arch="darwin"
1212         aros_target_family="unix"
1213         aros_flavour="emulation"
1214         case "$target_cpu" in
1215             *i?86*)
1216                 aros_ios_platform="iPhoneSimulator"
1217                 aros_target_cpu="i386"
1218                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1219                 aros_kernel_ldflags=""
1220                 aros_macosx_version="10.4"
1221                 aros_nominal_depth=8
1222                 gcc_target_cpu="i386"
1223                 aros_object_format="elf_i386"
1224                 aros_kernel_ar_flags="-cr"
1225                 aros_target_strip_flags="-x"
1226                 kernel_tool_flags="-m32"
1227                 ;;
1228             *x86_64*)
1229                 aros_target_cpu="x86_64"
1230                 aros_object_format="elf_x86_64"
1231                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1232                 aros_macosx_version="10.6"
1233                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1234                 aros_kernel_cflags="-m64"
1235                 aros_kernel_ldflags="-m64"
1236                 aros_target_cflags="-mcmodel=large"
1237                 aros_nominal_depth=8
1238                 aros_kernel_ar="ar"
1239                 aros_kernel_ar_flags="-cr"
1240                 aros_kernel_ld="ld"
1241                 aros_kernel_as="as"
1242                 aros_kernel_ranlib="ranlib"
1243                 aros_kernel_nm="nm"
1244                 aros_kernel_strip="strip"
1245                 kernel_tool_prefix="i686-apple-darwin10-"
1246                 ;;
1247             *ppc*)
1248                 aros_target_cpu="ppc"
1249                 aros_object_format="elf32ppc"
1250                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1251                 aros_kernel_ldflags=""
1252                 aros_macosx_version="10.0"
1253                 aros_nominal_depth=8
1254                 gcc_target_cpu="ppc"
1255                 aros_kernel_ar="ar"
1256                 aros_kernel_ar_flags="-cr"
1257                 aros_kernel_ld="ld -arch ppc"
1258                 aros_kernel_as="as -arch ppc"
1259                 aros_kernel_ranlib="ranlib -arch ppc"
1260                 aros_kernel_nm="nm -arch ppc"
1261                 aros_kernel_strip="strip -arch ppc"
1262                 kernel_tool_prefix="powerpc-apple-darwin10-"
1263                 ;;
1264             *arm*)
1265                 aros_ios_platform="iPhoneOS"
1266                 aros_target_cpu="arm"
1267                 aros_object_format="armelf_aros"
1268                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1269                 aros_arch_libs="-laeabi"
1270                 aros_nominal_depth=8
1271                 gcc_target_cpu="arm"
1272                 aros_kernel_ar="ar"
1273                 aros_kernel_ar_flags="-cr"
1274                 aros_kernel_ld="ld -arch arm"
1275                 aros_kernel_ranlib="ranlib -arch arm"
1276                 kernel_tool_prefix="arm-apple-darwin10-" 
1277                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1278                 ;;
1279             *)
1280                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1281                 ;;
1282         esac
1283         case "$aros_target_variant" in
1284             ios)
1285                 aros_ios_version="3.0"
1286                 aros_nominal_width=320
1287                 aros_nominal_height=480
1288                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1289                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1290                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1291                 need_x11=no
1292                 # This is here because it may depend on iOS or SDK version
1293                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1294                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1295                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1296             ;;
1297             *)
1298                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1299                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1300             ;;
1301         esac
1302         ;;
1304     dragonfly*)
1305         aros_target_arch="dragonfly"
1306         aros_target_family="unix"
1307         aros_flavour="emulation"
1308         case "$target_cpu" in
1309             *i?86*)
1310                 aros_target_cpu="i386"
1311                 aros_object_format="elf_i386"
1312                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1313                 ;;
1314             *x86_64*)
1315                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1316                 aros_target_cpu="x86_64"
1317                 aros_object_format="elf_x86_64"
1318                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1319                 ;;
1320             *)
1321                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1322                 ;;
1323         esac
1324         ;;
1326     netbsd*)
1327         aros_target_arch="netbsd"
1328         aros_target_family="unix"
1329         case "$target_cpu" in
1330             *m68k*)
1331                 aros_target_cpu="m68k"
1332                 aros_object_format="m68kelf"
1333                 aros_flavour="emulcompat"
1334                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1335                 gcc_target_cpu="mc68000"
1336                 ;;
1337             *i?86*)
1338                 aros_target_cpu="i386"
1339                 aros_object_format="elf_i386"
1340                 aros_flavour="emulation"
1341                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1342                 aros_nominal_depth=8
1343                 gcc_target_cpu="i386"
1344                 ;;
1345             *)
1346                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1347                 ;;
1348         esac
1349         aros_target_genmap="-Wl,-M -Xlinker >"
1350         aros_flavour="emulation"
1351         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1352         ;;   
1354     openbsd*)
1355         aros_target_arch="openbsd"
1356         aros_target_family="unix"
1357         case "$target_cpu" in
1358             *i?86*)
1359                 aros_target_cpu="i386"
1360                 aros_object_format="elf_i386"
1361                 aros_flavour="emulation"
1362                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1363                 gcc_target_cpu="i386"
1364                 ;;
1365             *)
1366                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1367                 ;;
1368         esac
1369         aros_target_genmap="-Wl,-M -Xlinker >"
1370         aros_target_nm_flags="-u"
1371         aros_flavour="emulation"
1372         ;;
1374     solaris*)
1375         aros_target_arch="solaris"
1376         aros_target_family="unix"
1377         case "$target_cpu" in
1378            *i?86*)
1379                aros_target_cpu="i386"
1380                aros_object_format="elf_i386"
1381                aros_flavour="emulation"
1382                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1383                aros_nominal_depth=8
1384                gcc_target_cpu="i386"
1385                ;;
1386             *sparc*)
1387                 aros_target_cpu="sparc"
1388                 aros_object_format="elf_sparc"
1389                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1390                 gcc_target_cpu="sparc"
1391                 ;;
1392             *)
1393                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1394                 ;;
1395         esac
1396         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1397         aros_flavour="emulation"
1398         ;;
1400     morphos*)
1401         aros_target_arch="morphos"
1402         aros_shared_default="no"
1403         aros_target_cpu="ppc"
1404         aros_object_format="elf_ppc"
1405         aros_flavour="nativecompat"
1406         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1407         gcc_target_cpu="ppc"
1408         ;;
1410     sam440)
1411         aros_target_arch="sam440"
1412         aros_shared_default="no"
1413         aros_target_cpu="ppc"
1414         aros_object_format="elf32ppc"
1415         aros_flavour="ppcnative"
1416         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1417         aros_kernel_ldflags=""
1418         aros_nominal_width=1024
1419         aros_nominal_height=768
1420         aros_nominal_depth=24
1421         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1422         gcc_target_cpu="powerpc"
1423         ;;
1425     efika)
1426         aros_target_arch="efika"
1427         aros_shared_default="no"
1428         aros_target_cpu="arm"
1429         aros_object_format="armelf_aros"
1430         aros_flavour="standalone"
1431         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1432         aros_kernel_ldflags=""
1433         aros_nominal_width=1024
1434         aros_nominal_height=600
1435         aros_arch_libs="-laeabi"
1436         gcc_default_cpu="armv7-a"
1437         gcc_default_fpu="vfpv3"
1438         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1439         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1440         aros_optimization_cflags="$aros_optimization_cflags -Os"
1441         case "$target_cpu" in
1442             *armhf*)
1443                 gcc_default_float_abi="hard"
1444                 target_cpu=arm
1445                 aros_target_cpu=arm
1446                 ;;
1447             *arm*)
1448                 gcc_default_float_abi="softfp"
1449                 ;;
1450             *)
1451                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1452                 ;;
1453         esac
1454         ;;
1455         
1456     chrp)
1457         aros_target_arch="chrp"
1458         aros_shared_default="no"
1459         aros_target_cpu="ppc"
1460         aros_object_format="elf32ppc"
1461         aros_flavour="ppcnative"
1462         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1463         aros_kernel_ldflags=""
1464         aros_nominal_width=640
1465         aros_nominal_height=480
1466         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1467         gcc_target_cpu="powerpc"
1468         case "$aros_target_variant" in
1469             efika)
1470                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1471             ;;
1472         esac
1473         ;;
1475     r*pi)
1476         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1477         aros_flavour="standalone"
1478         aros_target_arch="raspi"
1480         aros_shared_default="no"
1482         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1483         
1484         case "$target_cpu" in
1485             *aarch64*)
1486                 aros_target_cpu="aarch64"
1487                 gcc_default_cpu="aarch64"
1488                 aros_object_format="aarch64elf_aros"
1489                 ;;
1490             *armhf*)
1491                 aros_target_cpu="arm"
1492                 gcc_default_cpu="armv6zk"
1493                 gcc_default_cpu_tune="arm1176jzf-s"
1494                 aros_object_format="armelf_aros"
1495                 aros_config_cflags="$aros_config_cflags -marm"
1496                 aros_config_aflags="$aros_config_aflags -marm"
1497                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1498                 aros_target_cflags="$aros_kernel_cflags -marm"
1499                 aros_target_mkdep="$aros_target_mkdep -Darm"
1500                 aros_arch_libs="-laeabi"
1501                 ;;
1502             *arm*)
1503                 aros_target_cpu="arm"
1504                 gcc_default_cpu="armv6zk"
1505                 gcc_default_cpu_tune="arm1176jzf-s"
1506                 aros_object_format="armelf_aros"
1507                 aros_config_cflags="$aros_config_cflags -marm"
1508                 aros_config_aflags="$aros_config_aflags -marm"
1509                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1510                 aros_target_cflags="$aros_kernel_cflags -marm"
1511                 aros_target_mkdep="$aros_target_mkdep -Darm"
1512                 aros_arch_libs="-laeabi"
1513                 ;;
1514             *)
1515                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1516                 ;;
1517         esac
1519         aros_config_cflags="$aros_config_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1520         aros_config_aflags="$aros_config_aflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1521         aros_kernel_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1522         aros_target_cflags="$aros_kernel_cflags -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1524         case "$aros_target_variant" in
1525             smp)
1526                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1527             ;;
1528         esac
1529         ;;
1531     stm32f7_discovery)
1532         aros_flavour="standalone"
1533         aros_target_arch="stm32f7_discovery"
1534         aros_target_cpu="arm"
1535         aros_target_cpu_mode="thumb2"
1536         aros_object_format="armelf_aros"
1537         aros_shared_default="no"
1539         # stm32f7 has DSP opcode support
1540         gcc_default_cpu="armv7e-m"
1541         # gcc_default_cpu="armv7-m"
1542         gcc_default_cpu_tune="cortex-m7"
1543         gcc_default_fpu="fpv4-sp-d16"
1544         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1545         # gcc_default_fpu="fpv5-sp-d16"
1546                 gcc_default_float_abi="hard"
1548         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1549         ;;
1551     amiga*)
1552         aros_target_arch="amiga"
1553         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1554         aros_shared_default="no"
1556         case "$target_cpu" in
1557             *m68k*)
1558                 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")
1559                 aros_enable_mmu=no
1560                 aros_target_cpu="m68k"
1561                 aros_object_format="m68kelf"
1562                 aros_flavour="standcompat"
1563                 gcc_target_cpu="m68000"
1564                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1565                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -DNOLIBINLINE"
1566                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1567                 aros_config_aflags="$aros_config_aflags"
1568                 aros_target_strip_flags="-R.comment --strip-debug"
1569                 aros_nominal_width=640
1570                 aros_nominal_height=256
1571                 aros_nominal_depth=2
1572                 ;;
1573             *ppc*)
1574                 aros_cpu="ppc"
1575                 aros_flavour="native"
1576                 gcc_target_cpu="ppc"
1577                 ;;
1578             *)
1579                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1580                 ;;
1581         esac
1582         ;;
1584     mingw*)
1585         aros_target_arch="mingw32"
1586         aros_shared_default="no"
1587         aros_flavour="emulation"
1588         aros_shared_cflags=""
1589         need_crosstools="yes"
1590         need_dlopen="no"
1591         rescomp="windres"
1592         case "$target_cpu" in
1593             *i?86*)
1594                 aros_target_cpu="i386"
1595                 aros_object_format="elf_i386"
1596                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1597                 aros_nominal_depth=8
1598                 gcc_target_cpu="i386"
1600                 kernel_tool_prefix="i386-mingw32-"
1601                 ;;
1602             *x86_64*)
1603                 aros_target_cpu="x86_64"
1604                 aros_object_format="elf_x86_64"
1605                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1606                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1607                 aros_nominal_depth=8
1608                 kernel_tool_prefix="x86_64-w64-mingw32-"
1609                 ;;
1610             *arm*)
1611                 aros_target_cpu="arm"
1612                 aros_object_format="armelf_aros"
1613                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1614                 aros_arch_libs="-laeabi"
1615                 aros_nominal_depth=8
1616                 gcc_target_cpu="arm"
1617                 gcc_default_float_abi="soft"
1618                 kernel_tool_prefix="arm-mingw32ce-"
1619                 aros_nominal_width=160
1620                 aros_nominal_height=160
1621                 ;;
1622             *)
1623                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1624                 ;;
1625         esac
1626         if test $host_os = "cygwin"; then
1627                 aros_kernel_cflags="-mno-cygwin"
1628         fi
1629     ;;
1630     pp*)
1631         aros_target_arch="pp"
1632         aros_shared_default="no"
1633         case "$target_cpu" in
1634             *m68k*)
1635                 aros_target_cpu="m68k"
1636                 aros_object_format="m68kelf"
1637                 aros_flavour="palmnative"
1638                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1639                 aros_nominal_width=160
1640                 aros_nominal_height=160
1641                 aros_nominal_depth=1
1642                 aros_target_ar_flags="cru"
1643                 aros_compiler_libs="-lgcc1"
1644                 aros_shared_default=no
1645                 aros_shared_cflags="-fpic"
1646                 aros_shared_aflags=""
1647                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1648                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1649                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1650                 aros_debug_aflags=""
1651                 aros_debug_ldflags="$aros_symbols_debug"
1652                 aros_mungwall_debug="0"
1653                 aros_modules_debug="0"
1654                 gcc_target_cpu="mc68000"
1655                 ignore_undefined_symbols="-ius"
1656                 ;;
1657            *)
1658                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1659                 ;;
1660         esac
1661         ;;
1663     mac*)
1664         aros_target_arch="mac"
1665         aros_shared_default="no"
1666         case "$target_cpu" in
1667             *m68k*)
1668                 aros_target_cpu="m68k"
1669                 aros_object_format="m68kelf"
1670                 aros_flavour="mac68knative"
1671                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1672                 aros_nominal_width=512
1673                 aros_nominal_height=384
1674                 aros_nominal_depth=8
1675                 aros_target_ar_flags="cru"
1676                 aros_compiler_libs="-lgcc1"
1677                 aros_shared_default=no
1678                 aros_shared_cflags="-fpic"
1679                 aros_shared_aflags=""
1680                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1681                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1682                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1683                 aros_debug_aflags=""
1684                 aros_debug_ldflags="$aros_symbols_debug"
1685                 aros_mungwall_debug="0"
1686                 aros_modules_debug="0"
1687                 gcc_target_cpu="mc68000"
1688                 ignore_undefined_symbols="-ius"
1689                 ;;
1690            *)
1691                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1692                 ;;
1693         esac
1694         ;;
1696     *)
1697         AC_MSG_ERROR([Unsupported target architecture $target])
1698         ;;
1699 esac
1701 #-----------------------------------------------------------------------------
1702 crosstools_guess="yes"
1703 aros_target_toolchain="no"
1704 aros_config_sysroot=""
1705 aros_kernel_sysroot=""
1707 AC_MSG_CHECKING([Kernel toolchain prefix])
1708 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1709 AC_MSG_RESULT($kernel_tool_prefix)
1711 AC_MSG_CHECKING([ELF toolchain prefix])
1712 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"
1713                                                  crosstools_guess="no"])
1714 AC_MSG_RESULT($elf_tool_prefix)
1716 AC_MSG_CHECKING([AROS toolchain prefix])
1717 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"
1718                 crosstools_guess="no"])
1719 if test "$aros_tool_prefix" = "yes" ; then
1720     aros_tool_prefix=$aros_target_cpu-aros-
1722 AC_MSG_RESULT($aros_tool_prefix)
1724 #-----------------------------------------------------------------------------
1725 #   Checking if we should build crosstools..
1726 AC_MSG_CHECKING([whether to build crosstools])
1727 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1728 AC_MSG_RESULT($crosstools)
1730 if test "${crosstools}" = "yes"; then
1731     if test "${crosstools_guess}" = "no"; then
1732         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1733     fi
1736 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1737     aros_target_toolchain="yes"
1740 AC_MSG_CHECKING([where to install the crosstools binaries])
1741 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])
1742 if test "x$aros_toolchain_install" = "x"; then
1743     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1744 else
1745     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1746     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1747     if test "$crosstools_guess" = "no" ; then
1748         toolchain_needs_sysroot=yes
1750         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1751             aros_kernel_sysroot = $aros_config_sysroot
1752         fi
1753     fi
1755 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1757 AC_MSG_CHECKING([If we need to use --sysroot])
1758 if test "$toolchain_needs_sysroot" = "yes" ; then
1759     aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1761 AC_MSG_RESULT($toolchain_needs_sysroot)
1763 #-----------------------------------------------------------------------------
1764 if test "$aros_toolchain" = "gnu" ; then
1765     AC_MSG_CHECKING([what specific target binutils version to use])
1767 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="")
1768 if test "$use_binutils_version" = ""; then
1769         target_binutils_version="$default_binutils_version"
1770 else
1771     target_binutils_version="$use_binutils_version"
1773 if test "$aros_toolchain" = "gnu" ; then
1774     AC_MSG_RESULT($target_binutils_version)
1778 # Helper to identify gcc version
1779 AC_DEFUN([CROSS_GCC_VERSION], [
1780   target_gcc_version=""
1781   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1782     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1783     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1784       ax_cv_gcc_version=""
1785     ])
1786   ])
1787   target_gcc_version=$ax_cv_gcc_version
1788   AC_SUBST([target_gcc_version])
1791 #-----------------------------------------------------------------------------
1792 if test "$aros_toolchain" = "gnu" ; then
1793     AC_MSG_CHECKING([what specific target gcc version to use])
1795 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1796 if test "$use_gcc_version" = ""; then
1797     if test "${crosstools}" = "no"; then
1798       if test "x$aros_toolchain_install" != "x"; then
1799           CROSS_GCC_VERSION
1800       fi
1801     fi
1802     if test "$use_gcc_version" = ""; then
1803         target_gcc_version="$default_gcc_version"
1804     fi
1805 else
1806     target_gcc_version="$use_gcc_version"
1808 if test "$aros_toolchain" = "gnu" ; then
1809     AC_MSG_RESULT($target_gcc_version)
1811     GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1812     GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1813     GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1815     gcc_fix_bitfields="false"
1816     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1817         gcc_fix_bitfields="true"
1818     else
1819         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1820             if test "$GCC_VERSION_MINOR" -gt "6" ; then
1821                 gcc_fix_bitfields="true"
1822             fi
1823         fi
1824     fi
1826     if test "$gcc_fix_bitfields" = "true" ; then
1827         case "$aros_target_cpu" in
1828         *x86_64*)
1829             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1830             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1831             ;;
1832         i386)
1833             aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1834             aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1835             ;;
1836         esac
1837     fi
1840 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1841 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1842 AC_MSG_RESULT($objc)
1843 if test "x$objc" = "xyes"; then
1844     objc_target="$objc"
1845 else
1846     objc_target="no-objc"
1849 AC_MSG_CHECKING([whether to enable Java suppport])
1850 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1851 AC_MSG_RESULT($java)
1852 if test "x$java" != "xno"; then
1853     java_target="$java"
1854 else
1855     java_target="no-java"
1858 spec_obj_format="-m $aros_object_format"
1859 # Now process extra architecture-specific options.
1860 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1861 # as well as floating-point ABI.
1862 case "$aros_target_cpu" in
1863 *x86_64*)
1864     dnl x86_64 can build 32 or 64bit code
1865     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1866     ;;
1867 arm*)
1868     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1869     if test "$gcc_default_cpu" = ""; then
1870         gcc_default_cpu="armv6"
1871     fi
1872     if test "$gcc_default_fpu" = ""; then
1873         gcc_default_fpu="vfp"
1874     fi
1875     if test "$gcc_default_float_abi" = ""; then
1876         if test "$target_cpu" = "armhf"; then
1877             gcc_default_float_abi="hard"
1878         else
1879             gcc_default_float_abi="softfp"
1880         fi
1881     fi
1883     AC_MSG_CHECKING([Which minimum CPU to use])
1884     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)
1885     AC_MSG_RESULT($aros_gcc_cpu)
1887     AC_MSG_CHECKING([Which minimum FPU to use])
1888     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)
1889     AC_MSG_RESULT($aros_gcc_fpu)
1891     AC_MSG_CHECKING([Which floating point ABI to use])
1892     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)
1893     AC_MSG_RESULT($aros_gcc_float_abi)
1895     AC_MSG_CHECKING([Which ARM mode to use])
1896     if test "$aros_target_cpu_mode" = ""; then
1897         aros_target_cpu_mode="arm32"
1898         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1899     else
1900         AC_MSG_RESULT([$aros_target_cpu_mode])
1901     fi
1903     case "$aros_target_cpu_mode" in
1904     arm32)
1905         gcc_default_mode="arm"
1906         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1907     ;;
1908     arm64)
1909         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1910     ;;
1911     thumb)
1912         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1913     ;;
1914     thumb1)
1915         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1916     ;;
1917     thumb2)
1918         gcc_default_mode="thumb"
1919         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1920         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1921     ;;
1922     *)
1923         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1924     ;;
1925     esac
1927     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1928     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1929     ;;
1930 i386)
1931     aros_isa_flags="-m32 -march=i486"
1932     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1933     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1934     ;;
1935 esac
1937 # Some architectures may need custom ELF specs.
1938 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1939     elf_specs_in=config/${aros_object_format}-specs.in
1940 else
1941     elf_specs_in=config/elf-specs.in
1944 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1945 # Since we override specs, we may need to put these defines there
1946 if test "$gcc_target_cpu" != ""; then
1947     gcc_target_cpu="-D__${gcc_target_cpu}__"
1950 AC_MSG_CHECKING([where to download sourcecode for external ports])
1951 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1952 if test "$with_portssrcdir" = "default"; then
1953     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1954 else
1955     AROS_PORTSSRCDIR="$with_portssrcdir"
1957 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1959 AC_MSG_CHECKING([which bootloader to use])
1960 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1961 if test "$target_bootloader" = "none"; then
1962     aros_target_bootloader=""
1963 else
1964     aros_target_bootloader="$target_bootloader"
1966 AC_MSG_RESULT($target_bootloader)
1968 AC_MSG_CHECKING([which icon-set to use])
1969 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1970 if test "$target_iconset" = "default"; then
1971     aros_target_iconset="Gorilla"
1972     target_iconset="default (Gorilla)"
1973 else
1974     aros_target_iconset="$target_iconset"
1976 AC_MSG_RESULT($target_iconset)
1978 AC_MSG_CHECKING([which GUI Theme to use])
1979 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1980 if test "$target_guitheme" = "default"; then
1981     aros_target_guitheme="Ice"
1982 else
1983     aros_target_guitheme="$target_guitheme"
1985 AC_MSG_RESULT($aros_target_guitheme)
1987 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1988 # for target code)
1989 cross_compiling=no
1991 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1992 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1993     cross_compiling=yes
1996 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1997 dnl The flag itself is given in per-target section, because some targets require to pass it
1998 dnl in a different manner, otherwise some tests fail.
1999 dnl TODO: Justify this.
2000 if test "$aros_host_cpu" == "x86_64" ; then
2001     if test "$aros_target_cpu" == "i386" ; then
2002         cross_compiling=no
2003     fi
2006 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2007     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2008     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2009     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2010     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2011     dnl used to build bootstrap for target arch in either case.
2012     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2013     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2014     dnl perhaps introducing aros_host_variant
2015     if test "$aros_host_arch" != "$aros_target_arch" ; then
2016         cross_compiling=yes
2017     fi
2018 else
2019     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2020     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2021     if test "$host_cc_elf" = "no" ; then
2022         cross_compiling=yes
2023     fi
2026 if test "$cross_compiling" = "no" ; then
2027     kernel_tool_prefix=""
2028     if test "$host_cc_elf" = "yes" ; then
2029         elf_tool_prefix=""
2030     fi
2033 if test "$kernel_tool_version" != ""; then
2034     kernel_tool_version="-$kernel_tool_version"
2037 #######################################################################
2038 ## Compute what toolchains to use, and their paths                   ##
2039 #######################################################################
2041 # This takes, as input:
2042 #   crosstools             {yes,no}
2043 #   kernel_tool_version    {"",[version]}
2044 #   target_tool_version    {"",[version]}
2045 #   kernel_tool_prefix     {none,[some-arch-os-]}
2046 #   gnu-toolchain -:
2047 #     target_tool_prefix     ${aros_target_cpu}-aros-
2048 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2050 # The output is
2051 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2052 #        Where the 'kernel' binaries are located
2053 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2054 #        Where the 'target' binaries are located
2055 #        (not the symlink farm - that is aros_target_*!)
2057 # The rules are:
2058 #   if crosstools then
2059 #      if kernel_tools_prefix = "no-kernel-prefix-"
2060 #          aros_kernel_* = crosstools cc paths
2061 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2062 #      else
2063 #          VALIDATE(${kernel_tools_prefix}*)
2064 #          aros_kernel_* = ${kernel_tools_prefix}*
2065 #          if ${kernel_tools_prefix}cc is an AROS gcc
2066 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2067 #          else
2068 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2069 #          fi
2070 #      fi
2072 #      orig_target_* = aros built crosstools
2073 #      orig_target_cc = elf cc wrapper around crosstools cc
2074 #   else
2075 #      VALIDATE(${kernel_tools_prefix}*)
2077 #      orig_target_* = aros_kernel_*
2078 #      if aros_kernel_cc is an AROS gcc
2079 #          orig_target_cc = aros_kernel_cc
2080 #      else
2081 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2082 #      fi
2083 #   fi
2085 if test "$aros_toolchain" = "gnu" ; then
2086     target_tool_prefix="${aros_target_cpu}-aros-"
2087 elif test "$aros_toolchain" = "llvm" ; then
2088     target_tool_prefix="bin/"
2091 if test "$kernel_tool_prefix" != "" ; then
2092     AC_MSG_CHECKING([which kernel tools])
2093     AC_MSG_RESULT([$kernel_tool_prefix]);
2096 if test "$kernel_tool_prefix" = "none" ; then
2097     dnl ELF wrapper can be used only for native bootstrap
2098     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2099         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2100     fi
2101 else
2102     # Kernel tools required - find them
2103     # Note that 'normally', aros_kernel_* overrides will be
2104     # empty, unless specified in the per-arch sections above.
2105     if test "x$aros_kernel_cpp" = "x"; then
2106         aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2107     fi
2108     AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2109     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2110     AROS_REQUIRED(cpp,$aros_kernel_cpp)
2112     if test "x$aros_kernel_cc" = "x"; then
2113         aros_kernel_cc=${kernel_tool_prefix}${CC}
2114     fi
2115     AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2116     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2117     AROS_REQUIRED(cc,$aros_kernel_cc)
2119     if test "x$aros_kernel_cxx" = "x"; then
2120         aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2121     fi
2122     AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2123     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2124     # If it's set, make sure it's really there
2125     if test "x$aros_kernel_cxx" != "x" ; then
2126         AROS_REQUIRED(cxx,$aros_kernel_cxx)
2127     fi
2128     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2129     AROS_REQUIRED(ld,$aros_kernel_ld)
2130     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2131     AROS_REQUIRED(as,$aros_kernel_as)
2132     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2133     AROS_REQUIRED(ar,$aros_kernel_ar)
2134     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2135     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2136     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2137     AROS_REQUIRED(nm,$aros_kernel_nm)
2138     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2139     AROS_REQUIRED(strip,$aros_kernel_strip)
2141     # Objcopy and objdump are not required for the kernel
2142     # toolchain on many architectures.
2143     # So we'll look for them, but not make them strictly required.
2144     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2145     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2146     if test "x${crosstools}" != "xyes" ; then
2147         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2148         AROS_REQUIRED(objdump,$aros_kernel_objdump)
2149     fi
2152 AC_MSG_CHECKING([which target tools to use])
2153 if test "$aros_target_toolchain" = "yes"; then
2154     if test "$aros_toolchain" = "llvm" ; then
2155         msg_result="llvm"
2156     else
2157         msg_result=$target_tool_prefix
2158     fi
2159     AC_MSG_RESULT([$msg_result])
2160     # We are building AROS crosstools
2161     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2162     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2163     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2164     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2165     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2166     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2167     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2168     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2169     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2170     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2171     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2172     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2173 else
2174     # Determine whether AROS or ELF tools should be used
2175     if test "$aros_tool_prefix" = "none"; then
2176         aros_tool_prefix="${elf_tool_prefix}"
2177     fi
2179     AC_MSG_RESULT([$aros_tool_prefix])
2180     # We are *not* building AROS crosstools - use the AROS or ELF tools
2181     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2182     AROS_REQUIRED(cpp,$orig_target_cpp)
2183     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2184     AROS_REQUIRED(cc,$orig_target_cc)
2185     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2186     AROS_REQUIRED(cxx,$orig_target_cxx)
2187     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2188     AROS_REQUIRED(ld,$orig_target_ld)
2189     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2190     AROS_REQUIRED(as,$orig_target_as)
2191     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2192     AROS_REQUIRED(ar,$orig_target_ar)
2193     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2194     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2195     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2196     AROS_REQUIRED(nm,$orig_target_nm)
2197     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2198     AROS_REQUIRED(strip,$orig_target_strip)
2199     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2200     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2201     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2202     AROS_REQUIRED(objdump,$orig_target_objdump)
2205 if test "$kernel_tool_prefix" = "none" ; then
2206     # No kernel tools specified
2207     # Assume target tools == kernel tools with ELF wrapper
2208     aros_kernel_cc=$orig_target_cc
2209     aros_kernel_cxx=$orig_target_cxx
2210     aros_kernel_cpp=$orig_target_cpp
2211     aros_kernel_ld=$orig_target_ld
2212     aros_kernel_as=$orig_target_as
2213     aros_kernel_ar=$orig_target_ar
2214     aros_kernel_ranlib=$orig_target_ranlib
2215     aros_kernel_nm=$orig_target_nm
2216     aros_kernel_strip=$orig_target_strip
2217     aros_kernel_objcopy=$orig_target_objcopy
2218     aros_kernel_objdump=$orig_target_objdump
2219     use_kernel_cc_wrapper=yes
2222 # At this point, all aros_kernel_* and aros_target_* 
2223 # tools should be set up correctly
2225 CC="$aros_kernel_cc $kernel_tool_flags"
2226 CPP="$aros_kernel_cpp"
2228 #-----------------------------------------------------------------------------
2230 # Find all the tools we need to compile. This could be cross-compiling
2231 # though! If that is the case we use the GNU form of the target and
2232 # simply add this to the front of the binary name. This is rather simple,
2233 # but it should work under most circumstances.
2235 # The default tools are to use the same as the host, but only if the
2236 # host and target CPU are the same. With GCC this is normally enough.
2239 aros_cc_pre=""
2240 aros_shared_ld="$aros_host_ld"
2242 aros_target_mkdep="$aros_host_mkdep"
2244 # The default tools executables to be linked to.
2245 if test "$rescomp" != ""; then
2246     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2247     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2250 # Set up the sources for the symlink farm
2251 if test "$crosstools" = "yes"; then
2252     crosstools_target=tools-crosstools
2255 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2256 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2258 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2259 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2260 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2261 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2262 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2263 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2264 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2266 # aros_cc_pre is a variable that is added to the front of the compiler name
2267 # in the generated aros-gcc shell script. We need this to enable the cache
2268 # to work across cleaned builds. Also, support DISTCC using the correct
2269 # environment variable.
2272 if test "x${DISTCC}" != "x" ; then
2273     if test "x${CCACHE}" != "x" ; then
2274         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2275     else
2276         aros_cc_pre="${DISTCC} "
2277     fi
2278 else
2279     if test "x${CCACHE}" != "x" ; then
2280         aros_cc_pre="${CCACHE} "
2281     fi
2284 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2285 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2286 AC_SUBST(aros_target_nix_ldflags,-nix)
2287 AC_SUBST(aros_target_detach_ldflags,-detach)
2288 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2290 # Target tools
2291 AC_SUBST(aros_toolchain)
2292 if test "$aros_target_toolchain" != "yes"; then
2293     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2294     if test "$GCC" = "yes"; then
2295         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2296     fi
2297 else
2298     # We do not know which c compiler version we are going to build and what we need to know
2299     # here is different for different versions so this will be set later during the
2300     # build of crosstools.
2301     if test "$aros_toolchain" = "gnu" ; then
2302         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2303     elif test "$aros_toolchain" = "llvm" ; then
2304         prefix="$AROS_CROSSTOOLSDIR/bin/"
2305     fi
2306     aros_target_cc_path=@aros_target_cc_path@
2308 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2309 aros_target_cc="${prefix}${toolchain_c_compiler}"
2310 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2311 aros_target_as="${prefix}${toolchain_as}"
2312 if test "${use_ld_wrapper}" = "yes"; then
2313     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2314 else
2315     aros_target_ld="${prefix}${toolchain_ld}"
2317 aros_toolchain_ld="${prefix}${toolchain_ld}"
2319 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2320 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2321 aros_target_objdump="${prefix}${toolchain_objdump}"
2322 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2323 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2324 aros_target_strip="${prefix}${toolchain_strip}"
2325 aros_plain_nm="${prefix}${toolchain_nm}"
2326 aros_plain_ar="${prefix}${toolchain_ar}"
2328 AC_ARG_ENABLE(includes,
2329 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2330 [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`])
2332 if test "$aros_kernel_includes" = ""; then
2333     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2334         aros_kernel_includes="-isystem $aros_target_incl"
2335     fi
2338 if test "$aros_kernel_includes" != "" ; then
2339     dnl find out about the kernel cc's include path
2340     AC_MSG_CHECKING([for the kernel compiler's include path])
2341     if test "$aros_kernel_cc_includes" = "" ; then
2342         # Try to guess where the directory is.
2343         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2344         if test -d $aros_kernel_cc_includes; then
2345             # Check if there is also an include-fixed directory and add it
2346             # to kernel compiler's include path as it may contain some of
2347             # the headers we need.
2348             if test -d "$aros_kernel_cc_includes"-fixed; then
2349                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2350             fi
2351             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2352             if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2353                 aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2354             fi
2355         else
2356             # The directory doesn't exist, we need to do some more work.
2357             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2359             # These are the headers we're looking for.
2360             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2361                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2362                      zutil.h stdint.h"
2364             dirs=
2365             for h in $headers; do
2366                 # Which other headers are needed by each of the above?
2367                 deps=$(echo "#include <$h>" | \
2368                        $aros_kernel_cc -E -M - 2>/dev/null | \
2369                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2371                 # Copy all the needed headers to a directory beneath gendir.
2372                 for d in $deps; do
2373                     h=$(basename $d)
2374                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2375                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2376                     ! test -d $dir && mkdir -p $dir
2377                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2378                 done
2379             done            
2380         fi
2381     fi
2382     AC_MSG_RESULT($aros_kernel_cc_includes)
2383     # Adding -nostdinc to kernel includes as they are always used together.
2384     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2387 if test "$crosstools" != "yes"; then
2388     dnl find out about the target cc's include path
2389     AC_MSG_CHECKING([for the target compiler's include path])
2390     if test "$aros_target_cc_includes" = "" ; then
2391         #try to guess where the directory is
2392         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2393         if ! test -d $aros_target_cc_includes; then
2394             #the directory doesn't exist, we need to do some more work
2395             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2396         
2397             #these are the headers we're looking for
2398             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2399                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2400                     zutil.h"
2402             dirs=
2403             for h in $headers; do
2404                 #which other headers each of the above headers needs?
2405                 deps=$(echo "#include <$h>" | \
2406                     $orig_target_cc -E -M - 2>/dev/null | \
2407                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2408             
2409                 #copy all the needed headers to a directory beneath gendir
2410                 for d in $deps; do
2411                     h=$(basename $d)
2412                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2413                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2414                     ! test -d $dir && mkdir -p $dir
2415                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2416                 done
2417             done
2418         fi
2419     fi
2420     AC_MSG_RESULT($aros_target_cc_includes)
2421 else
2422     # We do not know which c compiler version we are going to build and what we need to know
2423     # here is different for different versions so this will be set later during the
2424     # build of crosstools.
2425     aros_target_cc_includes=@aros_target_cc_includes@
2429 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2430 # On GCC >= 4.0 -iquote should be used
2433 save_cc="$CC"
2434 save_cflags="$CFLAGS"
2435 CFLAGS="-iquote."
2436 kernel_cflags_iquote=$host_cflags_iquote
2437 kernel_cflags_iquote_end=$host_cflags_iquote_end
2438 if test "x-$cross_compiling" = "x-yes"; then
2439     CC="$aros_kernel_cc"
2440     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2441     if test "x-$crosstools" != "x-yes"; then
2442         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2443     else
2444         # we do know it is supported for the smallest version of gcc we are going to build
2445         # we assume it's also supported by later versions
2446         use_no_stack_protector=yes
2447     fi
2448     AC_MSG_RESULT($use_no_stack_protector)
2449     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2450     if test "x-$crosstools" != "x-yes"; then
2451         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2452     else
2453         # we do know it is supported for the smallest version of gcc we are going to build
2454         # we assume it's also supported by later versions
2455         has_iquote=yes
2456     fi
2457     AC_MSG_RESULT($has_iquote)
2458     if test "x-$has_iquote" = "x-yes" ; then
2459         kernel_cflags_iquote=-iquote
2460         kernel_cflags_iquote_end=
2461     else
2462         kernel_cflags_iquote=-I
2463         kernel_cflags_iquote_end=-I-
2464     fi
2466 if test "x-$use_no_stack_protector" = "x-yes" ; then
2467     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2470 #-----------------------------------------------------------------------------
2472 # Check if we can explicitly choose older version of symbol hashing
2474 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2475 CC="$aros_kernel_cc"
2476 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2477 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2478 AC_MSG_RESULT($use_hash_style)
2479 if test "x-$use_hash_style" = "x-yes" ; then
2480     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2482 CC="$save_cc"
2483 CFLAGS="$save_cflags"
2485 AC_SUBST(host_cflags_iquote)
2486 AC_SUBST(host_cflags_iquote_end)
2487 AC_SUBST(kernel_cflags_iquote)
2488 AC_SUBST(kernel_cflags_iquote_end)
2491 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2492 AC_MSG_CHECKING([for default resolution of WBScreen])
2493 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2494 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2495 if test "$resolution" = "yes" ; then
2496     resolution="none"
2498 if test "$resolution" = "no" ; then
2499     resolution="none"
2501 if test "$resolution" != "none" ; then
2502     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2503     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2504     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2506 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2507 aros_cv_nominal_width=$aros_nominal_width
2508 aros_cv_nominal_height=$aros_nominal_height
2509 aros_cv_nominal_depth=$aros_nominal_depth
2511 dnl See if the user wants the serial debug output for native flavour
2512 AC_MSG_CHECKING([whether serial debug is enabled])
2513 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)
2514 if test "$aros_serial_debug" = 0 ; then
2515     serial_debug_forced=""
2516     if test "$serial_debug" = "yes" ; then
2517         serial_debug="1"
2518     fi
2519     if test "$serial_debug" = "no" ; then
2520         serial_debug="none"
2521     fi
2522 else
2523     serial_debug_forced="(forced)"
2524     serial_debug=$aros_serial_debug
2526 if test "$serial_debug" != "none" ; then
2527     aros_serial_debug=$serial_debug
2528     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2529 else
2530     AC_MSG_RESULT(no)
2533 dnl See if the user wants the palm debug output hack for palm native flavour
2534 AC_MSG_CHECKING([whether palm debug hack is enabled])
2535 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")
2536 if test "$palm_debug_hack" = "yes" ; then
2537     aros_palm_debug_hack="1"
2539 AC_MSG_RESULT($palm_debug_hack)
2541 dnl See if dev wants the usb3.0 code
2542 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2543 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2544 if test "$usb30_code" = "yes" ; then
2545     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2546     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2548 AC_MSG_RESULT($usb30_code)
2550 dnl See if the user wants nesting supervisor activated for unix flavour
2551 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2552 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")
2553 if test "$nesting_supervisor" = "yes" ; then
2554     aros_nesting_supervisor="1"
2556 AC_MSG_RESULT($nesting_supervisor)
2558 dnl See if the user wants to disable MMU support
2559 dnl This can be overriden on per-target basis,
2560 dnl set $aros_enable_mmu to "yes" or "no" to do this
2561 if test "$aros_enable_mmu" = "" ; then
2562     AC_MSG_CHECKING([whether MMU support is enabled])
2563     dnl Enabled by default
2564     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2565     if test "$aros_enable_mmu" = "" ; then
2566         aros_enable_mmu="yes"
2567     fi
2568     AC_MSG_RESULT($aros_enable_mmu)
2570 if test "$aros_enable_mmu" = "no" ; then
2571     aros_enable_mmu="0"
2572 else
2573     aros_enable_mmu="1"
2575     
2577 dnl things specifically required for hosted flavours
2578 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2580     if test "x-$need_dlopen" != "x-no" ; then
2581       save_libs="$LIBS"
2582       LIBS=""
2583       dnl some kind of dynamic library access system is required for hostlib.resource
2584       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2585       if test "x-$have_dl" = "x-no" ; then
2586           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2587                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2588                                     have_dl="no")
2589       fi
2590       if test "x-$have_dl" = "x-no" ; then
2591           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2592       fi
2593       LIBS="$save_libs"
2594     fi
2597     dnl x11 hidd
2598     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2599                                            [build X11 hidd for hosted (default=auto)]),
2600                                            x11_hidd="$enableval",
2601                                            x11_hidd="$need_x11")
2602     case "x-$x11_hidd" in
2603         x-yes|x-no|x-auto)                 ;;
2604         *)                 x11_hidd="$need_x11" ;;
2605     esac
2607     ENABLE_X11=0
2609     dnl they want it
2610     if test "x-$x11_hidd" != "x-no" ; then
2612         dnl find x11 stuff
2613         AC_PATH_X
2615         if test -n "$x_includes"; then
2616             X_CFLAGS="$X_CFLAGS -I$x_includes"
2617         fi
2619         if test -n "$x_libraries"; then
2620             X_LIBS="$X_LIBS -L$x_libraries"
2621         fi
2623         if test "x-$no_x" = "x-yes" ; then
2625             dnl didn't find it
2626             if test "x-$x11_hidd" != "x-auto" ; then
2627                 dnl and they explicitly asked for it, bail out
2628                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2629             fi
2630         
2631         else
2632             dnl found it, setup the metatarget
2633             host_x_gfx=yes
2634             ENABLE_X11=1
2636             aros_host_x11_cflags="$X_CFLAGS"
2637             aros_host_x11_ldflags="$X_LIBS  -lX11"
2639             dnl setup shared memory extensions
2640             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2641                                                   [use X11 shared memory (default=auto)]),
2642                                                   x11_hidd_shm="$enableval",
2643                                                   x11_hidd_shm="auto")
2644             case "x-$x11_hidd_shm" in
2645                 x-yes|x-no|x-auto)                     ;;
2646                 *)                 x11_hidd_shm="auto" ;;
2647             esac
2649             have_xshm=no
2651             dnl they want it
2652             if test "x-$x11_hidd_shm" != "x-no" ; then
2654                 dnl system shm headers
2655                 AC_CHECK_HEADERS(sys/ipc.h)
2656                 AC_CHECK_HEADERS(sys/shm.h)
2658                 dnl got them
2659                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2661                     dnl make sure X libs have shm functions
2662                     save_cflags="$CFLAGS"
2663                     save_ldflags="$LDFLAGS"
2664                     CFLAGS="$CFLAGS $X_CFLAGS"
2665                     LDFLAGS="$LDFLAGS $X_LIBS"
2666                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2667                     CFLAGS="$save_cflags"
2668                     LDFLAGS="$save_ldflags"
2669                 fi
2670             fi
2672             dnl detection done, prepare output
2673             if test "x-$have_xshm" = "x-yes" ; then
2674                 dnl we can do shm
2675                 DO_XSHM_SUPPORT="1"
2676             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2677                 dnl they explicitly asked for it, but we can't do it
2678                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2679             else
2680                 dnl otherwise just disable it
2681                 DO_XSHM_SUPPORT="0"
2682             fi
2684             
2685             dnl setup vidmode (fullscreen) extensions
2686             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2687                                                       [use X11 vidmode extension (default=auto)]),
2688                                                       x11_hidd_vidmode="$enableval",
2689                                                       x11_hidd_vidmode="auto")
2690             case "x-$x11_hidd_vidmode" in
2691                 x-yes|x-no|x-auto)                         ;;
2692                 *)                 x11_hidd_vidmode="auto" ;;
2693             esac
2695             have_vidmode=no
2697             dnl they want it
2698             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2700                 dnl make sure X libs have vidmode functions
2701                 save_cflags="$CFLAGS"
2702                 save_ldflags="$LDFLAGS"
2703                 CFLAGS="$CFLAGS $X_CFLAGS"
2704                 LDFLAGS="$LDFLAGS $X_LIBS"
2705                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2706                 CFLAGS="$save_cflags"
2707                 LDFLAGS="$save_ldflags"
2708             fi
2710             dnl detection done, prepare output
2711             if test "x-$have_vidmode" = "x-yes" ; then
2712                 dnl we can do vidmode
2713                 DO_VIDMODE_SUPPORT="1"
2714             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2715                 dnl they explicitly asked for it, but we can't do it
2716                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2717             else
2718                 dnl otherwise just disable it
2719                 DO_VIDMODE_SUPPORT="0"
2720             fi
2721         fi
2722     fi
2724     dnl sdl hidd
2725     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2726                                            [build SDL hidd for hosted (default=auto)]),
2727                                            sdl_hidd="$enableval",
2728                                            sdl_hidd="auto")
2729     case "x-$sdl_hidd" in
2730         x-yes|x-no|x-auto)                 ;;
2731         *)                 sdl_hidd="auto" ;;
2732     esac
2734     dnl they want it
2735     if test "x-$sdl_hidd" != "x-no" ; then
2737         dnl find sdl
2738         SDL_VERSION=1.2.5
2739         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2740             [have_sdl="no"])
2742         if test "x-$have_sdl" != "x-yes" ; then
2744             dnl didn't find it
2745             if test "x-$sdl_hidd" != "x-auto" ; then
2746                 dnl and they explicitly asked for it, bail out
2747                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2748             fi
2750         else
2751             dnl found it, enable the build
2752             host_sdl_gfx=yes
2753             aros_host_sdl_cflags=$SDL_CFLAGS
2754             aros_host_sdl_libs=$SDL_LIBS
2755         fi
2756     fi
2761 dnl See if the user wants dbus.library
2762 AC_MSG_CHECKING([whether building of dbus.library is enabled])
2763 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2764 if test "$dbus" = "yes" ; then
2765     ENABLE_DBUS=1
2766     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2767     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2768     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2769     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2770 else
2771     ENABLE_DBUS=0
2773 AC_MSG_RESULT($dbus)
2775 if test "$use_kernel_cc_wrapper" = "yes" ; then
2776     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
2779 dnl --------------------------------------------------------------------
2780 dnl Configuration Output Section
2781 dnl --------------------------------------------------------------------
2783 # Generic
2784 AC_SUBST(aros_arch)
2785 AC_SUBST(aros_cpu)
2786 AC_SUBST(aros_flavour)
2787 AC_SUBST(aros_flavour_uc)
2788 AC_SUBST(aros_target_toolchain)
2789 AC_SUBST(aros_toolchain_ld)
2790 AC_SUBST(aros_build_host)
2791 AC_SUBST(AROS_BUILDDIR)
2792 AC_SUBST(AROS_BUILDDIR_UNIX)
2793 AC_SUBST(SRCDIR)
2794 AC_SUBST(AROS_CROSSTOOLSDIR)
2795 AC_SUBST(AROS_PORTSSRCDIR)
2797 # Compatability with other Amiga-like operation systems
2798 AC_SUBST(aros_amigaos_compliance)
2800 # Host related
2801 AC_SUBST(aros_cc_pre)
2802 AC_SUBST(aros_host_strip)
2803 AC_SUBST(aros_host_arch)
2804 AC_SUBST(aros_host_cpu)
2805 AC_SUBST(aros_host_cpp)
2806 AC_SUBST(aros_host_def_cc)
2807 AC_SUBST(aros_host_cc)
2808 AC_SUBST(aros_host_cxx)
2809 AC_SUBST(aros_host_ar)
2810 AC_SUBST(aros_host_ranlib)
2811 AC_SUBST(aros_host_ld)
2812 AC_SUBST(aros_host_make)
2813 AC_SUBST(aros_host_cflags)
2814 AC_SUBST(aros_host_cxxflags)
2815 AC_SUBST(gnu89_inline)
2816 AC_SUBST(aros_host_ldflags)
2817 AC_SUBST(aros_host_debug)
2818 AC_SUBST(aros_host_mkdep)
2819 AC_SUBST(aros_host_mkargs)
2820 AC_SUBST(aros_host_exe_suffix)
2821 AC_SUBST(aros_host_lib_suffix)
2822 AC_SUBST(aros_tools_dir)
2823 AC_SUBST(aros_host_aclocal)
2824 AC_SUBST(aros_host_autoconf)
2825 AC_SUBST(aros_host_autoheader)
2826 AC_SUBST(aros_host_automake)
2827 AC_SUBST(ant)
2829 # Target Related
2830 AC_SUBST(aros_target_guitheme)
2831 AC_SUBST(aros_target_iconset)
2832 AC_SUBST(aros_target_bootloader)
2833 AC_SUBST(aros_target_arch)
2834 AC_SUBST(aros_target_family)
2835 AC_SUBST(aros_target_cpu)
2836 AC_SUBST(aros_target_cpu_mode)
2837 AC_SUBST(aros_target_variant)
2838 AC_SUBST(aros_target_suffix)
2839 AC_SUBST(aros_target_ar)
2840 AC_SUBST(aros_target_ranlib)
2841 AC_SUBST(aros_plain_nm)
2842 AC_SUBST(aros_plain_ar)
2843 AC_SUBST(aros_kernel_ar)
2844 AC_SUBST(aros_kernel_ranlib)
2845 AC_SUBST(orig_target_cc)
2846 AC_SUBST(aros_target_cc)
2847 AC_SUBST(aros_kernel_cc)
2848 AC_SUBST(orig_target_cxx)
2849 AC_SUBST(aros_target_cxx)
2850 AC_SUBST(aros_kernel_cxx)
2851 AC_SUBST(orig_target_cpp)
2852 AC_SUBST(aros_target_cpp)
2853 AC_SUBST(aros_kernel_cpp)
2854 AC_SUBST(orig_target_as)
2855 AC_SUBST(aros_target_as)
2856 AC_SUBST(aros_kernel_as)
2857 AC_SUBST(orig_target_ld)
2858 AC_SUBST(aros_target_ld)
2859 AC_SUBST(aros_kernel_ld)
2860 AC_SUBST(aros_target_cc_includes)
2861 AC_SUBST(aros_target_cc_path)
2862 AC_SUBST(aros_target_objdump)
2863 AC_SUBST(aros_target_objcopy)
2864 AC_SUBST(aros_target_strip)
2865 AC_SUBST(aros_target_nm)
2866 AC_SUBST(aros_kernel_rescomp)
2867 AC_SUBST(aros_shared_default)
2868 AC_SUBST(aros_shared_ld)
2869 AC_SUBST(aros_object_format)
2870 AC_SUBST(spec_obj_format)
2871 AC_SUBST(aros_compiler_libs)
2872 AC_SUBST(aros_arch_libs)
2874 AC_SUBST(aros_shared_cflags)
2875 AC_SUBST(aros_shared_aflags)
2876 AC_SUBST(aros_shared_ldflags)
2878 AC_SUBST(aros_config_sysroot)
2879 AC_SUBST(aros_nowarn_flags)
2880 AC_SUBST(aros_config_cflags)
2881 AC_SUBST(aros_config_aflags)
2882 AC_SUBST(aros_config_ldflags)
2884 AC_SUBST(aros_kernel_sysroot)
2885 AC_SUBST(aros_kernel_cflags)
2886 AC_SUBST(aros_kernel_includes)
2887 AC_SUBST(aros_kernel_objcflags)
2888 AC_SUBST(aros_kernel_ldflags)
2889 AC_SUBST(aros_target_cflags)
2890 AC_SUBST(aros_debug_cflags)
2891 AC_SUBST(aros_debug_aflags)
2892 AC_SUBST(aros_debug_ldflags)
2893 AC_SUBST(aros_target_genmap)
2894 AC_SUBST(aros_target_strip_flags)
2895 AC_SUBST(aros_config_lto)
2896 AC_SUBST(aros_optimization_cflags)
2897 AC_SUBST(aros_isa_flags)
2899 AC_SUBST(crosstools_target)
2900 AC_SUBST(crosstools_cxx_target)
2902 # Hosted Graphics Related
2903 AC_SUBST(host_x_gfx)
2904 AC_SUBST(host_sdl_gfx)
2905 AC_SUBST(host_android_gfx)
2907 AC_SUBST(pci_hidd_target)
2909 AC_SUBST(aros_nominal_width)
2910 AC_SUBST(aros_nominal_height)
2911 AC_SUBST(aros_nominal_depth)
2912 AC_SUBST(DO_XSHM_SUPPORT)
2913 AC_SUBST(DO_VIDMODE_SUPPORT)
2915 AC_SUBST(aros_host_x11_cflags)
2916 AC_SUBST(aros_host_x11_ldflags)
2917 AC_SUBST(aros_host_sdl_cflags)
2918 AC_SUBST(aros_host_sdl_libs)
2920 # Native version related
2921 AC_SUBST(aros_serial_debug)
2922 AC_SUBST(PLATFORM_EXECSMP)
2923 AC_SUBST(ENABLE_EXECSMP)
2925 # Palm native version related
2926 AC_SUBST(aros_palm_debug_hack)
2928 # Unix/Hosted version related
2929 AC_SUBST(aros_nesting_supervisor)
2931 # MMU related
2932 AC_SUBST(aros_enable_mmu)
2934 # Apple iOS related
2935 AC_SUBST(aros_ios_platform)
2936 AC_SUBST(aros_ios_version)
2937 AC_SUBST(aros_ios_sdk)
2939 # ARM default GCC target related
2940 AC_SUBST(gcc_default_cpu)
2941 AC_SUBST(gcc_default_cpu_tune)
2942 AC_SUBST(gcc_default_fpu)
2943 AC_SUBST(gcc_default_float_abi)
2944 AC_SUBST(gcc_default_mode)
2946 # Android related
2947 AC_SUBST(android_tool)
2948 AC_SUBST(aros_android_level)
2949 AC_SUBST(aros_android_antapk)
2951 # DBUS related
2952 AC_SUBST(ENABLE_DBUS)
2953 AC_SUBST(DBUS_CFLAGS)
2954 AC_SUBST(DBUS_LIBFLAGS)
2955 AC_SUBST(KERNEL_DBUS_KOBJ)
2956 AC_SUBST(KERNEL_DBUS_INCLUDES)
2958 #X11 related
2959 AC_SUBST(ENABLE_X11)
2961 # Debug related
2962 AC_SUBST(aros_debug)
2963 AC_SUBST(aros_mungwall_debug)
2964 AC_SUBST(aros_stack_debug)
2965 AC_SUBST(aros_modules_debug)
2967 # Collect-aros stuff: "-ius" to ignore undefined symbols
2968 AC_SUBST(ignore_undefined_symbols)
2970 # C compiler related
2971 AC_SUBST(gcc_target_cpu)
2972 AC_SUBST(target_binutils_version)
2973 AC_SUBST(target_gcc_version)
2975 #ObjC compiler related
2976 AC_SUBST(objc_target)
2978 #Java related
2979 AC_SUBST(java_target)
2981 # USB3.0 code
2982 AC_SUBST(aros_usb30_code)
2984 dnl Prepare for output, make up all the generated patches
2985 case "$aros_flavour" in
2986 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2987                 aros_flavour="emulation" ;;
2988 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2989                 aros_flavour="emulation" ;;
2990 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2991                 aros_flavour="standalone";;
2992 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2993                 aros_flavour="standalone";;
2994 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2995                 aros_flavour="native" ;;
2996 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2997                 aros_flavour="native" ;;
2998 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2999                 aros_flavour="linklib" ;;
3000 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3001                 aros_flavour="palmnative" ;;
3002 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3003                 aros_flavour="mac68knative" ;;
3004 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3005                 aros_flavour="ppcnative" ;;
3006 esac
3008 if test ! -d ${aros_inc_dir} ; then
3009     ${MKDIR} ${aros_inc_dir}
3011 if test ! -d ${aros_geninc_dir} ; then
3012     ${MKDIR} ${aros_geninc_dir}
3014 if test ! -d ${aros_hostcfg_dir} ; then
3015     ${MKDIR} ${aros_hostcfg_dir}
3017 if test ! -d ${aros_targetcfg_dir} ; then
3018     ${MKDIR} ${aros_targetcfg_dir}
3020 if test ! -d ${aros_tools_dir} ; then
3021     ${MKDIR} ${aros_tools_dir}
3023 if test ! -d ${aros_scripts_dir} ; then
3024     ${MKDIR} ${aros_scripts_dir}
3027 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3029 # Generic build tools (metamake, etc)
3030 AC_CONFIG_COMMANDS([genmf-executable-support],
3031     [chmod a+x ${aros_tools_dir}/genmf.py],
3032     [aros_tools_dir=${aros_tools_dir}]
3034 AC_CONFIG_FILES(
3035     Makefile
3036     config/make.cfg
3037     ${aros_inc_dir}/config.h:config/config.h.in
3038     ${aros_geninc_dir}/config.h:config/config.h.in
3039     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3040     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3041     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3042     mmake.config
3043     compiler/include/mmakefile:compiler/include/mmakefile.in
3044     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3045     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3046     tools/collect-aros/env.h
3049 # Binutils
3050 AC_CONFIG_COMMANDS([binutils-support],
3051     [
3052         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3053         mkdir -p $prefix
3054         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3056         chmod a+x ${prefix2}-ld
3058         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3059         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3060         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3061         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3062         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3063         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3064         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3065     ],
3066     [
3067         aros_host_exe_suffix=${aros_host_exe_suffix}
3068         aros_tools_dir=${aros_tools_dir}
3069         aros_target_cpu=${aros_target_cpu}
3070         aros_target_arch=${aros_target_arch}
3071         aros_target_suffix=${aros_target_suffix}
3072         orig_target_nm=${orig_target_nm}
3073         orig_target_as=${orig_target_as}
3074         orig_target_ar=${orig_target_ar}
3075         orig_target_ranlib=${orig_target_ranlib}
3076         orig_target_objdump=${orig_target_objdump}
3077         orig_target_objcopy=${orig_target_objcopy}
3078         orig_target_strip=${orig_target_strip}
3079         aros_kernel_ld=${aros_kernel_ld}
3080     ]
3082 if test "${use_ld_wrapper}" = "yes"; then
3083     AC_CONFIG_FILES(
3084         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3085     )
3087 # Bare Elf support script and spec
3088 if test "${use_kernel_cc_wrapper}" = "yes"; then
3089     AC_CONFIG_COMMANDS([elf-compiler-support],
3090         [
3091             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3092             mkdir -p $prefix
3093             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3095             chmod a+x ${prefix2}-gcc
3097             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3098         ],
3099         [
3100             aros_host_exe_suffix=${aros_host_exe_suffix}
3101             aros_tools_dir=${aros_tools_dir}
3102             aros_target_cpu=${aros_target_cpu}
3103             aros_target_arch=${aros_target_arch}
3104             aros_target_suffix=${aros_target_suffix}
3105             aros_kernel_ld=${aros_kernel_ld}
3106         ]
3107     )
3108     AC_CONFIG_FILES(
3109         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3110         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3111     )
3114 # Host compiler support scripts and spec
3115 if test "${aros_target_toolchain}" = "no"; then
3116     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3117         [
3118             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3119             mkdir -p $prefix
3120             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3122             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3123         ],
3124         [
3125             aros_host_exe_suffix=${aros_host_exe_suffix}
3126             aros_tools_dir=${aros_tools_dir}
3127             aros_target_cpu=${aros_target_cpu}
3128             aros_target_arch=${aros_target_arch}
3129             aros_target_suffix=${aros_target_suffix}
3130         ]
3131     )
3132     AC_CONFIG_FILES(
3133         ${aros_targetcfg_dir}/specs:config/specs.in
3134         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3135         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3136         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3137     )
3140 # Android support
3141 if test "$aros_target_variant" == "android"; then
3142     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3145 # cmake helper
3146 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3148 AC_OUTPUT
3150 dnl This is in order to not define SHARED_CFLAGS sometimes
3151 dnl We don't always do aros_shared_ar, aros_shared_cflags
3153 #XXX compatability...
3154 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3156 if test -n "$aros_shared_cflags" ; then
3157     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3158     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg