ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.in
Revision: 1.47
Committed: 2001-08-19T16:18:30Z (23 years, 3 months ago) by gbeauche
Branch: MAIN
Changes since 1.46: +1 -1 lines
Log Message:
- configure.in: actually save CXXFLAGS instead of CFLAGS in the code to
  detect whether the compiler supports -fno-merge-constants or not
- Makefile.in: make sure to link gencpu with g++ since it contains objects
  compiled from C++ code. Fix build problems with gcc 3.0.1

File Contents

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