don't use the host ar including options.
[AROS.git] / configure.in
blobce4dd3b39b01894459ea2dc609da963920f80ca8
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} 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} 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} 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} 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} 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_config_cppflags=
730 aros_config_cflags=
731 aros_config_cxxflags=
732 aros_config_aflags="$""(WARN_ALL) -x assembler-with-cpp -c"
733 aros_config_ldflags=""
735 aros_shared_default=yes
737 aros_shared_cflags="-fPIC"
738 aros_shared_aflags=""
739 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
740 aros_kernel_ldflags="-Wl,-rpath,./lib"
742 aros_kernel_ar_flags="cr"
743 aros_target_ar_flags="cr"
744 aros_target_nm_flags="-C -ul"
745 aros_target_strip_flags="--strip-unneeded -R.comment"
747 aros_c_libs=
748 aros_cxx_libs=
750 aros_target_genmap="-Wl,-Map -Xlinker"
752 # Native flavour stuff
753 aros_serial_debug="0"
755 # Palm native flavour stuff
756 aros_palm_debug_hack="0"
758 # Unix flavour stuff
759 aros_nesting_supervisor="0"
761 # Collect-aros stuff: "-ius" to ignore undefined symbols
762 ignore_undefined_symbols=""
764 # Check for X11 by default
765 need_x11="auto"
767 AC_MSG_CHECKING([Which toolchain family to use ...])
768 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")
769 AC_MSG_RESULT($aros_toolchain)
772 AC_MSG_CHECKING([if we should enable link time optimizations (LTO)])
773 AC_ARG_ENABLE(lto,AC_HELP_STRING([--enable-lto=[yes|no]],[Enable link time optimizations if the target compiler supports them (default=no)]),
774  aros_config_lto="$enableval",aros_config_lto="no")
775 if test "$aros_config_lto" != "no"; then
776     aros_config_lto="yes"
778 AC_MSG_RESULT($aros_config_lto)
780 AC_MSG_CHECKING([if we should enable coverage instrumentation])
781 AC_ARG_ENABLE(coverage,AC_HELP_STRING([--enable-coverage=[yes|no]],[Enable coverage instrumentation if the target compiler supports it (default=no)]),
782  aros_config_coverage="$enableval",aros_config_coverage="no")
783 if test "$aros_config_coverage" != "no"; then
784     aros_config_coverage="yes"
786 AC_MSG_RESULT($aros_config_coverage)
788 use_ld_wrapper=yes
790 case "$aros_toolchain" in
791     *llvm*)
792         toolchain_c_compiler="clang"
793         toolchain_cxx_compiler="clang++"
794         toolchain_cpp_preprocessor="clang -E"
795         toolchain_ld="ld.lld"
796         aros_ld="ld"
797         toolchain_as="llvm-as"
798         toolchain_ar="llvm-ar"
799         toolchain_ranlib="llvm-ranlib"
800         toolchain_nm="llvm-nm"
801         toolchain_strip="true"
802         toolchain_objcopy="llvm-objcopy"
803         toolchain_objdump="llvm-objdump"
804         use_libatomic=yes
805         ;;
806     *gnu*)
807         toolchain_c_compiler="gcc"
808         toolchain_cxx_compiler="g++"
809         toolchain_cpp_preprocessor="gcc -E"
810         toolchain_as="as"
811         aros_ld="ld"
812         if test "$aros_config_lto" != "yes"; then
813             toolchain_ld="ld"
814             toolchain_ar="ar"
815             toolchain_ranlib="ranlib"
816             toolchain_nm="nm"
817         else
818             toolchain_ld="ld.bfd"
819             toolchain_ar="gcc-ar"
820             toolchain_ranlib="gcc-ranlib"
821             toolchain_nm="gcc-nm"
822         fi
823         toolchain_strip="strip"
824         toolchain_objcopy="objcopy"
825         toolchain_objdump="objdump"
826         use_libatomic=yes
827         ;;
828     *)
829         AC_MSG_WARN("Unknown toolchain family!")
830         toolchain_c_compiler="cc"
831         toolchain_cxx_compiler="c++"
832         toolchain_cpp_preprocessor="cpp"
833         toolchain_ld="ld"
834         aros_ld="ld"
835         toolchain_as="as"
836         toolchain_ar="ar"
837         toolchain_ranlib="ranlib"
838         toolchain_nm="nm"
839         toolchain_strip="strip"
840         toolchain_objcopy="objcopy"
841         toolchain_objdump="objdump"
842         ;;
843 esac
845 #-----------------------------------------------------------------------------
847 AC_MSG_CHECKING([which type of build to do])
848 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")
850 if test "$build_type" = "nightly"; then
851     build_type_string="NIGHTLY"
852 elif test "$build_type" = "snapshot"; then
853     build_type_string="SNAPSHOT"
854 elif test "$build_type" = "milestone"; then
855     build_type_string="MILESTONE"
856 elif test "$build_type" = "release"; then
857     build_type_string="RELEASE"
858 else
859     build_type_string="PERSONAL"
860     build_type="personal"
863 aros_config_cppflags="$aros_config_cppflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
865 AC_MSG_RESULT($build_type)
867 #-----------------------------------------------------------------------------
868 all_debug_types="messages stack modules mungwall symbols"
870 AC_MSG_CHECKING([which debug types to enable])
871 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)]),
872  debug="$enableval",debug="")
874 if test "$debug" = "" -o "$debug" = "no"; then
875     debug="none"
876 elif test "$debug" = "yes"; then
877     debug="all"
880 if test "$debug" = "all" ; then
881     debug="messages stack modules symbols"
882     for d in $all_debug_types; do
883         export aros_${d}_debug="1"
884     done
885 else
886     for d in $all_debug_types; do
887         export aros_${d}_debug="0"
888     done
891 if test "$debug" != "none"; then
892     debug=`echo $debug | sed s/,/\ /g`
893     for d in $debug; do
894         found="0"
895         for d2 in $all_debug_types; do
896             if test "$d2" = "$d"; then
897                 found="1"
898                 break
899             fi
900         done
901         if test "$found" = "0"; then
902             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
903         fi
904         export aros_${d}_debug="1"
905     done
906     aros_debug="yes"
908 AC_MSG_RESULT($debug)
910 if test "$aros_messages_debug" = "1"; then
911     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
912 else
913     aros_messages_debug=""
915 if test "$aros_symbols_debug" = "1"; then
916     aros_symbols_debug="-g"
917 else
918     aros_symbols_debug=""
921 # These are the flags to pass when compiling debugged programs
922 aros_debug_cppflags="$aros_messages_debug"
923 aros_debug_cflags="$aros_symbols_debug"
924 aros_debug_cxxflags=
925 aros_debug_aflags=""
926 aros_debug_ldflags="$aros_symbols_debug"
928 #-----------------------------------------------------------------------------
929 #   Checking for distcc and ccache.
931 #   Always apply the transforms in this particular order. Basically you should
932 #   always run 'ccache distcc compiler' in that order for the best performance.
934 AC_MSG_CHECKING([whether to enable distcc])
935 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
936 if test "$distcc" != "" -a "$distcc" != "no"; then
937     # AC_CHECK_PROG will print out the result in this case
938     AC_PATH_PROG(DISTCC,[distcc],distcc,)
939 else
940     AC_MSG_RESULT(no)
943 AC_MSG_CHECKING([whether to enable ccache])
944 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
945 if test "$ccache" != "" -a "$ccache" != "no"; then
946     # AC_CHECK_PROG will print out the result in this case
947     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
948 else
949     AC_MSG_RESULT(no)
952 #-----------------------------------------------------------------------------
953 AC_MSG_CHECKING([what specific host gcc version to use])
954 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="")
955 if test "$kernel_tool_version" != "" ; then
956     msg_result=$kernel_tool_version
957 else
958     msg_result="default"
960 AC_MSG_RESULT($msg_result)
962 #-----------------------------------------------------------------------------
963 AC_MSG_CHECKING([what optimization flags to use])
964 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")
965 if test "$optimization_level" = "unknown"; then
966     dnl default is -O2 for normal builds, -O0 for debug builds
967     optimization="default"
968     if test "$debug" != "none"; then
969         optimization_level="-O0"
970     else
971         optimization_level="-O2"
972     fi
973 else
974     optimization="$optimization_level"
976 AC_MSG_RESULT($optimization)
978 paranoia_default=yes
979 #-----------------------------------------------------------------------------
980 AC_MSG_CHECKING([which paranoia flags to use])
981 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"])
982 if test "$paranoia_flags" = "no"; then
983         paranoia_flags="$""(WARN_ALL) -Werror-implicit-function-declaration"
984         msg_result="none"
985 else
986     if test "$paranoia_flags" = "yes"; then
987         paranoia_flags="$""(WARN_ALL) $""(WARN_ERROR)"
988     fi
989     msg_result="$paranoia_flags"
991 AC_MSG_RESULT($msg_result)
992 aros_warn_flags="$aros_warn_flags $paranoia_flags"
994 #-----------------------------------------------------------------------------
995 AC_MSG_CHECKING([what target variant to enable])
996 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant (default=none)]),target_variant=$enableval,target_variant="")
997 if test "$target_variant" = ""; then
998     aros_target_variant=""
999     aros_target_suffix=""
1000     enableval="none"
1001 else
1002     aros_target_variant="$target_variant"
1003     aros_target_suffix="-$target_variant"
1005 AC_MSG_RESULT($enableval)
1007 #-----------------------------------------------------------------------------
1008 # Target-specific defaults. You can override then on a per-target basis.
1010 # Bootloader name. Currently used by PC target.
1011 target_bootloader="none"
1012 PLATFORM_EXECSMP=
1013 ENABLE_EXECSMP=
1015 #-----------------------------------------------------------------------------
1016 # Additional options for some specific targets
1018 case "$aros_target_variant" in
1019 ios)
1020     AC_MSG_CHECKING([XCode path])
1021     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")
1022     AC_MSG_RESULT($aros_xcode_path)
1024     AC_MSG_CHECKING([what iOS SDK version to use])
1025     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")
1026     AC_MSG_RESULT($aros_sdk_version)
1028     ;;
1030 "android")
1031     AC_MSG_CHECKING([Android SDK path])
1032     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)
1033     AC_MSG_RESULT($aros_android_sdk)
1035     AC_MSG_CHECKING([Android NDK path])
1036     AC_ARG_WITH(ndk,AC_HELP_STRING([--with-ndk=PATH],[Specify Android NDK path (default=none).]),aros_android_ndk="$withval",aros_android_ndk="none")
1037     AC_MSG_RESULT($aros_android_ndk)
1039     AC_MSG_CHECKING([what Android SDK version to use])
1040     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")
1041     AC_MSG_RESULT($aros_sdk_version)
1043     aros_android_level=android-$aros_sdk_version
1044     if test ! -d $aros_android_sdk/platforms/$aros_android_level; then
1045         echo "Platform $aros_android_level is not installed in your SDK"
1046         echo "Use --with-sdk-version=<API level number> to select another platform version"
1047         echo "You can check what plaform versions are installed in your SDK"
1048         echo "by examining contents of $aros_android_sdk/platforms directory"
1049         AC_MSG_ERROR([Android platform $aros_android_level is not installed])
1050     fi
1052     export PATH="$aros_android_sdk/tools:$PATH"
1053     AC_PATH_PROG(android_tool, $android_tool)
1054     AROS_REQUIRED(android,$android_tool)
1056     if test "$aros_android_ndk" != "none"; then
1057         AC_MSG_CHECKING([what Android NDK version to use])
1058         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")
1059         AC_MSG_RESULT($aros_ndk_version)
1060     fi
1062     AC_PATH_PROG(ant, ant)
1063     if test "$ant" = ""; then
1064         AC_MSG_WARN([Apache Ant is missing, Java bootstrap can't be built automatically])
1065     fi
1067     AC_MSG_CHECKING([Build debug or release apk])
1068     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)
1069     if test $aros_android_antapk != release -a $aros_android_antapk != debug; then
1070         AC_MSG_ERROR([apk-version has to be release or debug])
1071     fi
1072     AC_MSG_RESULT($aros_android_antapk)
1074     target_extra_cfg+="$export_newline""# Android$export_newline""AROS_ANDROID_ANTAPK           := $aros_android_antapk$export_newline"
1075     host_extra_cfg+="$export_newline""# Android-specific$export_newline""ANDROID                       := $android_tool$export_newline""ANT                                   := $ant$export_newline"
1076     aros_target_options+="$export_newline""# Enable Android Gfx Driver$export_newline""OPT_HOST_ANDROIDGFX           := yes$export_newline"
1078     dnl MSYS bash can't run .bat files directly, then need to be started via cmd.exe
1079     if test "$host_os" = "mingw32"; then
1080         android_tool="cmd //c $android_tool"
1081     fi
1083     need_dlopen="no"
1085     ;;
1086 esac
1088 #-----------------------------------------------------------------------------
1089 # External toolchains
1090 kernel_tool_prefix="none"
1091 aros_tool_prefix="none"
1092 elf_tool_prefix="${target_cpu}-elf-"
1094 # Base target cpu ISA configuration switch.
1095 case "$target_cpu" in
1096     *aarch64*)
1097         ;;
1098     *arm*)
1099         ;;
1100     *m68k*)
1101         m68k_isa_extra="ISA_MC68000_FLAGS             = -march=68000"
1102         m68k_020_isa_extra="ISA_MC68020_FLAGS             = -march=68020"
1103         m68k_030_isa_extra="ISA_MC68030_FLAGS             = -march=68030"
1104         m68k_040_isa_extra="ISA_MC68040_FLAGS             = -march=68040"
1105         m68k_060_isa_extra="ISA_MC68060_FLAGS             = -march=68060"
1106         m68k_ac080_isa_extra="ISA_AC68080_FLAGS             = -march=68040"
1107         m68k_020_ext="ISA_MC68020_EXT               :=020"
1108         m68k_030_ext="ISA_MC68030_EXT               :=030"
1109         m68k_040_ext="ISA_MC68040_EXT               :=040"
1110         m68k_060_ext="ISA_MC68060_EXT               :=060"
1111         m68k_020_cflags="ISA_MC68020_CFLAGS            ="
1112         m68k_030_cflags="ISA_MC68030_CFLAGS            ="
1113         m68k_040_cflags="ISA_MC68040_CFLAGS            ="
1114         m68k_060_cflags="ISA_MC68060_CFLAGS            ="
1115         m68k_020_cppflags="ISA_MC68020_CPPFLAGS          ="
1116         m68k_030_cppflags="ISA_MC68030_CPPFLAGS          ="
1117         m68k_040_cppflags="ISA_MC68040_CPPFLAGS          ="
1118         m68k_060_cppflags="ISA_MC68060_CPPFLAGS          ="
1119         m68k_020_ldflags="ISA_MC68020_LDFLAGS           ="
1120         m68k_030_ldflags="ISA_MC68030_LDFLAGS           ="
1121         m68k_040_ldflags="ISA_MC68040_LDFLAGS           ="
1122         m68k_060_ldflags="ISA_MC68060_LDFLAGS           ="
1123         ;;
1124     *x86_64* | *i?86*)
1125         x86_isa_extra="ISA_X86_FLAGS                 = -m32 -march=i486"
1126         x86_64_isa_extra="ISA_X8664_FLAGS               = -mcmodel=large"
1127         ;;
1128     *powerpc*)
1129         ;;
1130 esac
1132 # This is the target configuration switch.
1133 case "$target_os" in
1134     linux*)
1135         aros_target_arch="linux"
1136         aros_target_family="unix"
1137         case "$target_cpu" in
1138             *m68k*)
1139                 aros_target_cpu="m68k"
1140                 aros_object_format="m68kelf"
1141                 aros_flavour="emulcompat"
1142                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
1143                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1144                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
1145                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
1146                 gcc_target_cpu="mc68000"
1147                 ;;
1148             *i?86*)
1149                 aros_target_cpu="i386"
1150                 aros_object_format="elf_i386"
1151                 aros_flavour="emulation"
1152                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
1153                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1154                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1155                 aros_kernel_ldflags="-Wl,-melf_i386"
1156                 aros_nominal_depth=8
1157                 gcc_target_cpu="i386"
1158                 pci_hidd_target="hidd-pci-linux"
1159                 android_tool_dir_prefix="x86"
1160                 android_tool_prefix="i686-android-linux"
1161                 android_ndk_arch="x86"
1162                 ;;
1163             *x86_64*)
1164                 aros_target_cpu="x86_64"
1165                 aros_object_format="elf_x86_64"
1166                 aros_flavour="emulation"
1167                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
1168                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1169                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1170                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1171                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1172                 aros_nominal_depth=8
1173                 pci_hidd_target="hidd-pci-linux"
1174                 ;;
1175             *powerpc*)
1176                 aros_target_cpu="ppc"
1177                 aros_object_format="elf32ppc"
1178                 aros_flavour="emulation"
1179                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1180                 aros_nominal_depth=8
1181                 gcc_target_cpu="ppc"
1182                 ;;
1183 # TODO
1184 # Same as powerpc, but I need this for the nightly build to work again.
1185 # Actually, the nightly should be made working with powerpc target.
1186 # That just was too much work for the moment, another week or two.
1187             *ppc*)
1188                 aros_target_cpu="ppc"
1189                 aros_object_format="elf32ppc"
1190                 aros_flavour="emulation"
1191                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
1192                 aros_nominal_depth=8
1193                 gcc_target_cpu="ppc"
1194                 ;;
1195             *aarch64*)
1196                 aros_target_cpu="aarch64"
1197                 target_cpu="aarch64"
1198                 aros_object_format="aarch64elf_aros"
1199                 aros_flavour="emulation"
1200                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1201                 gcc_target_cpu="aarch64"
1202                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1203                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1204                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1205                 aros_c_libs="$aros_c_libs -laeabi"
1206                 gcc_default_float_abi="hard"
1207                 kernel_tool_prefix="aarch64-linux-gnueabihf-"
1208                 ;;
1209             *armhf*)
1210                 aros_target_cpu="arm"
1211                 target_cpu="arm"
1212                 aros_object_format="armelf_aros"
1213                 aros_flavour="emulation"
1214                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1215                 gcc_target_cpu="arm"
1216                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1217                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1218                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1219                 aros_c_libs="$aros_c_libs -laeabi"
1220                 gcc_default_float_abi="hard"
1221                 android_tool_dir_prefix="arm-linux-androideabi"
1222                 android_tool_prefix="arm-linux-androideabi"
1223                 android_ndk_arch="arm"
1224                 kernel_tool_prefix="arm-linux-gnueabihf-"
1225                 ;;
1226             *arm*)
1227                 aros_target_cpu="arm"
1228                 aros_object_format="armelf_aros"
1229                 aros_flavour="emulation"
1230                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm -D__linux__"
1231                 gcc_target_cpu="arm"
1232                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1233                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_OMIT_FP)"
1234                 aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING)"
1235                 aros_c_libs="$aros_c_libs -laeabi"
1236                 android_tool_dir_prefix="arm-linux-androideabi"
1237                 android_tool_prefix="arm-linux-androideabi"
1238                 android_ndk_arch="arm"
1239                 kernel_tool_prefix="arm-linux-gnueabi-"
1240                 ;;
1241             *)
1242                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
1243                 ;;
1244         esac
1245         case "$aros_target_variant" in
1246             android)
1248                 dnl Not all Linux CPUs are supported by Android
1249                 if test "$android_ndk_arch" = ""; then
1250                     AC_MSG_ERROR("Unsupported CPU for Android -- $target_cpu")
1251                 fi
1253                 aros_nominal_width=320
1254                 aros_nominal_height=480
1255                 if test "$aros_android_ndk" = "none"; then
1256                     dnl Use standalone toolchain, don't adjust paths
1257                     aros_kernel_cflags="-mandroid"
1258                     aros_kernel_ldflags="-mandroid"
1259                     CFLAGS="-mandroid"
1260                 else
1261                     dnl In Android NDK toolchains are placed in own directories,
1262                     dnl but tool names are not suffixed with version 
1263                     export PATH="$aros_android_ndk/toolchains/$android_tool_dir_prefix-$kernel_tool_version/prebuilt/$android_build_os/bin:$PATH"
1264                     kernel_tool_version=""
1265                     aros_android_ndk="$aros_android_ndk/platforms/android-$aros_ndk_version/arch-$android_ndk_arch"
1266                     aros_kernel_cflags="--sysroot $aros_android_ndk -mandroid"
1267                     aros_kernel_ldflags="--sysroot $aros_android_ndk -mandroid"
1268                     CFLAGS="$CFLAGS --sysroot $aros_android_ndk -mandroid"
1269                     aros_kernel_includes="-isystem $aros_android_ndk/usr/include"
1270                 fi
1271                 need_x11=no
1272                 # Disable implicit PIC mode
1273                 aros_config_cflags="$aros_config_cflags -fno-pic"
1274                 kernel_tool_prefix="$android_tool_prefix-"
1275             ;;
1276         esac
1277     ;;
1279     pc)
1280         aros_target_arch="pc"
1281         aros_shared_default="no"
1282         target_bootloader="grub2"
1283         case "$target_cpu" in
1284             *i?86*)
1285                 aros_target_cpu="i386"
1287                 dnl If somebody hasn't already set the target object
1288                 dnl format, then use this value. Mostly to support
1289                 dnl FreeBSD cross-compilation.
1290                 dnl TODO: Remove when we always use our compiler.
1292                 if test "$aros_object_format" = "" ; then
1293                     aros_object_format="elf_i386"
1294                 fi
1295                 aros_flavour="standalone"
1296                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1297                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1298                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1299                 aros_kernel_ldflags="-Wl,-melf_i386"
1300                 aros_nominal_width=640
1301                 aros_nominal_height=480
1302                 gcc_target_cpu="i386"
1303                 ;;
1304             *x86_64*)
1305                 PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1306                 aros_target_cpu="x86_64"
1307                 aros_serial_debug=1
1308                 if test "$aros_object_format" = "" ; then
1309                     aros_object_format="elf_x86_64"
1310                 fi
1311                 aros_flavour="standalone"
1312                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1313                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1314                 x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_RED_ZONE)"
1315                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1316                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_OMIT_FP)"
1317                 aros_kernel_ldflags=""
1318                 aros_nominal_width=640
1319                 aros_nominal_height=480
1320                 case "$aros_target_variant" in
1321                     smp)
1322                         ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1323                     ;;
1324                 esac
1325                 ;;
1326             *)
1327                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
1328                 ;;
1329         esac
1330         ;;
1332     prep)
1333         aros_target_arch="prep"
1334         aros_shared_default="no"
1335         aros_target_cpu="ppc"
1336         aros_object_format="elf32ppc"
1337         aros_flavour="ppcnative"
1338         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1339         aros_kernel_ldflags=""
1340         aros_nominal_width=640
1341         aros_nominal_height=480
1342         gcc_target_cpu="ppc"
1343         ;;
1345     freebsd*)
1346         aros_target_arch="freebsd"
1347         aros_target_family="unix"
1348         aros_target_cpu="i386"
1349         aros_flavour="emulation"
1350         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1351         gcc_target_cpu="i386"
1353         aros_target_strip_flags="-x"
1354         ;;
1356     darwin*)
1357         aros_target_arch="darwin"
1358         aros_target_family="unix"
1359         aros_flavour="emulation"
1360         case "$target_cpu" in
1361             *i?86*)
1362                 aros_ios_platform="iPhoneSimulator"
1363                 aros_target_cpu="i386"
1364                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1365                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1366                 aros_kernel_ldflags=""
1367                 aros_macosx_version="10.4"
1368                 aros_nominal_depth=8
1369                 gcc_target_cpu="i386"
1370                 aros_object_format="elf_i386"
1371                 aros_kernel_ar_flags="-cr"
1372                 aros_target_strip_flags="-x"
1373                 kernel_tool_flags="-m32"
1374                 ;;
1375             *x86_64*)
1376                 aros_target_cpu="x86_64"
1377                 aros_object_format="elf_x86_64"
1378                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1379                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1380                 aros_macosx_version="10.6"
1381                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1382                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1383                 aros_kernel_cflags="-m64"
1384                 aros_kernel_ldflags="-m64"
1385                 aros_nominal_depth=8
1386                 aros_kernel_rs="$toolchain_ar"
1387                 aros_kernel_ar_flags="-cr"
1388                 aros_kernel_ld="$toolchain_ld"
1389                 aros_kernel_as="$toolchain_as"
1390                 aros_kernel_ranlib="$toolchain_ranlib"
1391                 aros_kernel_nm="$toolchain_nm"
1392                 aros_kernel_strip="strip"
1393                 kernel_tool_prefix="i686-apple-darwin10-"
1394                 ;;
1395             *ppc*)
1396                 aros_target_cpu="ppc"
1397                 aros_object_format="elf32ppc"
1398                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1399                 aros_kernel_ldflags=""
1400                 aros_macosx_version="10.0"
1401                 aros_nominal_depth=8
1402                 gcc_target_cpu="ppc"
1403                 aros_kernel_rs="$toolchain_ar"
1404                 aros_kernel_ar_flags="-cr"
1405                 aros_kernel_ld="$toolchain_ld -arch ppc"
1406                 aros_kernel_as="$toolchain_as -arch ppc"
1407                 aros_kernel_ranlib="$toolchain_ranlib -arch ppc"
1408                 aros_kernel_nm="$toolchain_nm -arch ppc"
1409                 aros_kernel_strip="strip -arch ppc"
1410                 kernel_tool_prefix="powerpc-apple-darwin10-"
1411                 ;;
1412             *arm*)
1413                 aros_ios_platform="iPhoneOS"
1414                 aros_target_cpu="arm"
1415                 aros_object_format="armelf_aros"
1416                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1417                 aros_c_libs="$aros_c_libs -laeabi"
1418                 aros_nominal_depth=8
1419                 gcc_target_cpu="arm"
1420                 aros_kernel_rs="$toolchain_ar"
1421                 aros_kernel_ar_flags="-cr"
1422                 aros_kernel_ld="$toolchain_ld -arch arm"
1423                 aros_kernel_ranlib="$toolchain_ranlib -arch arm"
1424                 kernel_tool_prefix="arm-apple-darwin10-" 
1425                 export PATH="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/usr/bin:$PATH"
1426                 ;;
1427             *)
1428                 AC_MSG_ERROR("Unsupported target CPU for darwin hosted flavour -- $target_cpu")
1429                 ;;
1430         esac
1431         case "$aros_target_variant" in
1432             ios)
1433                 make_extra_targetcfg="$export_newline""# Apple iOS stuff for gcc$export_newline""IOS_LDFLAGS  := -F$""(IOS_SDK_PATH)/System/Library/Frameworks$export_newline"
1434                 aros_ios_version="3.0"
1435                 aros_nominal_width=320
1436                 aros_nominal_height=480
1437                 aros_ios_sdk="$aros_xcode_path/Platforms/$aros_ios_platform.platform/Developer/SDKs/$aros_ios_platform$aros_sdk_version.sdk"
1438                 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"
1439                 kernel_tool_flags="$target_tool_flags -isysroot $aros_ios_sdk"
1440                 aros_kernel_includes="-isystem $aros_ios_sdk/usr/include"
1441                 need_x11=no
1442                 # This is here because it may depend on iOS or SDK version
1443                 aros_kernel_cflags="$aros_kernel_cflags -miphoneos-version-min=$aros_ios_version"
1444                 aros_kernel_ldflags="$aros_kernel_ldflags -miphoneos-version-min=$aros_ios_version"
1445                 aros_kernel_objcflags="-fobjc-abi-version=2 -fobjc-legacy-dispatch"
1446             ;;
1447             *)
1448                 aros_kernel_cflags="$aros_kernel_cflags -mmacosx-version-min=$aros_macosx_version"
1449                 aros_kernel_ldflags="$aros_kernel_ldflags -mmacosx-version-min=$aros_macosx_version"
1450             ;;
1451         esac
1452         ;;
1454     dragonfly*)
1455         aros_target_arch="dragonfly"
1456         aros_target_family="unix"
1457         aros_flavour="emulation"
1458         case "$target_cpu" in
1459             *i?86*)
1460                 aros_target_cpu="i386"
1461                 aros_object_format="elf_i386"
1462                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__DragonFly__"
1463                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1464                 ;;
1465             *x86_64*)
1466                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1467                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1468                 aros_target_cpu="x86_64"
1469                 aros_object_format="elf_x86_64"
1470                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__DragonFly__"
1471                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1472                 ;;
1473             *)
1474                 AC_MSG_ERROR("Unknown CPU for DragonFly -- $target_cpu")
1475                 ;;
1476         esac
1477         ;;
1479     netbsd*)
1480         aros_target_arch="netbsd"
1481         aros_target_family="unix"
1482         case "$target_cpu" in
1483             *m68k*)
1484                 aros_target_cpu="m68k"
1485                 aros_object_format="m68kelf"
1486                 aros_flavour="emulcompat"
1487                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
1488                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1489                 gcc_target_cpu="mc68000"
1490                 ;;
1491             *i?86*)
1492                 aros_target_cpu="i386"
1493                 aros_object_format="elf_i386"
1494                 aros_flavour="emulation"
1495                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
1496                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1497                 aros_nominal_depth=8
1498                 gcc_target_cpu="i386"
1499                 ;;
1500             *)
1501                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
1502                 ;;
1503         esac
1504         aros_target_genmap="-Wl,-M -Xlinker >"
1505         aros_flavour="emulation"
1506         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1507         ;;   
1509     openbsd*)
1510         aros_target_arch="openbsd"
1511         aros_target_family="unix"
1512         case "$target_cpu" in
1513             *i?86*)
1514                 aros_target_cpu="i386"
1515                 aros_object_format="elf_i386"
1516                 aros_flavour="emulation"
1517                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
1518                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1519                 gcc_target_cpu="i386"
1520                 ;;
1521             *)
1522                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
1523                 ;;
1524         esac
1525         aros_target_genmap="-Wl,-M -Xlinker >"
1526         aros_target_nm_flags="-u"
1527         aros_flavour="emulation"
1528         ;;
1530     solaris*)
1531         aros_target_arch="solaris"
1532         aros_target_family="unix"
1533         case "$target_cpu" in
1534            *i?86*)
1535                aros_target_cpu="i386"
1536                aros_object_format="elf_i386"
1537                aros_flavour="emulation"
1538                aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__Solaris__"
1539                aros_isa_flags="$""(ISA_X86_FLAGS)"
1540                aros_nominal_depth=8
1541                gcc_target_cpu="i386"
1542                ;;
1543             *sparc*)
1544                 aros_target_cpu="sparc"
1545                 aros_object_format="elf_sparc"
1546                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
1547                 gcc_target_cpu="sparc"
1548                 ;;
1549             *)
1550                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
1551                 ;;
1552         esac
1553         aros_config_cppflags="$aros_config_cppflags -D$aros_target_cpu"
1554         aros_flavour="emulation"
1555         ;;
1557     morphos*)
1558         aros_target_arch="morphos"
1559         aros_shared_default="no"
1560         aros_target_cpu="ppc"
1561         aros_object_format="elf_ppc"
1562         aros_flavour="nativecompat"
1563         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1564         gcc_target_cpu="ppc"
1565         ;;
1567     sam440)
1568         aros_target_arch="sam440"
1569         aros_shared_default="no"
1570         aros_target_cpu="ppc"
1571         aros_object_format="elf32ppc"
1572         aros_flavour="ppcnative"
1573         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1574         aros_kernel_ldflags=""
1575         aros_nominal_width=1024
1576         aros_nominal_height=768
1577         aros_nominal_depth=24
1578         aros_isa_flags="$aros_isa_flags -mcpu=440fp -mno-toc"
1579         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1580         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1581         gcc_target_cpu="powerpc"
1582         ;;
1584     efika)
1585         aros_target_arch="efika"
1586         aros_shared_default="no"
1587         aros_target_cpu="arm"
1588         aros_object_format="armelf_aros"
1589         aros_flavour="standalone"
1590         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1591         aros_kernel_ldflags=""
1592         aros_nominal_width=1024
1593         aros_nominal_height=600
1594         aros_c_libs="$aros_c_libs -laeabi"
1595         gcc_default_cpu="armv7-a"
1596         gcc_default_fpu="vfpv3"
1597         aros_isa_flags="$aros_isa_flags -mtune=cortex-a8"
1598         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1599         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1600         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1601         if test "$optimization" = "default"; then
1602             optimization_level="-Os"
1603         fi
1604         case "$target_cpu" in
1605             *armhf*)
1606                 gcc_default_float_abi="hard"
1607                 target_cpu=arm
1608                 aros_target_cpu=arm
1609                 ;;
1610             *arm*)
1611                 gcc_default_float_abi="softfp"
1612                 ;;
1613             *)
1614                 AC_MSG_ERROR("Unknown CPU for EfikaMX $target_cpu")
1615                 ;;
1616         esac
1617         ;;
1618         
1619     chrp)
1620         aros_target_arch="chrp"
1621         aros_shared_default="no"
1622         aros_target_cpu="ppc"
1623         aros_object_format="elf32ppc"
1624         aros_flavour="ppcnative"
1625         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
1626         aros_kernel_ldflags=""
1627         aros_nominal_width=640
1628         aros_nominal_height=480
1629         aros_isa_flags="$aros_isa_flags -mno-toc"
1630         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1631         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES)"
1632         gcc_target_cpu="powerpc"
1633         case "$aros_target_variant" in
1634             efika)
1635                 aros_isa_flags="$aros_isa_flags -mcpu=603e"
1636                 aros_config_cppflags="$aros_config_cppflags -DBIG_ENDIAN_OHCI=1"
1637             ;;
1638         esac
1639         ;;
1641     r*pi)
1642         PLATFORM_EXECSMP="#define __AROSPLATFORM_SMP__"
1643         aros_flavour="standalone"
1644         aros_target_arch="raspi"
1646         aros_shared_default="no"
1648         aros_target_mkdep="$aros_target_mkdep -D__GNUC__"
1649         
1650         case "$target_cpu" in
1651             *aarch64*)
1652                 aros_target_cpu="aarch64"
1653                 gcc_default_cpu="aarch64"
1654                 aros_object_format="aarch64elf_aros"
1655                 ;;
1656             *armhf*)
1657                 aros_target_cpu="arm"
1658                 gcc_default_cpu="armv6zk"
1659                 gcc_default_cpu_tune="arm1176jzf-s"
1660                 aros_object_format="armelf_aros"
1661                 aros_isa_flags="$aros_isa_flags -marm"
1662                 aros_config_cflags="$aros_config_cflags"
1663                 aros_config_cxxflags="$aros_config_cxxflags"
1664                 aros_config_aflags="$aros_config_aflags -marm"
1665                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1666                 aros_target_mkdep="$aros_target_mkdep -Darm"
1667                 aros_c_libs="$aros_c_libs -laeabi"
1668                 ;;
1669             *armeb*)
1670                 aros_flavour="standcompat"
1671                 aros_target_cpu="armeb"
1672                 gcc_default_float_abi="hard"
1673                 gcc_default_cpu="armv7ve"
1674                 gcc_default_cpu_tune="cortex-a7"
1675                 aros_object_format="armelfb_aros"
1676                 aros_isa_flags="$aros_isa_flags -marm"
1677                 aros_config_cflags="$aros_config_cflags"
1678                 aros_config_cxxflags="$aros_config_cxxflags"
1679                 aros_config_aflags="$aros_config_aflags -marm"
1680                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1681                 aros_target_mkdep="$aros_target_mkdep -Darm"
1682                 aros_c_libs="$aros_c_libs -laeabi"
1683                 ;;
1684             *arm*)
1685                 aros_target_cpu="arm"
1686                 gcc_default_cpu="armv6zk"
1687                 gcc_default_cpu_tune="arm1176jzf-s"
1688                 aros_object_format="armelf_aros"
1689                 aros_isa_flags="$aros_isa_flags -marm"
1690                 aros_config_cflags="$aros_config_cflags"
1691                 aros_config_cxxflags="$aros_config_cxxflags"
1692                 aros_config_aflags="$aros_config_aflags -marm"
1693                 aros_kernel_cflags="$aros_kernel_cflags -marm"
1694                 aros_target_mkdep="$aros_target_mkdep -Darm"
1695                 aros_c_libs="$aros_c_libs -laeabi"
1696                 ;;
1697             *)
1698                 AC_MSG_ERROR("Unknown CPU for RasPi $target_cpu")
1699                 ;;
1700         esac
1702         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1703         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1704         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1705         aros_kernel_cflags="$aros_kernel_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
1707         case "$aros_target_variant" in
1708             smp)
1709                 ENABLE_EXECSMP="#define __AROSEXEC_SMP__"
1710             ;;
1711         esac
1712         ;;
1714     stm32f7_discovery)
1715         aros_flavour="standalone"
1716         aros_target_arch="stm32f7_discovery"
1717         aros_target_cpu="arm"
1718         aros_target_cpu_mode="thumb2"
1719         aros_object_format="armelf_aros"
1720         aros_shared_default="no"
1722         gcc_default_cpu="armv7e-m"
1723         gcc_default_cpu_tune="cortex-m7"
1724         gcc_default_fpu="fpv5-sp-d16"
1725         gcc_default_float_abi="hard"
1727         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dthumb"
1728         ;;
1730     amiga*)
1731         aros_elf_translate="$""(ELF2HUNK)"
1732         make_extra_commands="$export_newline""ELF2HUNK  := $""(TOOLDIR)/elf2hunk$""(HOST_EXE_SUFFIX)$export_newline"
1733         aros_target_arch="amiga"
1734         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
1735         aros_shared_default="no"
1737         case "$target_cpu" in
1738             *m68k*)
1739                 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")
1740                 aros_enable_mmu=no
1741                 aros_target_cpu="m68k"
1742                 aros_object_format="m68kelf"
1743                 aros_flavour="standcompat"
1744                 gcc_target_cpu="m68000"
1745                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1746                 aros_nowarn_flags="$aros_nowarn_flags NOWARN_VOLATILE_REGISTER_VAR"
1747                 aros_config_cppflags="$aros_config_cppflags -DNOLIBINLINE"
1748                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1749                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_STRICT_ALIASING) $""(CFLAGS_FREESTANDING) $""(CFLAGS_OMIT_FP) $""(CFLAGS_BUILTIN)"
1750                 if test "$optimization" = "default"; then
1751                     optimization_level="-Os"
1752                 fi
1753                 aros_config_aflags="$aros_config_aflags"
1754                 aros_target_strip_flags="-R.comment --strip-debug"
1755                 aros_nominal_width=640
1756                 aros_nominal_height=256
1757                 aros_nominal_depth=2
1758                 ;;
1759             *ppc*)
1760                 aros_cpu="ppc"
1761                 aros_flavour="native"
1762                 gcc_target_cpu="ppc"
1763                 ;;
1764             *)
1765                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
1766                 ;;
1767         esac
1768         ;;
1770     mingw*)
1771         aros_target_arch="mingw32"
1772         aros_shared_default="no"
1773         aros_flavour="emulation"
1774         aros_shared_cflags=""
1775         need_crosstools="yes"
1776         need_dlopen="no"
1777         rescomp="windres"
1778         case "$target_cpu" in
1779             *i?86*)
1780                 aros_target_cpu="i386"
1781                 aros_object_format="elf_i386"
1782                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
1783                 aros_isa_flags="$""(ISA_X86_FLAGS)"
1784                 aros_nominal_depth=8
1785                 gcc_target_cpu="i386"
1787                 kernel_tool_prefix="i386-mingw32-"
1788                 ;;
1789             *x86_64*)
1790                 aros_target_cpu="x86_64"
1791                 aros_object_format="elf_x86_64"
1792                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
1793                 aros_isa_flags="$""(ISA_X8664_FLAGS)"
1794                 aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_OMIT_FP)"
1795                 aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_OMIT_FP)"
1796                 aros_nominal_depth=8
1797                 kernel_tool_prefix="x86_64-w64-mingw32-"
1798                 ;;
1799             *arm*)
1800                 aros_target_cpu="arm"
1801                 aros_object_format="armelf_aros"
1802                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Darm"
1803                 aros_c_libs="$aros_c_libs -laeabi"
1804                 aros_nominal_depth=8
1805                 gcc_target_cpu="arm"
1806                 gcc_default_float_abi="soft"
1807                 kernel_tool_prefix="arm-mingw32ce-"
1808                 aros_nominal_width=160
1809                 aros_nominal_height=160
1810                 ;;
1811             *)
1812                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
1813                 ;;
1814         esac
1815         if test $host_os = "cygwin"; then
1816                 aros_kernel_cflags="-mno-cygwin"
1817         fi
1818     ;;
1819     pp*)
1820         aros_target_arch="pp"
1821         aros_shared_default="no"
1822         case "$target_cpu" in
1823             *m68k*)
1824                 aros_target_cpu="m68k"
1825                 aros_object_format="m68kelf"
1826                 aros_flavour="palmnative"
1827                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1828                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1829                 aros_nominal_width=160
1830                 aros_nominal_height=160
1831                 aros_nominal_depth=1
1832                 aros_target_ar_flags="cru"
1833                 aros_c_libs="$aros_c_libs -lgcc1"
1834                 aros_shared_default=no
1835                 aros_shared_cflags="-fpic"
1836                 aros_shared_aflags=""
1837                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1838                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1839                 aros_debug_cppflags="$aros_messages_debug"
1840                 aros_debug_cflags="$aros_symbols_debug"
1841                 aros_debug_aflags=""
1842                 aros_debug_ldflags="$aros_symbols_debug"
1843                 aros_mungwall_debug="0"
1844                 aros_modules_debug="0"
1845                 gcc_target_cpu="mc68000"
1846                 ignore_undefined_symbols="-ius"
1847                 ;;
1848            *)
1849                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
1850                 ;;
1851         esac
1852         ;;
1854     mac*)
1855         aros_target_arch="mac"
1856         aros_shared_default="no"
1857         case "$target_cpu" in
1858             *m68k*)
1859                 aros_target_cpu="m68k"
1860                 aros_object_format="m68kelf"
1861                 aros_flavour="mac68knative"
1862                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
1863                 aros_isa_flags="$""(ISA_MC68000_FLAGS)"
1864                 aros_nominal_width=512
1865                 aros_nominal_height=384
1866                 aros_nominal_depth=8
1867                 aros_target_ar_flags="cru"
1868                 aros_c_libs="$aros_c_libs -lgcc1"
1869                 aros_shared_default=no
1870                 aros_shared_cflags="-fpic"
1871                 aros_shared_aflags=""
1872                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1873                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1874                 aros_debug_cppflags="$aros_messages_debug"
1875                 aros_debug_cflags="$aros_symbols_debug"
1876                 aros_debug_aflags=""
1877                 aros_debug_ldflags="$aros_symbols_debug"
1878                 aros_mungwall_debug="0"
1879                 aros_modules_debug="0"
1880                 gcc_target_cpu="mc68000"
1881                 ignore_undefined_symbols="-ius"
1882                 ;;
1883            *)
1884                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1885                 ;;
1886         esac
1887         ;;
1889     *)
1890         AC_MSG_ERROR([Unsupported target architecture $target])
1891         ;;
1892 esac
1894 #-----------------------------------------------------------------------------
1895 crosstools_guess="yes"
1896 aros_target_toolchain="no"
1897 aros_kernel_sysroot=""
1899 AC_MSG_CHECKING([Kernel toolchain prefix])
1900 AC_ARG_WITH(kernel-toolchain-prefix,AC_HELP_STRING([--with-kernel-toolchain-prefix=...],[Specify crosscompile toolchain prefix for kernel objects]),[kernel_tool_prefix="$withval"])
1901 AC_MSG_RESULT($kernel_tool_prefix)
1903 AC_MSG_CHECKING([ELF toolchain prefix])
1904 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"
1905                                                  crosstools_guess="no"])
1906 AC_MSG_RESULT($elf_tool_prefix)
1908 AC_MSG_CHECKING([AROS toolchain prefix])
1909 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"
1910                 crosstools_guess="no"])
1911 if test "$aros_tool_prefix" = "yes" ; then
1912     aros_tool_prefix=$aros_target_cpu-aros-
1914 AC_MSG_RESULT($aros_tool_prefix)
1916 #-----------------------------------------------------------------------------
1917 #   Checking if we should build crosstools..
1918 AC_MSG_CHECKING([whether to build crosstools])
1919 AC_ARG_ENABLE(crosstools,AC_HELP_STRING([--disable-crosstools],[Do not build cross-compiler toolchain]),crosstools="$enableval",crosstools="$crosstools_guess")
1920 AC_MSG_RESULT($crosstools)
1922 if test "${crosstools}" = "yes"; then
1923     if test "${crosstools_guess}" = "no"; then
1924         AC_MSG_ERROR([Cannot build external toolchain if an external ELF or AROS toolchain is specified])
1925     fi
1928 if test "${crosstools}" = "yes" || test "${crosstools_guess}" = "no"; then
1929     aros_target_toolchain="yes"
1932 AC_MSG_CHECKING([where to install the crosstools binaries])
1933 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])
1934 if test "x$aros_toolchain_install" = "x"; then
1935     AROS_CROSSTOOLSDIR="$AROS_BUILDDIR_UNIX/bin/$aros_host_arch-$aros_host_cpu/tools/crosstools"
1936 else
1937     AROS_CROSSTOOLSDIR="$aros_toolchain_install"
1938     PATH="$AROS_CROSSTOOLSDIR:$PATH"
1939     if test "$crosstools_guess" = "no" ; then
1940         if test "x-$aros_flavour" != "x-emulation" -a "x-$aros_flavour" != "x-emulcompat" ; then
1941             aros_kernel_sysroot="$""(TARGET_SYSROOT)"
1942         fi
1943     fi
1945 AC_MSG_RESULT($AROS_CROSSTOOLSDIR)
1947 #-----------------------------------------------------------------------------
1948 if test "$aros_toolchain" = "gnu" ; then
1949     AC_MSG_CHECKING([what specific target binutils version to use])
1951 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="")
1952 if test "$use_binutils_version" = ""; then
1953         target_binutils_version="$default_binutils_version"
1954 else
1955     target_binutils_version="$use_binutils_version"
1957 if test "$aros_toolchain" = "gnu" ; then
1958     AC_MSG_RESULT($target_binutils_version)
1962 # Helper to identify gcc version
1963 AC_DEFUN([CROSS_GCC_VERSION], [
1964   target_gcc_version=""
1965   AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
1966     ax_cv_gcc_version="`$AROS_CROSSTOOLSDIR/${aros_tool_prefix}${toolchain_cpp_preprocessor} -dumpversion`"
1967     AS_IF([test "x$ax_cv_gcc_version" = "x"],[
1968       ax_cv_gcc_version=""
1969     ])
1970   ])
1971   target_gcc_version=$ax_cv_gcc_version
1972   AC_SUBST([target_gcc_version])
1975 #-----------------------------------------------------------------------------
1976 if test "$aros_toolchain" = "gnu" ; then
1977     AC_MSG_CHECKING([what specific target gcc version to use])
1979 AC_ARG_WITH(gcc-version,AC_HELP_STRING([--with-gcc-version=VERSION],[Compile gcc-VERSION for AROS]),use_gcc_version="$withval",use_gcc_version="")
1980 if test "$use_gcc_version" = ""; then
1981     if test "${crosstools}" = "no"; then
1982       if test "x$aros_toolchain_install" != "x"; then
1983           CROSS_GCC_VERSION
1984       fi
1985     fi
1986     if test "$use_gcc_version" = ""; then
1987         target_gcc_version="$default_gcc_version"
1988     fi
1989 else
1990     target_gcc_version="$use_gcc_version"
1992 if test "$aros_toolchain" = "gnu" ; then
1993     AC_MSG_RESULT($target_gcc_version)
1995     AC_MSG_CHECKING([version string style])
1996     if test "${target_gcc_version#*$'-'}" != "$target_gcc_version" ; then
1997         AC_MSG_RESULT(snapshot)
1998         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'-' -f1)
1999         GCC_VERSION_MINOR=-1
2000         GCC_VERSION_PATCH=-1
2001     else
2002         AC_MSG_RESULT(release)
2003         GCC_VERSION_MAJOR=$(echo $target_gcc_version | cut -d'.' -f1)
2004         GCC_VERSION_MINOR=$(echo $target_gcc_version | cut -d'.' -f2)
2005         GCC_VERSION_PATCH=$(echo $target_gcc_version | cut -d'.' -f3)
2006     fi
2008     gcc_fix_bitfields="false"
2009     if test "$GCC_VERSION_MAJOR" -gt "4" ; then
2010         gcc_fix_bitfields="true"
2011     else
2012         if test "$GCC_VERSION_MAJOR" -gt "3" ; then
2013             if test "$GCC_VERSION_MINOR" -gt "6" ; then
2014                 gcc_fix_bitfields="true"
2015             fi
2016         fi
2017     fi
2019     if test "$gcc_fix_bitfields" = "true" ; then
2020         case "$aros_target_cpu" in
2021         *x86_64* | *i?86*)
2022             x86_isa_extra="$x86_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2023             x86_64_isa_extra="$x86_64_isa_extra $""(CFLAGS_NO_MS_BITFIELDS)"
2024             ;;
2025         esac
2026     fi
2029 AC_MSG_CHECKING([whether to enable Objective-C suppport])
2030 AC_ARG_ENABLE(objc,AC_HELP_STRING([--enable-objc],[Enable Objectve-C support (default=no)]),objc="$enableval",objc="no")
2031 AC_MSG_RESULT($objc)
2032 if test "x$objc" = "xyes"; then
2033     objc_target="$objc"
2034 else
2035     objc_target="no-objc"
2038 AC_MSG_CHECKING([whether to enable Java suppport])
2039 AC_ARG_ENABLE(java,AC_HELP_STRING([--enable-java],[Enable Java support (default=no)]),java="$enableval",java="no")
2040 AC_MSG_RESULT($java)
2041 if test "x$java" != "xno"; then
2042     java_target="$java"
2043 else
2044     java_target="no-java"
2047 spec_obj_format="-m $aros_object_format"
2048 # Now process extra architecture-specific options.
2049 # Currently this is implemented only for ARM. We can specify which minimum CPU and FPU to use,\
2050 # as well as floating-point ABI.
2051 case "$aros_target_cpu" in
2052     *m68k*)
2053         aros_isa_targets="M68K_ISA_TARGETS              :=MC68020 MC68040"
2054         aros_isa_extra="$aros_isa_extra$export_newline$aros_isa_targets$export_newline"
2055         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"
2056         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"
2057         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"
2058         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"
2059         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"
2060         ;;
2061     *x86_64*)
2062         aros_isa_extra="$export_newline$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2063         dnl x86_64 can build 32 or 64bit code
2064         spec_obj_format="%{!m32:-m elf_x86_64} %{m32:-m elf_i386}"
2065         ;;
2066     arm*)
2067         dnl ARM defaults are: armv6 + vfp (unless overriden in per-target section above)
2068         if test "$gcc_default_cpu" = ""; then
2069             gcc_default_cpu="armv6"
2070         fi
2071         if test "$gcc_default_fpu" = ""; then
2072             gcc_default_fpu="vfp"
2073         fi
2074         if test "$gcc_default_endian" = ""; then
2075             if test "$target_cpu" = "armeb"; then
2076                 gcc_default_endian="big-endian"
2077             else
2078                 gcc_default_endian="little-endian"
2079             fi
2080         fi
2081         if test "$gcc_default_float_abi" = ""; then
2082             if test "$target_cpu" = "armhf"; then
2083                 gcc_default_float_abi="hard"
2084             else
2085                 gcc_default_float_abi="softfp"
2086             fi
2087         fi
2089         AC_MSG_CHECKING([Which minimum CPU to use])
2090         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)
2091         AC_MSG_RESULT($aros_gcc_cpu)
2093         AC_MSG_CHECKING([Which minimum FPU to use])
2094         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)
2095         AC_MSG_RESULT($aros_gcc_fpu)
2097         AC_MSG_CHECKING([Which floating point ABI to use])
2098         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)
2099         AC_MSG_RESULT($aros_gcc_float_abi)
2101         AC_MSG_CHECKING([Which ARM mode to use])
2102         if test "$aros_target_cpu_mode" = ""; then
2103             aros_target_cpu_mode="arm32"
2104             AC_MSG_RESULT([Defaulting to $aros_target_cpu_mode])
2105         else
2106             AC_MSG_RESULT([$aros_target_cpu_mode])
2107         fi
2109         case "$aros_target_cpu_mode" in
2110         arm32)
2111             gcc_default_mode="arm"
2112             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"
2113         ;;
2114         arm64)
2115             AC_MSG_ERROR([ARM 64-bit mode is unsupported])
2116         ;;
2117         thumb)
2118             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2119         ;;
2120         thumb1)
2121             AC_MSG_ERROR([Thumb1 16-bit mode is unsupported])
2122         ;;
2123         thumb2)
2124             gcc_default_mode="thumb"
2125             # Do not specify -mthumb-interwork as it may add extra code to support arm/thumb interwork
2126             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"
2127         ;;
2128         *)
2129             AC_MSG_ERROR([Unsupported ARM mode specified $aros_target_cpu_mode])
2130         ;;
2131         esac
2133         aros_config_cflags="$aros_config_cflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2134         aros_config_cxxflags="$aros_config_cxxflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2135         aros_config_aflags="$aros_config_aflags $""(CFLAGS_NO_ASYNCHRONOUS_UNWIND_TABLES) $""(CFLAGS_NO_EXCEPTIONS)"
2136         ;;
2137     i386)
2138         aros_isa_extra="$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"
2139         aros_kernel_ldflags="$aros_kernel_ldflags -m32" 
2140         ;;
2141 esac
2143 # Some architectures may need custom ELF specs.
2144 if test -f $SRCDIR/config/${aros_object_format}-specs.in; then
2145     elf_specs_in=config/${aros_object_format}-specs.in
2146 else
2147     elf_specs_in=config/elf-specs.in
2150 # Some compilers (ppc-elf-gcc is known to) have CPU defines in specs
2151 # Since we override specs, we may need to put these defines there
2152 if test "$gcc_target_cpu" != ""; then
2153     gcc_target_cpu="-D__${gcc_target_cpu}__"
2156 AC_MSG_CHECKING([where to download sourcecode for external ports])
2157 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
2158 if test "$with_portssrcdir" = "default"; then
2159     AROS_PORTSSRCDIR="$AROS_BUILDDIR_UNIX/bin/Sources"
2160 else
2161     AROS_PORTSSRCDIR="$with_portssrcdir"
2163 AC_MSG_RESULT($AROS_PORTSSRCDIR)
2165 AC_MSG_CHECKING([which bootloader to use])
2166 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
2167 if test "$target_bootloader" = "none"; then
2168     aros_target_bootloader=""
2169 else
2170     aros_target_bootloader="$target_bootloader"
2172 AC_MSG_RESULT($target_bootloader)
2174 AC_MSG_CHECKING([which icon-set to use])
2175 AC_ARG_WITH(iconset,AC_HELP_STRING([--with-iconset=NAME],[Use a specific Icon-set (default=Gorilla).]),target_iconset=$withval,target_iconset="default")
2176 if test "$target_iconset" = "default"; then
2177     aros_target_iconset="Gorilla"
2178     target_iconset="default (Gorilla)"
2179 else
2180     aros_target_iconset="$target_iconset"
2182 AC_MSG_RESULT($target_iconset)
2184 AC_MSG_CHECKING([which GUI Theme to use])
2185 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
2186 if test "$target_guitheme" = "default"; then
2187     aros_target_guitheme="Ice"
2188 else
2189     aros_target_guitheme="$target_guitheme"
2191 AC_MSG_RESULT($aros_target_guitheme)
2193 # Find out if we are cross-compiling (i.e. if we can't use the host compiler
2194 # for target code)
2195 cross_compiling=no
2197 dnl The first case is simple. If we are compiling for another CPU, we are cross-compiling for sure
2198 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
2199     cross_compiling=yes
2202 dnl x86-64 toolchains can also produce i386 binaries, given -m32 flag.
2203 dnl The flag itself is given in per-target section, because some targets require to pass it
2204 dnl in a different manner, otherwise some tests fail.
2205 dnl TODO: Justify this.
2206 if test "$aros_host_cpu" == "x86_64" ; then
2207     if test "$aros_target_cpu" == "i386" ; then
2208         cross_compiling=no
2209     fi
2212 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2213     dnl For a hosted build we are cross-compiling if host OS differs from build OS.
2214     dnl TODO: This might get a little bit more tricky if we ever cross-compile ARM-Android-hosted
2215     dnl AROS on ARM Linux, or even vice versa (Linux-hosted ARM AROS building on ARM Android).
2216     dnl ARM ABIs of Linux and Android are not compatible (despite very close), so host_cc can't be
2217     dnl used to build bootstrap for target arch in either case.
2218     dnl For us Android is not a separate OS, but a variant of Linux, so both systems will be
2219     dnl identified as 'linux'. If this ever involves, we'll have to implement some additional check,
2220     dnl perhaps introducing aros_host_variant
2221     if test "$aros_host_arch" != "$aros_target_arch" ; then
2222         cross_compiling=yes
2223     fi
2224 else
2225     dnl For a native build we only care if our host_cc can produce static ELF files. If so, we can use
2226     dnl it as kernel_cc. If not, (e.g. we are on Windows or Darwin), we need a crosscompiler.
2227     dnl if test "$host_cc_elf" = "no" ; then
2228         cross_compiling=yes
2229     dnl fi
2232 if test "$cross_compiling" = "no" ; then
2233     kernel_tool_prefix=""
2234     if test "$host_cc_elf" = "yes" ; then
2235         elf_tool_prefix=""
2236     fi
2239 if test "$kernel_tool_version" != ""; then
2240     kernel_tool_version="-$kernel_tool_version"
2243 #######################################################################
2244 ## Compute what toolchains to use, and their paths                   ##
2245 #######################################################################
2247 # This takes, as input:
2248 #   crosstools             {yes,no}
2249 #   kernel_tool_version    {"",[version]}
2250 #   target_tool_version    {"",[version]}
2251 #   kernel_tool_prefix     {none,[some-arch-os-]}
2252 #   gnu-toolchain -:
2253 #     target_tool_prefix     ${aros_target_cpu}-aros-
2254 #     aros_tool_prefix       ${aros_target_cpu}-aros-
2256 # The output is
2257 #   aros_kernel_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2258 #        Where the 'kernel' binaries are located
2259 #   orig_target_{cpp,cc,ar,ld,as,ranlib,nm,strip}
2260 #        Where the 'target' binaries are located
2261 #        (not the symlink farm - that is aros_target_*!)
2263 # The rules are:
2264 #   if crosstools then
2265 #      if kernel_tools_prefix = "no-kernel-prefix-"
2266 #          aros_kernel_* = crosstools cc paths
2267 #          aros_kernel_cc = elf cc wrapper around crosstools cc
2268 #      else
2269 #          VALIDATE(${kernel_tools_prefix}*)
2270 #          aros_kernel_* = ${kernel_tools_prefix}*
2271 #          if ${kernel_tools_prefix}cc is an AROS gcc
2272 #              aros_kernel_cc = ${kernel_tools_prefix}cc
2273 #          else
2274 #              aros_kernel_cc = elf cc wrapper around ${kernel_tools_prefix}cc
2275 #          fi
2276 #      fi
2278 #      orig_target_* = aros built crosstools
2279 #      orig_target_cc = elf cc wrapper around crosstools cc
2280 #   else
2281 #      VALIDATE(${kernel_tools_prefix}*)
2283 #      orig_target_* = aros_kernel_*
2284 #      if aros_kernel_cc is an AROS gcc
2285 #          orig_target_cc = aros_kernel_cc
2286 #      else
2287 #          orig_target_cc = aros cc wrapper around aros_kernel_cc
2288 #      fi
2289 #   fi
2291 if test "$aros_toolchain" = "gnu" ; then
2292     target_tool_prefix="${aros_target_cpu}-aros-"
2293 elif test "$aros_toolchain" = "llvm" ; then
2294     target_tool_prefix="bin/"
2297 if test "$kernel_tool_prefix" != "" ; then
2298     AC_MSG_CHECKING([which kernel tools])
2299     AC_MSG_RESULT([$kernel_tool_prefix]);
2302 if test "$kernel_tool_prefix" = "none" ; then
2303     dnl ELF wrapper can be used only for native bootstrap
2304     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2305         AC_MSG_ERROR([--with-kernel-toolchain-prefix= is required for this arch])
2306     fi
2307 else
2308     if test "x-$aros_flavour" != "x-standalone" -o "x-$aros_flavour" != "x-standcompat" ; then
2309         # Kernel tools required - find them
2310         # Note that 'normally', aros_kernel_* overrides will be
2311         # empty, unless specified in the per-arch sections above.
2312         test_kernel_cc=yes
2313         if test "x$aros_kernel_cpp" = "x"; then
2314             aros_kernel_cpp=${kernel_tool_prefix}${CPP}
2315         fi
2316         AROS_BUILDCMD(aros_kernel_cpp,$aros_kernel_cpp,${kernel_tool_version})
2317         AROS_TOOL_KERNEL(aros_kernel_cpp,cpp,$aros_kernel_cpp)
2318         AROS_REQUIRED(cpp,$aros_kernel_cpp)
2320         if test "x$aros_kernel_cc" = "x"; then
2321             aros_kernel_cc=${kernel_tool_prefix}${CC}
2322         fi
2323         AROS_BUILDCMD(aros_kernel_cc,$aros_kernel_cc,${kernel_tool_version})
2324         AROS_TOOL_KERNEL(aros_kernel_cc,cc,$aros_kernel_cc)
2325         AROS_REQUIRED(cc,$aros_kernel_cc)
2327         if test "x$aros_kernel_cxx" = "x"; then
2328             aros_kernel_cxx=${kernel_tool_prefix}${CXX}
2329         fi
2330         AROS_BUILDCMD(aros_kernel_cxx,$aros_kernel_cxx,${kernel_tool_version})
2331         AROS_TOOL_KERNEL(aros_kernel_cxx,cxx,$aros_kernel_cxx)
2332         # If it's set, make sure it's really there
2333         if test "x$aros_kernel_cxx" != "x" ; then
2334             AROS_REQUIRED(cxx,$aros_kernel_cxx)
2335         fi
2336         if test "x$aros_kernel_ld" = "x"; then
2337             aros_kernel_ld=$aros_host_ld
2338         fi
2339         AROS_TOOL_KERNEL(aros_kernel_ld,ld,$aros_kernel_ld)
2340         AROS_REQUIRED(ld,$aros_kernel_ld)
2341         if test "x$aros_kernel_as" = "x"; then
2342             aros_kernel_as=$aros_host_as
2343             if test "x$aros_kernel_as" = "x"; then
2344                 aros_kernel_as=${HOST_TOOLCHAIN_PREFIX}as${HOST_TOOLCHAIN_SUFFIX}
2345             fi
2346         fi
2347         AROS_TOOL_KERNEL(aros_kernel_as,as,$aros_kernel_as)
2348         AROS_REQUIRED(as,$aros_kernel_as)
2349         if test "x$aros_kernel_ar" = "x"; then
2350             aros_kernel_ar=$aros_host_full_ar
2351         fi
2352         AROS_TOOL_KERNEL(aros_kernel_ar,ar,$aros_kernel_ar)
2353         AROS_REQUIRED(ar,$aros_kernel_ar)
2354         if test "x$aros_kernel_ranlib" = "x"; then
2355             aros_kernel_ranlib=$aros_host_ranlib
2356         fi
2357         AROS_TOOL_KERNEL(aros_kernel_ranlib,ranlib,$aros_kernel_ranlib)
2358         AROS_REQUIRED(ranlib,$aros_kernel_ranlib)
2359         if test "x$aros_kernel_nm" = "x"; then
2360             aros_kernel_nm=$aros_host_nm
2361             if test "x$aros_kernel_nm" = "x"; then
2362                 aros_kernel_nm=${HOST_TOOLCHAIN_PREFIX}nm${HOST_TOOLCHAIN_SUFFIX}
2363             fi
2364         fi
2365         AROS_TOOL_KERNEL(aros_kernel_nm,nm,$aros_kernel_nm)
2366         AROS_REQUIRED(nm,$aros_kernel_nm)
2367         AROS_TOOL_KERNEL(aros_kernel_strip,strip,$aros_kernel_strip)
2368         AROS_REQUIRED(strip,$aros_kernel_strip)
2370         # Objcopy and objdump are not required for the kernel
2371         # toolchain on many architectures.
2372         # So we'll look for them, but not make them strictly required.
2373         if test "x$aros_kernel_objcopy" = "x"; then
2374             aros_kernel_objcopy=$aros_host_objcopy
2375             if test "x$aros_kernel_objcopy" = "x"; then
2376                 aros_kernel_objcopy=${HOST_TOOLCHAIN_PREFIX}objcopy${HOST_TOOLCHAIN_SUFFIX}
2377             fi
2378         fi
2379         AROS_TOOL_KERNEL(aros_kernel_objcopy,objcopy,$aros_kernel_objcopy)
2380         if test "x$aros_kernel_objdump" = "x"; then
2381             aros_kernel_objdump=$aros_host_objdump
2382             if test "x$aros_kernel_objdump" = "x"; then
2383                 aros_kernel_objdump=${HOST_TOOLCHAIN_PREFIX}objdump${HOST_TOOLCHAIN_SUFFIX}
2384             fi
2385         fi
2386         AROS_TOOL_KERNEL(aros_kernel_objdump,objdump,$aros_kernel_objdump)
2387         if test "x${crosstools}" != "xyes" ; then
2388             AROS_REQUIRED(objcopy,$aros_kernel_objcopy)
2389             AROS_REQUIRED(objdump,$aros_kernel_objdump)
2390         fi
2391     fi
2394 AC_MSG_CHECKING([which target tools to use])
2395 if test "$aros_target_toolchain" = "yes"; then
2396     if test "$aros_toolchain" = "llvm" ; then
2397         msg_result="llvm"
2398     else
2399         msg_result=$target_tool_prefix
2400     fi
2401     AC_MSG_RESULT([$msg_result])
2402     # We are building AROS crosstools
2403     tmp_tool_prefix="$AROS_CROSSTOOLSDIR/${target_tool_prefix}"
2404     orig_target_cc="${tmp_tool_prefix}${toolchain_c_compiler}${target_tool_version}"
2405     orig_target_cxx="${tmp_tool_prefix}${toolchain_cxx_compiler}${target_tool_version}"
2406     orig_target_cpp="${tmp_tool_prefix}${toolchain_cpp_preprocessor}"
2407     orig_target_ld="${tmp_tool_prefix}${toolchain_ld}"
2408     orig_target_as="${tmp_tool_prefix}${toolchain_as}"
2409     orig_target_ar="${tmp_tool_prefix}${toolchain_ar}"
2410     orig_target_ranlib="${tmp_tool_prefix}${toolchain_ranlib}"
2411     orig_target_nm="${tmp_tool_prefix}${toolchain_nm}"
2412     orig_target_strip="${tmp_tool_prefix}${toolchain_strip}"
2413     orig_target_objcopy="${tmp_tool_prefix}${toolchain_objcopy}"
2414     orig_target_objdump="${tmp_tool_prefix}${toolchain_objdump}"
2415 else
2416     # Determine whether AROS or ELF tools should be used
2417     if test "$aros_tool_prefix" = "none"; then
2418         aros_tool_prefix="${elf_tool_prefix}"
2419     fi
2421     AC_MSG_RESULT([$aros_tool_prefix])
2422     # We are *not* building AROS crosstools - use the AROS or ELF tools
2423     AROS_TOOL_TARGET(orig_target_cpp,cpp,${aros_tool_prefix}${toolchain_cpp_preprocessor}${target_tool_version})
2424     AROS_REQUIRED(cpp,$orig_target_cpp)
2425     AROS_TOOL_TARGET(orig_target_cc,gcc,${aros_tool_prefix}${toolchain_c_compiler}${target_tool_version})
2426     AROS_REQUIRED(cc,$orig_target_cc)
2427     AROS_TOOL_TARGET(orig_target_cxx,g++,${aros_tool_prefix}${toolchain_cxx_compiler}${target_tool_version})
2428     AROS_REQUIRED(cxx,$orig_target_cxx)
2429     AROS_TOOL_TARGET(orig_target_ld,gcc,${aros_tool_prefix}${toolchain_ld})
2430     AROS_REQUIRED(ld,$orig_target_ld)
2431     AROS_TOOL_TARGET(orig_target_as,as,aros_tool_prefix}${toolchain_as})
2432     AROS_REQUIRED(as,$orig_target_as)
2433     AROS_TOOL_TARGET(orig_target_ar,ar,${aros_tool_prefix}${toolchain_ar})
2434     AROS_REQUIRED(ar,$orig_target_ar)
2435     AROS_TOOL_TARGET(orig_target_ranlib,ar,${aros_tool_prefix}${toolchain_ranlib})
2436     AROS_REQUIRED(ranlib,$orig_target_ranlib)
2437     AROS_TOOL_TARGET(orig_target_nm,nm,${aros_tool_prefix}${toolchain_nm})
2438     AROS_REQUIRED(nm,$orig_target_nm)
2439     AROS_TOOL_TARGET(orig_target_strip,strip,${aros_tool_prefix}${toolchain_strip})
2440     AROS_REQUIRED(strip,$orig_target_strip)
2441     AROS_TOOL_TARGET(orig_target_objcopy,objcopy,${aros_tool_prefix}${toolchain_objcopy})
2442     AROS_REQUIRED(objcopy,$orig_target_objcopy)
2443     AROS_TOOL_TARGET(orig_target_objdump,objdump,${aros_tool_prefix}${toolchain_objdump})
2444     AROS_REQUIRED(objdump,$orig_target_objdump)
2447 if test "$kernel_tool_prefix" = "none" ; then
2448     # No kernel tools specified
2449     # Assume target tools == kernel tools with ELF wrapper
2450     aros_kernel_cc=$orig_target_cc
2451     aros_kernel_cxx=$orig_target_cxx
2452     aros_kernel_cpp=$orig_target_cpp
2453     aros_kernel_ld=$orig_target_ld
2454     aros_kernel_as=$orig_target_as
2455     aros_kernel_ar=$orig_target_ar
2456     aros_kernel_ranlib=$orig_target_ranlib
2457     aros_kernel_nm=$orig_target_nm
2458     aros_kernel_strip=$orig_target_strip
2459     aros_kernel_objcopy=$orig_target_objcopy
2460     aros_kernel_objdump=$orig_target_objdump
2461     use_kernel_cc_wrapper=yes
2464 # At this point, all aros_kernel_* and aros_target_* 
2465 # tools should be set up correctly
2467 CC="$aros_kernel_cc $kernel_tool_flags"
2468 CPP="$aros_kernel_cpp"
2470 #-----------------------------------------------------------------------------
2472 # Find all the tools we need to compile. This could be cross-compiling
2473 # though! If that is the case we use the GNU form of the target and
2474 # simply add this to the front of the binary name. This is rather simple,
2475 # but it should work under most circumstances.
2477 # The default tools are to use the same as the host, but only if the
2478 # host and target CPU are the same. With GCC this is normally enough.
2481 aros_cc_pre=""
2482 aros_shared_ld="$aros_host_ld"
2484 aros_target_mkdep="$aros_host_mkdep"
2486 # The default tools executables to be linked to.
2487 if test "$rescomp" != ""; then
2488     AC_PATH_PROG(aros_kernel_rescomp,${kernel_tool_prefix}$rescomp)
2489     AROS_REQUIRED($rescomp,$aros_kernel_rescomp)
2492 # Set up the sources for the symlink farm
2493 if test "$crosstools" = "yes"; then
2494     crosstools_target=tools-crosstools
2497 aros_kernel_cc="$aros_kernel_cc $kernel_tool_flags"
2498 aros_kernel_ar="$aros_kernel_ar $aros_kernel_ar_flags"
2500 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/host/config"
2501 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
2502 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Developer/include/aros"
2503 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
2504 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
2505 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
2506 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
2508 # aros_cc_pre is a variable that is added to the front of the compiler name
2509 # in the generated aros-gcc shell script. We need this to enable the cache
2510 # to work across cleaned builds. Also, support DISTCC using the correct
2511 # environment variable.
2514 if test "x${DISTCC}" != "x" ; then
2515     if test "x${CCACHE}" != "x" ; then
2516         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
2517     else
2518         aros_cc_pre="${DISTCC} "
2519     fi
2520 else
2521     if test "x${CCACHE}" != "x" ; then
2522         aros_cc_pre="${CCACHE} "
2523     fi
2526 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
2527 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
2528 AC_SUBST(aros_target_nix_ldflags,-nix)
2529 AC_SUBST(aros_target_detach_ldflags,-detach)
2530 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
2532 aros_target_cc_path=
2534 # Target tools
2535 AC_SUBST(aros_toolchain)
2536 if test "$aros_target_toolchain" != "yes"; then
2537     prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-"
2538     if test "$GCC" = "yes"; then
2539         aros_target_cc_path=`$orig_target_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
2540     fi
2541 else
2542     # We do not know which c compiler version we are going to build and what we need to know
2543     # here is different for different versions so this will be set later during the
2544     # build of crosstools.
2545     if test "$aros_toolchain" = "gnu" ; then
2546         prefix="$AROS_CROSSTOOLSDIR/${aros_target_cpu}-aros-"
2547     elif test "$aros_toolchain" = "llvm" ; then
2548         prefix="$AROS_CROSSTOOLSDIR/bin/"
2549     fi
2550     aros_target_cc_path=@aros_target_cc_path@
2552 aros_target_cpp="${prefix}${toolchain_cpp_preprocessor}"
2553 aros_target_cc="${prefix}${toolchain_c_compiler}"
2554 aros_target_cxx="${prefix}${toolchain_cxx_compiler}"
2555 aros_target_as="${prefix}${toolchain_as}"
2556 if test "${use_ld_wrapper}" = "yes"; then
2557     aros_target_ld="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}"
2558 else
2559     aros_target_ld="${prefix}${toolchain_ld}"
2561 aros_toolchain_ld="${prefix}${toolchain_ld}"
2563 aros_target_ar="${prefix}${toolchain_ar} $aros_target_ar_flags"
2564 aros_target_objcopy="${prefix}${toolchain_objcopy}"
2565 aros_target_objdump="${prefix}${toolchain_objdump}"
2566 aros_target_ranlib="${prefix}${toolchain_ranlib} $aros_target_ranlib_flags"
2567 aros_target_nm="${prefix}${toolchain_nm} $aros_target_nm_flags"
2568 aros_target_strip="${prefix}${toolchain_strip}"
2569 aros_plain_nm="${prefix}${toolchain_nm}"
2570 aros_plain_ar="${prefix}${toolchain_ar}"
2572 AC_ARG_ENABLE(includes,
2573 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
2574 [aros_target_incl=$enable_includes], [aros_target_incl=no])
2576 if test "x$aros_target_incl" = "xno"; then
2577     if test "x$test_kernel_cc" != "xno"; then
2578         aros_target_incl=`$aros_kernel_cc -print-sysroot 2>/dev/null`/`$aros_kernel_cc --print-sysroot-headers-suffix 2>/dev/null || echo usr/include`
2579     else
2580         aros_target_incl=
2581     fi
2584 if test "x$aros_kernel_includes" = "x"; then
2585     if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2586         if test "x$aros_target_incl" != "x"; then
2587             aros_kernel_includes="-isystem $aros_target_incl"
2588         fi
2589     fi
2592 if test "x$test_kernel_cc" != "xno"; then
2593     if test "$aros_kernel_includes" != "" ; then
2594         dnl find out about the kernel cc's include path
2595         AC_MSG_CHECKING([for the kernel compiler's include path])
2596         if test "$aros_kernel_cc_includes" = "" ; then
2597             # Try to guess where the directory is.
2598             aros_kernel_cc_includes=`dirname \`${aros_kernel_cc} ${aros_kernel_cflags} -print-libgcc-file-name\``/include
2599             if test -d $aros_kernel_cc_includes; then
2600                 # Check if there is also an include-fixed directory and add it
2601                 # to kernel compiler's include path as it may contain some of
2602                 # the headers we need.
2603                 if test -d "$aros_kernel_cc_includes"-fixed; then
2604                     aros_kernel_cc_includes+=" -isystem $aros_kernel_cc_includes"-fixed
2605                 fi
2606                 # Check for specific includes directory. Needed for Ubuntu 11.10 and Debian
2607                 if test -d "/usr/include/${aros_target_cpu}-linux-gnu"; then
2608                     aros_kernel_cc_includes+=" -isystem /usr/include/${aros_target_cpu}-linux-gnu"
2609                 fi
2610             else
2611                 # The directory doesn't exist, we need to do some more work.
2612                 aros_kernel_cc_includes=${PWD}/${aros_gendir}/cc_include
2614                 # These are the headers we're looking for.
2615                 headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2616                          stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2617                          zutil.h stdint.h"
2619                 dirs=
2620                 for h in $headers; do
2621                     # Which other headers are needed by each of the above?
2622                     deps=$(echo "#include <$h>" | \
2623                            $aros_kernel_cc -E -M - 2>/dev/null | \
2624                            sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2626                     # Copy all the needed headers to a directory beneath gendir.
2627                     for d in $deps; do
2628                         h=$(basename $d)
2629                         dir=${aros_kernel_cc_includes}$(echo $(dirname $d) | \
2630                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2631                         ! test -d $dir && mkdir -p $dir
2632                         ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2633                     done
2634                 done            
2635             fi
2636         fi
2637         AC_MSG_RESULT($aros_kernel_cc_includes)
2638         # Adding -nostdinc to kernel includes as they are always used together.
2639         aros_kernel_includes="$aros_kernel_includes $aros_target_nostdinc_cflags -isystem $aros_kernel_cc_includes"
2640     fi
2643 if test "$crosstools" != "yes"; then
2644     dnl find out about the target cc's include path
2645     AC_MSG_CHECKING([for the target compiler's include path])
2646     if test "$aros_target_cc_includes" = "" ; then
2647         #try to guess where the directory is
2648         aros_target_cc_includes=`dirname \`${orig_target_cc} -print-libgcc-file-name\``/include
2649         if ! test -d $aros_target_cc_includes; then
2650             #the directory doesn't exist, we need to do some more work
2651             aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
2652         
2653             #these are the headers we're looking for
2654             headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
2655                     stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
2656                     zutil.h"
2658             dirs=
2659             for h in $headers; do
2660                 #which other headers each of the above headers needs?
2661                 deps=$(echo "#include <$h>" | \
2662                     $orig_target_cc -E -M - 2>/dev/null | \
2663                     sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
2664             
2665                 #copy all the needed headers to a directory beneath gendir
2666                 for d in $deps; do
2667                     h=$(basename $d)
2668                     dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
2669                                                 sed -n "s,^.*/include\(/.*\),\1,p")
2670                     ! test -d $dir && mkdir -p $dir
2671                     ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
2672                 done
2673             done
2674         fi
2675     fi
2676     AC_MSG_RESULT($aros_target_cc_includes)
2677 else
2678     # We do not know which c compiler version we are going to build and what we need to know
2679     # here is different for different versions so this will be set later during the
2680     # build of crosstools.
2681     aros_target_cc_includes=@aros_target_cc_includes@
2685 # For GCC < 4.0 -I- is used for giving the search path for '#include "..."'
2686 # On GCC >= 4.0 -iquote should be used
2689 save_cc="$CC"
2690 save_cflags="$CFLAGS"
2691 if test "x$test_kernel_cc" != "xno"; then
2692     CFLAGS="-iquote."
2693     kernel_cflags_iquote=$host_cflags_iquote
2694     kernel_cflags_iquote_end=$host_cflags_iquote_end
2695     if test "x-$cross_compiling" = "x-yes"; then
2696         CC="$aros_kernel_cc"
2697         AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
2698         if test "x-$crosstools" != "x-yes"; then
2699             AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
2700         else
2701             # we do know it is supported for the smallest version of gcc we are going to build
2702             # we assume it's also supported by later versions
2703             use_no_stack_protector=yes
2704         fi
2705         AC_MSG_RESULT($use_no_stack_protector)
2706         AC_MSG_CHECKING([whether ${CC} accepts -iquote])
2707         if test "x-$crosstools" != "x-yes"; then
2708             AC_TRY_COMPILE(,, has_iquote="yes", has_iquote="no")
2709         else
2710             # we do know it is supported for the smallest version of gcc we are going to build
2711             # we assume it's also supported by later versions
2712             has_iquote=yes
2713         fi
2714         AC_MSG_RESULT($has_iquote)
2715         if test "x-$has_iquote" = "x-yes" ; then
2716             kernel_cflags_iquote=-iquote
2717             kernel_cflags_iquote_end=
2718         else
2719             kernel_cflags_iquote=-I
2720             kernel_cflags_iquote_end=-I-
2721         fi
2722     fi
2723     if test "x-$use_no_stack_protector" = "x-yes" ; then
2724         aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector"
2725     fi
2727     #-----------------------------------------------------------------------------
2729     # Check if we can explicitly choose older version of symbol hashing
2731     CFLAGS="save_cflags -Wl,--hash-style=sysv"
2732     CC="$aros_kernel_cc"
2733     AC_MSG_CHECKING([whether ${CC} accepts -Wl,--hash-style=sysv])
2734     AC_TRY_LINK(,, use_hash_style="yes", use_hash_style="no")
2735     AC_MSG_RESULT($use_hash_style)
2736     if test "x-$use_hash_style" = "x-yes" ; then
2737         aros_kernel_cflags="$aros_kernel_cflags -Wl,--hash-style=sysv"
2738     fi
2739 else
2740     kernel_cflags_iquote="$""(CFLAGS_IQUOTE)"
2741     kernel_cflags_iquote_end="$""(CFLAGS_IQUOTE_END)"
2743 CC="$save_cc"
2744 CFLAGS="$save_cflags"
2746 AC_SUBST(host_cflags_iquote)
2747 AC_SUBST(host_cflags_iquote_end)
2748 AC_SUBST(kernel_cflags_iquote)
2749 AC_SUBST(kernel_cflags_iquote_end)
2752 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
2753 AC_MSG_CHECKING([for default resolution of WBScreen])
2754 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
2755 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
2756 if test "$resolution" = "yes" ; then
2757     resolution="none"
2759 if test "$resolution" = "no" ; then
2760     resolution="none"
2762 if test "$resolution" != "none" ; then
2763     aros_nominal_width=`echo $resolution | cut -d'x' -f1`
2764     aros_nominal_height=`echo $resolution | cut -d'x' -f2`
2765     aros_nominal_depth=`echo $resolution | cut -d'x' -f3`
2767 AC_MSG_RESULT($aros_nominal_width x $aros_nominal_height x $aros_nominal_depth)
2768 aros_cv_nominal_width=$aros_nominal_width
2769 aros_cv_nominal_height=$aros_nominal_height
2770 aros_cv_nominal_depth=$aros_nominal_depth
2772 dnl See if the user wants the serial debug output for native flavour
2773 AC_MSG_CHECKING([whether serial debug is enabled])
2774 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)
2775 if test "$aros_serial_debug" = 0 ; then
2776     serial_debug_forced=""
2777     if test "$serial_debug" = "yes" ; then
2778         serial_debug="1"
2779     fi
2780     if test "$serial_debug" = "no" ; then
2781         serial_debug="none"
2782     fi
2783 else
2784     serial_debug_forced="(forced)"
2785     serial_debug=$aros_serial_debug
2787 if test "$serial_debug" != "none" ; then
2788     aros_serial_debug=$serial_debug
2789     AC_MSG_RESULT($serial_debug_forced on port $serial_debug)
2790 else
2791     AC_MSG_RESULT(no)
2794 dnl See if the user wants the palm debug output hack for palm native flavour
2795 AC_MSG_CHECKING([whether palm debug hack is enabled])
2796 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")
2797 if test "$palm_debug_hack" = "yes" ; then
2798     aros_palm_debug_hack="1"
2800 AC_MSG_RESULT($palm_debug_hack)
2802 dnl See if dev wants the usb3.0 code
2803 AC_MSG_CHECKING([whether usb3.0 code is enabled])
2804 AC_ARG_ENABLE(usb30_code,AC_HELP_STRING([--enable-usb30-code],[Enable usb3.0 code (default=no)]),usb30_code="yes",usb30_code="no")
2805 if test "$usb30_code" = "yes" ; then
2806     aros_config_cppflags="$aros_config_cppflags -DAROS_USB30_CODE"
2807     aros_kernel_cflags="$aros_kernel_cflags -DAROS_USB30_CODE"
2809 AC_MSG_RESULT($usb30_code)
2811 dnl See if the user wants nesting supervisor activated for unix flavour
2812 AC_MSG_CHECKING([whether nesting supervisor support is enabled])
2813 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")
2814 if test "$nesting_supervisor" = "yes" ; then
2815     aros_nesting_supervisor="1"
2817 AC_MSG_RESULT($nesting_supervisor)
2819 dnl See if the user wants to disable MMU support
2820 dnl This can be overriden on per-target basis,
2821 dnl set $aros_enable_mmu to "yes" or "no" to do this
2822 if test "$aros_enable_mmu" = "" ; then
2823     AC_MSG_CHECKING([whether MMU support is enabled])
2824     dnl Enabled by default
2825     AC_ARG_ENABLE(mmu,AC_HELP_STRING([--disable-mmu],[Disable MMU support (default=enabled)]),aros_enable_mmu=$enableval,aros_enable_mmu="yes")
2826     if test "$aros_enable_mmu" = "" ; then
2827         aros_enable_mmu="yes"
2828     fi
2829     AC_MSG_RESULT($aros_enable_mmu)
2831 if test "$aros_enable_mmu" = "no" ; then
2832     aros_enable_mmu="0"
2833 else
2834     aros_enable_mmu="1"
2836     
2838 dnl things specifically required for hosted flavours
2839 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
2841     if test "x-$need_dlopen" != "x-no" ; then
2842       save_libs="$LIBS"
2843       LIBS=""
2844       dnl some kind of dynamic library access system is required for hostlib.resource
2845       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
2846       if test "x-$have_dl" = "x-no" ; then
2847           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
2848                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
2849                                     have_dl="no")
2850       fi
2851       if test "x-$have_dl" = "x-no" ; then
2852           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
2853       fi
2854       LIBS="$save_libs"
2855     fi
2858     dnl x11 hidd
2859     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
2860                                            [build X11 hidd for hosted (default=auto)]),
2861                                            x11_hidd="$enableval",
2862                                            x11_hidd="$need_x11")
2863     case "x-$x11_hidd" in
2864         x-yes|x-no|x-auto)                 ;;
2865         *)                 x11_hidd="$need_x11" ;;
2866     esac
2868     ENABLE_X11=0
2870     dnl they want it
2871     if test "x-$x11_hidd" != "x-no" ; then
2873         dnl find x11 stuff
2874         AC_PATH_X
2876         if test -n "$x_includes"; then
2877             X_CFLAGS="$X_CFLAGS -I$x_includes"
2878         fi
2880         if test -n "$x_libraries"; then
2881             X_LIBS="$X_LIBS -L$x_libraries"
2882         fi
2884         if test "x-$no_x" = "x-yes" ; then
2886             dnl didn't find it
2887             if test "x-$x11_hidd" != "x-auto" ; then
2888                 dnl and they explicitly asked for it, bail out
2889                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
2890             fi
2891         
2892         else
2893             dnl found it, setup the metatarget
2894             aros_target_options+="$export_newline""# Enable X11 Gfx Driver$export_newline""OPT_HOST_X11GFX               := yes$export_newline"
2895             if test "x-$host_feature_glx" != "x-no" ; then
2896                 aros_target_options+="$export_newline""# Enable X11 HostGL 3D Passthrough$export_newline""OPT_HOST_X11_HOSTGL           := yes$export_newline"
2897             fi
2898             ENABLE_X11=1
2900             aros_host_x11_cflags="$X_CFLAGS"
2901             aros_host_x11_ldflags="$X_LIBS  -lX11"
2903             dnl setup shared memory extensions
2904             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
2905                                                   [use X11 shared memory (default=auto)]),
2906                                                   x11_hidd_shm="$enableval",
2907                                                   x11_hidd_shm="auto")
2908             case "x-$x11_hidd_shm" in
2909                 x-yes|x-no|x-auto)                     ;;
2910                 *)                 x11_hidd_shm="auto" ;;
2911             esac
2913             have_xshm=no
2915             dnl they want it
2916             if test "x-$x11_hidd_shm" != "x-no" ; then
2918                 dnl system shm headers
2919                 AC_CHECK_HEADERS(sys/ipc.h)
2920                 AC_CHECK_HEADERS(sys/shm.h)
2922                 dnl got them
2923                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
2925                     dnl make sure X libs have shm functions
2926                     save_cflags="$CFLAGS"
2927                     save_ldflags="$LDFLAGS"
2928                     CFLAGS="$CFLAGS $X_CFLAGS"
2929                     LDFLAGS="$LDFLAGS $X_LIBS"
2930                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
2931                     CFLAGS="$save_cflags"
2932                     LDFLAGS="$save_ldflags"
2933                 fi
2934             fi
2936             dnl detection done, prepare output
2937             if test "x-$have_xshm" = "x-yes" ; then
2938                 dnl we can do shm
2939                 DO_XSHM_SUPPORT="1"
2940             elif test "x-$x11_hidd_shm" = "x-yes" ; then
2941                 dnl they explicitly asked for it, but we can't do it
2942                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
2943             else
2944                 dnl otherwise just disable it
2945                 DO_XSHM_SUPPORT="0"
2946             fi
2948             
2949             dnl setup vidmode (fullscreen) extensions
2950             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
2951                                                       [use X11 vidmode extension (default=auto)]),
2952                                                       x11_hidd_vidmode="$enableval",
2953                                                       x11_hidd_vidmode="auto")
2954             case "x-$x11_hidd_vidmode" in
2955                 x-yes|x-no|x-auto)                         ;;
2956                 *)                 x11_hidd_vidmode="auto" ;;
2957             esac
2959             have_vidmode=no
2961             dnl they want it
2962             if test "x-$x11_hidd_vidmode" != "x-no" ; then
2964                 dnl make sure X libs have vidmode functions
2965                 save_cflags="$CFLAGS"
2966                 save_ldflags="$LDFLAGS"
2967                 CFLAGS="$CFLAGS $X_CFLAGS"
2968                 LDFLAGS="$LDFLAGS $X_LIBS"
2969                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
2970                 CFLAGS="$save_cflags"
2971                 LDFLAGS="$save_ldflags"
2972             fi
2974             dnl detection done, prepare output
2975             if test "x-$have_vidmode" = "x-yes" ; then
2976                 dnl we can do vidmode
2977                 DO_VIDMODE_SUPPORT="1"
2978             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
2979                 dnl they explicitly asked for it, but we can't do it
2980                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
2981             else
2982                 dnl otherwise just disable it
2983                 DO_VIDMODE_SUPPORT="0"
2984             fi
2985         fi
2986     fi
2988     dnl sdl hidd
2989     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
2990                                            [build SDL hidd for hosted (default=auto)]),
2991                                            sdl_hidd="$enableval",
2992                                            sdl_hidd="auto")
2993     case "x-$sdl_hidd" in
2994         x-yes|x-no|x-auto)                 ;;
2995         *)                 sdl_hidd="auto" ;;
2996     esac
2998     dnl they want it
2999     if test "x-$sdl_hidd" != "x-no" ; then
3001         dnl find sdl
3002         SDL_VERSION=1.2.5
3003         AM_PATH_SDL($SDL_VERSION, [have_sdl="yes"],
3004             [have_sdl="no"])
3006         if test "x-$have_sdl" != "x-yes" ; then
3008             dnl didn't find it
3009             if test "x-$sdl_hidd" != "x-auto" ; then
3010                 dnl and they explicitly asked for it, bail out
3011                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
3012             fi
3014         else
3015             dnl found it, enable the build
3016             aros_target_options+="$export_newline""# Enable SDL Gfx Driver$export_newline""OPT_HOST_SDLGFX               := yes$export_newline"
3017             aros_host_sdl_cflags=$SDL_CFLAGS
3018             aros_host_sdl_libs=$SDL_LIBS
3019         fi
3020     fi
3025 dnl See if the user wants dbus.library
3026 AC_MSG_CHECKING([whether building of dbus.library is enabled])
3027 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
3028 if test "$dbus" = "yes" ; then
3029     ENABLE_DBUS=1
3030     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
3031     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
3032     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
3033     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
3034 else
3035     ENABLE_DBUS=0
3037 AC_MSG_RESULT($dbus)
3039 if test "$use_kernel_cc_wrapper" = "yes" ; then
3040     aros_kernel_cc="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-${toolchain_c_compiler}"
3043 aros_kernel_cppflags=$aros_config_cppflags
3044 aros_optimization_cflags="$optimization_level"
3045 if test "$optimization" = "default"; then
3046 AC_MSG_CHECKING([default optimization level to use])
3047 AC_MSG_RESULT($optimization_level)
3050 if ! test "$gcc_default_cpu" = "" ; then
3051     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"
3054 if test "$use_libatomic" = "yes" ; then
3055     aros_cxx_libs="$aros_cxx_libs  -latomic"
3058 dnl --------------------------------------------------------------------
3059 dnl Configuration Output Section
3060 dnl --------------------------------------------------------------------
3062 # Generic
3063 AC_SUBST(aros_arch)
3064 AC_SUBST(aros_cpu)
3065 AC_SUBST(aros_flavour)
3066 AC_SUBST(aros_flavour_uc)
3067 AC_SUBST(aros_target_toolchain)
3068 AC_SUBST(aros_toolchain_ld)
3069 AC_SUBST(aros_build_host)
3070 AC_SUBST(AROS_BUILDDIR)
3071 AC_SUBST(AROS_BUILDDIR_UNIX)
3072 AC_SUBST(SRCDIR)
3073 AC_SUBST(AROS_CROSSTOOLSDIR)
3074 AC_SUBST(AROS_PORTSSRCDIR)
3076 # Compatability with other Amiga-like operating systems
3077 AC_SUBST(aros_amigaos_compliance)
3079 # Host Related ###########################
3080 AC_SUBST(host_stat_h__unused_used)
3081 AC_SUBST(ax_cv_flex_version)
3082 AC_SUBST(host_extra_cfg)
3083 AC_SUBST(aros_cc_pre)
3084 AC_SUBST(aros_host_strip)
3085 AC_SUBST(aros_host_arch)
3086 AC_SUBST(aros_host_cpu)
3087 AC_SUBST(aros_host_cpp)
3088 AC_SUBST(aros_host_def_cc)
3089 AC_SUBST(aros_host_cc)
3090 AC_SUBST(aros_host_cxx)
3091 AC_SUBST(aros_host_ar)
3092 AC_SUBST(aros_host_ranlib)
3093 AC_SUBST(aros_host_ld)
3094 AC_SUBST(aros_host_make)
3095 AC_SUBST(aros_host_cppflags)
3096 AC_SUBST(aros_host_cflags)
3097 AC_SUBST(aros_host_cxxflags)
3098 AC_SUBST(gnu89_inline)
3099 AC_SUBST(aros_host_ldflags)
3100 AC_SUBST(aros_host_debug)
3101 AC_SUBST(aros_host_mkdep)
3102 AC_SUBST(aros_host_mkargs)
3103 AC_SUBST(aros_host_exe_suffix)
3104 AC_SUBST(aros_host_lib_suffix)
3105 AC_SUBST(aros_tools_dir)
3106 AC_SUBST(aros_host_aclocal)
3107 AC_SUBST(aros_host_autoconf)
3108 AC_SUBST(aros_host_autoheader)
3109 AC_SUBST(aros_host_automake)
3111 # Target Related #########################
3112 AC_SUBST(aros_elf_translate)
3113 AC_SUBST(make_extra_commands)
3114 AC_SUBST(make_extra_targetcfg)
3115 AC_SUBST(target_extra_cfg)
3116 AC_SUBST(aros_target_options)
3118 AC_SUBST(aros_target_guitheme)
3119 AC_SUBST(aros_target_iconset)
3120 AC_SUBST(aros_target_bootloader)
3121 AC_SUBST(aros_target_arch)
3122 AC_SUBST(aros_target_family)
3123 AC_SUBST(aros_target_cpu)
3124 AC_SUBST(aros_target_cpu_mode)
3125 AC_SUBST(aros_target_variant)
3126 AC_SUBST(aros_target_suffix)
3127 AC_SUBST(aros_target_ar)
3128 AC_SUBST(aros_target_ranlib)
3129 AC_SUBST(aros_plain_nm)
3130 AC_SUBST(aros_plain_ar)
3131 AC_SUBST(aros_kernel_ar)
3132 AC_SUBST(aros_kernel_ranlib)
3133 AC_SUBST(orig_target_cc)
3134 AC_SUBST(aros_target_cc)
3135 AC_SUBST(aros_kernel_cc)
3136 AC_SUBST(orig_target_cxx)
3137 AC_SUBST(aros_target_cxx)
3138 AC_SUBST(aros_kernel_cxx)
3139 AC_SUBST(orig_target_cpp)
3140 AC_SUBST(aros_target_cpp)
3141 AC_SUBST(aros_kernel_cpp)
3142 AC_SUBST(orig_target_as)
3143 AC_SUBST(aros_target_as)
3144 AC_SUBST(aros_kernel_as)
3145 AC_SUBST(orig_target_ld)
3146 AC_SUBST(aros_target_ld)
3147 AC_SUBST(aros_kernel_ld)
3148 AC_SUBST(aros_target_cc_includes)
3149 AC_SUBST(aros_target_cc_path)
3150 AC_SUBST(aros_target_objdump)
3151 AC_SUBST(aros_target_objcopy)
3152 AC_SUBST(aros_target_strip)
3153 AC_SUBST(aros_target_nm)
3154 AC_SUBST(aros_kernel_rescomp)
3155 AC_SUBST(aros_shared_default)
3156 AC_SUBST(aros_shared_ld)
3157 AC_SUBST(aros_object_format)
3158 AC_SUBST(spec_obj_format)
3159 AC_SUBST(aros_c_libs)
3160 AC_SUBST(aros_cxx_libs)
3162 AC_SUBST(aros_shared_cflags)
3163 AC_SUBST(aros_shared_aflags)
3164 AC_SUBST(aros_shared_ldflags)
3166 AC_SUBST(aros_warn_flags)
3167 AC_SUBST(aros_nowarn_flags)
3168 AC_SUBST(aros_config_cppflags)
3169 AC_SUBST(aros_config_cflags)
3170 AC_SUBST(aros_config_cxxflags)
3171 AC_SUBST(aros_config_aflags)
3172 AC_SUBST(aros_config_ldflags)
3174 AC_SUBST(aros_kernel_sysroot)
3175 AC_SUBST(aros_kernel_cppflags)
3176 AC_SUBST(aros_kernel_cflags)
3177 AC_SUBST(aros_kernel_includes)
3178 AC_SUBST(aros_kernel_objcflags)
3179 AC_SUBST(aros_kernel_ldflags)
3180 AC_SUBST(aros_debug_cppflags)
3181 AC_SUBST(aros_debug_cflags)
3182 AC_SUBST(aros_debug_cxxflags)
3183 AC_SUBST(aros_debug_aflags)
3184 AC_SUBST(aros_debug_ldflags)
3185 AC_SUBST(aros_target_genmap)
3186 AC_SUBST(aros_target_strip_flags)
3187 AC_SUBST(aros_config_lto)
3188 AC_SUBST(aros_config_coverage)
3189 AC_SUBST(aros_optimization_cflags)
3190 AC_SUBST(aros_isa_extra)
3191 AC_SUBST(aros_isa_flags)
3193 AC_SUBST(crosstools_target)
3194 AC_SUBST(crosstools_cxx_target)
3196 AC_SUBST(use_libatomic)
3198 AC_SUBST(pci_hidd_target)
3200 AC_SUBST(aros_nominal_width)
3201 AC_SUBST(aros_nominal_height)
3202 AC_SUBST(aros_nominal_depth)
3204 # Native version related
3205 AC_SUBST(aros_serial_debug)
3206 AC_SUBST(PLATFORM_EXECSMP)
3207 AC_SUBST(ENABLE_EXECSMP)
3209 # MMU related
3210 AC_SUBST(aros_enable_mmu)
3212 # Bootloader related
3213 AC_SUBST(target_grub2_version)
3215 # Unix/Hosted version related
3216 AC_SUBST(aros_nesting_supervisor)
3218 # ARM default GCC target related
3219 AC_SUBST(gcc_default_cpu)
3220 AC_SUBST(gcc_default_cpu_tune)
3221 AC_SUBST(gcc_default_fpu)
3222 AC_SUBST(gcc_default_float_abi)
3223 AC_SUBST(gcc_default_mode)
3225 # Palm native version related
3226 AC_SUBST(aros_palm_debug_hack)
3228 # Apple iOS related
3229 AC_SUBST(aros_ios_platform)
3230 AC_SUBST(aros_ios_version)
3231 AC_SUBST(aros_ios_sdk)
3233 # Android related
3234 AC_SUBST(ant)
3235 AC_SUBST(android_tool)
3236 AC_SUBST(aros_android_level)
3237 AC_SUBST(aros_android_antapk)
3239 # Debug related
3240 AC_SUBST(aros_debug)
3241 AC_SUBST(aros_mungwall_debug)
3242 AC_SUBST(aros_stack_debug)
3243 AC_SUBST(aros_modules_debug)
3245 # Collect-aros stuff: "-ius" to ignore undefined symbols
3246 AC_SUBST(ignore_undefined_symbols)
3248 # C compiler related
3249 AC_SUBST(gcc_target_cpu)
3250 AC_SUBST(target_binutils_version)
3251 AC_SUBST(target_gcc_version)
3253 #ObjC compiler related
3254 AC_SUBST(objc_target)
3256 #Java related
3257 AC_SUBST(java_target)
3259 # DBUS related
3260 AC_SUBST(ENABLE_DBUS)
3261 AC_SUBST(DBUS_CFLAGS)
3262 AC_SUBST(DBUS_LIBFLAGS)
3263 AC_SUBST(KERNEL_DBUS_KOBJ)
3264 AC_SUBST(KERNEL_DBUS_INCLUDES)
3266 #X11 related
3267 AC_SUBST(ENABLE_X11)
3268 AC_SUBST(DO_XSHM_SUPPORT)
3269 AC_SUBST(DO_VIDMODE_SUPPORT)
3271 AC_SUBST(aros_host_x11_cflags)
3272 AC_SUBST(aros_host_x11_ldflags)
3274 #X11 related
3275 AC_SUBST(aros_host_sdl_cflags)
3276 AC_SUBST(aros_host_sdl_libs)
3278 # USB3.0 code
3279 AC_SUBST(aros_usb30_code)
3281 dnl Prepare for output, make up all the generated patches
3282 case "$aros_flavour" in
3283 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
3284                 aros_flavour="emulation" ;;
3285 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
3286                 aros_flavour="emulation" ;;
3287 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
3288                 aros_flavour="standalone";;
3289 standcompat)    aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3290                 aros_flavour="standalone";;
3291 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
3292                 aros_flavour="native" ;;
3293 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
3294                 aros_flavour="native" ;;
3295 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
3296                 aros_flavour="linklib" ;;
3297 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3298                 aros_flavour="palmnative" ;;
3299 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
3300                 aros_flavour="mac68knative" ;;
3301 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
3302                 aros_flavour="ppcnative" ;;
3303 esac
3305 if test ! -d ${aros_inc_dir} ; then
3306     ${MKDIR} ${aros_inc_dir}
3308 if test ! -d ${aros_geninc_dir} ; then
3309     ${MKDIR} ${aros_geninc_dir}
3311 if test ! -d ${aros_hostcfg_dir} ; then
3312     ${MKDIR} ${aros_hostcfg_dir}
3314 if test ! -d ${aros_targetcfg_dir} ; then
3315     ${MKDIR} ${aros_targetcfg_dir}
3317 if test ! -d ${aros_tools_dir} ; then
3318     ${MKDIR} ${aros_tools_dir}
3320 if test ! -d ${aros_scripts_dir} ; then
3321     ${MKDIR} ${aros_scripts_dir}
3324 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
3326 # Generic build tools (metamake, etc)
3327 AC_CONFIG_COMMANDS([genmf-executable-support],
3328     [
3329         chmod a+x ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname
3330         chmod a+x ${aros_tools_dir}/genmf.py
3331     ],
3332     [
3333         AROS_CROSSTOOLSDIR=${AROS_CROSSTOOLSDIR}
3334         aros_tools_dir=${aros_tools_dir}
3335     ]
3337 AC_CONFIG_FILES(
3338     Makefile
3339     config/make.cfg
3340     ${aros_inc_dir}/config.h:config/config.h.in
3341     ${aros_geninc_dir}/config.h:config/config.h.in
3342     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
3343     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
3344     ${aros_targetcfg_dir}/build.cfg:config/build.cfg.in
3345     mmake.config
3346     compiler/include/geninc.cfg:compiler/include/geninc.cfg.in
3347     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
3348     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
3349     ${AROS_CROSSTOOLSDIR}/${aros_target_cpu}-aros-uname:scripts/uname.in
3350     tools/collect-aros/env.h
3353 # Binutils
3354 AC_CONFIG_COMMANDS([binutils-support],
3355     [
3356         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3357         mkdir -p $prefix
3358         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3360         chmod a+x ${prefix2}-ld
3362         ln -sf $orig_target_as$aros_host_exe_suffix      ${prefix2}-as$aros_host_exe_suffix
3363         ln -sf $orig_target_nm$aros_host_exe_suffix      ${prefix2}-nm$aros_host_exe_suffix
3364         ln -sf $orig_target_ar$aros_host_exe_suffix      ${prefix2}-ar$aros_host_exe_suffix
3365         ln -sf $orig_target_ranlib$aros_host_exe_suffix  ${prefix2}-ranlib$aros_host_exe_suffix
3366         ln -sf $orig_target_objcopy$aros_host_exe_suffix ${prefix2}-objcopy$aros_host_exe_suffix
3367         ln -sf $orig_target_objdump$aros_host_exe_suffix ${prefix2}-objdump$aros_host_exe_suffix
3368         ln -sf $orig_target_strip$aros_host_exe_suffix   ${prefix2}-strip$aros_host_exe_suffix
3369     ],
3370     [
3371         aros_host_exe_suffix=${aros_host_exe_suffix}
3372         aros_tools_dir=${aros_tools_dir}
3373         aros_target_cpu=${aros_target_cpu}
3374         aros_target_arch=${aros_target_arch}
3375         aros_target_suffix=${aros_target_suffix}
3376         orig_target_nm=${orig_target_nm}
3377         orig_target_as=${orig_target_as}
3378         orig_target_ar=${orig_target_ar}
3379         orig_target_ranlib=${orig_target_ranlib}
3380         orig_target_objdump=${orig_target_objdump}
3381         orig_target_objcopy=${orig_target_objcopy}
3382         orig_target_strip=${orig_target_strip}
3383         aros_kernel_ld=${aros_kernel_ld}
3384     ]
3386 if test "${use_ld_wrapper}" = "yes"; then
3387     AC_CONFIG_FILES(
3388         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${aros_ld}:scripts/aros-ld.in
3389     )
3391 # Bare Elf support script and spec
3392 if test "${use_kernel_cc_wrapper}" = "yes"; then
3393     AC_CONFIG_COMMANDS([elf-compiler-support],
3394         [
3395             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3396             mkdir -p $prefix
3397             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf
3399             chmod a+x ${prefix2}-gcc
3401             ln -sf $aros_kernel_ld$aros_host_exe_suffix         ${prefix2}-ld$aros_host_exe_suffix
3402         ],
3403         [
3404             aros_host_exe_suffix=${aros_host_exe_suffix}
3405             aros_tools_dir=${aros_tools_dir}
3406             aros_target_cpu=${aros_target_cpu}
3407             aros_target_arch=${aros_target_arch}
3408             aros_target_suffix=${aros_target_suffix}
3409             aros_kernel_ld=${aros_kernel_ld}
3410         ]
3411     )
3412     AC_CONFIG_FILES(
3413         ${aros_targetcfg_dir}/elf-specs:${elf_specs_in}
3414         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-elf-gcc:scripts/elf-gcc.in
3415     )
3418 # Host compiler support scripts and spec
3419 if test "${aros_target_toolchain}" = "no"; then
3420     AC_CONFIG_COMMANDS([host-compiler-wrapper-support],
3421         [
3422             prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
3423             mkdir -p $prefix
3424             prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
3426             chmod a+x ${prefix2}-${toolchain_c_compiler} ${prefix2}-${toolchain_cxx_compiler} ${prefix2}-${toolchain_cpp_preprocessor}
3427         ],
3428         [
3429             aros_host_exe_suffix=${aros_host_exe_suffix}
3430             aros_tools_dir=${aros_tools_dir}
3431             aros_target_cpu=${aros_target_cpu}
3432             aros_target_arch=${aros_target_arch}
3433             aros_target_suffix=${aros_target_suffix}
3434         ]
3435     )
3436     AC_CONFIG_FILES(
3437         ${aros_targetcfg_dir}/specs:config/specs.in
3438         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cpp_preprocessor}:scripts/aros-${toolchain_cpp_preprocessor}.in
3439         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_c_compiler}:scripts/aros-${toolchain_c_compiler}.in
3440         ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-${toolchain_cxx_compiler}:scripts/aros-${toolchain_cxx_compiler}.in
3441     )
3444 # Android support
3445 if test "$aros_target_variant" == "android"; then
3446     AC_CONFIG_FILES(${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in)
3449 # cmake helper
3450 AC_CONFIG_FILES(${aros_targetcfg_dir}/conf.cmake:config/conf.cmake.in)
3452 AC_OUTPUT
3454 dnl This is in order to not define SHARED_CFLAGS sometimes
3455 dnl We don't always do aros_shared_ar, aros_shared_cflags
3457 #XXX compatability...
3458 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
3460 if test -n "$aros_shared_cflags" ; then
3461     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
3462     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg