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