ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.28
Committed: 2004-06-24T16:32:12Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.27: +9 -2 lines
Log Message:
Add --enable-sdl-static option to use static SDL libraries. Useful e.g. on
MacOS X as user might not have SDL installed and I am using self-built
libraries placed into /usr/local/lib/*. Note this can add extra dependencies
to unused libraries.

File Contents

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