Used AROS_SLOWSTACKHOOKS macros to make CallHook working on x86-64.
[AROS.git] / configure.in
blobf1f11b1175d7eea783e042cf226550403e5ac88d
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_config_cflags="$aros_config_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             *)
662                 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
663                 ;;
664         esac
665     ;;
667     pc)
668         aros_target_arch="pc"
669         aros_shared_default="no"
670         target_bootloader="grub"
671         case "$target_cpu" in
672             *i?86*)
673                 aros_target_cpu="i386"
675                 dnl If somebody hasn't already set the target object
676                 dnl format, then use this value. Mostly to support
677                 dnl FreeBSD cross-compilation.
678                 dnl TODO: Remove when we always use our compiler.
680                 if test "$aros_object_format" = "" ; then
681                     aros_object_format="elf_i386"
682                 fi
683                 aros_flavour="standalone"
684                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
685                 aros_kernel_ldflags=""
686                 aros_default_wbwidth=640
687                 aros_default_wbheight=480
688                 gcc_target_cpu="i386"
689                 ;;
690             *x86_64*)
691                 aros_target_cpu="x86_64"
692                 if test "$aros_object_format" = "" ; then
693                     aros_object_format="elf_x86_64"
694                 fi
695                 aros_flavour="standalone"
696                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dx86_64"
697                 aros_config_cflags="$aros_config_cflags -fno-asynchronous-unwind-tables -mno-red-zone"
698                 aros_kernel_ldflags=""
699                 aros_default_wbwidth=640
700                 aros_default_wbheight=480
701                 gcc_target_cpu="x86_64"
702                 ;;
703             *)
704                 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
705                 ;;
706         esac
707         ;;
709     prep)
710         aros_target_arch="prep"
711         aros_shared_default="no"
712         aros_target_cpu="ppc"
713         aros_object_format="elf32ppc"
714         aros_flavour="ppcnative"
715         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
716         aros_kernel_ldflags=""
717         aros_default_wbwidth=640
718         aros_default_wbheight=480
719         gcc_target_cpu="ppc"
720         case "$target_cpu" in
721             *cross*)
722                 aros_target_cc="ppc-linux-gcc -pipe"
723                 aros_target_ld="ppc-linux-ld"
724                 aros_target_as="ppc-linux-as"
725                 aros_target_ar="ppc-linux-ar"
726                 aros_target_ranlib="ppc-linux-ranlib"
727                 aros_target_nm="ppc-linux-nm"
728                 aros_target_strip="ppc-linux-strip"
729                 aros_target_objcopy="ppc-linux-objcopy"
730                 aros_target_objdump="ppc-linux-objdump"
731                 aros_shared_ld="ppc-linux-ld"
732                 aros_kernel_ld="ppc-linux-ld"
733                 ;;
734             *)
735                 ;;
736         esac
737         ;;
739     freebsd*)
740         aros_target_arch="freebsd"
741         aros_target_cpu="i386"
742         aros_flavour="emulation"
743         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
744         gcc_target_cpu="i386"
746         aros_target_strip_flags="-x"
747         ;;
749     darwin*)
750         aros_target_arch="darwin"
751         aros_target_cpu="i386"
752         aros_flavour="emulation"
753         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
754         gcc_target_cpu="i386"
756         aros_target_strip_flags="-x"
757         ;;
759     netbsd*)
760         aros_target_arch="netbsd"
761         case "$target_cpu" in
762             *m68k*)
763                 aros_target_cpu="m68k"
764                 aros_object_format="m68kelf"
765                 aros_flavour="emulcompat"
766                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__NetBSD__"
767                 gcc_target_cpu="mc68000"
768                 ;;
769             *i?86*)
770                 aros_target_cpu="i386"
771                 aros_object_format="elf_i386"
772                 aros_flavour="emulation"
773                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__NetBSD__"
774                 aros_default_wbdepth=8
775                 gcc_target_cpu="i386"
776                 ;;
777             *)
778                 AC_MSG_ERROR("Unknown CPU for NetBSD -- $target_cpu")
779                 ;;
780         esac
781         aros_target_genmap="-Wl,-M -Xlinker >"
782         aros_flavour="emulation"
783         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
784         ;;   
786     openbsd*)
787         aros_target_arch="openbsd"
788         case "$target_cpu" in
789             *i?86*)
790                 aros_target_cpu="i386"
791                 aros_object_format="elf_i386"
792                 aros_flavour="emulation"
793                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__OpenBSD__"
794                 gcc_target_cpu="i386"
795                 ;;
796             *)
797                 AC_MSG_ERROR("Unknown CPU for OpenBSD -- $target_cpu")
798                 ;;
799         esac
800         aros_target_genmap="-Wl,-M -Xlinker >"
801         aros_target_nm_flags="-u"
802         aros_flavour="emulation"
803         ;;
805     solaris*)
806         aros_target_arch="solaris"
807         case "$target_cpu" in
808             *sparc*)
809                 aros_target_cpu="sparc"
810                 aros_object_format="elf_sparc"
811                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dsparc -D__Solaris__"
812                 gcc_target_cpu="sparc"
813                 ;;
814             *)
815                 AC_MSG_ERROR("Unknown CPU for Solaris -- $target_cpu")
816                 ;;
817         esac
818         aros_config_cflags="$aros_config_cflags -D$aros_target_cpu"
819         aros_flavour="emulation"
820         ;;
822     morphos*)
823         aros_target_arch="morphos"
824         aros_shared_default="no"
825         aros_target_cpu="ppc"
826         aros_object_format="elf_ppc"
827         aros_flavour="nativecompat"
828         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
829         gcc_target_cpu="ppc"
830         ;;
832     sam440)
833         aros_target_arch="sam440"
834         aros_shared_default="no"
835         aros_target_cpu="ppc"
836         aros_object_format="elf32ppc"
837         aros_flavour="ppcnative"
838         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dppc"
839         aros_kernel_ldflags=""
840         aros_default_wbwidth=640
841         aros_default_wbheight=480
842         aros_config_cflags="$aros_config_cflags -mcpu=440fp -mno-toc -fno-asynchronous-unwind-tables"
843         gcc_target_cpu="powerpc"
844         case "$target_cpu" in
845             *powerpc*)
846                 aros_target_cc="powerpc-linux-gcc -pipe"
847                 aros_target_ld="powerpc-linux-ld"
848                 aros_target_as="powerpc-linux-as"
849                 aros_target_ar="powerpc-linux-ar"
850                 aros_target_ranlib="powerpc-linux-ranlib"
851                 aros_target_nm="powerpc-linux-nm"
852                 aros_target_strip="powerpc-linux-strip"
853                 aros_target_objcopy="powerpc-linux-objcopy"
854                 aros_target_objdump="powerpc-linux-objdump"
855                 aros_shared_ld="powerpc-linux-ld"
856                 aros_kernel_ld="powerpc-linux-ld"
857                 ;;
858             *)
859                 ;;
860         esac
861         ;;
863     amiga*)
864         aros_target_arch="amiga"
865         aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
866         aros_shared_default="no"
868         aros_config_cflags="$aros_config_cflags -fomit-frame-pointer -fbuiltin -ffreestanding"
870         case "$target_cpu" in
871             *m68k*)
872                 aros_target_cpu="m68k"
873                 aros_object_format="m68kelf"
874                 aros_flavour="nativecompat"
875                 gcc_target_cpu="mc68000"
876                 ;;
877             *ppc*)
878                 aros_cpu="ppc"
879                 aros_flavour="native"
880                 gcc_target_cpu="ppc"
881                 ;;
882             *)
883                 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
884                 ;;
885         esac
886         ;;
888     cygwin*)
889         aros_target_arch="cygwin"
890         aros_shared_default="no"
891         case "$target_cpu" in
892             *i?86*)
893                 aros_target_cpu="i386"
894                 aros_object_format="elf_i386"
895                 aros_flavour="emulation"
896                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
897                 aros_shared_cflags=""
898                 aros_default_wbdepth=8
899                 gcc_target_cpu="i386"
900                 ;;
901             *)
902                 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
903                 ;;
904         esac
905     ;;
907     mingw32*)
908         aros_target_arch="mingw32"
909         aros_shared_default="no"
910         case "$target_cpu" in
911             *i?86*)
912                 aros_target_cpu="i386"
913                 aros_object_format="elf_i386"
914                 aros_flavour="emulation"
915                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
916                 aros_shared_cflags=""
917                 aros_default_wbdepth=8
918                 gcc_target_cpu="i386"
919                 ;;
920             *)
921                 AC_MSG_ERROR("Unknown CPU for Mingw32 -- $target_cpu")
922                 ;;
923         esac
924     ;;
925     pp*)
926         aros_target_arch="pp"
927         aros_shared_default="no"
928         case "$target_cpu" in
929             *m68k*)
930                 aros_target_cpu="m68k"
931                 aros_object_format="m68kelf"
932                 aros_flavour="palmnative"
933                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
934                 aros_kernel_ldflags=""
935                 aros_default_wbwidth=160
936                 aros_default_wbheight=160
937                 aros_default_wbdepth=1
938                 aros_target_cc="m68k-elf-gcc -pipe"
939                 aros_target_ld="$(which m68k-elf-ld)"
940                 aros_target_as="m68k-elf-gcc -pipe"
941                 aros_shared_ld="m68k-elf-gcc"
942                 aros_kernel_ld="m68k-elf-gcc"
943                 aros_target_ar="m68k-elf-ar"
944                 aros_target_ar_flags="cru"
945                 aros_target_ranlib="m68k-elf-ranlib"
946                 aros_target_nm="m68k-elf-nm"
947                 aros_target_objcopy="m68k-elf-objcopy"
948                 aros_target_objdump="m68k-elf-objdump"
949                 aros_compiler_libs="-lgcc1"
950                 aros_shared_default=no
951                 aros_shared_cflags="-fpic"
952                 aros_shared_aflags=""
953                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
954                 aros_kernel_ldflags="-Wl,-rpath,./lib"
955                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000 -Wa,-mc68000"
956                 aros_debug_aflags=""
957                 aros_debug_ldflags="$aros_symbols_debug"
958                 aros_mungwall_debug="0"
959                 aros_modules_debug="0"
960                 gcc_target_cpu="mc68000"
961                 ignore_undefined_symbols="-ius"
962                 ;;
963            *)
964                 AC_MSG_ERROR("Unknown CPU for PalmPilot -- $target_cpu")
965                 ;;
966         esac
967         ;;
969     mac*)
970         aros_target_arch="mac"
971         aros_shared_default="no"
972         case "$target_cpu" in
973             *m68k*)
974                 aros_target_cpu="m68k"
975                 aros_object_format="m68kelf"
976                 aros_flavour="mac68knative"
977                 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Dm68k"
978                 aros_default_wbwidth=512
979                 aros_default_wbheight=384
980                 aros_default_wbdepth=8
981                 aros_target_cc="m68k-elf-gcc -pipe"
982                 aros_target_ld="$(which m68k-elf-ld)"
983                 aros_target_as="m68k-elf-gcc -pipe"
984                 aros_shared_ld="m68k-elf-gcc"
985                 aros_kernel_ld="m68k-elf-gcc"
986                 aros_target_ar="m68k-elf-ar"
987                 aros_target_ar_flags="cru"
988                 aros_target_ranlib="m68k-elf-ranlib"
989                 aros_target_nm="m68k-elf-nm"
990                 aros_target_objcopy="m68k-elf-objcopy"
991                 aros_target_objdump="m68k-elf-objdump"
992                 aros_compiler_libs="-lgcc1"
993                 aros_shared_default=no
994                 aros_shared_cflags="-fpic"
995                 aros_shared_aflags=""
996                 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
997                 aros_kernel_ldflags="-Wl,-rpath,./lib"
998                 aros_debug_cflags="-Wall -Werror-implicit-function-declaration $aros_symbols_debug  $aros_messages_debug -mc68000"
999                 aros_debug_aflags=""
1000                 aros_debug_ldflags="$aros_symbols_debug"
1001                 aros_mungwall_debug="0"
1002                 aros_modules_debug="0"
1003                 gcc_target_cpu="mc68000"
1004                 ignore_undefined_symbols="-ius"
1005                 ;;
1006            *)
1007                 AC_MSG_ERROR("Unknown CPU for Mac68k -- $target_cpu")
1008                 ;;
1009         esac
1010         ;;
1012     *)
1013         AC_MSG_ERROR([Unsupported target architecture $target])
1014         ;;
1015 esac
1017 AC_MSG_CHECKING([Where to download sourcecode for external ports])
1018 AC_ARG_WITH(portssources,AC_HELP_STRING([--with-portssources=DIR],[Where to download sourcecode for external ports]),with_portssrcdir=$withval,with_portssrcdir="default")
1019 if test "$with_portssrcdir" = "default"; then
1020     AROS_PORTSSRCDIR="$AROS_BUILDDIR/bin/Sources"
1021 else
1022     AROS_PORTSSRCDIR="$with_portssrcdir"
1024 AC_MSG_RESULT($AROS_PORTSSRCDIR)
1026 AC_MSG_CHECKING([which bootloader to use])
1027 AC_ARG_WITH(bootloader,AC_HELP_STRING([--with-bootloader=NAME],[Use a specific bootloader]),target_bootloader=$withval,target_bootloader=$target_bootloader)
1028 if test "$target_bootloader" = "none"; then
1029     aros_target_bootloader=""
1030 else
1031     aros_target_bootloader="$target_bootloader"
1033 AC_MSG_RESULT($target_bootloader)
1035 # Check LZO when compiling the grub2 bootloader on i386/x86_64.
1036 aros_liblzo_check="no"
1037 case "$aros_target_bootloader" in
1038     grub2*)
1039     case "$target_cpu" in
1040         *i?86*)
1041         aros_liblzo_check="yes"
1042         ;;
1043         *x86_64*)
1044         aros_liblzo_check="yes"  
1045         ;;
1046         *)
1047         ;;
1048     esac
1049   
1050     ;;
1051    *)
1052     ;;
1053 esac
1055 if test "$aros_liblzo_check" = "yes"; then
1056     # There are three possibilities. LZO version 2 installed with the name
1057     # liblzo2, with the name liblzo, and LZO version 1.  
1058     AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"],  
1059     AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"],
1060                 AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"],
1061                 AC_MSG_ERROR([LZO library version 1.02 or later is required]))))
1063     AC_SUBST(LIBLZO)
1064     LIBS="$LIBS $LIBLZO"
1065     AC_CHECK_FUNC(lzo1x_999_compress, ,
1066                 [AC_MSG_ERROR([LZO1X-999 must be enabled])])
1068     # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.
1069     AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h)
1072 AC_MSG_CHECKING([which GUI Theme to use])
1073 AC_ARG_WITH(theme,AC_HELP_STRING([--with-theme=NAME],[Use a specific GUI Theme]),target_guitheme=$withval,target_guitheme="default")
1074 if test "$target_guitheme" = "default"; then
1075     aros_target_guitheme="Ice"
1076 else
1077     aros_target_guitheme="$target_guitheme"
1079 AC_MSG_RESULT($aros_target_guitheme)
1081 # Find out if we are cross-compiling (ie. if we can't use the host compiler
1082 # for target code)
1083 cross_compiling=no
1084 if test "$aros_host_cpu" != "$aros_target_cpu" ; then
1085     cross_compiling=yes
1087 if test "$aros_host_arch" == "darwin" ; then
1088     cross_compiling=yes
1091 # Set prefix for target compiler etc. if we're cross-compiling
1092 # (should possibly be earlier but needs to be after AC_PROG_CC)
1093 if test "$cross_compiling" = "yes" ; then
1094     target_tool_prefix=${target_cpu}-elf-
1095     CC=${target_tool_prefix}gcc
1098 # Find all the tools we need to compile. This could be cross-compiling
1099 # though! If that is the case we use the GNU form of the target and
1100 # simply add this to the front of the binary name. This is rather simple,
1101 # but it should work under most circumstances.
1103 # The default tools are to use the same as the host, but only if the
1104 # host and target CPU are the same. With GCC this is normally enough.
1107 aros_cc_pre=""
1108 aros_shared_ld="$aros_host_ld"
1110 aros_target_mkdep="$aros_host_mkdep"
1111 aros_target_incl_def="$aros_host_incl"
1113 AC_PATH_PROG(aros_kernel_cc,$CC)
1115 # The default tools executables to be linked to.
1116 AROS_TOOL_TARGET(aros_target_as_ln,as)
1117 AROS_REQUIRED(as,$aros_target_as_ln)
1118 AROS_TOOL_TARGET(aros_kernel_ld,ld)
1119 AROS_REQUIRED(ld,$aros_kernel_ld)
1120 AROS_TOOL_TARGET(aros_target_ar_ln,ar)
1121 AROS_REQUIRED(ar,$aros_target_ar_ln)
1122 AROS_TOOL_TARGET(aros_target_nm_ln,nm)
1123 AROS_REQUIRED(nm,$aros_target_nm_ln)
1124 AROS_TOOL_TARGET(aros_target_objcopy_ln,objcopy)
1125 AROS_REQUIRED(objcopy,$aros_target_objcopy_ln)
1126 AROS_TOOL_TARGET(aros_target_objdump_ln,objdump)
1127 AROS_REQUIRED(objdump,$aros_target_objdump_ln)
1128 AROS_TOOL_TARGET(aros_target_ranlib_ln,ranlib)
1129 AROS_REQUIRED(ranlib,$aros_target_ranlib_ln)
1130 AROS_TOOL_TARGET(aros_target_strip_ln,strip)
1131 AROS_REQUIRED(strip,$aros_target_strip_ln)
1133 if test "$GCC" = "yes"; then
1134     aros_target_cc_path=`$aros_kernel_cc -print-search-dirs | grep "programs: =" | cut -c 12-`
1137 aros_hostcfg_dir="bin/${aros_host_arch}-${aros_host_cpu}/gen/config"
1138 aros_targetcfg_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/config"
1139 aros_inc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/AROS/Development/include/aros"
1140 aros_gendir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen"
1141 aros_geninc_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/include/aros"
1142 aros_tools_dir="bin/${aros_host_arch}-${aros_host_cpu}/tools"
1143 aros_scripts_dir="bin/${aros_target_arch}-${aros_target_cpu}${aros_target_suffix}/gen/scripts"
1145 # aros_cc_pre is a variable that is added to the front of the compiler name
1146 # in the generated aros-gcc shell script. We need this to enable the cache
1147 # to work across cleaned builds. Also, support DISTCC using the correct
1148 # environment variable.
1151 if test "x${DISTCC}" != "x" ; then
1152     if test "x${CCACHE}" != "x" ; then
1153         aros_cc_pre="env CCACHE_PREFIX=${DISTCC} ${CCACHE} "
1154     else
1155         aros_cc_pre="${DISTCC} "
1156     fi
1157 else
1158     if test "x${CCACHE}" != "x" ; then
1159         aros_cc_pre="${CCACHE} "
1160     fi
1163 prefix="${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros"
1165 AC_SUBST(aros_target_nostdinc_cflags,-nostdinc)
1166 AC_SUBST(aros_target_nostartup_ldflags,-nostartfiles)
1167 AC_SUBST(aros_target_nix_ldflags,-nix)
1168 AC_SUBST(aros_target_detach_ldflags,-detach)
1169 AC_SUBST(aros_target_nostdlib_ldflags,-nostdlib)
1171 # Target tools
1172 aros_target_cc="${prefix}-gcc"
1173 aros_target_as="${prefix}-as"
1174 aros_target_ld="${prefix}-ld"
1175 aros_target_ar="${prefix}-ar $aros_target_ar_flags"
1176 aros_target_objcopy=${prefix}-objcopy
1177 aros_target_objdump=${prefix}-objdump
1178 aros_target_ranlib="${prefix}-ranlib $aros_target_ranlib_flags"
1179 aros_target_nm="${prefix}-nm $aros_target_nm_flags"
1180 aros_kernel_nm="${prefix}-nm"
1181 aros_target_strip=${prefix}-strip
1183 # Find the system include path. We can suggest that an alternative is
1184 # used if we don't get it correct. The default is to use /usr/include.
1185 # Which is set in the aros_target_incl_def variable.
1187 AC_ARG_ENABLE(includes,
1188 AC_HELP_STRING([--enable-includes=dir],[Alternative system include directory]),
1189 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
1191 dnl find out about the target cc's include path
1192 AC_MSG_CHECKING([for the target compiler's include path])
1193 if test "$aros_target_cc_includes" = "" ; then
1194     #try to guess where the directory is
1195     aros_target_cc_includes=`dirname \`${aros_kernel_cc} -print-libgcc-file-name\``/include
1196     if ! test -d $aros_target_cc_includes; then
1197         #the directory doesn't exist, we need to do some more work
1198         aros_target_cc_includes=${PWD}/${aros_gendir}/cc_include
1199         
1200         #these are the headers we're looling for
1201         headers="limits.h mmintrin.h stdbool.h syslimits.h float.h \
1202                  stddef.h xmmintrin.h iso646.h stdarg.h unwind.h   \
1203                  zutil.h"
1205         dirs=
1206         for h in $headers; do
1207             #which other headers each of the above headers needs?
1208             deps=$(echo "#include <$h>" | \
1209                    $aros_host_cc -E -M - 2>/dev/null | \
1210                    sed 's/^.*://; s/\\$/ /g; s/[[ \t]]\+/ /g')
1211             
1212             #copy all the needed headers to a directory beneath gendir
1213             for d in $deps; do
1214                 h=$(basename $d)
1215                 dir=${aros_target_cc_includes}$(echo $(dirname $d) | \
1216                                                 sed -n "s,^.*/include\(/.*\),\1,p")
1217                 ! test -d $dir && mkdir -p $dir
1218                 ! test -f $dir/$h && { cp $d $dir; chmod u+w $dir/$h; }
1219             done
1220         done        
1221     fi
1223 AC_MSG_RESULT($aros_target_cc_includes)
1225 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
1226 AC_MSG_CHECKING([for default resolution of WBScreen])
1227 AC_ARG_WITH(resolution,AC_HELP_STRING([--with-resolution=XRESxYRESxDEPTH],[Default resolution of the initial WorkbenchScreen]),resolution=$withval,resolution=none)
1228 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
1229 if test "$resolution" = "yes" ; then
1230     resolution="none"
1232 if test "$resolution" = "no" ; then
1233     resolution="none"
1235 if test "$resolution" != "none" ; then
1236     aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
1237     aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
1238     aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
1240 AC_MSG_RESULT($aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth)
1241 aros_cv_default_wbwidth=$aros_default_wbwidth
1242 aros_cv_default_wbheight=$aros_default_wbheight
1243 aros_cv_default_wbdepth=$aros_default_wbdepth
1245 dnl See if the user wants the BOCHS hack for native flavour
1246 AC_MSG_CHECKING([if bochs hack is enabled])
1247 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")
1248 if test "$bochs_hack" = "yes" ; then
1249     aros_bochs_hack="1"
1251 AC_MSG_RESULT($bochs_hack)
1253 dnl See if the user wants the serial debug output for native flavour
1254 AC_MSG_CHECKING([if serial debug is enabled])
1255 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)
1256 if test "$serial_debug" = "yes" ; then
1257     serial_debug="2"
1259 if test "$serial_debug" = "no" ; then
1260     serial_debug="none"
1262 if test "$serial_debug" != "none" ; then
1263     aros_serial_debug=$serial_debug
1264     AC_MSG_RESULT(on port $serial_debug)
1265 else
1266     AC_MSG_RESULT(no)
1269 dnl See if the user wants the palm debug output hack for palm native flavour
1270 AC_MSG_CHECKING([if palm debug hack is enabled])
1271 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")
1272 if test "$palm_debug_hack" = "yes" ; then
1273     aros_palm_debug_hack="1"
1275 AC_MSG_RESULT($palm_debug_hack)
1278 dnl See if the user wants nesting supervisor activated for unix flavour
1279 AC_MSG_CHECKING([if nesting supervisor support is enabled])
1280 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")
1281 if test "$nesting_supervisor" = "yes" ; then
1282     aros_nesting_supervisor="1"
1284 AC_MSG_RESULT($nesting_supervisor)
1287 dnl things specifically required for hosted flavours
1288 if test "x-$aros_flavour" = "x-emulation" -o "x-$aros_flavour" = "x-emulcompat" ; then
1290     dnl some kind of dynamic library access system is required for hostlib.resource
1291     AC_CHECK_FUNC(dlopen, have_dl="yes", have_dl="no")
1292     if test "x-$have_dl" = "x-no" ; then
1293         AC_CHECK_LIB(dl, dlopen, [have_dl="yes"
1294                                   aros_host_ldflags="$aros_host_ldflags -ldl"],
1295                                  have_dl="no")
1296     fi
1297     if test "x-$have_dl" = "x-no" ; then
1298          AC_MSG_ERROR([dlopen() dynamic linker functions not available])
1299     fi
1302     dnl x11 hidd
1303     AC_ARG_ENABLE(x11_hidd, AC_HELP_STRING([--enable-x11-hidd],
1304                                            [build X11 hidd for hosted (default=auto)]),
1305                                            x11_hidd="$enableval",
1306                                            x11_hidd="auto")
1307     case "x-$x11_hidd" in
1308         x-yes|x-no|x-auto)                 ;;
1309         *)                 x11_hidd="auto" ;;
1310     esac
1312     dnl they want it
1313     if test "x-$x11_hidd" != "x-no" ; then
1315         dnl find x11 stuff
1316         AC_PATH_X
1318         x_cflags=
1319         for path in $x_libraries
1320         do
1321             x_cflags="$x_cflags -L$path"
1322         done
1324         for path in $x_includes
1325         do
1326             x_cflags="$x_cflags -I$path"
1327         done
1328         
1329         if test "x-$no_x" = "x-yes" ; then
1331             dnl didn't find it
1332             if test "x-$x11_hidd" != "x-auto" ; then
1333                 dnl and they explicitly asked for it, bail out
1334                 AC_MSG_ERROR([X11 libs/headers not found, cannot build X11 hidd as requested])
1335             fi
1336         
1337         else
1338             dnl found it, setup the metatarget
1339             x11_hidd_target=kernel-x11gfx
1342             dnl setup shared memory extensions
1343             AC_ARG_ENABLE(x11_shm, AC_HELP_STRING([--enable-x11-shm],
1344                                                   [use X11 shared memory (default=auto)]),
1345                                                   x11_hidd_shm="$enableval",
1346                                                   x11_hidd_shm="auto")
1347             case "x-$x11_hidd_shm" in
1348                 x-yes|x-no|x-auto)                     ;;
1349                 *)                 x11_hidd_shm="auto" ;;
1350             esac
1352             have_xshm=no
1354             dnl they want it
1355             if test "x-$x11_hidd_shm" != "x-no" ; then
1357                 dnl system shm headers
1358                 AC_CHECK_HEADERS(sys/ipc.h)
1359                 AC_CHECK_HEADERS(sys/shm.h)
1361                 dnl got them
1362                 if test "x-$ac_cv_header_sys_ipc_h" = "x-yes" -a "x-$ac_cv_header_sys_shm_h" = "x-yes" ; then
1364                     dnl make sure X libs have shm functions
1365                     save_cflags="$CFLAGS"
1366                     CFLAGS="$CFLAGS $x_cflags"
1367                     AC_CHECK_LIB(Xext, XShmQueryExtension, have_xshm=yes)
1368                     CFLAGS="$save_cflags"
1369                 fi
1370             fi
1372             dnl detection done, prepare output
1373             if test "x-$have_xshm" = "x-yes" ; then
1374                 dnl we can do shm
1375                 DO_XSHM_SUPPORT="1"
1376             elif test "x-$x11_hidd_shm" = "x-yes" ; then
1377                 dnl they explicitly asked for it, but we can't do it
1378                 AC_MSG_ERROR([X11 has no support for shared memory, cannot enable it as requested])
1379             else
1380                 dnl otherwise just disable it
1381                 DO_XSHM_SUPPORT="0"
1382             fi
1384             
1385             dnl setup vidmode (fullscreen) extensions
1386             AC_ARG_ENABLE(x11_vidmode, AC_HELP_STRING([--enable-x11-vidmode],
1387                                                       [use X11 vidmode extension (default=auto)]),
1388                                                       x11_hidd_vidmode="$enableval",
1389                                                       x11_hidd_vidmode="auto")
1390             case "x-$x11_hidd_vidmode" in
1391                 x-yes|x-no|x-auto)                         ;;
1392                 *)                 x11_hidd_vidmode="auto" ;;
1393             esac
1395             have_vidmode=no
1397             dnl they want it
1398             if test "x-$x11_hidd_vidmode" != "x-no" ; then
1400                 dnl make sure X libs have vidmode functions
1401                 save_cflags="$CFLAGS"
1402                 CFLAGS="$CFLAGS $x_cflags"
1403                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, have_vidmode=yes)
1404                 CFLAGS="$save_cflags"
1405             fi
1407             dnl detection done, prepare output
1408             if test "x-$have_vidmode" = "x-yes" ; then
1409                 dnl we can do vidmode
1410                 DO_VIDMODE_SUPPORT="1"
1411             elif test "x-$x11_hidd_vidmode" = "x-yes" ; then
1412                 dnl they explicitly asked for it, but we can't do it
1413                 AC_MSG_ERROR([X11 vidmode extension not available, cannot enable it as requested])
1414             else
1415                 dnl otherwise just disable it
1416                 DO_VIDMODE_SUPPORT="0"
1417             fi
1418         fi
1420         aros_host_x11_includes=$x_includes 
1421         aros_host_x11_libdirs=$x_libraries
1422     fi
1425     dnl sdl hidd
1426     AC_ARG_ENABLE(sdl_hidd, AC_HELP_STRING([--enable-sdl-hidd],
1427                                            [build SDL hidd for hosted (default=auto)]),
1428                                            sdl_hidd="$enableval",
1429                                            sdl_hidd="auto")
1430     case "x-$sdl_hidd" in
1431         x-yes|x-no|x-auto)                 ;;
1432         *)                 sdl_hidd="auto" ;;
1433     esac
1435     dnl they want it
1436     if test "x-$sdl_hidd" != "x-no" ; then
1438         dnl find sdl
1439         AM_PATH_SDL([1.2.10], have_sdl="yes", have_sdl="no")
1441         if test "x-$have_sdl" != "x-yes" ; then
1443             dnl didn't find it
1444             if test "x-$sdl_hidd" != "x-auto" ; then
1445                 dnl and they explicitly asked for it, bail out
1446                 AC_MSG_ERROR([SDL libs/headers not found, cannot build SDL hidd as requested])
1447             fi
1449         else
1450             dnl found it, setup the metatarget
1451             sdl_hidd_target=kernel-hidd-sdl
1452             aros_host_sdl_cflags=SDL_CFLAGS
1453             aros_host_sdl_libs=SDL_LIBS
1454         fi
1455     fi
1460 dnl See if the user wants dbus.library
1461 AC_MSG_CHECKING([if building of dbus.library is enabled])
1462 AC_ARG_ENABLE(dbus,AC_HELP_STRING([--enable-dbus],[Enable DBUS support via dbus.library (default=no)]),dbus="yes",dbus="no")
1463 if test "$dbus" = "yes" ; then
1464     ENABLE_DBUS=1
1465     DBUS_CFLAGS=`pkg-config --cflags dbus-1`
1466     DBUS_LIBFLAGS=`pkg-config --libs dbus-1`
1467     KERNEL_DBUS_KOBJ=kernel-dbus-kobj
1468     KERNEL_DBUS_INCLUDES=kernel-dbus-includes
1469 else
1470     ENABLE_DBUS=0
1472 AC_MSG_RESULT($dbus)
1475 dnl --------------------------------------------------------------------
1476 dnl Configuration Output Section
1477 dnl --------------------------------------------------------------------
1479 # Generic
1480 AC_SUBST(aros_arch)
1481 AC_SUBST(aros_cpu)
1482 AC_SUBST(aros_flavour)
1483 AC_SUBST(aros_flavour_uc)
1484 AC_SUBST(AROS_BUILDDIR)
1485 AC_SUBST(AROS_SRCDIR)
1486 AC_SUBST(AROS_PORTSSRCDIR)
1488 # Host related
1489 AC_SUBST(aros_cc_pre)
1490 AC_SUBST(aros_host_strip)
1491 AC_SUBST(aros_host_arch)
1492 AC_SUBST(aros_host_cpu)
1493 AC_SUBST(aros_host_cc)
1494 AC_SUBST(aros_host_ar)
1495 AC_SUBST(aros_host_ranlib)
1496 AC_SUBST(aros_host_ld)
1497 AC_SUBST(aros_host_make)
1498 AC_SUBST(aros_host_cflags)
1499 AC_SUBST(aros_host_ldflags)
1500 AC_SUBST(aros_host_debug)
1501 AC_SUBST(aros_host_mkdep)
1502 AC_SUBST(aros_host_mkargs)
1503 AC_SUBST(aros_host_exe_suffix)
1504 AC_SUBST(aros_host_lib_suffix)
1505 AC_SUBST(aros_tools_dir)
1506 AC_SUBST(aros_host_aclocal)
1507 AC_SUBST(aros_host_autoconf)
1508 AC_SUBST(aros_host_autoheader)
1509 AC_SUBST(aros_host_automake)
1511 # Target Related
1512 AC_SUBST(aros_target_guitheme)
1513 AC_SUBST(aros_target_bootloader)
1514 AC_SUBST(aros_target_arch)
1515 AC_SUBST(aros_target_cpu)
1516 AC_SUBST(aros_target_variant)
1517 AC_SUBST(aros_target_suffix)
1518 AC_SUBST(aros_target_incl)
1519 AC_SUBST(aros_target_ar)
1520 AC_SUBST(aros_target_ranlib)
1521 AC_SUBST(aros_kernel_nm)
1522 AC_SUBST(aros_target_cc)
1523 AC_SUBST(aros_kernel_cc)
1524 AC_SUBST(aros_target_as)
1525 AC_SUBST(aros_target_ld)
1526 AC_SUBST(aros_kernel_ld)
1527 AC_SUBST(aros_target_cc_includes)
1528 AC_SUBST(aros_target_cc_path)
1529 AC_SUBST(aros_target_objdump)
1530 AC_SUBST(aros_target_objcopy)
1531 AC_SUBST(aros_target_strip)
1532 AC_SUBST(aros_target_nm)
1533 AC_SUBST(aros_shared_default)
1534 AC_SUBST(aros_shared_ld)
1535 AC_SUBST(aros_object_format)
1536 AC_SUBST(aros_compiler_libs)
1538 AC_SUBST(aros_config_cflags)
1539 AC_SUBST(aros_config_aflags)
1540 AC_SUBST(aros_config_ldflags)
1542 AC_SUBST(aros_shared_cflags)
1543 AC_SUBST(aros_shared_aflags)
1544 AC_SUBST(aros_shared_ldflags)
1545 AC_SUBST(aros_kernel_ldflags)
1546 AC_SUBST(aros_debug_cflags)
1547 AC_SUBST(aros_debug_aflags)
1548 AC_SUBST(aros_debug_ldflags)
1549 AC_SUBST(aros_target_genmap)
1550 AC_SUBST(aros_target_strip_flags)
1552 # Graphics Related
1553 AC_SUBST(x11_hidd_target)
1554 AC_SUBST(sdl_hidd_target)
1556 AC_SUBST(aros_default_wbwidth)
1557 AC_SUBST(aros_default_wbheight)
1558 AC_SUBST(aros_default_wbdepth)
1559 AC_SUBST(DO_XSHM_SUPPORT)
1560 AC_SUBST(DO_VIDMODE_SUPPORT)
1562 AC_SUBST(aros_host_x11_includes)
1563 AC_SUBST(aros_host_x11_libdirs)
1564 AC_SUBST(aros_host_sdl_cflags)
1565 AC_SUBST(aros_host_sdl_libs)
1567 # Native version related
1568 AC_SUBST(aros_bochs_hack)
1569 AC_SUBST(aros_serial_debug)
1571 # Palm native version related
1572 AC_SUBST(aros_palm_debug_hack)
1574 # Unix/Hosted version related
1575 AC_SUBST(aros_nesting_supervisor)
1577 # DBUS related
1578 AC_SUBST(ENABLE_DBUS)
1579 AC_SUBST(DBUS_CFLAGS)
1580 AC_SUBST(DBUS_LIBFLAGS)
1581 AC_SUBST(KERNEL_DBUS_KOBJ)
1582 AC_SUBST(KERNEL_DBUS_INCLUDES)
1584 # Debug related
1585 AC_SUBST(aros_debug)
1586 AC_SUBST(aros_mungwall_debug)
1587 AC_SUBST(aros_stack_debug)
1588 AC_SUBST(aros_modules_debug)
1590 # Collect-aros stuff: "-ius" to ignore undefined symbols
1591 AC_SUBST(ignore_undefined_symbols)
1593 # C compiler related
1594 AC_SUBST(gcc_target_cpu)
1596 dnl Prepare for output, make up all the generated patches
1597 case "$aros_flavour" in
1598 emulation)      aros_flavour_uc="AROS_FLAVOUR_EMULATION"
1599                 aros_flavour="emulation" ;;
1600 emulcompat)     aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
1601                 aros_flavour="emulation" ;;
1602 standalone)     aros_flavour_uc="AROS_FLAVOUR_STANDALONE"
1603                 aros_flavour="standalone";;
1604 native)         aros_flavour_uc="AROS_FLAVOUR_NATIVE"
1605                 aros_flavour="native" ;;
1606 nativecompat)   aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
1607                 aros_flavour="native" ;;
1608 linklib)        aros_flavour_uc="AROS_FLAVOUR_LINKLIB"
1609                 aros_flavour="linklib" ;;
1610 palmnative)     aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1611                 aros_flavour="palmnative" ;;
1612 mac68knative)   aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_EMULATION)"
1613                 aros_flavour="mac68knative" ;;
1614 ppcnative)      aros_flavour_uc="(AROS_FLAVOUR_STANDALONE|AROS_FLAVOUR_BINCOMPAT)"
1615                 aros_flavour="ppcnative" ;;
1616 esac
1618 if test ! -d ${aros_inc_dir} ; then
1619     ${MKDIR} ${aros_inc_dir}
1621 if test ! -d ${aros_geninc_dir} ; then
1622     ${MKDIR} ${aros_geninc_dir}
1624 if test ! -d ${aros_hostcfg_dir} ; then
1625     ${MKDIR} ${aros_hostcfg_dir}
1627 if test ! -d ${aros_targetcfg_dir} ; then
1628     ${MKDIR} ${aros_targetcfg_dir}
1630 if test ! -d ${aros_tools_dir} ; then
1631     ${MKDIR} ${aros_tools_dir}
1633 if test ! -d ${aros_scripts_dir} ; then
1634     ${MKDIR} ${aros_scripts_dir}
1637 AC_CONFIG_HEADERS(${aros_geninc_dir}/host-conf.h:config/host-conf.h.in)
1639 AC_CONFIG_COMMANDS([compiler_executable],
1640     [
1641         prefix=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}
1642         mkdir -p $prefix
1643         prefix="${prefix}/${aros_target_cpu}-aros"
1644         prefix2=${PWD}/${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros
1646         echo ${prefix}
1647         echo ${prefix2}
1648         chmod a+x ${prefix2}-gcc ${prefix2}-ld
1650         ln -sf ${prefix2}-gcc          ${prefix}-gcc
1651         ln -sf ${prefix2}-ld           ${prefix}-ld
1653         ln -sf $aros_target_as_ln      ${prefix}-as
1654         ln -sf $aros_target_nm_ln      ${prefix}-nm
1655         ln -sf $aros_target_ar_ln      ${prefix}-ar
1656         ln -sf $aros_target_ranlib_ln  ${prefix}-ranlib
1657         ln -sf $aros_target_objcopy_ln ${prefix}-objcopy
1658         ln -sf $aros_target_objdump_ln ${prefix}-objdump
1659         ln -sf $aros_target_strip_ln   ${prefix}-strip
1661         ln -sf $aros_target_as_ln      ${prefix2}-as
1662         ln -sf $aros_target_nm_ln      ${prefix2}-nm
1663         ln -sf $aros_target_ar_ln      ${prefix2}-ar
1664         ln -sf $aros_target_ranlib_ln  ${prefix2}-ranlib
1665         ln -sf $aros_target_objcopy_ln ${prefix2}-objcopy
1666         ln -sf $aros_target_objdump_ln ${prefix2}-objdump
1667         ln -sf $aros_target_strip_ln   ${prefix2}-strip
1668     ],
1669     [
1670         aros_tools_dir=${aros_tools_dir}
1671         aros_target_cpu=${aros_target_cpu}
1672         aros_target_arch=${aros_target_arch}
1673         aros_target_suffix=${aros_target_suffix}
1674         aros_target_nm_ln=${aros_target_nm_ln}
1675         aros_target_as_ln=${aros_target_as_ln}
1676         aros_target_ar_ln=${aros_target_ar_ln}
1677         aros_target_ranlib_ln=${aros_target_ranlib_ln}
1678         aros_target_objdump_ln=${aros_target_objdump_ln}
1679         aros_target_objcopy_ln=${aros_target_objcopy_ln}
1680         aros_target_strip_ln=${aros_target_strip_ln}
1681     ]
1683 AC_CONFIG_COMMANDS([genshared_executable],
1684     [chmod a+x ${aros_scripts_dir}/genshared],
1685     [aros_scripts_dir=${aros_scripts_dir}]
1687 AC_CONFIG_COMMANDS([genmf_executable],
1688     [chmod a+x ${aros_tools_dir}/genmf.py],
1689     [aros_tools_dir=${aros_tools_dir}]
1691 AC_CONFIG_COMMANDS([adflib_myaros.conf_executable],
1692     [chmod a+x tools/adflib/myconf.aros]
1695 AC_CONFIG_FILES(
1696     Makefile
1697     rom/mmakefile
1698     config/make.cfg
1699     ${aros_inc_dir}/config.h:config/config.h.in
1700     ${aros_geninc_dir}/config.h:config/config.h.in
1701     ${aros_hostcfg_dir}/host.cfg:config/host.cfg.in
1702     ${aros_targetcfg_dir}/target.cfg:config/target.cfg.in
1703     mmake.config
1704     ${aros_targetcfg_dir}/make.defaults:config/make.defaults.in
1705     ${aros_targetcfg_dir}/specs:config/specs.in
1706     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-gcc:scripts/aros-gcc.in
1707     ${aros_tools_dir}/${aros_target_cpu}-${aros_target_arch}${aros_target_suffix}-aros-ld:scripts/aros-ld.in
1708     ${aros_scripts_dir}/genshared:compiler/c_lib/source/lib_source/genshared.in
1709     ${aros_tools_dir}/genmf.py:tools/genmf/genmf.py
1710     tools/adflib/myconf.aros
1711     tools/collect-aros/env.h
1714 AC_OUTPUT
1716 dnl This is in order to not define SHARED_CFLAGS sometimes
1717 dnl We don't always do aros_shared_ar, aros_shared_cflags
1719 #XXX compatability...
1720 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
1722 if test -n "$aros_shared_cflags" ; then
1723     echo "SHARED_CFLAGS := $aros_shared_cflags" >> ${aros_hostcfg_dir}/host.cfg
1724     echo "SHARED_AR := $aros_shared_ar" >> ${aros_hostcfg_dir}/host.cfg