1 dnl Copyright (C) 1997-1998 AROS - The Amiga Research OS
4 dnl Desc: Autoconf source for configuration file
8 # method of getting shared/non-shared ld/ar tool for target.
9 # ar, ranlib, strip, nm for target
12 # ------------------------------------------------------------------------
13 # Here starts the first section of the configure.in file.
14 # ------------------------------------------------------------------------
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.
23 # The AROS target is slightly different to the normal GNU style
24 # format. We don't have the middle part, and we reverse the order
25 # of the $(CPU) and $(OS) bits.
27 # Don't strip the version of the target yet, it might be
28 # useful on some systems.
30 AC_MSG_CHECKING([for AROS style target])
31 AC_CACHE_VAL(aros_cv_target,[aros_cv_target=$target])
32 target=`eval echo '$''{'aros_cv_target'}'`
34 if test $target = "NONE" ; then
35 target=$host_os-$host_cpu
40 AC_MSG_RESULT($target)
42 # Parse the target field into something useful.
44 target_os=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\1/'`
45 target_cpu=`echo $target | sed 's/^\([^-]*\)-\(.*\)$/\2/'`
48 dnl --------------------------------------------------------------------
49 dnl Set the default Workbench resolution
50 dnl --------------------------------------------------------------------
51 aros_default_wbwidth=800
52 aros_default_wbheight=600
53 aros_default_wbdepth=4
55 dnl --------------------------------------------------------------------
56 dnl Host Configuration Section
57 dnl --------------------------------------------------------------------
59 dnl The idea here is to find out all the information we need about the
60 dnl host. This means things like tools for building directory structures
61 dnl copying files around and the like.
63 # The first step is to find the host binaries.
64 # Check for a compiler.
70 # We don't yet support cross-compiling, but we may later on.
75 # Check for awk and a few other programs.
77 AROS_PROG(MMAKE,mmake)
79 # Perform some default variable assignments. Note all of these will be
80 # Regenerated from the script, so there is no need to cache them.
87 aros_host_debug="-g -O0"
88 aros_host_mkdep="\$(TOP)/scripts/mkdep"
89 aros_host_mkargs="--no-print-directory"
90 aros_host_incl="/usr/include"
91 aros_host_exe_suffix=""
92 aros_host_lib_suffix=""
94 # This is the main host configuration section. It is where the host
95 # can change the values of any variables it needs to change. We do
96 # not look at anything that compiles to the target yet, we'll get
101 aros_host_arch="linux"
102 aros_host_cc="$aros_host_cc -pipe"
111 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
112 aros_host_cpu="$host_cpu"
118 aros_host_cc="$aros_host_cc -pipe"
119 aros_host_arch="freebsd"
124 aros_host_cc="$aros_host_cc -pipe"
125 aros_host_make="gmake"
126 aros_host_arch="netbsd"
128 aros_host_lib_suffix=".0.0"
132 aros_host_arch="amiga"
137 TOUCH="/gg/bin/touch"
146 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
147 aros_host_cpu="$host_cpu"
153 aros_host_arch="cygwin"
154 aros_host_cc="$aros_host_cc -pipe"
155 aros_host_exe_suffix=".exe"
161 AC_MSG_WARN("Unknown CPU for host -- $host_cpu")
162 aros_host_cpu="$host_cpu"
168 AC_MSG_ERROR([Unsupported host architecture $host])
172 AROS_PROG(HOST_AR,[ar],[cru])
173 AROS_PROG(HOST_RANLIB,ranlib)
175 AROS_PROG(RM,[rm],[-rf])
178 AROS_PROG(ECHO,[echo])
179 AROS_PROG(MKDIR,[mkdir],[-p])
180 AROS_PROG(TOUCH,[touch])
181 AROS_PROG(SORT,[sort])
182 AROS_PROG(UNIQ,[uniq])
183 AROS_PROG(NOP,[true])
184 AROS_PROG(LITE,[lite])
185 AROS_PROG(PYTHON,[python])
186 AROS_PROG(GNUPLOT,[gnuplot])
196 dnl --------------------------------------------------------------------
197 dnl Target Configuration Section
198 dnl --------------------------------------------------------------------
200 dnl The target configuration section is responsible for setting up all
201 dnl the paths for includes, and tools required to build AROS to some
202 dnl particular target.
204 # Find all the tools we need to compile. This could be cross-compiling
205 # though! If that is the case we use the GNU form of the target and
206 # simply add this to the front of the binary name. This is rather simple,
207 # but it should work under most circumstances.
209 # The default tools are to use the same as the host, but only if the
210 # host and target CPU are the same. With GCC this is normally enough.
213 #if test "$cross_compile" = "no" ; then
214 aros_target_cc="$aros_host_cc"
215 aros_target_as="$aros_host_cc"
216 aros_shared_ld="$aros_host_ld"
217 aros_static_ld="$aros_host_ld"
218 aros_kernel_ld="$aros_host_ld"
220 aros_target_mkdep="$aros_host_mkdep"
221 aros_target_incl_def="$aros_host_incl"
223 # AC_MSG_ERROR([cross compiling is not yet supported])
228 aros_target_ar_flags="cr"
230 aros_target_nm_flags="-ul"
231 aros_target_objcopy="objcopy"
232 aros_target_objdump="objdump"
233 aros_target_ranlib="ranlib"
234 aros_target_strip="true"
236 # It is necessary to clear the include and link paths for target
237 # commands. This should help clear up problems when cross compiling.
238 # XXX We don't do this yet.
239 aros_target_cflags="-Wall -O0 -DADEBUG=1 -DMDEBUG=1"
240 aros_target_aflags="-Wall -x assembler-with-cpp"
241 aros_target_ldflags="-nostartfiles -nostdlib -Wl,-i"
243 aros_shared_default=yes
245 aros_shared_cflags="-fPIC"
246 aros_shared_aflags=""
247 aros_shared_ldflags="-Wl,-rpath,./lib -shared"
248 aros_static_cflags=""
249 aros_static_aflags=""
250 aros_static_ldflags=""
251 aros_kernel_ldflags="-Wl,-rpath,./lib"
253 # These are the flags to pass when compiling debugged programs
254 aros_debug_cflags="-g -O0 -DADEBUG=1 -DMDEBUG=1"
256 aros_debug_ldflags="-g"
257 aros_target_genmap="-Wl,-Map -Xlinker"
259 # Native flavour stuff
263 # Check for some includes
264 AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
266 # This is the target configuration switch.
270 aros_target_arch="linux"
271 case "$target_cpu" in
273 aros_target_cpu="m68k"
274 aros_flavour="emulcompat"
275 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D__mc68000 -D__linux__"
276 aros_shared_ldflags="-Wl,-T,\$(TOP)/config/linux/m68k/script.so"
277 aros_kernel_ldflags="-Wl,-rpath,./lib,-T,\$(TOP)/config/linux/m68k/script.normal"
280 aros_target_cpu="i386"
281 aros_flavour="emulation"
282 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__linux__"
283 aros_default_wbdepth=8
286 AC_MSG_ERROR("Unknown CPU for Linux -- $target_cpu")
292 aros_target_arch="native"
293 aros_target_cflags="-Wall -O2 -DADEBUG=1 -DMDEBUG=1"
294 aros_shared_default="no"
296 case "$target_cpu" in
298 aros_target_cpu="i386"
299 aros_flavour="standalone"
300 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
301 aros_kernel_ldflags=""
302 aros_default_wbwidth=640
303 aros_default_wbheight=480
306 AC_MSG_ERROR("Unknown native CPU -- $target_cpu")
312 aros_target_arch="freebsd"
313 aros_target_cpu="i386"
314 aros_flavour="emulation"
315 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
320 aros_target_arch="netbsd"
321 aros_target_cpu="i386"
322 aros_target_ldflags="-nostartfiles -nostdlib -Wl,-r"
323 aros_target_genmap="-Wl,-M -Xlinker >"
324 aros_flavour="emulation"
325 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386"
330 aros_target_arch="amiga"
331 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -D_AMIGA -DAMIGA"
332 aros_shared_default="no"
334 aros_target_cflags="-Wall -O2 -fomit-frame-pointer -fbuiltin -ffreestanding"
336 case "$target_cpu" in
338 aros_target_cpu="m68k"
339 aros_flavour="nativecompat"
340 aros_target_cflags="$aros_target_cflags -m68020 -m68881"
341 aros_target_aflags="$aros_target_aflags -m68060"
345 aros_flavour="native"
346 aros_target_strip="strip"
347 aros_target_cflags="$aros_target_cflags -mpowerpc -mcpu=603e"
348 aros_target_aflags="$aros_target_aflags -m603e"
351 AC_MSG_ERROR("Unknown CPU for Amiga $target_cpu")
357 aros_target_arch="cygwin"
358 aros_shared_default="no"
359 case "$target_cpu" in
361 aros_target_cpu="i386"
362 aros_flavour="emulation"
363 aros_target_mkdep="$aros_target_mkdep -D__GNUC__ -Di386 -D__CYGWIN32__"
364 aros_shared_cflags=""
365 aros_default_wbdepth=8
368 AC_MSG_ERROR("Unknown CPU for CygWin -- $target_cpu")
374 AC_MSG_ERROR([Unsupported target architecture $target])
379 # Find the tools that we need for the target - this could be quite
380 # expensive, but we shall try it anyway.
381 AROS_TOOL_CC(TARGET_CC,$aros_target_cc)
382 AROS_TOOL_CC(TARGET_AS,$aros_target_as)
383 AROS_TOOL_CC(SHARED_LD,$aros_shared_ld)
384 AROS_TOOL_CC(STATIC_LD,$aros_static_ld)
385 AROS_TOOL_CC(KERNEL_LD,$aros_kernel_ld)
387 AROS_TOOL(AR,$aros_target_ar,$aros_target_ar_flags)
388 AROS_TOOL(RANLIB,$aros_target_ranlib,$aros_target_ranlib_flags)
389 AROS_TOOL(NM,$aros_target_nm,$aros_target_nm_flags)
390 AROS_TOOL(STRIP,$aros_target_strip,$aros_target_strip_flags)
391 AROS_TOOL(OBJDUMP,$aros_target_objdump)
392 AROS_TOOL(OBJCOPY,$aros_target_objcopy)
397 # See if we can compile SHM support
399 if [[ "x$no_x" != "xyes" -a "x$ac_cv_header_sys_ipc_h" = "xyes" -a "x$ac_cv_header_sys_shm_h" = "xyes" ]]; then
400 AC_MSG_CHECKING(whether the X11 MIT-SHM extension can be compiled in)
401 CFLAGS="-I $x_includes"
402 LIBS="-L/usr/X11/lib -L/usr/X11R6/lib -lX11 -lXext"
404 #include <sys/types.h>
405 #include <X11/Xlib.h>
406 #include <X11/Xutil.h>
407 #include <X11/keysym.h>
408 #include <X11/cursorfont.h>
411 #include <X11/extensions/XShm.h>],[
412 static XShmSegmentInfo shminfo;
413 static Display *display;
414 XShmAttach(display, &shminfo);
416 shmctl(shminfo.shmid, IPC_RMID, 0);
425 # Find the system include path. We can suggest that an alternative is
426 # used if we don't get it correct. The default is to use /usr/include.
427 # Which is set in the aros_target_incl_def variable.
429 AROS_CACHE_CHECK(for the system include path,target_incl,[
430 AC_ARG_ENABLE(includes,
431 [ --enable-includes=dir Alternative system include directory],
432 [aros_target_incl=$enable_includes], [aros_target_incl=$aros_target_incl_def])
435 dnl Check if user specified --with-resolution=XRESxYRESxDEPTH
436 AC_MSG_CHECKING([for default resolution of WBScreen])
437 AC_ARG_WITH(resolution,[ --with-resolution=XRESxYRESxDEPTH Default resolution of the initial WorkbenchScreen],resolution=$withval,resolution=none)
438 # We require an argument, so map --with/--without ("yes"/"no") to "none" specified
439 if test "$resolution" = "yes" ; then
442 if test "$resolution" = "no" ; then
445 if test "$resolution" != "none" ; then
446 aros_default_wbwidth=`echo $resolution | cut -d'x' -f1`
447 aros_default_wbheight=`echo $resolution | cut -d'x' -f2`
448 aros_default_wbdepth=`echo $resolution | cut -d'x' -f3`
450 # If "--with-resolution" is not given, check cache...
451 AC_CACHE_VAL(aros_cv_default_wbwidth,aros_cv_default_wbwidth=$aros_default_wbwidth)
452 AC_CACHE_VAL(aros_cv_default_wbheight,aros_cv_default_wbheight=$aros_default_wbheight)
453 AC_CACHE_VAL(aros_cv_default_wbdepth,aros_cv_default_wbdepth=$aros_default_wbdepth)
454 aros_default_wbwidth=$aros_cv_default_wbwidth
455 aros_default_wbheight=$aros_cv_default_wbheight
456 aros_default_wbdepth=$aros_cv_default_wbdepth
458 AC_MSG_RESULT("$aros_default_wbwidth x $aros_default_wbheight x $aros_default_wbdepth")
459 aros_cv_default_wbwidth=$aros_default_wbwidth
460 aros_cv_default_wbheight=$aros_default_wbheight
461 aros_cv_default_wbdepth=$aros_default_wbdepth
463 dnl See if the user wants the VMWare hack for native flavour
464 AC_MSG_CHECKING([if vmware hack is enabled])
465 AC_ARG_ENABLE(vmware_hack,[ --enable-vmware-hack Enable a hack on the kernel output in native [default=no]],vmware_hack="yes",vmware_hack="no")
466 if test "$vmware_hack" = "yes" ; then
469 AC_MSG_RESULT("$vmware_hack")
471 dnl See if the user wants the BOCHS hack for native flavour
472 AC_MSG_CHECKING([if bochs hack is enabled])
473 AC_ARG_ENABLE(bochs_hack,[ --enable-bochs-hack Enable hacks to make BOCHS (partly) work [default=no]],bochs_hack="yes",bochs_hack="no")
474 if test "$bochs_hack" = "yes" ; then
477 AC_MSG_RESULT("$bochs_hack")
479 dnl --------------------------------------------------------------------
480 dnl Configuration Output Section
481 dnl --------------------------------------------------------------------
486 AC_SUBST(aros_flavour)
487 AC_SUBST(aros_flavour_uc)
490 AC_SUBST(aros_host_arch)
491 AC_SUBST(aros_host_cpu)
492 AC_SUBST(aros_host_cc)
493 AC_SUBST(aros_host_ld)
494 AC_SUBST(aros_host_make)
495 AC_SUBST(aros_host_cflags)
496 AC_SUBST(aros_host_ldflags)
497 AC_SUBST(aros_host_debug)
498 AC_SUBST(aros_host_mkdep)
499 AC_SUBST(aros_host_mkargs)
500 AC_SUBST(aros_host_exe_suffix)
501 AC_SUBST(aros_host_lib_suffix)
504 AC_SUBST(aros_target_arch)
505 AC_SUBST(aros_target_cpu)
506 AC_SUBST(aros_target_incl)
507 AC_SUBST(aros_shared_default)
509 AC_SUBST(aros_target_cflags)
510 AC_SUBST(aros_target_aflags)
511 AC_SUBST(aros_target_ldflags)
512 AC_SUBST(aros_static_cflags)
513 AC_SUBST(aros_static_aflags)
514 AC_SUBST(aros_static_ldflags)
515 AC_SUBST(aros_shared_cflags)
516 AC_SUBST(aros_shared_aflags)
517 AC_SUBST(aros_shared_ldflags)
518 AC_SUBST(aros_kernel_ldflags)
519 AC_SUBST(aros_debug_cflags)
520 AC_SUBST(aros_debug_aflags)
521 AC_SUBST(aros_debug_ldflags)
522 AC_SUBST(aros_target_genmap)
525 AC_SUBST(aros_gui_libdir)
526 AC_SUBST(aros_gui_ldflags)
527 AC_SUBST(aros_gui_libflags)
528 AC_SUBST(aros_gui_incdir)
529 AC_SUBST(aros_gui_ccflags)
531 AC_SUBST(aros_default_wbwidth)
532 AC_SUBST(aros_default_wbheight)
533 AC_SUBST(aros_default_wbdepth)
534 AC_SUBST(HAVE_XSHM_SUPPORT)
536 # Native version related
537 AC_SUBST(aros_vmware_hack)
538 AC_SUBST(aros_bochs_hack)
540 dnl Prepare for output, make up all the generated patches
541 case "$aros_flavour" in
542 emulation) aros_flavour_uc="AROS_FLAVOUR_EMULATION" ;;
543 emulcompat) aros_flavour_uc="(AROS_FLAVOUR_EMULATION|AROS_FLAVOUR_BINCOMPAT)"
544 aros_flavour="emulation" ;;
545 standalone) aros_flavour_uc="AROS_FLAVOUR_STANDALONE" ;;
546 native) aros_flavour_uc="AROS_FLAVOUR_NATIVE" ;;
547 nativecompat) aros_flavour_uc="(AROS_FLAVOUR_NATIVE|AROS_FLAVOUR_BINCOMPAT)"
548 aros_flavour="native" ;;
549 linklib) aros_flavour_uc="AROS_FLAVOUR_LINKLIB" ;;
552 if test -z "$aros_gui_basedir" ; then
553 dnl Use X as the default GUI
554 aros_gui_libdir="$x_libraries"
555 if test -z "$x_libraries" ; then
558 aros_gui_ldflags="-L $x_libraries"
560 if test "$HAVE_XSHM_SUPPORT" = "1" ; then
561 aros_gui_libflags="-lX11 -lXext"
563 aros_gui_libflags="-lX11"
565 aros_gui_incdir="$x_includes"
566 if test -z "$x_includes" ; then
569 aros_gui_ccflags="-I $x_includes"
572 if test -n "$aros_gui_basedir" ; then
573 aros_gui_libdir="${aros_gui_basedir}/lib"
574 aros_gui_incdir="${aros_gui_basedir}/include"
577 if test -n "$aros_gui_libdir" ; then
578 aros_gui_ldflags="-L ${aros_gui_libdir}"
581 if test -n "$aros_gui_incdir" ; then
582 aros_gui_ccflags="-I ${aros_gui_incdir}"
584 aros_gui_incdir="${aros_sysincludes}"
589 if test ! -d bin/${aros_target_arch}-${aros_target_cpu}/AROS/Include/aros ; then
590 ${MKDIR} bin/${aros_target_arch}-${aros_target_cpu}/AROS/Include/aros
593 AC_OUTPUT(Makefile config/config.h config/host.cfg mmake.config
596 dnl This is in order to not defined SHARED_CFLAGS sometimes
597 dnl We don't always do aros_shared_ar, aros_shared_cflags
599 #XXX compatability...
600 aros_shared_ar="$aros_shared_ld $aros_shared_ldflags -o"
602 if test -n "$aros_shared_cflags" ; then
603 echo "SHARED_CFLAGS := $aros_shared_cflags" >> config/host.cfg
604 echo "SHARED_AR := $aros_shared_ar" >> config/host.cfg
607 # Sometimes, configure will not create config/config.h; in that case,
608 # assume that it has not changed.
609 if test -f config/config.h ; then
610 out=bin/$aros_target_arch-$aros_target_cpu/AROS/Include/aros/config.h
611 if cmp -s "$out" "config/config.h"; then
612 echo "config/config.h is unchanged."
615 echo "Replacing $out by config/config.h"
616 if test -f $out ; then
619 mv config/config.h $out