ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.in
Revision: 1.34
Committed: 2001-03-20T17:35:45Z (23 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.33: +1 -1 lines
Log Message:
- removed old JIT compiler, its related support functions and files
  (compiler.{h,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.27 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=no]], [WANT_VOSF=$enableval], [WANT_VOSF=no])
13 gbeauche 1.32
14     dnl Addressing modes.
15 gbeauche 1.23 AC_ARG_ENABLE(addressing,
16 gbeauche 1.32 [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
17 gbeauche 1.23 [ case "$enableval" in
18 cebix 1.24 real) ADDRESSING_TEST_ORDER="real";;
19     direct) ADDRESSING_TEST_ORDER="direct";;
20     banks) ADDRESSING_TEST_ORDER="banks";;
21 gbeauche 1.32 fastest)ADDRESSING_TEST_ORDER="direct banks";;
22     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
23 gbeauche 1.23 esac
24     ],
25     [ ADDRESSING_TEST_ORDER="direct banks"
26     ])
27 gbeauche 1.32
28     dnl External packages.
29 cebix 1.17 AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
30     AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
31     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
32 cebix 1.1
33 gbeauche 1.23 dnl Canonical system information.
34     AC_CANONICAL_HOST
35     AC_CANONICAL_TARGET
36    
37     dnl Target OS type (target is host if not cross-compiling).
38     case "$target_os" in
39     linux*) OS_TYPE=linux;;
40     netbsd*) OS_TYPE=netbsd;;
41     freebsd*) OS_TYPE=freebsd;;
42     solaris*) OS_TYPE=solaris;;
43 cebix 1.28 *) OS_TYPE=`echo $target_os | sed -e 's/-/_/' | sed -e 's/\./_/'`;;
44 gbeauche 1.23 esac
45     DEFINES="$DEFINES -DOS_$OS_TYPE"
46    
47     dnl Target CPU type.
48     HAVE_I386=no
49     HAVE_M68K=no
50     HAVE_SPARC=no
51 cebix 1.33 HAVE_POWERPC=no
52 gbeauche 1.23 case "$target_cpu" in
53     i386* | i486* | i586* | i686* | i786* ) CPU_TYPE=i386 HAVE_I386=yes;;
54     m68k* ) CPU_TYPE=m68k HAVE_M68K=yes;;
55     sparc* ) CPU_TYPE=sparc HAVE_SPARC=yes;;
56 cebix 1.33 powerpc* ) CPU_TYPE=powerpc HAVE_POWERPC=yes;;
57 gbeauche 1.23 *) CPU_TYPE=`echo $target_cpu | sed -e 's/-/_/'`;;
58     esac
59     DEFINES="$DEFINES -DCPU_$CPU_TYPE"
60    
61 cebix 1.1 dnl Checks for programs.
62     AC_PROG_CC
63 gbeauche 1.23 AC_PROG_CC_C_O
64 cebix 1.4 AC_PROG_CPP
65 cebix 1.1 AC_PROG_CXX
66     AC_PROG_MAKE_SET
67     AC_PROG_INSTALL
68    
69 cebix 1.11 dnl We use mon if possible.
70     MONSRCS=
71 cebix 1.18 if [[ "x$WANT_MON" = "xyes" ]]; then
72     AC_MSG_CHECKING(for mon)
73 cebix 1.24 mon_srcdir=../../../mon/src
74     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
75 cebix 1.18 AC_MSG_RESULT(yes)
76 cebix 1.19 AC_DEFINE(ENABLE_MON)
77 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"
78 cebix 1.24 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
79 cebix 1.18 AC_CHECK_LIB(readline, readline)
80 cebix 1.19 AC_CHECK_LIB(termcap, tputs)
81     AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
82 cebix 1.18 else
83     AC_MSG_RESULT(no)
84     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
85     WANT_MON=no
86     fi
87 cebix 1.11 fi
88    
89 cebix 1.1 dnl Checks for libraries.
90 cebix 1.10 AC_CHECK_LIB(posix4, sem_init)
91    
92     dnl We need X11.
93 cebix 1.1 AC_PATH_XTRA
94     if [[ "x$no_x" = "xyes" ]]; then
95     AC_MSG_ERROR([You need X11 to run Basilisk II.])
96     fi
97     CFLAGS="$CFLAGS $X_CFLAGS"
98     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
99     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
100    
101 cebix 1.19 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
102     HAVE_PTHREADS=yes
103 cebix 1.10 AC_CHECK_LIB(pthread, pthread_create, , [
104     AC_CHECK_LIB(c_r, pthread_create, , [
105     AC_CHECK_LIB(PTL, pthread_create, , [
106 cebix 1.19 HAVE_PTHREADS=no
107 cebix 1.10 ])
108     ])
109     ])
110 cebix 1.19 if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
111     AC_DEFINE(HAVE_PTHREADS)
112     fi
113     AC_CHECK_FUNCS(pthread_cancel)
114 cebix 1.10
115     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
116 cebix 1.19 SEMSRC=
117 cebix 1.10 AC_CHECK_FUNCS(sem_init, , [
118 cebix 1.26 if test "x$HAVE_PTHREADS" = "xyes"; then
119 cebix 1.19 SEMSRC=posix_sem.cpp
120     fi
121 cebix 1.10 ])
122 cebix 1.1
123 cebix 1.10 dnl We use DGA (XFree86 or fbdev) if possible.
124 cebix 1.8 if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
125 cebix 1.10 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
126 cebix 1.19 AC_DEFINE(ENABLE_XF86_DGA)
127 cebix 1.1 LIBS="$LIBS -lXxf86dga"
128 cebix 1.8 if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
129     AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.])
130     WANT_FBDEV_DGA=no
131     fi
132 cebix 1.10 ], [
133     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
134 cebix 1.13 WANT_XF86_DGA=no
135 cebix 1.10 ])
136 cebix 1.8 fi
137     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
138 cebix 1.19 AC_DEFINE(ENABLE_FBDEV_DGA)
139 cebix 1.1 fi
140    
141 cebix 1.17 dnl We use XFree86 VidMode if possible.
142     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
143     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
144 cebix 1.19 AC_DEFINE(ENABLE_XF86_VIDMODE)
145 cebix 1.17 LIBS="$LIBS -lXxf86vm"
146     ], [
147     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
148     WANT_XF86_VIDMODE=no
149     ])
150     fi
151    
152 cebix 1.1 dnl We use GTK+ if possible.
153 cebix 1.10 UISRCS=../dummy/prefs_editor_dummy.cpp
154 cebix 1.14 if [[ "x$WANT_GTK" = "xyes" ]]; then
155 cebix 1.10 AM_PATH_GTK(1.2.0, [
156 cebix 1.19 AC_DEFINE(ENABLE_GTK)
157 cebix 1.10 CFLAGS="$CFLAGS $GTK_CFLAGS"
158     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
159     LIBS="$LIBS $GTK_LIBS"
160     UISRCS=prefs_editor_gtk.cpp
161     ], [
162     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
163 cebix 1.14 WANT_GTK=no
164 cebix 1.10 ])
165 cebix 1.1 fi
166    
167 cebix 1.10 dnl We use ESD if possible.
168     if [[ "x$WANT_ESD" = "xyes" ]]; then
169     AM_PATH_ESD(0.2.8, [
170 cebix 1.19 AC_DEFINE(ENABLE_ESD)
171 cebix 1.10 CFLAGS="$CFLAGS $ESD_CFLAGS"
172     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
173     LIBS="$LIBS $ESD_LIBS"
174     ], [
175     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
176     WANT_ESD=no
177     ])
178 cebix 1.1 fi
179    
180     dnl Checks for header files.
181     AC_HEADER_STDC
182     AC_CHECK_HEADERS(unistd.h fcntl.h sys/time.h)
183    
184     dnl Checks for typedefs, structures, and compiler characteristics.
185     AC_C_BIGENDIAN
186     AC_C_CONST
187     AC_C_INLINE
188     AC_CHECK_SIZEOF(short, 2)
189     AC_CHECK_SIZEOF(int, 4)
190     AC_CHECK_SIZEOF(long, 4)
191     AC_CHECK_SIZEOF(long long, 8)
192 gbeauche 1.23 AC_CHECK_SIZEOF(void *, 4)
193 cebix 1.1 AC_TYPE_OFF_T
194     AC_CHECK_TYPE(loff_t, off_t)
195     AC_TYPE_SIZE_T
196 gbeauche 1.23 AC_TYPE_SIGNAL
197 cebix 1.1 AC_HEADER_TIME
198     AC_STRUCT_TM
199    
200     dnl Checks for library functions.
201     AC_CHECK_FUNCS(strdup cfmakeraw)
202 cebix 1.21 AC_CHECK_FUNCS(clock_gettime timer_create)
203 cebix 1.1
204     dnl Select system-dependant source files.
205 cebix 1.19 SERIALSRC=serial_unix.cpp
206     ETHERSRC=../dummy/ether_dummy.cpp
207     SCSISRC=../dummy/scsi_dummy.cpp
208     AUDIOSRC=../dummy/audio_dummy.cpp
209     EXTRASYSSRCS=
210 cebix 1.27 CAN_NATIVE_M68K=no
211 gbeauche 1.23 case "$target_os" in
212     linux*)
213     ETHERSRC=Linux/ether_linux.cpp
214     SCSISRC=Linux/scsi_linux.cpp
215     AUDIOSRC=audio_oss_esd.cpp
216     ;;
217     freebsd*3.*)
218     AUDIOSRC=audio_oss_esd.cpp
219     DEFINES="$DEFINES -DBSD_COMP"
220     dnl Check for the CAM library
221     AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
222     if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
223     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
224     else
225     dnl Check for the sys kernel includes
226     AC_CHECK_HEADER(/sys/cam/cam.h)
227     if [[ "x$ac_cv_header__sys_cam_cam_h" = "xno" ]]; then
228     dnl In this case I should fix this thing including a "patch"
229     dnl to access directly to the functions in the kernel :) --Orlando
230     AC_MSG_WARN([Cannot find kernel includes for CAM library, disabling SCSI support.])
231     else
232     SCSISRC=FreeBSD/scsi_freebsd.cpp
233     CXXFLAGS="$CXXFLAGS -I/sys"
234     CFLAGS="$CFLAGS -I/sys"
235     LIBS="$LIBS -lcam"
236     DEFINES="$DEFINES -DCAM"
237     fi
238     fi
239     ;;
240     freebsd*)
241     DEFINES="$DEFINES -DBSD_COMP"
242     dnl Check for the SCSI library
243     AC_CHECK_LIB(scsi, scsi_open, HAVE_LIBSCSI=yes, HAVE_LIBSCSI=no)
244     if [[ "x$HAVE_LIBSCSI" = "xno" ]]; then
245     AC_MSG_WARN([Cannot find libscsi for SCSI management, disabling SCSI support.])
246     else
247     dnl Check for the sys kernel includes
248     AC_CHECK_HEADER(scsi.h sys/scsiio.h)
249     if [[ "x$ac_cv_header_scsi_h" = "xno" ]]; then
250     AC_MSG_WARN([Cannot find includes for the SCSI library, disabling SCSI support.])
251     else
252     SCSISRC=FreeBSD/scsi_freebsd.cpp
253     LIBS="$LIBS -lscsi"
254     fi
255     fi
256     ;;
257     netbsd*)
258 cebix 1.27 CAN_NATIVE_M68K=yes
259 gbeauche 1.23 ;;
260     solaris*)
261     AUDIOSRC=Solaris/audio_solaris.cpp
262     DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
263     ;;
264     irix*)
265 cebix 1.30 AUDIOSRC=Irix/audio_irix.cpp
266 gbeauche 1.23 EXTRASYSSRCS=Irix/unaligned.c
267 cebix 1.28 dnl IRIX headers work fine, but somehow don't define or use "STDC_HEADERS"
268     DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200 -DSTDC_HEADERS"
269 cebix 1.30 LIBS="$LIBS -laudio"
270 gbeauche 1.23 ;;
271     esac
272    
273 cebix 1.27 dnl Use 68k CPU natively?
274     WANT_NATIVE_M68K=no
275     if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
276     AC_DEFINE(ENABLE_NATIVE_M68K)
277     WANT_NATIVE_M68K=yes
278     fi
279    
280 gbeauche 1.23 if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
281     dnl Serial, ethernet and audio support needs pthreads
282     AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
283     SERIALSRC=../dummy/serial_dummy.cpp
284     ETHERSRC=../dummy/ether_dummy.cpp
285     AUDIOSRC=../dummy/audio_dummy.cpp
286     fi
287     SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
288    
289     dnl Define a macro that translates a yesno-variable into a C macro definition
290     dnl to be put into the config.h file
291     dnl $1 -- the macro to define
292     dnl $2 -- the value to translate
293     AC_DEFUN(AC_TRANSLATE_DEFINE, [
294     if [[ "x$2" = "xyes" ]]; then
295     AC_DEFINE($1)
296     fi
297     ])
298    
299     dnl Check if we can mmap 0x2000 bytes from 0x0000
300     AC_CACHE_CHECK("whether we can map Low Memory area 0x0000-0x2000",
301     ac_cv_can_map_lm, [
302     AC_LANG_SAVE
303     AC_LANG_CPLUSPLUS
304     AC_TRY_RUN([
305     #include <unistd.h>
306     #include <fcntl.h>
307     #include <sys/mman.h>
308    
309     int main()
310     { int zero_fd; char * lm;
311     if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1);
312     if ((lm = (char *)mmap((caddr_t)0x0000, 0x2000, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0)) == MAP_FAILED) exit(1);
313     lm[0] = 0x12;
314     munmap(lm, 0x2000);
315     close(zero_fd);
316     exit(0);
317     }
318     ],
319     [ac_cv_can_map_lm=yes],
320     [ac_cv_can_map_lm=no]
321     )
322     AC_LANG_RESTORE
323     ]
324     )
325    
326     dnl Check if extended signals are supported.
327     AC_CACHE_CHECK("whether your system supports extended signal handlers",
328     ac_cv_have_extended_signals, [
329     AC_LANG_SAVE
330     AC_LANG_CPLUSPLUS
331     AC_TRY_RUN([
332     #include <unistd.h>
333 cebix 1.25 #include <stdlib.h>
334 gbeauche 1.23 #include <signal.h>
335     #include <fcntl.h>
336     #include <sys/mman.h>
337    
338     static volatile caddr_t mem = 0;
339     static int zero_fd = -1;
340    
341     static RETSIGTYPE segfault_handler(int, siginfo_t * sip, void *)
342     { if ((caddr_t)(sip->si_addr) != mem) exit(1);
343     munmap(mem, getpagesize()); close(zero_fd); exit(0); }
344    
345     int main()
346     { if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1);
347     if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1);
348 cebix 1.25 struct sigaction sa; sa.sa_sigaction = segfault_handler; sa.sa_flags = SA_SIGINFO;
349 gbeauche 1.23 sigaction(SIGSEGV, &sa, 0);
350     mem[0] = 0;
351     exit(1); // should not be reached
352     }
353     ],
354     [ac_cv_have_extended_signals=yes],
355     [ac_cv_have_extended_signals=no]
356     )
357     AC_LANG_RESTORE
358     ]
359     )
360     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals")
361    
362     dnl Otherwise, check for subterfuges.
363     if [[ "x$ac_cv_have_extended_signals" = "xno" ]]; then
364     case "$target_os" in
365     linux*)
366     if [[ "x$HAVE_I386" = "xyes" ]]; then
367     AC_CACHE_CHECK("whether we then have a subterfuge for your system",
368     ac_cv_have_sigcontext_hack, [
369     AC_LANG_SAVE
370     AC_LANG_CPLUSPLUS
371     AC_TRY_RUN([
372     #include <unistd.h>
373     #include <signal.h>
374     #include <fcntl.h>
375     #include <sys/mman.h>
376    
377     static volatile caddr_t mem = 0;
378     static int zero_fd = -1;
379    
380     static RETSIGTYPE segfault_handler(int, struct sigcontext scs)
381     { if ((caddr_t)(scs.cr2) != mem) exit(1);
382 cebix 1.33 munmap(mem, getpagesize()); close(zero_fd); exit(0); }
383    
384     int main()
385     { if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1);
386     if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1);
387     struct sigaction sa; sa.sa_flags = 0;
388     sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler;
389     sigaction(SIGSEGV, &sa, 0);
390     mem[0] = 0;
391     exit(1); // should not be reached
392     }
393     ],
394     [ac_cv_have_sigcontext_hack=yes],
395     [ac_cv_have_sigcontext_hack=no]
396     )
397     AC_LANG_RESTORE
398     ])
399     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack)
400     elif [[ "x$HAVE_POWERPC" = "xyes" ]]; then
401     AC_CACHE_CHECK("whether we then have a subterfuge for your system",
402     ac_cv_have_sigcontext_hack, [
403     AC_LANG_SAVE
404     AC_LANG_CPLUSPLUS
405     AC_TRY_RUN([
406     #include <unistd.h>
407     #include <signal.h>
408     #include <fcntl.h>
409     #include <sys/mman.h>
410    
411     static volatile caddr_t mem = 0;
412     static int zero_fd = -1;
413    
414     static RETSIGTYPE segfault_handler(int, struct sigcontext_struct *scs)
415     { if ((caddr_t)(scs->regs->dar) != mem) exit(1);
416 gbeauche 1.23 munmap(mem, getpagesize()); close(zero_fd); exit(0); }
417    
418     int main()
419     { if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1);
420     if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1);
421     struct sigaction sa; sa.sa_flags = 0;
422 cebix 1.25 sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler;
423 gbeauche 1.23 sigaction(SIGSEGV, &sa, 0);
424     mem[0] = 0;
425     exit(1); // should not be reached
426     }
427     ],
428     [ac_cv_have_sigcontext_hack=yes],
429     [ac_cv_have_sigcontext_hack=no]
430     )
431     AC_LANG_RESTORE
432     ])
433 cebix 1.25 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack)
434 gbeauche 1.23 fi
435 cebix 1.27 ;;
436     netbsd*)
437     if [[ "x$HAVE_M68K" = "xyes" ]]; then
438     AC_CACHE_CHECK("whether we then have a subterfuge for your system",
439     ac_cv_have_sigcontext_hack, [
440     AC_LANG_SAVE
441     AC_LANG_CPLUSPLUS
442     AC_TRY_RUN([
443     #include <unistd.h>
444     #include <signal.h>
445     #include <fcntl.h>
446     #include <sys/mman.h>
447    
448     static volatile caddr_t mem = 0;
449     static int zero_fd = -1;
450    
451     static RETSIGTYPE segfault_handler(int, int code)
452     { if ((caddr_t)code != mem) exit(1);
453     munmap(mem, getpagesize()); close(zero_fd); exit(0); }
454    
455     int main()
456     { if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1);
457     if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1);
458     struct sigaction sa; sa.sa_flags = 0;
459     sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler;
460     sigaction(SIGSEGV, &sa, 0);
461     mem[0] = 0;
462     exit(1); // should not be reached
463     }
464     ],
465     [ac_cv_have_sigcontext_hack=yes],
466     [ac_cv_have_sigcontext_hack=no]
467     )
468     AC_LANG_RESTORE
469     ])
470     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack)
471     fi
472 cebix 1.1 ;;
473 gbeauche 1.23 esac
474     fi
475    
476     dnl Can we do Video on SEGV Signals ?
477     CAN_VOSF=no
478     if [[ "$ac_cv_have_extended_signals" = "yes" -o "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
479     CAN_VOSF=yes
480     fi
481    
482     dnl Determine the addressing mode to use
483 cebix 1.27 if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
484     ADDRESSING_MODE="real"
485     else
486     ADDRESSING_MODE=""
487     AC_MSG_CHECKING([for the addressing mode to use])
488     for am in $ADDRESSING_TEST_ORDER; do
489     case $am in
490     real)
491 gbeauche 1.32 dnl Requires ability to mmap() Low Memory globals
492 cebix 1.27 if [[ "x$ac_cv_can_map_lm" = "xno" ]]; then
493     continue
494     fi
495 gbeauche 1.32 dnl Requires VOSF screen updates
496     if [[ "x$CAN_VOSF" = "xno" ]]; then
497     continue
498 cebix 1.1 fi
499 gbeauche 1.32 dnl Real addressing will probably work.
500 cebix 1.27 ADDRESSING_MODE="real"
501     WANT_VOSF=yes dnl we can use VOSF and we need it actually
502     DEFINES="$DEFINES -DREAL_ADDRESSING"
503     break
504     ;;
505     direct)
506 gbeauche 1.32 dnl Requires VOSF screen updates
507 cebix 1.27 if [[ "x$CAN_VOSF" = "xyes" ]]; then
508     ADDRESSING_MODE="direct"
509     WANT_VOSF=yes dnl we can use VOSF and we need it actually
510     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
511     break
512 cebix 1.1 fi
513 cebix 1.27 ;;
514     banks)
515     dnl Default addressing mode
516     ADDRESSING_MODE="memory banks"
517 gbeauche 1.23 break
518 cebix 1.27 ;;
519     *)
520     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
521     esac
522     done
523     AC_MSG_RESULT($ADDRESSING_MODE)
524     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
525     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
526 gbeauche 1.23 ADDRESSING_MODE="memory banks"
527 cebix 1.27 fi
528 cebix 1.8 fi
529 gbeauche 1.23
530 gbeauche 1.32 dnl Enable VOSF screen updates with this feature is requested and feasible
531     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
532     AC_DEFINE(ENABLE_VOSF)
533     else
534 gbeauche 1.23 WANT_VOSF=no
535 cebix 1.19 fi
536 cebix 1.9
537 cebix 1.3 dnl Check for GAS.
538 cebix 1.1 HAVE_GAS=no
539     AC_MSG_CHECKING(for GAS .p2align feature)
540     cat >conftest.S << EOF
541     .text
542     .p2align 5
543     EOF
544     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
545     AC_MSG_RESULT($HAVE_GAS)
546    
547 cebix 1.3 dnl Check for GCC 2.7 or higher.
548 cebix 1.1 HAVE_GCC27=no
549     AC_MSG_CHECKING(for GCC 2.7 or higher)
550     AC_EGREP_CPP(yes,
551     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
552     yes
553     #endif
554     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
555    
556 cebix 1.19 dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
557     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
558 cebix 1.1 CFLAGS="$CFLAGS -fomit-frame-pointer"
559     CXXFLAGS="$CXXFLAGS -fomit-frame-pointer"
560     fi
561    
562 cebix 1.3 dnl Select appropriate CPU source and REGPARAM define.
563 gbeauche 1.23 ASM_OPTIMIZATIONS=none
564 cebix 1.9 CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
565 gbeauche 1.22 FPUSRCS="../uae_cpu/fpp.cpp"
566 cebix 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
567 cebix 1.9 dnl i386 CPU
568 cebix 1.1 DEFINES="$DEFINES -DREGPARAM=\"__attribute__((regparm(3)))\""
569     if [[ "x$HAVE_GAS" = "xyes" ]]; then
570 gbeauche 1.23 ASM_OPTIMIZATIONS=i386
571 gbeauche 1.31 DEFINES="$DEFINES -DX86_ASSEMBLY -DUNALIGNED_PROFITABLE -DOPTIMIZED_FLAGS"
572 gbeauche 1.34 CPUSRCS="cpufast1.s cpufast2.s cpufast3.s cpufast4.s cpufast5.s cpufast6.s cpufast7.s cpufast8.s"
573 gbeauche 1.22 FPUSRCS="../uae_cpu/fpu_x86.cpp"
574 cebix 1.1 fi
575 cebix 1.9 elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
576     dnl SPARC CPU
577 gbeauche 1.23 case "$target_os" in
578     solaris*)
579 cebix 1.9 AC_MSG_CHECKING(SPARC CPU architecture)
580     SPARC_TYPE=`Solaris/which_sparc`
581     AC_MSG_RESULT($SPARC_TYPE)
582     case "$SPARC_TYPE" in
583     SPARC_V8)
584 cebix 1.26 ASM_OPTIMIZATIONS="SPARC V8 architecture"
585 gbeauche 1.31 DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
586 cebix 1.9 CFLAGS="$CFLAGS -Wa,-Av8"
587     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
588     ;;
589     SPARC_V9)
590 cebix 1.26 ASM_OPTIMIZATIONS="SPARC V9 architecture"
591 gbeauche 1.31 DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
592 cebix 1.9 CFLAGS="$CFLAGS -Wa,-Av9"
593     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
594     ;;
595     esac
596     ;;
597     esac
598 cebix 1.27 elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
599 cebix 1.19 dnl Native m68k, no emulation
600 cebix 1.27 CPUINCLUDES="-I../native_cpu"
601     CPUSRCS="asm_support.s"
602 cebix 1.1 fi
603 cebix 1.9
604 cebix 1.19 dnl UAE CPU sources for all non-m68k-native architectures.
605     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
606 cebix 1.20 CPUINCLUDES="-I../uae_cpu"
607 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"
608 cebix 1.19 fi
609 cebix 1.1
610 gbeauche 1.23 dnl Remove the "-g" option if set for GCC.
611     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
612 cebix 1.26 dnl gb-- Probably not the cleanest way to take
613     CFLAGS=`echo $CFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
614     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
615 gbeauche 1.23 fi
616    
617 cebix 1.3 dnl Generate Makefile.
618 cebix 1.1 AC_SUBST(DEFINES)
619     AC_SUBST(SYSSRCS)
620     AC_SUBST(CPUINCLUDES)
621     AC_SUBST(CPUSRCS)
622     AC_OUTPUT(Makefile)
623 cebix 1.12
624     dnl Print summary.
625     echo
626     echo Basilisk II configuration summary:
627     echo
628     echo XFree86 DGA support .............. : $WANT_XF86_DGA
629 cebix 1.17 echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
630 cebix 1.12 echo fbdev DGA support ................ : $WANT_FBDEV_DGA
631 gbeauche 1.23 echo Enable video on SEGV signals ..... : $WANT_VOSF
632 cebix 1.12 echo ESD sound support ................ : $WANT_ESD
633 cebix 1.14 echo GTK user interface ............... : $WANT_GTK
634 cebix 1.12 echo mon debugger support ............. : $WANT_MON
635 cebix 1.19 echo Running m68k code natively ....... : $WANT_NATIVE_M68K
636 gbeauche 1.23 echo Assembly optimizations ........... : $ASM_OPTIMIZATIONS
637     echo Addressing mode .................. : $ADDRESSING_MODE
638 cebix 1.12 echo
639 cebix 1.19 echo "Configuration done. Now type \"make\" (or \"gmake\")."