Use 'mail' instead of 'mutt', since it's more readily available and
[tangerine.git] / configure.in
blob4e524538157b68a1d8033f5a74cb9b3f17b2e559
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 AC_MSG_CHECKING([Building AROS in .. ])
48 AROS_BUILDDIR=$PWD
49 AC_MSG_RESULT($AROS_BUILDDIR)
51 AC_MSG_CHECKING([AROS Source in .. ])
52 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
53 AROS_SRCDIR=${srcpwd}
54 AC_MSG_RESULT($AROS_SRCDIR)
56 # Parse the target field into something useful.
57 changequote(<<,>>)
58 target_os=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\1/'`
59 target_cpu=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\2/'`
60 changequote([,])
62 dnl --------------------------------------------------------------------
63 dnl Set the default Workbench resolution
64 dnl --------------------------------------------------------------------
65 aros_default_wbwidth=800
66 aros_default_wbheight=600
67 aros_default_wbdepth=4
69 dnl --------------------------------------------------------------------
70 dnl Host Configuration Section
71 dnl --------------------------------------------------------------------
72 dnl
73 dnl The idea here is to find out all the information we need about the
74 dnl host. This means things like tools for building directory structures,
75 dnl copying files around and the like.
77 # The first step is to find the host binaries.
78 # Check for a compiler.
79 AC_PROG_CC
80 AC_PROG_CC_STDC
81 AC_PROG_CPP
83 # Check for a compatible awk
84 AC_CHECK_PROGS(AWK,[gawk nawk])
85 AROS_REQUIRED(gawk,$AWK)
86 AROS_PROG(MMAKE,mmake)
88 # Perform some default variable assignments. Note all of these will be
89 # Regenerated from the script, so there is no need to cache them.
91 aros_host_cc="$CC"
92 AROS_TOOL_CCPATH(aros_host_ld,ld)
93 AROS_REQUIRED(ld,$aros_host_ld)
94 aros_host_make="make"
95 aros_host_cflags=$CFLAGS
96 aros_host_ldflags=$LDFLAGS
97 aros_host_debug="-g -O0"
98 aros_host_mkdep="\$(TOP)/scripts/mkdep"
99 aros_host_mkargs="--no-print-directory"
100 aros_host_incl="/usr/include"
101 aros_host_exe_suffix="$EXEEXT"
102 aros_host_lib_suffix=""
104 AC_CHECK_PROGS(aros_host_aclocal,[aclocal aclocal19])
105 AC_CHECK_PROGS(aros_host_autoconf,[autoconf autoconf259 autoconf253])
106 AC_CHECK_PROGS(aros_host_autoheader,[autoheader autoheader259 autoheader253])
107 AC_CHECK_PROGS(aros_host_automake,[automake automake19])
109 case "$aros_host_cc" in
110     *gcc*)
111         aros_host_cc_pipe="-pipe"
112         ;;
113     icc)
114         aros_host_cc_pipe=""
115         ;;
116     *)
117         aros_host_cc_pipe=""
118         ;;
119 esac
121 dnl Despite the name, this is really a host configuration variable.
122 aros_target_cc_includes=""
124 # This is the main host configuration section. It is where the host
125 # can change the values of any variables it needs to change. We do
126 # not look at anything that compiles to the target yet, we'll get
127 # to that later.
129 case "$host_os" in
130     linux*)
131         aros_host_arch="linux"
132         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
133         case "$host_cpu" in
134             *i?86*)
135                 aros_host_cpu="i386"
136                 ;;
137             *x86_64*)
138                 aros_host_cpu="x86_64"
139                 ;;
140             *m68k*)
141                 aros_host_cpu="m68k"
142                 ;;
143             *powerpc*)
144                 aros_host_cpu="ppc"
145                 ;;
146             *)
147                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
148                 aros_host_cpu="$host_cpu"
149                 ;;
150         esac
151         ;;
153     freebsd*)
154         aros_host_cc="$aros_host_cc $aros_host_cc_pipe -I/usr/local/include"
155         aros_host_make="gmake"
156         aros_host_arch="freebsd"
157         aros_host_cpu="i386"
159         aros_host_ldflags="$aros_host_ldflags -L/usr/local/lib -liconv"
161         dnl Need to override this here, it's just too hard later.
162         dnl This shouldn't be here at all...
163         dnl aros_target_cc_includes="/usr/include"
165         dnl FreeBSD 5.x (and later) has changed the default object format.
166         dnl The double [[]] is necessary to get around m4's quoting rules.
167         case $host_os in
168             freebsd[[234]]*)
169                 aros_object_format="elf_i386"
170                 ;;
172             *)
173                 aros_object_format="elf_i386_fbsd"
174                 ;;
175         esac
177         ;;
179     darwin*)
180         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
181         aros_host_arch="darwin"
182         case "$host_cpu" in
183             *i?86*)
184                 aros_host_cpu="i386"
185                 ;;
186             *powerpc*)
187                 aros_host_cpu="ppc"
188                 ;;
189             *)
190                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
191                 aros_host_cpu="$host_cpu"
192                 ;;
193         esac
195         aros_host_ldflags="$aros_host_ldflags -liconv"
197         ;;
199     netbsd*)
200         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
201         aros_host_make="gmake"
202         aros_host_arch="netbsd"
203         case "$host_cpu" in
204             *i?86*)
205                 aros_host_cpu="i386"
206                 ;;
207             *m68k*)
208                 aros_host_cpu="m68k"
209                 ;;
210             *)
211                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
212                 aros_host_cpu="$host_cpu"
213                 ;;
214         esac    
215         aros_host_lib_suffix=".0.0"
216         ;;
218     openbsd*)
219         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
220         aros_host_make="gmake"
221         aros_host_arch="openbsd"
222         case "$host_cpu" in
223             *i?86*)
224                 aros_host_cpu="i386"
225                 ;;
226             *)
227                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
228                 aros_host_cpu="$host_cpu"
229                 ;;
230         esac
231         ;;
232         
233     solaris*)
234         aros_host_arch="solaris"
235         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
236         case "$host_cpu" in
237             *sparc*)
238                 aros_host_cpu="sparc"
239                 ;;
240             *)
241                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
242                 aros_host_cpu="$host_cpu"
243                 ;;
244         esac
245         ;;
247     morphos*)
248         aros_host_arch="morphos"
249         aros_host_cpu="ppc"
250         ;;
252     amiga*)
253         aros_host_arch="amiga"
254         SORT="/gg/bin/sort"
255         TEST="/gg/bin/test"
256         UNIQ="/gg/bin/uniq"
257         FOR="for"
258         TOUCH="/gg/bin/touch"
259         case "$host_cpu" in
260             *m68k*)
261                 aros_host_cpu="m68k"
262                 ;;
263             *powerpc*)
264                 aros_host_cpu="ppc"
265                 ;;
266             *)
267                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
268                 aros_host_cpu="$host_cpu"
269                 ;;
270         esac
271         ;;
273     cygwin*)
274         aros_host_arch="cygwin"
275         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
276         case "$host_cpu" in
277             *i?86*)
278                 aros_host_cpu="i386"
279                 ;;
280             *)
281                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
282                 aros_host_cpu="$host_cpu"
283                 ;;
284         esac
285         ;;
287     mingw32*)
288         aros_host_arch="mingw32"
289         aros_host_cc="$aros_host_cc $aros_host_cc_pipe"
290         case "$host_cpu" in
291             *i?86*)
292                 aros_host_cpu="i386"
293                 ;;
294             *)
295                 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
296                 aros_host_cpu="$host_cpu"
297                 ;;
298         esac
299         ;;
300     *)
301         AC_MSG_ERROR([Unsupported host architecture $host])
302         ;;
303 esac
305 AROS_PROG(aros_host_ar,[ar],[cr])
306 AROS_REQUIRED(ar,$aros_host_ar)
307 AROS_PROG(aros_host_ranlib,ranlib)
308 AROS_REQUIRED(ranlib,$aros_host_ranlib)
309 AROS_PROG(aros_host_strip,strip)
310 AROS_REQUIRED(strip,$aros_host_strip)
312 AROS_PROG(RM,[rm],[-rf])
313 AROS_REQUIRED(rm,$RM)
314 AROS_PROG(CP,[cp])
315 AROS_REQUIRED(cp,$CP)
316 AROS_PROG(MV,[mv])
317 AROS_REQUIRED(mv,$MV)
318 AROS_PROG(ECHO,[echo])
319 AROS_REQUIRED(echo,$ECHO)
320 AROS_PROG(MKDIR,[mkdir],[-p])
321 AROS_REQUIRED(mkdir,$MKDIR)
322 AROS_PROG(TOUCH,[touch])
323 AROS_REQUIRED(touch,$TOUCH)
324 AROS_PROG(SORT,[sort])
325 AROS_REQUIRED(sort,$SORT)
326 AROS_PROG(UNIQ,[uniq])
327 AROS_REQUIRED(uniq,$UNIQ)
328 AROS_PROG(NOP,[true])
329 AROS_REQUIRED(true,$NOP)
330 AROS_PROG(CAT,[cat])
331 AROS_REQUIRED(cat,$CAT)
332 AROS_PROG(BISON,[bison])
333 AROS_REQUIRED(bison,$BISON)
334 AROS_PROG(FLEX,[flex])
335 AROS_REQUIRED(flex,$FLEX)
336 AROS_PROG(PNGTOPNM,[pngtopnm])
337 AROS_REQUIRED(pngtopnm,$PNGTOPNM)
338 AROS_PROG(PPMTOILBM,[ppmtoilbm])
339 AROS_REQUIRED(ppmtoilbm,$PPMTOILBM)
340 AROS_PROG(SED,[sed])
341 AROS_REQUIRED(sed,$SED)
342 AROS_PROG(CHMOD,[chmod])
343 AROS_REQUIRED(chmod,$CHMOD)
345 AM_PATH_PYTHON(2.2.1)
347 AC_SUBST(FOR, for)
348 AC_SUBST(IF, if)
349 AC_SUBST(TEST, test)
350 AC_SUBST(CMP, cmp)
352 dnl ---------------------------------------------------------------------------
353 dnl Look for things about the host system, good for hosted targets.
354 dnl ---------------------------------------------------------------------------
356 # Check for some includes for the X11 HIDD and the kernel
357 AC_CHECK_HEADERS([sys/ipc.h sys/shm.h \
358     sys/mmap.h sys/mman.h sysexits.h \
359     sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
362 AC_CHECK_HEADERS([sys/mount.h],,,[#include <sys/param.h>])
364 AC_HEADER_DIRENT
365 AC_HEADER_STAT
366 AC_HEADER_STDC
367 AC_HEADER_SYS_WAIT
368 AC_HEADER_TIME
369 AC_STRUCT_ST_BLKSIZE
370 AC_STRUCT_ST_BLOCKS
371 AC_STRUCT_ST_RDEV
372 AC_STRUCT_TM
373 AC_STRUCT_TIMEZONE
374 AC_TYPE_OFF_T
375 AC_TYPE_PID_T
376 AC_TYPE_SIZE_T
377 AC_TYPE_UID_T
379 AC_CHECK_MEMBERS(struct tm.tm_gmtoff)
381 # Look for some functions
382 AC_CHECK_FUNCS([getpagesize kqueue statfs statvfs \
383     clone kse_create rfork_thread thr_create sa_register \
384     getcontext makecontext setcontext sigaltstack swapcontext])
386 AC_FUNC_MMAP
389 dnl --------------------------------------------------------------------
390 dnl Target Configuration Section
391 dnl --------------------------------------------------------------------
393 dnl The target configuration section is responsible for setting up all
394 dnl the paths for includes, and tools required to build AROS to some
395 dnl particular target.
397 aros_config_cflags="-Wall -Werror-implicit-function-declaration"
398 aros_config_aflags="-Wall -x assembler-with-cpp -c"
399 aros_config_ldflags=""
401 aros_shared_default=yes
403 aros_shared_cflags="-fPIC"
404 aros_shared_aflags=""
405 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
406 aros_kernel_ldflags="-Wl,-rpath,./lib"
408 aros_target_ar_flags="cr"
409 aros_target_nm_flags="-C -ul"
410 aros_target_strip_flags="--strip-unneeded -R.comment"
412 aros_compiler_libs=
414 aros_target_genmap="-Wl,-Map -Xlinker"
416 # Native flavour stuff
417 aros_bochs_hack="0"
418 aros_serial_debug="0"
420 # Palm native flavour stuff
421 aros_palm_debug_hack="0"
423 # Unix flavour stuff
424 aros_nesting_supervisor="0"
426 # Collect-aros stuff: "-ius" to ignore undefined symbols
427 ignore_undefined_symbols=""
429 #-----------------------------------------------------------------------------
432 # GCC 4.1+ has a stack protection feature that requires OS support. Ubuntu has
433 # it switched on by default, and we use the host compiler, so it compiles AROS
434 # code with this enabled resulting in link failures as we don't have support
435 # for it.
437 # We use two methods to disable it. For the host compiler (used to compile
438 # some hosted modules), we test to see if the compiler supports stack
439 # protection, and if it does we disable it in AROS_CONFIG_CFLAGS. This should
440 # work on all platforms.
442 # For the "cross" compiler we clear the "ssp_default" spec in config/specs.in
443 # (this is done unconditionally, as it should have no effect on compilers
444 # without the stack protection feature). This may be specific to the way that
445 # Ubuntu enables the feature, so may not work everywhere. My specs-fu isn't
446 # strong enough to disable it in a generic way though, so we'll live with it
447 # until another vendor ships GCC with it enabled in a different way, and deal
448 # with it then.
451 AC_MSG_CHECKING([whether ${CC} accepts -fno-stack-protector])
452 save_cflags="$CFLAGS"
453 CFLAGS="$CFLAGS -fno-stack-protector"
454 AC_TRY_COMPILE(,, use_no_stack_protector="yes", use_no_stack_protector="no")
455 AC_MSG_RESULT($use_no_stack_protector)
456 if test "x-$use_no_stack_protector" = "x-yes" ; then
457     aros_host_cflags="$aros_host_cflags -fno-stack-protector"
459 CFLAGS="$save_cflags"
461 #-----------------------------------------------------------------------------
463 # Disable pointer-signedness warnings if the compiler recognises the option
464 # (this only works for the host compiler at the moment)
466 AC_MSG_CHECKING([whether ${CC} accepts -Wno-pointer-sign])
467 save_cflags="$CFLAGS"
468 CFLAGS="$CFLAGS -Wno-pointer-sign"
469 AC_TRY_COMPILE(,, use_no_sign_warning="yes", use_no_sign_warning="no")
470 AC_MSG_RESULT($use_no_sign_warning)
471 if test "x-$use_no_sign_warning" = "x-yesnnn" ; then
472     aros_host_cflags="$aros_host_cflags -Wno-pointer-sign"
474 CFLAGS="$save_cflags"
476 #-----------------------------------------------------------------------------
478 AC_MSG_CHECKING([for type of build])
479 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")
481 if test "$build_type" = "nightly"; then
482     build_type_string="NIGHTLY"
483 elif test "$build_type" = "snapshot"; then
484     build_type_string="SNAPSHOT"
485 elif test "$build_type" = "milestone"; then
486     build_type_string="MILESTONE"
487 elif test "$build_type" = "release"; then
488     build_type_string="RELEASE"
489 else
490     build_type_string="PERSONAL"
491     build_type="personal"
494 aros_config_cflags="$aros_config_cflags -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_$build_type_string"
496 AC_MSG_RESULT($build_type)
498 #-----------------------------------------------------------------------------
499 all_debug_types="messages stack mungwall modules symbols"
501 AC_MSG_CHECKING([which debug types to enable])
502 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)]),
503  debug="$enableval",debug="")
505 if test "$debug" = "" -o "$debug" = "no"; then
506     debug="none"
507 elif test "$debug" = "yes"; then
508     debug="all"
511 if test "$debug" = "all" ; then
512     debug=$all_debug_types
513     for d in $all_debug_types; do
514         export aros_${d}_debug="1"
515     done
516 else
517     for d in $all_debug_types; do
518         export aros_${d}_debug="0"
519     done
522 if test "$debug" != "none"; then
523     debug=`echo $debug | sed s/,/\ /g`
524     for d in $debug; do
525         found="0"
526         for d2 in $all_debug_types; do
527             if test "$d2" = "$d"; then
528                 found="1"
529                 break
530             fi
531         done
532         if test "$found" = "0"; then
533             AC_MSG_ERROR([unrecognized debug type "$d". Available types are: all none $all_debug_types])
534         fi
535         export aros_${d}_debug="1"
536     done
537     aros_debug="yes"
539 AC_MSG_RESULT($debug)
541 if test "$aros_messages_debug" = "1"; then
542     aros_messages_debug="-DADEBUG=1 -DMDEBUG=1"
543 else
544     aros_messages_debug=""
546 if test "$aros_symbols_debug" = "1"; then
547     aros_symbols_debug="-g"
548 else
549     aros_symbols_debug=""
552 # These are the flags to pass when compiling debugged programs
553 aros_debug_cflags="$aros_symbols_debug $aros_messages_debug"
554 aros_debug_aflags=""
555 aros_debug_ldflags="$aros_symbols_debug"
557 #-----------------------------------------------------------------------------
558 #   Checking for distcc and ccache.
560 #   Always apply the transforms in this particular order. Basically you should
561 #   always run 'ccache distcc compiler' in that order for the best performance.
563 AC_MSG_CHECKING([whether to enable distcc])
564 AC_ARG_ENABLE(distcc,AC_HELP_STRING([--enable-distcc],[Use distcc as a front end to the compiler (default=no).]),distcc="$enableval",distcc="no")
565 if test "$distcc" != "" -a "$distcc" != "no"; then
566     # AC_CHECK_PROG will print out the result in this case
567     AC_PATH_PROG(DISTCC,[distcc],distcc,)
568 else
569     AC_MSG_RESULT(no)
572 AC_MSG_CHECKING([whether to enable ccache])
573 AC_ARG_ENABLE(ccache,AC_HELP_STRING([--enable-ccache],[Use ccache as a front end to the compiler (default=no).]),ccache="$enableval",ccache="no")
574 if test "$ccache" != "" -a "$ccache" != "no"; then
575     # AC_CHECK_PROG will print out the result in this case
576     AC_CHECK_PROG(CCACHE,[ccache],ccache,)
577 else
578     AC_MSG_RESULT(no)
581 #-----------------------------------------------------------------------------
582 AC_MSG_CHECKING([what optimization flags to use])
583 AC_ARG_WITH(optimization,AC_HELP_STRING([--with-optimization=FLAGS],[Use optimization flags FLAGS (default=-O2).]),optimization="$withval",optimization="unknown")
584 if test "$optimization" = "unknown"; then
585     dnl default is -O2 for normal builds, -O0 for debug builds
586     if test "$debug" != "none"; then
587         optimization="-O0"
588     else
589         optimization="-O2"
590     fi
592 aros_config_cflags="$aros_config_cflags $optimization"
593 AC_MSG_RESULT($optimization)
595 #-----------------------------------------------------------------------------
596 AC_MSG_CHECKING([what target variant to enable])
597 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")
598 if test "$target_variant" = "none"; then
599     aros_target_variant=""
600     aros_target_suffix=""
601 else
602     aros_target_variant="$target_variant"
603     aros_target_suffix="-$target_variant"
605 AC_MSG_RESULT($enableval)
607 target_bootloader="none"
609 #-----------------------------------------------------------------------------
610 # This is the target configuration switch.
611 case "$target_os" in
612     linux*)
613         aros_target_arch="linux"
614         case "$target_cpu" in
615             *m68k*)
616                 aros_target_cpu="m68k"
617                 aros_object_format="m68kelf"
618                 aros_flavour="emulcompat"
619                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
620                 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
621                 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
622                 gcc_target_cpu="mc68000"
623                 ;;
624             *i?86*)
625                 aros_target_cpu="i386"
626                 aros_object_format="elf_i386"
627                 aros_flavour="emulation"
628                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
629                 aros_default_wbdepth=8
630                 gcc_target_cpu="i386"
631                 ;;
632             *x86_64*)
633                 aros_target_cpu="x86_64"
634                 aros_object_format="elf_x86_64"
635                 aros_flavour="emulation"
636                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64 -D__linux__"
637                 aros_config_cflags="$aros_config_cflags -mno-red-zone"
638                 aros_default_wbdepth=8
639                 gcc_target_cpu="x86_64"
640                 ;;
641             *powerpc*)
642                 aros_target_cpu="ppc"
643                 aros_object_format="elf32ppc"
644                 aros_flavour="emulation"
645                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
646                 aros_default_wbdepth=8
647                 gcc_target_cpu="ppc"
648                 ;;
649 # TODO
650 # Same as powerpc, but I need this for the nightly build to work again.
651 # Actually, the nightly should be made working with powerpc target.
652 # That just was too much work for the moment, another week or two.
653             *ppc*)
654                 aros_target_cpu="ppc"
655                 aros_object_format="elf32ppc"
656                 aros_flavour="emulation"
657                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
658                 aros_default_wbdepth=8
659                 gcc_target_cpu="ppc"
660                 ;;
661 # TODO
662 # Same as powerpc, but I need this for the nightly build to work again.
663 # Actually, the nightly should be made working with powerpc target.
664 # That just was too much work for the moment, another week or two.
665             *ppc*)
666                 aros_target_cpu="ppc"
667                 aros_object_format="elf32ppc"
668                 aros_flavour="emulation"
669                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc -D__linux__"
670                 aros_default_wbdepth=8
671                 gcc_target_cpu="ppc"
672                 ;;
673             *)
674                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
675                 ;;
676         esac
677     ;;
679     pc)
680         aros_target_arch="pc"
681         aros_shared_default="no"
682         target_bootloader="grub"
683         case "$target_cpu" in
684             *i?86*)
685                 aros_target_cpu="i386"
687                 dnl If somebody hasn't already set the target object
688                 dnl format, then use this value. Mostly to support
689                 dnl FreeBSD cross-compilation.
690                 dnl TODO: Remove when we always use our compiler.
692                 if test "$aros_object_format" = "" ; then
693                     aros_object_format="elf_i386"
694                 fi
695                 aros_flavour="standalone"
696                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
697                 aros_kernel_ldflags=""
698                 aros_default_wbwidth=640
699                 aros_default_wbheight=480
700                 gcc_target_cpu="i386"
701                 ;;
702             *x86_64*)
703                 aros_target_cpu="x86_64"
704                 if test "$aros_object_format" = "" ; then
705                     aros_object_format="elf_x86_64"
706                 fi
707                 aros_flavour="standalone"
708                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
709                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone"
710                 aros_kernel_ldflags=""
711                 aros_default_wbwidth=640
712                 aros_default_wbheight=480
713                 gcc_target_cpu="x86_64"
714                 ;;
715             *)
716                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
717                 ;;
718         esac
719         ;;
721     prep)
722         aros_target_arch="prep"
723         aros_shared_default="no"
724         aros_target_cpu="ppc"
725         aros_object_format="elf32ppc"
726         aros_flavour="ppcnative"
727         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
728         aros_kernel_ldflags=""
729         aros_default_wbwidth=640
730         aros_default_wbheight=480
731         gcc_target_cpu="ppc"
732         case "$target_cpu" in
733             *cross*)
734                 aros_target_cc="ppc-linux-gcc -pipe"
735                 aros_target_ld="ppc-linux-ld"
736                 aros_target_as="ppc-linux-as"
737                 aros_target_ar="ppc-linux-ar"
738                 aros_target_ranlib="ppc-linux-ranlib"
739                 aros_target_nm="ppc-linux-nm"
740                 aros_target_strip="ppc-linux-strip"
741                 aros_target_objcopy="ppc-linux-objcopy"
742                 aros_target_objdump="ppc-linux-objdump"
743                 aros_shared_ld="ppc-linux-ld"
744                 aros_kernel_ld="ppc-linux-ld"
745                 ;;
746             *)
747                 ;;
748         esac
749         ;;
751     freebsd*)
752         aros_target_arch="freebsd"
753         aros_target_cpu="i386"
754         aros_flavour="emulation"
755         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
756         gcc_target_cpu="i386"
758         aros_target_strip_flags="-x"
759         ;;
761     darwin*)
762         aros_target_arch="darwin"
763         aros_target_cpu="i386"
764         aros_flavour="emulation"
765         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
766         gcc_target_cpu="i386"
768         aros_target_strip_flags="-x"
769         ;;
771     netbsd*)
772         aros_target_arch="netbsd"
773         case "$target_cpu" in
774             *m68k*)
775                 aros_target_cpu="m68k"
776                 aros_object_format="m68kelf"
777                 aros_flavour="emulcompat"
778                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
779                 gcc_target_cpu="mc68000"
780                 ;;
781             *i?86*)
782                 aros_target_cpu="i386"
783                 aros_object_format="elf_i386"
784                 aros_flavour="emulation"
785                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
786                 aros_default_wbdepth=8
787                 gcc_target_cpu="i386"
788                 ;;
789             *)
790                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
791                 ;;
792         esac
793         aros_target_genmap="-Wl,-M -Xlinker >"
794         aros_flavour="emulation"
795         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
796         ;;   
798     openbsd*)
799         aros_target_arch="openbsd"
800         case "$target_cpu" in
801             *i?86*)
802                 aros_target_cpu="i386"
803                 aros_object_format="elf_i386"
804                 aros_flavour="emulation"
805                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
806                 gcc_target_cpu="i386"
807                 ;;
808             *)
809                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
810                 ;;
811         esac
812         aros_target_genmap="-Wl,-M -Xlinker >"
813         aros_target_nm_flags="-u"
814         aros_flavour="emulation"
815         ;;
817     solaris*)
818         aros_target_arch="solaris"
819         case "$target_cpu" in
820             *sparc*)
821                 aros_target_cpu="sparc"
822                 aros_object_format="elf_sparc"
823                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
824                 gcc_target_cpu="sparc"
825                 ;;
826             *)
827                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
828                 ;;
829         esac
830         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
831         aros_flavour="emulation"
832         ;;
834     morphos*)
835         aros_target_arch="morphos"
836         aros_shared_default="no"
837         aros_target_cpu="ppc"
838         aros_object_format="elf_ppc"
839         aros_flavour="nativecompat"
840         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
841         gcc_target_cpu="ppc"
842         ;;
844     sam440)
845         aros_target_arch="sam440"
846         aros_shared_default="no"
847         aros_target_cpu="ppc"
848         aros_object_format="elf32ppc"
849         aros_flavour="ppcnative"
850         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
851         aros_kernel_ldflags=""
852         aros_default_wbwidth=640
853         aros_default_wbheight=480
854         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
855         gcc_target_cpu="powerpc"
856         case "$target_cpu" in
857             *powerpc*)
858                 aros_target_cc="powerpc-linux-gcc -pipe"
859                 aros_target_ld="powerpc-linux-ld"
860                 aros_target_as="powerpc-linux-as"
861                 aros_target_ar="powerpc-linux-ar"
862                 aros_target_ranlib="powerpc-linux-ranlib"
863                 aros_target_nm="powerpc-linux-nm"
864                 aros_target_strip="powerpc-linux-strip"
865                 aros_target_objcopy="powerpc-linux-objcopy"
866                 aros_target_objdump="powerpc-linux-objdump"
867                 aros_shared_ld="powerpc-linux-ld"
868                 aros_kernel_ld="powerpc-linux-ld"
869                 ;;
870             *)
871                 ;;
872         esac
873         ;;
875     amiga*)
876         aros_target_arch="amiga"
877         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
878         aros_shared_default="no"
880         aros_config_cflags="$aros_config_cflags -fomit-frame-pointer -fbuiltin -ffreestanding"
882         case "$target_cpu" in
883             *m68k*)
884                 aros_target_cpu="m68k"
885                 aros_object_format="m68kelf"
886                 aros_flavour="nativecompat"
887                 gcc_target_cpu="mc68000"
888                 ;;
889             *ppc*)
890                 aros_cpu="ppc"
891                 aros_flavour="native"
892                 gcc_target_cpu="ppc"
893                 ;;
894             *)
895                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
896                 ;;
897         esac
898         ;;
900     cygwin*)
901         aros_target_arch="cygwin"
902         aros_shared_default="no"
903         case "$target_cpu" in
904             *i?86*)
905                 aros_target_cpu="i386"
906                 aros_object_format="elf_i386"
907                 aros_flavour="emulation"
908                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
909                 aros_shared_cflags=""
910                 aros_default_wbdepth=8
911                 gcc_target_cpu="i386"
912                 ;;
913             *)
914                 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
915                 ;;
916         esac
917     ;;
919     mingw32*)
920         aros_target_arch="mingw32"
921         aros_shared_default="no"
922         case "$target_cpu" in
923             *i?86*)
924                 aros_target_cpu="i386"
925                 aros_object_format="elf_i386"
926                 aros_flavour="emulation"
927                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
928                 aros_shared_cflags=""
929                 aros_default_wbdepth=8
930                 gcc_target_cpu="i386"
931                 ;;
932             *)
933                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
934                 ;;
935         esac
936     ;;
937     pp*)
938         aros_target_arch="pp"
939         aros_shared_default="no"
940         case "$target_cpu" in
941             *m68k*)
942                 aros_target_cpu="m68k"
943                 aros_object_format="m68kelf"
944                 aros_flavour="palmnative"
945                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
946                 aros_kernel_ldflags=""
947                 aros_default_wbwidth=160
948                 aros_default_wbheight=160
949                 aros_default_wbdepth=1
950                 aros_target_cc="m68k-elf-gcc -pipe"
951                 aros_target_ld="$(which m68k-elf-ld)"
952                 aros_target_as="m68k-elf-gcc -pipe"
953                 aros_shared_ld="m68k-elf-gcc"
954                 aros_kernel_ld="m68k-elf-gcc"
955                 aros_target_ar="m68k-elf-ar"
956                 aros_target_ar_flags="cru"
957                 aros_target_ranlib="m68k-elf-ranlib"
958                 aros_target_nm="m68k-elf-nm"
959                 aros_target_objcopy="m68k-elf-objcopy"
960                 aros_target_objdump="m68k-elf-objdump"
961                 aros_compiler_libs="-lgcc1"
962                 aros_shared_default=no
963                 aros_shared_cflags="-fpic"
964                 aros_shared_aflags=""
965                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
966                 aros_kernel_ldflags="-Wl,-rpath,./lib"
967                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
968                 aros_debug_aflags=""
969                 aros_debug_ldflags="$aros_symbols_debug"
970                 aros_mungwall_debug="0"
971                 aros_modules_debug="0"
972                 gcc_target_cpu="mc68000"
973                 ignore_undefined_symbols="-ius"
974                 ;;
975            *)
976                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
977                 ;;
978         esac
979         ;;
981     mac*)
982         aros_target_arch="mac"
983         aros_shared_default="no"
984         case "$target_cpu" in
985             *m68k*)
986                 aros_target_cpu="m68k"
987                 aros_object_format="m68kelf"
988                 aros_flavour="mac68knative"
989                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
990                 aros_default_wbwidth=512
991                 aros_default_wbheight=384
992                 aros_default_wbdepth=8
993                 aros_target_cc="m68k-elf-gcc -pipe"
994                 aros_target_ld="$(which m68k-elf-ld)"
995                 aros_target_as="m68k-elf-gcc -pipe"
996                 aros_shared_ld="m68k-elf-gcc"
997                 aros_kernel_ld="m68k-elf-gcc"
998                 aros_target_ar="m68k-elf-ar"
999                 aros_target_ar_flags="cru"
1000                 aros_target_ranlib="m68k-elf-ranlib"
1001                 aros_target_nm="m68k-elf-nm"
1002                 aros_target_objcopy="m68k-elf-objcopy"
1003                 aros_target_objdump="m68k-elf-objdump"
1004                 aros_compiler_libs="-lgcc1"
1005                 aros_shared_default=no
1006                 aros_shared_cflags="-fpic"
1007                 aros_shared_aflags=""
1008                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
1009                 aros_kernel_ldflags="-Wl,-rpath,./lib"
1010                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000"
1011                 aros_debug_aflags=""
1012                 aros_debug_ldflags="$aros_symbols_debug"
1013                 aros_mungwall_debug="0"
1014                 aros_modules_debug="0"
1015                 gcc_target_cpu="mc68000"
1016                 ignore_undefined_symbols="-ius"
1017                 ;;
1018            *)
1019                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1020                 ;;
1021         esac
1022         ;;
1024     *)
1025         AC_MSG_ERROR([Unsupported target architecture $target])
1026         ;;
1027 esac
1029 AC_MSG_CHECKING([Where to download sourcecode for external ports])
1030 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1031 if test "$with_portssrcdir" = "default"; then
1032     AROS_PORTSSRCDIR="$AROS_BUILDDIR/bin/Sources"
1033 else
1034     AROS_PORTSSRCDIR="$with_portssrcdir"
1036 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1038 AC_MSG_CHECKING([which bootloader to use])
1039 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1040 if test "$target_bootloader" = "none"; then
1041     aros_target_bootloader=""
1042 else
1043     aros_target_bootloader="$target_bootloader"
1045 AC_MSG_RESULT($target_bootloader)
1047 # Check LZO when compiling the grub2 bootloader on i386/x86_64.
1048 aros_liblzo_check="no"
1049 case "$aros_target_bootloader" in
1050     grub2*)
1051     case "$target_cpu" in
1052         *i?86*)
1053         aros_liblzo_check="yes"
1054         ;;
1055         *x86_64*)
1056         aros_liblzo_check="yes"  
1057         ;;
1058         *)
1059         ;;
1060     esac
1061   
1062     ;;
1063    *)
1064     ;;
1065 esac
1067 if test "$aros_liblzo_check" = "yes"; then
1068     # There are three possibilities. LZO version 2 installed with the name
1069     # liblzo2, with the name liblzo, and LZO version 1.  
1070     AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"],  
1071     AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"],
1072                 AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"],
1073                 AC_MSG_ERROR([LZO library version 1.02 or later is required]))))
1075     AC_SUBST(LIBLZO)
1076     LIBS="$LIBS $LIBLZO"
1077     AC_CHECK_FUNC(lzo1x_999_compress, ,
1078                 [AC_MSG_ERROR([LZO1X-999 must be enabled])])
1080     # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.
1081     AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h)
1084 AC_MSG_CHECKING([which GUI Theme to use])
1085 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1086 if test "$target_guitheme" = "default"; then
1087     aros_target_guitheme="Ice"
1088 else
1089     aros_target_guitheme="$target_guitheme"
1091 AC_MSG_RESULT($aros_target_guitheme)
1093 # Find out if we are cross-compiling (ie. if we can't use the host compiler
1094 # for target code)
1095 cross_compiling=no
1096 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1097     cross_compiling=yes
1099 if test "$aros_host_arch" == "darwin" ; then
1100     cross_compiling=yes
1103 # Set prefix for target compiler etc. if we're cross-compiling
1104 # (should possibly be earlier but needs to be after AC_PROG_CC)
1105 if test "$cross_compiling" = "yes" ; then
1106     target_tool_prefix=${target_cpu}-elf-
1107     CC=${target_tool_prefix}gcc
1110 # Find all the tools we need to compile. This could be cross-compiling
1111 # though! If that is the case we use the GNU form of the target and
1112 # simply add this to the front of the binary name. This is rather simple,
1113 # but it should work under most circumstances.
1115 # The default tools are to use the same as the host, but only if the
1116 # host and target CPU are the same. With GCC this is normally enough.
1119 aros_cc_pre=""
1120 aros_shared_ld="$aros_host_ld"
1122 aros_target_mkdep="$aros_host_mkdep"
1123 aros_target_incl_def="$aros_host_incl"
1125 AC_PATH_PROG(aros_kernel_cc,$CC)
1127 # The default tools executables to be linked to.
1128 AROS_TOOL_TARGET(aros_target_as_ln,as)
1129 AROS_REQUIRED(as,$aros_target_as_ln)
1130 AROS_TOOL_TARGET(aros_kernel_ld,ld)
1131 AROS_REQUIRED(ld,$aros_kernel_ld)
1132 AROS_TOOL_TARGET(aros_target_ar_ln,ar)
1133 AROS_REQUIRED(ar,$aros_target_ar_ln)
1134 AROS_TOOL_TARGET(aros_target_nm_ln,nm)
1135 AROS_REQUIRED(nm,$aros_target_nm_ln)
1136 AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy)
1137 AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
1138 AROS_TOOL_TARGET(aros_target_objdump_ln,objdump)
1139 AROS_REQUIRED(objdump,$aros_target_objdump_ln)
1140 AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib)
1141 AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
1142 AROS_TOOL_TARGET(aros_target_strip_ln,strip)
1143 AROS_REQUIRED(strip,$aros_target_strip_ln)
1145 if test "$GCC" = "yes"; then
1146     aros_target_cc_path=`$aros_kernel_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1149 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1150 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1151 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1152 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1153 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1154 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1155 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1157 # aros_cc_pre is a variable that is added to the front of the compiler name
1158 # in the generated aros-gcc shell script. We need this to enable the cache
1159 # to work across cleaned builds. Also, support DISTCC using the correct
1160 # environment variable.
1163 if test "x${DISTCC}" != "x" ; then
1164     if test "x${CCACHE}" != "x" ; then
1165         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1166     else
1167         aros_cc_pre="${DISTCC} "
1168     fi
1169 else
1170     if test "x${CCACHE}" != "x" ; then
1171         aros_cc_pre="${CCACHE} "
1172     fi
1175 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1177 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1178 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1179 AC_SUBST(aros_target_nix_ldflags,-nix)
1180 AC_SUBST(aros_target_detach_ldflags,-detach)
1181 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1183 # Target tools
1184 aros_target_cc="${prefix}-gcc"
1185 aros_target_as="${prefix}-as"
1186 aros_target_ld="${prefix}-ld"
1187 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1188 aros_target_objcopy=${prefix}-objcopy
1189 aros_target_objdump=${prefix}-objdump
1190 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1191 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1192 aros_kernel_nm="${prefix}-nm"
1193 aros_target_strip=${prefix}-strip
1195 # Find the system include path. We can suggest that an alternative is
1196 # used if we don't get it correct. The default is to use /usr/include.
1197 # Which is set in the aros_target_incl_def variable.
1199 AC_ARG_ENABLE(includes,
1200 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1201 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1203 dnl find out about the target cc's include path
1204 AC_MSG_CHECKING([for the target compiler's include path])
1205 if test "$aros_target_cc_includes" = "" ; then
1206     #try to guess where the directory is
1207     aros_target_cc_includes=`dirname \`${aros_kernel_cc} -print-libgcc-file-name\``/include
1208     if ! test -d $aros_target_cc_includes; then
1209         #the directory doesn't exist, we need to do some more work
1210         aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1211         
1212         #these are the headers we're looling for
1213         headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1214                  stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1215                  zutil.h"
1217         dirs=
1218         for h in $headers; do
1219             #which other headers each of the above headers needs?
1220             deps=$(echo "#include <$h>" | \
1221                    $aros_host_cc -E -M - 2>/dev/null | \
1222                    sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1223             
1224             #copy all the needed headers to a directory beneath gendir
1225             for d in $deps; do
1226                 h=$(basename $d)
1227                 dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1228                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1229                 ! test -d $dir && mkdir -p $dir
1230                 ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1231             done
1232         done        
1233     fi
1235 AC_MSG_RESULT($aros_target_cc_includes)
1237 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
1238 AC_MSG_CHECKING([for default resolution of WBScreen])
1239 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
1240 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
1241 if test "$resolution" = "yes" ; then
1242     resolution="none"
1244 if test "$resolution" = "no" ; then
1245     resolution="none"
1247 if test "$resolution" != "none" ; then
1248     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
1249     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
1250     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
1252 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
1253 aros_cv_default_wbwidth=$aros_default_wbwidth
1254 aros_cv_default_wbheight=$aros_default_wbheight
1255 aros_cv_default_wbdepth=$aros_default_wbdepth
1257 dnl See if the user wants the BOCHS hack for native flavour
1258 AC_MSG_CHECKING([if bochs hack is enabled])
1259 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")
1260 if test "$bochs_hack" = "yes" ; then
1261     aros_bochs_hack="1"
1263 AC_MSG_RESULT($bochs_hack)
1265 dnl See if the user wants the serial debug output for native flavour
1266 AC_MSG_CHECKING([if serial debug is enabled])
1267 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)
1268 if test "$serial_debug" = "yes" ; then
1269     serial_debug="2"
1271 if test "$serial_debug" = "no" ; then
1272     serial_debug="none"
1274 if test "$serial_debug" != "none" ; then
1275     aros_serial_debug=$serial_debug
1276     AC_MSG_RESULT(on port $serial_debug)
1277 else
1278     AC_MSG_RESULT(no)
1281 dnl See if the user wants the palm debug output hack for palm native flavour
1282 AC_MSG_CHECKING([if palm debug hack is enabled])
1283 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")
1284 if test "$palm_debug_hack" = "yes" ; then
1285     aros_palm_debug_hack="1"
1287 AC_MSG_RESULT($palm_debug_hack)
1290 dnl See if the user wants nesting supervisor activated for unix flavour
1291 AC_MSG_CHECKING([if nesting supervisor support is enabled])
1292 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")
1293 if test "$nesting_supervisor" = "yes" ; then
1294     aros_nesting_supervisor="1"
1296 AC_MSG_RESULT($nesting_supervisor)
1299 dnl things specifically required for hosted flavours
1300 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1302     if test "x-$aros_host_arch" != "x-darwin" ; then
1303       dnl some kind of dynamic library access system is required for hostlib.resource
1304       AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
1305       if test "x-$have_dl" = "x-no" ; then
1306           AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
1307                                     aros_host_ldflags="$aros_host_ldflags -ldl"],
1308                                     have_dl="no")
1309       fi
1310       if test "x-$have_dl" = "x-no" ; then
1311           AC_MSG_ERROR([dlopen() dynamic linker functions not available])
1312       fi
1313     fi
1316     dnl x11 hidd
1317     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
1318                                            [build X11 hidd for hosted (default=auto)]),
1319                                            x11_hidd="$enableval",
1320                                            x11_hidd="auto")
1321     case "x-$x11_hidd" in
1322         x-yes|x-no|x-auto)                 ;;
1323         *)                 x11_hidd="auto" ;;
1324     esac
1326     dnl they want it
1327     if test "x-$x11_hidd" != "x-no" ; then
1329         dnl find x11 stuff
1330         AC_PATH_X
1332         x_cflags=
1333         for path in $x_libraries
1334         do
1335             x_cflags="$x_cflags -L$path"
1336         done
1338         for path in $x_includes
1339         do
1340             x_cflags="$x_cflags -I$path"
1341         done
1342         
1343         if test "x-$no_x" = "x-yes" ; then
1345             dnl didn't find it
1346             if test "x-$x11_hidd" != "x-auto" ; then
1347                 dnl and they explicitly asked for it, bail out
1348                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
1349             fi
1350         
1351         else
1352             dnl found it, setup the metatarget
1353             x11_hidd_target=kernel-x11gfx
1356             dnl setup shared memory extensions
1357             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
1358                                                   [use X11 shared memory (default=auto)]),
1359                                                   x11_hidd_shm="$enableval",
1360                                                   x11_hidd_shm="auto")
1361             case "x-$x11_hidd_shm" in
1362                 x-yes|x-no|x-auto)                     ;;
1363                 *)                 x11_hidd_shm="auto" ;;
1364             esac
1366             have_xshm=no
1368             dnl they want it
1369             if test "x-$x11_hidd_shm" != "x-no" ; then
1371                 dnl system shm headers
1372                 AC_CHECK_HEADERS(sys/ipc.h)
1373                 AC_CHECK_HEADERS(sys/shm.h)
1375                 dnl got them
1376                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
1378                     dnl make sure X libs have shm functions
1379                     save_cflags="$CFLAGS"
1380                     CFLAGS="$CFLAGS $x_cflags"
1381                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
1382                     CFLAGS="$save_cflags"
1383                 fi
1384             fi
1386             dnl detection done, prepare output
1387             if test "x-$have_xshm" = "x-yes" ; then
1388                 dnl we can do shm
1389                 DO_XSHM_SUPPORT="1"
1390             elif test "x-$x11_hidd_shm" = "x-yes" ; then
1391                 dnl they explicitly asked for it, but we can't do it
1392                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
1393             else
1394                 dnl otherwise just disable it
1395                 DO_XSHM_SUPPORT="0"
1396             fi
1398             
1399             dnl setup vidmode (fullscreen) extensions
1400             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
1401                                                       [use X11 vidmode extension (default=auto)]),
1402                                                       x11_hidd_vidmode="$enableval",
1403                                                       x11_hidd_vidmode="auto")
1404             case "x-$x11_hidd_vidmode" in
1405                 x-yes|x-no|x-auto)                         ;;
1406                 *)                 x11_hidd_vidmode="auto" ;;
1407             esac
1409             have_vidmode=no
1411             dnl they want it
1412             if test "x-$x11_hidd_vidmode" != "x-no" ; then
1414                 dnl make sure X libs have vidmode functions
1415                 save_cflags="$CFLAGS"
1416                 CFLAGS="$CFLAGS $x_cflags"
1417                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
1418                 CFLAGS="$save_cflags"
1419             fi
1421             dnl detection done, prepare output
1422             if test "x-$have_vidmode" = "x-yes" ; then
1423                 dnl we can do vidmode
1424                 DO_VIDMODE_SUPPORT="1"
1425             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
1426                 dnl they explicitly asked for it, but we can't do it
1427                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
1428             else
1429                 dnl otherwise just disable it
1430                 DO_VIDMODE_SUPPORT="0"
1431             fi
1432         fi
1434         aros_host_x11_includes=$x_includes 
1435         aros_host_x11_libdirs=$x_libraries
1436     fi
1439     dnl sdl hidd
1440     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
1441                                            [build SDL hidd for hosted (default=auto)]),
1442                                            sdl_hidd="$enableval",
1443                                            sdl_hidd="auto")
1444     case "x-$sdl_hidd" in
1445         x-yes|x-no|x-auto)                 ;;
1446         *)                 sdl_hidd="auto" ;;
1447     esac
1449     dnl they want it
1450     if test "x-$sdl_hidd" != "x-no" ; then
1452         dnl find sdl
1453         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
1455         if test "x-$have_sdl" != "x-yes" ; then
1457             dnl didn't find it
1458             if test "x-$sdl_hidd" != "x-auto" ; then
1459                 dnl and they explicitly asked for it, bail out
1460                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
1461             fi
1463         else
1464             dnl found it, setup the metatarget
1465             sdl_hidd_target=kernel-hidd-sdl
1466             aros_host_sdl_cflags=SDL_CFLAGS
1467             aros_host_sdl_libs=SDL_LIBS
1468         fi
1469     fi
1474 dnl See if the user wants dbus.library
1475 AC_MSG_CHECKING([if building of dbus.library is enabled])
1476 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
1477 if test "$dbus" = "yes" ; then
1478     ENABLE_DBUS=1
1479     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
1480     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
1481     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
1482     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
1483 else
1484     ENABLE_DBUS=0
1486 AC_MSG_RESULT($dbus)
1489 dnl --------------------------------------------------------------------
1490 dnl Configuration Output Section
1491 dnl --------------------------------------------------------------------
1493 # Generic
1494 AC_SUBST(aros_arch)
1495 AC_SUBST(aros_cpu)
1496 AC_SUBST(aros_flavour)
1497 AC_SUBST(aros_flavour_uc)
1498 AC_SUBST(AROS_BUILDDIR)
1499 AC_SUBST(AROS_SRCDIR)
1500 AC_SUBST(AROS_PORTSSRCDIR)
1502 # Host related
1503 AC_SUBST(aros_cc_pre)
1504 AC_SUBST(aros_host_strip)
1505 AC_SUBST(aros_host_arch)
1506 AC_SUBST(aros_host_cpu)
1507 AC_SUBST(aros_host_cc)
1508 AC_SUBST(aros_host_ar)
1509 AC_SUBST(aros_host_ranlib)
1510 AC_SUBST(aros_host_ld)
1511 AC_SUBST(aros_host_make)
1512 AC_SUBST(aros_host_cflags)
1513 AC_SUBST(aros_host_ldflags)
1514 AC_SUBST(aros_host_debug)
1515 AC_SUBST(aros_host_mkdep)
1516 AC_SUBST(aros_host_mkargs)
1517 AC_SUBST(aros_host_exe_suffix)
1518 AC_SUBST(aros_host_lib_suffix)
1519 AC_SUBST(aros_tools_dir)
1520 AC_SUBST(aros_host_aclocal)
1521 AC_SUBST(aros_host_autoconf)
1522 AC_SUBST(aros_host_autoheader)
1523 AC_SUBST(aros_host_automake)
1525 # Target Related
1526 AC_SUBST(aros_target_guitheme)
1527 AC_SUBST(aros_target_bootloader)
1528 AC_SUBST(aros_target_arch)
1529 AC_SUBST(aros_target_cpu)
1530 AC_SUBST(aros_target_variant)
1531 AC_SUBST(aros_target_suffix)
1532 AC_SUBST(aros_target_incl)
1533 AC_SUBST(aros_target_ar)
1534 AC_SUBST(aros_target_ranlib)
1535 AC_SUBST(aros_kernel_nm)
1536 AC_SUBST(aros_target_cc)
1537 AC_SUBST(aros_kernel_cc)
1538 AC_SUBST(aros_target_as)
1539 AC_SUBST(aros_target_ld)
1540 AC_SUBST(aros_kernel_ld)
1541 AC_SUBST(aros_target_cc_includes)
1542 AC_SUBST(aros_target_cc_path)
1543 AC_SUBST(aros_target_objdump)
1544 AC_SUBST(aros_target_objcopy)
1545 AC_SUBST(aros_target_strip)
1546 AC_SUBST(aros_target_nm)
1547 AC_SUBST(aros_shared_default)
1548 AC_SUBST(aros_shared_ld)
1549 AC_SUBST(aros_object_format)
1550 AC_SUBST(aros_compiler_libs)
1552 AC_SUBST(aros_config_cflags)
1553 AC_SUBST(aros_config_aflags)
1554 AC_SUBST(aros_config_ldflags)
1556 AC_SUBST(aros_shared_cflags)
1557 AC_SUBST(aros_shared_aflags)
1558 AC_SUBST(aros_shared_ldflags)
1559 AC_SUBST(aros_kernel_ldflags)
1560 AC_SUBST(aros_debug_cflags)
1561 AC_SUBST(aros_debug_aflags)
1562 AC_SUBST(aros_debug_ldflags)
1563 AC_SUBST(aros_target_genmap)
1564 AC_SUBST(aros_target_strip_flags)
1566 # Graphics Related
1567 AC_SUBST(x11_hidd_target)
1568 AC_SUBST(sdl_hidd_target)
1570 AC_SUBST(aros_default_wbwidth)
1571 AC_SUBST(aros_default_wbheight)
1572 AC_SUBST(aros_default_wbdepth)
1573 AC_SUBST(DO_XSHM_SUPPORT)
1574 AC_SUBST(DO_VIDMODE_SUPPORT)
1576 AC_SUBST(aros_host_x11_includes)
1577 AC_SUBST(aros_host_x11_libdirs)
1578 AC_SUBST(aros_host_sdl_cflags)
1579 AC_SUBST(aros_host_sdl_libs)
1581 # Native version related
1582 AC_SUBST(aros_bochs_hack)
1583 AC_SUBST(aros_serial_debug)
1585 # Palm native version related
1586 AC_SUBST(aros_palm_debug_hack)
1588 # Unix/Hosted version related
1589 AC_SUBST(aros_nesting_supervisor)
1591 # DBUS related
1592 AC_SUBST(ENABLE_DBUS)
1593 AC_SUBST(DBUS_CFLAGS)
1594 AC_SUBST(DBUS_LIBFLAGS)
1595 AC_SUBST(KERNEL_DBUS_KOBJ)
1596 AC_SUBST(KERNEL_DBUS_INCLUDES)
1598 # Debug related
1599 AC_SUBST(aros_debug)
1600 AC_SUBST(aros_mungwall_debug)
1601 AC_SUBST(aros_stack_debug)
1602 AC_SUBST(aros_modules_debug)
1604 # Collect-aros stuff: "-ius" to ignore undefined symbols
1605 AC_SUBST(ignore_undefined_symbols)
1607 # C compiler related
1608 AC_SUBST(gcc_target_cpu)
1610 dnl Prepare for output, make up all the generated patches
1611 case "$aros_flavour" in
1612 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
1613                 aros_flavour="emulation" ;;
1614 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
1615                 aros_flavour="emulation" ;;
1616 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
1617                 aros_flavour="standalone";;
1618 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
1619                 aros_flavour="native" ;;
1620 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1621                 aros_flavour="native" ;;
1622 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
1623                 aros_flavour="linklib" ;;
1624 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1625                 aros_flavour="palmnative" ;;
1626 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1627                 aros_flavour="mac68knative" ;;
1628 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
1629                 aros_flavour="ppcnative" ;;
1630 esac
1632 if test ! -d ${aros_inc_dir} ; then
1633     ${MKDIR} ${aros_inc_dir}
1635 if test ! -d ${aros_geninc_dir} ; then
1636     ${MKDIR} ${aros_geninc_dir}
1638 if test ! -d ${aros_hostcfg_dir} ; then
1639     ${MKDIR} ${aros_hostcfg_dir}
1641 if test ! -d ${aros_targetcfg_dir} ; then
1642     ${MKDIR} ${aros_targetcfg_dir}
1644 if test ! -d ${aros_tools_dir} ; then
1645     ${MKDIR} ${aros_tools_dir}
1647 if test ! -d ${aros_scripts_dir} ; then
1648     ${MKDIR} ${aros_scripts_dir}
1651 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
1653 AC_CONFIG_COMMANDS([compiler_executable],
1654     [
1655         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
1656         mkdir -p $prefix
1657         prefix="${prefix}/${aros_target_cpu}-aros"
1658         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
1660         echo ${prefix}
1661         echo ${prefix2}
1662         chmod a+x ${prefix2}-gcc ${prefix2}-ld
1664         ln -sf ${prefix2}-gcc          ${prefix}-gcc
1665         ln -sf ${prefix2}-ld           ${prefix}-ld
1667         ln -sf $aros_target_as_ln      ${prefix}-as
1668         ln -sf $aros_target_nm_ln      ${prefix}-nm
1669         ln -sf $aros_target_ar_ln      ${prefix}-ar
1670         ln -sf $aros_target_ranlib_ln  ${prefix}-ranlib
1671         ln -sf $aros_target_objcopy_ln ${prefix}-objcopy
1672         ln -sf $aros_target_objdump_ln ${prefix}-objdump
1673         ln -sf $aros_target_strip_ln   ${prefix}-strip
1675         ln -sf $aros_target_as_ln      ${prefix2}-as
1676         ln -sf $aros_target_nm_ln      ${prefix2}-nm
1677         ln -sf $aros_target_ar_ln      ${prefix2}-ar
1678         ln -sf $aros_target_ranlib_ln  ${prefix2}-ranlib
1679         ln -sf $aros_target_objcopy_ln ${prefix2}-objcopy
1680         ln -sf $aros_target_objdump_ln ${prefix2}-objdump
1681         ln -sf $aros_target_strip_ln   ${prefix2}-strip
1682     ],
1683     [
1684         aros_tools_dir=${aros_tools_dir}
1685         aros_target_cpu=${aros_target_cpu}
1686         aros_target_arch=${aros_target_arch}
1687         aros_target_suffix=${aros_target_suffix}
1688         aros_target_nm_ln=${aros_target_nm_ln}
1689         aros_target_as_ln=${aros_target_as_ln}
1690         aros_target_ar_ln=${aros_target_ar_ln}
1691         aros_target_ranlib_ln=${aros_target_ranlib_ln}
1692         aros_target_objdump_ln=${aros_target_objdump_ln}
1693         aros_target_objcopy_ln=${aros_target_objcopy_ln}
1694         aros_target_strip_ln=${aros_target_strip_ln}
1695     ]
1697 AC_CONFIG_COMMANDS([genshared_executable],
1698     [chmod a+x ${aros_scripts_dir}/genshared],
1699     [aros_scripts_dir=${aros_scripts_dir}]
1701 AC_CONFIG_COMMANDS([genmf_executable],
1702     [chmod a+x ${aros_tools_dir}/genmf.py],
1703     [aros_tools_dir=${aros_tools_dir}]
1705 AC_CONFIG_COMMANDS([adflib_myaros.conf_executable],
1706     [chmod a+x tools/adflib/myconf.aros]
1709 AC_CONFIG_FILES(
1710     Makefile
1711     rom/mmakefile
1712     config/make.cfg
1713     ${aros_inc_dir}/config.h:config/config.h.in
1714     ${aros_geninc_dir}/config.h:config/config.h.in
1715     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
1716     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
1717     mmake.config
1718     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
1719     ${aros_targetcfg_dir}/specs:config/specs.in
1720     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
1721     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
1722     ${aros_scripts_dir}/genshared:compiler/c_lib/source/lib_source/genshared.in
1723     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
1724     tools/adflib/myconf.aros
1725     tools/collect-aros/env.h
1728 AC_OUTPUT
1730 dnl This is in order to not define SHARED_CFLAGS sometimes
1731 dnl We don't always do aros_shared_ar, aros_shared_cflags
1733 #XXX compatability...
1734 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
1736 if test -n "$aros_shared_cflags" ; then
1737     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
1738     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg