ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.in
Revision: 1.55
Committed: 2002-03-16T10:51:17Z (22 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.54: +1 -0 lines
Log Message:
- Check for caddr_t. On some systems like Solaris/SPARC, mmap() address
  type (first parameter) is caddr_t instead of void *. Explicitly cast
  address to (caddr_t) type and C++ implicit pointer conversion rules
  will do the rest. aka. caddr_t -> void * is OK unlike the opposite.

File Contents

# User Rev Content
1 cebix 1.1 dnl Process this file with autoconf to produce a configure script.
2 cebix 1.50 dnl Written in 2002 by Christian Bauer et al.
3 cebix 1.1
4     AC_INIT(main_unix.cpp)
5     AC_PREREQ(2.12)
6     AC_CONFIG_HEADER(config.h)
7    
8 gbeauche 1.49 dnl These defines are necessary to get 64-bit file size support.
9     AC_DEFINE(_USE_LARGEFILE_SOURCE, 1, [Get more functions for correct standard I/O])
10     AC_DEFINE(_FILE_OFFSET_BITS, 64, [Get 64-bit file size support])
11    
12 cebix 1.1 dnl Options.
13 cebix 1.17 AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
14     AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
15     AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes])
16 cebix 1.42 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
17 gbeauche 1.32
18 gbeauche 1.35 dnl FPU emulation core.
19     AC_ARG_ENABLE(fpe,
20     [ --enable-fpe=which specify which fpu emulator to use [default=opt]],
21     [ case "$enableval" in
22     default) FPE_CORE="default";; dnl fpu_x86.cpp if i386 architecture, fpu_uae.cpp otherwise
23     uae) FPE_CORE="uae";;
24     *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: default, uae]);;
25     esac
26     ],
27     [ FPE_CORE="default"
28     ])
29    
30 gbeauche 1.32 dnl Addressing modes.
31 gbeauche 1.23 AC_ARG_ENABLE(addressing,
32 gbeauche 1.32 [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
33 gbeauche 1.23 [ case "$enableval" in
34 cebix 1.24 real) ADDRESSING_TEST_ORDER="real";;
35     direct) ADDRESSING_TEST_ORDER="direct";;
36     banks) ADDRESSING_TEST_ORDER="banks";;
37 gbeauche 1.32 fastest)ADDRESSING_TEST_ORDER="direct banks";;
38     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
39 gbeauche 1.23 esac
40     ],
41     [ ADDRESSING_TEST_ORDER="direct banks"
42     ])
43 gbeauche 1.32
44     dnl External packages.
45 cebix 1.17 AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
46     AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
47     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
48 cebix 1.1
49 gbeauche 1.23 dnl Canonical system information.
50     AC_CANONICAL_HOST
51     AC_CANONICAL_TARGET
52    
53     dnl Target OS type (target is host if not cross-compiling).
54     case "$target_os" in
55     linux*) OS_TYPE=linux;;
56     netbsd*) OS_TYPE=netbsd;;
57     freebsd*) OS_TYPE=freebsd;;
58     solaris*) OS_TYPE=solaris;;
59 gbeauche 1.44 darwin*) OS_TYPE=darwin;;
60     *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
61 gbeauche 1.23 esac
62     DEFINES="$DEFINES -DOS_$OS_TYPE"
63    
64     dnl Target CPU type.
65     HAVE_I386=no
66     HAVE_M68K=no
67     HAVE_SPARC=no
68 cebix 1.33 HAVE_POWERPC=no
69 gbeauche 1.23 case "$target_cpu" in
70     i386* | i486* | i586* | i686* | i786* ) CPU_TYPE=i386 HAVE_I386=yes;;
71     m68k* ) CPU_TYPE=m68k HAVE_M68K=yes;;
72     sparc* ) CPU_TYPE=sparc HAVE_SPARC=yes;;
73 cebix 1.33 powerpc* ) CPU_TYPE=powerpc HAVE_POWERPC=yes;;
74 gbeauche 1.44 *) CPU_TYPE=`echo $target_cpu | sed -e 's/-/_/g'`;;
75 gbeauche 1.23 esac
76     DEFINES="$DEFINES -DCPU_$CPU_TYPE"
77    
78 cebix 1.1 dnl Checks for programs.
79     AC_PROG_CC
80 gbeauche 1.23 AC_PROG_CC_C_O
81 cebix 1.4 AC_PROG_CPP
82 cebix 1.1 AC_PROG_CXX
83     AC_PROG_MAKE_SET
84     AC_PROG_INSTALL
85    
86 cebix 1.11 dnl We use mon if possible.
87     MONSRCS=
88 cebix 1.18 if [[ "x$WANT_MON" = "xyes" ]]; then
89     AC_MSG_CHECKING(for mon)
90 cebix 1.24 mon_srcdir=../../../mon/src
91     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
92 cebix 1.18 AC_MSG_RESULT(yes)
93 cebix 1.19 AC_DEFINE(ENABLE_MON)
94 cebix 1.51 MONSRCS="$mon_srcdir/mon.cpp $mon_srcdir/mon_6502.cpp $mon_srcdir/mon_z80.cpp $mon_srcdir/mon_cmd.cpp $mon_srcdir/mon_disass.cpp $mon_srcdir/mon_ppc.cpp $mon_srcdir/mon_lowmem.cpp $mon_srcdir/disass/floatformat.c $mon_srcdir/disass/i386-dis.c $mon_srcdir/disass/m68k-dis.c $mon_srcdir/disass/m68k-opc.c"
95 cebix 1.24 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
96 cebix 1.18 AC_CHECK_LIB(readline, readline)
97 cebix 1.19 AC_CHECK_LIB(termcap, tputs)
98     AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
99 cebix 1.18 else
100     AC_MSG_RESULT(no)
101     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
102     WANT_MON=no
103     fi
104 cebix 1.11 fi
105    
106 cebix 1.1 dnl Checks for libraries.
107 cebix 1.10 AC_CHECK_LIB(posix4, sem_init)
108 cebix 1.45 AC_CHECK_LIB(rt, timer_create)
109 cebix 1.10
110     dnl We need X11.
111 cebix 1.1 AC_PATH_XTRA
112     if [[ "x$no_x" = "xyes" ]]; then
113     AC_MSG_ERROR([You need X11 to run Basilisk II.])
114     fi
115     CFLAGS="$CFLAGS $X_CFLAGS"
116     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
117     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
118    
119 cebix 1.19 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
120     HAVE_PTHREADS=yes
121 cebix 1.10 AC_CHECK_LIB(pthread, pthread_create, , [
122     AC_CHECK_LIB(c_r, pthread_create, , [
123     AC_CHECK_LIB(PTL, pthread_create, , [
124 cebix 1.19 HAVE_PTHREADS=no
125 cebix 1.10 ])
126     ])
127     ])
128 cebix 1.19 if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
129     AC_DEFINE(HAVE_PTHREADS)
130     fi
131     AC_CHECK_FUNCS(pthread_cancel)
132 cebix 1.53 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
133     AC_CHECK_FUNCS(pthread_mutexattr_settype)
134 cebix 1.10
135     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
136 cebix 1.19 SEMSRC=
137 cebix 1.10 AC_CHECK_FUNCS(sem_init, , [
138 cebix 1.26 if test "x$HAVE_PTHREADS" = "xyes"; then
139 cebix 1.19 SEMSRC=posix_sem.cpp
140     fi
141 cebix 1.10 ])
142 cebix 1.1
143 cebix 1.10 dnl We use DGA (XFree86 or fbdev) if possible.
144 cebix 1.8 if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
145 cebix 1.10 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
146 cebix 1.19 AC_DEFINE(ENABLE_XF86_DGA)
147 cebix 1.1 LIBS="$LIBS -lXxf86dga"
148 cebix 1.8 if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
149     AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.])
150     WANT_FBDEV_DGA=no
151     fi
152 cebix 1.10 ], [
153     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
154 cebix 1.13 WANT_XF86_DGA=no
155 cebix 1.10 ])
156 cebix 1.8 fi
157     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
158 cebix 1.19 AC_DEFINE(ENABLE_FBDEV_DGA)
159 cebix 1.1 fi
160    
161 cebix 1.17 dnl We use XFree86 VidMode if possible.
162     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
163     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
164 cebix 1.19 AC_DEFINE(ENABLE_XF86_VIDMODE)
165 cebix 1.17 LIBS="$LIBS -lXxf86vm"
166     ], [
167     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
168     WANT_XF86_VIDMODE=no
169     ])
170     fi
171    
172 cebix 1.1 dnl We use GTK+ if possible.
173 cebix 1.10 UISRCS=../dummy/prefs_editor_dummy.cpp
174 cebix 1.14 if [[ "x$WANT_GTK" = "xyes" ]]; then
175 cebix 1.10 AM_PATH_GTK(1.2.0, [
176 cebix 1.19 AC_DEFINE(ENABLE_GTK)
177 cebix 1.10 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
178     LIBS="$LIBS $GTK_LIBS"
179     UISRCS=prefs_editor_gtk.cpp
180 cebix 1.52 B2_PATH_GNOMEUI([
181     AC_DEFINE(HAVE_GNOMEUI)
182     CXXFLAGS="$CXXFLAGS $GNOMEUI_CFLAGS"
183     LIBS="$LIBS $GNOMEUI_LIBS"
184     ], [])
185 cebix 1.10 ], [
186     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
187 cebix 1.14 WANT_GTK=no
188 cebix 1.10 ])
189 cebix 1.1 fi
190    
191 cebix 1.10 dnl We use ESD if possible.
192     if [[ "x$WANT_ESD" = "xyes" ]]; then
193     AM_PATH_ESD(0.2.8, [
194 cebix 1.19 AC_DEFINE(ENABLE_ESD)
195 cebix 1.10 CFLAGS="$CFLAGS $ESD_CFLAGS"
196     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
197     LIBS="$LIBS $ESD_LIBS"
198     ], [
199     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
200     WANT_ESD=no
201     ])
202 cebix 1.1 fi
203    
204     dnl Checks for header files.
205     AC_HEADER_STDC
206 gbeauche 1.44 AC_CHECK_HEADERS(unistd.h fcntl.h sys/time.h sys/mman.h)
207 cebix 1.1
208     dnl Checks for typedefs, structures, and compiler characteristics.
209     AC_C_BIGENDIAN
210     AC_C_CONST
211     AC_C_INLINE
212     AC_CHECK_SIZEOF(short, 2)
213     AC_CHECK_SIZEOF(int, 4)
214     AC_CHECK_SIZEOF(long, 4)
215     AC_CHECK_SIZEOF(long long, 8)
216 gbeauche 1.23 AC_CHECK_SIZEOF(void *, 4)
217 cebix 1.1 AC_TYPE_OFF_T
218     AC_CHECK_TYPE(loff_t, off_t)
219 gbeauche 1.55 AC_CHECK_TYPE(caddr_t, [char *])
220 cebix 1.1 AC_TYPE_SIZE_T
221 gbeauche 1.23 AC_TYPE_SIGNAL
222 cebix 1.1 AC_HEADER_TIME
223     AC_STRUCT_TM
224 gbeauche 1.54
225     dnl Check whether sys/socket.h defines type socklen_t.
226     dnl (extracted from ac-archive/Miscellaneous)
227     AC_CACHE_CHECK("for socklen_t",
228     ac_cv_type_socklen_t, [
229     AC_TRY_COMPILE([
230     #include <sys/types.h>
231     #include <sys/socket.h>
232     ], [socklen_t len = 42; return 0;],
233     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
234     dnl When cross-compiling, do not assume anything.
235     ac_cv_type_socklen_t="guessing no"
236     )
237     ])
238     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
239     AC_DEFINE(socklen_t, int)
240     fi
241 cebix 1.1
242     dnl Checks for library functions.
243     AC_CHECK_FUNCS(strdup cfmakeraw)
244 cebix 1.21 AC_CHECK_FUNCS(clock_gettime timer_create)
245 gbeauche 1.40 AC_CHECK_FUNCS(sigaction signal)
246 gbeauche 1.44 AC_CHECK_FUNCS(mmap mprotect munmap)
247     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
248    
249     dnl Darwin seems to define mach_task_self() instead of task_self().
250     AC_CHECK_FUNCS(mach_task_self task_self)
251 cebix 1.1
252     dnl Select system-dependant source files.
253 cebix 1.19 SERIALSRC=serial_unix.cpp
254     ETHERSRC=../dummy/ether_dummy.cpp
255     SCSISRC=../dummy/scsi_dummy.cpp
256     AUDIOSRC=../dummy/audio_dummy.cpp
257     EXTRASYSSRCS=
258 cebix 1.27 CAN_NATIVE_M68K=no
259 gbeauche 1.23 case "$target_os" in
260     linux*)
261 cebix 1.38 ETHERSRC=ether_unix.cpp
262     AUDIOSRC=audio_oss_esd.cpp
263 gbeauche 1.23 SCSISRC=Linux/scsi_linux.cpp
264     ;;
265 cebix 1.38 freebsd*)
266     ETHERSRC=ether_unix.cpp
267 gbeauche 1.23 AUDIOSRC=audio_oss_esd.cpp
268     DEFINES="$DEFINES -DBSD_COMP"
269 cebix 1.38 CXXFLAGS="$CXXFLAGS -fpermissive"
270 gbeauche 1.23 dnl Check for the CAM library
271     AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
272     if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
273     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
274     else
275     dnl Check for the sys kernel includes
276 cebix 1.38 AC_CHECK_HEADER(camlib.h)
277     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
278 gbeauche 1.23 dnl In this case I should fix this thing including a "patch"
279     dnl to access directly to the functions in the kernel :) --Orlando
280 cebix 1.38 AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
281 gbeauche 1.23 else
282     SCSISRC=FreeBSD/scsi_freebsd.cpp
283     LIBS="$LIBS -lcam"
284     DEFINES="$DEFINES -DCAM"
285     fi
286     fi
287     ;;
288     netbsd*)
289 cebix 1.27 CAN_NATIVE_M68K=yes
290 gbeauche 1.23 ;;
291     solaris*)
292     AUDIOSRC=Solaris/audio_solaris.cpp
293     DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
294     ;;
295     irix*)
296 cebix 1.48 ETHERSRC=ether_unix.cpp
297 cebix 1.30 AUDIOSRC=Irix/audio_irix.cpp
298 gbeauche 1.23 EXTRASYSSRCS=Irix/unaligned.c
299 cebix 1.28 dnl IRIX headers work fine, but somehow don't define or use "STDC_HEADERS"
300     DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200 -DSTDC_HEADERS"
301 cebix 1.30 LIBS="$LIBS -laudio"
302 cebix 1.48 WANT_ESD=no
303 cebix 1.37
304     dnl Check if our compiler supports -Ofast (MIPSPro)
305     HAVE_OFAST=no
306     ocflags="$CFLAGS"
307     CFLAGS=`echo $CFLAGS | sed -e 's/ -g / -Ofast /;s/^-g /-Ofast /;s/-g$/ -Ofast/;s/^-g$/-Ofast/'`
308     AC_MSG_CHECKING(if "-Ofast" works)
309     dnl Do a test compile of an empty function
310     AC_TRY_COMPILE(,, [AC_MSG_RESULT(yes); HAVE_OFAST=yes], AC_MSG_RESULT(no))
311     CFLAGS="$ocflags"
312    
313 gbeauche 1.23 ;;
314     esac
315    
316 cebix 1.27 dnl Use 68k CPU natively?
317     WANT_NATIVE_M68K=no
318     if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
319     AC_DEFINE(ENABLE_NATIVE_M68K)
320     WANT_NATIVE_M68K=yes
321     fi
322    
323 gbeauche 1.23 if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
324     dnl Serial, ethernet and audio support needs pthreads
325     AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
326     SERIALSRC=../dummy/serial_dummy.cpp
327     ETHERSRC=../dummy/ether_dummy.cpp
328     AUDIOSRC=../dummy/audio_dummy.cpp
329     fi
330     SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
331    
332     dnl Define a macro that translates a yesno-variable into a C macro definition
333     dnl to be put into the config.h file
334     dnl $1 -- the macro to define
335     dnl $2 -- the value to translate
336     AC_DEFUN(AC_TRANSLATE_DEFINE, [
337 gbeauche 1.44 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
338 gbeauche 1.23 AC_DEFINE($1)
339     fi
340     ])
341    
342 gbeauche 1.44 dnl Various checks if the system supports vm_allocate() and the like functions.
343     have_mach_vm=no
344     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
345     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
346     have_mach_vm=yes
347     fi
348     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm")
349    
350     dnl Check that vm_allocate(), vm_protect() work
351     if [[ "x$have_mach_vm" = "xyes" ]]; then
352    
353     AC_CACHE_CHECK("whether vm_protect works",
354     ac_cv_vm_protect_works, [
355     AC_LANG_SAVE
356     AC_LANG_CPLUSPLUS
357     ac_cv_vm_protect_works=yes
358     dnl First the tests that should segfault
359     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
360     AC_TRY_RUN([
361     #define CONFIGURE_TEST_VM_MAP
362     #define TEST_VM_PROT_$test_def
363     #include "vm_alloc.cpp"
364     ], ac_cv_vm_protect_works=no, rm -f core,
365     dnl When cross-compiling, do not assume anything
366     ac_cv_vm_protect_works="guessing no"
367     )
368     done
369     AC_TRY_RUN([
370     #define CONFIGURE_TEST_VM_MAP
371     #define TEST_VM_PROT_RDWR_WRITE
372     #include "vm_alloc.cpp"
373     ], , ac_cv_vm_protect_works=no,
374     dnl When cross-compiling, do not assume anything
375     ac_cv_vm_protect_works="guessing no"
376     )
377     AC_LANG_RESTORE
378     ]
379     )
380    
381     dnl Remove support for vm_allocate() if vm_protect() does not work
382     if [[ "x$have_mach_vm" = "xyes" ]]; then
383     case $ac_cv_vm_protect_works in
384     *yes) have_mach_vm=yes;;
385     *no) have_mach_vm=no;;
386     esac
387     fi
388     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm")
389    
390     fi dnl HAVE_MACH_VM
391    
392     dnl Various checks if the system supports mmap() and the like functions.
393     dnl ... and Mach memory allocators are not supported
394     have_mmap_vm=no
395     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
396     "x$ac_cv_func_mprotect" = "xyes" ]]; then
397     if [[ "x$have_mach_vm" = "xno" ]]; then
398     have_mmap_vm=yes
399     fi
400     fi
401     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm")
402    
403     dnl Check that mmap() and associated functions work.
404     if [[ "x$have_mmap_vm" = "xyes" ]]; then
405    
406     dnl Check if we have a working anonymous mmap()
407     AC_CACHE_CHECK("whether mmap supports MAP_ANON",
408     ac_cv_mmap_anon, [
409     AC_LANG_SAVE
410     AC_LANG_CPLUSPLUS
411     AC_TRY_RUN([
412     #define HAVE_MMAP_ANON
413     #define CONFIGURE_TEST_VM_MAP
414     #define TEST_VM_MMAP_ANON
415     #include "vm_alloc.cpp"
416     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
417     dnl When cross-compiling, do not assume anything.
418     ac_cv_mmap_anon="guessing no"
419     )
420     AC_LANG_RESTORE
421     ]
422     )
423     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon")
424    
425     AC_CACHE_CHECK("whether mmap supports MAP_ANONYMOUS",
426     ac_cv_mmap_anonymous, [
427     AC_LANG_SAVE
428     AC_LANG_CPLUSPLUS
429     AC_TRY_RUN([
430     #define HAVE_MMAP_ANONYMOUS
431     #define CONFIGURE_TEST_VM_MAP
432     #define TEST_VM_MMAP_ANON
433     #include "vm_alloc.cpp"
434     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
435     dnl When cross-compiling, do not assume anything.
436     ac_cv_mmap_anonymous="guessing no"
437     )
438     AC_LANG_RESTORE
439     ]
440     )
441     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous")
442    
443     AC_CACHE_CHECK("whether mprotect works",
444     ac_cv_mprotect_works, [
445     AC_LANG_SAVE
446     AC_LANG_CPLUSPLUS
447     ac_cv_mprotect_works=yes
448     dnl First the tests that should segfault
449     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
450     AC_TRY_RUN([
451     #define CONFIGURE_TEST_VM_MAP
452     #define TEST_VM_PROT_$test_def
453     #include "vm_alloc.cpp"
454     ], ac_cv_mprotect_works=no, rm -f core,
455     dnl When cross-compiling, do not assume anything
456     ac_cv_mprotect_works="guessing no"
457     )
458     done
459     AC_TRY_RUN([
460     #define CONFIGURE_TEST_VM_MAP
461     #define TEST_VM_PROT_RDWR_WRITE
462     #include "vm_alloc.cpp"
463     ], , ac_cv_mprotect_works=no,
464     dnl When cross-compiling, do not assume anything
465     ac_cv_mprotect_works="guessing no"
466     )
467     AC_LANG_RESTORE
468     ]
469     )
470    
471     dnl Remove support for mmap() if mprotect() does not work
472     if [[ "x$have_mmap_vm" = "xyes" ]]; then
473     case $ac_cv_mprotect_works in
474     *yes) have_mmap_vm=yes;;
475     *no) have_mmap_vm=no;;
476     esac
477     fi
478     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm)
479    
480     fi dnl HAVE_MMAP_VM
481    
482 gbeauche 1.23 dnl Check if we can mmap 0x2000 bytes from 0x0000
483     AC_CACHE_CHECK("whether we can map Low Memory area 0x0000-0x2000",
484     ac_cv_can_map_lm, [
485     AC_LANG_SAVE
486     AC_LANG_CPLUSPLUS
487     AC_TRY_RUN([
488 gbeauche 1.44 #include "vm_alloc.cpp"
489     int main(void) { /* returns 0 if we could map the lowmem globals */
490     volatile char * lm;
491     if (vm_init() < 0) exit(1);
492     if ((lm = (volatile char *)vm_acquire_fixed(0, 0x2000)) == VM_MAP_FAILED) exit(1);
493     lm[0] = 'z';
494     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
495     vm_exit(); exit(0);
496 gbeauche 1.23 }
497 gbeauche 1.44 ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
498     dnl When cross-compiling, do not assume anything.
499     ac_cv_can_map_lm="guessing no"
500 gbeauche 1.23 )
501     AC_LANG_RESTORE
502     ]
503     )
504    
505 gbeauche 1.40 dnl Check signal handlers need to be reinstalled
506     AC_CACHE_CHECK("whether signal handlers need to be reinstalled",
507 gbeauche 1.44 ac_cv_signal_need_reinstall, [
508     AC_LANG_SAVE
509     AC_LANG_CPLUSPLUS
510     AC_TRY_RUN([
511     #include <stdlib.h>
512     #ifdef HAVE_UNISTD_H
513     #include <unistd.h>
514     #endif
515     #include <signal.h>
516     static int handled_signal = 0;
517     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
518     int main(void) { /* returns 0 if signals need not to be reinstalled */
519     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
520     exit(handled_signal == 2);
521     }
522     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
523     dnl When cross-compiling, do not assume anything.
524     ac_cv_signal_need_reinstall="guessing yes"
525     )
526     AC_LANG_RESTORE
527     ]
528 gbeauche 1.40 )
529     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall")
530    
531     dnl Check if sigaction handlers need to be reinstalled
532     AC_CACHE_CHECK("whether sigaction handlers need to be reinstalled",
533     ac_cv_sigaction_need_reinstall, [
534     AC_LANG_SAVE
535     AC_LANG_CPLUSPLUS
536     AC_TRY_RUN([
537     #include <stdlib.h>
538     #ifdef HAVE_UNISTD_H
539     #include <unistd.h>
540     #endif
541     #include <signal.h>
542     static int handled_signal = 0;
543     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
544     typedef RETSIGTYPE (*signal_handler)(int);
545     static signal_handler mysignal(int sig, signal_handler handler) {
546     struct sigaction old_sa;
547     struct sigaction new_sa;
548     new_sa.sa_handler = handler;
549     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
550     }
551     int main(void) { /* returns 0 if signals need not to be reinstalled */
552     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
553     exit(handled_signal == 2);
554     }
555 gbeauche 1.44 ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
556     dnl When cross-compiling, do not assume anything.
557     ac_cv_sigaction_need_reinstall="guessing yes"
558 gbeauche 1.40 )
559     AC_LANG_RESTORE
560     ]
561     )
562     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall")
563    
564 gbeauche 1.23 dnl Check if extended signals are supported.
565     AC_CACHE_CHECK("whether your system supports extended signal handlers",
566     ac_cv_have_extended_signals, [
567     AC_LANG_SAVE
568     AC_LANG_CPLUSPLUS
569     AC_TRY_RUN([
570 gbeauche 1.40 #define HAVE_SIGINFO_T 1
571 gbeauche 1.44 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
572     #include "vm_alloc.cpp"
573 gbeauche 1.40 #include "sigsegv.cpp"
574 gbeauche 1.44 ], ac_cv_have_extended_signals=yes, ac_cv_have_extended_signals=no,
575     dnl When cross-compiling, do not assume anything.
576     ac_cv_have_extended_signals=no
577 gbeauche 1.23 )
578     AC_LANG_RESTORE
579     ]
580     )
581     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals")
582    
583     dnl Otherwise, check for subterfuges.
584     if [[ "x$ac_cv_have_extended_signals" = "xno" ]]; then
585 gbeauche 1.40 AC_CACHE_CHECK("whether we then have a subterfuge for your system",
586     ac_cv_have_sigcontext_hack, [
587     AC_LANG_SAVE
588     AC_LANG_CPLUSPLUS
589     AC_TRY_RUN([
590     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
591 gbeauche 1.44 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
592     #include "vm_alloc.cpp"
593 gbeauche 1.40 #include "sigsegv.cpp"
594 gbeauche 1.44 ], ac_cv_have_sigcontext_hack=yes, ac_cv_have_sigcontext_hack=no,
595     dnl When cross-compiling, do not assume anything.
596     ac_cv_have_sigcontext_hack=no
597 gbeauche 1.40 )
598     AC_LANG_RESTORE
599     ])
600     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack")
601 gbeauche 1.23 fi
602    
603     dnl Can we do Video on SEGV Signals ?
604     CAN_VOSF=no
605     if [[ "$ac_cv_have_extended_signals" = "yes" -o "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
606     CAN_VOSF=yes
607     fi
608    
609     dnl Determine the addressing mode to use
610 cebix 1.27 if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
611     ADDRESSING_MODE="real"
612     else
613     ADDRESSING_MODE=""
614     AC_MSG_CHECKING([for the addressing mode to use])
615     for am in $ADDRESSING_TEST_ORDER; do
616     case $am in
617     real)
618 gbeauche 1.32 dnl Requires ability to mmap() Low Memory globals
619 cebix 1.27 if [[ "x$ac_cv_can_map_lm" = "xno" ]]; then
620     continue
621     fi
622 gbeauche 1.32 dnl Requires VOSF screen updates
623     if [[ "x$CAN_VOSF" = "xno" ]]; then
624     continue
625 cebix 1.1 fi
626 gbeauche 1.32 dnl Real addressing will probably work.
627 cebix 1.27 ADDRESSING_MODE="real"
628     WANT_VOSF=yes dnl we can use VOSF and we need it actually
629     DEFINES="$DEFINES -DREAL_ADDRESSING"
630     break
631     ;;
632     direct)
633 gbeauche 1.32 dnl Requires VOSF screen updates
634 cebix 1.27 if [[ "x$CAN_VOSF" = "xyes" ]]; then
635     ADDRESSING_MODE="direct"
636     WANT_VOSF=yes dnl we can use VOSF and we need it actually
637     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
638     break
639 cebix 1.1 fi
640 cebix 1.27 ;;
641     banks)
642     dnl Default addressing mode
643     ADDRESSING_MODE="memory banks"
644 gbeauche 1.23 break
645 cebix 1.27 ;;
646     *)
647     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
648     esac
649     done
650     AC_MSG_RESULT($ADDRESSING_MODE)
651     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
652     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
653 gbeauche 1.23 ADDRESSING_MODE="memory banks"
654 cebix 1.27 fi
655 cebix 1.8 fi
656 gbeauche 1.23
657 gbeauche 1.32 dnl Enable VOSF screen updates with this feature is requested and feasible
658     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
659     AC_DEFINE(ENABLE_VOSF)
660     else
661 gbeauche 1.23 WANT_VOSF=no
662 cebix 1.19 fi
663 cebix 1.9
664 cebix 1.3 dnl Check for GAS.
665 cebix 1.1 HAVE_GAS=no
666     AC_MSG_CHECKING(for GAS .p2align feature)
667     cat >conftest.S << EOF
668     .text
669     .p2align 5
670     EOF
671     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
672     AC_MSG_RESULT($HAVE_GAS)
673    
674 cebix 1.3 dnl Check for GCC 2.7 or higher.
675 cebix 1.1 HAVE_GCC27=no
676     AC_MSG_CHECKING(for GCC 2.7 or higher)
677     AC_EGREP_CPP(yes,
678     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
679     yes
680     #endif
681     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
682    
683 gbeauche 1.46 dnl Check for GCC 3.0 or higher.
684     HAVE_GCC30=no
685     AC_MSG_CHECKING(for GCC 3.0 or higher)
686     AC_EGREP_CPP(yes,
687     [#if __GNUC__ >= 3
688     yes
689     #endif
690     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
691    
692 cebix 1.19 dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
693 cebix 1.53 dnl Also set "-fno-exceptions" for C++ because exception handling requires
694     dnl the frame pointer.
695 cebix 1.19 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
696 cebix 1.1 CFLAGS="$CFLAGS -fomit-frame-pointer"
697 cebix 1.53 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
698 cebix 1.1 fi
699    
700 gbeauche 1.46 dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
701     dnl As of 2001/08/02, this affects the following compilers:
702     dnl Official: probably gcc-3.1 (mainline CVS)
703     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
704     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
705     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
706     SAVED_CXXFLAGS="$CXXFLAGS"
707 gbeauche 1.47 CXXFLAGS="$CXXFLAGS -fno-merge-constants"
708 gbeauche 1.46 AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
709     AC_LANG_SAVE
710     AC_LANG_CPLUSPLUS
711     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
712     AC_LANG_RESTORE
713     ])
714     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
715     CXXFLAGS="$SAVED_CXXFLAGS"
716     fi
717     fi
718    
719 cebix 1.3 dnl Select appropriate CPU source and REGPARAM define.
720 gbeauche 1.23 ASM_OPTIMIZATIONS=none
721 cebix 1.9 CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
722 cebix 1.41 FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
723 cebix 1.38 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" -a "x$OS_TYPE" != "xfreebsd" ]]; then
724 cebix 1.9 dnl i386 CPU
725 cebix 1.1 DEFINES="$DEFINES -DREGPARAM=\"__attribute__((regparm(3)))\""
726     if [[ "x$HAVE_GAS" = "xyes" ]]; then
727 gbeauche 1.23 ASM_OPTIMIZATIONS=i386
728 gbeauche 1.31 DEFINES="$DEFINES -DX86_ASSEMBLY -DUNALIGNED_PROFITABLE -DOPTIMIZED_FLAGS"
729 gbeauche 1.34 CPUSRCS="cpufast1.s cpufast2.s cpufast3.s cpufast4.s cpufast5.s cpufast6.s cpufast7.s cpufast8.s"
730 gbeauche 1.22 FPUSRCS="../uae_cpu/fpu_x86.cpp"
731 cebix 1.1 fi
732 cebix 1.9 elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
733     dnl SPARC CPU
734 gbeauche 1.23 case "$target_os" in
735     solaris*)
736 cebix 1.9 AC_MSG_CHECKING(SPARC CPU architecture)
737     SPARC_TYPE=`Solaris/which_sparc`
738     AC_MSG_RESULT($SPARC_TYPE)
739     case "$SPARC_TYPE" in
740     SPARC_V8)
741 cebix 1.26 ASM_OPTIMIZATIONS="SPARC V8 architecture"
742 gbeauche 1.31 DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
743 cebix 1.9 CFLAGS="$CFLAGS -Wa,-Av8"
744     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
745     ;;
746     SPARC_V9)
747 cebix 1.26 ASM_OPTIMIZATIONS="SPARC V9 architecture"
748 gbeauche 1.31 DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
749 cebix 1.9 CFLAGS="$CFLAGS -Wa,-Av9"
750     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
751     ;;
752     esac
753     ;;
754     esac
755 cebix 1.27 elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
756 cebix 1.19 dnl Native m68k, no emulation
757 cebix 1.27 CPUINCLUDES="-I../native_cpu"
758     CPUSRCS="asm_support.s"
759 cebix 1.1 fi
760 cebix 1.9
761 gbeauche 1.35 dnl Select appropriate FPU source.
762     dnl 1. Optimized X86 assembly core if target is i386 architecture
763     SAVED_DEFINES=$DEFINES
764     if [[ "x$FPE_CORE" = "xdefault" ]]; then
765     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
766     DEFINES="$DEFINES -DFPU_X86"
767     FPE_CORE_STR="i386 optimized core"
768     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
769 gbeauche 1.46 FPE_CORE="i386"
770 gbeauche 1.36 else
771     FPE_CORE="uae"
772 gbeauche 1.35 fi
773     fi
774    
775     dnl 2. JIT-FPU only supports IEEE-based implementation.
776     if [[ "x$WANT_JIT_FPU" = "xyes" -a "x$FPE_CORE" != "xieee" ]]; then
777     AC_MSG_WARN([Sorry, JIT-FPU supports only the "ieee" FPE implementation])
778     FPE_CORE="ieee"
779     dnl Restore previous variables. FPE_CORE_STR and FPUSRCS are overwritten
780     DEFINES=$SAVED_DEFINES
781     fi
782    
783     dnl 3. Choose either IEEE-based implementation or the old UAE core
784     if [[ "x$FPE_CORE" = "xieee" ]]; then
785     AC_CHECK_HEADERS(fenv.h)
786     AC_CHECK_FUNCS(feclearexcept fegetexceptflag feraiseexcept fesetexceptflag fetestexcept)
787     AC_CHECK_FUNCS(fegetround fesetround)
788     DEFINES="$DEFINES -DFPU_IEEE"
789     FPE_CORE_STR="ieee-based fpu core"
790     FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
791     elif [[ "x$FPE_CORE" = "xuae" ]]; then
792     DEFINES="$DEFINES -DFPU_UAE"
793     FPE_CORE_STR="original uae core"
794     FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
795     fi
796    
797     dnl Check for certain math functions
798     AC_CHECK_FUNCS(atanh)
799     AC_CHECK_FUNCS(isnan isinf) dnl C99
800     AC_CHECK_FUNCS(isnanl isinfl) dnl IEEE ?
801    
802 cebix 1.19 dnl UAE CPU sources for all non-m68k-native architectures.
803     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
804 cebix 1.20 CPUINCLUDES="-I../uae_cpu"
805 gbeauche 1.22 CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp $FPUSRCS cpustbl.cpp cpudefs.cpp $CPUSRCS"
806 cebix 1.19 fi
807 cebix 1.1
808 gbeauche 1.23 dnl Remove the "-g" option if set for GCC.
809     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
810 gbeauche 1.43 CFLAGS=`echo $CFLAGS | sed -e 's/-g//g'`
811     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g//g'`
812 cebix 1.37 fi
813    
814     dnl Or if we have -Ofast
815     if [[ "x$HAVE_OFAST" = "xyes" ]]; then
816 gbeauche 1.43 CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -Ofast"
817     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -Ofast"
818 cebix 1.37 CXXFLAGS="-LANG:std $CXXFLAGS"
819     LDFLAGS="$LDFLAGS -Ofast"
820 gbeauche 1.23 fi
821    
822 cebix 1.3 dnl Generate Makefile.
823 cebix 1.1 AC_SUBST(DEFINES)
824     AC_SUBST(SYSSRCS)
825     AC_SUBST(CPUINCLUDES)
826     AC_SUBST(CPUSRCS)
827     AC_OUTPUT(Makefile)
828 cebix 1.12
829     dnl Print summary.
830     echo
831     echo Basilisk II configuration summary:
832     echo
833     echo XFree86 DGA support .............. : $WANT_XF86_DGA
834 cebix 1.17 echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
835 cebix 1.12 echo fbdev DGA support ................ : $WANT_FBDEV_DGA
836 gbeauche 1.23 echo Enable video on SEGV signals ..... : $WANT_VOSF
837 cebix 1.12 echo ESD sound support ................ : $WANT_ESD
838 cebix 1.14 echo GTK user interface ............... : $WANT_GTK
839 cebix 1.12 echo mon debugger support ............. : $WANT_MON
840 cebix 1.19 echo Running m68k code natively ....... : $WANT_NATIVE_M68K
841 gbeauche 1.35 echo Floating-Point emulation core .... : $FPE_CORE_STR
842 gbeauche 1.23 echo Assembly optimizations ........... : $ASM_OPTIMIZATIONS
843     echo Addressing mode .................. : $ADDRESSING_MODE
844 cebix 1.12 echo
845 cebix 1.19 echo "Configuration done. Now type \"make\" (or \"gmake\")."