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