- Properly differenciate between Work partition and partition Extras are
[cake.git] / configure.in
blob9901f8af1b0c2ff3a74981638754256739388385
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     sam440)
795         aros_target_arch="sam440"
796         aros_shared_default="no"
797         aros_target_cpu="ppc"
798         aros_object_format="elf32ppc"
799         aros_flavour="ppcnative"
800         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
801         aros_kernel_ldflags=""
802         aros_default_wbwidth=640
803         aros_default_wbheight=480
804         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
805         gcc_target_cpu="powerpc"
806         case "$target_cpu" in
807             *powerpc*)
808                 aros_target_cc="powerpc-linux-gcc -pipe"
809                 aros_target_ld="powerpc-linux-ld"
810                 aros_target_as="powerpc-linux-as"
811                 aros_target_ar="powerpc-linux-ar"
812                 aros_target_ranlib="powerpc-linux-ranlib"
813                 aros_target_nm="powerpc-linux-nm"
814                 aros_target_strip="powerpc-linux-strip"
815                 aros_target_objcopy="powerpc-linux-objcopy"
816                 aros_target_objdump="pwoerpc-linux-objdump"
817                 aros_shared_ld="powerpc-linux-ld"
818                 aros_kernel_ld="powerpc-linux-ld"
819                 ;;
820             *)
821                 ;;
822         esac
823         ;;
825     amiga*)
826         aros_target_arch="amiga"
827         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
828         aros_shared_default="no"
830         aros_config_cflags="$aros_config_cflags -fomit-frame-pointer -fbuiltin -ffreestanding"
832         case "$target_cpu" in
833             *m68k*)
834                 aros_target_cpu="m68k"
835                 aros_object_format="m68kelf"
836                 aros_flavour="nativecompat"
837                 gcc_target_cpu="mc68000"
838                 ;;
839             *ppc*)
840                 aros_cpu="ppc"
841                 aros_flavour="native"
842                 gcc_target_cpu="ppc"
843                 ;;
844             *)
845                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
846                 ;;
847         esac
848         ;;
850     cygwin*)
851         aros_target_arch="cygwin"
852         aros_shared_default="no"
853         case "$target_cpu" in
854             *i?86*)
855                 aros_target_cpu="i386"
856                 aros_object_format="elf_i386"
857                 aros_flavour="emulation"
858                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
859                 aros_shared_cflags=""
860                 aros_default_wbdepth=8
861                 gcc_target_cpu="i386"
862                 ;;
863             *)
864                 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
865                 ;;
866         esac
867     ;;
869     mingw32*)
870         aros_target_arch="mingw32"
871         aros_shared_default="no"
872         case "$target_cpu" in
873             *i?86*)
874                 aros_target_cpu="i386"
875                 aros_object_format="elf_i386"
876                 aros_flavour="emulation"
877                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
878                 aros_shared_cflags=""
879                 aros_default_wbdepth=8
880                 gcc_target_cpu="i386"
881                 ;;
882             *)
883                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
884                 ;;
885         esac
886     ;;
887     pp*)
888         aros_target_arch="pp"
889         aros_shared_default="no"
890         case "$target_cpu" in
891             *m68k*)
892                 aros_target_cpu="m68k"
893                 aros_object_format="m68kelf"
894                 aros_flavour="palmnative"
895                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
896                 aros_kernel_ldflags=""
897                 aros_default_wbwidth=160
898                 aros_default_wbheight=160
899                 aros_default_wbdepth=1
900                 aros_target_cc="m68k-elf-gcc -pipe"
901                 aros_target_ld="$(which m68k-elf-ld)"
902                 aros_target_as="m68k-elf-gcc -pipe"
903                 aros_shared_ld="m68k-elf-gcc"
904                 aros_kernel_ld="m68k-elf-gcc"
905                 aros_target_ar="m68k-elf-ar"
906                 aros_target_ar_flags="cru"
907                 aros_target_ranlib="m68k-elf-ranlib"
908                 aros_target_nm="m68k-elf-nm"
909                 aros_target_objcopy="m68k-elf-objcopy"
910                 aros_target_objdump="m68k-elf-objdump"
911                 aros_compiler_libs="-lgcc1"
912                 aros_shared_default=no
913                 aros_shared_cflags="-fpic"
914                 aros_shared_aflags=""
915                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
916                 aros_kernel_ldflags="-Wl,-rpath,./lib"
917                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
918                 aros_debug_aflags=""
919                 aros_debug_ldflags="$aros_symbols_debug"
920                 aros_mungwall_debug="0"
921                 aros_modules_debug="0"
922                 gcc_target_cpu="mc68000"
923                 ignore_undefined_symbols="-ius"
924                 ;;
925            *)
926                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
927                 ;;
928         esac
929         ;;
931     mac*)
932         aros_target_arch="mac"
933         aros_shared_default="no"
934         case "$target_cpu" in
935             *m68k*)
936                 aros_target_cpu="m68k"
937                 aros_object_format="m68kelf"
938                 aros_flavour="mac68knative"
939                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
940                 aros_default_wbwidth=512
941                 aros_default_wbheight=384
942                 aros_default_wbdepth=8
943                 aros_target_cc="m68k-elf-gcc -pipe"
944                 aros_target_ld="$(which m68k-elf-ld)"
945                 aros_target_as="m68k-elf-gcc -pipe"
946                 aros_shared_ld="m68k-elf-gcc"
947                 aros_kernel_ld="m68k-elf-gcc"
948                 aros_target_ar="m68k-elf-ar"
949                 aros_target_ar_flags="cru"
950                 aros_target_ranlib="m68k-elf-ranlib"
951                 aros_target_nm="m68k-elf-nm"
952                 aros_target_objcopy="m68k-elf-objcopy"
953                 aros_target_objdump="m68k-elf-objdump"
954                 aros_compiler_libs="-lgcc1"
955                 aros_shared_default=no
956                 aros_shared_cflags="-fpic"
957                 aros_shared_aflags=""
958                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
959                 aros_kernel_ldflags="-Wl,-rpath,./lib"
960                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000"
961                 aros_debug_aflags=""
962                 aros_debug_ldflags="$aros_symbols_debug"
963                 aros_mungwall_debug="0"
964                 aros_modules_debug="0"
965                 gcc_target_cpu="mc68000"
966                 ignore_undefined_symbols="-ius"
967                 ;;
968            *)
969                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
970                 ;;
971         esac
972         ;;
974     *)
975         AC_MSG_ERROR([Unsupported target architecture $target])
976         ;;
977 esac
980 # Find out if we are cross-compiling (ie. if we can't use the host compiler
981 # for target code)
982 cross_compiling=no
983 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
984     cross_compiling=yes
986 if test "$aros_host_arch" == "darwin" ; then
987     cross_compiling=yes
990 # Set prefix for target compiler etc. if we're cross-compiling
991 # (should possibly be earlier but needs to be after AC_PROG_CC)
992 if test "$cross_compiling" = "yes" ; then
993     target_tool_prefix=${target_cpu}-elf-
994     CC=${target_tool_prefix}gcc
997 # Find all the tools we need to compile. This could be cross-compiling
998 # though! If that is the case we use the GNU form of the target and
999 # simply add this to the front of the binary name. This is rather simple,
1000 # but it should work under most circumstances.
1002 # The default tools are to use the same as the host, but only if the
1003 # host and target CPU are the same. With GCC this is normally enough.
1006 aros_cc_pre=""
1007 aros_shared_ld="$aros_host_ld"
1009 aros_target_mkdep="$aros_host_mkdep"
1010 aros_target_incl_def="$aros_host_incl"
1012 AC_PATH_PROG(aros_kernel_cc,$CC)
1014 # The default tools executables to be linked to.
1015 AROS_TOOL_TARGET(aros_target_as_ln,as)
1016 AROS_REQUIRED(as,$aros_target_as_ln)
1017 AROS_TOOL_TARGET(aros_kernel_ld,ld)
1018 AROS_REQUIRED(ld,$aros_kernel_ld)
1019 AROS_TOOL_TARGET(aros_target_ar_ln,ar)
1020 AROS_REQUIRED(ar,$aros_target_ar_ln)
1021 AROS_TOOL_TARGET(aros_target_nm_ln,nm)
1022 AROS_REQUIRED(nm,$aros_target_nm_ln)
1023 AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy)
1024 AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
1025 AROS_TOOL_TARGET(aros_target_objdump_ln,objdump)
1026 AROS_REQUIRED(objdump,$aros_target_objdump_ln)
1027 AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib)
1028 AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
1029 AROS_TOOL_TARGET(aros_target_strip_ln,strip)
1030 AROS_REQUIRED(strip,$aros_target_strip_ln)
1032 if test "$GCC" = "yes"; then
1033     aros_target_cc_path=`$aros_kernel_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1036 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1037 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1038 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1039 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1040 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1041 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1042 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1044 # aros_cc_pre is a variable that is added to the front of the compiler name
1045 # in the generated aros-gcc shell script. We need this to enable the cache
1046 # to work across cleaned builds. Also, support DISTCC using the correct
1047 # environment variable.
1050 if test "x${DISTCC}" != "x" ; then
1051     if test "x${CCACHE}" != "x" ; then
1052         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1053     else
1054         aros_cc_pre="${DISTCC} "
1055     fi
1056 else
1057     if test "x${CCACHE}" != "x" ; then
1058         aros_cc_pre="${CCACHE} "
1059     fi
1062 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1064 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1065 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1066 AC_SUBST(aros_target_nix_ldflags,-nix)
1067 AC_SUBST(aros_target_detach_ldflags,-detach)
1068 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1070 # Target tools
1071 aros_target_cc="${prefix}-gcc"
1072 aros_target_as="${prefix}-as"
1073 aros_target_ld="${prefix}-ld"
1074 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1075 aros_target_objcopy=${prefix}-objcopy
1076 aros_target_objdump=${prefix}-objdump
1077 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1078 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1079 aros_kernel_nm="${prefix}-nm"
1080 aros_target_strip=${prefix}-strip
1083 # Find the system include path. We can suggest that an alternative is
1084 # used if we don't get it correct. The default is to use /usr/include.
1085 # Which is set in the aros_target_incl_def variable.
1087 AC_ARG_ENABLE(includes,
1088 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1089 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1091 dnl find out about the target cc's include path
1092 AC_MSG_CHECKING([for the target compiler's include path])
1093 if test "$aros_target_cc_includes" = "" ; then
1094     #try to guess where the directory is
1095     aros_target_cc_includes=`dirname \`${aros_kernel_cc} -print-libgcc-file-name\``/include
1096     if ! test -d $aros_target_cc_includes; then
1097         #the directory doesn't exist, we need to do some more work
1098         aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1099         
1100         #these are the headers we're looling for
1101         headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1102                  stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1103                  zutil.h"
1105         dirs=
1106         for h in $headers; do
1107             #which other headers each of the above headers needs?
1108             deps=$(echo "#include <$h>" | \
1109                    $aros_host_cc -E -M - 2>/dev/null | \
1110                    sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1111             
1112             #copy all the needed headers to a directory beneath gendir
1113             for d in $deps; do
1114                 h=$(basename $d)
1115                 dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1116                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1117                 ! test -d $dir && mkdir -p $dir
1118                 ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1119             done
1120         done        
1121     fi
1123 AC_MSG_RESULT($aros_target_cc_includes)
1125 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
1126 AC_MSG_CHECKING([for default resolution of WBScreen])
1127 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
1128 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
1129 if test "$resolution" = "yes" ; then
1130     resolution="none"
1132 if test "$resolution" = "no" ; then
1133     resolution="none"
1135 if test "$resolution" != "none" ; then
1136     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
1137     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
1138     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
1140 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
1141 aros_cv_default_wbwidth=$aros_default_wbwidth
1142 aros_cv_default_wbheight=$aros_default_wbheight
1143 aros_cv_default_wbdepth=$aros_default_wbdepth
1145 dnl See if the user wants the BOCHS hack for native flavour
1146 AC_MSG_CHECKING([if bochs hack is enabled])
1147 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")
1148 if test "$bochs_hack" = "yes" ; then
1149     aros_bochs_hack="1"
1151 AC_MSG_RESULT($bochs_hack)
1153 dnl See if the user wants the serial debug output for native flavour
1154 AC_MSG_CHECKING([if serial debug is enabled])
1155 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)
1156 if test "$serial_debug" = "yes" ; then
1157     serial_debug="2"
1159 if test "$serial_debug" = "no" ; then
1160     serial_debug="none"
1162 if test "$serial_debug" != "none" ; then
1163     aros_serial_debug=$serial_debug
1164     AC_MSG_RESULT(on port $serial_debug)
1165 else
1166     AC_MSG_RESULT(no)
1169 dnl See if the user wants the palm debug output hack for palm native flavour
1170 AC_MSG_CHECKING([if palm debug hack is enabled])
1171 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")
1172 if test "$palm_debug_hack" = "yes" ; then
1173     aros_palm_debug_hack="1"
1175 AC_MSG_RESULT($palm_debug_hack)
1178 dnl See if the user wants nesting supervisor activated for unix flavour
1179 AC_MSG_CHECKING([if nesting supervisor support is enabled])
1180 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")
1181 if test "$nesting_supervisor" = "yes" ; then
1182     aros_nesting_supervisor="1"
1184 AC_MSG_RESULT($nesting_supervisor)
1187 dnl things specifically required for hosted flavours
1188 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1190     dnl some kind of dynamic library access system is required for hostlib.resource
1191     AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
1192     if test "x-$have_dl" = "x-no" ; then
1193         AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
1194                                   aros_host_ldflags="$aros_host_ldflags -ldl"],
1195                                  have_dl="no")
1196     fi
1197     if test "x-$have_dl" = "x-no" ; then
1198          AC_MSG_ERROR([dlopen() dynamic linker functions not available])
1199     fi
1202     dnl x11 hidd
1203     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
1204                                            [build X11 hidd for hosted (default=auto)]),
1205                                            x11_hidd="$enableval",
1206                                            x11_hidd="auto")
1207     case "x-$x11_hidd" in
1208         x-yes|x-no|x-auto)                 ;;
1209         *)                 x11_hidd="auto" ;;
1210     esac
1212     dnl they want it
1213     if test "x-$x11_hidd" != "x-no" ; then
1215         dnl find x11 stuff
1216         AC_PATH_X
1218         if test "x-$no_x" = "x-yes" ; then
1220             dnl didn't find it
1221             if test "x-$x11_hidd" != "x-auto" ; then
1222                 dnl and they explicitly asked for it, bail out
1223                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
1224             fi
1225         
1226         else
1227             dnl found it, setup the metatarget
1228             x11_hidd_target=kernel-x11gfx
1231             dnl setup shared memory extensions
1232             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
1233                                                   [use X11 shared memory (default=auto)]),
1234                                                   x11_hidd_shm="$enableval",
1235                                                   x11_hidd_shm="auto")
1236             case "x-$x11_hidd_shm" in
1237                 x-yes|x-no|x-auto)                     ;;
1238                 *)                 x11_hidd_shm="auto" ;;
1239             esac
1241             have_xshm=no
1243             dnl they want it
1244             if test "x-$x11_hidd_shm" != "x-no" ; then
1246                 dnl system shm headers
1247                 AC_CHECK_HEADERS(sys/ipc.h)
1248                 AC_CHECK_HEADERS(sys/shm.h)
1250                 dnl got them
1251                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
1253                     dnl make sure X libs have shm functions
1254                     save_libs="$LIBS"
1255                     save_cflags="$CFLAGS"
1256                     LIBS="$x_libraries"
1257                     CFLAGS="$x_includes"
1258                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
1259                     LIBS="$save_libs"
1260                     CFLAGS="$save_cflags"
1261                 fi
1262             fi
1264             dnl detection done, prepare output
1265             if test "x-$have_xshm" = "x-yes" ; then
1266                 dnl we can do shm
1267                 DO_XSHM_SUPPORT="1"
1268             elif test "x-$x11_hidd_shm" = "x-yes" ; then
1269                 dnl they explicitly asked for it, but we can't do it
1270                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
1271             else
1272                 dnl otherwise just disable it
1273                 DO_XSHM_SUPPORT="0"
1274             fi
1276             
1277             dnl setup vidmode (fullscreen) extensions
1278             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
1279                                                       [use X11 vidmode extension (default=auto)]),
1280                                                       x11_hidd_vidmode="$enableval",
1281                                                       x11_hidd_vidmode="auto")
1282             case "x-$x11_hidd_vidmode" in
1283                 x-yes|x-no|x-auto)                         ;;
1284                 *)                 x11_hidd_vidmode="auto" ;;
1285             esac
1287             have_vidmode=no
1289             dnl they want it
1290             if test "x-$x11_hidd_vidmode" != "x-no" ; then
1292                 dnl make sure X libs have vidmode functions
1293                 save_libs="$LIBS"
1294                 save_cflags="$CFLAGS"
1295                 LIBS="$x_libraries"
1296                 CFLAGS="$x_includes"
1297                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
1298                 LIBS="$save_libs"
1299                 CFLAGS="$save_cflags"
1300             fi
1302             dnl detection done, prepare output
1303             if test "x-$have_vidmode" = "x-yes" ; then
1304                 dnl we can do vidmode
1305                 DO_VIDMODE_SUPPORT="1"
1306             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
1307                 dnl they explicitly asked for it, but we can't do it
1308                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
1309             else
1310                 dnl otherwise just disable it
1311                 DO_VIDMODE_SUPPORT="0"
1312             fi
1313         fi
1315         aros_host_x11_includes=$x_includes 
1316         aros_host_x11_libdirs=$x_libraries
1317     fi
1320     dnl sdl hidd
1321     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
1322                                            [build SDL hidd for hosted (default=auto)]),
1323                                            sdl_hidd="$enableval",
1324                                            sdl_hidd="auto")
1325     case "x-$sdl_hidd" in
1326         x-yes|x-no|x-auto)                 ;;
1327         *)                 sdl_hidd="auto" ;;
1328     esac
1330     dnl they want it
1331     if test "x-$sdl_hidd" != "x-no" ; then
1333         dnl find sdl
1334         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
1336         if test "x-$have_sdl" != "x-yes" ; then
1338             dnl didn't find it
1339             if test "x-$sdl_hidd" != "x-auto" ; then
1340                 dnl and they explicitly asked for it, bail out
1341                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
1342             fi
1344         else
1345             dnl found it, setup the metatarget
1346             sdl_hidd_target=kernel-hidd-sdl
1347             aros_host_sdl_cflags=SDL_CFLAGS
1348             aros_host_sdl_libs=SDL_LIBS
1349         fi
1350     fi
1355 dnl See if the user wants dbus.library
1356 AC_MSG_CHECKING([if building of dbus.library is enabled])
1357 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
1358 if test "$dbus" = "yes" ; then
1359     ENABLE_DBUS=1
1360     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
1361     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
1362     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
1363     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
1364 else
1365     ENABLE_DBUS=0
1367 AC_MSG_RESULT($dbus)
1370 dnl --------------------------------------------------------------------
1371 dnl Configuration Output Section
1372 dnl --------------------------------------------------------------------
1374 # Generic
1375 AC_SUBST(aros_arch)
1376 AC_SUBST(aros_cpu)
1377 AC_SUBST(aros_flavour)
1378 AC_SUBST(aros_flavour_uc)
1379 AC_SUBST(TOPDIR)
1381 # Host related
1382 AC_SUBST(aros_cc_pre)
1383 AC_SUBST(aros_host_strip)
1384 AC_SUBST(aros_host_arch)
1385 AC_SUBST(aros_host_cpu)
1386 AC_SUBST(aros_host_cc)
1387 AC_SUBST(aros_host_ar)
1388 AC_SUBST(aros_host_ranlib)
1389 AC_SUBST(aros_host_ld)
1390 AC_SUBST(aros_host_make)
1391 AC_SUBST(aros_host_cflags)
1392 AC_SUBST(aros_host_ldflags)
1393 AC_SUBST(aros_host_debug)
1394 AC_SUBST(aros_host_mkdep)
1395 AC_SUBST(aros_host_mkargs)
1396 AC_SUBST(aros_host_exe_suffix)
1397 AC_SUBST(aros_host_lib_suffix)
1398 AC_SUBST(aros_tools_dir)
1399 AC_SUBST(aros_host_aclocal)
1400 AC_SUBST(aros_host_autoconf)
1401 AC_SUBST(aros_host_autoheader)
1402 AC_SUBST(aros_host_automake)
1404 # Target Related
1405 AC_SUBST(aros_target_arch)
1406 AC_SUBST(aros_target_cpu)
1407 AC_SUBST(aros_target_variant)
1408 AC_SUBST(aros_target_suffix)
1409 AC_SUBST(aros_target_incl)
1410 AC_SUBST(aros_target_ar)
1411 AC_SUBST(aros_target_ranlib)
1412 AC_SUBST(aros_kernel_nm)
1413 AC_SUBST(aros_target_cc)
1414 AC_SUBST(aros_kernel_cc)
1415 AC_SUBST(aros_target_as)
1416 AC_SUBST(aros_target_ld)
1417 AC_SUBST(aros_kernel_ld)
1418 AC_SUBST(aros_target_cc_includes)
1419 AC_SUBST(aros_target_cc_path)
1420 AC_SUBST(aros_target_objdump)
1421 AC_SUBST(aros_target_objcopy)
1422 AC_SUBST(aros_target_strip)
1423 AC_SUBST(aros_target_nm)
1424 AC_SUBST(aros_shared_default)
1425 AC_SUBST(aros_shared_ld)
1426 AC_SUBST(aros_object_format)
1427 AC_SUBST(aros_compiler_libs)
1429 AC_SUBST(aros_config_cflags)
1430 AC_SUBST(aros_config_aflags)
1431 AC_SUBST(aros_config_ldflags)
1433 AC_SUBST(aros_shared_cflags)
1434 AC_SUBST(aros_shared_aflags)
1435 AC_SUBST(aros_shared_ldflags)
1436 AC_SUBST(aros_kernel_ldflags)
1437 AC_SUBST(aros_debug_cflags)
1438 AC_SUBST(aros_debug_aflags)
1439 AC_SUBST(aros_debug_ldflags)
1440 AC_SUBST(aros_target_genmap)
1441 AC_SUBST(aros_target_strip_flags)
1443 # Graphics Related
1444 AC_SUBST(x11_hidd_target)
1445 AC_SUBST(sdl_hidd_target)
1447 AC_SUBST(aros_default_wbwidth)
1448 AC_SUBST(aros_default_wbheight)
1449 AC_SUBST(aros_default_wbdepth)
1450 AC_SUBST(DO_XSHM_SUPPORT)
1451 AC_SUBST(DO_VIDMODE_SUPPORT)
1453 AC_SUBST(aros_host_x11_includes)
1454 AC_SUBST(aros_host_x11_libdirs)
1455 AC_SUBST(aros_host_sdl_cflags)
1456 AC_SUBST(aros_host_sdl_libs)
1458 # Native version related
1459 AC_SUBST(aros_bochs_hack)
1460 AC_SUBST(aros_serial_debug)
1462 # Palm native version related
1463 AC_SUBST(aros_palm_debug_hack)
1465 # Unix/Hosted version related
1466 AC_SUBST(aros_nesting_supervisor)
1468 # DBUS related
1469 AC_SUBST(ENABLE_DBUS)
1470 AC_SUBST(DBUS_CFLAGS)
1471 AC_SUBST(DBUS_LIBFLAGS)
1472 AC_SUBST(KERNEL_DBUS_KOBJ)
1473 AC_SUBST(KERNEL_DBUS_INCLUDES)
1475 # Debug related
1476 AC_SUBST(aros_debug)
1477 AC_SUBST(aros_mungwall_debug)
1478 AC_SUBST(aros_stack_debug)
1479 AC_SUBST(aros_modules_debug)
1481 # Collect-aros stuff: "-ius" to ignore undefined symbols
1482 AC_SUBST(ignore_undefined_symbols)
1484 # C compiler related
1485 AC_SUBST(gcc_target_cpu)
1487 dnl Prepare for output, make up all the generated patches
1488 case "$aros_flavour" in
1489 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
1490                 aros_flavour="emulation" ;;
1491 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
1492                 aros_flavour="emulation" ;;
1493 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
1494                 aros_flavour="standalone";;
1495 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
1496                 aros_flavour="native" ;;
1497 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1498                 aros_flavour="native" ;;
1499 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
1500                 aros_flavour="linklib" ;;
1501 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1502                 aros_flavour="palmnative" ;;
1503 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1504                 aros_flavour="mac68knative" ;;
1505 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1506                 aros_flavour="ppcnative" ;;
1507 esac
1509 if test ! -d ${aros_inc_dir} ; then
1510     ${MKDIR} ${aros_inc_dir}
1512 if test ! -d ${aros_geninc_dir} ; then
1513     ${MKDIR} ${aros_geninc_dir}
1515 if test ! -d ${aros_hostcfg_dir} ; then
1516     ${MKDIR} ${aros_hostcfg_dir}
1518 if test ! -d ${aros_targetcfg_dir} ; then
1519     ${MKDIR} ${aros_targetcfg_dir}
1521 if test ! -d ${aros_tools_dir} ; then
1522     ${MKDIR} ${aros_tools_dir}
1524 if test ! -d ${aros_scripts_dir} ; then
1525     ${MKDIR} ${aros_scripts_dir}
1528 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
1530 AC_CONFIG_COMMANDS([compiler_executable],
1531     [
1532         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
1533         mkdir -p $prefix
1534         prefix="${prefix}/${aros_target_cpu}-aros"
1535         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
1537         echo ${prefix}
1538         echo ${prefix2}
1539         chmod a+x ${prefix2}-gcc ${prefix2}-ld
1541         ln -sf ${prefix2}-gcc          ${prefix}-gcc
1542         ln -sf ${prefix2}-ld           ${prefix}-ld
1544         ln -sf $aros_target_as_ln      ${prefix}-as
1545         ln -sf $aros_target_nm_ln      ${prefix}-nm
1546         ln -sf $aros_target_ar_ln      ${prefix}-ar
1547         ln -sf $aros_target_ranlib_ln  ${prefix}-ranlib
1548         ln -sf $aros_target_objcopy_ln ${prefix}-objcopy
1549         ln -sf $aros_target_objdump_ln ${prefix}-objdump
1550         ln -sf $aros_target_strip_ln   ${prefix}-strip
1552         ln -sf $aros_target_as_ln      ${prefix2}-as
1553         ln -sf $aros_target_nm_ln      ${prefix2}-nm
1554         ln -sf $aros_target_ar_ln      ${prefix2}-ar
1555         ln -sf $aros_target_ranlib_ln  ${prefix2}-ranlib
1556         ln -sf $aros_target_objcopy_ln ${prefix2}-objcopy
1557         ln -sf $aros_target_objdump_ln ${prefix2}-objdump
1558         ln -sf $aros_target_strip_ln   ${prefix2}-strip
1559     ],
1560     [
1561         aros_tools_dir=${aros_tools_dir}
1562         aros_target_cpu=${aros_target_cpu}
1563         aros_target_arch=${aros_target_arch}
1564         aros_target_suffix=${aros_target_suffix}
1565         aros_target_nm_ln=${aros_target_nm_ln}
1566         aros_target_as_ln=${aros_target_as_ln}
1567         aros_target_ar_ln=${aros_target_ar_ln}
1568         aros_target_ranlib_ln=${aros_target_ranlib_ln}
1569         aros_target_objdump_ln=${aros_target_objdump_ln}
1570         aros_target_objcopy_ln=${aros_target_objcopy_ln}
1571         aros_target_strip_ln=${aros_target_strip_ln}
1572     ]
1574 AC_CONFIG_COMMANDS([genshared_executable],
1575     [chmod a+x ${aros_scripts_dir}/genshared],
1576     [aros_scripts_dir=${aros_scripts_dir}]
1578 AC_CONFIG_COMMANDS([genmf_executable],
1579     [chmod a+x ${aros_tools_dir}/genmf.py],
1580     [aros_tools_dir=${aros_tools_dir}]
1582 AC_CONFIG_COMMANDS([adflib_myaros.conf_executable],
1583     [chmod a+x tools/adflib/myconf.aros]
1586 AC_CONFIG_FILES(
1587     Makefile
1588     rom/mmakefile
1589     ${aros_inc_dir}/config.h:config/config.h.in
1590     ${aros_geninc_dir}/config.h:config/config.h.in
1591     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
1592     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
1593     mmake.config
1594     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
1595     ${aros_targetcfg_dir}/specs:config/specs.in
1596     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
1597     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
1598     ${aros_scripts_dir}/genshared:compiler/c_lib/source/lib_source/genshared.in
1599     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
1600     tools/adflib/myconf.aros
1601     tools/collect-aros/env.h
1604 AC_OUTPUT
1606 dnl This is in order to not define SHARED_CFLAGS sometimes
1607 dnl We don't always do aros_shared_ar, aros_shared_cflags
1609 #XXX compatability...
1610 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
1612 if test -n "$aros_shared_cflags" ; then
1613     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
1614     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg