Start AVL functions three entries early for the moment in order to avoid
[tangerine.git] / configure.in
blobac296586f308517fb72d2fa72eea3b08ff72bd12
1 dnl Copyright © 1997-2006, 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 #TODO
8 # method of getting shared/non-shared ld/ar tool for target.
11 # ------------------------------------------------------------------------
12 # Here starts the first section of the configure.in file.
13 # ------------------------------------------------------------------------
15 AC_INIT(mmakefile)
16 AC_PREREQ(2.61)
17 AC_CONFIG_AUX_DIR(scripts/autoconf)
19 # Check what host we are running on.
20 # If a target is not suggested, we use this one.
21 # Note that what we call a target, Autoconf calls a host.
22 AC_CANONICAL_HOST
24 # The AROS target is slightly different to the normal GNU style
25 # format. We don't have the middle part, and we reverse the order
26 # of the $(CPU) and $(OS) bits.
28 # Don't strip the version of the target yet, it might be
29 # useful on some systems.
31 AC_MSG_CHECKING([for AROS style target])
33 if test "$target" = "NONE" ; then
34     target=$host_os-$host_cpu
35     cross_compile=no
36 else
37     if test "$target" = "" ; then
38         target=$host_os-$host_cpu
39         cross_compile=no
40     else
41         cross_compile=yes
42     fi
44 AC_MSG_RESULT($target)
46 #don't know where else to put this...
47 TOPDIR=$PWD
49 # Parse the target field into something useful.
50 changequote(<<,>>)
51 target_os=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\1/'`
52 target_cpu=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\2/'`
53 changequote([,])
55 dnl --------------------------------------------------------------------
56 dnl Set the default Workbench resolution
57 dnl --------------------------------------------------------------------
58 aros_default_wbwidth=800
59 aros_default_wbheight=600
60 aros_default_wbdepth=4
62 dnl --------------------------------------------------------------------
63 dnl Host Configuration Section
64 dnl --------------------------------------------------------------------
65 dnl
66 dnl The idea here is to find out all the information we need about the
67 dnl host. This means things like tools for building directory structures,
68 dnl copying files around and the like.
70 # The first step is to find the host binaries.
71 # Check for a compiler.
72 AC_PROG_CC
73 AC_PROG_CC_STDC
74 AC_PROG_CPP
76 # Check for a compatible awk
77 AC_CHECK_PROGS(AWK,[gawk nawk])
78 AROS_REQUIRED(gawk,$AWK)
79 AROS_PROG(MMAKE,mmake)
81 # Perform some default variable assignments. Note all of these will be
82 # Regenerated from the script, so there is no need to cache them.
84 aros_host_cc="$CC"
85 AROS_TOOL_CCPATH(aros_host_ld,ld)
86 AROS_REQUIRED(ld,$aros_host_ld)
87 aros_host_make="make"
88 aros_host_cflags=$CFLAGS
89 aros_host_ldflags=$LDFLAGS
90 aros_host_debug="-g -O0"
91 aros_host_mkdep="\$(TOP)/scripts/mkdep"
92 aros_host_mkargs="--no-print-directory"
93 aros_host_incl="/usr/include"
94 aros_host_exe_suffix="$EXEEXT"
95 aros_host_lib_suffix=""
97 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19])
98 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
99 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
100 AC_CHECK_PROGS(aros_host_automake,[automake automake19])
102 case "$aros_host_cc" in
103     *gcc*)
104         aros_host_cc_pipe="-pipe"
105         ;;
106     icc)
107         aros_host_cc_pipe=""
108         ;;
109     *)
110         aros_host_cc_pipe=""
111         ;;
112 esac
114 dnl Despite the name, this is really a host configuration variable.
115 aros_target_cc_includes=""
117 # This is the main host configuration section. It is where the host
118 # can change the values of any variables it needs to change. We do
119 # not look at anything that compiles to the target yet, we'll get
120 # to that later.
122 case "$host_os" in
123     linux*)
124         aros_host_arch="linux"
125         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
126         case "$host_cpu" in
127             *i?86*)
128                 aros_host_cpu="i386"
129                 ;;
130             *x86_64*)
131                 aros_host_cpu="x86_64"
132                 ;;
133             *m68k*)
134                 aros_host_cpu="m68k"
135                 ;;
136             *powerpc*)
137                 aros_host_cpu="ppc"
138                 ;;
139             *)
140                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
141                 aros_host_cpu="$host_cpu"
142                 ;;
143         esac
144         ;;
146     freebsd*)
147         aros_host_cc="$aros_host_cc $aros_host_cc_pipe -I/usr/local/include"
148         aros_host_make="gmake"
149         aros_host_arch="freebsd"
150         aros_host_cpu="i386"
152         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
154         dnl Need to override this here, it's just too hard later.
155         dnl This shouldn't be here at all...
156         dnl aros_target_cc_includes="/usr/include"
158         dnl FreeBSD 5.x (and later) has changed the default object format.
159         dnl The double [[]] is necessary to get around m4's quoting rules.
160         case $host_os in
161             freebsd[[234]]*)
162                 aros_object_format="elf_i386"
163                 ;;
165             *)
166                 aros_object_format="elf_i386_fbsd"
167                 ;;
168         esac
170         ;;
172     darwin*)
173         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
174         aros_host_arch="darwin"
175         case "$host_cpu" in
176             *i?86*)
177                 aros_host_cpu="i386"
178                 ;;
179             *powerpc*)
180                 aros_host_cpu="ppc"
181                 ;;
182             *)
183                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
184                 aros_host_cpu="$host_cpu"
185                 ;;
186         esac
188         aros_host_ldflags="$aros_host_ldflags -liconv"
190         ;;
192     netbsd*)
193         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
194         aros_host_make="gmake"
195         aros_host_arch="netbsd"
196         case "$host_cpu" in
197             *i?86*)
198                 aros_host_cpu="i386"
199                 ;;
200             *m68k*)
201                 aros_host_cpu="m68k"
202                 ;;
203             *)
204                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
205                 aros_host_cpu="$host_cpu"
206                 ;;
207         esac    
208         aros_host_lib_suffix=".0.0"
209         ;;
211     openbsd*)
212         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
213         aros_host_make="gmake"
214         aros_host_arch="openbsd"
215         case "$host_cpu" in
216             *i?86*)
217                 aros_host_cpu="i386"
218                 ;;
219             *)
220                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
221                 aros_host_cpu="$host_cpu"
222                 ;;
223         esac
224         ;;
225         
226     solaris*)
227         aros_host_arch="solaris"
228         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
229         case "$host_cpu" in
230             *sparc*)
231                 aros_host_cpu="sparc"
232                 ;;
233             *)
234                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
235                 aros_host_cpu="$host_cpu"
236                 ;;
237         esac
238         ;;
240     morphos*)
241         aros_host_arch="morphos"
242         aros_host_cpu="ppc"
243         ;;
245     amiga*)
246         aros_host_arch="amiga"
247         SORT="/gg/bin/sort"
248         TEST="/gg/bin/test"
249         UNIQ="/gg/bin/uniq"
250         FOR="for"
251         TOUCH="/gg/bin/touch"
252         case "$host_cpu" in
253             *m68k*)
254                 aros_host_cpu="m68k"
255                 ;;
256             *powerpc*)
257                 aros_host_cpu="ppc"
258                 ;;
259             *)
260                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
261                 aros_host_cpu="$host_cpu"
262                 ;;
263         esac
264         ;;
266     cygwin*)
267         aros_host_arch="cygwin"
268         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
269         case "$host_cpu" in
270             *i?86*)
271                 aros_host_cpu="i386"
272                 ;;
273             *)
274                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
275                 aros_host_cpu="$host_cpu"
276                 ;;
277         esac
278         ;;
280     mingw32*)
281         aros_host_arch="mingw32"
282         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
283         case "$host_cpu" in
284             *i?86*)
285                 aros_host_cpu="i386"
286                 ;;
287             *)
288                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
289                 aros_host_cpu="$host_cpu"
290                 ;;
291         esac
292         ;;
293     *)
294         AC_MSG_ERROR([Unsupported host architecture $host])
295         ;;
296 esac
298 AROS_PROG(aros_host_ar,[ar],[cr])
299 AROS_REQUIRED(ar,$aros_host_ar)
300 AROS_PROG(aros_host_ranlib,ranlib)
301 AROS_REQUIRED(ranlib,$aros_host_ranlib)
302 AROS_PROG(aros_host_strip,strip)
303 AROS_REQUIRED(strip,$aros_host_strip)
305 AROS_PROG(RM,[rm],[-rf])
306 AROS_REQUIRED(rm,$RM)
307 AROS_PROG(CP,[cp])
308 AROS_REQUIRED(cp,$CP)
309 AROS_PROG(MV,[mv])
310 AROS_REQUIRED(mv,$MV)
311 AROS_PROG(ECHO,[echo])
312 AROS_REQUIRED(echo,$ECHO)
313 AROS_PROG(MKDIR,[mkdir],[-p])
314 AROS_REQUIRED(mkdir,$MKDIR)
315 AROS_PROG(TOUCH,[touch])
316 AROS_REQUIRED(touch,$TOUCH)
317 AROS_PROG(SORT,[sort])
318 AROS_REQUIRED(sort,$SORT)
319 AROS_PROG(UNIQ,[uniq])
320 AROS_REQUIRED(uniq,$UNIQ)
321 AROS_PROG(NOP,[true])
322 AROS_REQUIRED(true,$NOP)
323 AROS_PROG(CAT,[cat])
324 AROS_REQUIRED(cat,$CAT)
325 AROS_PROG(BISON,[bison])
326 AROS_REQUIRED(bison,$BISON)
327 AROS_PROG(FLEX,[flex])
328 AROS_REQUIRED(flex,$FLEX)
329 AROS_PROG(PNGTOPNM,[pngtopnm])
330 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
331 AROS_PROG(PPMTOILBM,[ppmtoilbm])
332 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
333 AROS_PROG(SED,[sed])
334 AROS_REQUIRED(sed,$SED)
335 AROS_PROG(CHMOD,[chmod])
336 AROS_REQUIRED(chmod,$CHMOD)
338 AM_PATH_PYTHON(2.2.1)
340 AC_SUBST(FOR, for)
341 AC_SUBST(IF, if)
342 AC_SUBST(TEST, test)
343 AC_SUBST(CMP, cmp)
345 dnl ---------------------------------------------------------------------------
346 dnl Look for things about the host system, good for hosted targets.
347 dnl ---------------------------------------------------------------------------
349 # Check for some includes for the X11 HIDD and the kernel
350 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
351     sys/mmap.h sys/mman.h sysexits.h \
352     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
355 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
357 AC_HEADER_DIRENT
358 AC_HEADER_STAT
359 AC_HEADER_STDC
360 AC_HEADER_SYS_WAIT
361 AC_HEADER_TIME
362 AC_STRUCT_ST_BLKSIZE
363 AC_STRUCT_ST_BLOCKS
364 AC_STRUCT_ST_RDEV
365 AC_STRUCT_TM
366 AC_STRUCT_TIMEZONE
367 AC_TYPE_OFF_T
368 AC_TYPE_PID_T
369 AC_TYPE_SIZE_T
370 AC_TYPE_UID_T
372 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
374 # Look for some functions
375 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
376     clone kse_create rfork_thread thr_create sa_register \
377     getcontext makecontext setcontext sigaltstack swapcontext])
379 AC_FUNC_MMAP
382 dnl --------------------------------------------------------------------
383 dnl Target Configuration Section
384 dnl --------------------------------------------------------------------
386 dnl The target configuration section is responsible for setting up all
387 dnl the paths for includes, and tools required to build AROS to some
388 dnl particular target.
390 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
391 aros_config_aflags="-Wall -x assembler-with-cpp -c"
392 aros_config_ldflags=""
394 aros_shared_default=yes
396 aros_shared_cflags="-fPIC"
397 aros_shared_aflags=""
398 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
399 aros_kernel_ldflags="-Wl,-rpath,./lib"
401 aros_target_ar_flags="cr"
402 aros_target_nm_flags="-C -ul"
403 aros_target_strip_flags="--strip-unneeded -R.comment"
405 aros_compiler_libs=
407 aros_target_genmap="-Wl,-Map -Xlinker"
409 # Native flavour stuff
410 aros_bochs_hack="0"
411 aros_serial_debug="0"
413 # Palm native flavour stuff
414 aros_palm_debug_hack="0"
416 # Unix flavour stuff
417 aros_nesting_supervisor="0"
419 # Collect-aros stuff: "-ius" to ignore undefined symbols
420 ignore_undefined_symbols=""
422 #-----------------------------------------------------------------------------
425 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
426 # it switched on by default, and we use the host compiler, so it compiles AROS
427 # code with this enabled resulting in link failures as we don't have support
428 # for it.
430 # We use two methods to disable it. For the host compiler (used to compile
431 # some hosted modules), we test to see if the compiler supports stack
432 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
433 # work on all platforms.
435 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
436 # (this is done unconditionally, as it should have no effect on compilers
437 # without the stack protection feature). This may be specific to the way that
438 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
439 # strong enough to disable it in a generic way though, so we'll live with it
440 # until another vendor ships GCC with it enabled in a different way, and deal
441 # with it then.
444 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
445 save_cflags="$CFLAGS"
446 CFLAGS="$CFLAGS -fno-stack-protector"
447 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
448 AC_MSG_RESULT($use_no_stack_protector)
449 if test "x-$use_no_stack_protector" = "x-yes" ; then
450     aros_config_cflags="$aros_config_cflags -fno-stack-protector"
452 CFLAGS="$save_cflags"
454 #-----------------------------------------------------------------------------
456 AC_MSG_CHECKING([for type of build])
457 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")
459 if test "$build_type" = "nightly"; then
460     build_type_string="NIGHTLY"
461 elif test "$build_type" = "snapshot"; then
462     build_type_string="SNAPSHOT"
463 elif test "$build_type" = "milestone"; then
464     build_type_string="MILESTONE"
465 elif test "$build_type" = "release"; then
466     build_type_string="RELEASE"
467 else
468     build_type_string="PERSONAL"
469     build_type="personal"
472 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
474 AC_MSG_RESULT($build_type)
476 #-----------------------------------------------------------------------------
477 all_debug_types="messages stack mungwall modules symbols"
479 AC_MSG_CHECKING([which debug types to enable])
480 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)]),
481  debug="$enableval",debug="")
483 if test "$debug" = "" -o "$debug" = "no"; then
484     debug="none"
485 elif test "$debug" = "yes"; then
486     debug="all"
489 if test "$debug" = "all" ; then
490     debug=$all_debug_types
491     for d in $all_debug_types; do
492         export aros_${d}_debug="1"
493     done
494 else
495     for d in $all_debug_types; do
496         export aros_${d}_debug="0"
497     done
500 if test "$debug" != "none"; then
501     debug=`echo $debug | sed s/,/\ /g`
502     for d in $debug; do
503         found="0"
504         for d2 in $all_debug_types; do
505             if test "$d2" = "$d"; then
506                 found="1"
507                 break
508             fi
509         done
510         if test "$found" = "0"; then
511             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
512         fi
513         export aros_${d}_debug="1"
514     done
515     aros_debug="yes"
517 AC_MSG_RESULT($debug)
519 if test "$aros_messages_debug" = "1"; then
520     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
521 else
522     aros_messages_debug=""
524 if test "$aros_symbols_debug" = "1"; then
525     aros_symbols_debug="-g"
526 else
527     aros_symbols_debug=""
530 # These are the flags to pass when compiling debugged programs
531 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
532 aros_debug_aflags=""
533 aros_debug_ldflags="$aros_symbols_debug"
535 #-----------------------------------------------------------------------------
536 #   Checking for distcc and ccache.
538 #   Always apply the transforms in this particular order. Basically you should
539 #   always run 'ccache distcc compiler' in that order for the best performance.
541 AC_MSG_CHECKING([whether to enable distcc])
542 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
543 if test "$distcc" != "" -a "$distcc" != "no"; then
544     # AC_CHECK_PROG will print out the result in this case
545     AC_PATH_PROG(DISTCC,[distcc],distcc,)
546 else
547     AC_MSG_RESULT(no)
550 AC_MSG_CHECKING([whether to enable ccache])
551 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
552 if test "$ccache" != "" -a "$ccache" != "no"; then
553     # AC_CHECK_PROG will print out the result in this case
554     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
555 else
556     AC_MSG_RESULT(no)
559 #-----------------------------------------------------------------------------
560 AC_MSG_CHECKING([what optimization flags to use])
561 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
562 if test "$optimization" = "unknown"; then
563     dnl default is -O2 for normal builds, -O0 for debug builds
564     if test "$debug" != "none"; then
565         optimization="-O0"
566     else
567         optimization="-O2"
568     fi
570 aros_config_cflags="$aros_config_cflags $optimization"
571 AC_MSG_RESULT($optimization)
573 #-----------------------------------------------------------------------------
574 AC_MSG_CHECKING([what target variant to enable])
575 AC_ARG_ENABLE(target_variant,AC_HELP_STRING([--enable-target-variant=NAME],[Enable a specific target variant(default=none)]),target_variant=$enableval,target_variant="none")
576 if test "$target_variant" = "none"; then
577     aros_target_variant=""
578     aros_target_suffix=""
579 else
580     aros_target_variant="$target_variant"
581     aros_target_suffix="-$target_variant"
583 AC_MSG_RESULT($enableval)
585 target_bootloader="none"
587 #-----------------------------------------------------------------------------
588 # This is the target configuration switch.
589 case "$target_os" in
590     linux*)
591         aros_target_arch="linux"
592         case "$target_cpu" in
593             *m68k*)
594                 aros_target_cpu="m68k"
595                 aros_object_format="m68kelf"
596                 aros_flavour="emulcompat"
597                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
598                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
599                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
600                 gcc_target_cpu="mc68000"
601                 ;;
602             *i?86*)
603                 aros_target_cpu="i386"
604                 aros_object_format="elf_i386"
605                 aros_flavour="emulation"
606                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
607                 aros_default_wbdepth=8
608                 gcc_target_cpu="i386"
609                 ;;
610             *x86_64*)
611                 aros_target_cpu="x86_64"
612                 aros_object_format="elf_x86_64"
613                 aros_flavour="emulation"
614                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
615                 aros_default_wbdepth=8
616                 gcc_target_cpu="x86_64"
617                 ;;
618             *powerpc*)
619                 aros_target_cpu="ppc"
620                 aros_object_format="elf32ppc"
621                 aros_flavour="emulation"
622                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
623                 aros_default_wbdepth=8
624                 gcc_target_cpu="ppc"
625                 ;;
626             *)
627                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
628                 ;;
629         esac
630     ;;
632     pc)
633         aros_target_arch="pc"
634         aros_shared_default="no"
635         target_bootloader="grub"
636         case "$target_cpu" in
637             *i?86*)
638                 aros_target_cpu="i386"
640                 dnl If somebody hasn't already set the target object
641                 dnl format, then use this value. Mostly to support
642                 dnl FreeBSD cross-compilation.
643                 dnl TODO: Remove when we always use our compiler.
645                 if test "$aros_object_format" = "" ; then
646                     aros_object_format="elf_i386"
647                 fi
648                 aros_flavour="standalone"
649                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
650                 aros_kernel_ldflags=""
651                 aros_default_wbwidth=640
652                 aros_default_wbheight=480
653                 gcc_target_cpu="i386"
654                 ;;
655             *x86_64*)
656                 aros_target_cpu="x86_64"
657                 if test "$aros_object_format" = "" ; then
658                     aros_object_format="elf_x86_64"
659                 fi
660                 aros_flavour="standalone"
661                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
662                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables"
663                 aros_kernel_ldflags=""
664                 aros_default_wbwidth=640
665                 aros_default_wbheight=480
666                 gcc_target_cpu="x86_64"
667                 ;;
668             *)
669                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
670                 ;;
671         esac
672         ;;
674     prep)
675         aros_target_arch="prep"
676         aros_shared_default="no"
677         aros_target_cpu="ppc"
678         aros_object_format="elf32ppc"
679         aros_flavour="ppcnative"
680         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
681         aros_kernel_ldflags=""
682         aros_default_wbwidth=640
683         aros_default_wbheight=480
684         gcc_target_cpu="ppc"
685         case "$target_cpu" in
686             *cross*)
687                 aros_target_cc="ppc-linux-gcc -pipe"
688                 aros_target_ld="ppc-linux-ld"
689                 aros_target_as="ppc-linux-as"
690                 aros_target_ar="ppc-linux-ar"
691                 aros_target_ranlib="ppc-linux-ranlib"
692                 aros_target_nm="ppc-linux-nm"
693                 aros_target_strip="ppc-linux-strip"
694                 aros_target_objcopy="ppc-linux-objcopy"
695                 aros_target_objdump="ppc-linux-objdump"
696                 aros_shared_ld="ppc-linux-ld"
697                 aros_kernel_ld="ppc-linux-ld"
698                 ;;
699             *)
700                 ;;
701         esac
702         ;;
704     freebsd*)
705         aros_target_arch="freebsd"
706         aros_target_cpu="i386"
707         aros_flavour="emulation"
708         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
709         gcc_target_cpu="i386"
711         aros_target_strip_flags="-x"
712         ;;
714     darwin*)
715         aros_target_arch="darwin"
716         aros_target_cpu="i386"
717         aros_flavour="emulation"
718         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
719         gcc_target_cpu="i386"
721         aros_target_strip_flags="-x"
722         ;;
724     netbsd*)
725         aros_target_arch="netbsd"
726         case "$target_cpu" in
727             *m68k*)
728                 aros_target_cpu="m68k"
729                 aros_object_format="m68kelf"
730                 aros_flavour="emulcompat"
731                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
732                 gcc_target_cpu="mc68000"
733                 ;;
734             *i?86*)
735                 aros_target_cpu="i386"
736                 aros_object_format="elf_i386"
737                 aros_flavour="emulation"
738                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
739                 aros_default_wbdepth=8
740                 gcc_target_cpu="i386"
741                 ;;
742             *)
743                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
744                 ;;
745         esac
746         aros_target_genmap="-Wl,-M -Xlinker >"
747         aros_flavour="emulation"
748         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
749         ;;   
751     openbsd*)
752         aros_target_arch="openbsd"
753         case "$target_cpu" in
754             *i?86*)
755                 aros_target_cpu="i386"
756                 aros_object_format="elf_i386"
757                 aros_flavour="emulation"
758                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
759                 gcc_target_cpu="i386"
760                 ;;
761             *)
762                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
763                 ;;
764         esac
765         aros_target_genmap="-Wl,-M -Xlinker >"
766         aros_target_nm_flags="-u"
767         aros_flavour="emulation"
768         ;;
770     solaris*)
771         aros_target_arch="solaris"
772         case "$target_cpu" in
773             *sparc*)
774                 aros_target_cpu="sparc"
775                 aros_object_format="elf_sparc"
776                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
777                 gcc_target_cpu="sparc"
778                 ;;
779             *)
780                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
781                 ;;
782         esac
783         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
784         aros_flavour="emulation"
785         ;;
787     morphos*)
788         aros_target_arch="morphos"
789         aros_shared_default="no"
790         aros_target_cpu="ppc"
791         aros_object_format="elf_ppc"
792         aros_flavour="nativecompat"
793         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
794         gcc_target_cpu="ppc"
795         ;;
797     sam440)
798         aros_target_arch="sam440"
799         aros_shared_default="no"
800         aros_target_cpu="ppc"
801         aros_object_format="elf32ppc"
802         aros_flavour="ppcnative"
803         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
804         aros_kernel_ldflags=""
805         aros_default_wbwidth=640
806         aros_default_wbheight=480
807         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
808         gcc_target_cpu="powerpc"
809         case "$target_cpu" in
810             *powerpc*)
811                 aros_target_cc="powerpc-linux-gcc -pipe"
812                 aros_target_ld="powerpc-linux-ld"
813                 aros_target_as="powerpc-linux-as"
814                 aros_target_ar="powerpc-linux-ar"
815                 aros_target_ranlib="powerpc-linux-ranlib"
816                 aros_target_nm="powerpc-linux-nm"
817                 aros_target_strip="powerpc-linux-strip"
818                 aros_target_objcopy="powerpc-linux-objcopy"
819                 aros_target_objdump="powerpc-linux-objdump"
820                 aros_shared_ld="powerpc-linux-ld"
821                 aros_kernel_ld="powerpc-linux-ld"
822                 ;;
823             *)
824                 ;;
825         esac
826         ;;
828     amiga*)
829         aros_target_arch="amiga"
830         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
831         aros_shared_default="no"
833         aros_config_cflags="$aros_config_cflags -fomit-frame-pointer -fbuiltin -ffreestanding"
835         case "$target_cpu" in
836             *m68k*)
837                 aros_target_cpu="m68k"
838                 aros_object_format="m68kelf"
839                 aros_flavour="nativecompat"
840                 gcc_target_cpu="mc68000"
841                 ;;
842             *ppc*)
843                 aros_cpu="ppc"
844                 aros_flavour="native"
845                 gcc_target_cpu="ppc"
846                 ;;
847             *)
848                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
849                 ;;
850         esac
851         ;;
853     cygwin*)
854         aros_target_arch="cygwin"
855         aros_shared_default="no"
856         case "$target_cpu" in
857             *i?86*)
858                 aros_target_cpu="i386"
859                 aros_object_format="elf_i386"
860                 aros_flavour="emulation"
861                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
862                 aros_shared_cflags=""
863                 aros_default_wbdepth=8
864                 gcc_target_cpu="i386"
865                 ;;
866             *)
867                 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
868                 ;;
869         esac
870     ;;
872     mingw32*)
873         aros_target_arch="mingw32"
874         aros_shared_default="no"
875         case "$target_cpu" in
876             *i?86*)
877                 aros_target_cpu="i386"
878                 aros_object_format="elf_i386"
879                 aros_flavour="emulation"
880                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
881                 aros_shared_cflags=""
882                 aros_default_wbdepth=8
883                 gcc_target_cpu="i386"
884                 ;;
885             *)
886                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
887                 ;;
888         esac
889     ;;
890     pp*)
891         aros_target_arch="pp"
892         aros_shared_default="no"
893         case "$target_cpu" in
894             *m68k*)
895                 aros_target_cpu="m68k"
896                 aros_object_format="m68kelf"
897                 aros_flavour="palmnative"
898                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
899                 aros_kernel_ldflags=""
900                 aros_default_wbwidth=160
901                 aros_default_wbheight=160
902                 aros_default_wbdepth=1
903                 aros_target_cc="m68k-elf-gcc -pipe"
904                 aros_target_ld="$(which m68k-elf-ld)"
905                 aros_target_as="m68k-elf-gcc -pipe"
906                 aros_shared_ld="m68k-elf-gcc"
907                 aros_kernel_ld="m68k-elf-gcc"
908                 aros_target_ar="m68k-elf-ar"
909                 aros_target_ar_flags="cru"
910                 aros_target_ranlib="m68k-elf-ranlib"
911                 aros_target_nm="m68k-elf-nm"
912                 aros_target_objcopy="m68k-elf-objcopy"
913                 aros_target_objdump="m68k-elf-objdump"
914                 aros_compiler_libs="-lgcc1"
915                 aros_shared_default=no
916                 aros_shared_cflags="-fpic"
917                 aros_shared_aflags=""
918                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
919                 aros_kernel_ldflags="-Wl,-rpath,./lib"
920                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
921                 aros_debug_aflags=""
922                 aros_debug_ldflags="$aros_symbols_debug"
923                 aros_mungwall_debug="0"
924                 aros_modules_debug="0"
925                 gcc_target_cpu="mc68000"
926                 ignore_undefined_symbols="-ius"
927                 ;;
928            *)
929                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
930                 ;;
931         esac
932         ;;
934     mac*)
935         aros_target_arch="mac"
936         aros_shared_default="no"
937         case "$target_cpu" in
938             *m68k*)
939                 aros_target_cpu="m68k"
940                 aros_object_format="m68kelf"
941                 aros_flavour="mac68knative"
942                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
943                 aros_default_wbwidth=512
944                 aros_default_wbheight=384
945                 aros_default_wbdepth=8
946                 aros_target_cc="m68k-elf-gcc -pipe"
947                 aros_target_ld="$(which m68k-elf-ld)"
948                 aros_target_as="m68k-elf-gcc -pipe"
949                 aros_shared_ld="m68k-elf-gcc"
950                 aros_kernel_ld="m68k-elf-gcc"
951                 aros_target_ar="m68k-elf-ar"
952                 aros_target_ar_flags="cru"
953                 aros_target_ranlib="m68k-elf-ranlib"
954                 aros_target_nm="m68k-elf-nm"
955                 aros_target_objcopy="m68k-elf-objcopy"
956                 aros_target_objdump="m68k-elf-objdump"
957                 aros_compiler_libs="-lgcc1"
958                 aros_shared_default=no
959                 aros_shared_cflags="-fpic"
960                 aros_shared_aflags=""
961                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
962                 aros_kernel_ldflags="-Wl,-rpath,./lib"
963                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000"
964                 aros_debug_aflags=""
965                 aros_debug_ldflags="$aros_symbols_debug"
966                 aros_mungwall_debug="0"
967                 aros_modules_debug="0"
968                 gcc_target_cpu="mc68000"
969                 ignore_undefined_symbols="-ius"
970                 ;;
971            *)
972                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
973                 ;;
974         esac
975         ;;
977     *)
978         AC_MSG_ERROR([Unsupported target architecture $target])
979         ;;
980 esac
982 AC_MSG_CHECKING([which bootloader to use])
983 AC_ARG_ENABLE(bootloader,AC_HELP_STRING([--enable-bootloader=NAME],[Enable a specific bootloader]),target_bootloader=$enableval,target_bootloader=$target_bootloader)
984 if test "$target_bootloader" = "none"; then
985     aros_target_bootloader=""
986 else
987     aros_target_bootloader="$target_bootloader"
989 AC_MSG_RESULT($target_bootloader)
991 # Find out if we are cross-compiling (ie. if we can't use the host compiler
992 # for target code)
993 cross_compiling=no
994 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
995     cross_compiling=yes
997 if test "$aros_host_arch" == "darwin" ; then
998     cross_compiling=yes
1001 # Set prefix for target compiler etc. if we're cross-compiling
1002 # (should possibly be earlier but needs to be after AC_PROG_CC)
1003 if test "$cross_compiling" = "yes" ; then
1004     target_tool_prefix=${target_cpu}-elf-
1005     CC=${target_tool_prefix}gcc
1008 # Find all the tools we need to compile. This could be cross-compiling
1009 # though! If that is the case we use the GNU form of the target and
1010 # simply add this to the front of the binary name. This is rather simple,
1011 # but it should work under most circumstances.
1013 # The default tools are to use the same as the host, but only if the
1014 # host and target CPU are the same. With GCC this is normally enough.
1017 aros_cc_pre=""
1018 aros_shared_ld="$aros_host_ld"
1020 aros_target_mkdep="$aros_host_mkdep"
1021 aros_target_incl_def="$aros_host_incl"
1023 AC_PATH_PROG(aros_kernel_cc,$CC)
1025 # The default tools executables to be linked to.
1026 AROS_TOOL_TARGET(aros_target_as_ln,as)
1027 AROS_REQUIRED(as,$aros_target_as_ln)
1028 AROS_TOOL_TARGET(aros_kernel_ld,ld)
1029 AROS_REQUIRED(ld,$aros_kernel_ld)
1030 AROS_TOOL_TARGET(aros_target_ar_ln,ar)
1031 AROS_REQUIRED(ar,$aros_target_ar_ln)
1032 AROS_TOOL_TARGET(aros_target_nm_ln,nm)
1033 AROS_REQUIRED(nm,$aros_target_nm_ln)
1034 AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy)
1035 AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
1036 AROS_TOOL_TARGET(aros_target_objdump_ln,objdump)
1037 AROS_REQUIRED(objdump,$aros_target_objdump_ln)
1038 AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib)
1039 AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
1040 AROS_TOOL_TARGET(aros_target_strip_ln,strip)
1041 AROS_REQUIRED(strip,$aros_target_strip_ln)
1043 if test "$GCC" = "yes"; then
1044     aros_target_cc_path=`$aros_kernel_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1047 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1048 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1049 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1050 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1051 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1052 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1053 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1055 # aros_cc_pre is a variable that is added to the front of the compiler name
1056 # in the generated aros-gcc shell script. We need this to enable the cache
1057 # to work across cleaned builds. Also, support DISTCC using the correct
1058 # environment variable.
1061 if test "x${DISTCC}" != "x" ; then
1062     if test "x${CCACHE}" != "x" ; then
1063         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1064     else
1065         aros_cc_pre="${DISTCC} "
1066     fi
1067 else
1068     if test "x${CCACHE}" != "x" ; then
1069         aros_cc_pre="${CCACHE} "
1070     fi
1073 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1075 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1076 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1077 AC_SUBST(aros_target_nix_ldflags,-nix)
1078 AC_SUBST(aros_target_detach_ldflags,-detach)
1079 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1081 # Target tools
1082 aros_target_cc="${prefix}-gcc"
1083 aros_target_as="${prefix}-as"
1084 aros_target_ld="${prefix}-ld"
1085 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1086 aros_target_objcopy=${prefix}-objcopy
1087 aros_target_objdump=${prefix}-objdump
1088 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1089 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1090 aros_kernel_nm="${prefix}-nm"
1091 aros_target_strip=${prefix}-strip
1094 # Find the system include path. We can suggest that an alternative is
1095 # used if we don't get it correct. The default is to use /usr/include.
1096 # Which is set in the aros_target_incl_def variable.
1098 AC_ARG_ENABLE(includes,
1099 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1100 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1102 dnl find out about the target cc's include path
1103 AC_MSG_CHECKING([for the target compiler's include path])
1104 if test "$aros_target_cc_includes" = "" ; then
1105     #try to guess where the directory is
1106     aros_target_cc_includes=`dirname \`${aros_kernel_cc} -print-libgcc-file-name\``/include
1107     if ! test -d $aros_target_cc_includes; then
1108         #the directory doesn't exist, we need to do some more work
1109         aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1110         
1111         #these are the headers we're looling for
1112         headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1113                  stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1114                  zutil.h"
1116         dirs=
1117         for h in $headers; do
1118             #which other headers each of the above headers needs?
1119             deps=$(echo "#include <$h>" | \
1120                    $aros_host_cc -E -M - 2>/dev/null | \
1121                    sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1122             
1123             #copy all the needed headers to a directory beneath gendir
1124             for d in $deps; do
1125                 h=$(basename $d)
1126                 dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1127                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1128                 ! test -d $dir && mkdir -p $dir
1129                 ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1130             done
1131         done        
1132     fi
1134 AC_MSG_RESULT($aros_target_cc_includes)
1136 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
1137 AC_MSG_CHECKING([for default resolution of WBScreen])
1138 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
1139 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
1140 if test "$resolution" = "yes" ; then
1141     resolution="none"
1143 if test "$resolution" = "no" ; then
1144     resolution="none"
1146 if test "$resolution" != "none" ; then
1147     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
1148     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
1149     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
1151 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
1152 aros_cv_default_wbwidth=$aros_default_wbwidth
1153 aros_cv_default_wbheight=$aros_default_wbheight
1154 aros_cv_default_wbdepth=$aros_default_wbdepth
1156 dnl See if the user wants the BOCHS hack for native flavour
1157 AC_MSG_CHECKING([if bochs hack is enabled])
1158 AC_ARG_ENABLE(bochs_hack,AC_HELP_STRING([--enable-bochs-hack],[Enable hacks to make BOCHS (partly) work (default=no)]),bochs_hack="yes",bochs_hack="no")
1159 if test "$bochs_hack" = "yes" ; then
1160     aros_bochs_hack="1"
1162 AC_MSG_RESULT($bochs_hack)
1164 dnl See if the user wants the serial debug output for native flavour
1165 AC_MSG_CHECKING([if serial debug is enabled])
1166 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)
1167 if test "$serial_debug" = "yes" ; then
1168     serial_debug="2"
1170 if test "$serial_debug" = "no" ; then
1171     serial_debug="none"
1173 if test "$serial_debug" != "none" ; then
1174     aros_serial_debug=$serial_debug
1175     AC_MSG_RESULT(on port $serial_debug)
1176 else
1177     AC_MSG_RESULT(no)
1180 dnl See if the user wants the palm debug output hack for palm native flavour
1181 AC_MSG_CHECKING([if palm debug hack is enabled])
1182 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")
1183 if test "$palm_debug_hack" = "yes" ; then
1184     aros_palm_debug_hack="1"
1186 AC_MSG_RESULT($palm_debug_hack)
1189 dnl See if the user wants nesting supervisor activated for unix flavour
1190 AC_MSG_CHECKING([if nesting supervisor support is enabled])
1191 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")
1192 if test "$nesting_supervisor" = "yes" ; then
1193     aros_nesting_supervisor="1"
1195 AC_MSG_RESULT($nesting_supervisor)
1198 dnl things specifically required for hosted flavours
1199 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1201     dnl some kind of dynamic library access system is required for hostlib.resource
1202     AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
1203     if test "x-$have_dl" = "x-no" ; then
1204         AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
1205                                   aros_host_ldflags="$aros_host_ldflags -ldl"],
1206                                  have_dl="no")
1207     fi
1208     if test "x-$have_dl" = "x-no" ; then
1209          AC_MSG_ERROR([dlopen() dynamic linker functions not available])
1210     fi
1213     dnl x11 hidd
1214     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
1215                                            [build X11 hidd for hosted (default=auto)]),
1216                                            x11_hidd="$enableval",
1217                                            x11_hidd="auto")
1218     case "x-$x11_hidd" in
1219         x-yes|x-no|x-auto)                 ;;
1220         *)                 x11_hidd="auto" ;;
1221     esac
1223     dnl they want it
1224     if test "x-$x11_hidd" != "x-no" ; then
1226         dnl find x11 stuff
1227         AC_PATH_X
1229         x_cflags=
1230         for path in $x_libraries
1231         do
1232             x_cflags="$x_cflags -L$path"
1233         done
1235         for path in $x_includes
1236         do
1237             x_cflags="$x_cflags -I$path"
1238         done
1239         
1240         if test "x-$no_x" = "x-yes" ; then
1242             dnl didn't find it
1243             if test "x-$x11_hidd" != "x-auto" ; then
1244                 dnl and they explicitly asked for it, bail out
1245                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
1246             fi
1247         
1248         else
1249             dnl found it, setup the metatarget
1250             x11_hidd_target=kernel-x11gfx
1253             dnl setup shared memory extensions
1254             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
1255                                                   [use X11 shared memory (default=auto)]),
1256                                                   x11_hidd_shm="$enableval",
1257                                                   x11_hidd_shm="auto")
1258             case "x-$x11_hidd_shm" in
1259                 x-yes|x-no|x-auto)                     ;;
1260                 *)                 x11_hidd_shm="auto" ;;
1261             esac
1263             have_xshm=no
1265             dnl they want it
1266             if test "x-$x11_hidd_shm" != "x-no" ; then
1268                 dnl system shm headers
1269                 AC_CHECK_HEADERS(sys/ipc.h)
1270                 AC_CHECK_HEADERS(sys/shm.h)
1272                 dnl got them
1273                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
1275                     dnl make sure X libs have shm functions
1276                     save_cflags="$CFLAGS"
1277                     CFLAGS="$CFLAGS $x_cflags"
1278                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
1279                     CFLAGS="$save_cflags"
1280                 fi
1281             fi
1283             dnl detection done, prepare output
1284             if test "x-$have_xshm" = "x-yes" ; then
1285                 dnl we can do shm
1286                 DO_XSHM_SUPPORT="1"
1287             elif test "x-$x11_hidd_shm" = "x-yes" ; then
1288                 dnl they explicitly asked for it, but we can't do it
1289                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
1290             else
1291                 dnl otherwise just disable it
1292                 DO_XSHM_SUPPORT="0"
1293             fi
1295             
1296             dnl setup vidmode (fullscreen) extensions
1297             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
1298                                                       [use X11 vidmode extension (default=auto)]),
1299                                                       x11_hidd_vidmode="$enableval",
1300                                                       x11_hidd_vidmode="auto")
1301             case "x-$x11_hidd_vidmode" in
1302                 x-yes|x-no|x-auto)                         ;;
1303                 *)                 x11_hidd_vidmode="auto" ;;
1304             esac
1306             have_vidmode=no
1308             dnl they want it
1309             if test "x-$x11_hidd_vidmode" != "x-no" ; then
1311                 dnl make sure X libs have vidmode functions
1312                 save_cflags="$CFLAGS"
1313                 CFLAGS="$CFLAGS $x_cflags"
1314                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
1315                 CFLAGS="$save_cflags"
1316             fi
1318             dnl detection done, prepare output
1319             if test "x-$have_vidmode" = "x-yes" ; then
1320                 dnl we can do vidmode
1321                 DO_VIDMODE_SUPPORT="1"
1322             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
1323                 dnl they explicitly asked for it, but we can't do it
1324                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
1325             else
1326                 dnl otherwise just disable it
1327                 DO_VIDMODE_SUPPORT="0"
1328             fi
1329         fi
1331         aros_host_x11_includes=$x_includes 
1332         aros_host_x11_libdirs=$x_libraries
1333     fi
1336     dnl sdl hidd
1337     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
1338                                            [build SDL hidd for hosted (default=auto)]),
1339                                            sdl_hidd="$enableval",
1340                                            sdl_hidd="auto")
1341     case "x-$sdl_hidd" in
1342         x-yes|x-no|x-auto)                 ;;
1343         *)                 sdl_hidd="auto" ;;
1344     esac
1346     dnl they want it
1347     if test "x-$sdl_hidd" != "x-no" ; then
1349         dnl find sdl
1350         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
1352         if test "x-$have_sdl" != "x-yes" ; then
1354             dnl didn't find it
1355             if test "x-$sdl_hidd" != "x-auto" ; then
1356                 dnl and they explicitly asked for it, bail out
1357                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
1358             fi
1360         else
1361             dnl found it, setup the metatarget
1362             sdl_hidd_target=kernel-hidd-sdl
1363             aros_host_sdl_cflags=SDL_CFLAGS
1364             aros_host_sdl_libs=SDL_LIBS
1365         fi
1366     fi
1371 dnl See if the user wants dbus.library
1372 AC_MSG_CHECKING([if building of dbus.library is enabled])
1373 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
1374 if test "$dbus" = "yes" ; then
1375     ENABLE_DBUS=1
1376     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
1377     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
1378     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
1379     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
1380 else
1381     ENABLE_DBUS=0
1383 AC_MSG_RESULT($dbus)
1386 dnl --------------------------------------------------------------------
1387 dnl Configuration Output Section
1388 dnl --------------------------------------------------------------------
1390 # Generic
1391 AC_SUBST(aros_arch)
1392 AC_SUBST(aros_cpu)
1393 AC_SUBST(aros_flavour)
1394 AC_SUBST(aros_flavour_uc)
1395 AC_SUBST(TOPDIR)
1397 # Host related
1398 AC_SUBST(aros_cc_pre)
1399 AC_SUBST(aros_host_strip)
1400 AC_SUBST(aros_host_arch)
1401 AC_SUBST(aros_host_cpu)
1402 AC_SUBST(aros_host_cc)
1403 AC_SUBST(aros_host_ar)
1404 AC_SUBST(aros_host_ranlib)
1405 AC_SUBST(aros_host_ld)
1406 AC_SUBST(aros_host_make)
1407 AC_SUBST(aros_host_cflags)
1408 AC_SUBST(aros_host_ldflags)
1409 AC_SUBST(aros_host_debug)
1410 AC_SUBST(aros_host_mkdep)
1411 AC_SUBST(aros_host_mkargs)
1412 AC_SUBST(aros_host_exe_suffix)
1413 AC_SUBST(aros_host_lib_suffix)
1414 AC_SUBST(aros_tools_dir)
1415 AC_SUBST(aros_host_aclocal)
1416 AC_SUBST(aros_host_autoconf)
1417 AC_SUBST(aros_host_autoheader)
1418 AC_SUBST(aros_host_automake)
1420 # Target Related
1421 AC_SUBST(aros_target_bootloader)
1422 AC_SUBST(aros_target_arch)
1423 AC_SUBST(aros_target_cpu)
1424 AC_SUBST(aros_target_variant)
1425 AC_SUBST(aros_target_suffix)
1426 AC_SUBST(aros_target_incl)
1427 AC_SUBST(aros_target_ar)
1428 AC_SUBST(aros_target_ranlib)
1429 AC_SUBST(aros_kernel_nm)
1430 AC_SUBST(aros_target_cc)
1431 AC_SUBST(aros_kernel_cc)
1432 AC_SUBST(aros_target_as)
1433 AC_SUBST(aros_target_ld)
1434 AC_SUBST(aros_kernel_ld)
1435 AC_SUBST(aros_target_cc_includes)
1436 AC_SUBST(aros_target_cc_path)
1437 AC_SUBST(aros_target_objdump)
1438 AC_SUBST(aros_target_objcopy)
1439 AC_SUBST(aros_target_strip)
1440 AC_SUBST(aros_target_nm)
1441 AC_SUBST(aros_shared_default)
1442 AC_SUBST(aros_shared_ld)
1443 AC_SUBST(aros_object_format)
1444 AC_SUBST(aros_compiler_libs)
1446 AC_SUBST(aros_config_cflags)
1447 AC_SUBST(aros_config_aflags)
1448 AC_SUBST(aros_config_ldflags)
1450 AC_SUBST(aros_shared_cflags)
1451 AC_SUBST(aros_shared_aflags)
1452 AC_SUBST(aros_shared_ldflags)
1453 AC_SUBST(aros_kernel_ldflags)
1454 AC_SUBST(aros_debug_cflags)
1455 AC_SUBST(aros_debug_aflags)
1456 AC_SUBST(aros_debug_ldflags)
1457 AC_SUBST(aros_target_genmap)
1458 AC_SUBST(aros_target_strip_flags)
1460 # Graphics Related
1461 AC_SUBST(x11_hidd_target)
1462 AC_SUBST(sdl_hidd_target)
1464 AC_SUBST(aros_default_wbwidth)
1465 AC_SUBST(aros_default_wbheight)
1466 AC_SUBST(aros_default_wbdepth)
1467 AC_SUBST(DO_XSHM_SUPPORT)
1468 AC_SUBST(DO_VIDMODE_SUPPORT)
1470 AC_SUBST(aros_host_x11_includes)
1471 AC_SUBST(aros_host_x11_libdirs)
1472 AC_SUBST(aros_host_sdl_cflags)
1473 AC_SUBST(aros_host_sdl_libs)
1475 # Native version related
1476 AC_SUBST(aros_bochs_hack)
1477 AC_SUBST(aros_serial_debug)
1479 # Palm native version related
1480 AC_SUBST(aros_palm_debug_hack)
1482 # Unix/Hosted version related
1483 AC_SUBST(aros_nesting_supervisor)
1485 # DBUS related
1486 AC_SUBST(ENABLE_DBUS)
1487 AC_SUBST(DBUS_CFLAGS)
1488 AC_SUBST(DBUS_LIBFLAGS)
1489 AC_SUBST(KERNEL_DBUS_KOBJ)
1490 AC_SUBST(KERNEL_DBUS_INCLUDES)
1492 # Debug related
1493 AC_SUBST(aros_debug)
1494 AC_SUBST(aros_mungwall_debug)
1495 AC_SUBST(aros_stack_debug)
1496 AC_SUBST(aros_modules_debug)
1498 # Collect-aros stuff: "-ius" to ignore undefined symbols
1499 AC_SUBST(ignore_undefined_symbols)
1501 # C compiler related
1502 AC_SUBST(gcc_target_cpu)
1504 dnl Prepare for output, make up all the generated patches
1505 case "$aros_flavour" in
1506 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
1507                 aros_flavour="emulation" ;;
1508 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
1509                 aros_flavour="emulation" ;;
1510 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
1511                 aros_flavour="standalone";;
1512 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
1513                 aros_flavour="native" ;;
1514 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1515                 aros_flavour="native" ;;
1516 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
1517                 aros_flavour="linklib" ;;
1518 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1519                 aros_flavour="palmnative" ;;
1520 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1521                 aros_flavour="mac68knative" ;;
1522 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1523                 aros_flavour="ppcnative" ;;
1524 esac
1526 if test ! -d ${aros_inc_dir} ; then
1527     ${MKDIR} ${aros_inc_dir}
1529 if test ! -d ${aros_geninc_dir} ; then
1530     ${MKDIR} ${aros_geninc_dir}
1532 if test ! -d ${aros_hostcfg_dir} ; then
1533     ${MKDIR} ${aros_hostcfg_dir}
1535 if test ! -d ${aros_targetcfg_dir} ; then
1536     ${MKDIR} ${aros_targetcfg_dir}
1538 if test ! -d ${aros_tools_dir} ; then
1539     ${MKDIR} ${aros_tools_dir}
1541 if test ! -d ${aros_scripts_dir} ; then
1542     ${MKDIR} ${aros_scripts_dir}
1545 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
1547 AC_CONFIG_COMMANDS([compiler_executable],
1548     [
1549         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
1550         mkdir -p $prefix
1551         prefix="${prefix}/${aros_target_cpu}-aros"
1552         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
1554         echo ${prefix}
1555         echo ${prefix2}
1556         chmod a+x ${prefix2}-gcc ${prefix2}-ld
1558         ln -sf ${prefix2}-gcc          ${prefix}-gcc
1559         ln -sf ${prefix2}-ld           ${prefix}-ld
1561         ln -sf $aros_target_as_ln      ${prefix}-as
1562         ln -sf $aros_target_nm_ln      ${prefix}-nm
1563         ln -sf $aros_target_ar_ln      ${prefix}-ar
1564         ln -sf $aros_target_ranlib_ln  ${prefix}-ranlib
1565         ln -sf $aros_target_objcopy_ln ${prefix}-objcopy
1566         ln -sf $aros_target_objdump_ln ${prefix}-objdump
1567         ln -sf $aros_target_strip_ln   ${prefix}-strip
1569         ln -sf $aros_target_as_ln      ${prefix2}-as
1570         ln -sf $aros_target_nm_ln      ${prefix2}-nm
1571         ln -sf $aros_target_ar_ln      ${prefix2}-ar
1572         ln -sf $aros_target_ranlib_ln  ${prefix2}-ranlib
1573         ln -sf $aros_target_objcopy_ln ${prefix2}-objcopy
1574         ln -sf $aros_target_objdump_ln ${prefix2}-objdump
1575         ln -sf $aros_target_strip_ln   ${prefix2}-strip
1576     ],
1577     [
1578         aros_tools_dir=${aros_tools_dir}
1579         aros_target_cpu=${aros_target_cpu}
1580         aros_target_arch=${aros_target_arch}
1581         aros_target_suffix=${aros_target_suffix}
1582         aros_target_nm_ln=${aros_target_nm_ln}
1583         aros_target_as_ln=${aros_target_as_ln}
1584         aros_target_ar_ln=${aros_target_ar_ln}
1585         aros_target_ranlib_ln=${aros_target_ranlib_ln}
1586         aros_target_objdump_ln=${aros_target_objdump_ln}
1587         aros_target_objcopy_ln=${aros_target_objcopy_ln}
1588         aros_target_strip_ln=${aros_target_strip_ln}
1589     ]
1591 AC_CONFIG_COMMANDS([genshared_executable],
1592     [chmod a+x ${aros_scripts_dir}/genshared],
1593     [aros_scripts_dir=${aros_scripts_dir}]
1595 AC_CONFIG_COMMANDS([genmf_executable],
1596     [chmod a+x ${aros_tools_dir}/genmf.py],
1597     [aros_tools_dir=${aros_tools_dir}]
1599 AC_CONFIG_COMMANDS([adflib_myaros.conf_executable],
1600     [chmod a+x tools/adflib/myconf.aros]
1603 AC_CONFIG_FILES(
1604     Makefile
1605     rom/mmakefile
1606     ${aros_inc_dir}/config.h:config/config.h.in
1607     ${aros_geninc_dir}/config.h:config/config.h.in
1608     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
1609     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
1610     mmake.config
1611     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
1612     ${aros_targetcfg_dir}/specs:config/specs.in
1613     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
1614     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
1615     ${aros_scripts_dir}/genshared:compiler/c_lib/source/lib_source/genshared.in
1616     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
1617     tools/adflib/myconf.aros
1618     tools/collect-aros/env.h
1621 AC_OUTPUT
1623 dnl This is in order to not define SHARED_CFLAGS sometimes
1624 dnl We don't always do aros_shared_ar, aros_shared_cflags
1626 #XXX compatability...
1627 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
1629 if test -n "$aros_shared_cflags" ; then
1630     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
1631     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg