- Made some fields used only by packet handlers type-compatible with AmigaOS.
[tangerine.git] / configure.in
blobe7e9d7f56165f7c1a5751a0be9c1a4c245f62040
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 #-----------------------------------------------------------------------------
586 # This is the target configuration switch.
587 case "$target_os" in
588     linux*)
589         aros_target_arch="linux"
590         case "$target_cpu" in
591             *m68k*)
592                 aros_target_cpu="m68k"
593                 aros_object_format="m68kelf"
594                 aros_flavour="emulcompat"
595                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
596                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
597                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
598                 gcc_target_cpu="mc68000"
599                 ;;
600             *i?86*)
601                 aros_target_cpu="i386"
602                 aros_object_format="elf_i386"
603                 aros_flavour="emulation"
604                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
605                 aros_default_wbdepth=8
606                 gcc_target_cpu="i386"
607                 ;;
608             *x86_64*)
609                 aros_target_cpu="x86_64"
610                 aros_object_format="elf_x86_64"
611                 aros_flavour="emulation"
612                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
613                 aros_default_wbdepth=8
614                 gcc_target_cpu="x86_64"
615                 ;;
616             *powerpc*)
617                 aros_target_cpu="ppc"
618                 aros_object_format="elf32ppc"
619                 aros_flavour="emulation"
620                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
621                 aros_default_wbdepth=8
622                 gcc_target_cpu="ppc"
623                 ;;
624             *)
625                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
626                 ;;
627         esac
628     ;;
630     pc)
631         aros_target_arch="pc"
632         aros_shared_default="no"
633         case "$target_cpu" in
634             *i?86*)
635                 aros_target_cpu="i386"
637                 dnl If somebody hasn't already set the target object
638                 dnl format, then use this value. Mostly to support
639                 dnl FreeBSD cross-compilation.
640                 dnl TODO: Remove when we always use our compiler.
642                 if test "$aros_object_format" = "" ; then
643                     aros_object_format="elf_i386"
644                 fi
645                 aros_flavour="standalone"
646                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
647                 aros_kernel_ldflags=""
648                 aros_default_wbwidth=640
649                 aros_default_wbheight=480
650                 gcc_target_cpu="i386"
651                 ;;
652             *x86_64*)
653                 aros_target_cpu="x86_64"
654                 if test "$aros_object_format" = "" ; then
655                     aros_object_format="elf_x86_64"
656                 fi
657                 aros_flavour="standalone"
658                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
659                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables"
660                 aros_kernel_ldflags=""
661                 aros_default_wbwidth=640
662                 aros_default_wbheight=480
663                 gcc_target_cpu="x86_64"
664                 ;;
665             *)
666                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
667                 ;;
668         esac
669         ;;
671     prep)
672         aros_target_arch="prep"
673         aros_shared_default="no"
674         aros_target_cpu="ppc"
675         aros_object_format="elf32ppc"
676         aros_flavour="ppcnative"
677         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
678         aros_kernel_ldflags=""
679         aros_default_wbwidth=640
680         aros_default_wbheight=480
681         gcc_target_cpu="ppc"
682         case "$target_cpu" in
683             *cross*)
684                 aros_target_cc="ppc-linux-gcc -pipe"
685                 aros_target_ld="ppc-linux-ld"
686                 aros_target_as="ppc-linux-as"
687                 aros_target_ar="ppc-linux-ar"
688                 aros_target_ranlib="ppc-linux-ranlib"
689                 aros_target_nm="ppc-linux-nm"
690                 aros_target_strip="ppc-linux-strip"
691                 aros_target_objcopy="ppc-linux-objcopy"
692                 aros_target_objdump="ppc-linux-objdump"
693                 aros_shared_ld="ppc-linux-ld"
694                 aros_kernel_ld="ppc-linux-ld"
695                 ;;
696             *)
697                 ;;
698         esac
699         ;;
701     freebsd*)
702         aros_target_arch="freebsd"
703         aros_target_cpu="i386"
704         aros_flavour="emulation"
705         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
706         gcc_target_cpu="i386"
708         aros_target_strip_flags="-x"
709         ;;
711     darwin*)
712         aros_target_arch="darwin"
713         aros_target_cpu="i386"
714         aros_flavour="emulation"
715         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
716         gcc_target_cpu="i386"
718         aros_target_strip_flags="-x"
719         ;;
721     netbsd*)
722         aros_target_arch="netbsd"
723         case "$target_cpu" in
724             *m68k*)
725                 aros_target_cpu="m68k"
726                 aros_object_format="m68kelf"
727                 aros_flavour="emulcompat"
728                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
729                 gcc_target_cpu="mc68000"
730                 ;;
731             *i?86*)
732                 aros_target_cpu="i386"
733                 aros_object_format="elf_i386"
734                 aros_flavour="emulation"
735                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
736                 aros_default_wbdepth=8
737                 gcc_target_cpu="i386"
738                 ;;
739             *)
740                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
741                 ;;
742         esac
743         aros_target_genmap="-Wl,-M -Xlinker >"
744         aros_flavour="emulation"
745         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
746         ;;   
748     openbsd*)
749         aros_target_arch="openbsd"
750         case "$target_cpu" in
751             *i?86*)
752                 aros_target_cpu="i386"
753                 aros_object_format="elf_i386"
754                 aros_flavour="emulation"
755                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
756                 gcc_target_cpu="i386"
757                 ;;
758             *)
759                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
760                 ;;
761         esac
762         aros_target_genmap="-Wl,-M -Xlinker >"
763         aros_target_nm_flags="-u"
764         aros_flavour="emulation"
765         ;;
767     solaris*)
768         aros_target_arch="solaris"
769         case "$target_cpu" in
770             *sparc*)
771                 aros_target_cpu="sparc"
772                 aros_object_format="elf_sparc"
773                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
774                 gcc_target_cpu="sparc"
775                 ;;
776             *)
777                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
778                 ;;
779         esac
780         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
781         aros_flavour="emulation"
782         ;;
784     morphos*)
785         aros_target_arch="morphos"
786         aros_shared_default="no"
787         aros_target_cpu="ppc"
788         aros_object_format="elf_ppc"
789         aros_flavour="nativecompat"
790         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
791         gcc_target_cpu="ppc"
792         ;;
794     amiga*)
795         aros_target_arch="amiga"
796         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
797         aros_shared_default="no"
799         aros_config_cflags="$aros_config_cflags -fomit-frame-pointer -fbuiltin -ffreestanding"
801         case "$target_cpu" in
802             *m68k*)
803                 aros_target_cpu="m68k"
804                 aros_object_format="m68kelf"
805                 aros_flavour="nativecompat"
806                 gcc_target_cpu="mc68000"
807                 ;;
808             *ppc*)
809                 aros_cpu="ppc"
810                 aros_flavour="native"
811                 gcc_target_cpu="ppc"
812                 ;;
813             *)
814                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
815                 ;;
816         esac
817         ;;
819     cygwin*)
820         aros_target_arch="cygwin"
821         aros_shared_default="no"
822         case "$target_cpu" in
823             *i?86*)
824                 aros_target_cpu="i386"
825                 aros_object_format="elf_i386"
826                 aros_flavour="emulation"
827                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
828                 aros_shared_cflags=""
829                 aros_default_wbdepth=8
830                 gcc_target_cpu="i386"
831                 ;;
832             *)
833                 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
834                 ;;
835         esac
836     ;;
838     mingw32*)
839         aros_target_arch="mingw32"
840         aros_shared_default="no"
841         case "$target_cpu" in
842             *i?86*)
843                 aros_target_cpu="i386"
844                 aros_object_format="elf_i386"
845                 aros_flavour="emulation"
846                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
847                 aros_shared_cflags=""
848                 aros_default_wbdepth=8
849                 gcc_target_cpu="i386"
850                 ;;
851             *)
852                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
853                 ;;
854         esac
855     ;;
856     pp*)
857         aros_target_arch="pp"
858         aros_shared_default="no"
859         case "$target_cpu" in
860             *m68k*)
861                 aros_target_cpu="m68k"
862                 aros_object_format="m68kelf"
863                 aros_flavour="palmnative"
864                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
865                 aros_kernel_ldflags=""
866                 aros_default_wbwidth=160
867                 aros_default_wbheight=160
868                 aros_default_wbdepth=1
869                 aros_target_cc="m68k-elf-gcc -pipe"
870                 aros_target_ld="$(which m68k-elf-ld)"
871                 aros_target_as="m68k-elf-gcc -pipe"
872                 aros_shared_ld="m68k-elf-gcc"
873                 aros_kernel_ld="m68k-elf-gcc"
874                 aros_target_ar="m68k-elf-ar"
875                 aros_target_ar_flags="cru"
876                 aros_target_ranlib="m68k-elf-ranlib"
877                 aros_target_nm="m68k-elf-nm"
878                 aros_target_objcopy="m68k-elf-objcopy"
879                 aros_target_objdump="m68k-elf-objdump"
880                 aros_compiler_libs="-lgcc1"
881                 aros_shared_default=no
882                 aros_shared_cflags="-fpic"
883                 aros_shared_aflags=""
884                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
885                 aros_kernel_ldflags="-Wl,-rpath,./lib"
886                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
887                 aros_debug_aflags=""
888                 aros_debug_ldflags="$aros_symbols_debug"
889                 aros_mungwall_debug="0"
890                 aros_modules_debug="0"
891                 gcc_target_cpu="mc68000"
892                 ignore_undefined_symbols="-ius"
893                 ;;
894            *)
895                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
896                 ;;
897         esac
898         ;;
900     mac*)
901         aros_target_arch="mac"
902         aros_shared_default="no"
903         case "$target_cpu" in
904             *m68k*)
905                 aros_target_cpu="m68k"
906                 aros_object_format="m68kelf"
907                 aros_flavour="mac68knative"
908                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
909                 aros_default_wbwidth=512
910                 aros_default_wbheight=384
911                 aros_default_wbdepth=8
912                 aros_target_cc="m68k-elf-gcc -pipe"
913                 aros_target_ld="$(which m68k-elf-ld)"
914                 aros_target_as="m68k-elf-gcc -pipe"
915                 aros_shared_ld="m68k-elf-gcc"
916                 aros_kernel_ld="m68k-elf-gcc"
917                 aros_target_ar="m68k-elf-ar"
918                 aros_target_ar_flags="cru"
919                 aros_target_ranlib="m68k-elf-ranlib"
920                 aros_target_nm="m68k-elf-nm"
921                 aros_target_objcopy="m68k-elf-objcopy"
922                 aros_target_objdump="m68k-elf-objdump"
923                 aros_compiler_libs="-lgcc1"
924                 aros_shared_default=no
925                 aros_shared_cflags="-fpic"
926                 aros_shared_aflags=""
927                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
928                 aros_kernel_ldflags="-Wl,-rpath,./lib"
929                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000"
930                 aros_debug_aflags=""
931                 aros_debug_ldflags="$aros_symbols_debug"
932                 aros_mungwall_debug="0"
933                 aros_modules_debug="0"
934                 gcc_target_cpu="mc68000"
935                 ignore_undefined_symbols="-ius"
936                 ;;
937            *)
938                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
939                 ;;
940         esac
941         ;;
943     *)
944         AC_MSG_ERROR([Unsupported target architecture $target])
945         ;;
946 esac
949 # Find out if we are cross-compiling (ie. if we can't use the host compiler
950 # for target code)
951 cross_compiling=no
952 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
953     cross_compiling=yes
955 if test "$aros_host_arch" == "darwin" ; then
956     cross_compiling=yes
959 # Set prefix for target compiler etc. if we're cross-compiling
960 # (should possibly be earlier but needs to be after AC_PROG_CC)
961 if test "$cross_compiling" = "yes" ; then
962     target_tool_prefix=${target_cpu}-elf-
963     CC=${target_tool_prefix}gcc
966 # Find all the tools we need to compile. This could be cross-compiling
967 # though! If that is the case we use the GNU form of the target and
968 # simply add this to the front of the binary name. This is rather simple,
969 # but it should work under most circumstances.
971 # The default tools are to use the same as the host, but only if the
972 # host and target CPU are the same. With GCC this is normally enough.
975 aros_cc_pre=""
976 aros_shared_ld="$aros_host_ld"
978 aros_target_mkdep="$aros_host_mkdep"
979 aros_target_incl_def="$aros_host_incl"
981 AC_PATH_PROG(aros_kernel_cc,$CC)
983 # The default tools executables to be linked to.
984 AROS_TOOL_TARGET(aros_target_as_ln,as)
985 AROS_REQUIRED(as,$aros_target_as_ln)
986 AROS_TOOL_TARGET(aros_kernel_ld,ld)
987 AROS_REQUIRED(ld,$aros_kernel_ld)
988 AROS_TOOL_TARGET(aros_target_ar_ln,ar)
989 AROS_REQUIRED(ar,$aros_target_ar_ln)
990 AROS_TOOL_TARGET(aros_target_nm_ln,nm)
991 AROS_REQUIRED(nm,$aros_target_nm_ln)
992 AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy)
993 AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
994 AROS_TOOL_TARGET(aros_target_objdump_ln,objdump)
995 AROS_REQUIRED(objdump,$aros_target_objdump_ln)
996 AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib)
997 AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
998 AROS_TOOL_TARGET(aros_target_strip_ln,strip)
999 AROS_REQUIRED(strip,$aros_target_strip_ln)
1001 if test "$GCC" = "yes"; then
1002     aros_target_cc_path=`$aros_kernel_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1005 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1006 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1007 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1008 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1009 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1010 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1011 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1013 # aros_cc_pre is a variable that is added to the front of the compiler name
1014 # in the generated aros-gcc shell script. We need this to enable the cache
1015 # to work across cleaned builds. Also, support DISTCC using the correct
1016 # environment variable.
1019 if test "x${DISTCC}" != "x" ; then
1020     if test "x${CCACHE}" != "x" ; then
1021         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1022     else
1023         aros_cc_pre="${DISTCC} "
1024     fi
1025 else
1026     if test "x${CCACHE}" != "x" ; then
1027         aros_cc_pre="${CCACHE} "
1028     fi
1031 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1033 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1034 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1035 AC_SUBST(aros_target_nix_ldflags,-nix)
1036 AC_SUBST(aros_target_detach_ldflags,-detach)
1037 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1039 # Target tools
1040 aros_target_cc="${prefix}-gcc"
1041 aros_target_as="${prefix}-as"
1042 aros_target_ld="${prefix}-ld"
1043 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1044 aros_target_objcopy=${prefix}-objcopy
1045 aros_target_objdump=${prefix}-objdump
1046 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1047 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1048 aros_kernel_nm="${prefix}-nm"
1049 aros_target_strip=${prefix}-strip
1052 # Find the system include path. We can suggest that an alternative is
1053 # used if we don't get it correct. The default is to use /usr/include.
1054 # Which is set in the aros_target_incl_def variable.
1056 AC_ARG_ENABLE(includes,
1057 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1058 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1060 dnl find out about the target cc's include path
1061 AC_MSG_CHECKING([for the target compiler's include path])
1062 if test "$aros_target_cc_includes" = "" ; then
1063     #try to guess where the directory is
1064     aros_target_cc_includes=`dirname \`${aros_kernel_cc} -print-libgcc-file-name\``/include
1065     if ! test -d $aros_target_cc_includes; then
1066         #the directory doesn't exist, we need to do some more work
1067         aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1068         
1069         #these are the headers we're looling for
1070         headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1071                  stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1072                  zutil.h"
1074         dirs=
1075         for h in $headers; do
1076             #which other headers each of the above headers needs?
1077             deps=$(echo "#include <$h>" | \
1078                    $aros_host_cc -E -M - 2>/dev/null | \
1079                    sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1080             
1081             #copy all the needed headers to a directory beneath gendir
1082             for d in $deps; do
1083                 h=$(basename $d)
1084                 dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1085                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1086                 ! test -d $dir && mkdir -p $dir
1087                 ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1088             done
1089         done        
1090     fi
1092 AC_MSG_RESULT($aros_target_cc_includes)
1094 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
1095 AC_MSG_CHECKING([for default resolution of WBScreen])
1096 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
1097 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
1098 if test "$resolution" = "yes" ; then
1099     resolution="none"
1101 if test "$resolution" = "no" ; then
1102     resolution="none"
1104 if test "$resolution" != "none" ; then
1105     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
1106     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
1107     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
1109 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
1110 aros_cv_default_wbwidth=$aros_default_wbwidth
1111 aros_cv_default_wbheight=$aros_default_wbheight
1112 aros_cv_default_wbdepth=$aros_default_wbdepth
1114 dnl See if the user wants the BOCHS hack for native flavour
1115 AC_MSG_CHECKING([if bochs hack is enabled])
1116 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")
1117 if test "$bochs_hack" = "yes" ; then
1118     aros_bochs_hack="1"
1120 AC_MSG_RESULT($bochs_hack)
1122 dnl See if the user wants the serial debug output for native flavour
1123 AC_MSG_CHECKING([if serial debug is enabled])
1124 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)
1125 if test "$serial_debug" = "yes" ; then
1126     serial_debug="2"
1128 if test "$serial_debug" = "no" ; then
1129     serial_debug="none"
1131 if test "$serial_debug" != "none" ; then
1132     aros_serial_debug=$serial_debug
1133     AC_MSG_RESULT(on port $serial_debug)
1134 else
1135     AC_MSG_RESULT(no)
1138 dnl See if the user wants the palm debug output hack for palm native flavour
1139 AC_MSG_CHECKING([if palm debug hack is enabled])
1140 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")
1141 if test "$palm_debug_hack" = "yes" ; then
1142     aros_palm_debug_hack="1"
1144 AC_MSG_RESULT($palm_debug_hack)
1147 dnl See if the user wants nesting supervisor activated for unix flavour
1148 AC_MSG_CHECKING([if nesting supervisor support is enabled])
1149 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")
1150 if test "$nesting_supervisor" = "yes" ; then
1151     aros_nesting_supervisor="1"
1153 AC_MSG_RESULT($nesting_supervisor)
1156 dnl things specifically required for hosted flavours
1157 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1159     dnl some kind of dynamic library access system is required for hostlib.resource
1160     AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
1161     if test "x-$have_dl" = "x-no" ; then
1162         AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
1163                                   aros_host_ldflags="$aros_host_ldflags -ldl"],
1164                                  have_dl="no")
1165     fi
1166     if test "x-$have_dl" = "x-no" ; then
1167          AC_MSG_ERROR([dlopen() dynamic linker functions not available])
1168     fi
1171     dnl x11 hidd
1172     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
1173                                            [build X11 hidd for hosted (default=auto)]),
1174                                            x11_hidd="$enableval",
1175                                            x11_hidd="auto")
1176     case "x-$x11_hidd" in
1177         x-yes|x-no|x-auto)                 ;;
1178         *)                 x11_hidd="auto" ;;
1179     esac
1181     dnl they want it
1182     if test "x-$x11_hidd" != "x-no" ; then
1184         dnl find x11 stuff
1185         AC_PATH_X
1187         if test "x-$no_x" = "x-yes" ; then
1189             dnl didn't find it
1190             if test "x-$x11_hidd" != "x-auto" ; then
1191                 dnl and they explicitly asked for it, bail out
1192                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
1193             fi
1194         
1195         else
1196             dnl found it, setup the metatarget
1197             x11_hidd_target=kernel-x11gfx
1200             dnl setup shared memory extensions
1201             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
1202                                                   [use X11 shared memory (default=auto)]),
1203                                                   x11_hidd_shm="$enableval",
1204                                                   x11_hidd_shm="auto")
1205             case "x-$x11_hidd_shm" in
1206                 x-yes|x-no|x-auto)                     ;;
1207                 *)                 x11_hidd_shm="auto" ;;
1208             esac
1210             have_xshm=no
1212             dnl they want it
1213             if test "x-$x11_hidd_shm" != "x-no" ; then
1215                 dnl system shm headers
1216                 AC_CHECK_HEADERS(sys/ipc.h)
1217                 AC_CHECK_HEADERS(sys/shm.h)
1219                 dnl got them
1220                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
1222                     dnl make sure X libs have shm functions
1223                     save_libs="$LIBS"
1224                     save_cflags="$CFLAGS"
1225                     LIBS="$x_libraries"
1226                     CFLAGS="$x_includes"
1227                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
1228                     LIBS="$save_libs"
1229                     CFLAGS="$save_cflags"
1230                 fi
1231             fi
1233             dnl detection done, prepare output
1234             if test "x-$have_xshm" = "x-yes" ; then
1235                 dnl we can do shm
1236                 DO_XSHM_SUPPORT="1"
1237             elif test "x-$x11_hidd_shm" = "x-yes" ; then
1238                 dnl they explicitly asked for it, but we can't do it
1239                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
1240             else
1241                 dnl otherwise just disable it
1242                 DO_XSHM_SUPPORT="0"
1243             fi
1245             
1246             dnl setup vidmode (fullscreen) extensions
1247             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
1248                                                       [use X11 vidmode extension (default=auto)]),
1249                                                       x11_hidd_vidmode="$enableval",
1250                                                       x11_hidd_vidmode="auto")
1251             case "x-$x11_hidd_vidmode" in
1252                 x-yes|x-no|x-auto)                         ;;
1253                 *)                 x11_hidd_vidmode="auto" ;;
1254             esac
1256             have_vidmode=no
1258             dnl they want it
1259             if test "x-$x11_hidd_vidmode" != "x-no" ; then
1261                 dnl make sure X libs have vidmode functions
1262                 save_libs="$LIBS"
1263                 save_cflags="$CFLAGS"
1264                 LIBS="$x_libraries"
1265                 CFLAGS="$x_includes"
1266                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
1267                 LIBS="$save_libs"
1268                 CFLAGS="$save_cflags"
1269             fi
1271             dnl detection done, prepare output
1272             if test "x-$have_vidmode" = "x-yes" ; then
1273                 dnl we can do vidmode
1274                 DO_VIDMODE_SUPPORT="1"
1275             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
1276                 dnl they explicitly asked for it, but we can't do it
1277                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
1278             else
1279                 dnl otherwise just disable it
1280                 DO_VIDMODE_SUPPORT="0"
1281             fi
1282         fi
1284         aros_host_x11_includes=$x_includes 
1285         aros_host_x11_libdirs=$x_libraries
1286     fi
1289     dnl sdl hidd
1290     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
1291                                            [build SDL hidd for hosted (default=auto)]),
1292                                            sdl_hidd="$enableval",
1293                                            sdl_hidd="auto")
1294     case "x-$sdl_hidd" in
1295         x-yes|x-no|x-auto)                 ;;
1296         *)                 sdl_hidd="auto" ;;
1297     esac
1299     dnl they want it
1300     if test "x-$sdl_hidd" != "x-no" ; then
1302         dnl find sdl
1303         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
1305         if test "x-$have_sdl" != "x-yes" ; then
1307             dnl didn't find it
1308             if test "x-$sdl_hidd" != "x-auto" ; then
1309                 dnl and they explicitly asked for it, bail out
1310                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
1311             fi
1313         else
1314             dnl found it, setup the metatarget
1315             sdl_hidd_target=kernel-hidd-sdl
1316             aros_host_sdl_cflags=SDL_CFLAGS
1317             aros_host_sdl_libs=SDL_LIBS
1318         fi
1319     fi
1324 dnl See if the user wants dbus.library
1325 AC_MSG_CHECKING([if building of dbus.library is enabled])
1326 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
1327 if test "$dbus" = "yes" ; then
1328     ENABLE_DBUS=1
1329     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
1330     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
1331     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
1332     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
1333 else
1334     ENABLE_DBUS=0
1336 AC_MSG_RESULT($dbus)
1339 dnl --------------------------------------------------------------------
1340 dnl Configuration Output Section
1341 dnl --------------------------------------------------------------------
1343 # Generic
1344 AC_SUBST(aros_arch)
1345 AC_SUBST(aros_cpu)
1346 AC_SUBST(aros_flavour)
1347 AC_SUBST(aros_flavour_uc)
1348 AC_SUBST(TOPDIR)
1350 # Host related
1351 AC_SUBST(aros_cc_pre)
1352 AC_SUBST(aros_host_strip)
1353 AC_SUBST(aros_host_arch)
1354 AC_SUBST(aros_host_cpu)
1355 AC_SUBST(aros_host_cc)
1356 AC_SUBST(aros_host_ar)
1357 AC_SUBST(aros_host_ranlib)
1358 AC_SUBST(aros_host_ld)
1359 AC_SUBST(aros_host_make)
1360 AC_SUBST(aros_host_cflags)
1361 AC_SUBST(aros_host_ldflags)
1362 AC_SUBST(aros_host_debug)
1363 AC_SUBST(aros_host_mkdep)
1364 AC_SUBST(aros_host_mkargs)
1365 AC_SUBST(aros_host_exe_suffix)
1366 AC_SUBST(aros_host_lib_suffix)
1367 AC_SUBST(aros_tools_dir)
1368 AC_SUBST(aros_host_aclocal)
1369 AC_SUBST(aros_host_autoconf)
1370 AC_SUBST(aros_host_autoheader)
1371 AC_SUBST(aros_host_automake)
1373 # Target Related
1374 AC_SUBST(aros_target_arch)
1375 AC_SUBST(aros_target_cpu)
1376 AC_SUBST(aros_target_variant)
1377 AC_SUBST(aros_target_suffix)
1378 AC_SUBST(aros_target_incl)
1379 AC_SUBST(aros_target_ar)
1380 AC_SUBST(aros_target_ranlib)
1381 AC_SUBST(aros_kernel_nm)
1382 AC_SUBST(aros_target_cc)
1383 AC_SUBST(aros_kernel_cc)
1384 AC_SUBST(aros_target_as)
1385 AC_SUBST(aros_target_ld)
1386 AC_SUBST(aros_kernel_ld)
1387 AC_SUBST(aros_target_cc_includes)
1388 AC_SUBST(aros_target_cc_path)
1389 AC_SUBST(aros_target_objdump)
1390 AC_SUBST(aros_target_objcopy)
1391 AC_SUBST(aros_target_strip)
1392 AC_SUBST(aros_target_nm)
1393 AC_SUBST(aros_shared_default)
1394 AC_SUBST(aros_shared_ld)
1395 AC_SUBST(aros_object_format)
1396 AC_SUBST(aros_compiler_libs)
1398 AC_SUBST(aros_config_cflags)
1399 AC_SUBST(aros_config_aflags)
1400 AC_SUBST(aros_config_ldflags)
1402 AC_SUBST(aros_shared_cflags)
1403 AC_SUBST(aros_shared_aflags)
1404 AC_SUBST(aros_shared_ldflags)
1405 AC_SUBST(aros_kernel_ldflags)
1406 AC_SUBST(aros_debug_cflags)
1407 AC_SUBST(aros_debug_aflags)
1408 AC_SUBST(aros_debug_ldflags)
1409 AC_SUBST(aros_target_genmap)
1410 AC_SUBST(aros_target_strip_flags)
1412 # Graphics Related
1413 AC_SUBST(x11_hidd_target)
1414 AC_SUBST(sdl_hidd_target)
1416 AC_SUBST(aros_default_wbwidth)
1417 AC_SUBST(aros_default_wbheight)
1418 AC_SUBST(aros_default_wbdepth)
1419 AC_SUBST(DO_XSHM_SUPPORT)
1420 AC_SUBST(DO_VIDMODE_SUPPORT)
1422 AC_SUBST(aros_host_x11_includes)
1423 AC_SUBST(aros_host_x11_libdirs)
1424 AC_SUBST(aros_host_sdl_cflags)
1425 AC_SUBST(aros_host_sdl_libs)
1427 # Native version related
1428 AC_SUBST(aros_bochs_hack)
1429 AC_SUBST(aros_serial_debug)
1431 # Palm native version related
1432 AC_SUBST(aros_palm_debug_hack)
1434 # Unix/Hosted version related
1435 AC_SUBST(aros_nesting_supervisor)
1437 # DBUS related
1438 AC_SUBST(ENABLE_DBUS)
1439 AC_SUBST(DBUS_CFLAGS)
1440 AC_SUBST(DBUS_LIBFLAGS)
1441 AC_SUBST(KERNEL_DBUS_KOBJ)
1442 AC_SUBST(KERNEL_DBUS_INCLUDES)
1444 # Debug related
1445 AC_SUBST(aros_debug)
1446 AC_SUBST(aros_mungwall_debug)
1447 AC_SUBST(aros_stack_debug)
1448 AC_SUBST(aros_modules_debug)
1450 # Collect-aros stuff: "-ius" to ignore undefined symbols
1451 AC_SUBST(ignore_undefined_symbols)
1453 # C compiler related
1454 AC_SUBST(gcc_target_cpu)
1456 dnl Prepare for output, make up all the generated patches
1457 case "$aros_flavour" in
1458 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
1459                 aros_flavour="emulation" ;;
1460 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
1461                 aros_flavour="emulation" ;;
1462 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
1463                 aros_flavour="standalone";;
1464 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
1465                 aros_flavour="native" ;;
1466 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1467                 aros_flavour="native" ;;
1468 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
1469                 aros_flavour="linklib" ;;
1470 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1471                 aros_flavour="palmnative" ;;
1472 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1473                 aros_flavour="mac68knative" ;;
1474 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1475                 aros_flavour="ppcnative" ;;
1476 esac
1478 if test ! -d ${aros_inc_dir} ; then
1479     ${MKDIR} ${aros_inc_dir}
1481 if test ! -d ${aros_geninc_dir} ; then
1482     ${MKDIR} ${aros_geninc_dir}
1484 if test ! -d ${aros_hostcfg_dir} ; then
1485     ${MKDIR} ${aros_hostcfg_dir}
1487 if test ! -d ${aros_targetcfg_dir} ; then
1488     ${MKDIR} ${aros_targetcfg_dir}
1490 if test ! -d ${aros_tools_dir} ; then
1491     ${MKDIR} ${aros_tools_dir}
1493 if test ! -d ${aros_scripts_dir} ; then
1494     ${MKDIR} ${aros_scripts_dir}
1497 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
1499 AC_CONFIG_COMMANDS([compiler_executable],
1500     [
1501         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
1502         mkdir -p $prefix
1503         prefix="${prefix}/${aros_target_cpu}-aros"
1504         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
1506         echo ${prefix}
1507         echo ${prefix2}
1508         chmod a+x ${prefix2}-gcc ${prefix2}-ld
1510         ln -sf ${prefix2}-gcc          ${prefix}-gcc
1511         ln -sf ${prefix2}-ld           ${prefix}-ld
1513         ln -sf $aros_target_as_ln      ${prefix}-as
1514         ln -sf $aros_target_nm_ln      ${prefix}-nm
1515         ln -sf $aros_target_ar_ln      ${prefix}-ar
1516         ln -sf $aros_target_ranlib_ln  ${prefix}-ranlib
1517         ln -sf $aros_target_objcopy_ln ${prefix}-objcopy
1518         ln -sf $aros_target_objdump_ln ${prefix}-objdump
1519         ln -sf $aros_target_strip_ln   ${prefix}-strip
1521         ln -sf $aros_target_as_ln      ${prefix2}-as
1522         ln -sf $aros_target_nm_ln      ${prefix2}-nm
1523         ln -sf $aros_target_ar_ln      ${prefix2}-ar
1524         ln -sf $aros_target_ranlib_ln  ${prefix2}-ranlib
1525         ln -sf $aros_target_objcopy_ln ${prefix2}-objcopy
1526         ln -sf $aros_target_objdump_ln ${prefix2}-objdump
1527         ln -sf $aros_target_strip_ln   ${prefix2}-strip
1528     ],
1529     [
1530         aros_tools_dir=${aros_tools_dir}
1531         aros_target_cpu=${aros_target_cpu}
1532         aros_target_arch=${aros_target_arch}
1533         aros_target_suffix=${aros_target_suffix}
1534         aros_target_nm_ln=${aros_target_nm_ln}
1535         aros_target_as_ln=${aros_target_as_ln}
1536         aros_target_ar_ln=${aros_target_ar_ln}
1537         aros_target_ranlib_ln=${aros_target_ranlib_ln}
1538         aros_target_objdump_ln=${aros_target_objdump_ln}
1539         aros_target_objcopy_ln=${aros_target_objcopy_ln}
1540         aros_target_strip_ln=${aros_target_strip_ln}
1541     ]
1543 AC_CONFIG_COMMANDS([genshared_executable],
1544     [chmod a+x ${aros_scripts_dir}/genshared],
1545     [aros_scripts_dir=${aros_scripts_dir}]
1547 AC_CONFIG_COMMANDS([genmf_executable],
1548     [chmod a+x ${aros_tools_dir}/genmf.py],
1549     [aros_tools_dir=${aros_tools_dir}]
1551 AC_CONFIG_COMMANDS([adflib_myaros.conf_executable],
1552     [chmod a+x tools/adflib/myconf.aros]
1555 AC_CONFIG_FILES(
1556     Makefile
1557     rom/mmakefile
1558     ${aros_inc_dir}/config.h:config/config.h.in
1559     ${aros_geninc_dir}/config.h:config/config.h.in
1560     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
1561     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
1562     mmake.config
1563     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
1564     ${aros_targetcfg_dir}/specs:config/specs.in
1565     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
1566     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
1567     ${aros_scripts_dir}/genshared:compiler/c_lib/source/lib_source/genshared.in
1568     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
1569     tools/adflib/myconf.aros
1570     tools/collect-aros/env.h
1573 AC_OUTPUT
1575 dnl This is in order to not define SHARED_CFLAGS sometimes
1576 dnl We don't always do aros_shared_ar, aros_shared_cflags
1578 #XXX compatability...
1579 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
1581 if test -n "$aros_shared_cflags" ; then
1582     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
1583     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg