fix debug
[AROS.git] / configure.in
blob32bfabd1966864077cb02d3e93762c671a27ffd6
1 dnl Copyright © 1997-2014, 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_default_wbwidth=800
78 aros_default_wbheight=600
79 aros_default_wbdepth=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"
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 #-----------------------------------------------------------------------------
567 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
568 # it switched on by default, and we use the host compiler, so it compiles AROS
569 # code with this enabled resulting in link failures as we don't have support
570 # for it.
572 # We use two methods to disable it. For the host compiler (used to compile
573 # some hosted modules), we test to see if the compiler supports stack
574 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
575 # work on all platforms.
577 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
578 # (this is done unconditionally, as it should have no effect on compilers
579 # without the stack protection feature). This may be specific to the way that
580 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
581 # strong enough to disable it in a generic way though, so we'll live with it
582 # until another vendor ships GCC with it enabled in a different way, and deal
583 # with it then.
586 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
587 save_cflags="$CFLAGS"
588 CFLAGS="$CFLAGS -fno-stack-protector"
589 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
590 AC_MSG_RESULT($use_no_stack_protector)
591 if test "x-$use_no_stack_protector" = "x-yes" ; then
592     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
594 CFLAGS="$save_cflags"
596 #-----------------------------------------------------------------------------
598 # Disable pointer-signedness warnings if the compiler recognises the option
599 # (this only works for the host compiler at the moment)
601 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
602 save_cflags="$CFLAGS"
603 CFLAGS="$CFLAGS -Wno-pointer-sign"
604 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
605 AC_MSG_RESULT($use_no_sign_warning)
606 if test "x-$use_no_sign_warning" = "x-yes" ; then
607     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
609 CFLAGS="$save_cflags"
611 #-----------------------------------------------------------------------------
613 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
615 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
616 save_cflags="$CFLAGS"
617 CFLAGS="$CFLAGS -fgnu89-inline"
618 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
619 AC_MSG_RESULT($use_gnu89_inline)
620 if test "x-$use_gnu89_inline" = "x-yes" ; then
621     gnu89_inline="-fgnu89-inline"
623 CFLAGS="$save_cflags"
625 #-----------------------------------------------------------------------------
627 AC_MSG_CHECKING([for type of build])
628 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")
630 if test "$build_type" = "nightly"; then
631     build_type_string="NIGHTLY"
632 elif test "$build_type" = "snapshot"; then
633     build_type_string="SNAPSHOT"
634 elif test "$build_type" = "milestone"; then
635     build_type_string="MILESTONE"
636 elif test "$build_type" = "release"; then
637     build_type_string="RELEASE"
638 else
639     build_type_string="PERSONAL"
640     build_type="personal"
643 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
645 AC_MSG_RESULT($build_type)
647 #-----------------------------------------------------------------------------
648 all_debug_types="messages stack modules mungwall symbols"
650 AC_MSG_CHECKING([which debug types to enable])
651 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)]),
652  debug="$enableval",debug="")
654 if test "$debug" = "" -o "$debug" = "no"; then
655     debug="none"
656 elif test "$debug" = "yes"; then
657     debug="all"
660 if test "$debug" = "all" ; then
661     debug="messages stack modules symbols"
662     for d in $all_debug_types; do
663         export aros_${d}_debug="1"
664     done
665 else
666     for d in $all_debug_types; do
667         export aros_${d}_debug="0"
668     done
671 if test "$debug" != "none"; then
672     debug=`echo $debug | sed s/,/\ /g`
673     for d in $debug; do
674         found="0"
675         for d2 in $all_debug_types; do
676             if test "$d2" = "$d"; then
677                 found="1"
678                 break
679             fi
680         done
681         if test "$found" = "0"; then
682             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
683         fi
684         export aros_${d}_debug="1"
685     done
686     aros_debug="yes"
688 AC_MSG_RESULT($debug)
690 if test "$aros_messages_debug" = "1"; then
691     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
692 else
693     aros_messages_debug=""
695 if test "$aros_symbols_debug" = "1"; then
696     aros_symbols_debug="-g"
697 else
698     aros_symbols_debug=""
701 # These are the flags to pass when compiling debugged programs
702 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
703 aros_debug_aflags=""
704 aros_debug_ldflags="$aros_symbols_debug"
706 #-----------------------------------------------------------------------------
707 #   Checking for distcc and ccache.
709 #   Always apply the transforms in this particular order. Basically you should
710 #   always run 'ccache distcc compiler' in that order for the best performance.
712 AC_MSG_CHECKING([whether to enable distcc])
713 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
714 if test "$distcc" != "" -a "$distcc" != "no"; then
715     # AC_CHECK_PROG will print out the result in this case
716     AC_PATH_PROG(DISTCC,[distcc],distcc,)
717 else
718     AC_MSG_RESULT(no)
721 AC_MSG_CHECKING([whether to enable ccache])
722 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
723 if test "$ccache" != "" -a "$ccache" != "no"; then
724     # AC_CHECK_PROG will print out the result in this case
725     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
726 else
727     AC_MSG_RESULT(no)
730 #-----------------------------------------------------------------------------
731 AC_MSG_CHECKING([what specific host gcc version to use])
732 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="")
733 AC_MSG_RESULT($kernel_tool_version)
735 #-----------------------------------------------------------------------------
736 AC_MSG_CHECKING([what optimization flags to use])
737 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
738 if test "$optimization" = "unknown"; then
739     dnl default is -O2 for normal builds, -O0 for debug builds
740     if test "$debug" != "none"; then
741         optimization="-O0"
742     else
743         optimization="-O2"
744     fi
746 aros_optimization_cflags="$optimization"
747 AC_MSG_RESULT($optimization)
749 #-----------------------------------------------------------------------------
750 AC_MSG_CHECKING([what paranoia flags to use])
751 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=FLAGS],[CC flags to enable paranoia]),[paranoia_flags="$withval"],[paranoia_flags="default"])
752 if test "$paranoia_flags" = "default"; then
753         paranoia_flags=""
754 else if test "$paranoia_flags" = "yes"; then
755         paranoia_flags="-Wall -Werror"
756 fi fi
757 AC_MSG_RESULT($paranoia_flags)
758 aros_config_cflags="$aros_config_cflags $paranoia_flags"
760 #-----------------------------------------------------------------------------
761 AC_MSG_CHECKING([what target variant to enable])
762 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="")
763 if test "$target_variant" = ""; then
764     aros_target_variant=""
765     aros_target_suffix=""
766     enableval="none"
767 else
768     aros_target_variant="$target_variant"
769     aros_target_suffix="-$target_variant"
771 AC_MSG_RESULT($enableval)
773 #-----------------------------------------------------------------------------
774 # Target-specific defaults. You can override then on a per-target basis.
776 # Bootloader name. Currently used by PC target.
777 target_bootloader="none"
779 #-----------------------------------------------------------------------------
780 # Additional options for some specific targets
782 case "$aros_target_variant" in
783 ios)
784     AC_MSG_CHECKING([XCode path])
785     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")
786     AC_MSG_RESULT($aros_xcode_path)
788     AC_MSG_CHECKING([what iOS SDK version to use])
789     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")
790     AC_MSG_RESULT($aros_sdk_version)
792     ;;
794 "android")
795     AC_MSG_CHECKING([Android SDK path])
796     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)
797     AC_MSG_RESULT($aros_android_sdk)
799     AC_MSG_CHECKING([Android NDK path])
800     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
801     AC_MSG_RESULT($aros_android_ndk)
803     AC_MSG_CHECKING([what Android SDK version to use])
804     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")
805     AC_MSG_RESULT($aros_sdk_version)
807     aros_android_level=android-$aros_sdk_version
808     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
809         echo "Platform $aros_android_level is not installed in your SDK"
810         echo "Use --with-sdk-version=<API level number> to select another platform version"
811         echo "You can check what plaform versions are installed in your SDK"
812         echo "by examining contents of $aros_android_sdk/platforms directory"
813         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
814     fi
816     export PATH="$aros_android_sdk/tools:$PATH"
817     AC_PATH_PROG(android_tool, $android_tool)
818     AROS_REQUIRED(android,$android_tool)
820     if test "$aros_android_ndk" != "none"; then
821         AC_MSG_CHECKING([what Android NDK version to use])
822         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")
823         AC_MSG_RESULT($aros_ndk_version)
824     fi
826     AC_PATH_PROG(ant, ant)
827     if test "$ant" = ""; then
828         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
829     fi
831     AC_MSG_CHECKING([Build debug or release apk])
832     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)
833     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
834         AC_MSG_ERROR([apk-version has to be release or debug])
835     fi
836     AC_MSG_RESULT($aros_android_antapk)
838     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
839     if test "$host_os" = "mingw32"; then
840         android_tool="cmd //c $android_tool"
841     fi
843     need_dlopen="no"
845     ;;
846 esac
848 #-----------------------------------------------------------------------------
849 # External toolchains
850 kernel_tool_prefix="none"
851 aros_tool_prefix="none"
852 elf_tool_prefix="${target_cpu}-elf-"
854 # This is the target configuration switch.
855 case "$target_os" in
856     linux*)
857         aros_target_arch="linux"
858         aros_target_family="unix"
859         case "$target_cpu" in
860             *m68k*)
861                 aros_target_cpu="m68k"
862                 aros_object_format="m68kelf"
863                 aros_flavour="emulcompat"
864                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
865                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
866                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
867                 gcc_target_cpu="mc68000"
868                 ;;
869             *i?86*)
870                 aros_target_cpu="i386"
871                 aros_object_format="elf_i386"
872                 aros_flavour="emulation"
873                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
874                 aros_kernel_ldflags="-Wl,-melf_i386"
875                 aros_default_wbdepth=8
876                 gcc_target_cpu="i386"
877                 pci_hidd_target="hidd-pci-linux"
878                 android_tool_dir_prefix="x86"
879                 android_tool_prefix="i686-android-linux"
880                 android_ndk_arch="x86"
881                 ;;
882             *x86_64*)
883                 aros_target_cpu="x86_64"
884                 aros_object_format="elf_x86_64"
885                 aros_flavour="emulation"
886                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
887                 aros_config_cflags="$aros_config_cflags -mno-red-zone -fno-omit-frame-pointer"
888                 aros_default_wbdepth=8
889                 pci_hidd_target="hidd-pci-linux"
890                 ;;
891             *powerpc*)
892                 aros_target_cpu="ppc"
893                 aros_object_format="elf32ppc"
894                 aros_flavour="emulation"
895                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
896                 aros_default_wbdepth=8
897                 gcc_target_cpu="ppc"
898                 ;;
899 # TODO
900 # Same as powerpc, but I need this for the nightly build to work again.
901 # Actually, the nightly should be made working with powerpc target.
902 # That just was too much work for the moment, another week or two.
903             *ppc*)
904                 aros_target_cpu="ppc"
905                 aros_object_format="elf32ppc"
906                 aros_flavour="emulation"
907                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
908                 aros_default_wbdepth=8
909                 gcc_target_cpu="ppc"
910                 ;;
911             *armhf*)
912                 aros_target_cpu="arm"
913                 target_cpu="arm"
914                 aros_object_format="armelf_aros"
915                 aros_flavour="emulation"
916                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
917                 gcc_target_cpu="arm"
918                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
919                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
920                 aros_arch_libs="-laeabi"
921                 gcc_default_float_abi="hard"
922                 android_tool_dir_prefix="arm-linux-androideabi"
923                 android_tool_prefix="arm-linux-androideabi"
924                 android_ndk_arch="arm"
925                 kernel_tool_prefix="arm-linux-gnueabihf-"
926                 ;;
927             *arm*)
928                 aros_target_cpu="arm"
929                 aros_object_format="armelf_aros"
930                 aros_flavour="emulation"
931                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
932                 gcc_target_cpu="arm"
933                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -fno-omit-frame-pointer"
934                 aros_config_aflags="$aros_config_aflags -fno-strict-aliasing"
935                 aros_arch_libs="-laeabi"
936                 android_tool_dir_prefix="arm-linux-androideabi"
937                 android_tool_prefix="arm-linux-androideabi"
938                 android_ndk_arch="arm"
939                 kernel_tool_prefix="arm-linux-gnueabi-"
940                 ;;
941             *)
942                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
943                 ;;
944         esac
945         case "$aros_target_variant" in
946             android)
948                 dnl Not all Linux CPUs are supported by Android
949                 if test "$android_ndk_arch" = ""; then
950                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
951                 fi
953                 aros_default_wbwidth=320
954                 aros_default_wbheight=480
955                 if test "$aros_android_ndk" = "none"; then
956                     dnl Use standalone toolchain, don't adjust paths
957                     aros_kernel_cflags="-mandroid"
958                     aros_kernel_ldflags="-mandroid"
959                     CFLAGS="-mandroid"
960                 else
961                     dnl In Android NDK toolchains are placed in own directories,
962                     dnl but tool names are not suffixed with version 
963                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
964                     kernel_tool_version=""
965                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
966                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
967                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
968                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
969                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
970                 fi
971                 need_x11=no
972                 unixgfx_hidd_target=kernel-hidd-androidgfx
973                 # Disable implicit PIC mode
974                 aros_target_cflags="$aros_target_cflags -fno-pic"
975                 kernel_tool_prefix="$android_tool_prefix-"
976             ;;
977         esac
978     ;;
980     pc)
981         aros_target_arch="pc"
982         aros_shared_default="no"
983         target_bootloader="grub2"
984         case "$target_cpu" in
985             *i?86*)
986                 aros_target_cpu="i386"
988                 dnl If somebody hasn't already set the target object
989                 dnl format, then use this value. Mostly to support
990                 dnl FreeBSD cross-compilation.
991                 dnl TODO: Remove when we always use our compiler.
993                 if test "$aros_object_format" = "" ; then
994                     aros_object_format="elf_i386"
995                 fi
996                 aros_flavour="standalone"
997                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
998                 aros_kernel_ldflags="-Wl,-melf_i386"
999                 aros_default_wbwidth=640
1000                 aros_default_wbheight=480
1001                 gcc_target_cpu="i386"
1002                 ;;
1003             *x86_64*)
1004                 aros_target_cpu="x86_64"
1005                 aros_serial_debug=1
1006                 if test "$aros_object_format" = "" ; then
1007                     aros_object_format="elf_x86_64"
1008                 fi
1009                 aros_flavour="standalone"
1010                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1011                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone -fno-omit-frame-pointer"
1012                 aros_kernel_ldflags=""
1013                 aros_default_wbwidth=640
1014                 aros_default_wbheight=480
1015                 ;;
1016             *)
1017                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1018                 ;;
1019         esac
1020         ;;
1022     prep)
1023         aros_target_arch="prep"
1024         aros_shared_default="no"
1025         aros_target_cpu="ppc"
1026         aros_object_format="elf32ppc"
1027         aros_flavour="ppcnative"
1028         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1029         aros_kernel_ldflags=""
1030         aros_default_wbwidth=640
1031         aros_default_wbheight=480
1032         gcc_target_cpu="ppc"
1033         ;;
1035     freebsd*)
1036         aros_target_arch="freebsd"
1037         aros_target_family="unix"
1038         aros_target_cpu="i386"
1039         aros_flavour="emulation"
1040         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1041         gcc_target_cpu="i386"
1043         aros_target_strip_flags="-x"
1044         ;;
1046     darwin*)
1047         aros_target_arch="darwin"
1048         aros_target_family="unix"
1049         aros_flavour="emulation"
1050         case "$target_cpu" in
1051             *i?86*)
1052                 aros_ios_platform="iPhoneSimulator"
1053                 aros_target_cpu="i386"
1054                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1055                 aros_kernel_ldflags=""
1056                 aros_macosx_version="10.4"
1057                 aros_default_wbdepth=8
1058                 gcc_target_cpu="i386"
1059                 aros_object_format="elf_i386"
1060                 aros_kernel_ar_flags="-cr"
1061                 aros_target_strip_flags="-x"
1062                 kernel_tool_flags="-m32"
1063                 ;;
1064             *x86_64*)
1065                 aros_target_cpu="x86_64"
1066                 aros_object_format="elf_x86_64"
1067                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1068                 aros_macosx_version="10.6"
1069                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1070                 aros_kernel_cflags="-m64"
1071                 aros_kernel_ldflags="-m64"
1072                 aros_target_cflags="-mcmodel=large"
1073                 aros_default_wbdepth=8
1074                 aros_kernel_ar="ar"
1075                 aros_kernel_ar_flags="-cr"
1076                 aros_kernel_ld="ld"
1077                 aros_kernel_as="as"
1078                 aros_kernel_ranlib="ranlib"
1079                 aros_kernel_nm="nm"
1080                 aros_kernel_strip="strip"
1081                 kernel_tool_prefix="i686-apple-darwin10-"
1082                 ;;
1083             *ppc*)
1084                 aros_target_cpu="ppc"
1085                 aros_object_format="elf32ppc"
1086                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1087                 aros_kernel_ldflags=""
1088                 aros_macosx_version="10.0"
1089                 aros_default_wbdepth=8
1090                 gcc_target_cpu="ppc"
1091                 aros_kernel_ar="ar"
1092                 aros_kernel_ar_flags="-cr"
1093                 aros_kernel_ld="ld -arch ppc"
1094                 aros_kernel_as="as -arch ppc"
1095                 aros_kernel_ranlib="ranlib -arch ppc"
1096                 aros_kernel_nm="nm -arch ppc"
1097                 aros_kernel_strip="strip -arch ppc"
1098                 kernel_tool_prefix="powerpc-apple-darwin10-"
1099                 ;;
1100             *arm*)
1101                 aros_ios_platform="iPhoneOS"
1102                 aros_target_cpu="arm"
1103                 aros_object_format="armelf_aros"
1104                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1105                 aros_arch_libs="-laeabi"
1106                 aros_default_wbdepth=8
1107                 gcc_target_cpu="arm"
1108                 aros_kernel_ar="ar"
1109                 aros_kernel_ar_flags="-cr"
1110                 aros_kernel_ld="ld -arch arm"
1111                 aros_kernel_ranlib="ranlib -arch arm"
1112                 kernel_tool_prefix="arm-apple-darwin10-" 
1113                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1114                 ;;
1115             *)
1116                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1117                 ;;
1118         esac
1119         case "$aros_target_variant" in
1120             ios)
1121                 aros_ios_version="3.0"
1122                 aros_default_wbwidth=320
1123                 aros_default_wbheight=480
1124                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1125                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1126                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1127                 need_x11=no
1128                 # This is here because it may depend on iOS or SDK version
1129                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1130                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1131                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1132             ;;
1133             *)
1134                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1135                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1136             ;;
1137         esac
1138         ;;
1140     dragonfly*)
1141         aros_target_arch="dragonfly"
1142         aros_target_family="unix"
1143         aros_flavour="emulation"
1144         case "$target_cpu" in
1145             *i?86*)
1146                 aros_target_cpu="i386"
1147                 aros_object_format="elf_i386"
1148                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1149                 ;;
1150             *x86_64*)
1151                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1152                 aros_target_cpu="x86_64"
1153                 aros_object_format="elf_x86_64"
1154                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1155                 ;;
1156             *)
1157                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1158                 ;;
1159         esac
1160         ;;
1162     netbsd*)
1163         aros_target_arch="netbsd"
1164         aros_target_family="unix"
1165         case "$target_cpu" in
1166             *m68k*)
1167                 aros_target_cpu="m68k"
1168                 aros_object_format="m68kelf"
1169                 aros_flavour="emulcompat"
1170                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1171                 gcc_target_cpu="mc68000"
1172                 ;;
1173             *i?86*)
1174                 aros_target_cpu="i386"
1175                 aros_object_format="elf_i386"
1176                 aros_flavour="emulation"
1177                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1178                 aros_default_wbdepth=8
1179                 gcc_target_cpu="i386"
1180                 ;;
1181             *)
1182                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1183                 ;;
1184         esac
1185         aros_target_genmap="-Wl,-M -Xlinker >"
1186         aros_flavour="emulation"
1187         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1188         ;;   
1190     openbsd*)
1191         aros_target_arch="openbsd"
1192         aros_target_family="unix"
1193         case "$target_cpu" in
1194             *i?86*)
1195                 aros_target_cpu="i386"
1196                 aros_object_format="elf_i386"
1197                 aros_flavour="emulation"
1198                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1199                 gcc_target_cpu="i386"
1200                 ;;
1201             *)
1202                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1203                 ;;
1204         esac
1205         aros_target_genmap="-Wl,-M -Xlinker >"
1206         aros_target_nm_flags="-u"
1207         aros_flavour="emulation"
1208         ;;
1210     solaris*)
1211         aros_target_arch="solaris"
1212         aros_target_family="unix"
1213         case "$target_cpu" in
1214            *i?86*)
1215                aros_target_cpu="i386"
1216                aros_object_format="elf_i386"
1217                aros_flavour="emulation"
1218                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1219                aros_default_wbdepth=8
1220                gcc_target_cpu="i386"
1221                ;;
1222             *sparc*)
1223                 aros_target_cpu="sparc"
1224                 aros_object_format="elf_sparc"
1225                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1226                 gcc_target_cpu="sparc"
1227                 ;;
1228             *)
1229                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1230                 ;;
1231         esac
1232         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
1233         aros_flavour="emulation"
1234         ;;
1236     morphos*)
1237         aros_target_arch="morphos"
1238         aros_shared_default="no"
1239         aros_target_cpu="ppc"
1240         aros_object_format="elf_ppc"
1241         aros_flavour="nativecompat"
1242         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1243         gcc_target_cpu="ppc"
1244         ;;
1246     sam440)
1247         aros_target_arch="sam440"
1248         aros_shared_default="no"
1249         aros_target_cpu="ppc"
1250         aros_object_format="elf32ppc"
1251         aros_flavour="ppcnative"
1252         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1253         aros_kernel_ldflags=""
1254         aros_default_wbwidth=1024
1255         aros_default_wbheight=768
1256         aros_default_wbdepth=24
1257         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
1258         gcc_target_cpu="powerpc"
1259         ;;
1261     efika)
1262         aros_target_arch="efika"
1263         aros_shared_default="no"
1264         aros_target_cpu="arm"
1265         aros_object_format="armelf_aros"
1266         aros_flavour="standalone"
1267         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1268         aros_kernel_ldflags=""
1269         aros_default_wbwidth=1024
1270         aros_default_wbheight=600
1271         aros_arch_libs="-laeabi"
1272         gcc_default_cpu="armv7-a"
1273         gcc_default_fpu="vfpv3"
1274         aros_config_cflags="$aros_config_cflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1275         aros_config_aflags="$aros_config_aflags -mtune=cortex-a8 -fno-strict-aliasing -fno-asynchronous-unwind-tables"
1276         aros_optimization_cflags="$aros_optimization_cflags -Os"
1277         case "$target_cpu" in
1278             *armhf*)
1279                 gcc_default_float_abi="hard"
1280                 target_cpu=arm
1281                 aros_target_cpu=arm
1282                 ;;
1283             *arm*)
1284                 gcc_default_float_abi="softfp"
1285                 ;;
1286             *)
1287                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1288                 ;;
1289         esac
1290         ;;
1291         
1292     chrp)
1293         aros_target_arch="chrp"
1294         aros_shared_default="no"
1295         aros_target_cpu="ppc"
1296         aros_object_format="elf32ppc"
1297         aros_flavour="ppcnative"
1298         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1299         aros_kernel_ldflags=""
1300         aros_default_wbwidth=640
1301         aros_default_wbheight=480
1302         aros_config_cflags="$aros_config_cflags -mno-toc -fno-asynchronous-unwind-tables"    
1303         gcc_target_cpu="powerpc"
1304         case "$aros_target_variant" in
1305             efika)
1306                 aros_config_cflags="$aros_config_cflags -DBIG_ENDIAN_OHCI=1 -mcpu=603e"
1307             ;;
1308         esac
1309         ;;
1311     r*pi)
1312         aros_flavour="standalone"
1313         aros_target_arch="raspi"
1314         aros_target_cpu="arm"
1315         aros_object_format="armelf_aros"
1316         aros_shared_default="no"
1317         aros_arch_libs="-laeabi"
1319         gcc_default_cpu="armv6zk"
1320         gcc_default_cpu_tune="arm1176jzf-s"
1322         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1323         aros_config_cflags="$aros_config_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1324         aros_config_aflags="$aros_config_aflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1325         aros_kernel_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1326         aros_target_cflags="$aros_kernel_cflags -marm -Wno-error -fno-asynchronous-unwind-tables -fno-exceptions"
1327         ;;
1329     sun4i)
1330         aros_flavour="standalone"
1331         aros_target_arch="sun4i"
1332         aros_target_cpu="arm"
1333         aros_object_format="armelf_aros"
1334         aros_shared_default="no"
1335         aros_arch_libs="-laeabi"
1337                 gcc_default_cpu="armv7-a"
1338         gcc_default_fpu="neon"
1339         gcc_default_cpu_tune="cortex-a8"
1340                 gcc_default_float_abi="hard"
1342         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1343         aros_optimization_cflags=""
1344         aros_config_cflags="$aros_config_cflags -mcpu=cortex-a8 -mtune=cortex-a8 -fno-strict-aliasing"
1345         aros_config_aflags="$aros_config_aflags -mcpu=cortex-a8 -mtune=cortex-a8 -fno-strict-aliasing"
1346         ;;
1348     amiga*)
1349         aros_target_arch="amiga"
1350         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1351         aros_shared_default="no"
1353         case "$target_cpu" in
1354             *m68k*)
1355                 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")
1356                 aros_enable_mmu=no
1357                 aros_target_cpu="m68k"
1358                 aros_object_format="m68kelf"
1359                 aros_flavour="standcompat"
1360                 gcc_target_cpu="m68000"
1361                 aros_config_cflags="$aros_config_cflags -fno-strict-aliasing -ffreestanding -fomit-frame-pointer -fbuiltin -Wno-volatile-register-var -DNOLIBINLINE"
1362                 aros_optimization_cflags="$aros_optimization_cflags -Os"
1363                 aros_config_aflags="$aros_config_aflags"
1364                 aros_target_strip_flags="-R.comment --strip-debug"
1365                 aros_default_wbwidth=640
1366                 aros_default_wbheight=256
1367                 aros_default_wbdepth=2
1368                 ;;
1369             *ppc*)
1370                 aros_cpu="ppc"
1371                 aros_flavour="native"
1372                 gcc_target_cpu="ppc"
1373                 ;;
1374             *)
1375                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1376                 ;;
1377         esac
1378         ;;
1380     mingw*)
1381         aros_target_arch="mingw32"
1382         aros_shared_default="no"
1383         aros_flavour="emulation"
1384         aros_shared_cflags=""
1385         need_crosstools="yes"
1386         need_dlopen="no"
1387         rescomp="windres"
1388         case "$target_cpu" in
1389             *i?86*)
1390                 aros_target_cpu="i386"
1391                 aros_object_format="elf_i386"
1392                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1393                 aros_default_wbdepth=8
1394                 gcc_target_cpu="i386"
1396                 kernel_tool_prefix="i386-mingw32-"
1397                 ;;
1398             *x86_64*)
1399                 aros_target_cpu="x86_64"
1400                 aros_object_format="elf_x86_64"
1401                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1402                 aros_config_cflags="$aros_config_cflags -fno-omit-frame-pointer"
1403                 aros_default_wbdepth=8
1404                 kernel_tool_prefix="x86_64-w64-mingw32-"
1405                 ;;
1406             *arm*)
1407                 aros_target_cpu="arm"
1408                 aros_object_format="armelf_aros"
1409                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1410                 aros_arch_libs="-laeabi"
1411                 aros_default_wbdepth=8
1412                 gcc_target_cpu="arm"
1413                 gcc_default_float_abi="soft"
1414                 kernel_tool_prefix="arm-mingw32ce-"
1415                 aros_default_wbwidth=160
1416                 aros_default_wbheight=160
1417                 ;;
1418             *)
1419                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1420                 ;;
1421         esac
1422         if test $host_os = "cygwin"; then
1423                 aros_kernel_cflags="-mno-cygwin"
1424         fi
1425     ;;
1426     pp*)
1427         aros_target_arch="pp"
1428         aros_shared_default="no"
1429         case "$target_cpu" in
1430             *m68k*)
1431                 aros_target_cpu="m68k"
1432                 aros_object_format="m68kelf"
1433                 aros_flavour="palmnative"
1434                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1435                 aros_default_wbwidth=160
1436                 aros_default_wbheight=160
1437                 aros_default_wbdepth=1
1438                 aros_target_ar_flags="cru"
1439                 aros_compiler_libs="-lgcc1"
1440                 aros_shared_default=no
1441                 aros_shared_cflags="-fpic"
1442                 aros_shared_aflags=""
1443                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1444                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1445                 aros_debug_cflags="$aros_symbols_debug  $aros_messages_debug"
1446                 aros_debug_aflags=""
1447                 aros_debug_ldflags="$aros_symbols_debug"
1448                 aros_mungwall_debug="0"
1449                 aros_modules_debug="0"
1450                 gcc_target_cpu="mc68000"
1451                 ignore_undefined_symbols="-ius"
1452                 ;;
1453            *)
1454                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1455                 ;;
1456         esac
1457         ;;
1459     mac*)
1460         aros_target_arch="mac"
1461         aros_shared_default="no"
1462         case "$target_cpu" in
1463             *m68k*)
1464                 aros_target_cpu="m68k"
1465                 aros_object_format="m68kelf"
1466                 aros_flavour="mac68knative"
1467                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1468                 aros_default_wbwidth=512
1469                 aros_default_wbheight=384
1470                 aros_default_wbdepth=8
1471                 aros_target_ar_flags="cru"
1472                 aros_compiler_libs="-lgcc1"
1473                 aros_shared_default=no
1474                 aros_shared_cflags="-fpic"
1475                 aros_shared_aflags=""
1476                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1477                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1478                 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
1479                 aros_debug_aflags=""
1480                 aros_debug_ldflags="$aros_symbols_debug"
1481                 aros_mungwall_debug="0"
1482                 aros_modules_debug="0"
1483                 gcc_target_cpu="mc68000"
1484                 ignore_undefined_symbols="-ius"
1485                 ;;
1486            *)
1487                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1488                 ;;
1489         esac
1490         ;;
1492     *)
1493         AC_MSG_ERROR([Unsupported target architecture $target])
1494         ;;
1495 esac
1497 #-----------------------------------------------------------------------------
1498 crosstools_guess="yes"
1499 aros_target_toolchain="no"
1500 aros_config_sysroot=""
1501 aros_kernel_sysroot=""
1503 AC_MSG_CHECKING([Kernel toolchain prefix])
1504 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1505 AC_MSG_RESULT($kernel_tool_prefix)
1507 AC_MSG_CHECKING([ELF toolchain prefix])
1508 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"
1509                                                  crosstools_guess="no"])
1510 AC_MSG_RESULT($elf_tool_prefix)
1512 AC_MSG_CHECKING([AROS toolchain prefix])
1513 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"
1514                 crosstools_guess="no"])
1515 if test "$aros_tool_prefix" = "yes" ; then
1516     aros_tool_prefix=$aros_target_cpu-aros-
1518 AC_MSG_RESULT($aros_tool_prefix)
1520 #-----------------------------------------------------------------------------
1521 #   Checking if we should build crosstools..
1522 AC_MSG_CHECKING([whether to build crosstools])
1523 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1524 AC_MSG_RESULT($crosstools)
1526 if test "${crosstools}" = "yes"; then
1527     if test "${crosstools_guess}" = "no"; then
1528         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1529     fi
1532 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1533     aros_target_toolchain="yes"
1536 AC_MSG_CHECKING([where to install the crosstools binaries])
1537 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])
1538 if test "x$aros_toolchain_install" = "x"; then
1539     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1540 else
1541     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1542     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1543     if test "$crosstools_guess" = "no" ; then
1544         aros_config_sysroot="--sysroot $AROS_BUILDDIR_UNIX/bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development"
1546         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1547             aros_kernel_sysroot = $aros_config_sysroot
1548         fi
1549     fi
1551 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1553 #-----------------------------------------------------------------------------
1554 AC_MSG_CHECKING([what specific target binutils version to use])
1555 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="")
1556 if test "$use_binutils_version" = ""; then
1557         target_binutils_version="$default_binutils_version"
1558 else
1559     target_binutils_version="$use_binutils_version"
1561 AC_MSG_RESULT($target_binutils_version)
1564 # Helper to identify gcc version
1565 AC_DEFUN([CROSS_GCC_VERSION], [
1566   target_gcc_version=""
1567   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1568     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}cpp -dumpversion`"
1569     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1570       ax_cv_gcc_version=""
1571     ])
1572   ])
1573   target_gcc_version=$ax_cv_gcc_version
1574   AC_SUBST([target_gcc_version])
1577 #-----------------------------------------------------------------------------
1578 AC_MSG_CHECKING([what specific target gcc version to use])
1579 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="")
1580 if test "$use_gcc_version" = ""; then
1581     if test "${crosstools}" = "no"; then
1582       if test "x$aros_toolchain_install" != "x"; then
1583           CROSS_GCC_VERSION
1584       fi
1585     fi
1586     if test "$use_gcc_version" = ""; then
1587         target_gcc_version="$default_gcc_version"
1588     fi
1589 else
1590     target_gcc_version="$use_gcc_version"
1592 AC_MSG_RESULT($target_gcc_version)
1594 AC_MSG_CHECKING([whether to enable Objective-C suppport])
1595 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
1596 AC_MSG_RESULT($objc)
1597 if test "x$objc" = "xyes"; then
1598     objc_target="$objc"
1599 else
1600     objc_target="no-objc"
1603 AC_MSG_CHECKING([whether to enable Java suppport])
1604 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
1605 AC_MSG_RESULT($java)
1606 if test "x$java" != "xno"; then
1607     java_target="$java"
1608 else
1609     java_target="no-java"
1612 spec_obj_format="-m $aros_object_format"
1613 # Now process extra architecture-specific options.
1614 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
1615 # as well as floating-point ABI.
1616 case "$aros_target_cpu" in
1617 *x86_64*)
1618     dnl x86_64 can build 32 or 64bit code
1619     spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
1620     ;;
1621 arm*)
1622     dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
1623     if test "$gcc_default_cpu" = ""; then
1624         gcc_default_cpu="armv6"
1625     fi
1626     if test "$gcc_default_fpu" = ""; then
1627         gcc_default_fpu="vfp"
1628     fi
1629     if test "$gcc_default_float_abi" = ""; then
1630         if test "$target_cpu" = "armhf"; then
1631             gcc_default_float_abi="hard"
1632         else
1633             gcc_default_float_abi="softfp"
1634         fi
1635     fi
1637     AC_MSG_CHECKING([Which minimum CPU to use])
1638     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)
1639     AC_MSG_RESULT($aros_gcc_cpu)
1641     AC_MSG_CHECKING([Which minimum FPU to use])
1642     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)
1643     AC_MSG_RESULT($aros_gcc_fpu)
1645     AC_MSG_CHECKING([Which floating point ABI to use])
1646     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)
1647     AC_MSG_RESULT($aros_gcc_float_abi)
1649     aros_isa_flags="-marm -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
1650     aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -fno-exceptions"
1651     aros_config_aflags="$aros_config_aflags -fno-asynchronous-unwind-tables -fno-exceptions"
1652     ;;
1653 i386)
1654     aros_isa_flags="-m32 -march=i486"
1655     aros_kernel_cflags="$aros_kernel_cflags $aros_isa_flags"
1656     aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
1657     ;;
1658 esac
1660 # Some architectures may need custom ELF specs.
1661 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
1662     elf_specs_in=config/${aros_object_format}-specs.in
1663 else
1664     elf_specs_in=config/elf-specs.in
1667 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
1668 # Since we override specs, we may need to put these defines there
1669 if test "$gcc_target_cpu" != ""; then
1670     gcc_target_cpu="-D__${gcc_target_cpu}__"
1673 AC_MSG_CHECKING([where to download sourcecode for external ports])
1674 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1675 if test "$with_portssrcdir" = "default"; then
1676     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
1677 else
1678     AROS_PORTSSRCDIR="$with_portssrcdir"
1680 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1682 AC_MSG_CHECKING([which bootloader to use])
1683 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1684 if test "$target_bootloader" = "none"; then
1685     aros_target_bootloader=""
1686 else
1687     aros_target_bootloader="$target_bootloader"
1689 AC_MSG_RESULT($target_bootloader)
1691 AC_MSG_CHECKING([which icon-set to use])
1692 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
1693 if test "$target_iconset" = "default"; then
1694     aros_target_iconset="Gorilla"
1695     target_iconset="default (Gorilla)"
1696 else
1697     aros_target_iconset="$target_iconset"
1699 AC_MSG_RESULT($target_iconset)
1701 AC_MSG_CHECKING([which GUI Theme to use])
1702 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1703 if test "$target_guitheme" = "default"; then
1704     aros_target_guitheme="Ice"
1705 else
1706     aros_target_guitheme="$target_guitheme"
1708 AC_MSG_RESULT($aros_target_guitheme)
1710 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
1711 # for target code)
1712 cross_compiling=no
1714 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
1715 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1716     cross_compiling=yes
1719 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
1720 dnl The flag itself is given in per-target section, because some targets require to pass it
1721 dnl in a different manner, otherwise some tests fail.
1722 dnl TODO: Justify this.
1723 if test "$aros_host_cpu" == "x86_64" ; then
1724     if test "$aros_target_cpu" == "i386" ; then
1725         cross_compiling=no
1726     fi
1729 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1730     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
1731     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
1732     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
1733     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
1734     dnl used to build bootstrap for target arch in either case.
1735     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
1736     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
1737     dnl perhaps introducing aros_host_variant
1738     if test "$aros_host_arch" != "$aros_target_arch" ; then
1739         cross_compiling=yes
1740     fi
1741 else
1742     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
1743     dnl it as kernel_cc. If not, (e. g. we are on Windows or Darwin), we need a crosscompiler.
1744     if test "$host_cc_elf" = "no" ; then
1745         cross_compiling=yes
1746     fi
1749 if test "$cross_compiling" = "no" ; then
1750     kernel_tool_prefix=""
1751     if test "$host_cc_elf" = "yes" ; then
1752         elf_tool_prefix=""
1753     fi
1756 if test "$kernel_tool_version" != ""; then
1757     kernel_tool_version="-$kernel_tool_version"
1760 #######################################################################
1761 ## Compute what toolchains to use, and their paths                   ##
1762 #######################################################################
1764 # This takes, as input:
1765 #   crosstools             {yes,no}
1766 #   kernel_tool_version    {"",[version]}
1767 #   target_tool_version    {"",[version]}
1768 #   kernel_tool_prefix     {none,[some-arch-os-]}
1769 #   target_tool_prefix     ${aros_target_cpu}-aros-
1770 #   aros_tool_prefix       ${aros_target_cpu}-aros-
1772 # The output is
1773 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1774 #        Where the 'kernel' binaries are located
1775 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
1776 #        Where the 'target' binaries are located
1777 #        (not the symlink farm - that is aros_target_*!)
1779 # The rules are:
1780 #   if crosstools then
1781 #      if kernel_tools_prefix = "no-kernel-prefix-"
1782 #          aros_kernel_* = crosstools cc paths
1783 #          aros_kernel_cc = elf cc wrapper around crosstools cc
1784 #      else
1785 #          VALIDATE(${kernel_tools_prefix}*)
1786 #          aros_kernel_* = ${kernel_tools_prefix}*
1787 #          if ${kernel_tools_prefix}cc is an AROS gcc
1788 #              aros_kernel_cc = ${kernel_tools_prefix}cc
1789 #          else
1790 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
1791 #          fi
1792 #      fi
1794 #      orig_target_* = aros built crosstools
1795 #      orig_target_cc = elf cc wrapper around crosstools cc
1796 #   else
1797 #      VALIDATE(${kernel_tools_prefix}*)
1799 #      orig_target_* = aros_kernel_*
1800 #      if aros_kernel_cc is an AROS gcc
1801 #          orig_target_cc = aros_kernel_cc
1802 #      else
1803 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
1804 #      fi
1805 #   fi
1807 target_tool_prefix="${aros_target_cpu}-aros-"
1809 AC_MSG_CHECKING([which kernel tools])
1810 AC_MSG_RESULT([$kernel_tool_prefix]);
1812 if test "$kernel_tool_prefix" = "none" ; then
1813     dnl ELF wrapper can be used only for native bootstrap
1814     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1815         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
1816     fi
1817 else
1818     # Kernel tools required - find them
1819     # Note that 'normally', aros_kernel_* overrides will be
1820     # empty, unless specified in the per-arch sections above.
1821     if test "x$aros_kernel_cpp" = "x"; then
1822         aros_kernel_cpp=${kernel_tool_prefix}cpp
1823     fi
1824     AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp${kernel_tool_version})
1825     AROS_REQUIRED(cpp,$aros_kernel_cpp)
1826     if test "x$aros_kernel_cc" = "x"; then
1827         aros_kernel_cc=${kernel_tool_prefix}gcc
1828     fi
1829     AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc${kernel_tool_version})
1830     AROS_REQUIRED(cc,$aros_kernel_cc)
1831     if test "x$aros_kernel_cxx" = "x"; then
1832         aros_kernel_cxx=${kernel_tool_prefix}g++
1833     fi
1834     AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx${kernel_tool_version})
1835     # If it's set, make sure it's really there
1836     if test "x$aros_kernel_cxx" != "x" ; then
1837         AROS_REQUIRED(cxx,$aros_kernel_cxx)
1838     fi
1839     AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
1840     AROS_REQUIRED(ld,$aros_kernel_ld)
1841     AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
1842     AROS_REQUIRED(as,$aros_kernel_as)
1843     AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
1844     AROS_REQUIRED(ar,$aros_kernel_ar)
1845     AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
1846     AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
1847     AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
1848     AROS_REQUIRED(nm,$aros_kernel_nm)
1849     AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
1850     AROS_REQUIRED(strip,$aros_kernel_strip)
1852     # Objcopy and objdump are not required for the kernel
1853     # toolchain on many architectures.
1854     # So we'll look for them, but not make them strictly required.
1855     AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
1856     AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
1857     if test "x${crosstools}" != "xyes" ; then
1858         AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
1859         AROS_REQUIRED(objdump,$aros_kernel_objdump)
1860     fi
1863 AC_MSG_CHECKING([which target tools to use])
1864 if test "$aros_target_toolchain" = "yes"; then
1865     AC_MSG_RESULT([$target_tool_prefix])
1866     # We are building AROS crosstools
1867     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
1868     orig_target_cc="${tmp_tool_prefix}gcc${target_tool_version}"
1869     orig_target_cxx="${tmp_tool_prefix}g++${target_tool_version}"
1870     orig_target_cpp="${tmp_tool_prefix}cpp"
1871     orig_target_ld="${tmp_tool_prefix}ld"
1872     orig_target_as="${tmp_tool_prefix}as"
1873     orig_target_ar="${tmp_tool_prefix}ar"
1874     orig_target_ranlib="${tmp_tool_prefix}ranlib"
1875     orig_target_nm="${tmp_tool_prefix}nm"
1876     orig_target_strip="${tmp_tool_prefix}strip"
1877     orig_target_objcopy="${tmp_tool_prefix}objcopy"
1878     orig_target_objdump="${tmp_tool_prefix}objdump"
1879 else
1880     # Determine whether AROS or ELF tools should be used
1881     if test "$aros_tool_prefix" = "none"; then
1882         aros_tool_prefix="${elf_tool_prefix}"
1883     fi
1885     AC_MSG_RESULT([$aros_tool_prefix])
1886     # We are *not* building AROS crosstools - use the AROS or ELF tools
1887     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}cpp${target_tool_version})
1888     AROS_REQUIRED(cpp,$orig_target_cpp)
1889     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}gcc${target_tool_version})
1890     AROS_REQUIRED(cc,$orig_target_cc)
1891     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}g++${target_tool_version})
1892     AROS_REQUIRED(cxx,$orig_target_cxx)
1893     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}ld)
1894     AROS_REQUIRED(ld,$orig_target_ld)
1895     AROS_TOOL_TARGET(orig_target_as,as,${aros_tool_prefix}as)
1896     AROS_REQUIRED(as,$orig_target_as)
1897     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}ar)
1898     AROS_REQUIRED(ar,$orig_target_ar)
1899     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}ranlib)
1900     AROS_REQUIRED(ranlib,$orig_target_ranlib)
1901     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}nm)
1902     AROS_REQUIRED(nm,$orig_target_nm)
1903     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}strip)
1904     AROS_REQUIRED(strip,$orig_target_strip)
1905     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}objcopy)
1906     AROS_REQUIRED(objcopy,$orig_target_objcopy)
1907     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}objdump)
1908     AROS_REQUIRED(objdump,$orig_target_objdump)
1911 if test "$kernel_tool_prefix" = "none" ; then
1912     # No kernel tools specified
1913     # Assume target tools == kernel tools with ELF wrapper
1914     aros_kernel_cc=$orig_target_cc
1915     aros_kernel_cxx=$orig_target_cxx
1916     aros_kernel_cpp=$orig_target_cpp
1917     aros_kernel_ld=$orig_target_ld
1918     aros_kernel_as=$orig_target_as
1919     aros_kernel_ar=$orig_target_ar
1920     aros_kernel_ranlib=$orig_target_ranlib
1921     aros_kernel_nm=$orig_target_nm
1922     aros_kernel_strip=$orig_target_strip
1923     aros_kernel_objcopy=$orig_target_objcopy
1924     aros_kernel_objdump=$orig_target_objdump
1925     use_kernel_cc_wrapper=yes
1928 # At this point, all aros_kernel_* and aros_target_* 
1929 # tools should be set up correctly
1931 CC="$aros_kernel_cc $kernel_tool_flags"
1932 CPP="$aros_kernel_cpp"
1934 #-----------------------------------------------------------------------------
1936 # Disable pointer-signedness warnings if the compiler recognises the option
1938 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
1939 save_cflags="$CFLAGS"
1940 if test "$crosstools" != "yes" ; then
1941     CFLAGS="$CFLAGS -Wno-pointer-sign"
1942     AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
1943 else
1944     # we do know it is supported for the smallest version of gcc we are going to build
1945     # we assume it's also supported by later versions
1946     use_no_sign_warning=yes
1948 AC_MSG_RESULT($use_no_sign_warning)
1949 if test "x-$use_no_sign_warning" = "x-yes" ; then
1950     aros_config_cflags="$aros_config_cflags -Wno-pointer-sign"
1952 CFLAGS="$save_cflags"
1954 #-----------------------------------------------------------------------------
1956 # Find all the tools we need to compile. This could be cross-compiling
1957 # though! If that is the case we use the GNU form of the target and
1958 # simply add this to the front of the binary name. This is rather simple,
1959 # but it should work under most circumstances.
1961 # The default tools are to use the same as the host, but only if the
1962 # host and target CPU are the same. With GCC this is normally enough.
1965 aros_cc_pre=""
1966 aros_shared_ld="$aros_host_ld"
1968 aros_target_mkdep="$aros_host_mkdep"
1970 # The default tools executables to be linked to.
1971 if test "$rescomp" != ""; then
1972     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
1973     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
1976 # Set up the sources for the symlink farm
1977 if test "$crosstools" = "yes"; then
1978     crosstools_target=tools-crosstools
1981 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
1982 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
1984 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1985 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1986 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1987 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1988 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1989 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1990 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1992 # aros_cc_pre is a variable that is added to the front of the compiler name
1993 # in the generated aros-gcc shell script. We need this to enable the cache
1994 # to work across cleaned builds. Also, support DISTCC using the correct
1995 # environment variable.
1998 if test "x${DISTCC}" != "x" ; then
1999     if test "x${CCACHE}" != "x" ; then
2000         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2001     else
2002         aros_cc_pre="${DISTCC} "
2003     fi
2004 else
2005     if test "x${CCACHE}" != "x" ; then
2006         aros_cc_pre="${CCACHE} "
2007     fi
2010 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2011 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2012 AC_SUBST(aros_target_nix_ldflags,-nix)
2013 AC_SUBST(aros_target_detach_ldflags,-detach)
2014 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2016 # Target tools
2017 if test "$aros_target_toolchain" != "yes"; then
2018     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2019     if test "$GCC" = "yes"; then
2020         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2021     fi
2022 else
2023     # We do not know which gcc version we are going to build and what we need to know
2024     # here is different for different versions so this will be set later during the
2025     # build of crosstools.
2026     prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2027     aros_target_cc_path=@aros_target_cc_path@
2029 aros_target_cpp="${prefix}cpp"
2030 aros_target_cc="${prefix}gcc"
2031 aros_target_cxx="${prefix}g++"
2032 aros_target_as="${prefix}as"
2033 aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld"
2034 aros_target_ar="${prefix}ar $aros_target_ar_flags"
2035 aros_target_objcopy="${prefix}objcopy"
2036 aros_target_objdump="${prefix}objdump"
2037 aros_target_ranlib="${prefix}ranlib $aros_target_ranlib_flags"
2038 aros_target_nm="${prefix}nm $aros_target_nm_flags"
2039 aros_target_strip="${prefix}strip"
2040 aros_plain_nm="${prefix}nm"
2041 aros_plain_ar="${prefix}ar"
2043 AC_ARG_ENABLE(includes,
2044 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2045 [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`])
2047 if test "$aros_kernel_includes" = ""; then
2048     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2049         aros_kernel_includes="-isystem $aros_target_incl"
2050     fi
2053 if test "$aros_kernel_includes" != "" ; then
2054     dnl find out about the kernel cc's include path
2055     AC_MSG_CHECKING([for the kernel compiler's include path])
2056     if test "$aros_kernel_cc_includes" = "" ; then
2057         # Try to guess where the directory is.
2058         aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2059         if test -d $aros_kernel_cc_includes; then
2060             # Check if there is also an include-fixed directory and add it
2061             # to kernel compiler's include path as it may contain some of
2062             # the headers we need.
2063             if test -d "$aros_kernel_cc_includes"-fixed; then
2064                 aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2065             fi
2066             # Check for specific includes directory. Neede for Ubuntu 11.10
2067             if test -d "/usr/include/i386-linux-gnu"; then
2068                 aros_kernel_cc_includes+=" -isystem /usr/include/i386-linux-gnu"
2069             fi
2070         else
2071             # The directory doesn't exist, we need to do some more work.
2072             aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2074             # These are the headers we're looking for.
2075             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2076                      stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2077                      zutil.h stdint.h"
2079             dirs=
2080             for h in $headers; do
2081                 # Which other headers are needed by each of the above?
2082                 deps=$(echo "#include <$h>" | \
2083                        $aros_kernel_cc -E -M - 2>/dev/null | \
2084                        sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2086                 # Copy all the needed headers to a directory beneath gendir.
2087                 for d in $deps; do
2088                     h=$(basename $d)
2089                     dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2090                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2091                     ! test -d $dir && mkdir -p $dir
2092                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2093                 done
2094             done            
2095         fi
2096     fi
2097     AC_MSG_RESULT($aros_kernel_cc_includes)
2098     # Adding -nostdinc to kernel includes as they are always used together.
2099     aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2102 if test "$crosstools" != "yes"; then
2103     dnl find out about the target cc's include path
2104     AC_MSG_CHECKING([for the target compiler's include path])
2105     if test "$aros_target_cc_includes" = "" ; then
2106         #try to guess where the directory is
2107         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2108         if ! test -d $aros_target_cc_includes; then
2109             #the directory doesn't exist, we need to do some more work
2110             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2111         
2112             #these are the headers we're looking for
2113             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2114                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2115                     zutil.h"
2117             dirs=
2118             for h in $headers; do
2119                 #which other headers each of the above headers needs?
2120                 deps=$(echo "#include <$h>" | \
2121                     $orig_target_cc -E -M - 2>/dev/null | \
2122                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2123             
2124                 #copy all the needed headers to a directory beneath gendir
2125                 for d in $deps; do
2126                     h=$(basename $d)
2127                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2128                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2129                     ! test -d $dir && mkdir -p $dir
2130                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2131                 done
2132             done
2133         fi
2134     fi
2135     AC_MSG_RESULT($aros_target_cc_includes)
2136 else
2137     # We do not know which gcc version we are going to build and what we need to know
2138     # here is different for different versions so this will be set later during the
2139     # build of crosstools.
2140     aros_target_cc_includes=@aros_target_cc_includes@
2144 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2145 # On GCC >= 4.0 -iquote should be used
2148 save_cc="$CC"
2149 save_cflags="$CFLAGS"
2150 CFLAGS="-iquote."
2151 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2152 if test "x-$crosstools" != "x-yes"; then
2153     AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2154 else
2155     # we do know it is supported for the smallest version of gcc we are going to build
2156     # we assume it's also supported by later versions
2157     has_iquote=yes
2159 AC_MSG_RESULT($has_iquote)
2160 if test "x-$has_iquote" = "x-yes" ; then
2161     host_cflags_iquote=-iquote
2162     host_cflags_iquote_end=
2163 else
2164     host_cflags_iquote=-I
2165     host_cflags_iquote_end=-I-
2167 kernel_cflags_iquote=$host_cflags_iquote
2168 kernel_cflags_iquote_end=$host_cflags_iquote_end
2169 if test "x-$cross_compiling" = "x-yes"; then
2170     CC="$aros_kernel_cc"
2171     AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2172     if test "x-$crosstools" != "x-yes"; then
2173         AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2174     else
2175         # we do know it is supported for the smallest version of gcc we are going to build
2176         # we assume it's also supported by later versions
2177         use_no_stack_protector=yes
2178     fi
2179     AC_MSG_RESULT($use_no_stack_protector)
2180     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2181     if test "x-$crosstools" != "x-yes"; then
2182         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2183     else
2184         # we do know it is supported for the smallest version of gcc we are going to build
2185         # we assume it's also supported by later versions
2186         has_iquote=yes
2187     fi
2188     AC_MSG_RESULT($has_iquote)
2189     if test "x-$has_iquote" = "x-yes" ; then
2190         kernel_cflags_iquote=-iquote
2191         kernel_cflags_iquote_end=
2192     else
2193         kernel_cflags_iquote=-I
2194         kernel_cflags_iquote_end=-I-
2195     fi
2197 aros_cflags_iquote=$kernel_cflags_iquote
2198 aros_cflags_iquote_end=$kernel_cflags_iquote_end
2199 if test "$orig_target_cc" != "$aros_kernel_cc"; then
2200     CC="$orig_target_cc"
2201     AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2202     if test "x-$crosstools" != "x-yes"; then
2203         AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2204     else
2205         # we do know it is supported for the smallest version of gcc we are going to build
2206         # we assume it's also supported by later versions
2207         has_iquote=yes
2208     fi
2209     AC_MSG_RESULT($has_iquote)
2210     if test "x-$has_iquote" = "x-yes" ; then
2211         aros_cflags_iquote=-iquote
2212         aros_cflags_iquote_end=
2213     else
2214         aros_cflags_iquote=-I
2215         aros_cflags_iquote_end=-I-
2216     fi
2218 if test "x-$use_no_stack_protector" = "x-yes" ; then
2219     aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2223 #-----------------------------------------------------------------------------
2225 # Check if the target compiler supports some options used for delinting:
2226 #  -Wunused-but-set-variable
2227 #  -Warray-bounds
2228 #  -Wenum-compare
2229 #  -Wstrict-overflow
2230 #  -Wformat-security
2232 if test "x-$crosstools" != "x-yes"; then
2233     if test "$orig_target_cc" != "$aros_kernel_cc"; then
2234         CC="$orig_target_cc"
2235     fi
2236     AC_MSG_CHECKING([whether ${CC} accepts -Wunused-but-set-variable])
2237     CFLAGS=-Wunused-but-set-variable
2238     AC_TRY_COMPILE(,, aros_unused_but_set_variable="yes", aros_unused_but_set_variable="no")
2239     AC_MSG_RESULT($aros_unused_but_set_variable)
2240     if test "x-$aros_unused_but_set_variable" = "x-yes" ; then
2241         aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable
2242     fi
2244     AC_MSG_CHECKING([whether ${CC} accepts -Warray-bounds])
2245     CFLAGS=-Warray-bounds
2246     AC_TRY_COMPILE(,, aros_array_bounds="yes", aros_array_bounds="no")
2247     AC_MSG_RESULT($aros_array_bounds)
2248     if test "x-$aros_array_bounds" = "x-yes" ; then
2249         aros_cflags_array_bounds=-Wno-array-bounds
2250     fi
2252     AC_MSG_CHECKING([whether ${CC} accepts -Wenum-compare])
2253     CFLAGS=-Wenum-compare
2254     AC_TRY_COMPILE(,, aros_enum_compare="yes", aros_enum_compare="no")
2255     AC_MSG_RESULT($aros_enum_compare)
2256     if test "x-$aros_enum_compare" = "x-yes" ; then
2257         aros_cflags_enum_compare=-Wno-enum-compare
2258     fi
2260     AC_MSG_CHECKING([whether ${CC} accepts -Wstrict-overflow])
2261     CFLAGS=-Wstrict-overflow
2262     AC_TRY_COMPILE(,, aros_strict_overflow="yes", aros_strict_overflow="no")
2263     AC_MSG_RESULT($aros_strict_overflow)
2264     if test "x-$aros_strict_overflow" = "x-yes" ; then
2265         aros_cflags_strict_overflow=-Wno-strict-overflow
2266     fi
2268     AC_MSG_CHECKING([whether ${CC} accepts -Wformat-security])
2269     CFLAGS=-Wformat-security
2270     AC_TRY_COMPILE(,, aros_format_security="yes", aros_format_security="no")
2271     AC_MSG_RESULT($aros_format_security)
2272     if test "x-$aros_format_security" = "x-yes" ; then
2273         aros_cflags_format_security=-Wno-format-security
2274     fi
2275 else
2276     # We do not know which gcc version we are going to build and what we need to know
2277     # here is different for different versions so this will be set later during the
2278     # build of crosstools.
2279     aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@
2280     aros_cflags_array_bounds=@aros_cflags_array_bounds@
2281     aros_cflags_enum_compare=@aros_cflags_enum_compare@
2282     aros_cflags_strict_overflow=@aros_cflags_strict_overflow@
2283     aros_cflags_format_security=@aros_cflags_format_security@
2286 #-----------------------------------------------------------------------------
2288 # Check if we can explicitly choose older version of symbol hashing
2290 CFLAGS="save_cflags -Wl,--hash-style=sysv"
2291 CC="$aros_kernel_cc"
2292 AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2293 AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2294 AC_MSG_RESULT($use_hash_style)
2295 if test "x-$use_hash_style" = "x-yes" ; then
2296     aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2298 CC="$save_cc"
2299 CFLAGS="$save_cflags"
2301 AC_SUBST(host_cflags_iquote)
2302 AC_SUBST(host_cflags_iquote_end)
2303 AC_SUBST(kernel_cflags_iquote)
2304 AC_SUBST(kernel_cflags_iquote_end)
2305 AC_SUBST(aros_cflags_iquote)
2306 AC_SUBST(aros_cflags_iquote_end)
2309 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2310 AC_MSG_CHECKING([for default resolution of WBScreen])
2311 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2312 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2313 if test "$resolution" = "yes" ; then
2314     resolution="none"
2316 if test "$resolution" = "no" ; then
2317     resolution="none"
2319 if test "$resolution" != "none" ; then
2320     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
2321     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
2322     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
2324 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
2325 aros_cv_default_wbwidth=$aros_default_wbwidth
2326 aros_cv_default_wbheight=$aros_default_wbheight
2327 aros_cv_default_wbdepth=$aros_default_wbdepth
2329 dnl See if the user wants the serial debug output for native flavour
2330 AC_MSG_CHECKING([if serial debug is enabled])
2331 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)
2332 if test "$aros_serial_debug" = 0 ; then
2333     serial_debug_forced=""
2334     if test "$serial_debug" = "yes" ; then
2335         serial_debug="1"
2336     fi
2337     if test "$serial_debug" = "no" ; then
2338         serial_debug="none"
2339     fi
2340 else
2341     serial_debug_forced="(forced)"
2342     serial_debug=$aros_serial_debug
2344 if test "$serial_debug" != "none" ; then
2345     aros_serial_debug=$serial_debug
2346     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2347 else
2348     AC_MSG_RESULT(no)
2351 dnl See if the user wants the palm debug output hack for palm native flavour
2352 AC_MSG_CHECKING([if palm debug hack is enabled])
2353 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")
2354 if test "$palm_debug_hack" = "yes" ; then
2355     aros_palm_debug_hack="1"
2357 AC_MSG_RESULT($palm_debug_hack)
2359 dnl See if dev wants the usb3.0 code
2360 AC_MSG_CHECKING([if usb3.0 code is enabled])
2361 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2362 if test "$usb30_code" = "yes" ; then
2363     aros_config_cflags="$aros_config_cflags -DAROS_USB30_CODE"
2364     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2366 AC_MSG_RESULT($usb30_code)
2368 dnl See if the user wants nesting supervisor activated for unix flavour
2369 AC_MSG_CHECKING([if nesting supervisor support is enabled])
2370 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")
2371 if test "$nesting_supervisor" = "yes" ; then
2372     aros_nesting_supervisor="1"
2374 AC_MSG_RESULT($nesting_supervisor)
2376 dnl See if the user wants to disable MMU support
2377 dnl This can be overriden on per-target basis,
2378 dnl set $aros_enable_mmu to "yes" or "no" to do this
2379 if test "$aros_enable_mmu" = "" ; then
2380     AC_MSG_CHECKING([if MMU support is enabled])
2381     dnl Enabled by default
2382     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2383     if test "$aros_enable_mmu" = "" ; then
2384         aros_enable_mmu="yes"
2385     fi
2386     AC_MSG_RESULT($aros_enable_mmu)
2388 if test "$aros_enable_mmu" = "no" ; then
2389     aros_enable_mmu="0"
2390 else
2391     aros_enable_mmu="1"
2393     
2395 dnl things specifically required for hosted flavours
2396 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2398     if test "x-$need_dlopen" != "x-no" ; then
2399       save_libs="$LIBS"
2400       LIBS=""
2401       dnl some kind of dynamic library access system is required for hostlib.resource
2402       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2403       if test "x-$have_dl" = "x-no" ; then
2404           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2405                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2406                                     have_dl="no")
2407       fi
2408       if test "x-$have_dl" = "x-no" ; then
2409           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2410       fi
2411       LIBS="$save_libs"
2412     fi
2415     dnl x11 hidd
2416     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2417                                            [build X11 hidd for hosted (default=auto)]),
2418                                            x11_hidd="$enableval",
2419                                            x11_hidd="$need_x11")
2420     case "x-$x11_hidd" in
2421         x-yes|x-no|x-auto)                 ;;
2422         *)                 x11_hidd="$need_x11" ;;
2423     esac
2425     ENABLE_X11=0
2427     dnl they want it
2428     if test "x-$x11_hidd" != "x-no" ; then
2430         dnl find x11 stuff
2431         AC_PATH_X
2433         x_cflags=
2434         for path in $x_libraries
2435         do
2436             x_cflags="$x_cflags -L$path"
2437         done
2439         for path in $x_includes
2440         do
2441             x_cflags="$x_cflags -I$path"
2442         done
2443         
2444         if test "x-$no_x" = "x-yes" ; then
2446             dnl didn't find it
2447             if test "x-$x11_hidd" != "x-auto" ; then
2448                 dnl and they explicitly asked for it, bail out
2449                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2450             fi
2451         
2452         else
2453             dnl found it, setup the metatarget
2454             unixgfx_hidd_target=kernel-x11gfx
2455             ENABLE_X11=1
2457             dnl setup shared memory extensions
2458             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2459                                                   [use X11 shared memory (default=auto)]),
2460                                                   x11_hidd_shm="$enableval",
2461                                                   x11_hidd_shm="auto")
2462             case "x-$x11_hidd_shm" in
2463                 x-yes|x-no|x-auto)                     ;;
2464                 *)                 x11_hidd_shm="auto" ;;
2465             esac
2467             have_xshm=no
2469             dnl they want it
2470             if test "x-$x11_hidd_shm" != "x-no" ; then
2472                 dnl system shm headers
2473                 AC_CHECK_HEADERS(sys/ipc.h)
2474                 AC_CHECK_HEADERS(sys/shm.h)
2476                 dnl got them
2477                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2479                     dnl make sure X libs have shm functions
2480                     save_cflags="$CFLAGS"
2481                     CFLAGS="$CFLAGS $x_cflags"
2482                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2483                     CFLAGS="$save_cflags"
2484                 fi
2485             fi
2487             dnl detection done, prepare output
2488             if test "x-$have_xshm" = "x-yes" ; then
2489                 dnl we can do shm
2490                 DO_XSHM_SUPPORT="1"
2491             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2492                 dnl they explicitly asked for it, but we can't do it
2493                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2494             else
2495                 dnl otherwise just disable it
2496                 DO_XSHM_SUPPORT="0"
2497             fi
2499             
2500             dnl setup vidmode (fullscreen) extensions
2501             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2502                                                       [use X11 vidmode extension (default=auto)]),
2503                                                       x11_hidd_vidmode="$enableval",
2504                                                       x11_hidd_vidmode="auto")
2505             case "x-$x11_hidd_vidmode" in
2506                 x-yes|x-no|x-auto)                         ;;
2507                 *)                 x11_hidd_vidmode="auto" ;;
2508             esac
2510             have_vidmode=no
2512             dnl they want it
2513             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2515                 dnl make sure X libs have vidmode functions
2516                 save_cflags="$CFLAGS"
2517                 CFLAGS="$CFLAGS $x_cflags"
2518                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2519                 CFLAGS="$save_cflags"
2520             fi
2522             dnl detection done, prepare output
2523             if test "x-$have_vidmode" = "x-yes" ; then
2524                 dnl we can do vidmode
2525                 DO_VIDMODE_SUPPORT="1"
2526             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2527                 dnl they explicitly asked for it, but we can't do it
2528                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2529             else
2530                 dnl otherwise just disable it
2531                 DO_VIDMODE_SUPPORT="0"
2532             fi
2533         fi
2535         aros_host_x11_includes=$x_includes 
2536         aros_host_x11_libdirs=$x_libraries
2537     fi
2540     dnl sdl hidd
2541     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2542                                            [build SDL hidd for hosted (default=auto)]),
2543                                            sdl_hidd="$enableval",
2544                                            sdl_hidd="auto")
2545     case "x-$sdl_hidd" in
2546         x-yes|x-no|x-auto)                 ;;
2547         *)                 sdl_hidd="auto" ;;
2548     esac
2550     dnl they want it
2551     if test "x-$sdl_hidd" != "x-no" ; then
2553         dnl find sdl
2554         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
2556         if test "x-$have_sdl" != "x-yes" ; then
2558             dnl didn't find it
2559             if test "x-$sdl_hidd" != "x-auto" ; then
2560                 dnl and they explicitly asked for it, bail out
2561                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
2562             fi
2564         else
2565             dnl found it, set up the metatarget
2566             sdl_hidd_target=kernel-hidd-sdl
2567             aros_host_sdl_cflags=SDL_CFLAGS
2568             aros_host_sdl_libs=SDL_LIBS
2569         fi
2570     fi
2572     dnl oss.library
2573     AC_CHECK_HEADER(sys/soundcard.h)
2574     if test "x-$ac_cv_header_sys_soundcard_h" = "x-yes" ; then
2575         oss_library_target=workbench-libs-oss-unix
2576     fi
2580 dnl See if the user wants dbus.library
2581 AC_MSG_CHECKING([if building of dbus.library is enabled])
2582 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
2583 if test "$dbus" = "yes" ; then
2584     ENABLE_DBUS=1
2585     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
2586     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
2587     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
2588     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
2589 else
2590     ENABLE_DBUS=0
2592 AC_MSG_RESULT($dbus)
2594 if test "$use_kernel_cc_wrapper" = "yes" ; then
2595     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc"
2598 dnl --------------------------------------------------------------------
2599 dnl Configuration Output Section
2600 dnl --------------------------------------------------------------------
2602 # Generic
2603 AC_SUBST(aros_arch)
2604 AC_SUBST(aros_cpu)
2605 AC_SUBST(aros_flavour)
2606 AC_SUBST(aros_flavour_uc)
2607 AC_SUBST(aros_target_toolchain)
2608 AC_SUBST(AROS_BUILDDIR)
2609 AC_SUBST(AROS_BUILDDIR_UNIX)
2610 AC_SUBST(SRCDIR)
2611 AC_SUBST(AROS_CROSSTOOLSDIR)
2612 AC_SUBST(AROS_PORTSSRCDIR)
2614 # Compatability with other Amiga-like operation systems
2615 AC_SUBST(aros_amigaos_compliance)
2617 # Host related
2618 AC_SUBST(aros_cc_pre)
2619 AC_SUBST(aros_host_strip)
2620 AC_SUBST(aros_host_arch)
2621 AC_SUBST(aros_host_cpu)
2622 AC_SUBST(aros_host_cpp)
2623 AC_SUBST(aros_host_cc)
2624 AC_SUBST(aros_host_cxx)
2625 AC_SUBST(aros_host_ar)
2626 AC_SUBST(aros_host_ranlib)
2627 AC_SUBST(aros_host_ld)
2628 AC_SUBST(aros_host_make)
2629 AC_SUBST(aros_host_cflags)
2630 AC_SUBST(aros_host_cxxflags)
2631 AC_SUBST(gnu89_inline)
2632 AC_SUBST(aros_host_ldflags)
2633 AC_SUBST(aros_host_debug)
2634 AC_SUBST(aros_host_mkdep)
2635 AC_SUBST(aros_host_mkargs)
2636 AC_SUBST(aros_host_exe_suffix)
2637 AC_SUBST(aros_host_lib_suffix)
2638 AC_SUBST(aros_tools_dir)
2639 AC_SUBST(aros_host_aclocal)
2640 AC_SUBST(aros_host_autoconf)
2641 AC_SUBST(aros_host_autoheader)
2642 AC_SUBST(aros_host_automake)
2643 AC_SUBST(ant)
2645 # Target Related
2646 AC_SUBST(aros_target_guitheme)
2647 AC_SUBST(aros_target_iconset)
2648 AC_SUBST(aros_target_bootloader)
2649 AC_SUBST(aros_target_arch)
2650 AC_SUBST(aros_target_family)
2651 AC_SUBST(aros_target_cpu)
2652 AC_SUBST(aros_target_variant)
2653 AC_SUBST(aros_target_suffix)
2654 AC_SUBST(aros_target_ar)
2655 AC_SUBST(aros_target_ranlib)
2656 AC_SUBST(aros_plain_nm)
2657 AC_SUBST(aros_plain_ar)
2658 AC_SUBST(aros_kernel_ar)
2659 AC_SUBST(aros_kernel_ranlib)
2660 AC_SUBST(orig_target_cc)
2661 AC_SUBST(aros_target_cc)
2662 AC_SUBST(aros_kernel_cc)
2663 AC_SUBST(orig_target_cxx)
2664 AC_SUBST(aros_target_cxx)
2665 AC_SUBST(aros_kernel_cxx)
2666 AC_SUBST(orig_target_cpp)
2667 AC_SUBST(aros_target_cpp)
2668 AC_SUBST(aros_kernel_cpp)
2669 AC_SUBST(orig_target_as)
2670 AC_SUBST(aros_target_as)
2671 AC_SUBST(aros_kernel_as)
2672 AC_SUBST(orig_target_ld)
2673 AC_SUBST(aros_target_ld)
2674 AC_SUBST(aros_kernel_ld)
2675 AC_SUBST(aros_target_cc_includes)
2676 AC_SUBST(aros_target_cc_path)
2677 AC_SUBST(aros_target_objdump)
2678 AC_SUBST(aros_target_objcopy)
2679 AC_SUBST(aros_target_strip)
2680 AC_SUBST(aros_target_nm)
2681 AC_SUBST(aros_kernel_rescomp)
2682 AC_SUBST(aros_shared_default)
2683 AC_SUBST(aros_shared_ld)
2684 AC_SUBST(aros_object_format)
2685 AC_SUBST(spec_obj_format)
2686 AC_SUBST(aros_compiler_libs)
2687 AC_SUBST(aros_arch_libs)
2689 AC_SUBST(aros_shared_cflags)
2690 AC_SUBST(aros_shared_aflags)
2691 AC_SUBST(aros_shared_ldflags)
2693 AC_SUBST(aros_config_sysroot)
2694 AC_SUBST(aros_config_cflags)
2695 AC_SUBST(aros_config_aflags)
2696 AC_SUBST(aros_config_ldflags)
2698 AC_SUBST(aros_kernel_sysroot)
2699 AC_SUBST(aros_kernel_cflags)
2700 AC_SUBST(aros_kernel_includes)
2701 AC_SUBST(aros_kernel_objcflags)
2702 AC_SUBST(aros_kernel_ldflags)
2703 AC_SUBST(aros_target_cflags)
2704 AC_SUBST(aros_debug_cflags)
2705 AC_SUBST(aros_debug_aflags)
2706 AC_SUBST(aros_debug_ldflags)
2707 AC_SUBST(aros_target_genmap)
2708 AC_SUBST(aros_target_strip_flags)
2709 AC_SUBST(aros_optimization_cflags)
2710 AC_SUBST(aros_isa_flags)
2712 AC_SUBST(crosstools_target)
2713 AC_SUBST(crosstools_cxx_target)
2715 # Delinting target compiler flags
2716 AC_SUBST(aros_cflags_unused_but_set_variable)
2717 AC_SUBST(aros_cflags_array_bounds)
2718 AC_SUBST(aros_cflags_enum_compare)
2719 AC_SUBST(aros_cflags_strict_overflow)
2720 AC_SUBST(aros_cflags_format_security)
2722 # Graphics Related
2723 AC_SUBST(unixgfx_hidd_target)
2724 AC_SUBST(sdl_hidd_target)
2725 AC_SUBST(pci_hidd_target)
2726 AC_SUBST(oss_library_target)
2728 AC_SUBST(aros_default_wbwidth)
2729 AC_SUBST(aros_default_wbheight)
2730 AC_SUBST(aros_default_wbdepth)
2731 AC_SUBST(DO_XSHM_SUPPORT)
2732 AC_SUBST(DO_VIDMODE_SUPPORT)
2734 AC_SUBST(aros_host_x11_includes)
2735 AC_SUBST(aros_host_x11_libdirs)
2736 AC_SUBST(aros_host_sdl_cflags)
2737 AC_SUBST(aros_host_sdl_libs)
2739 # Native version related
2740 AC_SUBST(aros_serial_debug)
2742 # Palm native version related
2743 AC_SUBST(aros_palm_debug_hack)
2745 # Unix/Hosted version related
2746 AC_SUBST(aros_nesting_supervisor)
2748 # MMU related
2749 AC_SUBST(aros_enable_mmu)
2751 # Apple iOS related
2752 AC_SUBST(aros_ios_platform)
2753 AC_SUBST(aros_ios_version)
2754 AC_SUBST(aros_ios_sdk)
2756 # ARM default GCC target related
2757 AC_SUBST(gcc_default_cpu)
2758 AC_SUBST(gcc_default_cpu_tune)
2759 AC_SUBST(gcc_default_fpu)
2760 AC_SUBST(gcc_default_float_abi)
2762 # Android related
2763 AC_SUBST(android_tool)
2764 AC_SUBST(aros_android_level)
2765 AC_SUBST(aros_android_antapk)
2767 # DBUS related
2768 AC_SUBST(ENABLE_DBUS)
2769 AC_SUBST(DBUS_CFLAGS)
2770 AC_SUBST(DBUS_LIBFLAGS)
2771 AC_SUBST(KERNEL_DBUS_KOBJ)
2772 AC_SUBST(KERNEL_DBUS_INCLUDES)
2774 #X11 related
2775 AC_SUBST(ENABLE_X11)
2777 # Debug related
2778 AC_SUBST(aros_debug)
2779 AC_SUBST(aros_mungwall_debug)
2780 AC_SUBST(aros_stack_debug)
2781 AC_SUBST(aros_modules_debug)
2783 # Collect-aros stuff: "-ius" to ignore undefined symbols
2784 AC_SUBST(ignore_undefined_symbols)
2786 # C compiler related
2787 AC_SUBST(gcc_target_cpu)
2788 AC_SUBST(target_binutils_version)
2789 AC_SUBST(target_gcc_version)
2791 #ObjC compiler related
2792 AC_SUBST(objc_target)
2794 #Java related
2795 AC_SUBST(java_target)
2797 # USB3.0 code
2798 AC_SUBST(aros_usb30_code)
2800 dnl Prepare for output, make up all the generated patches
2801 case "$aros_flavour" in
2802 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
2803                 aros_flavour="emulation" ;;
2804 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
2805                 aros_flavour="emulation" ;;
2806 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
2807                 aros_flavour="standalone";;
2808 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2809                 aros_flavour="standalone";;
2810 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
2811                 aros_flavour="native" ;;
2812 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
2813                 aros_flavour="native" ;;
2814 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
2815                 aros_flavour="linklib" ;;
2816 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2817                 aros_flavour="palmnative" ;;
2818 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
2819                 aros_flavour="mac68knative" ;;
2820 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
2821                 aros_flavour="ppcnative" ;;
2822 esac
2824 if test ! -d ${aros_inc_dir} ; then
2825     ${MKDIR} ${aros_inc_dir}
2827 if test ! -d ${aros_geninc_dir} ; then
2828     ${MKDIR} ${aros_geninc_dir}
2830 if test ! -d ${aros_hostcfg_dir} ; then
2831     ${MKDIR} ${aros_hostcfg_dir}
2833 if test ! -d ${aros_targetcfg_dir} ; then
2834     ${MKDIR} ${aros_targetcfg_dir}
2836 if test ! -d ${aros_tools_dir} ; then
2837     ${MKDIR} ${aros_tools_dir}
2839 if test ! -d ${aros_scripts_dir} ; then
2840     ${MKDIR} ${aros_scripts_dir}
2843 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
2845 # Generic build tools (metamake, etc)
2846 AC_CONFIG_COMMANDS([genmf-executable-support],
2847     [chmod a+x ${aros_tools_dir}/genmf.py],
2848     [aros_tools_dir=${aros_tools_dir}]
2850 AC_CONFIG_FILES(
2851     Makefile
2852     config/make.cfg
2853     ${aros_inc_dir}/config.h:config/config.h.in
2854     ${aros_geninc_dir}/config.h:config/config.h.in
2855     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
2856     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
2857     mmake.config
2858     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
2859     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
2860     tools/collect-aros/env.h
2863 # Binutils
2864 AC_CONFIG_COMMANDS([binutils-support],
2865     [
2866         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2867         mkdir -p $prefix
2868         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2870         chmod a+x ${prefix2}-ld
2872         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
2873         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
2874         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
2875         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
2876         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
2877         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
2878         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
2879     ],
2880     [
2881         aros_host_exe_suffix=${aros_host_exe_suffix}
2882         aros_tools_dir=${aros_tools_dir}
2883         aros_target_cpu=${aros_target_cpu}
2884         aros_target_arch=${aros_target_arch}
2885         aros_target_suffix=${aros_target_suffix}
2886         orig_target_nm=${orig_target_nm}
2887         orig_target_as=${orig_target_as}
2888         orig_target_ar=${orig_target_ar}
2889         orig_target_ranlib=${orig_target_ranlib}
2890         orig_target_objdump=${orig_target_objdump}
2891         orig_target_objcopy=${orig_target_objcopy}
2892         orig_target_strip=${orig_target_strip}
2893         aros_kernel_ld=${aros_kernel_ld}
2894     ]
2896 AC_CONFIG_FILES(
2897     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
2900 # Bare Elf support script and spec
2901 if test "${use_kernel_cc_wrapper}" = "yes"; then
2902     AC_CONFIG_COMMANDS([elf-compiler-support],
2903         [
2904             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2905             mkdir -p $prefix
2906             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
2908             chmod a+x ${prefix2}-gcc
2910             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
2911         ],
2912         [
2913             aros_host_exe_suffix=${aros_host_exe_suffix}
2914             aros_tools_dir=${aros_tools_dir}
2915             aros_target_cpu=${aros_target_cpu}
2916             aros_target_arch=${aros_target_arch}
2917             aros_target_suffix=${aros_target_suffix}
2918             aros_kernel_ld=${aros_kernel_ld}
2919         ]
2920     )
2921     AC_CONFIG_FILES(
2922         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
2923         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
2924     )
2927 # Host compiler support scripts and spec
2928 if test "${aros_target_toolchain}" = "no"; then
2929     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
2930         [
2931             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
2932             mkdir -p $prefix
2933             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
2935             chmod a+x ${prefix2}-gcc ${prefix2}-g++ ${prefix2}-cpp
2936         ],
2937         [
2938             aros_host_exe_suffix=${aros_host_exe_suffix}
2939             aros_tools_dir=${aros_tools_dir}
2940             aros_target_cpu=${aros_target_cpu}
2941             aros_target_arch=${aros_target_arch}
2942             aros_target_suffix=${aros_target_suffix}
2943         ]
2944     )
2945     AC_CONFIG_FILES(
2946         ${aros_targetcfg_dir}/specs:config/specs.in
2947         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-cpp:scripts/aros-cpp.in
2948         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
2949         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-g++:scripts/aros-g++.in
2950     )
2953 # Android support
2954 if test "$aros_target_variant" == "android"; then
2955     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
2958 # cmake helper
2959 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
2961 AC_OUTPUT
2963 dnl This is in order to not define SHARED_CFLAGS sometimes
2964 dnl We don't always do aros_shared_ar, aros_shared_cflags
2966 #XXX compatability...
2967 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
2969 if test -n "$aros_shared_cflags" ; then
2970     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
2971     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg