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