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