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