compiler/pthread: implement pthread_detach and pthread_getschedparam
[AROS.git] / configure.in
blobc2163ca8fae901f031e04ae31790e206d1dfddd5
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 version of gnu tools to use
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 # The first step is to find the host binaries.
90 # Check for a compiler.
91 # Due to a bug in autoconf check for c++ compiler first.
92 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
93 AC_PROG_CXX
94 AC_PROG_CC
95 AC_PROG_CC_STDC
96 AC_PROG_CPP
98 # Check for a compatible awk
99 AC_CHECK_PROGS(AWK,[gawk nawk])
100 AROS_REQUIRED(gawk,$AWK)
101 AROS_PROG(MMAKE,mmake)
103 # Perform some default variable assignments. Note all of these will be
104 # Regenerated from the script, so there is no need to cache them.
106 aros_build_host=$host
107 aros_host_cpp="$CPP"
108 aros_host_cc="$CC"
109 aros_host_cxx="$CXX"
110 AROS_TOOL_CCPATH(aros_host_ld,ld)
111 AROS_REQUIRED(ld,$aros_host_ld)
112 aros_host_make="make"
113 aros_host_cflags="$CFLAGS"
114 aros_host_cxxflags="$CXXFLAGS"
115 aros_host_ldflags="$LDFLAGS"
116 aros_host_debug="-g -O0"
117 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
118 aros_host_mkargs="--no-print-directory"
119 aros_host_exe_suffix="$EXEEXT"
120 aros_host_lib_suffix=""
122 # Ignore all compliance, AROS ROMs = 0
123 # KickStart v1.0 = 30
124 # KickStart v1.3 = 34
125 # KickStart v2.0 = 37
126 # KickStart v3.0 = 39
127 # KickStart v3.1 = 40
128 # AmigaOS   v3.5 = 44
129 aros_amigaos_compliance=0
131 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
132 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
133 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
134 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
136 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
137 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
139 case "$aros_host_cc" in
140     *clang*)
141         aros_host_cc_pipe=""
142         ;;
143     *gcc*)
144         aros_host_cc_pipe="-pipe"
145         ;;
146     icc)
147         aros_host_cc_pipe=""
148         ;;
149     *)
150         aros_host_cc_pipe=""
151         ;;
152 esac
154 aros_kernel_cc_includes=""
155 aros_target_cc_includes=""
156 host_cc_elf=yes
158 # ----------------------------------------------------------------------------------------
159 # Host-specific defaults
161 # This is the main host configuration section. It is where the host
162 # can change the values of any variables it needs to change. We do
163 # not look at anything that compiles to the target yet, we'll get
164 # to that later.
166 case "$host_os" in
167     aros*)
168         aros_host_arch="aros"
169         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
170         case "$host_cpu" in
171             *i?86*)
172                 aros_host_cpu="i386"
173                 ;;
174             *x86_64*)
175                 aros_host_cpu="x86_64"
176                 ;;
177             *powerpc*)
178                 aros_host_cpu="ppc"
179                 ;;
180             *)
181                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
182                 aros_host_cpu="$host_cpu"
183                 ;;
184         esac
185         ;;
187     linux*)
188         aros_host_arch="linux"
189         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
190         android_build_os="linux-x86"
191         android_tool="android"
192         default_android_sdk="/opt/android-sdk-linux_x86"
193         case "$host_cpu" in
194             *i?86*)
195                 aros_host_cpu="i386"
196                 ;;
197             *x86_64*)
198                 aros_host_cpu="x86_64"
199                 ;;
200             *m68k*)
201                 aros_host_cpu="m68k"
202                 ;;
203             *powerpc*)
204                 aros_host_cpu="ppc"
205                 ;;
206             *arm*)
207                 aros_host_cpu="arm"
208                 ;;
209             *)
210                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
211                 aros_host_cpu="$host_cpu"
212                 ;;
213         esac
214         ;;
216     freebsd*)
217         aros_host_cc="$aros_host_cc $aros_host_cc_pipe -I/usr/local/include"
218         aros_host_make="gmake"
219         aros_host_arch="freebsd"
220         aros_host_cpu="i386"
222         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
224         dnl FreeBSD 5.x (and later) has changed the default object format.
225         dnl The double [[]] is necessary to get around m4's quoting rules.
226         case $host_os in
227             freebsd[[234]]*)
228                 aros_object_format="elf_i386"
229                 ;;
231             *)
232                 aros_object_format="elf_i386_fbsd"
233                 ;;
234         esac
236         ;;
238     darwin*)
239         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
240         aros_host_arch="darwin"
241         host_cc_elf=no
242         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
243         android_build_os="darwin-x86"
244         android_tool="android"
245         default_android_sdk="/android-sdk-mac_x86"
246         case "$host_cpu" in
247             *i?86*)
248                 aros_host_cpu="i386"
249                 ;;
250             *x86_64*)
251                 aros_host_cpu="x86_64"
252                 ;;
253             *powerpc*)
254                 aros_host_cpu="ppc"
255                 ;;
256             *)
257                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
258                 aros_host_cpu="$host_cpu"
259                 ;;
260         esac
262         aros_host_ldflags="$aros_host_ldflags -liconv"
264         ;;
266     dragonfly*)
267         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
268         aros_host_make="gmake"
269         aros_host_arch="dragonfly"
270         case $host_cpu in
271             *i?86*)
272                 aros_host_cpu="i386"
273                 ;;
274             *amd64*)
275                 aros_host_cpu="x86_64"
276                 ;;
277             *)
278                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
279                 aros_host_cpu="$host_cpu"
280                 ;;
281         esac
282         ;;
284     netbsd*)
285         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
286         aros_host_make="gmake"
287         aros_host_arch="netbsd"
288         case "$host_cpu" in
289             *i?86*)
290                 aros_host_cpu="i386"
291                 ;;
292             *m68k*)
293                 aros_host_cpu="m68k"
294                 ;;
295             *)
296                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
297                 aros_host_cpu="$host_cpu"
298                 ;;
299         esac    
300         aros_host_lib_suffix=".0.0"
301         ;;
303     openbsd*)
304         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
305         aros_host_make="gmake"
306         aros_host_arch="openbsd"
307         case "$host_cpu" in
308             *i?86*)
309                 aros_host_cpu="i386"
310                 ;;
311             *)
312                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
313                 aros_host_cpu="$host_cpu"
314                 ;;
315         esac
316         ;;
317         
318     solaris*)
319         aros_host_arch="solaris"
320         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
321         case "$host_cpu" in
322             *i?86*)
323                 aros_host_cpu="i386"
324                 ;;
325             *sparc*)
326                 aros_host_cpu="sparc"
327                 ;;
328             *)
329                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
330                 aros_host_cpu="$host_cpu"
331                 ;;
332         esac
333         ;;
335     morphos*)
336         aros_host_arch="morphos"
337         aros_host_cpu="ppc"
338         host_cc_elf=no
339         ;;
341     amiga*)
342         aros_host_arch="amiga"
343         host_cc_elf=no
344         SORT="/gg/bin/sort"
345         TEST="/gg/bin/test"
346         UNIQ="/gg/bin/uniq"
347         FOR="for"
348         TOUCH="/gg/bin/touch"
349         case "$host_cpu" in
350             *m68k*)
351                 aros_host_cpu="m68k"
352                 ;;
353             *powerpc*)
354                 aros_host_cpu="ppc"
355                 ;;
356             *)
357                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
358                 aros_host_cpu="$host_cpu"
359                 ;;
360         esac
361         ;;
363     cygwin*)
364         aros_host_arch="cygwin"
365         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
366         host_cc_elf=no
367         android_build_os="windows"
368         android_tool="android.bat"
369         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
371         case "$host_cpu" in
372             *i?86*)
373                 aros_host_cpu="i386"
374                 ;;
375             *)
376                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
377                 aros_host_cpu="$host_cpu"
378                 ;;
379         esac
380         ;;
382     mingw32*)
383         aros_host_arch="mingw32"
384         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
385         host_cc_elf=no
386         android_build_os="windows"
387         android_tool="android.bat"
388         default_android_sdk="/c/android-sdk-windows-1.6_r1"
390         case "$host_cpu" in
391         *i?86*)
392             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
393             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
394             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
395             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
397             AC_MSG_CHECKING([for Windows native gcc target])
398             host_cpu=`gcc -dumpmachine`
399             AC_MSG_RESULT($host_cpu)
400             ;;
402         esac
404         case "$host_cpu" in
405         *i?86*)
406             aros_host_cpu="i386"
407             ;;
409         mingw32*)
410             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
411             aros_host_cpu="i386"
412             ;;
414         *x86_64*)
415             aros_host_cpu="x86_64"
416             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
417             dnl directory, so we have to add it explicitly here.
418             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
419             ;;
421         *)
422             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
423             aros_host_cpu="$host_cpu"
424             ;;
425         esac
426         ;;
427     *)
428         AC_MSG_ERROR([Unsupported host architecture $host])
429         ;;
430 esac
432 AROS_PROG(aros_host_ar,[ar],[cr])
433 AROS_REQUIRED(ar,$aros_host_ar)
434 AROS_PROG(aros_host_ranlib,ranlib)
435 AROS_REQUIRED(ranlib,$aros_host_ranlib)
436 AROS_PROG(aros_host_strip,strip)
437 AROS_REQUIRED(strip,$aros_host_strip)
439 AROS_PROG(RM,[rm],[-rf])
440 AROS_REQUIRED(rm,$RM)
441 AROS_PROG(CP,[cp])
442 AROS_REQUIRED(cp,$CP)
443 AROS_PROG(MV,[mv])
444 AROS_REQUIRED(mv,$MV)
445 AROS_PROG(ECHO,[echo])
446 AROS_REQUIRED(echo,$ECHO)
447 AROS_PROG(MKDIR,[mkdir],[-p])
448 AROS_REQUIRED(mkdir,$MKDIR)
449 AROS_PROG(TOUCH,[touch])
450 AROS_REQUIRED(touch,$TOUCH)
451 AROS_PROG(SORT,[sort])
452 AROS_REQUIRED(sort,$SORT)
453 AROS_PROG(UNIQ,[uniq])
454 AROS_REQUIRED(uniq,$UNIQ)
455 AROS_PROG(NOP,[true])
456 AROS_REQUIRED(true,$NOP)
457 AROS_PROG(CAT,[cat])
458 AROS_REQUIRED(cat,$CAT)
459 AROS_PROG(BISON,[bison])
460 AROS_REQUIRED(bison,$BISON)
461 AROS_PROG(FLEX,[flex])
462 AROS_REQUIRED(flex,$FLEX)
463 AROS_PROG(PNGTOPNM,[pngtopnm])
464 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
465 AROS_PROG(PPMTOILBM,[ppmtoilbm])
466 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
467 AROS_PROG(SED,[sed])
468 AROS_REQUIRED(sed,$SED)
469 AROS_PROG(CHMOD,[chmod])
470 AROS_REQUIRED(chmod,$CHMOD)
471 AROS_PROG(PATCH,[patch])
472 AROS_REQUIRED(patch,$PATCH)
474 AM_PATH_PYTHON(2.5)
476 AC_CHECK_LIB(png, png_read_png)
477 AROS_REQUIRED(libpng, $ac_cv_lib_png_png_read_png)
479 AC_SUBST(FOR, for)
480 AC_SUBST(IF, if)
481 AC_SUBST(TEST, test)
482 AC_SUBST(CMP, cmp)
484 dnl ---------------------------------------------------------------------------
485 dnl Look for things about the host system, good for hosted targets.
486 dnl ---------------------------------------------------------------------------
488 # Check for some includes for the X11 HIDD and the kernel
489 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
490     sys/mmap.h sys/mman.h sysexits.h \
491     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
494 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
496 AC_HEADER_DIRENT
497 AC_HEADER_STAT
498 AC_HEADER_STDC
499 AC_HEADER_SYS_WAIT
500 AC_HEADER_TIME
501 AC_STRUCT_ST_BLKSIZE
502 AC_STRUCT_ST_BLOCKS
503 AC_STRUCT_ST_RDEV
504 AC_STRUCT_TM
505 AC_STRUCT_TIMEZONE
506 AC_TYPE_OFF_T
507 AC_TYPE_PID_T
508 AC_TYPE_SIZE_T
509 AC_TYPE_UID_T
511 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
513 # Look for some functions
514 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
515     clone kse_create rfork_thread thr_create sa_register \
516     getcontext makecontext setcontext sigaltstack swapcontext])
518 AC_FUNC_MMAP
521 dnl --------------------------------------------------------------------
522 dnl Target Configuration Section
523 dnl --------------------------------------------------------------------
525 dnl The target configuration section is responsible for setting up all
526 dnl the paths for includes, and tools required to build AROS to some
527 dnl particular target.
529 aros_config_cflags="-Wall -Werror-implicit-function-declaration -Wno-parentheses"
530 aros_config_aflags="-Wall -x assembler-with-cpp -c"
531 aros_config_ldflags=""
533 aros_shared_default=yes
535 aros_shared_cflags="-fPIC"
536 aros_shared_aflags=""
537 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
538 aros_kernel_ldflags="-Wl,-rpath,./lib"
540 aros_kernel_ar_flags="cr"
541 aros_target_ar_flags="cr"
542 aros_target_nm_flags="-C -ul"
543 aros_target_strip_flags="--strip-unneeded -R.comment"
545 aros_compiler_libs=
546 aros_arch_libs=
548 aros_target_genmap="-Wl,-Map -Xlinker"
550 # Native flavour stuff
551 aros_serial_debug="0"
553 # Palm native flavour stuff
554 aros_palm_debug_hack="0"
556 # Unix flavour stuff
557 aros_nesting_supervisor="0"
559 # Collect-aros stuff: "-ius" to ignore undefined symbols
560 ignore_undefined_symbols=""
562 # Check for X11 by default
563 need_x11="auto"
565 host_x_gfx=no
566 host_sdl_gfx=no
567 host_android_gfx=no
569 #-----------------------------------------------------------------------------
572 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
573 # it switched on by default, and we use the host compiler, so it compiles AROS
574 # code with this enabled resulting in link failures as we don't have support
575 # for it.
577 # We use two methods to disable it. For the host compiler (used to compile
578 # some hosted modules), we test to see if the compiler supports stack
579 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
580 # work on all platforms.
582 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
583 # (this is done unconditionally, as it should have no effect on compilers
584 # without the stack protection feature). This may be specific to the way that
585 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
586 # strong enough to disable it in a generic way though, so we'll live with it
587 # until another vendor ships GCC with it enabled in a different way, and deal
588 # with it then.
591 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
592 save_cflags="$CFLAGS"
593 CFLAGS="$CFLAGS -fno-stack-protector"
594 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
595 AC_MSG_RESULT($use_no_stack_protector)
596 if test "x-$use_no_stack_protector" = "x-yes" ; then
597     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
599 CFLAGS="$save_cflags"
601 #-----------------------------------------------------------------------------
603 # Disable pointer-signedness warnings if the compiler recognises the option
604 # (this only works for the host compiler at the moment)
606 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
607 save_cflags="$CFLAGS"
608 CFLAGS="$CFLAGS -Wno-pointer-sign"
609 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
610 AC_MSG_RESULT($use_no_sign_warning)
611 if test "x-$use_no_sign_warning" = "x-yes" ; then
612     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
614 CFLAGS="$save_cflags"
616 #-----------------------------------------------------------------------------
618 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
620 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
621 save_cflags="$CFLAGS"
622 CFLAGS="$CFLAGS -fgnu89-inline"
623 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
624 AC_MSG_RESULT($use_gnu89_inline)
625 if test "x-$use_gnu89_inline" = "x-yes" ; then
626     gnu89_inline="-fgnu89-inline"
628 CFLAGS="$save_cflags"
630 #-----------------------------------------------------------------------------
632 AC_MSG_CHECKING([for type of build])
633 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")
635 if test "$build_type" = "nightly"; then
636     build_type_string="NIGHTLY"
637 elif test "$build_type" = "snapshot"; then
638     build_type_string="SNAPSHOT"
639 elif test "$build_type" = "milestone"; then
640     build_type_string="MILESTONE"
641 elif test "$build_type" = "release"; then
642     build_type_string="RELEASE"
643 else
644     build_type_string="PERSONAL"
645     build_type="personal"
648 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
650 AC_MSG_RESULT($build_type)
652 #-----------------------------------------------------------------------------
653 all_debug_types="messages stack modules mungwall symbols"
655 AC_MSG_CHECKING([which debug types to enable])
656 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)]),
657  debug="$enableval",debug="")
659 if test "$debug" = "" -o "$debug" = "no"; then
660     debug="none"
661 elif test "$debug" = "yes"; then
662     debug="all"
665 if test "$debug" = "all" ; then
666     debug="messages stack modules symbols"
667     for d in $all_debug_types; do
668         export aros_${d}_debug="1"
669     done
670 else
671     for d in $all_debug_types; do
672         export aros_${d}_debug="0"
673     done
676 if test "$debug" != "none"; then
677     debug=`echo $debug | sed s/,/\ /g`
678     for d in $debug; do
679         found="0"
680         for d2 in $all_debug_types; do
681             if test "$d2" = "$d"; then
682                 found="1"
683                 break
684             fi
685         done
686         if test "$found" = "0"; then
687             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
688         fi
689         export aros_${d}_debug="1"
690     done
691     aros_debug="yes"
693 AC_MSG_RESULT($debug)
695 if test "$aros_messages_debug" = "1"; then
696     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
697 else
698     aros_messages_debug=""
700 if test "$aros_symbols_debug" = "1"; then
701     aros_symbols_debug="-g"
702 else
703     aros_symbols_debug=""
706 # These are the flags to pass when compiling debugged programs
707 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
708 aros_debug_aflags=""
709 aros_debug_ldflags="$aros_symbols_debug"
711 #-----------------------------------------------------------------------------
712 #   Checking for distcc and ccache.
714 #   Always apply the transforms in this particular order. Basically you should
715 #   always run 'ccache distcc compiler' in that order for the best performance.
717 AC_MSG_CHECKING([whether to enable distcc])
718 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
719 if test "$distcc" != "" -a "$distcc" != "no"; then
720     # AC_CHECK_PROG will print out the result in this case
721     AC_PATH_PROG(DISTCC,[distcc],distcc,)
722 else
723     AC_MSG_RESULT(no)
726 AC_MSG_CHECKING([whether to enable ccache])
727 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
728 if test "$ccache" != "" -a "$ccache" != "no"; then
729     # AC_CHECK_PROG will print out the result in this case
730     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
731 else
732     AC_MSG_RESULT(no)
735 #-----------------------------------------------------------------------------
736 AC_MSG_CHECKING([what specific host gcc version to use])
737 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="")
738 AC_MSG_RESULT($kernel_tool_version)
740 #-----------------------------------------------------------------------------
741 AC_MSG_CHECKING([what optimization flags to use])
742 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
743 if test "$optimization" = "unknown"; then
744     dnl default is -O2 for normal builds, -O0 for debug builds
745     if test "$debug" != "none"; then
746         optimization="-O0"
747     else
748         optimization="-O2"
749     fi
751 aros_optimization_cflags="$optimization"
752 AC_MSG_RESULT($optimization)
754 #-----------------------------------------------------------------------------
755 AC_MSG_CHECKING([what paranoia flags to use])
756 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[CC flags to enable paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
757 if test "$paranoia_flags" = "default"; then
758         paranoia_flags=""
759 else if test "$paranoia_flags" = "yes"; then
760         paranoia_flags="-Wall -Werror"
761 fi fi
762 AC_MSG_RESULT($paranoia_flags)
763 aros_config_cflags="$aros_config_cflags $paranoia_flags"
765 #-----------------------------------------------------------------------------
766 AC_MSG_CHECKING([what target variant to enable])
767 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
768 if test "$target_variant" = ""; then
769     aros_target_variant=""
770     aros_target_suffix=""
771     enableval="none"
772 else
773     aros_target_variant="$target_variant"
774     aros_target_suffix="-$target_variant"
776 AC_MSG_RESULT($enableval)
778 #-----------------------------------------------------------------------------
779 # Target-specific defaults. You can override then on a per-target basis.
781 # Bootloader name. Currently used by PC target.
782 target_bootloader="none"
783 ENABLE_EXECSMP=
785 #-----------------------------------------------------------------------------
786 # Additional options for some specific targets
788 case "$aros_target_variant" in
789 ios)
790     AC_MSG_CHECKING([XCode path])
791     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")
792     AC_MSG_RESULT($aros_xcode_path)
794     AC_MSG_CHECKING([what iOS SDK version to use])
795     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")
796     AC_MSG_RESULT($aros_sdk_version)
798     ;;
800 "android")
801     AC_MSG_CHECKING([Android SDK path])
802     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)
803     AC_MSG_RESULT($aros_android_sdk)
805     AC_MSG_CHECKING([Android NDK path])
806     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
807     AC_MSG_RESULT($aros_android_ndk)
809     AC_MSG_CHECKING([what Android SDK version to use])
810     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")
811     AC_MSG_RESULT($aros_sdk_version)
813     aros_android_level=android-$aros_sdk_version
814     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
815         echo "Platform $aros_android_level is not installed in your SDK"
816         echo "Use --with-sdk-version=<API level number> to select another platform version"
817         echo "You can check what plaform versions are installed in your SDK"
818         echo "by examining contents of $aros_android_sdk/platforms directory"
819         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
820     fi
822     export PATH="$aros_android_sdk/tools:$PATH"
823     AC_PATH_PROG(android_tool, $android_tool)
824     AROS_REQUIRED(android,$android_tool)
826     if test "$aros_android_ndk" != "none"; then
827         AC_MSG_CHECKING([what Android NDK version to use])
828         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")
829         AC_MSG_RESULT($aros_ndk_version)
830     fi
832     AC_PATH_PROG(ant, ant)
833     if test "$ant" = ""; then
834         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
835     fi
837     AC_MSG_CHECKING([Build debug or release apk])
838     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)
839     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
840         AC_MSG_ERROR([apk-version has to be release or debug])
841     fi
842     AC_MSG_RESULT($aros_android_antapk)
844     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
845     if test "$host_os" = "mingw32"; then
846         android_tool="cmd //c $android_tool"
847     fi
849     need_dlopen="no"
851     ;;
852 esac
854 #-----------------------------------------------------------------------------
855 # External toolchains
856 kernel_tool_prefix="none"
857 aros_tool_prefix="none"
858 elf_tool_prefix="${target_cpu}-elf-"
860 # This is the target configuration switch.
861 case "$target_os" in
862     linux*)
863         aros_target_arch="linux"
864         aros_target_family="unix"
865         case "$target_cpu" in
866             *m68k*)
867                 aros_target_cpu="m68k"
868                 aros_object_format="m68kelf"
869                 aros_flavour="emulcompat"
870                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
871                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
872                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
873                 gcc_target_cpu="mc68000"
874                 ;;
875             *i?86*)
876                 aros_target_cpu="i386"
877                 aros_object_format="elf_i386"
878                 aros_flavour="emulation"
879                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
880                 aros_kernel_ldflags="-Wl,-melf_i386"
881                 aros_nominal_depth=8
882                 gcc_target_cpu="i386"
883                 pci_hidd_target="hidd-pci-linux"
884                 android_tool_dir_prefix="x86"
885                 android_tool_prefix="i686-android-linux"
886                 android_ndk_arch="x86"
887                 ;;
888             *x86_64*)
889                 aros_target_cpu="x86_64"
890                 aros_object_format="elf_x86_64"
891                 aros_flavour="emulation"
892                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
893                 aros_config_cflags="$aros_config_cflags -mcmodel=large -mno-red-zone -fno-omit-frame-pointer"
894                 aros_nominal_depth=8
895                 pci_hidd_target="hidd-pci-linux"
896                 ;;
897             *powerpc*)
898                 aros_target_cpu="ppc"
899                 aros_object_format="elf32ppc"
900                 aros_flavour="emulation"
901                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
902                 aros_nominal_depth=8
903                 gcc_target_cpu="ppc"
904                 ;;
905 # TODO
906 # Same as powerpc, but I need this for the nightly build to work again.
907 # Actually, the nightly should be made working with powerpc target.
908 # That just was too much work for the moment, another week or two.
909             *ppc*)
910                 aros_target_cpu="ppc"
911                 aros_object_format="elf32ppc"
912                 aros_flavour="emulation"
913                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
914                 aros_nominal_depth=8
915                 gcc_target_cpu="ppc"
916                 ;;
917             *armhf*)
918                 aros_target_cpu="arm"
919                 target_cpu="arm"
920                 aros_object_format="armelf_aros"
921                 aros_flavour="emulation"
922                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
923                 gcc_target_cpu="arm"
924                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
925                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
926                 aros_arch_libs="-laeabi"
927                 gcc_default_float_abi="hard"
928                 android_tool_dir_prefix="arm-linux-androideabi"
929                 android_tool_prefix="arm-linux-androideabi"
930                 android_ndk_arch="arm"
931                 kernel_tool_prefix="arm-linux-gnueabihf-"
932                 ;;
933             *arm*)
934                 aros_target_cpu="arm"
935                 aros_object_format="armelf_aros"
936                 aros_flavour="emulation"
937                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
938                 gcc_target_cpu="arm"
939                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
940                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
941                 aros_arch_libs="-laeabi"
942                 android_tool_dir_prefix="arm-linux-androideabi"
943                 android_tool_prefix="arm-linux-androideabi"
944                 android_ndk_arch="arm"
945                 kernel_tool_prefix="arm-linux-gnueabi-"
946                 ;;
947             *)
948                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
949                 ;;
950         esac
951         case "$aros_target_variant" in
952             android)
954                 dnl Not all Linux CPUs are supported by Android
955                 if test "$android_ndk_arch" = ""; then
956                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
957                 fi
959                 aros_nominal_width=320
960                 aros_nominal_height=480
961                 if test "$aros_android_ndk" = "none"; then
962                     dnl Use standalone toolchain, don't adjust paths
963                     aros_kernel_cflags="-mandroid"
964                     aros_kernel_ldflags="-mandroid"
965                     CFLAGS="-mandroid"
966                 else
967                     dnl In Android NDK toolchains are placed in own directories,
968                     dnl but tool names are not suffixed with version 
969                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
970                     kernel_tool_version=""
971                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
972                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
973                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
974                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
975                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
976                 fi
977                 need_x11=no
978                 host_android_gfx=yes
979                 # Disable implicit PIC mode
980                 aros_target_cflags="$aros_target_cflags -fno-pic"
981                 kernel_tool_prefix="$android_tool_prefix-"
982             ;;
983         esac
984     ;;
986     pc)
987         aros_target_arch="pc"
988         aros_shared_default="no"
989         target_bootloader="grub2"
990         case "$target_cpu" in
991             *i?86*)
992                 aros_target_cpu="i386"
994                 dnl If somebody hasn't already set the target object
995                 dnl format, then use this value. Mostly to support
996                 dnl FreeBSD cross-compilation.
997                 dnl TODO: Remove when we always use our compiler.
999                 if test "$aros_object_format" = "" ; then
1000                     aros_object_format="elf_i386"
1001                 fi
1002                 aros_flavour="standalone"
1003                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1004                 aros_kernel_ldflags="-Wl,-melf_i386"
1005                 aros_nominal_width=640
1006                 aros_nominal_height=480
1007                 gcc_target_cpu="i386"
1008                 ;;
1009             *x86_64*)
1010                 aros_target_cpu="x86_64"
1011                 aros_serial_debug=1
1012                 if test "$aros_object_format" = "" ; then
1013                     aros_object_format="elf_x86_64"
1014                 fi
1015                 aros_flavour="standalone"
1016                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1017                 aros_config_cflags="$aros_config_cflags -mcmodel=large -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1018                 aros_kernel_ldflags=""
1019                 aros_nominal_width=640
1020                 aros_nominal_height=480
1021                 case "$aros_target_variant" in
1022                     smp)
1023                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1024                     ;;
1025                 esac
1026                 ;;
1027             *)
1028                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1029                 ;;
1030         esac
1031         ;;
1033     prep)
1034         aros_target_arch="prep"
1035         aros_shared_default="no"
1036         aros_target_cpu="ppc"
1037         aros_object_format="elf32ppc"
1038         aros_flavour="ppcnative"
1039         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1040         aros_kernel_ldflags=""
1041         aros_nominal_width=640
1042         aros_nominal_height=480
1043         gcc_target_cpu="ppc"
1044         ;;
1046     freebsd*)
1047         aros_target_arch="freebsd"
1048         aros_target_family="unix"
1049         aros_target_cpu="i386"
1050         aros_flavour="emulation"
1051         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1052         gcc_target_cpu="i386"
1054         aros_target_strip_flags="-x"
1055         ;;
1057     darwin*)
1058         aros_target_arch="darwin"
1059         aros_target_family="unix"
1060         aros_flavour="emulation"
1061         case "$target_cpu" in
1062             *i?86*)
1063                 aros_ios_platform="iPhoneSimulator"
1064                 aros_target_cpu="i386"
1065                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1066                 aros_kernel_ldflags=""
1067                 aros_macosx_version="10.4"
1068                 aros_nominal_depth=8
1069                 gcc_target_cpu="i386"
1070                 aros_object_format="elf_i386"
1071                 aros_kernel_ar_flags="-cr"
1072                 aros_target_strip_flags="-x"
1073                 kernel_tool_flags="-m32"
1074                 ;;
1075             *x86_64*)
1076                 aros_target_cpu="x86_64"
1077                 aros_object_format="elf_x86_64"
1078                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1079                 aros_macosx_version="10.6"
1080                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1081                 aros_kernel_cflags="-m64"
1082                 aros_kernel_ldflags="-m64"
1083                 aros_target_cflags="-mcmodel=large"
1084                 aros_nominal_depth=8
1085                 aros_kernel_ar="ar"
1086                 aros_kernel_ar_flags="-cr"
1087                 aros_kernel_ld="ld"
1088                 aros_kernel_as="as"
1089                 aros_kernel_ranlib="ranlib"
1090                 aros_kernel_nm="nm"
1091                 aros_kernel_strip="strip"
1092                 kernel_tool_prefix="i686-apple-darwin10-"
1093                 ;;
1094             *ppc*)
1095                 aros_target_cpu="ppc"
1096                 aros_object_format="elf32ppc"
1097                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1098                 aros_kernel_ldflags=""
1099                 aros_macosx_version="10.0"
1100                 aros_nominal_depth=8
1101                 gcc_target_cpu="ppc"
1102                 aros_kernel_ar="ar"
1103                 aros_kernel_ar_flags="-cr"
1104                 aros_kernel_ld="ld -arch ppc"
1105                 aros_kernel_as="as -arch ppc"
1106                 aros_kernel_ranlib="ranlib -arch ppc"
1107                 aros_kernel_nm="nm -arch ppc"
1108                 aros_kernel_strip="strip -arch ppc"
1109                 kernel_tool_prefix="powerpc-apple-darwin10-"
1110                 ;;
1111             *arm*)
1112                 aros_ios_platform="iPhoneOS"
1113                 aros_target_cpu="arm"
1114                 aros_object_format="armelf_aros"
1115                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1116                 aros_arch_libs="-laeabi"
1117                 aros_nominal_depth=8
1118                 gcc_target_cpu="arm"
1119                 aros_kernel_ar="ar"
1120                 aros_kernel_ar_flags="-cr"
1121                 aros_kernel_ld="ld -arch arm"
1122                 aros_kernel_ranlib="ranlib -arch arm"
1123                 kernel_tool_prefix="arm-apple-darwin10-" 
1124                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1125                 ;;
1126             *)
1127                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1128                 ;;
1129         esac
1130         case "$aros_target_variant" in
1131             ios)
1132                 aros_ios_version="3.0"
1133                 aros_nominal_width=320
1134                 aros_nominal_height=480
1135                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1136                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1137                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1138                 need_x11=no
1139                 # This is here because it may depend on iOS or SDK version
1140                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1141                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1142                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1143             ;;
1144             *)
1145                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1146                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1147             ;;
1148         esac
1149         ;;
1151     dragonfly*)
1152         aros_target_arch="dragonfly"
1153         aros_target_family="unix"
1154         aros_flavour="emulation"
1155         case "$target_cpu" in
1156             *i?86*)
1157                 aros_target_cpu="i386"
1158                 aros_object_format="elf_i386"
1159                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1160                 ;;
1161             *x86_64*)
1162                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1163                 aros_target_cpu="x86_64"
1164                 aros_object_format="elf_x86_64"
1165                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1166                 ;;
1167             *)
1168                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1169                 ;;
1170         esac
1171         ;;
1173     netbsd*)
1174         aros_target_arch="netbsd"
1175         aros_target_family="unix"
1176         case "$target_cpu" in
1177             *m68k*)
1178                 aros_target_cpu="m68k"
1179                 aros_object_format="m68kelf"
1180                 aros_flavour="emulcompat"
1181                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1182                 gcc_target_cpu="mc68000"
1183                 ;;
1184             *i?86*)
1185                 aros_target_cpu="i386"
1186                 aros_object_format="elf_i386"
1187                 aros_flavour="emulation"
1188                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1189                 aros_nominal_depth=8
1190                 gcc_target_cpu="i386"
1191                 ;;
1192             *)
1193                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1194                 ;;
1195         esac
1196         aros_target_genmap="-Wl,-M -Xlinker >"
1197         aros_flavour="emulation"
1198         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1199         ;;   
1201     openbsd*)
1202         aros_target_arch="openbsd"
1203         aros_target_family="unix"
1204         case "$target_cpu" in
1205             *i?86*)
1206                 aros_target_cpu="i386"
1207                 aros_object_format="elf_i386"
1208                 aros_flavour="emulation"
1209                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1210                 gcc_target_cpu="i386"
1211                 ;;
1212             *)
1213                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1214                 ;;
1215         esac
1216         aros_target_genmap="-Wl,-M -Xlinker >"
1217         aros_target_nm_flags="-u"
1218         aros_flavour="emulation"
1219         ;;
1221     solaris*)
1222         aros_target_arch="solaris"
1223         aros_target_family="unix"
1224         case "$target_cpu" in
1225            *i?86*)
1226                aros_target_cpu="i386"
1227                aros_object_format="elf_i386"
1228                aros_flavour="emulation"
1229                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1230                aros_nominal_depth=8
1231                gcc_target_cpu="i386"
1232                ;;
1233             *sparc*)
1234                 aros_target_cpu="sparc"
1235                 aros_object_format="elf_sparc"
1236                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1237                 gcc_target_cpu="sparc"
1238                 ;;
1239             *)
1240                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1241                 ;;
1242         esac
1243         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1244         aros_flavour="emulation"
1245         ;;
1247     morphos*)
1248         aros_target_arch="morphos"
1249         aros_shared_default="no"
1250         aros_target_cpu="ppc"
1251         aros_object_format="elf_ppc"
1252         aros_flavour="nativecompat"
1253         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1254         gcc_target_cpu="ppc"
1255         ;;
1257     sam440)
1258         aros_target_arch="sam440"
1259         aros_shared_default="no"
1260         aros_target_cpu="ppc"
1261         aros_object_format="elf32ppc"
1262         aros_flavour="ppcnative"
1263         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1264         aros_kernel_ldflags=""
1265         aros_nominal_width=1024
1266         aros_nominal_height=768
1267         aros_nominal_depth=24
1268         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1269         gcc_target_cpu="powerpc"
1270         ;;
1272     efika)
1273         aros_target_arch="efika"
1274         aros_shared_default="no"
1275         aros_target_cpu="arm"
1276         aros_object_format="armelf_aros"
1277         aros_flavour="standalone"
1278         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1279         aros_kernel_ldflags=""
1280         aros_nominal_width=1024
1281         aros_nominal_height=600
1282         aros_arch_libs="-laeabi"
1283         gcc_default_cpu="armv7-a"
1284         gcc_default_fpu="vfpv3"
1285         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1286         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1287         aros_optimization_cflags="$aros_optimization_cflags -Os"
1288         case "$target_cpu" in
1289             *armhf*)
1290                 gcc_default_float_abi="hard"
1291                 target_cpu=arm
1292                 aros_target_cpu=arm
1293                 ;;
1294             *arm*)
1295                 gcc_default_float_abi="softfp"
1296                 ;;
1297             *)
1298                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1299                 ;;
1300         esac
1301         ;;
1302         
1303     chrp)
1304         aros_target_arch="chrp"
1305         aros_shared_default="no"
1306         aros_target_cpu="ppc"
1307         aros_object_format="elf32ppc"
1308         aros_flavour="ppcnative"
1309         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1310         aros_kernel_ldflags=""
1311         aros_nominal_width=640
1312         aros_nominal_height=480
1313         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1314         gcc_target_cpu="powerpc"
1315         case "$aros_target_variant" in
1316             efika)
1317                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1318             ;;
1319         esac
1320         ;;
1322     r*pi)
1323         aros_flavour="standalone"
1324         aros_target_arch="raspi"
1325         aros_target_cpu="arm"
1326         aros_object_format="armelf_aros"
1327         aros_shared_default="no"
1328         aros_arch_libs="-laeabi"
1330         gcc_default_cpu="armv6zk"
1331         gcc_default_cpu_tune="arm1176jzf-s"
1333         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1334         aros_config_cflags="$aros_config_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1335         aros_config_aflags="$aros_config_aflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1336         aros_kernel_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1337         aros_target_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1338         case "$aros_target_variant" in
1339             smp)
1340                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1341             ;;
1342         esac
1343         ;;
1345     stm32f7_discovery)
1346         aros_flavour="standalone"
1347         aros_target_arch="stm32f7_discovery"
1348         aros_target_cpu="arm"
1349         aros_target_cpu_mode="thumb2"
1350         aros_object_format="armelf_aros"
1351         aros_shared_default="no"
1353         # stm32f7 has DSP opcode support
1354         gcc_default_cpu="armv7e-m"
1355         # gcc_default_cpu="armv7-m"
1356         gcc_default_cpu_tune="cortex-m7"
1357         gcc_default_fpu="fpv4-sp-d16"
1358         # GCC does not recognize fpv5-sp-d16 which should be the correct one to use, or not...
1359         # gcc_default_fpu="fpv5-sp-d16"
1360                 gcc_default_float_abi="hard"
1362         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1363         ;;
1365     amiga*)
1366         aros_target_arch="amiga"
1367         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1368         aros_shared_default="no"
1370         case "$target_cpu" in
1371             *m68k*)
1372                 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")
1373                 aros_enable_mmu=no
1374                 aros_target_cpu="m68k"
1375                 aros_object_format="m68kelf"
1376                 aros_flavour="standcompat"
1377                 gcc_target_cpu="m68000"
1378                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -Wno-volatile-register-var -DNOLIBINLINE"
1379                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1380                 aros_config_aflags="$aros_config_aflags"
1381                 aros_target_strip_flags="-R.comment --strip-debug"
1382                 aros_nominal_width=640
1383                 aros_nominal_height=256
1384                 aros_nominal_depth=2
1385                 ;;
1386             *ppc*)
1387                 aros_cpu="ppc"
1388                 aros_flavour="native"
1389                 gcc_target_cpu="ppc"
1390                 ;;
1391             *)
1392                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1393                 ;;
1394         esac
1395         ;;
1397     mingw*)
1398         aros_target_arch="mingw32"
1399         aros_shared_default="no"
1400         aros_flavour="emulation"
1401         aros_shared_cflags=""
1402         need_crosstools="yes"
1403         need_dlopen="no"
1404         rescomp="windres"
1405         case "$target_cpu" in
1406             *i?86*)
1407                 aros_target_cpu="i386"
1408                 aros_object_format="elf_i386"
1409                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1410                 aros_nominal_depth=8
1411                 gcc_target_cpu="i386"
1413                 kernel_tool_prefix="i386-mingw32-"
1414                 ;;
1415             *x86_64*)
1416                 aros_target_cpu="x86_64"
1417                 aros_object_format="elf_x86_64"
1418                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1419                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1420                 aros_nominal_depth=8
1421                 kernel_tool_prefix="x86_64-w64-mingw32-"
1422                 ;;
1423             *arm*)
1424                 aros_target_cpu="arm"
1425                 aros_object_format="armelf_aros"
1426                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1427                 aros_arch_libs="-laeabi"
1428                 aros_nominal_depth=8
1429                 gcc_target_cpu="arm"
1430                 gcc_default_float_abi="soft"
1431                 kernel_tool_prefix="arm-mingw32ce-"
1432                 aros_nominal_width=160
1433                 aros_nominal_height=160
1434                 ;;
1435             *)
1436                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1437                 ;;
1438         esac
1439         if test $host_os = "cygwin"; then
1440                 aros_kernel_cflags="-mno-cygwin"
1441         fi
1442     ;;
1443     pp*)
1444         aros_target_arch="pp"
1445         aros_shared_default="no"
1446         case "$target_cpu" in
1447             *m68k*)
1448                 aros_target_cpu="m68k"
1449                 aros_object_format="m68kelf"
1450                 aros_flavour="palmnative"
1451                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1452                 aros_nominal_width=160
1453                 aros_nominal_height=160
1454                 aros_nominal_depth=1
1455                 aros_target_ar_flags="cru"
1456                 aros_compiler_libs="-lgcc1"
1457                 aros_shared_default=no
1458                 aros_shared_cflags="-fpic"
1459                 aros_shared_aflags=""
1460                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1461                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1462                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1463                 aros_debug_aflags=""
1464                 aros_debug_ldflags="$aros_symbols_debug"
1465                 aros_mungwall_debug="0"
1466                 aros_modules_debug="0"
1467                 gcc_target_cpu="mc68000"
1468                 ignore_undefined_symbols="-ius"
1469                 ;;
1470            *)
1471                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1472                 ;;
1473         esac
1474         ;;
1476     mac*)
1477         aros_target_arch="mac"
1478         aros_shared_default="no"
1479         case "$target_cpu" in
1480             *m68k*)
1481                 aros_target_cpu="m68k"
1482                 aros_object_format="m68kelf"
1483                 aros_flavour="mac68knative"
1484                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1485                 aros_nominal_width=512
1486                 aros_nominal_height=384
1487                 aros_nominal_depth=8
1488                 aros_target_ar_flags="cru"
1489                 aros_compiler_libs="-lgcc1"
1490                 aros_shared_default=no
1491                 aros_shared_cflags="-fpic"
1492                 aros_shared_aflags=""
1493                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1494                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1495                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1496                 aros_debug_aflags=""
1497                 aros_debug_ldflags="$aros_symbols_debug"
1498                 aros_mungwall_debug="0"
1499                 aros_modules_debug="0"
1500                 gcc_target_cpu="mc68000"
1501                 ignore_undefined_symbols="-ius"
1502                 ;;
1503            *)
1504                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1505                 ;;
1506         esac
1507         ;;
1509     *)
1510         AC_MSG_ERROR([Unsupported target architecture $target])
1511         ;;
1512 esac
1514 #-----------------------------------------------------------------------------
1515 crosstools_guess="yes"
1516 aros_target_toolchain="no"
1517 aros_config_sysroot=""
1518 aros_kernel_sysroot=""
1520 AC_MSG_CHECKING([Kernel toolchain prefix])
1521 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1522 AC_MSG_RESULT($kernel_tool_prefix)
1524 AC_MSG_CHECKING([ELF toolchain prefix])
1525 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"
1526                                                  crosstools_guess="no"])
1527 AC_MSG_RESULT($elf_tool_prefix)
1529 AC_MSG_CHECKING([AROS toolchain prefix])
1530 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"
1531                 crosstools_guess="no"])
1532 if test "$aros_tool_prefix" = "yes" ; then
1533     aros_tool_prefix=$aros_target_cpu-aros-
1535 AC_MSG_RESULT($aros_tool_prefix)
1537 #-----------------------------------------------------------------------------
1538 #   Checking if we should build crosstools..
1539 AC_MSG_CHECKING([whether to build crosstools])
1540 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1541 AC_MSG_RESULT($crosstools)
1543 if test "${crosstools}" = "yes"; then
1544     if test "${crosstools_guess}" = "no"; then
1545         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1546     fi
1549 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1550     aros_target_toolchain="yes"
1553 AC_MSG_CHECKING([where to install the crosstools binaries])
1554 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])
1555 if test "x$aros_toolchain_install" = "x"; then
1556     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1557 else
1558     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1559     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1560     if test "$crosstools_guess" = "no" ; then
1561         aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1563         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1564             aros_kernel_sysroot = $aros_config_sysroot
1565         fi
1566     fi
1568 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1570 #-----------------------------------------------------------------------------
1571 AC_MSG_CHECKING([what specific target binutils version to use])
1572 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="")
1573 if test "$use_binutils_version" = ""; then
1574         target_binutils_version="$default_binutils_version"
1575 else
1576     target_binutils_version="$use_binutils_version"
1578 AC_MSG_RESULT($target_binutils_version)
1581 # Helper to identify gcc version
1582 AC_DEFUN([CROSS_GCC_VERSION], [
1583   target_gcc_version=""
1584   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1585     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}cpp -dumpversion`"
1586     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1587       ax_cv_gcc_version=""
1588     ])
1589   ])
1590   target_gcc_version=$ax_cv_gcc_version
1591   AC_SUBST([target_gcc_version])
1594 #-----------------------------------------------------------------------------
1595 AC_MSG_CHECKING([what specific target gcc version to use])
1596 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Use gcc-VERSION for building AROS]),use_gcc_version="$withval",use_gcc_version="")
1597 if test "$use_gcc_version" = ""; then
1598     if test "${crosstools}" = "no"; then
1599       if test "x$aros_toolchain_install" != "x"; then
1600           CROSS_GCC_VERSION
1601       fi
1602     fi
1603     if test "$use_gcc_version" = ""; then
1604         target_gcc_version="$default_gcc_version"
1605     fi
1606 else
1607     target_gcc_version="$use_gcc_version"
1609 AC_MSG_RESULT($target_gcc_version)
1611 GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1612 GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1613 GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1615 gcc_fix_bitfields="false"
1616 if test "$GCC_VERSION_MAJOR" -gt "4" ; then
1617     gcc_fix_bitfields="true"
1618 else
1619     if test "$GCC_VERSION_MAJOR" -gt "3" ; then
1620         if test "$GCC_VERSION_MINOR" -gt "6" ; then
1621             gcc_fix_bitfields="true"
1622         fi
1623     fi
1626 if test "$gcc_fix_bitfields" = "true" ; then
1627     case "$aros_target_cpu" in
1628     *x86_64*)
1629         aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1630         aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1631         ;;
1632     i386)
1633         aros_kernel_cflags="$aros_kernel_cflags -mno-ms-bitfields"
1634         aros_target_cflags="$aros_target_cflags -mno-ms-bitfields"
1635         ;;
1636     esac
1639 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1640 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1641 AC_MSG_RESULT($objc)
1642 if test "x$objc" = "xyes"; then
1643     objc_target="$objc"
1644 else
1645     objc_target="no-objc"
1648 AC_MSG_CHECKING([whether to enable Java suppport])
1649 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1650 AC_MSG_RESULT($java)
1651 if test "x$java" != "xno"; then
1652     java_target="$java"
1653 else
1654     java_target="no-java"
1657 spec_obj_format="-m $aros_object_format"
1658 # Now process extra architecture-specific options.
1659 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1660 # as well as floating-point ABI.
1661 case "$aros_target_cpu" in
1662 *x86_64*)
1663     dnl x86_64 can build 32 or 64bit code
1664     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1665     ;;
1666 arm*)
1667     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1668     if test "$gcc_default_cpu" = ""; then
1669         gcc_default_cpu="armv6"
1670     fi
1671     if test "$gcc_default_fpu" = ""; then
1672         gcc_default_fpu="vfp"
1673     fi
1674     if test "$gcc_default_float_abi" = ""; then
1675         if test "$target_cpu" = "armhf"; then
1676             gcc_default_float_abi="hard"
1677         else
1678             gcc_default_float_abi="softfp"
1679         fi
1680     fi
1682     AC_MSG_CHECKING([Which minimum CPU to use])
1683     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)
1684     AC_MSG_RESULT($aros_gcc_cpu)
1686     AC_MSG_CHECKING([Which minimum FPU to use])
1687     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)
1688     AC_MSG_RESULT($aros_gcc_fpu)
1690     AC_MSG_CHECKING([Which floating point ABI to use])
1691     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)
1692     AC_MSG_RESULT($aros_gcc_float_abi)
1694     AC_MSG_CHECKING([Which ARM mode to use])
1695     if test "$aros_target_cpu_mode" = ""; then
1696         aros_target_cpu_mode="arm32"
1697         AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
1698     else
1699         AC_MSG_RESULT([$aros_target_cpu_mode])
1700     fi
1702     case "$aros_target_cpu_mode" in
1703     arm32)
1704         gcc_default_mode="arm"
1705         aros_isa_flags="-m$gcc_default_mode -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1706     ;;
1707     arm64)
1708         AC_MSG_ERROR([ARM 64-bit mode is unsupported])
1709     ;;
1710     thumb)
1711         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1712     ;;
1713     thumb1)
1714         AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
1715     ;;
1716     thumb2)
1717         gcc_default_mode="thumb"
1718         # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
1719         aros_isa_flags="-m$gcc_default_mode -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1720     ;;
1721     *)
1722         AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
1723     ;;
1724     esac
1726     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1727     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1728     ;;
1729 i386)
1730     aros_isa_flags="-m32 -march=i486"
1731     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1732     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1733     ;;
1734 esac
1736 # Some architectures may need custom ELF specs.
1737 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1738     elf_specs_in=config/${aros_object_format}-specs.in
1739 else
1740     elf_specs_in=config/elf-specs.in
1743 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1744 # Since we override specs, we may need to put these defines there
1745 if test "$gcc_target_cpu" != ""; then
1746     gcc_target_cpu="-D__${gcc_target_cpu}__"
1749 AC_MSG_CHECKING([where to download sourcecode for external ports])
1750 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1751 if test "$with_portssrcdir" = "default"; then
1752     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1753 else
1754     AROS_PORTSSRCDIR="$with_portssrcdir"
1756 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1758 AC_MSG_CHECKING([which bootloader to use])
1759 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1760 if test "$target_bootloader" = "none"; then
1761     aros_target_bootloader=""
1762 else
1763     aros_target_bootloader="$target_bootloader"
1765 AC_MSG_RESULT($target_bootloader)
1767 AC_MSG_CHECKING([which icon-set to use])
1768 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1769 if test "$target_iconset" = "default"; then
1770     aros_target_iconset="Gorilla"
1771     target_iconset="default (Gorilla)"
1772 else
1773     aros_target_iconset="$target_iconset"
1775 AC_MSG_RESULT($target_iconset)
1777 AC_MSG_CHECKING([which GUI Theme to use])
1778 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1779 if test "$target_guitheme" = "default"; then
1780     aros_target_guitheme="Ice"
1781 else
1782     aros_target_guitheme="$target_guitheme"
1784 AC_MSG_RESULT($aros_target_guitheme)
1786 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1787 # for target code)
1788 cross_compiling=no
1790 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1791 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1792     cross_compiling=yes
1795 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1796 dnl The flag itself is given in per-target section, because some targets require to pass it
1797 dnl in a different manner, otherwise some tests fail.
1798 dnl TODO: Justify this.
1799 if test "$aros_host_cpu" == "x86_64" ; then
1800     if test "$aros_target_cpu" == "i386" ; then
1801         cross_compiling=no
1802     fi
1805 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1806     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1807     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1808     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1809     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1810     dnl used to build bootstrap for target arch in either case.
1811     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1812     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1813     dnl perhaps introducing aros_host_variant
1814     if test "$aros_host_arch" != "$aros_target_arch" ; then
1815         cross_compiling=yes
1816     fi
1817 else
1818     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1819     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1820     if test "$host_cc_elf" = "no" ; then
1821         cross_compiling=yes
1822     fi
1825 if test "$cross_compiling" = "no" ; then
1826     kernel_tool_prefix=""
1827     if test "$host_cc_elf" = "yes" ; then
1828         elf_tool_prefix=""
1829     fi
1832 if test "$kernel_tool_version" != ""; then
1833     kernel_tool_version="-$kernel_tool_version"
1836 #######################################################################
1837 ## Compute what toolchains to use, and their paths                   ##
1838 #######################################################################
1840 # This takes, as input:
1841 #   crosstools             {yes,no}
1842 #   kernel_tool_version    {"",[version]}
1843 #   target_tool_version    {"",[version]}
1844 #   kernel_tool_prefix     {none,[some-arch-os-]}
1845 #   target_tool_prefix     ${aros_target_cpu}-aros-
1846 #   aros_tool_prefix       ${aros_target_cpu}-aros-
1848 # The output is
1849 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1850 #        Where the 'kernel' binaries are located
1851 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1852 #        Where the 'target' binaries are located
1853 #        (not the symlink farm - that is aros_target_*!)
1855 # The rules are:
1856 #   if crosstools then
1857 #      if kernel_tools_prefix = "no-kernel-prefix-"
1858 #          aros_kernel_* = crosstools cc paths
1859 #          aros_kernel_cc = elf cc wrapper around crosstools cc
1860 #      else
1861 #          VALIDATE(${kernel_tools_prefix}*)
1862 #          aros_kernel_* = ${kernel_tools_prefix}*
1863 #          if ${kernel_tools_prefix}cc is an AROS gcc
1864 #              aros_kernel_cc = ${kernel_tools_prefix}cc
1865 #          else
1866 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
1867 #          fi
1868 #      fi
1870 #      orig_target_* = aros built crosstools
1871 #      orig_target_cc = elf cc wrapper around crosstools cc
1872 #   else
1873 #      VALIDATE(${kernel_tools_prefix}*)
1875 #      orig_target_* = aros_kernel_*
1876 #      if aros_kernel_cc is an AROS gcc
1877 #          orig_target_cc = aros_kernel_cc
1878 #      else
1879 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
1880 #      fi
1881 #   fi
1883 target_tool_prefix="${aros_target_cpu}-aros-"
1885 AC_MSG_CHECKING([which kernel tools])
1886 AC_MSG_RESULT([$kernel_tool_prefix]);
1888 if test "$kernel_tool_prefix" = "none" ; then
1889     dnl ELF wrapper can be used only for native bootstrap
1890     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1891         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
1892     fi
1893 else
1894     # Kernel tools required - find them
1895     # Note that 'normally', aros_kernel_* overrides will be
1896     # empty, unless specified in the per-arch sections above.
1897     if test "x$aros_kernel_cpp" = "x"; then
1898         aros_kernel_cpp=${kernel_tool_prefix}cpp
1899     fi
1900     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
1901     AROS_REQUIRED(cpp,$aros_kernel_cpp)
1902     if test "x$aros_kernel_cc" = "x"; then
1903         aros_kernel_cc=${kernel_tool_prefix}gcc
1904     fi
1905     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
1906     AROS_REQUIRED(cc,$aros_kernel_cc)
1907     if test "x$aros_kernel_cxx" = "x"; then
1908         aros_kernel_cxx=${kernel_tool_prefix}g++
1909     fi
1910     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
1911     # If it's set, make sure it's really there
1912     if test "x$aros_kernel_cxx" != "x" ; then
1913         AROS_REQUIRED(cxx,$aros_kernel_cxx)
1914     fi
1915     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
1916     AROS_REQUIRED(ld,$aros_kernel_ld)
1917     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
1918     AROS_REQUIRED(as,$aros_kernel_as)
1919     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
1920     AROS_REQUIRED(ar,$aros_kernel_ar)
1921     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1922     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
1923     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
1924     AROS_REQUIRED(nm,$aros_kernel_nm)
1925     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
1926     AROS_REQUIRED(strip,$aros_kernel_strip)
1928     # Objcopy and objdump are not required for the kernel
1929     # toolchain on many architectures.
1930     # So we'll look for them, but not make them strictly required.
1931     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
1932     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
1933     if test "x${crosstools}" != "xyes" ; then
1934         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
1935         AROS_REQUIRED(objdump,$aros_kernel_objdump)
1936     fi
1939 AC_MSG_CHECKING([which target tools to use])
1940 if test "$aros_target_toolchain" = "yes"; then
1941     AC_MSG_RESULT([$target_tool_prefix])
1942     # We are building AROS crosstools
1943     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
1944     orig_target_cc="${tmp_tool_prefix}gcc${target_tool_version}"
1945     orig_target_cxx="${tmp_tool_prefix}g++${target_tool_version}"
1946     orig_target_cpp="${tmp_tool_prefix}cpp"
1947     orig_target_ld="${tmp_tool_prefix}ld"
1948     orig_target_as="${tmp_tool_prefix}as"
1949     orig_target_ar="${tmp_tool_prefix}ar"
1950     orig_target_ranlib="${tmp_tool_prefix}ranlib"
1951     orig_target_nm="${tmp_tool_prefix}nm"
1952     orig_target_strip="${tmp_tool_prefix}strip"
1953     orig_target_objcopy="${tmp_tool_prefix}objcopy"
1954     orig_target_objdump="${tmp_tool_prefix}objdump"
1955 else
1956     # Determine whether AROS or ELF tools should be used
1957     if test "$aros_tool_prefix" = "none"; then
1958         aros_tool_prefix="${elf_tool_prefix}"
1959     fi
1961     AC_MSG_RESULT([$aros_tool_prefix])
1962     # We are *not* building AROS crosstools - use the AROS or ELF tools
1963     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}cpp${target_tool_version})
1964     AROS_REQUIRED(cpp,$orig_target_cpp)
1965     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}gcc${target_tool_version})
1966     AROS_REQUIRED(cc,$orig_target_cc)
1967     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}g++${target_tool_version})
1968     AROS_REQUIRED(cxx,$orig_target_cxx)
1969     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}ld)
1970     AROS_REQUIRED(ld,$orig_target_ld)
1971     AROS_TOOL_TARGET(orig_target_as,as,${aros_tool_prefix}as)
1972     AROS_REQUIRED(as,$orig_target_as)
1973     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}ar)
1974     AROS_REQUIRED(ar,$orig_target_ar)
1975     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}ranlib)
1976     AROS_REQUIRED(ranlib,$orig_target_ranlib)
1977     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}nm)
1978     AROS_REQUIRED(nm,$orig_target_nm)
1979     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}strip)
1980     AROS_REQUIRED(strip,$orig_target_strip)
1981     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}objcopy)
1982     AROS_REQUIRED(objcopy,$orig_target_objcopy)
1983     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}objdump)
1984     AROS_REQUIRED(objdump,$orig_target_objdump)
1987 if test "$kernel_tool_prefix" = "none" ; then
1988     # No kernel tools specified
1989     # Assume target tools == kernel tools with ELF wrapper
1990     aros_kernel_cc=$orig_target_cc
1991     aros_kernel_cxx=$orig_target_cxx
1992     aros_kernel_cpp=$orig_target_cpp
1993     aros_kernel_ld=$orig_target_ld
1994     aros_kernel_as=$orig_target_as
1995     aros_kernel_ar=$orig_target_ar
1996     aros_kernel_ranlib=$orig_target_ranlib
1997     aros_kernel_nm=$orig_target_nm
1998     aros_kernel_strip=$orig_target_strip
1999     aros_kernel_objcopy=$orig_target_objcopy
2000     aros_kernel_objdump=$orig_target_objdump
2001     use_kernel_cc_wrapper=yes
2004 # At this point, all aros_kernel_* and aros_target_* 
2005 # tools should be set up correctly
2007 CC="$aros_kernel_cc $kernel_tool_flags"
2008 CPP="$aros_kernel_cpp"
2010 #-----------------------------------------------------------------------------
2012 # Disable pointer-signedness warnings if the compiler recognises the option
2014 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
2015 save_cflags="$CFLAGS"
2016 if test "$crosstools" != "yes" ; then
2017     CFLAGS="$CFLAGS -Wno-pointer-sign"
2018     AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
2019 else
2020     # we do know it is supported for the smallest version of gcc we are going to build
2021     # we assume it's also supported by later versions
2022     use_no_sign_warning=yes
2024 AC_MSG_RESULT($use_no_sign_warning)
2025 if test "x-$use_no_sign_warning" = "x-yes" ; then
2026     aros_config_cflags="$aros_config_cflags -Wno-pointer-sign"
2028 CFLAGS="$save_cflags"
2030 #-----------------------------------------------------------------------------
2032 # Find all the tools we need to compile. This could be cross-compiling
2033 # though! If that is the case we use the GNU form of the target and
2034 # simply add this to the front of the binary name. This is rather simple,
2035 # but it should work under most circumstances.
2037 # The default tools are to use the same as the host, but only if the
2038 # host and target CPU are the same. With GCC this is normally enough.
2041 aros_cc_pre=""
2042 aros_shared_ld="$aros_host_ld"
2044 aros_target_mkdep="$aros_host_mkdep"
2046 # The default tools executables to be linked to.
2047 if test "$rescomp" != ""; then
2048     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2049     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2052 # Set up the sources for the symlink farm
2053 if test "$crosstools" = "yes"; then
2054     crosstools_target=tools-crosstools
2057 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2058 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2060 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2061 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2062 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
2063 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2064 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2065 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2066 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2068 # aros_cc_pre is a variable that is added to the front of the compiler name
2069 # in the generated aros-gcc shell script. We need this to enable the cache
2070 # to work across cleaned builds. Also, support DISTCC using the correct
2071 # environment variable.
2074 if test "x${DISTCC}" != "x" ; then
2075     if test "x${CCACHE}" != "x" ; then
2076         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2077     else
2078         aros_cc_pre="${DISTCC} "
2079     fi
2080 else
2081     if test "x${CCACHE}" != "x" ; then
2082         aros_cc_pre="${CCACHE} "
2083     fi
2086 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2087 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2088 AC_SUBST(aros_target_nix_ldflags,-nix)
2089 AC_SUBST(aros_target_detach_ldflags,-detach)
2090 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2092 # Target tools
2093 if test "$aros_target_toolchain" != "yes"; then
2094     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2095     if test "$GCC" = "yes"; then
2096         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2097     fi
2098 else
2099     # We do not know which gcc version we are going to build and what we need to know
2100     # here is different for different versions so this will be set later during the
2101     # build of crosstools.
2102     prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2103     aros_target_cc_path=@aros_target_cc_path@
2105 aros_target_cpp="${prefix}cpp"
2106 aros_target_cc="${prefix}gcc"
2107 aros_target_cxx="${prefix}g++"
2108 aros_target_as="${prefix}as"
2109 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld"
2110 aros_target_ar="${prefix}ar $aros_target_ar_flags"
2111 aros_target_objcopy="${prefix}objcopy"
2112 aros_target_objdump="${prefix}objdump"
2113 aros_target_ranlib="${prefix}ranlib $aros_target_ranlib_flags"
2114 aros_target_nm="${prefix}nm $aros_target_nm_flags"
2115 aros_target_strip="${prefix}strip"
2116 aros_plain_nm="${prefix}nm"
2117 aros_plain_ar="${prefix}ar"
2119 AC_ARG_ENABLE(includes,
2120 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2121 [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`])
2123 if test "$aros_kernel_includes" = ""; then
2124     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2125         aros_kernel_includes="-isystem $aros_target_incl"
2126     fi
2129 if test "$aros_kernel_includes" != "" ; then
2130     dnl find out about the kernel cc's include path
2131     AC_MSG_CHECKING([for the kernel compiler's include path])
2132     if test "$aros_kernel_cc_includes" = "" ; then
2133         # Try to guess where the directory is.
2134         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2135         if test -d $aros_kernel_cc_includes; then
2136             # Check if there is also an include-fixed directory and add it
2137             # to kernel compiler's include path as it may contain some of
2138             # the headers we need.
2139             if test -d "$aros_kernel_cc_includes"-fixed; then
2140                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2141             fi
2142             # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2143             case ${host_cpu} in
2144                 i[[3456]]86)
2145                     host_cpu_glibc=i386
2146                     ;;
2147                 *)
2148                     host_cpu_glibc=${host_cpu}
2149                     ;;
2150             esac
2151             if test -d "/usr/include/${host_cpu_glibc}-linux-gnu"; then
2152                 aros_kernel_cc_includes+=" -isystem /usr/include/${host_cpu_glibc}-linux-gnu"
2153             fi
2154         else
2155             # The directory doesn't exist, we need to do some more work.
2156             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2158             # These are the headers we're looking for.
2159             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2160                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2161                      zutil.h stdint.h"
2163             dirs=
2164             for h in $headers; do
2165                 # Which other headers are needed by each of the above?
2166                 deps=$(echo "#include <$h>" | \
2167                        $aros_kernel_cc -E -M - 2>/dev/null | \
2168                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2170                 # Copy all the needed headers to a directory beneath gendir.
2171                 for d in $deps; do
2172                     h=$(basename $d)
2173                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2174                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2175                     ! test -d $dir && mkdir -p $dir
2176                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2177                 done
2178             done            
2179         fi
2180     fi
2181     AC_MSG_RESULT($aros_kernel_cc_includes)
2182     # Adding -nostdinc to kernel includes as they are always used together.
2183     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2186 if test "$crosstools" != "yes"; then
2187     dnl find out about the target cc's include path
2188     AC_MSG_CHECKING([for the target compiler's include path])
2189     if test "$aros_target_cc_includes" = "" ; then
2190         #try to guess where the directory is
2191         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2192         if ! test -d $aros_target_cc_includes; then
2193             #the directory doesn't exist, we need to do some more work
2194             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2195         
2196             #these are the headers we're looking for
2197             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2198                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2199                     zutil.h"
2201             dirs=
2202             for h in $headers; do
2203                 #which other headers each of the above headers needs?
2204                 deps=$(echo "#include <$h>" | \
2205                     $orig_target_cc -E -M - 2>/dev/null | \
2206                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2207             
2208                 #copy all the needed headers to a directory beneath gendir
2209                 for d in $deps; do
2210                     h=$(basename $d)
2211                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2212                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2213                     ! test -d $dir && mkdir -p $dir
2214                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2215                 done
2216             done
2217         fi
2218     fi
2219     AC_MSG_RESULT($aros_target_cc_includes)
2220 else
2221     # We do not know which gcc version we are going to build and what we need to know
2222     # here is different for different versions so this will be set later during the
2223     # build of crosstools.
2224     aros_target_cc_includes=@aros_target_cc_includes@
2228 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2229 # On GCC >= 4.0 -iquote should be used
2232 save_cc="$CC"
2233 save_cflags="$CFLAGS"
2234 CFLAGS="-iquote."
2235 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2236 if test "x-$crosstools" != "x-yes"; then
2237     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2238 else
2239     # we do know it is supported for the smallest version of gcc we are going to build
2240     # we assume it's also supported by later versions
2241     has_iquote=yes
2243 AC_MSG_RESULT($has_iquote)
2244 if test "x-$has_iquote" = "x-yes" ; then
2245     host_cflags_iquote=-iquote
2246     host_cflags_iquote_end=
2247 else
2248     host_cflags_iquote=-I
2249     host_cflags_iquote_end=-I-
2251 kernel_cflags_iquote=$host_cflags_iquote
2252 kernel_cflags_iquote_end=$host_cflags_iquote_end
2253 if test "x-$cross_compiling" = "x-yes"; then
2254     CC="$aros_kernel_cc"
2255     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2256     if test "x-$crosstools" != "x-yes"; then
2257         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2258     else
2259         # we do know it is supported for the smallest version of gcc we are going to build
2260         # we assume it's also supported by later versions
2261         use_no_stack_protector=yes
2262     fi
2263     AC_MSG_RESULT($use_no_stack_protector)
2264     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2265     if test "x-$crosstools" != "x-yes"; then
2266         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2267     else
2268         # we do know it is supported for the smallest version of gcc we are going to build
2269         # we assume it's also supported by later versions
2270         has_iquote=yes
2271     fi
2272     AC_MSG_RESULT($has_iquote)
2273     if test "x-$has_iquote" = "x-yes" ; then
2274         kernel_cflags_iquote=-iquote
2275         kernel_cflags_iquote_end=
2276     else
2277         kernel_cflags_iquote=-I
2278         kernel_cflags_iquote_end=-I-
2279     fi
2281 aros_cflags_iquote=$kernel_cflags_iquote
2282 aros_cflags_iquote_end=$kernel_cflags_iquote_end
2283 if test "$orig_target_cc" != "$aros_kernel_cc"; then
2284     CC="$orig_target_cc"
2285     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2286     if test "x-$crosstools" != "x-yes"; then
2287         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2288     else
2289         # we do know it is supported for the smallest version of gcc we are going to build
2290         # we assume it's also supported by later versions
2291         has_iquote=yes
2292     fi
2293     AC_MSG_RESULT($has_iquote)
2294     if test "x-$has_iquote" = "x-yes" ; then
2295         aros_cflags_iquote=-iquote
2296         aros_cflags_iquote_end=
2297     else
2298         aros_cflags_iquote=-I
2299         aros_cflags_iquote_end=-I-
2300     fi
2302 if test "x-$use_no_stack_protector" = "x-yes" ; then
2303     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2306 #-----------------------------------------------------------------------------
2308 # Check if we can explicitly choose older version of symbol hashing
2310 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2311 CC="$aros_kernel_cc"
2312 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2313 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2314 AC_MSG_RESULT($use_hash_style)
2315 if test "x-$use_hash_style" = "x-yes" ; then
2316     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2318 CC="$save_cc"
2319 CFLAGS="$save_cflags"
2321 AC_SUBST(host_cflags_iquote)
2322 AC_SUBST(host_cflags_iquote_end)
2323 AC_SUBST(kernel_cflags_iquote)
2324 AC_SUBST(kernel_cflags_iquote_end)
2325 AC_SUBST(aros_cflags_iquote)
2326 AC_SUBST(aros_cflags_iquote_end)
2329 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2330 AC_MSG_CHECKING([for default resolution of WBScreen])
2331 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2332 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2333 if test "$resolution" = "yes" ; then
2334     resolution="none"
2336 if test "$resolution" = "no" ; then
2337     resolution="none"
2339 if test "$resolution" != "none" ; then
2340     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2341     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2342     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2344 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2345 aros_cv_nominal_width=$aros_nominal_width
2346 aros_cv_nominal_height=$aros_nominal_height
2347 aros_cv_nominal_depth=$aros_nominal_depth
2349 dnl See if the user wants the serial debug output for native flavour
2350 AC_MSG_CHECKING([if serial debug is enabled])
2351 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)
2352 if test "$aros_serial_debug" = 0 ; then
2353     serial_debug_forced=""
2354     if test "$serial_debug" = "yes" ; then
2355         serial_debug="1"
2356     fi
2357     if test "$serial_debug" = "no" ; then
2358         serial_debug="none"
2359     fi
2360 else
2361     serial_debug_forced="(forced)"
2362     serial_debug=$aros_serial_debug
2364 if test "$serial_debug" != "none" ; then
2365     aros_serial_debug=$serial_debug
2366     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2367 else
2368     AC_MSG_RESULT(no)
2371 dnl See if the user wants the palm debug output hack for palm native flavour
2372 AC_MSG_CHECKING([if palm debug hack is enabled])
2373 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")
2374 if test "$palm_debug_hack" = "yes" ; then
2375     aros_palm_debug_hack="1"
2377 AC_MSG_RESULT($palm_debug_hack)
2379 dnl See if dev wants the usb3.0 code
2380 AC_MSG_CHECKING([if usb3.0 code is enabled])
2381 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2382 if test "$usb30_code" = "yes" ; then
2383     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2384     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2386 AC_MSG_RESULT($usb30_code)
2388 dnl See if the user wants nesting supervisor activated for unix flavour
2389 AC_MSG_CHECKING([if nesting supervisor support is enabled])
2390 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")
2391 if test "$nesting_supervisor" = "yes" ; then
2392     aros_nesting_supervisor="1"
2394 AC_MSG_RESULT($nesting_supervisor)
2396 dnl See if the user wants to disable MMU support
2397 dnl This can be overriden on per-target basis,
2398 dnl set $aros_enable_mmu to "yes" or "no" to do this
2399 if test "$aros_enable_mmu" = "" ; then
2400     AC_MSG_CHECKING([if MMU support is enabled])
2401     dnl Enabled by default
2402     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2403     if test "$aros_enable_mmu" = "" ; then
2404         aros_enable_mmu="yes"
2405     fi
2406     AC_MSG_RESULT($aros_enable_mmu)
2408 if test "$aros_enable_mmu" = "no" ; then
2409     aros_enable_mmu="0"
2410 else
2411     aros_enable_mmu="1"
2413     
2415 dnl things specifically required for hosted flavours
2416 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2418     if test "x-$need_dlopen" != "x-no" ; then
2419       save_libs="$LIBS"
2420       LIBS=""
2421       dnl some kind of dynamic library access system is required for hostlib.resource
2422       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2423       if test "x-$have_dl" = "x-no" ; then
2424           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2425                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2426                                     have_dl="no")
2427       fi
2428       if test "x-$have_dl" = "x-no" ; then
2429           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2430       fi
2431       LIBS="$save_libs"
2432     fi
2435     dnl x11 hidd
2436     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2437                                            [build X11 hidd for hosted (default=auto)]),
2438                                            x11_hidd="$enableval",
2439                                            x11_hidd="$need_x11")
2440     case "x-$x11_hidd" in
2441         x-yes|x-no|x-auto)                 ;;
2442         *)                 x11_hidd="$need_x11" ;;
2443     esac
2445     ENABLE_X11=0
2447     dnl they want it
2448     if test "x-$x11_hidd" != "x-no" ; then
2450         dnl find x11 stuff
2451         AC_PATH_X
2453         x_cflags=
2454         for path in $x_libraries
2455         do
2456             x_cflags="$x_cflags -L$path"
2457         done
2459         for path in $x_includes
2460         do
2461             x_cflags="$x_cflags -I$path"
2462         done
2463         
2464         if test "x-$no_x" = "x-yes" ; then
2466             dnl didn't find it
2467             if test "x-$x11_hidd" != "x-auto" ; then
2468                 dnl and they explicitly asked for it, bail out
2469                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2470             fi
2471         
2472         else
2473             dnl found it, setup the metatarget
2474             host_x_gfx=yes
2475             ENABLE_X11=1
2477             dnl setup shared memory extensions
2478             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2479                                                   [use X11 shared memory (default=auto)]),
2480                                                   x11_hidd_shm="$enableval",
2481                                                   x11_hidd_shm="auto")
2482             case "x-$x11_hidd_shm" in
2483                 x-yes|x-no|x-auto)                     ;;
2484                 *)                 x11_hidd_shm="auto" ;;
2485             esac
2487             have_xshm=no
2489             dnl they want it
2490             if test "x-$x11_hidd_shm" != "x-no" ; then
2492                 dnl system shm headers
2493                 AC_CHECK_HEADERS(sys/ipc.h)
2494                 AC_CHECK_HEADERS(sys/shm.h)
2496                 dnl got them
2497                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2499                     dnl make sure X libs have shm functions
2500                     save_cflags="$CFLAGS"
2501                     CFLAGS="$CFLAGS $x_cflags"
2502                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2503                     CFLAGS="$save_cflags"
2504                 fi
2505             fi
2507             dnl detection done, prepare output
2508             if test "x-$have_xshm" = "x-yes" ; then
2509                 dnl we can do shm
2510                 DO_XSHM_SUPPORT="1"
2511             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2512                 dnl they explicitly asked for it, but we can't do it
2513                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2514             else
2515                 dnl otherwise just disable it
2516                 DO_XSHM_SUPPORT="0"
2517             fi
2519             
2520             dnl setup vidmode (fullscreen) extensions
2521             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2522                                                       [use X11 vidmode extension (default=auto)]),
2523                                                       x11_hidd_vidmode="$enableval",
2524                                                       x11_hidd_vidmode="auto")
2525             case "x-$x11_hidd_vidmode" in
2526                 x-yes|x-no|x-auto)                         ;;
2527                 *)                 x11_hidd_vidmode="auto" ;;
2528             esac
2530             have_vidmode=no
2532             dnl they want it
2533             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2535                 dnl make sure X libs have vidmode functions
2536                 save_cflags="$CFLAGS"
2537                 CFLAGS="$CFLAGS $x_cflags"
2538                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2539                 CFLAGS="$save_cflags"
2540             fi
2542             dnl detection done, prepare output
2543             if test "x-$have_vidmode" = "x-yes" ; then
2544                 dnl we can do vidmode
2545                 DO_VIDMODE_SUPPORT="1"
2546             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2547                 dnl they explicitly asked for it, but we can't do it
2548                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2549             else
2550                 dnl otherwise just disable it
2551                 DO_VIDMODE_SUPPORT="0"
2552             fi
2553         fi
2555         aros_host_x11_includes=$x_includes 
2556         aros_host_x11_libdirs=$x_libraries
2557     fi
2560     dnl sdl hidd
2561     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2562                                            [build SDL hidd for hosted (default=auto)]),
2563                                            sdl_hidd="$enableval",
2564                                            sdl_hidd="auto")
2565     case "x-$sdl_hidd" in
2566         x-yes|x-no|x-auto)                 ;;
2567         *)                 sdl_hidd="auto" ;;
2568     esac
2570     dnl they want it
2571     if test "x-$sdl_hidd" != "x-no" ; then
2573         dnl find sdl
2574         SDL_VERSION=1.2.5
2575         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2576             [have_sdl="no"])
2578         if test "x-$have_sdl" != "x-yes" ; then
2580             dnl didn't find it
2581             if test "x-$sdl_hidd" != "x-auto" ; then
2582                 dnl and they explicitly asked for it, bail out
2583                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2584             fi
2586         else
2587             dnl found it, enable the build
2588             host_sdl_gfx=yes
2589             aros_host_sdl_cflags=$SDL_CFLAGS
2590             aros_host_sdl_libs=$SDL_LIBS
2591         fi
2592     fi
2597 dnl See if the user wants dbus.library
2598 AC_MSG_CHECKING([if building of dbus.library is enabled])
2599 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2600 if test "$dbus" = "yes" ; then
2601     ENABLE_DBUS=1
2602     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2603     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2604     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2605     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2606 else
2607     ENABLE_DBUS=0
2609 AC_MSG_RESULT($dbus)
2611 if test "$use_kernel_cc_wrapper" = "yes" ; then
2612     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc"
2615 dnl --------------------------------------------------------------------
2616 dnl Configuration Output Section
2617 dnl --------------------------------------------------------------------
2619 # Generic
2620 AC_SUBST(aros_arch)
2621 AC_SUBST(aros_cpu)
2622 AC_SUBST(aros_flavour)
2623 AC_SUBST(aros_flavour_uc)
2624 AC_SUBST(aros_target_toolchain)
2625 AC_SUBST(aros_build_host)
2626 AC_SUBST(AROS_BUILDDIR)
2627 AC_SUBST(AROS_BUILDDIR_UNIX)
2628 AC_SUBST(SRCDIR)
2629 AC_SUBST(AROS_CROSSTOOLSDIR)
2630 AC_SUBST(AROS_PORTSSRCDIR)
2632 # Compatability with other Amiga-like operation systems
2633 AC_SUBST(aros_amigaos_compliance)
2635 # Host related
2636 AC_SUBST(aros_cc_pre)
2637 AC_SUBST(aros_host_strip)
2638 AC_SUBST(aros_host_arch)
2639 AC_SUBST(aros_host_cpu)
2640 AC_SUBST(aros_host_cpp)
2641 AC_SUBST(aros_host_cc)
2642 AC_SUBST(aros_host_cxx)
2643 AC_SUBST(aros_host_ar)
2644 AC_SUBST(aros_host_ranlib)
2645 AC_SUBST(aros_host_ld)
2646 AC_SUBST(aros_host_make)
2647 AC_SUBST(aros_host_cflags)
2648 AC_SUBST(aros_host_cxxflags)
2649 AC_SUBST(gnu89_inline)
2650 AC_SUBST(aros_host_ldflags)
2651 AC_SUBST(aros_host_debug)
2652 AC_SUBST(aros_host_mkdep)
2653 AC_SUBST(aros_host_mkargs)
2654 AC_SUBST(aros_host_exe_suffix)
2655 AC_SUBST(aros_host_lib_suffix)
2656 AC_SUBST(aros_tools_dir)
2657 AC_SUBST(aros_host_aclocal)
2658 AC_SUBST(aros_host_autoconf)
2659 AC_SUBST(aros_host_autoheader)
2660 AC_SUBST(aros_host_automake)
2661 AC_SUBST(ant)
2663 # Target Related
2664 AC_SUBST(aros_target_guitheme)
2665 AC_SUBST(aros_target_iconset)
2666 AC_SUBST(aros_target_bootloader)
2667 AC_SUBST(aros_target_arch)
2668 AC_SUBST(aros_target_family)
2669 AC_SUBST(aros_target_cpu)
2670 AC_SUBST(aros_target_cpu_mode)
2671 AC_SUBST(aros_target_variant)
2672 AC_SUBST(aros_target_suffix)
2673 AC_SUBST(aros_target_ar)
2674 AC_SUBST(aros_target_ranlib)
2675 AC_SUBST(aros_plain_nm)
2676 AC_SUBST(aros_plain_ar)
2677 AC_SUBST(aros_kernel_ar)
2678 AC_SUBST(aros_kernel_ranlib)
2679 AC_SUBST(orig_target_cc)
2680 AC_SUBST(aros_target_cc)
2681 AC_SUBST(aros_kernel_cc)
2682 AC_SUBST(orig_target_cxx)
2683 AC_SUBST(aros_target_cxx)
2684 AC_SUBST(aros_kernel_cxx)
2685 AC_SUBST(orig_target_cpp)
2686 AC_SUBST(aros_target_cpp)
2687 AC_SUBST(aros_kernel_cpp)
2688 AC_SUBST(orig_target_as)
2689 AC_SUBST(aros_target_as)
2690 AC_SUBST(aros_kernel_as)
2691 AC_SUBST(orig_target_ld)
2692 AC_SUBST(aros_target_ld)
2693 AC_SUBST(aros_kernel_ld)
2694 AC_SUBST(aros_target_cc_includes)
2695 AC_SUBST(aros_target_cc_path)
2696 AC_SUBST(aros_target_objdump)
2697 AC_SUBST(aros_target_objcopy)
2698 AC_SUBST(aros_target_strip)
2699 AC_SUBST(aros_target_nm)
2700 AC_SUBST(aros_kernel_rescomp)
2701 AC_SUBST(aros_shared_default)
2702 AC_SUBST(aros_shared_ld)
2703 AC_SUBST(aros_object_format)
2704 AC_SUBST(spec_obj_format)
2705 AC_SUBST(aros_compiler_libs)
2706 AC_SUBST(aros_arch_libs)
2708 AC_SUBST(aros_shared_cflags)
2709 AC_SUBST(aros_shared_aflags)
2710 AC_SUBST(aros_shared_ldflags)
2712 AC_SUBST(aros_config_sysroot)
2713 AC_SUBST(aros_config_cflags)
2714 AC_SUBST(aros_config_aflags)
2715 AC_SUBST(aros_config_ldflags)
2717 AC_SUBST(aros_kernel_sysroot)
2718 AC_SUBST(aros_kernel_cflags)
2719 AC_SUBST(aros_kernel_includes)
2720 AC_SUBST(aros_kernel_objcflags)
2721 AC_SUBST(aros_kernel_ldflags)
2722 AC_SUBST(aros_target_cflags)
2723 AC_SUBST(aros_debug_cflags)
2724 AC_SUBST(aros_debug_aflags)
2725 AC_SUBST(aros_debug_ldflags)
2726 AC_SUBST(aros_target_genmap)
2727 AC_SUBST(aros_target_strip_flags)
2728 AC_SUBST(aros_optimization_cflags)
2729 AC_SUBST(aros_isa_flags)
2731 AC_SUBST(crosstools_target)
2732 AC_SUBST(crosstools_cxx_target)
2734 # Hosted Graphics Related
2735 AC_SUBST(host_x_gfx)
2736 AC_SUBST(host_sdl_gfx)
2737 AC_SUBST(host_android_gfx)
2739 AC_SUBST(pci_hidd_target)
2741 AC_SUBST(aros_nominal_width)
2742 AC_SUBST(aros_nominal_height)
2743 AC_SUBST(aros_nominal_depth)
2744 AC_SUBST(DO_XSHM_SUPPORT)
2745 AC_SUBST(DO_VIDMODE_SUPPORT)
2747 AC_SUBST(aros_host_x11_includes)
2748 AC_SUBST(aros_host_x11_libdirs)
2749 AC_SUBST(aros_host_sdl_cflags)
2750 AC_SUBST(aros_host_sdl_libs)
2752 # Native version related
2753 AC_SUBST(aros_serial_debug)
2754 AC_SUBST(ENABLE_EXECSMP)
2756 # Palm native version related
2757 AC_SUBST(aros_palm_debug_hack)
2759 # Unix/Hosted version related
2760 AC_SUBST(aros_nesting_supervisor)
2762 # MMU related
2763 AC_SUBST(aros_enable_mmu)
2765 # Apple iOS related
2766 AC_SUBST(aros_ios_platform)
2767 AC_SUBST(aros_ios_version)
2768 AC_SUBST(aros_ios_sdk)
2770 # ARM default GCC target related
2771 AC_SUBST(gcc_default_cpu)
2772 AC_SUBST(gcc_default_cpu_tune)
2773 AC_SUBST(gcc_default_fpu)
2774 AC_SUBST(gcc_default_float_abi)
2775 AC_SUBST(gcc_default_mode)
2777 # Android related
2778 AC_SUBST(android_tool)
2779 AC_SUBST(aros_android_level)
2780 AC_SUBST(aros_android_antapk)
2782 # DBUS related
2783 AC_SUBST(ENABLE_DBUS)
2784 AC_SUBST(DBUS_CFLAGS)
2785 AC_SUBST(DBUS_LIBFLAGS)
2786 AC_SUBST(KERNEL_DBUS_KOBJ)
2787 AC_SUBST(KERNEL_DBUS_INCLUDES)
2789 #X11 related
2790 AC_SUBST(ENABLE_X11)
2792 # Debug related
2793 AC_SUBST(aros_debug)
2794 AC_SUBST(aros_mungwall_debug)
2795 AC_SUBST(aros_stack_debug)
2796 AC_SUBST(aros_modules_debug)
2798 # Collect-aros stuff: "-ius" to ignore undefined symbols
2799 AC_SUBST(ignore_undefined_symbols)
2801 # C compiler related
2802 AC_SUBST(gcc_target_cpu)
2803 AC_SUBST(target_binutils_version)
2804 AC_SUBST(target_gcc_version)
2806 #ObjC compiler related
2807 AC_SUBST(objc_target)
2809 #Java related
2810 AC_SUBST(java_target)
2812 # USB3.0 code
2813 AC_SUBST(aros_usb30_code)
2815 dnl Prepare for output, make up all the generated patches
2816 case "$aros_flavour" in
2817 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2818                 aros_flavour="emulation" ;;
2819 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2820                 aros_flavour="emulation" ;;
2821 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2822                 aros_flavour="standalone";;
2823 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2824                 aros_flavour="standalone";;
2825 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2826                 aros_flavour="native" ;;
2827 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2828                 aros_flavour="native" ;;
2829 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2830                 aros_flavour="linklib" ;;
2831 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2832                 aros_flavour="palmnative" ;;
2833 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2834                 aros_flavour="mac68knative" ;;
2835 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2836                 aros_flavour="ppcnative" ;;
2837 esac
2839 if test ! -d ${aros_inc_dir} ; then
2840     ${MKDIR} ${aros_inc_dir}
2842 if test ! -d ${aros_geninc_dir} ; then
2843     ${MKDIR} ${aros_geninc_dir}
2845 if test ! -d ${aros_hostcfg_dir} ; then
2846     ${MKDIR} ${aros_hostcfg_dir}
2848 if test ! -d ${aros_targetcfg_dir} ; then
2849     ${MKDIR} ${aros_targetcfg_dir}
2851 if test ! -d ${aros_tools_dir} ; then
2852     ${MKDIR} ${aros_tools_dir}
2854 if test ! -d ${aros_scripts_dir} ; then
2855     ${MKDIR} ${aros_scripts_dir}
2858 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2860 # Generic build tools (metamake, etc)
2861 AC_CONFIG_COMMANDS([genmf-executable-support],
2862     [chmod a+x ${aros_tools_dir}/genmf.py],
2863     [aros_tools_dir=${aros_tools_dir}]
2865 AC_CONFIG_FILES(
2866     Makefile
2867     config/make.cfg
2868     ${aros_inc_dir}/config.h:config/config.h.in
2869     ${aros_geninc_dir}/config.h:config/config.h.in
2870     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2871     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2872     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
2873     mmake.config
2874     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2875     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2876     tools/collect-aros/env.h
2879 # Binutils
2880 AC_CONFIG_COMMANDS([binutils-support],
2881     [
2882         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2883         mkdir -p $prefix
2884         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2886         chmod a+x ${prefix2}-ld
2888         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
2889         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
2890         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
2891         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
2892         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
2893         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
2894         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
2895     ],
2896     [
2897         aros_host_exe_suffix=${aros_host_exe_suffix}
2898         aros_tools_dir=${aros_tools_dir}
2899         aros_target_cpu=${aros_target_cpu}
2900         aros_target_arch=${aros_target_arch}
2901         aros_target_suffix=${aros_target_suffix}
2902         orig_target_nm=${orig_target_nm}
2903         orig_target_as=${orig_target_as}
2904         orig_target_ar=${orig_target_ar}
2905         orig_target_ranlib=${orig_target_ranlib}
2906         orig_target_objdump=${orig_target_objdump}
2907         orig_target_objcopy=${orig_target_objcopy}
2908         orig_target_strip=${orig_target_strip}
2909         aros_kernel_ld=${aros_kernel_ld}
2910     ]
2912 AC_CONFIG_FILES(
2913     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
2916 # Bare Elf support script and spec
2917 if test "${use_kernel_cc_wrapper}" = "yes"; then
2918     AC_CONFIG_COMMANDS([elf-compiler-support],
2919         [
2920             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2921             mkdir -p $prefix
2922             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
2924             chmod a+x ${prefix2}-gcc
2926             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
2927         ],
2928         [
2929             aros_host_exe_suffix=${aros_host_exe_suffix}
2930             aros_tools_dir=${aros_tools_dir}
2931             aros_target_cpu=${aros_target_cpu}
2932             aros_target_arch=${aros_target_arch}
2933             aros_target_suffix=${aros_target_suffix}
2934             aros_kernel_ld=${aros_kernel_ld}
2935         ]
2936     )
2937     AC_CONFIG_FILES(
2938         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
2939         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
2940     )
2943 # Host compiler support scripts and spec
2944 if test "${aros_target_toolchain}" = "no"; then
2945     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
2946         [
2947             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2948             mkdir -p $prefix
2949             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2951             chmod a+x ${prefix2}-gcc ${prefix2}-g++ ${prefix2}-cpp
2952         ],
2953         [
2954             aros_host_exe_suffix=${aros_host_exe_suffix}
2955             aros_tools_dir=${aros_tools_dir}
2956             aros_target_cpu=${aros_target_cpu}
2957             aros_target_arch=${aros_target_arch}
2958             aros_target_suffix=${aros_target_suffix}
2959         ]
2960     )
2961     AC_CONFIG_FILES(
2962         ${aros_targetcfg_dir}/specs:config/specs.in
2963         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-cpp:scripts/aros-cpp.in
2964         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
2965         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-g++:scripts/aros-g++.in
2966     )
2969 # Android support
2970 if test "$aros_target_variant" == "android"; then
2971     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
2974 # cmake helper
2975 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
2977 AC_OUTPUT
2979 dnl This is in order to not define SHARED_CFLAGS sometimes
2980 dnl We don't always do aros_shared_ar, aros_shared_cflags
2982 #XXX compatability...
2983 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
2985 if test -n "$aros_shared_cflags" ; then
2986     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
2987     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg