ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.in
Revision: 1.44
Committed: 2001-06-26T22:35:40Z (23 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.43: +195 -51 lines
Log Message:
- added SIGSEGV support for Linux/Alpha (to be checked), Darwin/PPC
- added uniform virtual memory allocation
  (supports mmap(), vm_allocate(), or fallbacks to malloc()/free())
- cleaned up memory allocation in main_unix.cpp

File Contents

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