1 |
dnl Process this file with autoconf to produce a configure script. |
2 |
dnl Written in 2002 by Christian Bauer |
3 |
|
4 |
AC_INIT(main_unix.cpp) |
5 |
AC_PREREQ(2.12) |
6 |
AC_CONFIG_HEADER(config.h) |
7 |
|
8 |
dnl Canonical system information. |
9 |
AC_CANONICAL_HOST |
10 |
AC_CANONICAL_TARGET |
11 |
|
12 |
dnl Options. |
13 |
AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) |
14 |
AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto]) |
15 |
AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes]) |
16 |
AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes]) |
17 |
AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes]) |
18 |
AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes]) |
19 |
AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes]) |
20 |
AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes]) |
21 |
AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval]) |
22 |
|
23 |
dnl Checks for programs. |
24 |
AC_PROG_CC |
25 |
AC_PROG_CPP |
26 |
AC_PROG_CXX |
27 |
AC_PROG_MAKE_SET |
28 |
AC_PROG_INSTALL |
29 |
|
30 |
dnl Check for PowerPC target CPU. |
31 |
HAVE_PPC=no |
32 |
AC_MSG_CHECKING(for PowerPC target CPU) |
33 |
AC_EGREP_CPP(yes, |
34 |
[ |
35 |
#ifdef __powerpc__ |
36 |
yes |
37 |
#endif |
38 |
#ifdef __ppc__ |
39 |
yes |
40 |
#endif |
41 |
], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no)) |
42 |
|
43 |
dnl We use native CPU if possible. |
44 |
EMULATED_PPC=yes |
45 |
case $WANT_EMULATED_PPC in |
46 |
auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;; |
47 |
no) EMULATED_PPC=no;; |
48 |
esac |
49 |
if [[ "x$EMULATED_PPC" = "xyes" ]]; then |
50 |
AC_DEFINE(EMULATED_PPC) |
51 |
fi |
52 |
|
53 |
dnl We use mon if possible. |
54 |
MONSRCS= |
55 |
case "x$WANT_MON" in |
56 |
x/* | x.*) |
57 |
mon_srcdir=$WANT_MON |
58 |
WANT_MON=yes |
59 |
;; |
60 |
xyes) |
61 |
mon_srcdir=../../../mon/src |
62 |
;; |
63 |
esac |
64 |
if [[ "x$WANT_MON" = "xyes" ]]; then |
65 |
AC_MSG_CHECKING(for mon) |
66 |
if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then |
67 |
AC_MSG_RESULT(yes) |
68 |
AC_DEFINE(ENABLE_MON) |
69 |
MONSRCS="$mon_srcdir/mon.cpp $mon_srcdir/mon_6502.cpp $mon_srcdir/mon_z80.cpp $mon_srcdir/mon_cmd.cpp $mon_srcdir/mon_lowmem.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" |
70 |
CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass" |
71 |
AC_CHECK_LIB(ncurses, tgetent, , |
72 |
AC_CHECK_LIB(termcap, tgetent, , |
73 |
AC_CHECK_LIB(termlib, tgetent, , |
74 |
AC_CHECK_LIB(terminfo, tgetent, , |
75 |
AC_CHECK_LIB(Hcurses, tgetent, , |
76 |
AC_CHECK_LIB(curses, tgetent)))))) |
77 |
AC_CHECK_LIB(readline, readline) |
78 |
AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h) |
79 |
else |
80 |
AC_MSG_RESULT(no) |
81 |
AC_MSG_WARN([Could not find mon, ignoring --with-mon.]) |
82 |
WANT_MON=no |
83 |
fi |
84 |
fi |
85 |
|
86 |
dnl Checks for libraries. |
87 |
AC_CHECK_LIB(posix4, sem_init) |
88 |
|
89 |
dnl We need X11. |
90 |
AC_PATH_XTRA |
91 |
if [[ "x$no_x" = "xyes" ]]; then |
92 |
AC_MSG_ERROR([You need X11 to run SheepShaver.]) |
93 |
fi |
94 |
CFLAGS="$CFLAGS $X_CFLAGS" |
95 |
CXXFLAGS="$CXXFLAGS $X_CFLAGS" |
96 |
LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" |
97 |
|
98 |
dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL. |
99 |
HAVE_PTHREADS=yes |
100 |
case $EMULATED_PPC:$target_os in |
101 |
no:linux*) |
102 |
dnl We do have our own pthread_cancel() implementation |
103 |
AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.]) |
104 |
;; |
105 |
*:*) |
106 |
AC_CHECK_LIB(pthread, pthread_create, , [ |
107 |
AC_CHECK_LIB(c_r, pthread_create, , [ |
108 |
AC_CHECK_LIB(PTL, pthread_create, , [ |
109 |
AC_MSG_ERROR([You need pthreads to run Basilisk II.]) |
110 |
]) |
111 |
]) |
112 |
]) |
113 |
AC_CHECK_FUNCS(pthread_cancel) |
114 |
AC_CHECK_FUNCS(pthread_mutexattr_setprotocol) |
115 |
AC_CHECK_FUNCS(pthread_mutexattr_settype) |
116 |
AC_CHECK_FUNCS(pthread_mutexattr_setpshared) |
117 |
if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then |
118 |
AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) |
119 |
fi |
120 |
dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. |
121 |
SEMSRC= |
122 |
AC_CHECK_FUNCS(sem_init, , [ |
123 |
if test "x$HAVE_PTHREADS" = "xyes"; then |
124 |
SEMSRC=posix_sem.cpp |
125 |
fi |
126 |
]) |
127 |
;; |
128 |
esac |
129 |
|
130 |
dnl We use XFree86 DGA if possible. |
131 |
if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then |
132 |
AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [ |
133 |
AC_DEFINE(ENABLE_XF86_DGA) |
134 |
LIBS="$LIBS -lXxf86dga" |
135 |
], [ |
136 |
AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.]) |
137 |
WANT_XF86_DGA=no |
138 |
]) |
139 |
fi |
140 |
|
141 |
dnl We use XFree86 VidMode if possible. |
142 |
if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then |
143 |
AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [ |
144 |
AC_DEFINE(ENABLE_XF86_VIDMODE) |
145 |
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 |
dnl We use GTK+ if possible. |
153 |
UISRCS=../dummy/prefs_editor_dummy.cpp |
154 |
if [[ "x$WANT_GTK" = "xyes" ]]; then |
155 |
AM_PATH_GTK(1.2.0, [ |
156 |
AC_DEFINE(ENABLE_GTK) |
157 |
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 |
WANT_GTK=no |
164 |
]) |
165 |
fi |
166 |
|
167 |
dnl We use ESD if possible. |
168 |
if [[ "x$WANT_ESD" = "xyes" ]]; then |
169 |
AM_PATH_ESD(0.2.8, [ |
170 |
AC_DEFINE(ENABLE_ESD) |
171 |
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 |
fi |
179 |
|
180 |
dnl Checks for header files. |
181 |
AC_HEADER_STDC |
182 |
AC_HEADER_SYS_WAIT |
183 |
AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h) |
184 |
AC_CHECK_HEADERS(sys/time.h sys/times.h) |
185 |
AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h) |
186 |
|
187 |
dnl Checks for typedefs, structures, and compiler characteristics. |
188 |
AC_C_BIGENDIAN |
189 |
AC_C_CONST |
190 |
AC_C_INLINE |
191 |
AC_CHECK_SIZEOF(short, 2) |
192 |
AC_CHECK_SIZEOF(int, 4) |
193 |
AC_CHECK_SIZEOF(long, 4) |
194 |
AC_CHECK_SIZEOF(long long, 8) |
195 |
AC_CHECK_SIZEOF(float, 4) |
196 |
AC_CHECK_SIZEOF(double, 8) |
197 |
AC_CHECK_SIZEOF(void *, 4) |
198 |
AC_TYPE_OFF_T |
199 |
AC_CHECK_TYPE(loff_t, off_t) |
200 |
AC_TYPE_SIZE_T |
201 |
AC_TYPE_SIGNAL |
202 |
AC_HEADER_TIME |
203 |
AC_STRUCT_TM |
204 |
|
205 |
dnl Check whether struct sigaction has sa_restorer member. |
206 |
AC_CACHE_CHECK([whether struct sigaction has sa_restorer], |
207 |
ac_cv_signal_sa_restorer, [ |
208 |
AC_TRY_COMPILE([ |
209 |
#include <signal.h> |
210 |
], [struct sigaction sa; sa.sa_restorer = 0;], |
211 |
ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no, |
212 |
dnl When cross-compiling, do not assume anything. |
213 |
ac_cv_signal_sa_restorer=no |
214 |
) |
215 |
]) |
216 |
if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then |
217 |
AC_DEFINE(HAVE_SIGNAL_SA_RESTORER) |
218 |
fi |
219 |
|
220 |
dnl Checks for library functions. |
221 |
AC_CHECK_FUNCS(strdup cfmakeraw) |
222 |
AC_CHECK_FUNCS(nanosleep) |
223 |
AC_CHECK_FUNCS(sigaction signal) |
224 |
AC_CHECK_FUNCS(mmap mprotect munmap) |
225 |
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) |
226 |
|
227 |
dnl Darwin seems to define mach_task_self() instead of task_self(). |
228 |
AC_CHECK_FUNCS(mach_task_self task_self) |
229 |
|
230 |
dnl We need clock_gettime() for better performance but it may drag |
231 |
dnl libpthread in, which we don't want for native ppc mode |
232 |
case $EMULATED_PPC:$target_os in |
233 |
no:linux*) |
234 |
;; |
235 |
*:*) |
236 |
AC_SEARCH_LIBS(clock_gettime, [rt posix4]) |
237 |
AC_CHECK_FUNCS(clock_gettime) |
238 |
;; |
239 |
esac |
240 |
|
241 |
dnl Select system-dependant sources. |
242 |
SERIALSRC=serial_unix.cpp |
243 |
ETHERSRC=../dummy/ether_dummy.cpp |
244 |
SCSISRC=../dummy/scsi_dummy.cpp |
245 |
AUDIOSRC=../dummy/audio_dummy.cpp |
246 |
EXTRASYSSRCS= |
247 |
case "$target_os" in |
248 |
linux*) |
249 |
ETHERSRC=Linux/ether_linux.cpp |
250 |
AUDIOSRC=audio_oss_esd.cpp |
251 |
SCSISRC=Linux/scsi_linux.cpp |
252 |
if [[ "x$EMULATED_PPC" = "xno" ]]; then |
253 |
EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S" |
254 |
fi |
255 |
;; |
256 |
darwin*) |
257 |
if [[ "x$EMULATED_PPC" = "xno" ]]; then |
258 |
EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S" |
259 |
fi |
260 |
;; |
261 |
esac |
262 |
SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" |
263 |
|
264 |
dnl Define a macro that translates a yesno-variable into a C macro definition |
265 |
dnl to be put into the config.h file |
266 |
dnl $1 -- the macro to define |
267 |
dnl $2 -- the value to translate |
268 |
dnl $3 -- template name |
269 |
AC_DEFUN(AC_TRANSLATE_DEFINE, [ |
270 |
if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then |
271 |
AC_DEFINE($1, 1, $3) |
272 |
fi |
273 |
]) |
274 |
|
275 |
dnl Various checks if the system supports vm_allocate() and the like functions. |
276 |
have_mach_vm=no |
277 |
if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \ |
278 |
"x$ac_cv_func_vm_protect" = "xyes" ]]; then |
279 |
have_mach_vm=yes |
280 |
fi |
281 |
AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm", |
282 |
[Define if your system has a working vm_allocate()-based memory allocator.]) |
283 |
|
284 |
dnl Check that vm_allocate(), vm_protect() work |
285 |
if [[ "x$have_mach_vm" = "xyes" ]]; then |
286 |
|
287 |
AC_CACHE_CHECK([whether vm_protect works], |
288 |
ac_cv_vm_protect_works, [ |
289 |
AC_LANG_SAVE |
290 |
AC_LANG_CPLUSPLUS |
291 |
ac_cv_vm_protect_works=yes |
292 |
dnl First the tests that should segfault |
293 |
for test_def in NONE_READ NONE_WRITE READ_WRITE; do |
294 |
AC_TRY_RUN([ |
295 |
#define CONFIGURE_TEST_VM_MAP |
296 |
#define TEST_VM_PROT_$test_def |
297 |
#include "vm_alloc.cpp" |
298 |
], ac_cv_vm_protect_works=no, rm -f core, |
299 |
dnl When cross-compiling, do not assume anything |
300 |
ac_cv_vm_protect_works="guessing no" |
301 |
) |
302 |
done |
303 |
AC_TRY_RUN([ |
304 |
#define CONFIGURE_TEST_VM_MAP |
305 |
#define TEST_VM_PROT_RDWR_WRITE |
306 |
#include "vm_alloc.cpp" |
307 |
], , ac_cv_vm_protect_works=no, |
308 |
dnl When cross-compiling, do not assume anything |
309 |
ac_cv_vm_protect_works="guessing no" |
310 |
) |
311 |
AC_LANG_RESTORE |
312 |
] |
313 |
) |
314 |
|
315 |
dnl Remove support for vm_allocate() if vm_protect() does not work |
316 |
if [[ "x$have_mach_vm" = "xyes" ]]; then |
317 |
case $ac_cv_vm_protect_works in |
318 |
*yes) have_mach_vm=yes;; |
319 |
*no) have_mach_vm=no;; |
320 |
esac |
321 |
fi |
322 |
AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm", |
323 |
[Define if your system has a working vm_allocate()-based memory allocator.]) |
324 |
|
325 |
fi dnl HAVE_MACH_VM |
326 |
|
327 |
dnl Various checks if the system supports mmap() and the like functions. |
328 |
dnl ... and Mach memory allocators are not supported |
329 |
have_mmap_vm=no |
330 |
if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \ |
331 |
"x$ac_cv_func_mprotect" = "xyes" ]]; then |
332 |
if [[ "x$have_mach_vm" = "xno" ]]; then |
333 |
have_mmap_vm=yes |
334 |
fi |
335 |
fi |
336 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm", |
337 |
[Define if your system has a working mmap()-based memory allocator.]) |
338 |
|
339 |
dnl Check that mmap() and associated functions work. |
340 |
if [[ "x$have_mmap_vm" = "xyes" ]]; then |
341 |
|
342 |
dnl Check if we have a working anonymous mmap() |
343 |
AC_CACHE_CHECK([whether mmap supports MAP_ANON], |
344 |
ac_cv_mmap_anon, [ |
345 |
AC_LANG_SAVE |
346 |
AC_LANG_CPLUSPLUS |
347 |
AC_TRY_RUN([ |
348 |
#define HAVE_MMAP_ANON |
349 |
#define CONFIGURE_TEST_VM_MAP |
350 |
#define TEST_VM_MMAP_ANON |
351 |
#include "vm_alloc.cpp" |
352 |
], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no, |
353 |
dnl When cross-compiling, do not assume anything. |
354 |
ac_cv_mmap_anon="guessing no" |
355 |
) |
356 |
AC_LANG_RESTORE |
357 |
] |
358 |
) |
359 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon", |
360 |
[Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.]) |
361 |
|
362 |
AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS], |
363 |
ac_cv_mmap_anonymous, [ |
364 |
AC_LANG_SAVE |
365 |
AC_LANG_CPLUSPLUS |
366 |
AC_TRY_RUN([ |
367 |
#define HAVE_MMAP_ANONYMOUS |
368 |
#define CONFIGURE_TEST_VM_MAP |
369 |
#define TEST_VM_MMAP_ANON |
370 |
#include "vm_alloc.cpp" |
371 |
], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no, |
372 |
dnl When cross-compiling, do not assume anything. |
373 |
ac_cv_mmap_anonymous="guessing no" |
374 |
) |
375 |
AC_LANG_RESTORE |
376 |
] |
377 |
) |
378 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous", |
379 |
[Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.]) |
380 |
|
381 |
AC_CACHE_CHECK([whether mprotect works], |
382 |
ac_cv_mprotect_works, [ |
383 |
AC_LANG_SAVE |
384 |
AC_LANG_CPLUSPLUS |
385 |
ac_cv_mprotect_works=yes |
386 |
dnl First the tests that should segfault |
387 |
for test_def in NONE_READ NONE_WRITE READ_WRITE; do |
388 |
AC_TRY_RUN([ |
389 |
#define CONFIGURE_TEST_VM_MAP |
390 |
#define TEST_VM_PROT_$test_def |
391 |
#include "vm_alloc.cpp" |
392 |
], ac_cv_mprotect_works=no, rm -f core, |
393 |
dnl When cross-compiling, do not assume anything |
394 |
ac_cv_mprotect_works="guessing no" |
395 |
) |
396 |
done |
397 |
AC_TRY_RUN([ |
398 |
#define CONFIGURE_TEST_VM_MAP |
399 |
#define TEST_VM_PROT_RDWR_WRITE |
400 |
#include "vm_alloc.cpp" |
401 |
], , ac_cv_mprotect_works=no, |
402 |
dnl When cross-compiling, do not assume anything |
403 |
ac_cv_mprotect_works="guessing no" |
404 |
) |
405 |
AC_LANG_RESTORE |
406 |
] |
407 |
) |
408 |
|
409 |
dnl Remove support for mmap() if mprotect() does not work |
410 |
if [[ "x$have_mmap_vm" = "xyes" ]]; then |
411 |
case $ac_cv_mprotect_works in |
412 |
*yes) have_mmap_vm=yes;; |
413 |
*no) have_mmap_vm=no;; |
414 |
esac |
415 |
fi |
416 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm, |
417 |
[Define if your system has a working mmap()-based memory allocator.]) |
418 |
|
419 |
fi dnl HAVE_MMAP_VM |
420 |
|
421 |
dnl Check if we can modify the __PAGEZERO segment for use as Low Memory |
422 |
AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000], |
423 |
ac_cv_pagezero_hack, [ |
424 |
ac_cv_pagezero_hack=no |
425 |
if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then |
426 |
ac_cv_pagezero_hack=yes |
427 |
dnl might as well skip the test for mmap-able low memory |
428 |
ac_cv_can_map_lm=no |
429 |
fi |
430 |
]) |
431 |
AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack", |
432 |
[Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.]) |
433 |
|
434 |
dnl Check if we can mmap 0x3000 bytes from 0x0000 |
435 |
AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000], |
436 |
ac_cv_can_map_lm, [ |
437 |
AC_LANG_SAVE |
438 |
AC_LANG_CPLUSPLUS |
439 |
AC_TRY_RUN([ |
440 |
#include "vm_alloc.cpp" |
441 |
int main(void) { /* returns 0 if we could map the lowmem globals */ |
442 |
volatile char * lm = 0; |
443 |
if (vm_init() < 0) exit(1); |
444 |
if (vm_acquire_fixed(0, 0x2000) < 0) exit(1); |
445 |
lm[0] = 'z'; |
446 |
if (vm_release((char *)lm, 0x2000) < 0) exit(1); |
447 |
vm_exit(); exit(0); |
448 |
} |
449 |
], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no, |
450 |
dnl When cross-compiling, do not assume anything. |
451 |
ac_cv_can_map_lm="guessing no" |
452 |
) |
453 |
AC_LANG_RESTORE |
454 |
] |
455 |
) |
456 |
|
457 |
dnl Check signal handlers need to be reinstalled |
458 |
AC_CACHE_CHECK([whether signal handlers need to be reinstalled], |
459 |
ac_cv_signal_need_reinstall, [ |
460 |
AC_LANG_SAVE |
461 |
AC_LANG_CPLUSPLUS |
462 |
AC_TRY_RUN([ |
463 |
#include <stdlib.h> |
464 |
#ifdef HAVE_UNISTD_H |
465 |
#include <unistd.h> |
466 |
#endif |
467 |
#include <signal.h> |
468 |
static int handled_signal = 0; |
469 |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
470 |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
471 |
signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
472 |
exit(handled_signal == 2); |
473 |
} |
474 |
], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no, |
475 |
dnl When cross-compiling, do not assume anything. |
476 |
ac_cv_signal_need_reinstall="guessing yes" |
477 |
) |
478 |
AC_LANG_RESTORE |
479 |
] |
480 |
) |
481 |
AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall", |
482 |
[Define if your system requires signals to be reinstalled.]) |
483 |
|
484 |
dnl Check if sigaction handlers need to be reinstalled |
485 |
AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled], |
486 |
ac_cv_sigaction_need_reinstall, [ |
487 |
AC_LANG_SAVE |
488 |
AC_LANG_CPLUSPLUS |
489 |
AC_TRY_RUN([ |
490 |
#include <stdlib.h> |
491 |
#ifdef HAVE_UNISTD_H |
492 |
#include <unistd.h> |
493 |
#endif |
494 |
#include <signal.h> |
495 |
static int handled_signal = 0; |
496 |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
497 |
typedef RETSIGTYPE (*signal_handler)(int); |
498 |
static signal_handler mysignal(int sig, signal_handler handler) { |
499 |
struct sigaction old_sa; |
500 |
struct sigaction new_sa; |
501 |
new_sa.sa_handler = handler; |
502 |
return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler); |
503 |
} |
504 |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
505 |
mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
506 |
exit(handled_signal == 2); |
507 |
} |
508 |
], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no, |
509 |
dnl When cross-compiling, do not assume anything. |
510 |
ac_cv_sigaction_need_reinstall="guessing yes" |
511 |
) |
512 |
AC_LANG_RESTORE |
513 |
] |
514 |
) |
515 |
AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall", |
516 |
[Define if your system requires sigactions to be reinstalled.]) |
517 |
|
518 |
dnl Check if Mach exceptions supported. |
519 |
AC_CACHE_CHECK([whether your system supports Mach exceptions], |
520 |
ac_cv_have_mach_exceptions, [ |
521 |
AC_LANG_SAVE |
522 |
AC_LANG_CPLUSPLUS |
523 |
AC_TRY_RUN([ |
524 |
#define HAVE_MACH_EXCEPTIONS 1 |
525 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
526 |
#include "vm_alloc.cpp" |
527 |
#include "sigsegv.cpp" |
528 |
], [ |
529 |
sigsegv_recovery=mach |
530 |
ac_cv_have_mach_exceptions=yes |
531 |
], |
532 |
ac_cv_have_mach_exceptions=no, |
533 |
dnl When cross-compiling, do not assume anything. |
534 |
ac_cv_have_mach_exceptions=no |
535 |
) |
536 |
AC_LANG_RESTORE |
537 |
] |
538 |
) |
539 |
AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions", |
540 |
[Define if your system supports Mach exceptions.]) |
541 |
|
542 |
dnl Otherwise, check if extended signals are supported. |
543 |
if [[ -z "$sigsegv_recovery" ]]; then |
544 |
AC_CACHE_CHECK([whether your system supports extended signal handlers], |
545 |
ac_cv_have_extended_signals, [ |
546 |
AC_LANG_SAVE |
547 |
AC_LANG_CPLUSPLUS |
548 |
AC_TRY_RUN([ |
549 |
#define HAVE_SIGINFO_T 1 |
550 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
551 |
#include "vm_alloc.cpp" |
552 |
#include "sigsegv.cpp" |
553 |
], [ |
554 |
sigsegv_recovery=siginfo |
555 |
ac_cv_have_extended_signals=yes |
556 |
], |
557 |
ac_cv_have_extended_signals=no, |
558 |
dnl When cross-compiling, do not assume anything. |
559 |
ac_cv_have_extended_signals=no |
560 |
) |
561 |
AC_LANG_RESTORE |
562 |
] |
563 |
) |
564 |
AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals", |
565 |
[Define if your system support extended signals.]) |
566 |
fi |
567 |
|
568 |
dnl Otherwise, check for subterfuges. |
569 |
if [[ -z "$sigsegv_recovery" ]]; then |
570 |
AC_CACHE_CHECK([whether we then have a subterfuge for your system], |
571 |
ac_cv_have_sigcontext_hack, [ |
572 |
AC_LANG_SAVE |
573 |
AC_LANG_CPLUSPLUS |
574 |
AC_TRY_RUN([ |
575 |
#define HAVE_SIGCONTEXT_SUBTERFUGE 1 |
576 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
577 |
#include "vm_alloc.cpp" |
578 |
#include "sigsegv.cpp" |
579 |
], [ |
580 |
sigsegv_recovery=sigcontext |
581 |
ac_cv_have_sigcontext_hack=yes |
582 |
], |
583 |
ac_cv_have_sigcontext_hack=no, |
584 |
dnl When cross-compiling, do not assume anything. |
585 |
ac_cv_have_sigcontext_hack=no |
586 |
) |
587 |
AC_LANG_RESTORE |
588 |
]) |
589 |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack", |
590 |
[Define if we know a hack to replace siginfo_t->si_addr member.]) |
591 |
fi |
592 |
|
593 |
dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler) |
594 |
AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler], |
595 |
ac_cv_have_skip_instruction, [ |
596 |
AC_LANG_SAVE |
597 |
AC_LANG_CPLUSPLUS |
598 |
AC_TRY_RUN([ |
599 |
#define HAVE_SIGSEGV_SKIP_INSTRUCTION 1 |
600 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
601 |
#include "vm_alloc.cpp" |
602 |
#include "sigsegv.cpp" |
603 |
], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no, |
604 |
dnl When cross-compiling, do not assume anything. |
605 |
ac_cv_have_skip_instruction=no |
606 |
) |
607 |
AC_LANG_RESTORE |
608 |
] |
609 |
) |
610 |
AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction", |
611 |
[Define if we can ignore the fault (instruction skipping in SIGSEGV handler).]) |
612 |
|
613 |
dnl Can we do Video on SEGV Signals ? |
614 |
CAN_VOSF=no |
615 |
if [[ -n "$sigsegv_recovery" ]]; then |
616 |
CAN_VOSF=yes |
617 |
fi |
618 |
|
619 |
dnl Enable VOSF screen updates with this feature is requested and feasible |
620 |
if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then |
621 |
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.]) |
622 |
else |
623 |
WANT_VOSF=no |
624 |
fi |
625 |
|
626 |
dnl Platform specific binary postprocessor |
627 |
BLESS=/bin/true |
628 |
if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then |
629 |
BLESS=Darwin/lowmem |
630 |
LDFLAGS="$LDFLAGS -pagezero_size 0x3000" |
631 |
fi |
632 |
|
633 |
dnl Check for GCC 2.7 or higher. |
634 |
HAVE_GCC27=no |
635 |
AC_MSG_CHECKING(for GCC 2.7 or higher) |
636 |
AC_EGREP_CPP(xyes, |
637 |
[#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5 |
638 |
xyes |
639 |
#endif |
640 |
], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no)) |
641 |
|
642 |
dnl Check for GCC 3.0 or higher. |
643 |
HAVE_GCC30=no |
644 |
AC_MSG_CHECKING(for GCC 3.0 or higher) |
645 |
AC_EGREP_CPP(xyes, |
646 |
[#if __GNUC__ >= 3 |
647 |
xyes |
648 |
#endif |
649 |
], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no)) |
650 |
|
651 |
dnl Check for ICC. |
652 |
AC_MSG_CHECKING(for ICC) |
653 |
HAVE_ICC=no |
654 |
if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then |
655 |
HAVE_ICC=yes |
656 |
fi |
657 |
AC_MSG_RESULT($HAVE_ICC) |
658 |
|
659 |
# Test if the compiler can generate ELF objects |
660 |
AC_CACHE_CHECK([whether the compiler can generate ELF objects], |
661 |
ac_cv_elf_objects, [ |
662 |
echo 'int i;' > conftest.$ac_ext |
663 |
ac_cv_elf_objects=no |
664 |
if AC_TRY_EVAL(ac_compile); then |
665 |
case `/usr/bin/file conftest.$ac_objext` in |
666 |
*"ELF"*) |
667 |
ac_cv_elf_objects=yes |
668 |
;; |
669 |
esac |
670 |
fi |
671 |
rm -rf conftest* |
672 |
]) |
673 |
ELF_OBJECTS=$ac_cv_elf_objects |
674 |
|
675 |
dnl CPU emulator sources |
676 |
if [[ "x$EMULATED_PPC" = "xyes" ]]; then |
677 |
CPUSRCS="\ |
678 |
../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \ |
679 |
../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \ |
680 |
../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \ |
681 |
../kpx_cpu/src/cpu/ppc/ppc-translate.cpp" |
682 |
CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src" |
683 |
|
684 |
dnl Enable JIT compiler, if possible |
685 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
686 |
AC_CACHE_CHECK([whether dyngen can be used], |
687 |
ac_cv_use_dyngen, [ |
688 |
case $host_cpu:$ELF_OBJECTS in |
689 |
powerpc:yes) |
690 |
ac_cv_use_dyngen=yes |
691 |
;; |
692 |
x86_64:yes) |
693 |
ac_cv_use_dyngen=yes |
694 |
;; |
695 |
i?86:yes) |
696 |
ac_cv_use_dyngen=yes |
697 |
;; |
698 |
*:*) |
699 |
ac_cv_use_dyngen=no |
700 |
;; |
701 |
esac |
702 |
dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2) |
703 |
if [[ -z "$DYNGEN_CC" ]]; then |
704 |
if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then |
705 |
DYNGEN_CC=$CXX |
706 |
else |
707 |
for p in /usr/bin /usr/local/bin; do |
708 |
gxx="$p/g++" |
709 |
if [[ -x "$gxx" ]]; then |
710 |
DYNGEN_CC="$gxx" |
711 |
fi |
712 |
done |
713 |
fi |
714 |
fi |
715 |
if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then |
716 |
ac_cv_use_dyngen=no |
717 |
fi |
718 |
]) |
719 |
if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then |
720 |
case $host_cpu in |
721 |
i?86) |
722 |
DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2" |
723 |
if [[ "x$HAVE_GCC30" = "xyes" ]]; then |
724 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0" |
725 |
else |
726 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" |
727 |
fi |
728 |
saved_CPPFLAGS=$CPPFLAGS |
729 |
CPPFLAGS="$CPPFLAGS -mmmx" |
730 |
AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"]) |
731 |
CPPFLAGS="$CPPFLAGS -msse" |
732 |
AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"]) |
733 |
CPPFLAGS="$CPPFLAGS -msse2" |
734 |
AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"]) |
735 |
CPPFLAGS=$saved_CPPFLAGS |
736 |
;; |
737 |
x86_64) |
738 |
AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h) |
739 |
;; |
740 |
esac |
741 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000" |
742 |
if [[ "x$HAVE_GCC30" = "xyes" ]]; then |
743 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" |
744 |
fi |
745 |
else |
746 |
WANT_JIT=no |
747 |
fi |
748 |
AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine]) |
749 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
750 |
DYNGENSRCS="\ |
751 |
../kpx_cpu/src/cpu/jit/dyngen.c \ |
752 |
../kpx_cpu/src/cpu/jit/cxxdemangle.cpp" |
753 |
CPUSRCS="\ |
754 |
../kpx_cpu/src/cpu/jit/jit-cache.cpp \ |
755 |
../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \ |
756 |
../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS" |
757 |
fi |
758 |
fi |
759 |
CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp" |
760 |
else |
761 |
WANT_JIT=no |
762 |
fi |
763 |
if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then |
764 |
AC_CACHE_CHECK([whether static data regions are executable], |
765 |
ac_cv_have_static_data_exec, [ |
766 |
AC_TRY_RUN([int main(void) { |
767 |
#if defined(__powerpc__) |
768 |
static unsigned int p[8] = {0x4e800020,}; |
769 |
asm volatile("dcbst 0,%0" : : "r" (p) : "memory"); |
770 |
asm volatile("sync" : : : "memory"); |
771 |
asm volatile("icbi 0,%0" : : "r" (p) : "memory"); |
772 |
asm volatile("sync" : : : "memory"); |
773 |
asm volatile("isync" : : : "memory"); |
774 |
((void (*)(void))p)(); |
775 |
return 0; |
776 |
#endif |
777 |
return 1; |
778 |
}], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no, |
779 |
dnl When cross-compiling, do not assume anything. |
780 |
ac_cv_have_static_data_exec=no |
781 |
) |
782 |
]) |
783 |
fi |
784 |
AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec", |
785 |
[Define if your system marks static data pages as executable.]) |
786 |
|
787 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
788 |
CPPFLAGS="$CPPFLAGS -DUSE_JIT" |
789 |
fi |
790 |
|
791 |
dnl Generate Makefile. |
792 |
AC_SUBST(DYNGENSRCS) |
793 |
AC_SUBST(DYNGEN_CC) |
794 |
AC_SUBST(DYNGEN_OP_FLAGS) |
795 |
AC_SUBST(SYSSRCS) |
796 |
AC_SUBST(CPUSRCS) |
797 |
AC_SUBST(BLESS) |
798 |
AC_OUTPUT(Makefile) |
799 |
|
800 |
dnl Print summary. |
801 |
echo |
802 |
echo SheepShaver configuration summary: |
803 |
echo |
804 |
echo XFree86 DGA support .............. : $WANT_XF86_DGA |
805 |
echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE |
806 |
echo Using PowerPC emulator ........... : $EMULATED_PPC |
807 |
echo Enable JIT compiler .............. : $WANT_JIT |
808 |
echo Enable video on SEGV signals ..... : $WANT_VOSF |
809 |
echo ESD sound support ................ : $WANT_ESD |
810 |
echo GTK user interface ............... : $WANT_GTK |
811 |
echo mon debugger support ............. : $WANT_MON |
812 |
echo Bad memory access recovery type .. : $sigsegv_recovery |
813 |
echo |
814 |
echo "Configuration done. Now type \"make\"." |