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