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