ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.in
Revision: 1.48
Committed: 2001-09-02T13:50:05Z (23 years, 2 months ago) by cebix
Branch: MAIN
Changes since 1.47: +3 -0 lines
Log Message:
- added IRIX patches from Brian Johnson
- the existence of socklen_t is now checked by the configure script

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