don't check when its clang masquerading as gcc
[AROS.git] / configure.in
blob7d665c422389e587de6199a27e0bd4557fc8b504
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_toolchain_family=`cat ${srcdir}/config/toolchain_def`
27 default_gcc_version=`cat ${srcdir}/config/gcc_def`
28 exp_gcc_version=`cat ${srcdir}/config/gcc_exp`
29 default_binutils_version=`cat ${srcdir}/config/binutils_def`
30 exp_binutils_version=`cat ${srcdir}/config/binutils_exp`
31 default_grub2_version="2.02"
32 target_grub2_version=$default_grub2_version
34 # The AROS target is slightly different to the normal GNU style
35 # format. We don't have the middle part, and we reverse the order
36 # of the $(CPU) and $(OS) bits.
38 # Don't strip the version of the target yet, it might be
39 # useful on some systems.
41 AC_MSG_CHECKING([for AROS style target])
43 if test "$target" = "NONE" ; then
44     target=$host_os-$host_cpu
45 else
46     if test "$target" = "" ; then
47         target=$host_os-$host_cpu
48     fi
50 AC_MSG_RESULT($target)
52 if test "$host_os" = "mingw32" ; then
53     PWDCMD="pwd -W"
56 # Don't know where else to put this...
57 AC_MSG_CHECKING([building AROS in])
58 AROS_BUILDDIR=`${PWDCMD-pwd}`
59 AROS_BUILDDIR_UNIX=${PWD}
60 AC_MSG_RESULT($AROS_BUILDDIR)
62 AC_MSG_CHECKING([AROS source in])
63 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
64 SRCDIR=${srcpwd}
65 AC_MSG_RESULT($SRCDIR)
67 # Parse the target field into something useful.
68 changequote(<<,>>)
69 target_os=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\1/'`
70 target_cpu=`echo $target | sed 's/^\([^-].*\)-\(.*\)$/\2/'`
71 changequote([,])
73 # Some debug output, to be removed again.
74 AC_MSG_CHECKING([for target system (debug output)])
75 AC_MSG_RESULT($target_os)
76 AC_MSG_CHECKING([for target cpu (debug output)])
77 AC_MSG_RESULT($target_cpu)
79 dnl --------------------------------------------------------------------
80 dnl Set the default Workbench resolution
81 dnl --------------------------------------------------------------------
82 aros_nominal_width=800
83 aros_nominal_height=600
84 aros_nominal_depth=4
86 dnl --------------------------------------------------------------------
87 dnl Host Configuration Section
88 dnl --------------------------------------------------------------------
89 dnl
90 dnl The idea here is to find out all the information we need about the
91 dnl host. This means things like tools for building directory structures,
92 dnl copying files around and the like.
94 default_c_compilers="gcc clang cc"
95 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="")
96 if test "$use_c_compiler" = ""; then
97     host_c_compilers="$default_c_compilers"
98 else
99     host_c_compilers="$use_c_compiler"
102 default_cxx_compilers="g++ clang++ c++"
103 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="")
104 if test "$use_cxx_compiler" = ""; then
105         host_cxx_compilers="$default_cxx_compilers"
106 else
107     host_cxx_compilers="$use_cxx_compiler"
111 # The first step is to find the host binaries.
112 # Check for a compiler.
113 # Due to a bug in autoconf check for c++ compiler first.
114 # For mor info see, http://osdir.com/ml/bug-autoconf-gnu/2010-05/msg00001.html.
115 AC_PROG_CXX([${host_cxx_compilers}])
116 CXX_BASE=$CXX
117 AC_PATH_PROG(CXX,$CXX)
118 AC_PROG_CC([${host_c_compilers}])
119 CC_BASE=$CC
120 AC_PATH_PROG(CC,$CC)
121 aros_host_def_cc="$CC"
122 AC_PROG_CC_STDC
123 AC_PROG_CPP
125 # detect the compiler version
126 AC_MSG_CHECKING([which toolchain family ${CC} belongs to])
127 HOST_COMPILER_VERSION=`"$CC" --version 2>/dev/null`
128 if test x"$HOST_COMPILER_VERSION" = "x"; then
129     HOST_COMPILER_VERSION=`"$CC" --qversion 2>/dev/null`
131 if test x"$HOST_COMPILER_VERSION" = "x"; then
132     HOST_COMPILER_VERSION=`"$CC" -V 2>/dev/null`
135 IS_SUN_COMPILER=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'Sun C\+\+'`
136 if test "$IS_SUN_COMPILER" -ne "0"; then
137     HOST_TOOLCHAIN_PREFIX=
138     HOST_TOOLCHAIN_SUFFIX=
139     HOST_TOOLCHAIN_FAMILY=sun
141 IS_LLVM_COMPILER=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'LLVM|clang'`
142 if test "$IS_LLVM_COMPILER" -ne "0"; then
143     HOST_TOOLCHAIN_PREFIX=llvm-
144     if test "$CC_BASE" != "gcc"; then
145         HOST_TOOLCHAIN_SUFFIX="`echo $CC_BASE | sed -e \"s|clang||g\"`"
146     fi
147     HOST_TOOLCHAIN_FAMILY=llvm
149 IS_GNU_COMPILER=`echo $HOST_COMPILER_VERSION | grep -i -c -E 'gcc'`
150 if test "$IS_GNU_COMPILER" -ne "0"; then
151     HOST_TOOLCHAIN_PREFIX=
152     HOST_TOOLCHAIN_SUFFIX=
153     HOST_TOOLCHAIN_FAMILY=gnu
155 if test x"$HOST_TOOLCHAIN_FAMILY" = "x"; then
156     HOST_TOOLCHAIN_FAMILY=unknown
158 AC_MSG_RESULT($HOST_TOOLCHAIN_FAMILY)
160 # Check for a compatible awk
161 AC_CHECK_PROGS(AWK,[gawk nawk])
162 AROS_REQUIRED(gawk,$AWK)
163 AROS_PROG(MMAKE,mmake)
165 # Perform some default variable assignments. Note all of these will be
166 # Regenerated from the script, so there is no need to cache them.
168 aros_build_host=$host
169 aros_host_cpp="$CPP"
170 aros_host_cc="$CC"
171 aros_host_cxx="$CXX"
172 base_ld_name=["${HOST_TOOLCHAIN_PREFIX}ld${HOST_TOOLCHAIN_SUFFIX}"]
173 if test "$HOST_TOOLCHAIN_FAMILY" = "llvm"; then
174     base_ld_name=["ld.lld${HOST_TOOLCHAIN_SUFFIX}"]
176 AROS_TOOL_CCPATH(aros_host_ld,ld,$base_ld_name)
177 AROS_REQUIRED(ld,$aros_host_ld)
178 aros_host_make="make"
179 aros_host_cflags="$CFLAGS"
180 aros_host_cxxflags="$CXXFLAGS"
181 aros_host_cppflags="$CPPFLAGS"
182 aros_host_ldflags="$LDFLAGS"
183 aros_host_debug="-g -O0"
184 aros_host_mkdep="\$(SRCDIR)/scripts/mkdep"
185 aros_host_mkargs="--no-print-directory"
186 aros_host_exe_suffix="$EXEEXT"
187 aros_host_lib_suffix=""
189 # Ignore all compliance, AROS ROMs = 0
190 # KickStart v1.0 = 30
191 # KickStart v1.3 = 34
192 # KickStart v2.0 = 37
193 # KickStart v3.0 = 39
194 # KickStart v3.1 = 40
195 # AmigaOS   v3.5 = 44
196 aros_amigaos_compliance=0
198 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19 aclocal-1.9])
199 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
200 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
201 AC_CHECK_PROGS(aros_host_automake,[automake automake19 automake-1.9])
203 AROS_REQUIRED(aclocal/aclocal19/aclocal-1.9, $aros_host_aclocal)
204 AROS_REQUIRED(automake/automake19/automake-1.9, $aros_host_automake)
206 case "$aros_host_cc" in
207     *clang*)
208         aros_host_cc_pipe=""
209         ;;
210     *gcc*)
211         aros_host_cc_pipe="-pipe"
212         ;;
213     icc)
214         aros_host_cc_pipe=""
215         ;;
216     *)
217         aros_host_cc_pipe=""
218         ;;
219 esac
221 aros_kernel_cc_includes=""
222 aros_target_cc_includes=""
223 host_cc_elf=yes
225 # ----------------------------------------------------------------------------------------
226 # Host-specific defaults
228 # This is the main host configuration section. It is where the host
229 # can change the values of any variables it needs to change. We do
230 # not look at anything that compiles to the target yet, we'll get
231 # to that later.
233 case "$host_os" in
234     aros*)
235         aros_host_arch="aros"
236         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
237         case "$host_cpu" in
238             *i?86*)
239                 aros_host_cpu="i386"
240                 ;;
241             *x86_64*)
242                 aros_host_cpu="x86_64"
243                 ;;
244             *powerpc*)
245                 aros_host_cpu="ppc"
246                 ;;
247             *)
248                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
249                 aros_host_cpu="$host_cpu"
250                 ;;
251         esac
252         ;;
254     linux*)
255         aros_host_arch="linux"
256         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
257         android_build_os="linux-x86"
258         android_tool="android"
259         default_android_sdk="/opt/android-sdk-linux_x86"
260         case "$host_cpu" in
261             *i?86*)
262                 aros_host_cpu="i386"
263                 ;;
264             *x86_64*)
265                 aros_host_cpu="x86_64"
266                 ;;
267             *m68k*)
268                 aros_host_cpu="m68k"
269                 ;;
270             *powerpc*)
271                 aros_host_cpu="ppc"
272                 ;;
273             *arm*)
274                 aros_host_cpu="arm"
275                 ;;
276             *)
277                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
278                 aros_host_cpu="$host_cpu"
279                 ;;
280         esac
281         ;;
283     freebsd*)
284         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe -I/usr/local/include"
285         aros_host_make="gmake"
286         aros_host_arch="freebsd"
287         aros_host_cpu="i386"
289         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
291         dnl FreeBSD 5.x (and later) has changed the default object format.
292         dnl The double [[]] is necessary to get around m4's quoting rules.
293         case $host_os in
294             freebsd[[234]]*)
295                 aros_object_format="elf_i386"
296                 ;;
298             *)
299                 aros_object_format="elf_i386_fbsd"
300                 ;;
301         esac
303         ;;
305     darwin*)
306         AC_MSG_CHECKING([for macOS SDK files])
307         LOC=$( xcode-select -p )
308         AS_IF([ test $? != 0],[AC_MSG_ERROR([XCode incorrectly configured!
309 please run 'xcode-select --install' before
310 re-running configure])])
311         AC_MSG_RESULT($LOC)
312         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
313         aros_host_arch="darwin"
314         host_cc_elf=no
315         if [[ -z ${SED+x} ]]; then SED="gsed"; fi
316         android_build_os="darwin-x86"
317         android_tool="android"
318         default_android_sdk="/android-sdk-mac_x86"
319         case "$host_cpu" in
320             *i?86*)
321                 aros_host_cpu="i386"
322                 ;;
323             *x86_64*)
324                 aros_host_cpu="x86_64"
325                 ;;
326             *powerpc*)
327                 aros_host_cpu="ppc"
328                 ;;
329             *)
330                 AC_MSG_WARN("Unknown CPU for Darwin host -- $host_cpu")
331                 aros_host_cpu="$host_cpu"
332                 ;;
333         esac
335         aros_host_ldflags="$aros_host_ldflags -liconv"
337         ;;
339     dragonfly*)
340         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
341         aros_host_make="gmake"
342         aros_host_arch="dragonfly"
343         case $host_cpu in
344             *i?86*)
345                 aros_host_cpu="i386"
346                 ;;
347             *amd64*)
348                 aros_host_cpu="x86_64"
349                 ;;
350             *)
351                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
352                 aros_host_cpu="$host_cpu"
353                 ;;
354         esac
355         ;;
357     netbsd*)
358         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
359         aros_host_make="gmake"
360         aros_host_arch="netbsd"
361         case "$host_cpu" in
362             *i?86*)
363                 aros_host_cpu="i386"
364                 ;;
365             *m68k*)
366                 aros_host_cpu="m68k"
367                 ;;
368             *)
369                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
370                 aros_host_cpu="$host_cpu"
371                 ;;
372         esac    
373         aros_host_lib_suffix=".0.0"
374         ;;
376     openbsd*)
377         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
378         aros_host_make="gmake"
379         aros_host_arch="openbsd"
380         case "$host_cpu" in
381             *i?86*)
382                 aros_host_cpu="i386"
383                 ;;
384             *)
385                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
386                 aros_host_cpu="$host_cpu"
387                 ;;
388         esac
389         ;;
390         
391     solaris*)
392         aros_host_arch="solaris"
393         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
394         case "$host_cpu" in
395             *i?86*)
396                 aros_host_cpu="i386"
397                 ;;
398             *sparc*)
399                 aros_host_cpu="sparc"
400                 ;;
401             *)
402                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
403                 aros_host_cpu="$host_cpu"
404                 ;;
405         esac
406         ;;
408     morphos*)
409         aros_host_arch="morphos"
410         aros_host_cpu="ppc"
411         host_cc_elf=no
412         ;;
414     amiga*)
415         aros_host_arch="amiga"
416         host_cc_elf=no
417         SORT="/gg/bin/sort"
418         TEST="/gg/bin/test"
419         UNIQ="/gg/bin/uniq"
420         FOR="for"
421         TOUCH="/gg/bin/touch"
422         case "$host_cpu" in
423             *m68k*)
424                 aros_host_cpu="m68k"
425                 ;;
426             *powerpc*)
427                 aros_host_cpu="ppc"
428                 ;;
429             *)
430                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
431                 aros_host_cpu="$host_cpu"
432                 ;;
433         esac
434         ;;
436     cygwin*)
437         aros_host_arch="cygwin"
438         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
439         host_cc_elf=no
440         android_build_os="windows"
441         android_tool="android.bat"
442         default_android_sdk="/cygdrive/c/android-sdk-windows-1.6_r1"
444         case "$host_cpu" in
445             *i?86*)
446                 aros_host_cpu="i386"
447                 ;;
448             *)
449                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
450                 aros_host_cpu="$host_cpu"
451                 ;;
452         esac
453         ;;
455     mingw32*)
456         aros_host_arch="mingw32"
457         aros_host_cflags="$aros_host_cflags $aros_host_cc_pipe"
458         host_cc_elf=no
459         android_build_os="windows"
460         android_tool="android.bat"
461         default_android_sdk="/c/android-sdk-windows-1.6_r1"
463         libpng_libextra="-lws2_32"
465         case "$host_cpu" in
466         *i?86*)
467             dnl Currently there's neither 64-bit MinGW nor MSYS. Both environments are 32-bit
468             dnl and run under emulation. Consequently, uname reports i386 even on 64-bit systems.
469             dnl Here we attempt to detect Windows home platform by asking gcc about its target.
470             dnl 64-bit gcc will output "x86_64-w64-mingw32" here.
472             AC_MSG_CHECKING([for Windows native gcc target])
473             host_cpu=`gcc -dumpmachine`
474             AC_MSG_RESULT($host_cpu)
475             ;;
477         esac
479         case "$host_cpu" in
480         *i?86*)
481             aros_host_cpu="i386"
482             ;;
484         mingw32*)
485             dnl Native i386 gcc for MinGW32 reports 'mingw32' with -dumpmachine switch
486             aros_host_cpu="i386"
487             ;;
489         *x86_64*)
490             aros_host_cpu="x86_64"
491             dnl Dragon's x86_64-w64-mingw32-gcc is a bit broken. It ignores standard $prefix/include
492             dnl directory, so we have to add it explicitly here.
493             aros_host_cflags="$aros_host_cflags -isystem /mingw/include"
494             ;;
496         *)
497             AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
498             aros_host_cpu="$host_cpu"
499             ;;
500         esac
501         ;;
502     *)
503         AC_MSG_ERROR([Unsupported host architecture $host])
504         ;;
505 esac
507 base_ar_name=${HOST_TOOLCHAIN_PREFIX}ar${HOST_TOOLCHAIN_SUFFIX}
508 AROS_PROG(aros_host_cmd_ar,$base_ar_name,[cr])
509 AROS_PATH_PROG(aros_host_full_ar,$aros_host_cmd_ar)
510 aros_host_ar=`echo $aros_host_cmd_ar | sed -e "s|$base_ar_name|$aros_host_full_ar|g"`
511 AROS_REQUIRED(ar,$aros_host_ar)
512 base_ranlib_name=${HOST_TOOLCHAIN_PREFIX}ranlib${HOST_TOOLCHAIN_SUFFIX}
513 AROS_PATH_PROG(aros_host_ranlib,$base_ranlib_name)
514 AROS_REQUIRED(ranlib,$aros_host_ranlib)
515 AROS_PROG(aros_host_strip,strip)
516 AROS_REQUIRED(strip,$aros_host_strip)
518 AROS_PROG(RM,[rm],[-rf])
519 AROS_REQUIRED(rm,$RM)
520 AROS_PROG(CP,[cp])
521 AROS_REQUIRED(cp,$CP)
522 AROS_PROG(MV,[mv])
523 AROS_REQUIRED(mv,$MV)
524 AROS_PROG(ECHO,[echo])
525 AROS_REQUIRED(echo,$ECHO)
526 AROS_PROG(MKDIR,[mkdir],[-p])
527 AROS_REQUIRED(mkdir,$MKDIR)
528 AROS_PROG(TOUCH,[touch])
529 AROS_REQUIRED(touch,$TOUCH)
530 AROS_PROG(SORT,[sort])
531 AROS_REQUIRED(sort,$SORT)
532 AROS_PROG(UNIQ,[uniq])
533 AROS_REQUIRED(uniq,$UNIQ)
534 AROS_PROG(NOP,[true])
535 AROS_REQUIRED(true,$NOP)
536 AROS_PROG(CAT,[cat])
537 AROS_REQUIRED(cat,$CAT)
538 AROS_PROG(BISON,[bison])
539 AROS_REQUIRED(bison,$BISON)
540 AROS_PROG(FLEX,[flex])
541 AROS_REQUIRED(flex,$FLEX)
542 AC_MSG_CHECKING([version of $FLEX])
543 ax_cv_flex_version="`$FLEX --version | cut -d\" \" -f2`"
544 AC_MSG_RESULT($ax_cv_flex_version)
545 AROS_PROG(PNGTOPNM,[pngtopnm])
546 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
547 AROS_PROG(PPMTOILBM,[ppmtoilbm])
548 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
549 AROS_PROG(SED,[sed])
550 AROS_REQUIRED(sed,$SED)
551 AROS_PROG(CHMOD,[chmod])
552 AROS_REQUIRED(chmod,$CHMOD)
553 AROS_PROG(PATCH,[patch])
554 AROS_REQUIRED(patch,$PATCH)
556 AM_PATH_PYTHON(2.5)
558 AC_ARG_ENABLE([libpng-config], [--disable-libpng-config    disable libpng-config test and configuration])
559 if test "$enable_libpng_config" != "no"; then
560   AC_CHECK_PROG([arosconfig_use_libpngconfig],[libpng-config],[yes],[no])
562 if test "$arosconfig_use_libpngconfig" = "yes"; then
563     AC_MSG_CHECKING([libpng-config library])
564     libpng_incdir="`libpng-config --cflags`"
565     libpng_libextra="$libpng_libextra `libpng-config --ldflags`"
566     libpng="`libpng-config --libs`"
567     AC_MSG_RESULT($libpng)
568 else
569     AC_CHECK_LIB(png, png_read_png, [libpng="-lpng"], [libpng="no"])
570     if test "$libpng_libextra" != ""; then
571         if test "$libpng" != "no"; then
572             libpng_libextra="$libpng_libextra $libpng"
573         fi
574     fi
576 AROS_REQUIRED(libpng, $libpng)
577 AC_SUBST(libpng)
578 AC_SUBST(libpng_libextra)
579 AC_SUBST(libpng_incdir)
581 AC_SUBST(FOR, for)
582 AC_SUBST(IF, if)
583 AC_SUBST(TEST, test)
584 AC_SUBST(CMP, cmp)
586 dnl ---------------------------------------------------------------------------
587 dnl Look for things about the host system, good for hosted targets.
588 dnl ---------------------------------------------------------------------------
590 # Check for some includes for the X11 HIDD and the kernel
591 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
592     sys/mmap.h sys/mman.h sysexits.h \
593     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
596 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
597 AC_CHECK_HEADERS([GL/glx.h],[host_feature_glx=yes],[host_feature_glx=no],)
599 AC_MSG_CHECKING([if __unused conflicts with sys/stat.h])
600 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
601      [[
602      #define __unused __attribute__((unused))
603      #include <sys/stat.h>
604      ]])],
605      [host_stat_h__unused_used=no],
606      [host_stat_h__unused_used=yes])
607 AC_MSG_RESULT($host_stat_h__unused_used)
609 AC_HEADER_DIRENT
610 AC_HEADER_STAT
611 AC_HEADER_STDC
612 AC_HEADER_SYS_WAIT
613 AC_HEADER_TIME
614 AC_STRUCT_ST_BLKSIZE
615 AC_STRUCT_ST_BLOCKS
616 AC_STRUCT_ST_RDEV
617 AC_STRUCT_TM
618 AC_STRUCT_TIMEZONE
619 AC_TYPE_OFF_T
620 AC_TYPE_PID_T
621 AC_TYPE_SIZE_T
622 AC_TYPE_UID_T
624 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
626 # Look for some functions
627 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
628     clone kse_create rfork_thread thr_create sa_register \
629     getcontext makecontext setcontext sigaltstack swapcontext])
631 AC_FUNC_MMAP
633 #-----------------------------------------------------------------------------
636 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
637 # it switched on by default, and we use the host compiler, so it compiles AROS
638 # code with this enabled resulting in link failures as we don't have support
639 # for it.
641 # We use two methods to disable it. For the host compiler (used to compile
642 # some hosted modules), we test to see if the compiler supports stack
643 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
644 # work on all platforms.
647 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
648 save_cflags="$CFLAGS"
649 CFLAGS="$CFLAGS -fno-stack-protector"
650 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
651 AC_MSG_RESULT($use_no_stack_protector)
652 if test "x-$use_no_stack_protector" = "x-yes" ; then
653     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
655 CFLAGS="$save_cflags"
657 #-----------------------------------------------------------------------------
659 # Disable pointer-signedness warnings if the compiler recognises the option
660 # (this only works for the host compiler at the moment)
662 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
663 save_cflags="$CFLAGS"
664 CFLAGS="$CFLAGS -Wno-pointer-sign"
665 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
666 AC_MSG_RESULT($use_no_sign_warning)
667 if test "x-$use_no_sign_warning" = "x-yes" ; then
668     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
670 CFLAGS="$save_cflags"
672 #-----------------------------------------------------------------------------
674 # Check if host compiler supports -fgnu89-inline, can be needed for crosstools.
676 AC_MSG_CHECKING([whether ${CC} accepts -fgnu89-inline])
677 save_cflags="$CFLAGS"
678 CFLAGS="$CFLAGS -fgnu89-inline"
679 AC_TRY_COMPILE(,, use_gnu89_inline="yes", use_gnu89_inline="no")
680 AC_MSG_RESULT($use_gnu89_inline)
681 if test "x-$use_gnu89_inline" = "x-yes" ; then
682     gnu89_inline="-fgnu89-inline"
684 CFLAGS="$save_cflags"
687 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
688 # On GCC >= 4.0 -iquote should be used
690 AC_MSG_CHECKING([whether ${CC} accepts -iquote])
691 CFLAGS="$CFLAGS -iquote."
692 AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
693 AC_MSG_RESULT($has_iquote)
694 if test "x-$has_iquote" = "x-yes" ; then
695     host_cflags_iquote=-iquote
696     host_cflags_iquote_end=
697 else
698     host_cflags_iquote=-I
699     host_cflags_iquote_end=-I-
702 AC_MSG_NOTICE([Performing target configuration...])
704 dnl --------------------------------------------------------------------
705 dnl Target Configuration Section
706 dnl --------------------------------------------------------------------
708 dnl The target configuration section is responsible for setting up all
709 dnl the paths for includes, and tools required to build AROS to some
710 dnl particular target.
712 test_kernel_cc=no
714 aros_nowarn_flags="NOWARN_UNUSED_COMMAND_LINE_ARGUMENT NOWARN_UNKNOWN_WARNING_OPTION NOWARN_POINTER_SIGN NOWARN_PARENTHESES"
715 export_newline="
718 aros_elf_translate=
719 aros_warn_flags=
720 aros_isa_extra=
721 aros_isa_flags=
722 aros_config_cppflags=
723 aros_config_cflags=
724 aros_config_cxxflags=
725 aros_config_aflags="$""(WARN_ALL) -x assembler-with-cpp -c"
726 aros_config_ldflags=""
728 aros_shared_default=yes
730 aros_shared_cflags="-fPIC"
731 aros_shared_aflags=""
732 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
733 aros_kernel_ldflags="-Wl,-rpath,./lib"
735 aros_kernel_ar_flags="cr"
736 aros_target_ar_flags="cr"
737 aros_target_nm_flags="-C -ul"
738 aros_target_strip_flags="--strip-unneeded -R.comment"
740 aros_c_libs=
741 aros_cxx_libs=
743 aros_target_genmap="-Wl,-Map -Xlinker"
745 # Native flavour stuff
746 aros_serial_debug="0"
748 # Palm native flavour stuff
749 aros_palm_debug_hack="0"
751 # Unix flavour stuff
752 aros_nesting_supervisor="0"
754 # Collect-aros stuff: "-ius" to ignore undefined symbols
755 ignore_undefined_symbols=""
757 # Check for X11 by default
758 need_x11="auto"
760 AC_MSG_CHECKING([Which toolchain family to use ...])
761 AC_ARG_WITH(toolchain,AC_HELP_STRING([--with-toolchain=family],[Which toolchain family to crosscompile with (defaults to gnu)]),aros_toolchain="$withval",aros_toolchain="$default_toolchain_family")
762 AC_MSG_RESULT($aros_toolchain)
765 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
766 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
767  aros_config_lto="$enableval",aros_config_lto="no")
768 if test "$aros_config_lto" != "no"; then
769     aros_config_lto="yes"
771 AC_MSG_RESULT($aros_config_lto)
773 AC_MSG_CHECKING([if we should enable coverage instrumentation])
774 AC_ARG_ENABLE(coverage,AC_HELP_STRING([--enable-coverage=[yes|no]],[Enable coverage instrumentation if the target compiler supports it (default=no)]),
775  aros_config_coverage="$enableval",aros_config_coverage="no")
776 if test "$aros_config_coverage" != "no"; then
777     aros_config_coverage="yes"
779 AC_MSG_RESULT($aros_config_coverage)
781 use_ld_wrapper=yes
783 case "$aros_toolchain" in
784     *llvm*)
785         toolchain_c_compiler="clang"
786         toolchain_cxx_compiler="clang++"
787         toolchain_cpp_preprocessor="clang -E"
788         toolchain_ld="ld.lld"
789         aros_ld="ld"
790         toolchain_as="llvm-as"
791         toolchain_ar="llvm-ar"
792         toolchain_ranlib="llvm-ranlib"
793         toolchain_nm="llvm-nm"
794         toolchain_strip="true"
795         toolchain_objcopy="llvm-objcopy"
796         toolchain_objdump="llvm-objdump"
797         use_libatomic=yes
798         ;;
799     *gnu*)
800         toolchain_c_compiler="gcc"
801         toolchain_cxx_compiler="g++"
802         toolchain_cpp_preprocessor="gcc -E"
803         toolchain_as="as"
804         aros_ld="ld"
805         if test "$aros_config_lto" != "yes"; then
806             toolchain_ld="ld"
807             toolchain_ar="ar"
808             toolchain_ranlib="ranlib"
809             toolchain_nm="nm"
810         else
811             toolchain_ld="ld.bfd"
812             toolchain_ar="gcc-ar"
813             toolchain_ranlib="gcc-ranlib"
814             toolchain_nm="gcc-nm"
815         fi
816         toolchain_strip="strip"
817         toolchain_objcopy="objcopy"
818         toolchain_objdump="objdump"
819         use_libatomic=yes
820         ;;
821     *)
822         AC_MSG_WARN("Unknown toolchain family!")
823         toolchain_c_compiler="cc"
824         toolchain_cxx_compiler="c++"
825         toolchain_cpp_preprocessor="cpp"
826         toolchain_ld="ld"
827         aros_ld="ld"
828         toolchain_as="as"
829         toolchain_ar="ar"
830         toolchain_ranlib="ranlib"
831         toolchain_nm="nm"
832         toolchain_strip="strip"
833         toolchain_objcopy="objcopy"
834         toolchain_objdump="objdump"
835         ;;
836 esac
838 #-----------------------------------------------------------------------------
840 AC_MSG_CHECKING([which type of build to do])
841 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")
843 if test "$build_type" = "nightly"; then
844     build_type_string="NIGHTLY"
845 elif test "$build_type" = "snapshot"; then
846     build_type_string="SNAPSHOT"
847 elif test "$build_type" = "milestone"; then
848     build_type_string="MILESTONE"
849 elif test "$build_type" = "release"; then
850     build_type_string="RELEASE"
851 else
852     build_type_string="PERSONAL"
853     build_type="personal"
856 aros_config_cppflags="$aros_config_cppflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
858 AC_MSG_RESULT($build_type)
860 #-----------------------------------------------------------------------------
861 all_debug_types="messages stack modules mungwall symbols"
863 AC_MSG_CHECKING([which debug types to enable])
864 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)]),
865  debug="$enableval",debug="")
867 if test "$debug" = "" -o "$debug" = "no"; then
868     debug="none"
869 elif test "$debug" = "yes"; then
870     debug="all"
873 if test "$debug" = "all" ; then
874     debug="messages stack modules symbols"
875     for d in $all_debug_types; do
876         export aros_${d}_debug="1"
877     done
878 else
879     for d in $all_debug_types; do
880         export aros_${d}_debug="0"
881     done
884 if test "$debug" != "none"; then
885     debug=`echo $debug | sed s/,/\ /g`
886     for d in $debug; do
887         found="0"
888         for d2 in $all_debug_types; do
889             if test "$d2" = "$d"; then
890                 found="1"
891                 break
892             fi
893         done
894         if test "$found" = "0"; then
895             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
896         fi
897         export aros_${d}_debug="1"
898     done
899     aros_debug="yes"
901 AC_MSG_RESULT($debug)
903 if test "$aros_messages_debug" = "1"; then
904     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
905 else
906     aros_messages_debug=""
908 if test "$aros_symbols_debug" = "1"; then
909     aros_symbols_debug="-g"
910 else
911     aros_symbols_debug=""
914 # These are the flags to pass when compiling debugged programs
915 aros_debug_cppflags="$aros_messages_debug"
916 aros_debug_cflags="$aros_symbols_debug"
917 aros_debug_cxxflags=
918 aros_debug_aflags=""
919 aros_debug_ldflags="$aros_symbols_debug"
921 #-----------------------------------------------------------------------------
922 #   Checking for distcc and ccache.
924 #   Always apply the transforms in this particular order. Basically you should
925 #   always run 'ccache distcc compiler' in that order for the best performance.
927 AC_MSG_CHECKING([whether to enable distcc])
928 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
929 if test "$distcc" != "" -a "$distcc" != "no"; then
930     # AC_CHECK_PROG will print out the result in this case
931     AC_PATH_PROG(DISTCC,[distcc],distcc,)
932 else
933     AC_MSG_RESULT(no)
936 AC_MSG_CHECKING([whether to enable ccache])
937 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
938 if test "$ccache" != "" -a "$ccache" != "no"; then
939     # AC_CHECK_PROG will print out the result in this case
940     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
941 else
942     AC_MSG_RESULT(no)
945 #-----------------------------------------------------------------------------
946 AC_MSG_CHECKING([what specific host gcc version to use])
947 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="")
948 if test "$kernel_tool_version" != "" ; then
949     msg_result=$kernel_tool_version
950 else
951     msg_result="default"
953 AC_MSG_RESULT($msg_result)
955 #-----------------------------------------------------------------------------
956 AC_MSG_CHECKING([what optimization flags to use])
957 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (e.g --with-optimization=-O2).]),optimization_level="$withval",optimization_level="unknown")
958 if test "$optimization_level" = "unknown"; then
959     dnl default is -O2 for normal builds, -O0 for debug builds
960     optimization="default"
961     if test "$debug" != "none"; then
962         optimization_level="-O0"
963     else
964         optimization_level="-O2"
965     fi
966 else
967     optimization="$optimization_level"
969 AC_MSG_RESULT($optimization)
971 paranoia_default=yes
972 #-----------------------------------------------------------------------------
973 AC_MSG_CHECKING([which paranoia flags to use])
974 AC_ARG_WITH(paranoia,AC_HELP_STRING([--with-paranoia=(yes|no|FLAGS)],[Specific compiler warning FLAGS to enable for paranoia builds (default=-Wall -Werror)]),[paranoia_flags="$withval"],[paranoia_flags="$paranoia_default"])
975 if test "$paranoia_flags" = "no"; then
976         paranoia_flags="$""(WARN_ALL) -Werror-implicit-function-declaration"
977         msg_result="none"
978 else
979     if test "$paranoia_flags" = "yes"; then
980         paranoia_flags="$""(WARN_ALL) $""(WARN_ERROR)"
981     fi
982     msg_result="$paranoia_flags"
984 AC_MSG_RESULT($msg_result)
985 aros_warn_flags="$aros_warn_flags $paranoia_flags"
987 #-----------------------------------------------------------------------------
988 AC_MSG_CHECKING([what target variant to enable])
989 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
990 if test "$target_variant" = ""; then
991     aros_target_variant=""
992     aros_target_suffix=""
993     enableval="none"
994 else
995     aros_target_variant="$target_variant"
996     aros_target_suffix="-$target_variant"
998 AC_MSG_RESULT($enableval)
1000 #-----------------------------------------------------------------------------
1001 # Target-specific defaults. You can override then on a per-target basis.
1003 # Bootloader name. Currently used by PC target.
1004 target_bootloader="none"
1005 PLATFORM_EXECSMP=
1006 ENABLE_EXECSMP=
1008 #-----------------------------------------------------------------------------
1009 # Additional options for some specific targets
1011 case "$aros_target_variant" in
1012 ios)
1013     AC_MSG_CHECKING([XCode path])
1014     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")
1015     AC_MSG_RESULT($aros_xcode_path)
1017     AC_MSG_CHECKING([what iOS SDK version to use])
1018     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")
1019     AC_MSG_RESULT($aros_sdk_version)
1021     ;;
1023 "android")
1024     AC_MSG_CHECKING([Android SDK path])
1025     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)
1026     AC_MSG_RESULT($aros_android_sdk)
1028     AC_MSG_CHECKING([Android NDK path])
1029     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
1030     AC_MSG_RESULT($aros_android_ndk)
1032     AC_MSG_CHECKING([what Android SDK version to use])
1033     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")
1034     AC_MSG_RESULT($aros_sdk_version)
1036     aros_android_level=android-$aros_sdk_version
1037     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
1038         echo "Platform $aros_android_level is not installed in your SDK"
1039         echo "Use --with-sdk-version=<API level number> to select another platform version"
1040         echo "You can check what plaform versions are installed in your SDK"
1041         echo "by examining contents of $aros_android_sdk/platforms directory"
1042         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
1043     fi
1045     export PATH="$aros_android_sdk/tools:$PATH"
1046     AC_PATH_PROG(android_tool, $android_tool)
1047     AROS_REQUIRED(android,$android_tool)
1049     if test "$aros_android_ndk" != "none"; then
1050         AC_MSG_CHECKING([what Android NDK version to use])
1051         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")
1052         AC_MSG_RESULT($aros_ndk_version)
1053     fi
1055     AC_PATH_PROG(ant, ant)
1056     if test "$ant" = ""; then
1057         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
1058     fi
1060     AC_MSG_CHECKING([Build debug or release apk])
1061     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)
1062     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
1063         AC_MSG_ERROR([apk-version has to be release or debug])
1064     fi
1065     AC_MSG_RESULT($aros_android_antapk)
1067     target_extra_cfg+="$export_newline""# Android$export_newline""AROS_ANDROID_ANTAPK           := $aros_android_antapk$export_newline"
1068     host_extra_cfg+="$export_newline""# Android-specific$export_newline""ANDROID                       := $android_tool$export_newline""ANT                                   := $ant$export_newline"
1069     aros_target_options+="$export_newline""# Enable Android Gfx Driver$export_newline""OPT_HOST_ANDROIDGFX           := yes$export_newline"
1071     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
1072     if test "$host_os" = "mingw32"; then
1073         android_tool="cmd //c $android_tool"
1074     fi
1076     need_dlopen="no"
1078     ;;
1079 esac
1081 #-----------------------------------------------------------------------------
1082 # External toolchains
1083 kernel_tool_prefix="none"
1084 aros_tool_prefix="none"
1085 elf_tool_prefix="${target_cpu}-elf-"
1087 # Base target cpu ISA configuration switch.
1088 case "$target_cpu" in
1089     *aarch64*)
1090         ;;
1091     *arm*)
1092         ;;
1093     *m68k*)
1094         m68k_isa_extra="ISA_MC68000_FLAGS             = -march=68000"
1095         m68k_020_isa_extra="ISA_MC68020_FLAGS             = -march=68020"
1096         m68k_030_isa_extra="ISA_MC68030_FLAGS             = -march=68030"
1097         m68k_040_isa_extra="ISA_MC68040_FLAGS             = -march=68040"
1098         m68k_060_isa_extra="ISA_MC68060_FLAGS             = -march=68060"
1099         m68k_ac080_isa_extra="ISA_AC68080_FLAGS             = -march=68040"
1100         m68k_020_ext="ISA_MC68020_EXT               :=020"
1101         m68k_030_ext="ISA_MC68030_EXT               :=030"
1102         m68k_040_ext="ISA_MC68040_EXT               :=040"
1103         m68k_060_ext="ISA_MC68060_EXT               :=060"
1104         m68k_020_cflags="ISA_MC68020_CFLAGS            ="
1105         m68k_030_cflags="ISA_MC68030_CFLAGS            ="
1106         m68k_040_cflags="ISA_MC68040_CFLAGS            ="
1107         m68k_060_cflags="ISA_MC68060_CFLAGS            ="
1108         m68k_020_cppflags="ISA_MC68020_CPPFLAGS          ="
1109         m68k_030_cppflags="ISA_MC68030_CPPFLAGS          ="
1110         m68k_040_cppflags="ISA_MC68040_CPPFLAGS          ="
1111         m68k_060_cppflags="ISA_MC68060_CPPFLAGS          ="
1112         m68k_020_ldflags="ISA_MC68020_LDFLAGS           ="
1113         m68k_030_ldflags="ISA_MC68030_LDFLAGS           ="
1114         m68k_040_ldflags="ISA_MC68040_LDFLAGS           ="
1115         m68k_060_ldflags="ISA_MC68060_LDFLAGS           ="
1116         ;;
1117     *x86_64* | *i?86*)
1118         x86_isa_extra="ISA_X86_FLAGS                 = -m32 -march=i486"
1119         x86_64_isa_extra="ISA_X8664_FLAGS               = -mcmodel=large"
1120         ;;
1121     *powerpc*)
1122         ;;
1123 esac
1125 # This is the target configuration switch.
1126 case "$target_os" in
1127     linux*)
1128         aros_target_arch="linux"
1129         aros_target_family="unix"
1130         case "$target_cpu" in
1131             *m68k*)
1132                 aros_target_cpu="m68k"
1133                 aros_object_format="m68kelf"
1134                 aros_flavour="emulcompat"
1135                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1136                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1137                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1138                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1139                 gcc_target_cpu="mc68000"
1140                 ;;
1141             *i?86*)
1142                 aros_target_cpu="i386"
1143                 aros_object_format="elf_i386"
1144                 aros_flavour="emulation"
1145                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1146                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1147                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1148                 aros_kernel_ldflags="-Wl,-melf_i386"
1149                 aros_nominal_depth=8
1150                 gcc_target_cpu="i386"
1151                 pci_hidd_target="hidd-pci-linux"
1152                 android_tool_dir_prefix="x86"
1153                 android_tool_prefix="i686-android-linux"
1154                 android_ndk_arch="x86"
1155                 ;;
1156             *x86_64*)
1157                 aros_target_cpu="x86_64"
1158                 aros_object_format="elf_x86_64"
1159                 aros_flavour="emulation"
1160                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1161                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1162                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1163                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1164                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1165                 aros_nominal_depth=8
1166                 pci_hidd_target="hidd-pci-linux"
1167                 ;;
1168             *powerpc*)
1169                 aros_target_cpu="ppc"
1170                 aros_object_format="elf32ppc"
1171                 aros_flavour="emulation"
1172                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1173                 aros_nominal_depth=8
1174                 gcc_target_cpu="ppc"
1175                 ;;
1176 # TODO
1177 # Same as powerpc, but I need this for the nightly build to work again.
1178 # Actually, the nightly should be made working with powerpc target.
1179 # That just was too much work for the moment, another week or two.
1180             *ppc*)
1181                 aros_target_cpu="ppc"
1182                 aros_object_format="elf32ppc"
1183                 aros_flavour="emulation"
1184                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1185                 aros_nominal_depth=8
1186                 gcc_target_cpu="ppc"
1187                 ;;
1188             *aarch64*)
1189                 aros_target_cpu="aarch64"
1190                 target_cpu="aarch64"
1191                 aros_object_format="aarch64elf_aros"
1192                 aros_flavour="emulation"
1193                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1194                 gcc_target_cpu="aarch64"
1195                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1196                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1197                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1198                 aros_c_libs="$aros_c_libs -laeabi"
1199                 gcc_default_float_abi="hard"
1200                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1201                 ;;
1202             *armhf*)
1203                 aros_target_cpu="arm"
1204                 target_cpu="arm"
1205                 aros_object_format="armelf_aros"
1206                 aros_flavour="emulation"
1207                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1208                 gcc_target_cpu="arm"
1209                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1210                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1211                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1212                 aros_c_libs="$aros_c_libs -laeabi"
1213                 gcc_default_float_abi="hard"
1214                 android_tool_dir_prefix="arm-linux-androideabi"
1215                 android_tool_prefix="arm-linux-androideabi"
1216                 android_ndk_arch="arm"
1217                 kernel_tool_prefix="arm-linux-gnueabihf-"
1218                 ;;
1219             *arm*)
1220                 aros_target_cpu="arm"
1221                 aros_object_format="armelf_aros"
1222                 aros_flavour="emulation"
1223                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1224                 gcc_target_cpu="arm"
1225                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1226                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1227                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1228                 aros_c_libs="$aros_c_libs -laeabi"
1229                 android_tool_dir_prefix="arm-linux-androideabi"
1230                 android_tool_prefix="arm-linux-androideabi"
1231                 android_ndk_arch="arm"
1232                 kernel_tool_prefix="arm-linux-gnueabi-"
1233                 ;;
1234             *)
1235                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1236                 ;;
1237         esac
1238         case "$aros_target_variant" in
1239             android)
1241                 dnl Not all Linux CPUs are supported by Android
1242                 if test "$android_ndk_arch" = ""; then
1243                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1244                 fi
1246                 aros_nominal_width=320
1247                 aros_nominal_height=480
1248                 if test "$aros_android_ndk" = "none"; then
1249                     dnl Use standalone toolchain, don't adjust paths
1250                     aros_kernel_cflags="-mandroid"
1251                     aros_kernel_ldflags="-mandroid"
1252                     CFLAGS="-mandroid"
1253                 else
1254                     dnl In Android NDK toolchains are placed in own directories,
1255                     dnl but tool names are not suffixed with version 
1256                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1257                     kernel_tool_version=""
1258                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1259                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1260                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1261                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1262                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1263                 fi
1264                 need_x11=no
1265                 # Disable implicit PIC mode
1266                 aros_config_cflags="$aros_config_cflags -fno-pic"
1267                 kernel_tool_prefix="$android_tool_prefix-"
1268             ;;
1269         esac
1270     ;;
1272     pc)
1273         aros_target_arch="pc"
1274         aros_shared_default="no"
1275         target_bootloader="grub2"
1276         case "$target_cpu" in
1277             *i?86*)
1278                 aros_target_cpu="i386"
1280                 dnl If somebody hasn't already set the target object
1281                 dnl format, then use this value. Mostly to support
1282                 dnl FreeBSD cross-compilation.
1283                 dnl TODO: Remove when we always use our compiler.
1285                 if test "$aros_object_format" = "" ; then
1286                     aros_object_format="elf_i386"
1287                 fi
1288                 aros_flavour="standalone"
1289                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1290                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1291                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1292                 aros_kernel_ldflags="-Wl,-melf_i386"
1293                 aros_nominal_width=640
1294                 aros_nominal_height=480
1295                 gcc_target_cpu="i386"
1296                 ;;
1297             *x86_64*)
1298                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1299                 aros_target_cpu="x86_64"
1300                 aros_serial_debug=1
1301                 if test "$aros_object_format" = "" ; then
1302                     aros_object_format="elf_x86_64"
1303                 fi
1304                 aros_flavour="standalone"
1305                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1306                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1307                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1308                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1309                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1310                 aros_kernel_ldflags=""
1311                 aros_nominal_width=640
1312                 aros_nominal_height=480
1313                 case "$aros_target_variant" in
1314                     smp)
1315                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1316                     ;;
1317                 esac
1318                 ;;
1319             *)
1320                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1321                 ;;
1322         esac
1323         ;;
1325     prep)
1326         aros_target_arch="prep"
1327         aros_shared_default="no"
1328         aros_target_cpu="ppc"
1329         aros_object_format="elf32ppc"
1330         aros_flavour="ppcnative"
1331         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1332         aros_kernel_ldflags=""
1333         aros_nominal_width=640
1334         aros_nominal_height=480
1335         gcc_target_cpu="ppc"
1336         ;;
1338     freebsd*)
1339         aros_target_arch="freebsd"
1340         aros_target_family="unix"
1341         aros_target_cpu="i386"
1342         aros_flavour="emulation"
1343         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1344         gcc_target_cpu="i386"
1346         aros_target_strip_flags="-x"
1347         ;;
1349     darwin*)
1350         aros_target_arch="darwin"
1351         aros_target_family="unix"
1352         aros_flavour="emulation"
1353         case "$target_cpu" in
1354             *i?86*)
1355                 aros_ios_platform="iPhoneSimulator"
1356                 aros_target_cpu="i386"
1357                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1358                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1359                 aros_kernel_ldflags=""
1360                 aros_macosx_version="10.4"
1361                 aros_nominal_depth=8
1362                 gcc_target_cpu="i386"
1363                 aros_object_format="elf_i386"
1364                 aros_kernel_ar_flags="-cr"
1365                 aros_target_strip_flags="-x"
1366                 kernel_tool_flags="-m32"
1367                 ;;
1368             *x86_64*)
1369                 aros_target_cpu="x86_64"
1370                 aros_object_format="elf_x86_64"
1371                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1372                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1373                 aros_macosx_version="10.6"
1374                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1375                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1376                 aros_kernel_cflags="-m64"
1377                 aros_kernel_ldflags="-m64"
1378                 aros_nominal_depth=8
1379                 aros_kernel_rs="$AR"
1380                 aros_kernel_ar_flags="-cr"
1381                 aros_kernel_ld="$LD"
1382                 aros_kernel_as="$AS"
1383                 aros_kernel_ranlib="$RANLIB"
1384                 aros_kernel_nm="$NM"
1385                 aros_kernel_strip="strip"
1386                 kernel_tool_prefix="i686-apple-darwin10-"
1387                 ;;
1388             *ppc*)
1389                 aros_target_cpu="ppc"
1390                 aros_object_format="elf32ppc"
1391                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1392                 aros_kernel_ldflags=""
1393                 aros_macosx_version="10.0"
1394                 aros_nominal_depth=8
1395                 gcc_target_cpu="ppc"
1396                 aros_kernel_rs="$AR"
1397                 aros_kernel_ar_flags="-cr"
1398                 aros_kernel_ld="$LD -arch ppc"
1399                 aros_kernel_as="$AS -arch ppc"
1400                 aros_kernel_ranlib="$RANLIB -arch ppc"
1401                 aros_kernel_nm="$NM -arch ppc"
1402                 aros_kernel_strip="strip -arch ppc"
1403                 kernel_tool_prefix="powerpc-apple-darwin10-"
1404                 ;;
1405             *arm*)
1406                 aros_ios_platform="iPhoneOS"
1407                 aros_target_cpu="arm"
1408                 aros_object_format="armelf_aros"
1409                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1410                 aros_c_libs="$aros_c_libs -laeabi"
1411                 aros_nominal_depth=8
1412                 gcc_target_cpu="arm"
1413                 aros_kernel_rs="$AR"
1414                 aros_kernel_ar_flags="-cr"
1415                 aros_kernel_ld="$LD -arch arm"
1416                 aros_kernel_ranlib="$RANLIB -arch arm"
1417                 kernel_tool_prefix="arm-apple-darwin10-" 
1418                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1419                 ;;
1420             *)
1421                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1422                 ;;
1423         esac
1424         case "$aros_target_variant" in
1425             ios)
1426                 make_extra_targetcfg="$export_newline""# Apple iOS stuff for gcc$export_newline""IOS_LDFLAGS  := -F$""(IOS_SDK_PATH)/System/Library/Frameworks$export_newline"
1427                 aros_ios_version="3.0"
1428                 aros_nominal_width=320
1429                 aros_nominal_height=480
1430                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1431                 target_extra_cfg+="$export_newline""# Apple iOS specific$export_newline""IOS_PLATFORM            := $aros_ios_platform$export_newline""IOS_OS_VERSION          := $aros_ios_version$export_newline""IOS_SDK_PATH            := $aros_ios_sdk$export_newline"
1432                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1433                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1434                 need_x11=no
1435                 # This is here because it may depend on iOS or SDK version
1436                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1437                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1438                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1439             ;;
1440             *)
1441                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1442                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1443             ;;
1444         esac
1445         ;;
1447     dragonfly*)
1448         aros_target_arch="dragonfly"
1449         aros_target_family="unix"
1450         aros_flavour="emulation"
1451         case "$target_cpu" in
1452             *i?86*)
1453                 aros_target_cpu="i386"
1454                 aros_object_format="elf_i386"
1455                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1456                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1457                 ;;
1458             *x86_64*)
1459                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1460                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1461                 aros_target_cpu="x86_64"
1462                 aros_object_format="elf_x86_64"
1463                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1464                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1465                 ;;
1466             *)
1467                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1468                 ;;
1469         esac
1470         ;;
1472     netbsd*)
1473         aros_target_arch="netbsd"
1474         aros_target_family="unix"
1475         case "$target_cpu" in
1476             *m68k*)
1477                 aros_target_cpu="m68k"
1478                 aros_object_format="m68kelf"
1479                 aros_flavour="emulcompat"
1480                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1481                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1482                 gcc_target_cpu="mc68000"
1483                 ;;
1484             *i?86*)
1485                 aros_target_cpu="i386"
1486                 aros_object_format="elf_i386"
1487                 aros_flavour="emulation"
1488                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1489                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1490                 aros_nominal_depth=8
1491                 gcc_target_cpu="i386"
1492                 ;;
1493             *)
1494                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1495                 ;;
1496         esac
1497         aros_target_genmap="-Wl,-M -Xlinker >"
1498         aros_flavour="emulation"
1499         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1500         ;;   
1502     openbsd*)
1503         aros_target_arch="openbsd"
1504         aros_target_family="unix"
1505         case "$target_cpu" in
1506             *i?86*)
1507                 aros_target_cpu="i386"
1508                 aros_object_format="elf_i386"
1509                 aros_flavour="emulation"
1510                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1511                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1512                 gcc_target_cpu="i386"
1513                 ;;
1514             *)
1515                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1516                 ;;
1517         esac
1518         aros_target_genmap="-Wl,-M -Xlinker >"
1519         aros_target_nm_flags="-u"
1520         aros_flavour="emulation"
1521         ;;
1523     solaris*)
1524         aros_target_arch="solaris"
1525         aros_target_family="unix"
1526         case "$target_cpu" in
1527            *i?86*)
1528                aros_target_cpu="i386"
1529                aros_object_format="elf_i386"
1530                aros_flavour="emulation"
1531                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1532                aros_isa_flags="$""(ISA_X86_FLAGS)"
1533                aros_nominal_depth=8
1534                gcc_target_cpu="i386"
1535                ;;
1536             *sparc*)
1537                 aros_target_cpu="sparc"
1538                 aros_object_format="elf_sparc"
1539                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1540                 gcc_target_cpu="sparc"
1541                 ;;
1542             *)
1543                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1544                 ;;
1545         esac
1546         aros_config_cppflags="$aros_config_cppflags -D$aros_target_cpu"
1547         aros_flavour="emulation"
1548         ;;
1550     morphos*)
1551         aros_target_arch="morphos"
1552         aros_shared_default="no"
1553         aros_target_cpu="ppc"
1554         aros_object_format="elf_ppc"
1555         aros_flavour="nativecompat"
1556         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1557         gcc_target_cpu="ppc"
1558         ;;
1560     sam440)
1561         aros_target_arch="sam440"
1562         aros_shared_default="no"
1563         aros_target_cpu="ppc"
1564         aros_object_format="elf32ppc"
1565         aros_flavour="ppcnative"
1566         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1567         aros_kernel_ldflags=""
1568         aros_nominal_width=1024
1569         aros_nominal_height=768
1570         aros_nominal_depth=24
1571         aros_isa_flags="$aros_isa_flags -mcpu=440fp -mno-toc"
1572         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1573         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1574         gcc_target_cpu="powerpc"
1575         ;;
1577     efika)
1578         aros_target_arch="efika"
1579         aros_shared_default="no"
1580         aros_target_cpu="arm"
1581         aros_object_format="armelf_aros"
1582         aros_flavour="standalone"
1583         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1584         aros_kernel_ldflags=""
1585         aros_nominal_width=1024
1586         aros_nominal_height=600
1587         aros_c_libs="$aros_c_libs -laeabi"
1588         gcc_default_cpu="armv7-a"
1589         gcc_default_fpu="vfpv3"
1590         aros_isa_flags="$aros_isa_flags -mtune=cortex-a8"
1591         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1592         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1593         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1594         if test "$optimization" = "default"; then
1595             optimization_level="-Os"
1596         fi
1597         case "$target_cpu" in
1598             *armhf*)
1599                 gcc_default_float_abi="hard"
1600                 target_cpu=arm
1601                 aros_target_cpu=arm
1602                 ;;
1603             *arm*)
1604                 gcc_default_float_abi="softfp"
1605                 ;;
1606             *)
1607                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1608                 ;;
1609         esac
1610         ;;
1611         
1612     chrp)
1613         aros_target_arch="chrp"
1614         aros_shared_default="no"
1615         aros_target_cpu="ppc"
1616         aros_object_format="elf32ppc"
1617         aros_flavour="ppcnative"
1618         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1619         aros_kernel_ldflags=""
1620         aros_nominal_width=640
1621         aros_nominal_height=480
1622         aros_isa_flags="$aros_isa_flags -mno-toc"
1623         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1624         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1625         gcc_target_cpu="powerpc"
1626         case "$aros_target_variant" in
1627             efika)
1628                 aros_isa_flags="$aros_isa_flags -mcpu=603e"
1629                 aros_config_cppflags="$aros_config_cppflags -DBIG_ENDIAN_OHCI=1"
1630             ;;
1631         esac
1632         ;;
1634     r*pi)
1635         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1636         aros_flavour="standalone"
1637         aros_target_arch="raspi"
1639         aros_shared_default="no"
1641         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1642         
1643         case "$target_cpu" in
1644             *aarch64*)
1645                 aros_target_cpu="aarch64"
1646                 gcc_default_cpu="aarch64"
1647                 aros_object_format="aarch64elf_aros"
1648                 ;;
1649             *armhf*)
1650                 aros_target_cpu="arm"
1651                 gcc_default_cpu="armv6zk"
1652                 gcc_default_cpu_tune="arm1176jzf-s"
1653                 aros_object_format="armelf_aros"
1654                 aros_isa_flags="$aros_isa_flags -marm"
1655                 aros_config_cflags="$aros_config_cflags"
1656                 aros_config_cxxflags="$aros_config_cxxflags"
1657                 aros_config_aflags="$aros_config_aflags -marm"
1658                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1659                 aros_target_mkdep="$aros_target_mkdep -Darm"
1660                 aros_c_libs="$aros_c_libs -laeabi"
1661                 ;;
1662             *armeb*)
1663                 aros_flavour="standcompat"
1664                 aros_target_cpu="armeb"
1665                 gcc_default_float_abi="hard"
1666                 gcc_default_cpu="armv7ve"
1667                 gcc_default_cpu_tune="cortex-a7"
1668                 aros_object_format="armelfb_aros"
1669                 aros_isa_flags="$aros_isa_flags -marm"
1670                 aros_config_cflags="$aros_config_cflags"
1671                 aros_config_cxxflags="$aros_config_cxxflags"
1672                 aros_config_aflags="$aros_config_aflags -marm"
1673                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1674                 aros_target_mkdep="$aros_target_mkdep -Darm"
1675                 aros_c_libs="$aros_c_libs -laeabi"
1676                 ;;
1677             *arm*)
1678                 aros_target_cpu="arm"
1679                 gcc_default_cpu="armv6zk"
1680                 gcc_default_cpu_tune="arm1176jzf-s"
1681                 aros_object_format="armelf_aros"
1682                 aros_isa_flags="$aros_isa_flags -marm"
1683                 aros_config_cflags="$aros_config_cflags"
1684                 aros_config_cxxflags="$aros_config_cxxflags"
1685                 aros_config_aflags="$aros_config_aflags -marm"
1686                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1687                 aros_target_mkdep="$aros_target_mkdep -Darm"
1688                 aros_c_libs="$aros_c_libs -laeabi"
1689                 ;;
1690             *)
1691                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1692                 ;;
1693         esac
1695         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1696         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1697         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1698         aros_kernel_cflags="$aros_kernel_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1700         case "$aros_target_variant" in
1701             smp)
1702                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1703             ;;
1704         esac
1705         ;;
1707     stm32f7_discovery)
1708         aros_flavour="standalone"
1709         aros_target_arch="stm32f7_discovery"
1710         aros_target_cpu="arm"
1711         aros_target_cpu_mode="thumb2"
1712         aros_object_format="armelf_aros"
1713         aros_shared_default="no"
1715         gcc_default_cpu="armv7e-m"
1716         gcc_default_cpu_tune="cortex-m7"
1717         gcc_default_fpu="fpv5-sp-d16"
1718         gcc_default_float_abi="hard"
1720         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1721         ;;
1723     amiga*)
1724         aros_elf_translate="$""(ELF2HUNK)"
1725         make_extra_commands="$export_newline""ELF2HUNK  := $""(TOOLDIR)/elf2hunk$""(HOST_EXE_SUFFIX)$export_newline"
1726         aros_target_arch="amiga"
1727         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1728         aros_shared_default="no"
1730         case "$target_cpu" in
1731             *m68k*)
1732                 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")
1733                 aros_enable_mmu=no
1734                 aros_target_cpu="m68k"
1735                 aros_object_format="m68kelf"
1736                 aros_flavour="standcompat"
1737                 gcc_target_cpu="m68000"
1738                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1739                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1740                 aros_config_cppflags="$aros_config_cppflags -DNOLIBINLINE"
1741                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1742                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1743                 if test "$optimization" = "default"; then
1744                     optimization_level="-Os"
1745                 fi
1746                 aros_config_aflags="$aros_config_aflags"
1747                 aros_target_strip_flags="-R.comment --strip-debug"
1748                 aros_nominal_width=640
1749                 aros_nominal_height=256
1750                 aros_nominal_depth=2
1751                 ;;
1752             *ppc*)
1753                 aros_cpu="ppc"
1754                 aros_flavour="native"
1755                 gcc_target_cpu="ppc"
1756                 ;;
1757             *)
1758                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1759                 ;;
1760         esac
1761         ;;
1763     mingw*)
1764         aros_target_arch="mingw32"
1765         aros_shared_default="no"
1766         aros_flavour="emulation"
1767         aros_shared_cflags=""
1768         need_crosstools="yes"
1769         need_dlopen="no"
1770         rescomp="windres"
1771         case "$target_cpu" in
1772             *i?86*)
1773                 aros_target_cpu="i386"
1774                 aros_object_format="elf_i386"
1775                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1776                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1777                 aros_nominal_depth=8
1778                 gcc_target_cpu="i386"
1780                 kernel_tool_prefix="i386-mingw32-"
1781                 ;;
1782             *x86_64*)
1783                 aros_target_cpu="x86_64"
1784                 aros_object_format="elf_x86_64"
1785                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1786                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1787                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1788                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1789                 aros_nominal_depth=8
1790                 kernel_tool_prefix="x86_64-w64-mingw32-"
1791                 ;;
1792             *arm*)
1793                 aros_target_cpu="arm"
1794                 aros_object_format="armelf_aros"
1795                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1796                 aros_c_libs="$aros_c_libs -laeabi"
1797                 aros_nominal_depth=8
1798                 gcc_target_cpu="arm"
1799                 gcc_default_float_abi="soft"
1800                 kernel_tool_prefix="arm-mingw32ce-"
1801                 aros_nominal_width=160
1802                 aros_nominal_height=160
1803                 ;;
1804             *)
1805                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1806                 ;;
1807         esac
1808         if test $host_os = "cygwin"; then
1809                 aros_kernel_cflags="-mno-cygwin"
1810         fi
1811     ;;
1812     pp*)
1813         aros_target_arch="pp"
1814         aros_shared_default="no"
1815         case "$target_cpu" in
1816             *m68k*)
1817                 aros_target_cpu="m68k"
1818                 aros_object_format="m68kelf"
1819                 aros_flavour="palmnative"
1820                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1821                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1822                 aros_nominal_width=160
1823                 aros_nominal_height=160
1824                 aros_nominal_depth=1
1825                 aros_target_ar_flags="cru"
1826                 aros_c_libs="$aros_c_libs -lgcc1"
1827                 aros_shared_default=no
1828                 aros_shared_cflags="-fpic"
1829                 aros_shared_aflags=""
1830                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1831                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1832                 aros_debug_cppflags="$aros_messages_debug"
1833                 aros_debug_cflags="$aros_symbols_debug"
1834                 aros_debug_aflags=""
1835                 aros_debug_ldflags="$aros_symbols_debug"
1836                 aros_mungwall_debug="0"
1837                 aros_modules_debug="0"
1838                 gcc_target_cpu="mc68000"
1839                 ignore_undefined_symbols="-ius"
1840                 ;;
1841            *)
1842                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1843                 ;;
1844         esac
1845         ;;
1847     mac*)
1848         aros_target_arch="mac"
1849         aros_shared_default="no"
1850         case "$target_cpu" in
1851             *m68k*)
1852                 aros_target_cpu="m68k"
1853                 aros_object_format="m68kelf"
1854                 aros_flavour="mac68knative"
1855                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1856                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1857                 aros_nominal_width=512
1858                 aros_nominal_height=384
1859                 aros_nominal_depth=8
1860                 aros_target_ar_flags="cru"
1861                 aros_c_libs="$aros_c_libs -lgcc1"
1862                 aros_shared_default=no
1863                 aros_shared_cflags="-fpic"
1864                 aros_shared_aflags=""
1865                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1866                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1867                 aros_debug_cppflags="$aros_messages_debug"
1868                 aros_debug_cflags="$aros_symbols_debug"
1869                 aros_debug_aflags=""
1870                 aros_debug_ldflags="$aros_symbols_debug"
1871                 aros_mungwall_debug="0"
1872                 aros_modules_debug="0"
1873                 gcc_target_cpu="mc68000"
1874                 ignore_undefined_symbols="-ius"
1875                 ;;
1876            *)
1877                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1878                 ;;
1879         esac
1880         ;;
1882     *)
1883         AC_MSG_ERROR([Unsupported target architecture $target])
1884         ;;
1885 esac
1887 #-----------------------------------------------------------------------------
1888 crosstools_guess="yes"
1889 aros_target_toolchain="no"
1890 aros_kernel_sysroot=""
1892 AC_MSG_CHECKING([Kernel toolchain prefix])
1893 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1894 AC_MSG_RESULT($kernel_tool_prefix)
1896 AC_MSG_CHECKING([ELF toolchain prefix])
1897 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"
1898                                                  crosstools_guess="no"])
1899 AC_MSG_RESULT($elf_tool_prefix)
1901 AC_MSG_CHECKING([AROS toolchain prefix])
1902 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"
1903                 crosstools_guess="no"])
1904 if test "$aros_tool_prefix" = "yes" ; then
1905     aros_tool_prefix=$aros_target_cpu-aros-
1907 AC_MSG_RESULT($aros_tool_prefix)
1909 #-----------------------------------------------------------------------------
1910 #   Checking if we should build crosstools..
1911 AC_MSG_CHECKING([whether to build crosstools])
1912 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1913 AC_MSG_RESULT($crosstools)
1915 if test "${crosstools}" = "yes"; then
1916     if test "${crosstools_guess}" = "no"; then
1917         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1918     fi
1921 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1922     aros_target_toolchain="yes"
1925 AC_MSG_CHECKING([where to install the crosstools binaries])
1926 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])
1927 if test "x$aros_toolchain_install" = "x"; then
1928     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1929 else
1930     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1931     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1932     if test "$crosstools_guess" = "no" ; then
1933         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1934             aros_kernel_sysroot="$""(TARGET_SYSROOT)"
1935         fi
1936     fi
1938 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1940 #-----------------------------------------------------------------------------
1941 if test "$aros_toolchain" = "gnu" ; then
1942     AC_MSG_CHECKING([what specific target binutils version to use])
1944 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="")
1945 if test "$use_binutils_version" = ""; then
1946         target_binutils_version="$default_binutils_version"
1947 else
1948     target_binutils_version="$use_binutils_version"
1950 if test "$aros_toolchain" = "gnu" ; then
1951     AC_MSG_RESULT($target_binutils_version)
1955 # Helper to identify gcc version
1956 AC_DEFUN([CROSS_GCC_VERSION], [
1957   target_gcc_version=""
1958   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1959     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1960     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1961       ax_cv_gcc_version=""
1962     ])
1963   ])
1964   target_gcc_version=$ax_cv_gcc_version
1965   AC_SUBST([target_gcc_version])
1968 #-----------------------------------------------------------------------------
1969 if test "$aros_toolchain" = "gnu" ; then
1970     AC_MSG_CHECKING([what specific target gcc version to use])
1972 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1973 if test "$use_gcc_version" = ""; then
1974     if test "${crosstools}" = "no"; then
1975       if test "x$aros_toolchain_install" != "x"; then
1976           CROSS_GCC_VERSION
1977       fi
1978     fi
1979     if test "$use_gcc_version" = ""; then
1980         target_gcc_version="$default_gcc_version"
1981     fi
1982 else
1983     target_gcc_version="$use_gcc_version"
1985 if test "$aros_toolchain" = "gnu" ; then
1986     AC_MSG_RESULT($target_gcc_version)
1988     AC_MSG_CHECKING([version string style])
1989     if test "${target_gcc_version#*$'-'}" != "$target_gcc_version" ; then
1990         AC_MSG_RESULT(snapshot)
1991         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'-' -f1)
1992         GCC_VERSION_MINOR=-1
1993         GCC_VERSION_PATCH=-1
1994     else
1995         AC_MSG_RESULT(release)
1996         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
1997         GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
1998         GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
1999     fi
2001     gcc_fix_bitfields="false"
2002     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
2003         gcc_fix_bitfields="true"
2004     else
2005         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
2006             if test "$GCC_VERSION_MINOR" -gt "6" ; then
2007                 gcc_fix_bitfields="true"
2008             fi
2009         fi
2010     fi
2012     if test "$gcc_fix_bitfields" = "true" ; then
2013         case "$aros_target_cpu" in
2014         *x86_64* | *i?86*)
2015             x86_isa_extra="$x86_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2016             x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2017             ;;
2018         esac
2019     fi
2022 AC_MSG_CHECKING([whether to enable Objective-C suppport])
2023 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
2024 AC_MSG_RESULT($objc)
2025 if test "x$objc" = "xyes"; then
2026     objc_target="$objc"
2027 else
2028     objc_target="no-objc"
2031 AC_MSG_CHECKING([whether to enable Java suppport])
2032 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
2033 AC_MSG_RESULT($java)
2034 if test "x$java" != "xno"; then
2035     java_target="$java"
2036 else
2037     java_target="no-java"
2040 spec_obj_format="-m $aros_object_format"
2041 # Now process extra architecture-specific options.
2042 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
2043 # as well as floating-point ABI.
2044 case "$aros_target_cpu" in
2045     *m68k*)
2046         aros_isa_targets="M68K_ISA_TARGETS              :=MC68020 MC68040"
2047         aros_isa_extra="$aros_isa_extra$export_newline$aros_isa_targets$export_newline"
2048         aros_isa_extra="$aros_isa_extra$m68k_isa_extra$export_newline$m68k_020_isa_extra$export_newline$m68k_030_isa_extra$export_newline$m68k_040_isa_extra$export_newline$m68k_060_isa_extra$export_newline$m68k_ac080_isa_extra$export_newline"
2049         aros_isa_extra="$aros_isa_extra$m68k_020_cppflags$export_newline$m68k_030_cppflags$export_newline$m68k_040_cppflags$export_newline$m68k_060_cppflags$export_newline"
2050         aros_isa_extra="$aros_isa_extra$m68k_020_cflags$export_newline$m68k_030_cflags$export_newline$m68k_040_cflags$export_newline$m68k_060_cflags$export_newline"
2051         aros_isa_extra="$aros_isa_extra$m68k_020_ldflags$export_newline$m68k_030_ldflags$export_newline$m68k_040_ldflags$export_newline$m68k_060_ldflags$export_newline"
2052         aros_isa_extra="$aros_isa_extra$m68k_020_ext$export_newline$m68k_030_ext$export_newline$m68k_040_ext$export_newline$m68k_060_ext$export_newline"
2053         ;;
2054     *x86_64*)
2055         aros_isa_extra="$export_newline$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2056         dnl x86_64 can build 32 or 64bit code
2057         spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
2058         ;;
2059     arm*)
2060         dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
2061         if test "$gcc_default_cpu" = ""; then
2062             gcc_default_cpu="armv6"
2063         fi
2064         if test "$gcc_default_fpu" = ""; then
2065             gcc_default_fpu="vfp"
2066         fi
2067         if test "$gcc_default_endian" = ""; then
2068             if test "$target_cpu" = "armeb"; then
2069                 gcc_default_endian="big-endian"
2070             else
2071                 gcc_default_endian="little-endian"
2072             fi
2073         fi
2074         if test "$gcc_default_float_abi" = ""; then
2075             if test "$target_cpu" = "armhf"; then
2076                 gcc_default_float_abi="hard"
2077             else
2078                 gcc_default_float_abi="softfp"
2079             fi
2080         fi
2082         AC_MSG_CHECKING([Which minimum CPU to use])
2083         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)
2084         AC_MSG_RESULT($aros_gcc_cpu)
2086         AC_MSG_CHECKING([Which minimum FPU to use])
2087         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)
2088         AC_MSG_RESULT($aros_gcc_fpu)
2090         AC_MSG_CHECKING([Which floating point ABI to use])
2091         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)
2092         AC_MSG_RESULT($aros_gcc_float_abi)
2094         AC_MSG_CHECKING([Which ARM mode to use])
2095         if test "$aros_target_cpu_mode" = ""; then
2096             aros_target_cpu_mode="arm32"
2097             AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
2098         else
2099             AC_MSG_RESULT([$aros_target_cpu_mode])
2100         fi
2102         case "$aros_target_cpu_mode" in
2103         arm32)
2104             gcc_default_mode="arm"
2105             aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -m$gcc_default_endian -mthumb-interwork -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
2106         ;;
2107         arm64)
2108             AC_MSG_ERROR([ARM 64-bit mode is unsupported])
2109         ;;
2110         thumb)
2111             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2112         ;;
2113         thumb1)
2114             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2115         ;;
2116         thumb2)
2117             gcc_default_mode="thumb"
2118             # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
2119             aros_isa_flags="$aros_isa_flags -m$gcc_default_mode -$gcc_default_endian -march=$aros_gcc_cpu -mfpu=$aros_gcc_fpu -mfloat-abi=$aros_gcc_float_abi"
2120         ;;
2121         *)
2122             AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
2123         ;;
2124         esac
2126         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2127         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2128         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2129         ;;
2130     i386)
2131         aros_isa_extra="$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2132         aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
2133         ;;
2134 esac
2136 # Some architectures may need custom ELF specs.
2137 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
2138     elf_specs_in=config/${aros_object_format}-specs.in
2139 else
2140     elf_specs_in=config/elf-specs.in
2143 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
2144 # Since we override specs, we may need to put these defines there
2145 if test "$gcc_target_cpu" != ""; then
2146     gcc_target_cpu="-D__${gcc_target_cpu}__"
2149 AC_MSG_CHECKING([where to download sourcecode for external ports])
2150 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
2151 if test "$with_portssrcdir" = "default"; then
2152     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
2153 else
2154     AROS_PORTSSRCDIR="$with_portssrcdir"
2156 AC_MSG_RESULT($AROS_PORTSSRCDIR)
2158 AC_MSG_CHECKING([which bootloader to use])
2159 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
2160 if test "$target_bootloader" = "none"; then
2161     aros_target_bootloader=""
2162 else
2163     aros_target_bootloader="$target_bootloader"
2165 AC_MSG_RESULT($target_bootloader)
2167 AC_MSG_CHECKING([which icon-set to use])
2168 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
2169 if test "$target_iconset" = "default"; then
2170     aros_target_iconset="Gorilla"
2171     target_iconset="default (Gorilla)"
2172 else
2173     aros_target_iconset="$target_iconset"
2175 AC_MSG_RESULT($target_iconset)
2177 AC_MSG_CHECKING([which GUI Theme to use])
2178 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2179 if test "$target_guitheme" = "default"; then
2180     aros_target_guitheme="Ice"
2181 else
2182     aros_target_guitheme="$target_guitheme"
2184 AC_MSG_RESULT($aros_target_guitheme)
2186 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2187 # for target code)
2188 cross_compiling=no
2190 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2191 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2192     cross_compiling=yes
2195 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2196 dnl The flag itself is given in per-target section, because some targets require to pass it
2197 dnl in a different manner, otherwise some tests fail.
2198 dnl TODO: Justify this.
2199 if test "$aros_host_cpu" == "x86_64" ; then
2200     if test "$aros_target_cpu" == "i386" ; then
2201         cross_compiling=no
2202     fi
2205 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2206     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2207     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2208     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2209     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2210     dnl used to build bootstrap for target arch in either case.
2211     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2212     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2213     dnl perhaps introducing aros_host_variant
2214     if test "$aros_host_arch" != "$aros_target_arch" ; then
2215         cross_compiling=yes
2216     fi
2217 else
2218     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2219     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2220     dnl if test "$host_cc_elf" = "no" ; then
2221         cross_compiling=yes
2222     dnl fi
2225 if test "$cross_compiling" = "no" ; then
2226     kernel_tool_prefix=""
2227     if test "$host_cc_elf" = "yes" ; then
2228         elf_tool_prefix=""
2229     fi
2232 if test "$kernel_tool_version" != ""; then
2233     kernel_tool_version="-$kernel_tool_version"
2236 #######################################################################
2237 ## Compute what toolchains to use, and their paths                   ##
2238 #######################################################################
2240 # This takes, as input:
2241 #   crosstools             {yes,no}
2242 #   kernel_tool_version    {"",[version]}
2243 #   target_tool_version    {"",[version]}
2244 #   kernel_tool_prefix     {none,[some-arch-os-]}
2245 #   gnu-toolchain -:
2246 #     target_tool_prefix     ${aros_target_cpu}-aros-
2247 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2249 # The output is
2250 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2251 #        Where the 'kernel' binaries are located
2252 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2253 #        Where the 'target' binaries are located
2254 #        (not the symlink farm - that is aros_target_*!)
2256 # The rules are:
2257 #   if crosstools then
2258 #      if kernel_tools_prefix = "no-kernel-prefix-"
2259 #          aros_kernel_* = crosstools cc paths
2260 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2261 #      else
2262 #          VALIDATE(${kernel_tools_prefix}*)
2263 #          aros_kernel_* = ${kernel_tools_prefix}*
2264 #          if ${kernel_tools_prefix}cc is an AROS gcc
2265 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2266 #          else
2267 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2268 #          fi
2269 #      fi
2271 #      orig_target_* = aros built crosstools
2272 #      orig_target_cc = elf cc wrapper around crosstools cc
2273 #   else
2274 #      VALIDATE(${kernel_tools_prefix}*)
2276 #      orig_target_* = aros_kernel_*
2277 #      if aros_kernel_cc is an AROS gcc
2278 #          orig_target_cc = aros_kernel_cc
2279 #      else
2280 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2281 #      fi
2282 #   fi
2284 if test "$aros_toolchain" = "gnu" ; then
2285     target_tool_prefix="${aros_target_cpu}-aros-"
2286 elif test "$aros_toolchain" = "llvm" ; then
2287     target_tool_prefix="bin/"
2290 if test "$kernel_tool_prefix" != "" ; then
2291     AC_MSG_CHECKING([which kernel tools])
2292     AC_MSG_RESULT([$kernel_tool_prefix]);
2295 if test "$kernel_tool_prefix" = "none" ; then
2296     dnl ELF wrapper can be used only for native bootstrap
2297     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2298         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2299     fi
2300 else
2301     if test "x-$aros_flavour" != "x-standalone" -o "x-$aros_flavour" != "x-standcompat" ; then
2302         # Kernel tools required - find them
2303         # Note that 'normally', aros_kernel_* overrides will be
2304         # empty, unless specified in the per-arch sections above.
2305         test_kernel_cc=yes
2306         if test "x$aros_kernel_cpp" = "x"; then
2307             aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2308         fi
2309         AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2310         AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2311         AROS_REQUIRED(cpp,$aros_kernel_cpp)
2313         if test "x$aros_kernel_cc" = "x"; then
2314             aros_kernel_cc=${kernel_tool_prefix}${CC}
2315         fi
2316         AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2317         AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2318         AROS_REQUIRED(cc,$aros_kernel_cc)
2320         if test "x$aros_kernel_cxx" = "x"; then
2321             aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2322         fi
2323         AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2324         AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2325         # If it's set, make sure it's really there
2326         if test "x$aros_kernel_cxx" != "x" ; then
2327             AROS_REQUIRED(cxx,$aros_kernel_cxx)
2328         fi
2329         if test "x$aros_kernel_ld" = "x"; then
2330             aros_kernel_ld=$aros_host_ld
2331         fi
2332         AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2333         AROS_REQUIRED(ld,$aros_kernel_ld)
2334         if test "x$aros_kernel_as" = "x"; then
2335             aros_kernel_as=$aros_host_as
2336             if test "x$aros_kernel_as" = "x"; then
2337                 aros_kernel_as=${HOST_TOOLCHAIN_PREFIX}as${HOST_TOOLCHAIN_SUFFIX}
2338             fi
2339         fi
2340         AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2341         AROS_REQUIRED(as,$aros_kernel_as)
2342         if test "x$aros_kernel_ar" = "x"; then
2343             aros_kernel_ar=$aros_host_ar
2344         fi
2345         AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2346         AROS_REQUIRED(ar,$aros_kernel_ar)
2347         if test "x$aros_kernel_ranlib" = "x"; then
2348             aros_kernel_ranlib=$aros_host_ranlib
2349         fi
2350         AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2351         AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2352         if test "x$aros_kernel_nm" = "x"; then
2353             aros_kernel_nm=$aros_host_nm
2354             if test "x$aros_kernel_nm" = "x"; then
2355                 aros_kernel_nm=${HOST_TOOLCHAIN_PREFIX}nm${HOST_TOOLCHAIN_SUFFIX}
2356             fi
2357         fi
2358         AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2359         AROS_REQUIRED(nm,$aros_kernel_nm)
2360         AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2361         AROS_REQUIRED(strip,$aros_kernel_strip)
2363         # Objcopy and objdump are not required for the kernel
2364         # toolchain on many architectures.
2365         # So we'll look for them, but not make them strictly required.
2366         if test "x$aros_kernel_objcopy" = "x"; then
2367             aros_kernel_objcopy=$aros_host_objcopy
2368             if test "x$aros_kernel_objcopy" = "x"; then
2369                 aros_kernel_objcopy=${HOST_TOOLCHAIN_PREFIX}objcopy${HOST_TOOLCHAIN_SUFFIX}
2370             fi
2371         fi
2372         AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2373         if test "x$aros_kernel_objdump" = "x"; then
2374             aros_kernel_objdump=$aros_host_objdump
2375             if test "x$aros_kernel_objdump" = "x"; then
2376                 aros_kernel_objdump=${HOST_TOOLCHAIN_PREFIX}objdump${HOST_TOOLCHAIN_SUFFIX}
2377             fi
2378         fi
2379         AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2380         if test "x${crosstools}" != "xyes" ; then
2381             AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2382             AROS_REQUIRED(objdump,$aros_kernel_objdump)
2383         fi
2384     fi
2387 AC_MSG_CHECKING([which target tools to use])
2388 if test "$aros_target_toolchain" = "yes"; then
2389     if test "$aros_toolchain" = "llvm" ; then
2390         msg_result="llvm"
2391     else
2392         msg_result=$target_tool_prefix
2393     fi
2394     AC_MSG_RESULT([$msg_result])
2395     # We are building AROS crosstools
2396     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2397     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2398     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2399     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2400     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2401     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2402     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2403     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2404     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2405     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2406     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2407     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2408 else
2409     # Determine whether AROS or ELF tools should be used
2410     if test "$aros_tool_prefix" = "none"; then
2411         aros_tool_prefix="${elf_tool_prefix}"
2412     fi
2414     AC_MSG_RESULT([$aros_tool_prefix])
2415     # We are *not* building AROS crosstools - use the AROS or ELF tools
2416     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2417     AROS_REQUIRED(cpp,$orig_target_cpp)
2418     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2419     AROS_REQUIRED(cc,$orig_target_cc)
2420     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2421     AROS_REQUIRED(cxx,$orig_target_cxx)
2422     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2423     AROS_REQUIRED(ld,$orig_target_ld)
2424     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2425     AROS_REQUIRED(as,$orig_target_as)
2426     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2427     AROS_REQUIRED(ar,$orig_target_ar)
2428     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2429     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2430     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2431     AROS_REQUIRED(nm,$orig_target_nm)
2432     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2433     AROS_REQUIRED(strip,$orig_target_strip)
2434     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2435     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2436     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2437     AROS_REQUIRED(objdump,$orig_target_objdump)
2440 if test "$kernel_tool_prefix" = "none" ; then
2441     # No kernel tools specified
2442     # Assume target tools == kernel tools with ELF wrapper
2443     aros_kernel_cc=$orig_target_cc
2444     aros_kernel_cxx=$orig_target_cxx
2445     aros_kernel_cpp=$orig_target_cpp
2446     aros_kernel_ld=$orig_target_ld
2447     aros_kernel_as=$orig_target_as
2448     aros_kernel_ar=$orig_target_ar
2449     aros_kernel_ranlib=$orig_target_ranlib
2450     aros_kernel_nm=$orig_target_nm
2451     aros_kernel_strip=$orig_target_strip
2452     aros_kernel_objcopy=$orig_target_objcopy
2453     aros_kernel_objdump=$orig_target_objdump
2454     use_kernel_cc_wrapper=yes
2457 # At this point, all aros_kernel_* and aros_target_* 
2458 # tools should be set up correctly
2460 CC="$aros_kernel_cc $kernel_tool_flags"
2461 CPP="$aros_kernel_cpp"
2463 #-----------------------------------------------------------------------------
2465 # Find all the tools we need to compile. This could be cross-compiling
2466 # though! If that is the case we use the GNU form of the target and
2467 # simply add this to the front of the binary name. This is rather simple,
2468 # but it should work under most circumstances.
2470 # The default tools are to use the same as the host, but only if the
2471 # host and target CPU are the same. With GCC this is normally enough.
2474 aros_cc_pre=""
2475 aros_shared_ld="$aros_host_ld"
2477 aros_target_mkdep="$aros_host_mkdep"
2479 # The default tools executables to be linked to.
2480 if test "$rescomp" != ""; then
2481     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2482     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2485 # Set up the sources for the symlink farm
2486 if test "$crosstools" = "yes"; then
2487     crosstools_target=tools-crosstools
2490 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2491 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2493 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2494 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2495 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2496 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2497 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2498 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2499 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2501 # aros_cc_pre is a variable that is added to the front of the compiler name
2502 # in the generated aros-gcc shell script. We need this to enable the cache
2503 # to work across cleaned builds. Also, support DISTCC using the correct
2504 # environment variable.
2507 if test "x${DISTCC}" != "x" ; then
2508     if test "x${CCACHE}" != "x" ; then
2509         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2510     else
2511         aros_cc_pre="${DISTCC} "
2512     fi
2513 else
2514     if test "x${CCACHE}" != "x" ; then
2515         aros_cc_pre="${CCACHE} "
2516     fi
2519 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2520 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2521 AC_SUBST(aros_target_nix_ldflags,-nix)
2522 AC_SUBST(aros_target_detach_ldflags,-detach)
2523 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2525 aros_target_cc_path=
2527 # Target tools
2528 AC_SUBST(aros_toolchain)
2529 if test "$aros_target_toolchain" != "yes"; then
2530     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2531     if test "$GCC" = "yes"; then
2532         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2533     fi
2534 else
2535     # We do not know which c compiler version we are going to build and what we need to know
2536     # here is different for different versions so this will be set later during the
2537     # build of crosstools.
2538     if test "$aros_toolchain" = "gnu" ; then
2539         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2540     elif test "$aros_toolchain" = "llvm" ; then
2541         prefix="$AROS_CROSSTOOLSDIR/bin/"
2542     fi
2543     aros_target_cc_path=@aros_target_cc_path@
2545 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2546 aros_target_cc="${prefix}${toolchain_c_compiler}"
2547 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2548 aros_target_as="${prefix}${toolchain_as}"
2549 if test "${use_ld_wrapper}" = "yes"; then
2550     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2551 else
2552     aros_target_ld="${prefix}${toolchain_ld}"
2554 aros_toolchain_ld="${prefix}${toolchain_ld}"
2556 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2557 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2558 aros_target_objdump="${prefix}${toolchain_objdump}"
2559 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2560 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2561 aros_target_strip="${prefix}${toolchain_strip}"
2562 aros_plain_nm="${prefix}${toolchain_nm}"
2563 aros_plain_ar="${prefix}${toolchain_ar}"
2565 AC_ARG_ENABLE(includes,
2566 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2567 [aros_target_incl=$enable_includes], [aros_target_incl=no])
2569 if test "x$aros_target_incl" = "xno"; then
2570     if test "x$test_kernel_cc" != "xno"; then
2571         aros_target_incl=`$aros_kernel_cc -print-sysroot 2>/dev/null`/`$aros_kernel_cc --print-sysroot-headers-suffix 2>/dev/null || echo usr/include`
2572     else
2573         aros_target_incl=
2574     fi
2577 if test "x$aros_kernel_includes" = "x"; then
2578     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2579         if test "x$aros_target_incl" != "x"; then
2580             aros_kernel_includes="-isystem $aros_target_incl"
2581         fi
2582     fi
2585 if test "x$test_kernel_cc" != "xno"; then
2586     if test "$aros_kernel_includes" != "" ; then
2587         dnl find out about the kernel cc's include path
2588         AC_MSG_CHECKING([for the kernel compiler's include path])
2589         if test "$aros_kernel_cc_includes" = "" ; then
2590             # Try to guess where the directory is.
2591             aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2592             if test -d $aros_kernel_cc_includes; then
2593                 # Check if there is also an include-fixed directory and add it
2594                 # to kernel compiler's include path as it may contain some of
2595                 # the headers we need.
2596                 if test -d "$aros_kernel_cc_includes"-fixed; then
2597                     aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2598                 fi
2599                 # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2600                 if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2601                     aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2602                 fi
2603             else
2604                 # The directory doesn't exist, we need to do some more work.
2605                 aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2607                 # These are the headers we're looking for.
2608                 headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2609                          stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2610                          zutil.h stdint.h"
2612                 dirs=
2613                 for h in $headers; do
2614                     # Which other headers are needed by each of the above?
2615                     deps=$(echo "#include <$h>" | \
2616                            $aros_kernel_cc -E -M - 2>/dev/null | \
2617                            sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2619                     # Copy all the needed headers to a directory beneath gendir.
2620                     for d in $deps; do
2621                         h=$(basename $d)
2622                         dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2623                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2624                         ! test -d $dir && mkdir -p $dir
2625                         ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2626                     done
2627                 done            
2628             fi
2629         fi
2630         AC_MSG_RESULT($aros_kernel_cc_includes)
2631         # Adding -nostdinc to kernel includes as they are always used together.
2632         aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2633     fi
2636 if test "$crosstools" != "yes"; then
2637     dnl find out about the target cc's include path
2638     AC_MSG_CHECKING([for the target compiler's include path])
2639     if test "$aros_target_cc_includes" = "" ; then
2640         #try to guess where the directory is
2641         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2642         if ! test -d $aros_target_cc_includes; then
2643             #the directory doesn't exist, we need to do some more work
2644             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2645         
2646             #these are the headers we're looking for
2647             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2648                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2649                     zutil.h"
2651             dirs=
2652             for h in $headers; do
2653                 #which other headers each of the above headers needs?
2654                 deps=$(echo "#include <$h>" | \
2655                     $orig_target_cc -E -M - 2>/dev/null | \
2656                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2657             
2658                 #copy all the needed headers to a directory beneath gendir
2659                 for d in $deps; do
2660                     h=$(basename $d)
2661                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2662                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2663                     ! test -d $dir && mkdir -p $dir
2664                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2665                 done
2666             done
2667         fi
2668     fi
2669     AC_MSG_RESULT($aros_target_cc_includes)
2670 else
2671     # We do not know which c compiler version we are going to build and what we need to know
2672     # here is different for different versions so this will be set later during the
2673     # build of crosstools.
2674     aros_target_cc_includes=@aros_target_cc_includes@
2678 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2679 # On GCC >= 4.0 -iquote should be used
2682 save_cc="$CC"
2683 save_cflags="$CFLAGS"
2684 if test "x$test_kernel_cc" != "xno"; then
2685     CFLAGS="-iquote."
2686     kernel_cflags_iquote=$host_cflags_iquote
2687     kernel_cflags_iquote_end=$host_cflags_iquote_end
2688     if test "x-$cross_compiling" = "x-yes"; then
2689         CC="$aros_kernel_cc"
2690         AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2691         if test "x-$crosstools" != "x-yes"; then
2692             AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2693         else
2694             # we do know it is supported for the smallest version of gcc we are going to build
2695             # we assume it's also supported by later versions
2696             use_no_stack_protector=yes
2697         fi
2698         AC_MSG_RESULT($use_no_stack_protector)
2699         AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2700         if test "x-$crosstools" != "x-yes"; then
2701             AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2702         else
2703             # we do know it is supported for the smallest version of gcc we are going to build
2704             # we assume it's also supported by later versions
2705             has_iquote=yes
2706         fi
2707         AC_MSG_RESULT($has_iquote)
2708         if test "x-$has_iquote" = "x-yes" ; then
2709             kernel_cflags_iquote=-iquote
2710             kernel_cflags_iquote_end=
2711         else
2712             kernel_cflags_iquote=-I
2713             kernel_cflags_iquote_end=-I-
2714         fi
2715     fi
2716     if test "x-$use_no_stack_protector" = "x-yes" ; then
2717         aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2718     fi
2720     #-----------------------------------------------------------------------------
2722     # Check if we can explicitly choose older version of symbol hashing
2724     CFLAGS="save_cflags -Wl,--hash-style=sysv"
2725     CC="$aros_kernel_cc"
2726     AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2727     AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2728     AC_MSG_RESULT($use_hash_style)
2729     if test "x-$use_hash_style" = "x-yes" ; then
2730         aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2731     fi
2732 else
2733     kernel_cflags_iquote="$""(CFLAGS_IQUOTE)"
2734     kernel_cflags_iquote_end="$""(CFLAGS_IQUOTE_END)"
2736 CC="$save_cc"
2737 CFLAGS="$save_cflags"
2739 AC_SUBST(host_cflags_iquote)
2740 AC_SUBST(host_cflags_iquote_end)
2741 AC_SUBST(kernel_cflags_iquote)
2742 AC_SUBST(kernel_cflags_iquote_end)
2745 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2746 AC_MSG_CHECKING([for default resolution of WBScreen])
2747 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2748 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2749 if test "$resolution" = "yes" ; then
2750     resolution="none"
2752 if test "$resolution" = "no" ; then
2753     resolution="none"
2755 if test "$resolution" != "none" ; then
2756     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2757     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2758     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2760 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2761 aros_cv_nominal_width=$aros_nominal_width
2762 aros_cv_nominal_height=$aros_nominal_height
2763 aros_cv_nominal_depth=$aros_nominal_depth
2765 dnl See if the user wants the serial debug output for native flavour
2766 AC_MSG_CHECKING([whether serial debug is enabled])
2767 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)
2768 if test "$aros_serial_debug" = 0 ; then
2769     serial_debug_forced=""
2770     if test "$serial_debug" = "yes" ; then
2771         serial_debug="1"
2772     fi
2773     if test "$serial_debug" = "no" ; then
2774         serial_debug="none"
2775     fi
2776 else
2777     serial_debug_forced="(forced)"
2778     serial_debug=$aros_serial_debug
2780 if test "$serial_debug" != "none" ; then
2781     aros_serial_debug=$serial_debug
2782     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2783 else
2784     AC_MSG_RESULT(no)
2787 dnl See if the user wants the palm debug output hack for palm native flavour
2788 AC_MSG_CHECKING([whether palm debug hack is enabled])
2789 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")
2790 if test "$palm_debug_hack" = "yes" ; then
2791     aros_palm_debug_hack="1"
2793 AC_MSG_RESULT($palm_debug_hack)
2795 dnl See if dev wants the usb3.0 code
2796 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2797 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2798 if test "$usb30_code" = "yes" ; then
2799     aros_config_cppflags="$aros_config_cppflags -DAROS_USB30_CODE"
2800     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2802 AC_MSG_RESULT($usb30_code)
2804 dnl See if the user wants nesting supervisor activated for unix flavour
2805 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2806 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")
2807 if test "$nesting_supervisor" = "yes" ; then
2808     aros_nesting_supervisor="1"
2810 AC_MSG_RESULT($nesting_supervisor)
2812 dnl See if the user wants to disable MMU support
2813 dnl This can be overriden on per-target basis,
2814 dnl set $aros_enable_mmu to "yes" or "no" to do this
2815 if test "$aros_enable_mmu" = "" ; then
2816     AC_MSG_CHECKING([whether MMU support is enabled])
2817     dnl Enabled by default
2818     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2819     if test "$aros_enable_mmu" = "" ; then
2820         aros_enable_mmu="yes"
2821     fi
2822     AC_MSG_RESULT($aros_enable_mmu)
2824 if test "$aros_enable_mmu" = "no" ; then
2825     aros_enable_mmu="0"
2826 else
2827     aros_enable_mmu="1"
2829     
2831 dnl things specifically required for hosted flavours
2832 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2834     if test "x-$need_dlopen" != "x-no" ; then
2835       save_libs="$LIBS"
2836       LIBS=""
2837       dnl some kind of dynamic library access system is required for hostlib.resource
2838       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2839       if test "x-$have_dl" = "x-no" ; then
2840           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2841                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2842                                     have_dl="no")
2843       fi
2844       if test "x-$have_dl" = "x-no" ; then
2845           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2846       fi
2847       LIBS="$save_libs"
2848     fi
2851     dnl x11 hidd
2852     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2853                                            [build X11 hidd for hosted (default=auto)]),
2854                                            x11_hidd="$enableval",
2855                                            x11_hidd="$need_x11")
2856     case "x-$x11_hidd" in
2857         x-yes|x-no|x-auto)                 ;;
2858         *)                 x11_hidd="$need_x11" ;;
2859     esac
2861     ENABLE_X11=0
2863     dnl they want it
2864     if test "x-$x11_hidd" != "x-no" ; then
2866         dnl find x11 stuff
2867         AC_PATH_X
2869         if test -n "$x_includes"; then
2870             X_CFLAGS="$X_CFLAGS -I$x_includes"
2871         fi
2873         if test -n "$x_libraries"; then
2874             X_LIBS="$X_LIBS -L$x_libraries"
2875         fi
2877         if test "x-$no_x" = "x-yes" ; then
2879             dnl didn't find it
2880             if test "x-$x11_hidd" != "x-auto" ; then
2881                 dnl and they explicitly asked for it, bail out
2882                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2883             fi
2884         
2885         else
2886             dnl found it, setup the metatarget
2887             aros_target_options+="$export_newline""# Enable X11 Gfx Driver$export_newline""OPT_HOST_X11GFX               := yes$export_newline"
2888             if test "x-$host_feature_glx" != "x-no" ; then
2889                 aros_target_options+="$export_newline""# Enable X11 HostGL 3D Passthrough$export_newline""OPT_HOST_X11_HOSTGL           := yes$export_newline"
2890             fi
2891             ENABLE_X11=1
2893             aros_host_x11_cflags="$X_CFLAGS"
2894             aros_host_x11_ldflags="$X_LIBS  -lX11"
2896             dnl setup shared memory extensions
2897             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2898                                                   [use X11 shared memory (default=auto)]),
2899                                                   x11_hidd_shm="$enableval",
2900                                                   x11_hidd_shm="auto")
2901             case "x-$x11_hidd_shm" in
2902                 x-yes|x-no|x-auto)                     ;;
2903                 *)                 x11_hidd_shm="auto" ;;
2904             esac
2906             have_xshm=no
2908             dnl they want it
2909             if test "x-$x11_hidd_shm" != "x-no" ; then
2911                 dnl system shm headers
2912                 AC_CHECK_HEADERS(sys/ipc.h)
2913                 AC_CHECK_HEADERS(sys/shm.h)
2915                 dnl got them
2916                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2918                     dnl make sure X libs have shm functions
2919                     save_cflags="$CFLAGS"
2920                     save_ldflags="$LDFLAGS"
2921                     CFLAGS="$CFLAGS $X_CFLAGS"
2922                     LDFLAGS="$LDFLAGS $X_LIBS"
2923                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2924                     CFLAGS="$save_cflags"
2925                     LDFLAGS="$save_ldflags"
2926                 fi
2927             fi
2929             dnl detection done, prepare output
2930             if test "x-$have_xshm" = "x-yes" ; then
2931                 dnl we can do shm
2932                 DO_XSHM_SUPPORT="1"
2933             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2934                 dnl they explicitly asked for it, but we can't do it
2935                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2936             else
2937                 dnl otherwise just disable it
2938                 DO_XSHM_SUPPORT="0"
2939             fi
2941             
2942             dnl setup vidmode (fullscreen) extensions
2943             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2944                                                       [use X11 vidmode extension (default=auto)]),
2945                                                       x11_hidd_vidmode="$enableval",
2946                                                       x11_hidd_vidmode="auto")
2947             case "x-$x11_hidd_vidmode" in
2948                 x-yes|x-no|x-auto)                         ;;
2949                 *)                 x11_hidd_vidmode="auto" ;;
2950             esac
2952             have_vidmode=no
2954             dnl they want it
2955             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2957                 dnl make sure X libs have vidmode functions
2958                 save_cflags="$CFLAGS"
2959                 save_ldflags="$LDFLAGS"
2960                 CFLAGS="$CFLAGS $X_CFLAGS"
2961                 LDFLAGS="$LDFLAGS $X_LIBS"
2962                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2963                 CFLAGS="$save_cflags"
2964                 LDFLAGS="$save_ldflags"
2965             fi
2967             dnl detection done, prepare output
2968             if test "x-$have_vidmode" = "x-yes" ; then
2969                 dnl we can do vidmode
2970                 DO_VIDMODE_SUPPORT="1"
2971             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2972                 dnl they explicitly asked for it, but we can't do it
2973                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2974             else
2975                 dnl otherwise just disable it
2976                 DO_VIDMODE_SUPPORT="0"
2977             fi
2978         fi
2979     fi
2981     dnl sdl hidd
2982     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2983                                            [build SDL hidd for hosted (default=auto)]),
2984                                            sdl_hidd="$enableval",
2985                                            sdl_hidd="auto")
2986     case "x-$sdl_hidd" in
2987         x-yes|x-no|x-auto)                 ;;
2988         *)                 sdl_hidd="auto" ;;
2989     esac
2991     dnl they want it
2992     if test "x-$sdl_hidd" != "x-no" ; then
2994         dnl find sdl
2995         SDL_VERSION=1.2.5
2996         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
2997             [have_sdl="no"])
2999         if test "x-$have_sdl" != "x-yes" ; then
3001             dnl didn't find it
3002             if test "x-$sdl_hidd" != "x-auto" ; then
3003                 dnl and they explicitly asked for it, bail out
3004                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
3005             fi
3007         else
3008             dnl found it, enable the build
3009             aros_target_options+="$export_newline""# Enable SDL Gfx Driver$export_newline""OPT_HOST_SDLGFX               := yes$export_newline"
3010             aros_host_sdl_cflags=$SDL_CFLAGS
3011             aros_host_sdl_libs=$SDL_LIBS
3012         fi
3013     fi
3018 dnl See if the user wants dbus.library
3019 AC_MSG_CHECKING([whether building of dbus.library is enabled])
3020 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
3021 if test "$dbus" = "yes" ; then
3022     ENABLE_DBUS=1
3023     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
3024     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
3025     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
3026     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
3027 else
3028     ENABLE_DBUS=0
3030 AC_MSG_RESULT($dbus)
3032 if test "$use_kernel_cc_wrapper" = "yes" ; then
3033     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
3036 aros_kernel_cppflags=$aros_config_cppflags
3037 aros_optimization_cflags="$optimization_level"
3038 if test "$optimization" = "default"; then
3039 AC_MSG_CHECKING([default optimization level to use])
3040 AC_MSG_RESULT($optimization_level)
3043 if ! test "$gcc_default_cpu" = "" ; then
3044     target_extra_cfg+="$export_newline""# ARM gcc default target$export_newline""GCC_DEFAULT_CPU         := $gcc_default_cpu$export_newline""GCC_DEFAULT_FPU         := $gcc_default_fpu$export_newline""GCC_DEFAULT_FLOAT_ABI   := $gcc_default_float_abi$export_newline""GCC_DEFAULT_MODE        := $gcc_default_mode$export_newline"
3047 if test "$use_libatomic" = "yes" ; then
3048     aros_cxx_libs="$aros_cxx_libs  -latomic"
3051 dnl --------------------------------------------------------------------
3052 dnl Configuration Output Section
3053 dnl --------------------------------------------------------------------
3055 # Generic
3056 AC_SUBST(aros_arch)
3057 AC_SUBST(aros_cpu)
3058 AC_SUBST(aros_flavour)
3059 AC_SUBST(aros_flavour_uc)
3060 AC_SUBST(aros_target_toolchain)
3061 AC_SUBST(aros_toolchain_ld)
3062 AC_SUBST(aros_build_host)
3063 AC_SUBST(AROS_BUILDDIR)
3064 AC_SUBST(AROS_BUILDDIR_UNIX)
3065 AC_SUBST(SRCDIR)
3066 AC_SUBST(AROS_CROSSTOOLSDIR)
3067 AC_SUBST(AROS_PORTSSRCDIR)
3069 # Compatability with other Amiga-like operating systems
3070 AC_SUBST(aros_amigaos_compliance)
3072 # Host Related ###########################
3073 AC_SUBST(host_stat_h__unused_used)
3074 AC_SUBST(ax_cv_flex_version)
3075 AC_SUBST(host_extra_cfg)
3076 AC_SUBST(aros_cc_pre)
3077 AC_SUBST(aros_host_strip)
3078 AC_SUBST(aros_host_arch)
3079 AC_SUBST(aros_host_cpu)
3080 AC_SUBST(aros_host_cpp)
3081 AC_SUBST(aros_host_def_cc)
3082 AC_SUBST(aros_host_cc)
3083 AC_SUBST(aros_host_cxx)
3084 AC_SUBST(aros_host_ar)
3085 AC_SUBST(aros_host_ranlib)
3086 AC_SUBST(aros_host_ld)
3087 AC_SUBST(aros_host_make)
3088 AC_SUBST(aros_host_cppflags)
3089 AC_SUBST(aros_host_cflags)
3090 AC_SUBST(aros_host_cxxflags)
3091 AC_SUBST(gnu89_inline)
3092 AC_SUBST(aros_host_ldflags)
3093 AC_SUBST(aros_host_debug)
3094 AC_SUBST(aros_host_mkdep)
3095 AC_SUBST(aros_host_mkargs)
3096 AC_SUBST(aros_host_exe_suffix)
3097 AC_SUBST(aros_host_lib_suffix)
3098 AC_SUBST(aros_tools_dir)
3099 AC_SUBST(aros_host_aclocal)
3100 AC_SUBST(aros_host_autoconf)
3101 AC_SUBST(aros_host_autoheader)
3102 AC_SUBST(aros_host_automake)
3104 # Target Related #########################
3105 AC_SUBST(aros_elf_translate)
3106 AC_SUBST(make_extra_commands)
3107 AC_SUBST(make_extra_targetcfg)
3108 AC_SUBST(target_extra_cfg)
3109 AC_SUBST(aros_target_options)
3111 AC_SUBST(aros_target_guitheme)
3112 AC_SUBST(aros_target_iconset)
3113 AC_SUBST(aros_target_bootloader)
3114 AC_SUBST(aros_target_arch)
3115 AC_SUBST(aros_target_family)
3116 AC_SUBST(aros_target_cpu)
3117 AC_SUBST(aros_target_cpu_mode)
3118 AC_SUBST(aros_target_variant)
3119 AC_SUBST(aros_target_suffix)
3120 AC_SUBST(aros_target_ar)
3121 AC_SUBST(aros_target_ranlib)
3122 AC_SUBST(aros_plain_nm)
3123 AC_SUBST(aros_plain_ar)
3124 AC_SUBST(aros_kernel_ar)
3125 AC_SUBST(aros_kernel_ranlib)
3126 AC_SUBST(orig_target_cc)
3127 AC_SUBST(aros_target_cc)
3128 AC_SUBST(aros_kernel_cc)
3129 AC_SUBST(orig_target_cxx)
3130 AC_SUBST(aros_target_cxx)
3131 AC_SUBST(aros_kernel_cxx)
3132 AC_SUBST(orig_target_cpp)
3133 AC_SUBST(aros_target_cpp)
3134 AC_SUBST(aros_kernel_cpp)
3135 AC_SUBST(orig_target_as)
3136 AC_SUBST(aros_target_as)
3137 AC_SUBST(aros_kernel_as)
3138 AC_SUBST(orig_target_ld)
3139 AC_SUBST(aros_target_ld)
3140 AC_SUBST(aros_kernel_ld)
3141 AC_SUBST(aros_target_cc_includes)
3142 AC_SUBST(aros_target_cc_path)
3143 AC_SUBST(aros_target_objdump)
3144 AC_SUBST(aros_target_objcopy)
3145 AC_SUBST(aros_target_strip)
3146 AC_SUBST(aros_target_nm)
3147 AC_SUBST(aros_kernel_rescomp)
3148 AC_SUBST(aros_shared_default)
3149 AC_SUBST(aros_shared_ld)
3150 AC_SUBST(aros_object_format)
3151 AC_SUBST(spec_obj_format)
3152 AC_SUBST(aros_c_libs)
3153 AC_SUBST(aros_cxx_libs)
3155 AC_SUBST(aros_shared_cflags)
3156 AC_SUBST(aros_shared_aflags)
3157 AC_SUBST(aros_shared_ldflags)
3159 AC_SUBST(aros_warn_flags)
3160 AC_SUBST(aros_nowarn_flags)
3161 AC_SUBST(aros_config_cppflags)
3162 AC_SUBST(aros_config_cflags)
3163 AC_SUBST(aros_config_cxxflags)
3164 AC_SUBST(aros_config_aflags)
3165 AC_SUBST(aros_config_ldflags)
3167 AC_SUBST(aros_kernel_sysroot)
3168 AC_SUBST(aros_kernel_cppflags)
3169 AC_SUBST(aros_kernel_cflags)
3170 AC_SUBST(aros_kernel_includes)
3171 AC_SUBST(aros_kernel_objcflags)
3172 AC_SUBST(aros_kernel_ldflags)
3173 AC_SUBST(aros_debug_cppflags)
3174 AC_SUBST(aros_debug_cflags)
3175 AC_SUBST(aros_debug_cxxflags)
3176 AC_SUBST(aros_debug_aflags)
3177 AC_SUBST(aros_debug_ldflags)
3178 AC_SUBST(aros_target_genmap)
3179 AC_SUBST(aros_target_strip_flags)
3180 AC_SUBST(aros_config_lto)
3181 AC_SUBST(aros_config_coverage)
3182 AC_SUBST(aros_optimization_cflags)
3183 AC_SUBST(aros_isa_extra)
3184 AC_SUBST(aros_isa_flags)
3186 AC_SUBST(crosstools_target)
3187 AC_SUBST(crosstools_cxx_target)
3189 AC_SUBST(use_libatomic)
3191 AC_SUBST(pci_hidd_target)
3193 AC_SUBST(aros_nominal_width)
3194 AC_SUBST(aros_nominal_height)
3195 AC_SUBST(aros_nominal_depth)
3197 # Native version related
3198 AC_SUBST(aros_serial_debug)
3199 AC_SUBST(PLATFORM_EXECSMP)
3200 AC_SUBST(ENABLE_EXECSMP)
3202 # MMU related
3203 AC_SUBST(aros_enable_mmu)
3205 # Bootloader related
3206 AC_SUBST(target_grub2_version)
3208 # Unix/Hosted version related
3209 AC_SUBST(aros_nesting_supervisor)
3211 # ARM default GCC target related
3212 AC_SUBST(gcc_default_cpu)
3213 AC_SUBST(gcc_default_cpu_tune)
3214 AC_SUBST(gcc_default_fpu)
3215 AC_SUBST(gcc_default_float_abi)
3216 AC_SUBST(gcc_default_mode)
3218 # Palm native version related
3219 AC_SUBST(aros_palm_debug_hack)
3221 # Apple iOS related
3222 AC_SUBST(aros_ios_platform)
3223 AC_SUBST(aros_ios_version)
3224 AC_SUBST(aros_ios_sdk)
3226 # Android related
3227 AC_SUBST(ant)
3228 AC_SUBST(android_tool)
3229 AC_SUBST(aros_android_level)
3230 AC_SUBST(aros_android_antapk)
3232 # Debug related
3233 AC_SUBST(aros_debug)
3234 AC_SUBST(aros_mungwall_debug)
3235 AC_SUBST(aros_stack_debug)
3236 AC_SUBST(aros_modules_debug)
3238 # Collect-aros stuff: "-ius" to ignore undefined symbols
3239 AC_SUBST(ignore_undefined_symbols)
3241 # C compiler related
3242 AC_SUBST(gcc_target_cpu)
3243 AC_SUBST(target_binutils_version)
3244 AC_SUBST(target_gcc_version)
3246 #ObjC compiler related
3247 AC_SUBST(objc_target)
3249 #Java related
3250 AC_SUBST(java_target)
3252 # DBUS related
3253 AC_SUBST(ENABLE_DBUS)
3254 AC_SUBST(DBUS_CFLAGS)
3255 AC_SUBST(DBUS_LIBFLAGS)
3256 AC_SUBST(KERNEL_DBUS_KOBJ)
3257 AC_SUBST(KERNEL_DBUS_INCLUDES)
3259 #X11 related
3260 AC_SUBST(ENABLE_X11)
3261 AC_SUBST(DO_XSHM_SUPPORT)
3262 AC_SUBST(DO_VIDMODE_SUPPORT)
3264 AC_SUBST(aros_host_x11_cflags)
3265 AC_SUBST(aros_host_x11_ldflags)
3267 #X11 related
3268 AC_SUBST(aros_host_sdl_cflags)
3269 AC_SUBST(aros_host_sdl_libs)
3271 # USB3.0 code
3272 AC_SUBST(aros_usb30_code)
3274 dnl Prepare for output, make up all the generated patches
3275 case "$aros_flavour" in
3276 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3277                 aros_flavour="emulation" ;;
3278 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3279                 aros_flavour="emulation" ;;
3280 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3281                 aros_flavour="standalone";;
3282 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3283                 aros_flavour="standalone";;
3284 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3285                 aros_flavour="native" ;;
3286 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3287                 aros_flavour="native" ;;
3288 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3289                 aros_flavour="linklib" ;;
3290 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3291                 aros_flavour="palmnative" ;;
3292 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3293                 aros_flavour="mac68knative" ;;
3294 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3295                 aros_flavour="ppcnative" ;;
3296 esac
3298 if test ! -d ${aros_inc_dir} ; then
3299     ${MKDIR} ${aros_inc_dir}
3301 if test ! -d ${aros_geninc_dir} ; then
3302     ${MKDIR} ${aros_geninc_dir}
3304 if test ! -d ${aros_hostcfg_dir} ; then
3305     ${MKDIR} ${aros_hostcfg_dir}
3307 if test ! -d ${aros_targetcfg_dir} ; then
3308     ${MKDIR} ${aros_targetcfg_dir}
3310 if test ! -d ${aros_tools_dir} ; then
3311     ${MKDIR} ${aros_tools_dir}
3313 if test ! -d ${aros_scripts_dir} ; then
3314     ${MKDIR} ${aros_scripts_dir}
3317 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3319 # Generic build tools (metamake, etc)
3320 AC_CONFIG_COMMANDS([genmf-executable-support],
3321     [
3322         chmod a+x ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname
3323         chmod a+x ${aros_tools_dir}/genmf.py
3324     ],
3325     [
3326         AROS_CROSSTOOLSDIR=${AROS_CROSSTOOLSDIR}
3327         aros_tools_dir=${aros_tools_dir}
3328     ]
3330 AC_CONFIG_FILES(
3331     Makefile
3332     config/make.cfg
3333     ${aros_inc_dir}/config.h:config/config.h.in
3334     ${aros_geninc_dir}/config.h:config/config.h.in
3335     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3336     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3337     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3338     mmake.config
3339     compiler/include/geninc.cfg:compiler/include/geninc.cfg.in
3340     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3341     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3342     ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname:scripts/uname.in
3343     tools/collect-aros/env.h
3346 # Binutils
3347 AC_CONFIG_COMMANDS([binutils-support],
3348     [
3349         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3350         mkdir -p $prefix
3351         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3353         chmod a+x ${prefix2}-ld
3355         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3356         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3357         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3358         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3359         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3360         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3361         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3362     ],
3363     [
3364         aros_host_exe_suffix=${aros_host_exe_suffix}
3365         aros_tools_dir=${aros_tools_dir}
3366         aros_target_cpu=${aros_target_cpu}
3367         aros_target_arch=${aros_target_arch}
3368         aros_target_suffix=${aros_target_suffix}
3369         orig_target_nm=${orig_target_nm}
3370         orig_target_as=${orig_target_as}
3371         orig_target_ar=${orig_target_ar}
3372         orig_target_ranlib=${orig_target_ranlib}
3373         orig_target_objdump=${orig_target_objdump}
3374         orig_target_objcopy=${orig_target_objcopy}
3375         orig_target_strip=${orig_target_strip}
3376         aros_kernel_ld=${aros_kernel_ld}
3377     ]
3379 if test "${use_ld_wrapper}" = "yes"; then
3380     AC_CONFIG_FILES(
3381         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3382     )
3384 # Bare Elf support script and spec
3385 if test "${use_kernel_cc_wrapper}" = "yes"; then
3386     AC_CONFIG_COMMANDS([elf-compiler-support],
3387         [
3388             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3389             mkdir -p $prefix
3390             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3392             chmod a+x ${prefix2}-gcc
3394             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3395         ],
3396         [
3397             aros_host_exe_suffix=${aros_host_exe_suffix}
3398             aros_tools_dir=${aros_tools_dir}
3399             aros_target_cpu=${aros_target_cpu}
3400             aros_target_arch=${aros_target_arch}
3401             aros_target_suffix=${aros_target_suffix}
3402             aros_kernel_ld=${aros_kernel_ld}
3403         ]
3404     )
3405     AC_CONFIG_FILES(
3406         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3407         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3408     )
3411 # Host compiler support scripts and spec
3412 if test "${aros_target_toolchain}" = "no"; then
3413     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3414         [
3415             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3416             mkdir -p $prefix
3417             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3419             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3420         ],
3421         [
3422             aros_host_exe_suffix=${aros_host_exe_suffix}
3423             aros_tools_dir=${aros_tools_dir}
3424             aros_target_cpu=${aros_target_cpu}
3425             aros_target_arch=${aros_target_arch}
3426             aros_target_suffix=${aros_target_suffix}
3427         ]
3428     )
3429     AC_CONFIG_FILES(
3430         ${aros_targetcfg_dir}/specs:config/specs.in
3431         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3432         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3433         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3434     )
3437 # Android support
3438 if test "$aros_target_variant" == "android"; then
3439     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3442 # cmake helper
3443 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3445 AC_OUTPUT
3447 dnl This is in order to not define SHARED_CFLAGS sometimes
3448 dnl We don't always do aros_shared_ar, aros_shared_cflags
3450 #XXX compatability...
3451 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3453 if test -n "$aros_shared_cflags" ; then
3454     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3455     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg