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