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