ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.6
Committed: 2002-10-29T14:26:26Z (21 years, 7 months ago) by nigel
Branch: MAIN
Changes since 1.5: +31 -30 lines
Log Message:
Correct path for some Unix files

File Contents

# User Rev Content
1 nigel 1.1 dnl Process this file with autoconf to produce a configure script.
2     dnl Based on Unix/configure.in
3     dnl Written in 1999 by Christian Bauer et al.
4    
5     AC_INIT(main_macosx.mm)
6     AC_PREREQ(2.12)
7     AC_CONFIG_HEADER(config.h)
8    
9 nigel 1.5 dnl Video options.
10 nigel 1.1 AC_ARG_ENABLE(multiwin,
11     [ --enable-multiwin allow multiple emulator windows [default=no]], [WANT_MWIN=$enableval], [WANT_MWIN=no])
12    
13 nigel 1.5 dnl JIT compiler options.
14     AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
15     AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
16    
17 nigel 1.1 dnl FPU emulation core.
18     AC_ARG_ENABLE(fpe,
19 nigel 1.5 [ --enable-fpe=FPE specify which fpu emulator to use [default=auto]],
20 nigel 1.1 [ case "$enableval" in
21 nigel 1.5 dnl default is always ieee, if architecture has this fp format
22     auto) FPE_CORE_TEST_ORDER="ieee uae";;
23     ieee) FPE_CORE_TEST_ORDER="ieee";;
24     uae) FPE_CORE_TEST_ORDER="uae";;
25     x86) FPE_CORE_TEST_ORDER="x86";;
26     *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: auto, x86, ieee, uae]);;
27 nigel 1.1 esac
28     ],
29 nigel 1.5 [ FPE_CORE_TEST_ORDER="ieee uae"
30 nigel 1.1 ])
31    
32     dnl Addressing modes.
33     AC_ARG_ENABLE(addressing,
34     [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
35     [ case "$enableval" in
36     real) ADDRESSING_TEST_ORDER="real";;
37     direct) ADDRESSING_TEST_ORDER="direct";;
38     banks) ADDRESSING_TEST_ORDER="banks";;
39     fastest)ADDRESSING_TEST_ORDER="direct banks";;
40     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
41     esac
42     ],
43     [ ADDRESSING_TEST_ORDER="direct banks"
44     ])
45    
46     dnl External packages.
47     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
48    
49     dnl Canonical system information.
50     AC_CANONICAL_HOST
51     AC_CANONICAL_TARGET
52    
53     dnl Target OS type
54     OS_TYPE=darwin
55     DEFINES="$DEFINES -DOS_$OS_TYPE"
56    
57     dnl Target CPU type.
58     HAVE_I386=no
59     HAVE_M68K=no
60     HAVE_SPARC=no
61     HAVE_POWERPC=no
62     case "$target_cpu" in
63     i386* | i486* | i586* | i686* | i786* ) CPU_TYPE=i386 HAVE_I386=yes;;
64     m68k* ) CPU_TYPE=m68k HAVE_M68K=yes;;
65     sparc* ) CPU_TYPE=sparc HAVE_SPARC=yes;;
66     powerpc* ) CPU_TYPE=powerpc HAVE_POWERPC=yes;;
67     *) CPU_TYPE=`echo $target_cpu | sed -e 's/-/_/g'`;;
68     esac
69     DEFINES="$DEFINES -DCPU_$CPU_TYPE"
70    
71     dnl Checks for programs.
72     AC_PROG_CC
73     AC_PROG_CC_C_O
74     AC_PROG_CPP
75     AC_PROG_CXX
76     AC_PROG_MAKE_SET
77     AC_PROG_INSTALL
78    
79     dnl We use mon if possible.
80     MONSRCS=
81     if [[ "x$WANT_MON" = "xyes" ]]; then
82     AC_MSG_CHECKING(for mon)
83     mon_srcdir=../../../mon/src
84     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
85     AC_MSG_RESULT(yes)
86 nigel 1.5 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
87     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/mon_lowmem.cpp $mon_srcdir/disass/floatformat.c $mon_srcdir/disass/i386-dis.c $mon_srcdir/disass/m68k-dis.c $mon_srcdir/disass/m68k-opc.c"
88 nigel 1.1 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
89 nigel 1.5 AC_CHECK_LIB(termcap, tputs)
90 nigel 1.1 AC_CHECK_LIB(readline, readline)
91     AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
92     else
93     AC_MSG_RESULT(no)
94     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
95     WANT_MON=no
96     fi
97     fi
98    
99     dnl We want pthreads.
100     HAVE_PTHREADS=yes
101     AC_CHECK_FUNCS(pthread_cancel)
102 nigel 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
103     AC_CHECK_FUNCS(pthread_mutexattr_settype)
104 nigel 1.5 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
105 nigel 1.1
106     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
107     SEMSRC=
108     AC_CHECK_FUNCS(sem_init, , [
109     if test "x$HAVE_PTHREADS" = "xyes"; then
110     SEMSRC=posix_sem.cpp
111     fi
112     ])
113    
114 nigel 1.5 dnl We want to enable multiple window support if possible
115 nigel 1.1 if [[ "x$WANT_MWIN" = "xyes" ]]; then
116     WANT_MWIN=yes
117     DEFINES="$DEFINES -DENABLE_MULTIPLE"
118     fi
119    
120 nigel 1.5 dnl We use 64-bit file size support if possible.
121     AC_SYS_LARGEFILE
122    
123 nigel 1.1 dnl Checks for header files.
124     AC_HEADER_STDC
125     AC_CHECK_HEADERS(unistd.h fcntl.h sys/time.h sys/mman.h)
126    
127     dnl Checks for typedefs, structures, and compiler characteristics.
128     AC_C_BIGENDIAN
129     AC_C_CONST
130     AC_C_INLINE
131     AC_CHECK_SIZEOF(short, 2)
132     AC_CHECK_SIZEOF(int, 4)
133     AC_CHECK_SIZEOF(long, 4)
134     AC_CHECK_SIZEOF(long long, 8)
135 nigel 1.5 AC_CHECK_SIZEOF(float, 4)
136     AC_CHECK_SIZEOF(double, 8)
137     AC_CHECK_SIZEOF(long double, 12)
138 nigel 1.1 AC_CHECK_SIZEOF(void *, 4)
139     AC_TYPE_OFF_T
140     AC_CHECK_TYPE(loff_t, off_t)
141 nigel 1.4 AC_CHECK_TYPE(caddr_t, [char *])
142 nigel 1.1 AC_TYPE_SIZE_T
143     AC_TYPE_SIGNAL
144     AC_HEADER_TIME
145     AC_STRUCT_TM
146    
147 nigel 1.5 dnl AC_CHECK_TYPE(socklen_t)
148     dnl Check whether sys/socket.h defines type socklen_t.
149     dnl (extracted from ac-archive/Miscellaneous)
150     AC_CACHE_CHECK([for socklen_t],
151     ac_cv_type_socklen_t, [
152     AC_TRY_COMPILE([
153     #include <sys/types.h>
154     #include <sys/socket.h>
155     ], [socklen_t len = 42; return 0;],
156     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
157     dnl When cross-compiling, do not assume anything.
158     ac_cv_type_socklen_t="guessing no"
159     )
160     ])
161     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
162     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
163     fi
164    
165    
166 nigel 1.1 dnl Checks for library functions.
167     AC_CHECK_FUNCS(strdup cfmakeraw)
168     AC_CHECK_FUNCS(clock_gettime timer_create)
169     AC_CHECK_FUNCS(sigaction signal)
170     AC_CHECK_FUNCS(mmap mprotect munmap)
171     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
172    
173     dnl Darwin seems to define mach_task_self() instead of task_self().
174     AC_CHECK_FUNCS(mach_task_self task_self)
175    
176     dnl Select system-dependant source files.
177     DEFINES="$DEFINES -DBSD_COMP"
178     dnl Check for the CAM library
179 nigel 1.5 AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
180 nigel 1.1 if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
181     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
182 nigel 1.5 else
183     dnl Check for the sys kernel includes
184 nigel 1.1 AC_CHECK_HEADER(camlib.h)
185     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
186     dnl In this case I should fix this thing including a "patch"
187     dnl to access directly to the functions in the kernel :) --Orlando
188     AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
189     else
190     SCSISRC=FreeBSD/scsi_freebsd.cpp
191     LIBS="$LIBS -lcam"
192     DEFINES="$DEFINES -DCAM"
193     fi
194     fi
195    
196     dnl Use 68k CPU natively?
197     WANT_NATIVE_M68K=no
198    
199 nigel 1.5 SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
200 nigel 1.1
201     dnl Define a macro that translates a yesno-variable into a C macro definition
202     dnl to be put into the config.h file
203     dnl $1 -- the macro to define
204     dnl $2 -- the value to translate
205 nigel 1.5 dnl $3 -- template name
206 nigel 1.1 AC_DEFUN(AC_TRANSLATE_DEFINE, [
207     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
208 nigel 1.5 AC_DEFINE($1, 1, $3)
209 nigel 1.1 fi
210     ])
211    
212     dnl Various checks if the system supports vm_allocate() and the like functions.
213     have_mach_vm=no
214     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
215     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
216     have_mach_vm=yes
217     fi
218 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
219     [Define if your system has a working vm_allocate()-based memory allocator.])
220 nigel 1.1
221     dnl Check that vm_allocate(), vm_protect() work
222     if [[ "x$have_mach_vm" = "xyes" ]]; then
223    
224 nigel 1.5 AC_CACHE_CHECK([whether vm_protect works],
225 nigel 1.1 ac_cv_vm_protect_works, [
226     AC_LANG_SAVE
227     AC_LANG_CPLUSPLUS
228     ac_cv_vm_protect_works=yes
229     dnl First the tests that should segfault
230     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
231     AC_TRY_RUN([
232     #define CONFIGURE_TEST_VM_MAP
233     #define TEST_VM_PROT_$test_def
234 nigel 1.6 #include "../Unix/vm_alloc.cpp"
235 nigel 1.1 ], ac_cv_vm_protect_works=no, rm -f core,
236     dnl When cross-compiling, do not assume anything
237     ac_cv_vm_protect_works="guessing no"
238     )
239     done
240     AC_TRY_RUN([
241     #define CONFIGURE_TEST_VM_MAP
242     #define TEST_VM_PROT_RDWR_WRITE
243 nigel 1.6 #include "../Unix/vm_alloc.cpp"
244 nigel 1.1 ], , ac_cv_vm_protect_works=no,
245     dnl When cross-compiling, do not assume anything
246     ac_cv_vm_protect_works="guessing no"
247     )
248     AC_LANG_RESTORE
249     ]
250     )
251    
252     dnl Remove support for vm_allocate() if vm_protect() does not work
253     if [[ "x$have_mach_vm" = "xyes" ]]; then
254     case $ac_cv_vm_protect_works in
255     *yes) have_mach_vm=yes;;
256     *no) have_mach_vm=no;;
257     esac
258     fi
259 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
260     [Define if your system has a working vm_allocate()-based memory allocator.])
261 nigel 1.1
262     fi dnl HAVE_MACH_VM
263    
264     dnl Various checks if the system supports mmap() and the like functions.
265     dnl ... and Mach memory allocators are not supported
266     have_mmap_vm=no
267     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
268     "x$ac_cv_func_mprotect" = "xyes" ]]; then
269     if [[ "x$have_mach_vm" = "xno" ]]; then
270     have_mmap_vm=yes
271     fi
272     fi
273 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
274     [Define if your system has a working mmap()-based memory allocator.])
275 nigel 1.1
276     dnl Check that mmap() and associated functions work.
277     if [[ "x$have_mmap_vm" = "xyes" ]]; then
278    
279     dnl Check if we have a working anonymous mmap()
280 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
281 nigel 1.1 ac_cv_mmap_anon, [
282     AC_LANG_SAVE
283     AC_LANG_CPLUSPLUS
284     AC_TRY_RUN([
285     #define HAVE_MMAP_ANON
286     #define CONFIGURE_TEST_VM_MAP
287     #define TEST_VM_MMAP_ANON
288 nigel 1.6 #include "../Unix/vm_alloc.cpp"
289 nigel 1.1 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
290     dnl When cross-compiling, do not assume anything.
291     ac_cv_mmap_anon="guessing no"
292     )
293     AC_LANG_RESTORE
294     ]
295     )
296 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
297     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
298 nigel 1.1
299 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
300 nigel 1.1 ac_cv_mmap_anonymous, [
301     AC_LANG_SAVE
302     AC_LANG_CPLUSPLUS
303     AC_TRY_RUN([
304     #define HAVE_MMAP_ANONYMOUS
305     #define CONFIGURE_TEST_VM_MAP
306     #define TEST_VM_MMAP_ANON
307 nigel 1.6 #include "../Unix/vm_alloc.cpp"
308 nigel 1.1 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
309     dnl When cross-compiling, do not assume anything.
310     ac_cv_mmap_anonymous="guessing no"
311     )
312     AC_LANG_RESTORE
313     ]
314     )
315 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
316     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
317 nigel 1.1
318 nigel 1.5 AC_CACHE_CHECK([whether mprotect works],
319 nigel 1.1 ac_cv_mprotect_works, [
320     AC_LANG_SAVE
321     AC_LANG_CPLUSPLUS
322     ac_cv_mprotect_works=yes
323     dnl First the tests that should segfault
324     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
325     AC_TRY_RUN([
326     #define CONFIGURE_TEST_VM_MAP
327     #define TEST_VM_PROT_$test_def
328 nigel 1.6 #include "../Unix/vm_alloc.cpp"
329 nigel 1.1 ], ac_cv_mprotect_works=no, rm -f core,
330     dnl When cross-compiling, do not assume anything
331     ac_cv_mprotect_works="guessing no"
332     )
333     done
334     AC_TRY_RUN([
335     #define CONFIGURE_TEST_VM_MAP
336     #define TEST_VM_PROT_RDWR_WRITE
337 nigel 1.6 #include "../Unix/vm_alloc.cpp"
338 nigel 1.1 ], , ac_cv_mprotect_works=no,
339     dnl When cross-compiling, do not assume anything
340     ac_cv_mprotect_works="guessing no"
341     )
342     AC_LANG_RESTORE
343     ]
344     )
345    
346     dnl Remove support for mmap() if mprotect() does not work
347     if [[ "x$have_mmap_vm" = "xyes" ]]; then
348     case $ac_cv_mprotect_works in
349     *yes) have_mmap_vm=yes;;
350     *no) have_mmap_vm=no;;
351     esac
352     fi
353 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
354     [Define if your system has a working mmap()-based memory allocator.])
355 nigel 1.1
356     fi dnl HAVE_MMAP_VM
357    
358     dnl Check if we can mmap 0x2000 bytes from 0x0000
359 nigel 1.5 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
360 nigel 1.1 ac_cv_can_map_lm, [
361     AC_LANG_SAVE
362     AC_LANG_CPLUSPLUS
363     AC_TRY_RUN([
364 nigel 1.6 #include "../Unix/vm_alloc.cpp"
365 nigel 1.1 int main(void) { /* returns 0 if we could map the lowmem globals */
366     volatile char * lm;
367     if (vm_init() < 0) exit(1);
368     if ((lm = (volatile char *)vm_acquire_fixed(0, 0x2000)) == VM_MAP_FAILED) exit(1);
369     lm[0] = 'z';
370     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
371     vm_exit(); exit(0);
372     }
373     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
374     dnl When cross-compiling, do not assume anything.
375     ac_cv_can_map_lm="guessing no"
376     )
377     AC_LANG_RESTORE
378     ]
379     )
380    
381     dnl Check signal handlers need to be reinstalled
382 nigel 1.5 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
383 nigel 1.1 ac_cv_signal_need_reinstall, [
384     AC_LANG_SAVE
385     AC_LANG_CPLUSPLUS
386     AC_TRY_RUN([
387     #include <stdlib.h>
388     #ifdef HAVE_UNISTD_H
389     #include <unistd.h>
390     #endif
391     #include <signal.h>
392     static int handled_signal = 0;
393     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
394     int main(void) { /* returns 0 if signals need not to be reinstalled */
395     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
396     exit(handled_signal == 2);
397     }
398     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
399     dnl When cross-compiling, do not assume anything.
400     ac_cv_signal_need_reinstall="guessing yes"
401     )
402     AC_LANG_RESTORE
403     ]
404     )
405 nigel 1.5 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
406     [Define if your system requires signals to be reinstalled.])
407 nigel 1.1
408     dnl Check if sigaction handlers need to be reinstalled
409 nigel 1.5 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
410 nigel 1.1 ac_cv_sigaction_need_reinstall, [
411     AC_LANG_SAVE
412     AC_LANG_CPLUSPLUS
413     AC_TRY_RUN([
414     #include <stdlib.h>
415     #ifdef HAVE_UNISTD_H
416     #include <unistd.h>
417     #endif
418     #include <signal.h>
419     static int handled_signal = 0;
420     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
421     typedef RETSIGTYPE (*signal_handler)(int);
422     static signal_handler mysignal(int sig, signal_handler handler) {
423     struct sigaction old_sa;
424     struct sigaction new_sa;
425     new_sa.sa_handler = handler;
426     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
427     }
428     int main(void) { /* returns 0 if signals need not to be reinstalled */
429     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
430     exit(handled_signal == 2);
431     }
432     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
433     dnl When cross-compiling, do not assume anything.
434     ac_cv_sigaction_need_reinstall="guessing yes"
435     )
436     AC_LANG_RESTORE
437     ]
438     )
439 nigel 1.5 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
440     [Define if your system requires sigactions to be reinstalled.])
441 nigel 1.1
442     dnl Check if extended signals are supported.
443 nigel 1.5 AC_CACHE_CHECK([whether your system supports extended signal handlers],
444 nigel 1.1 ac_cv_have_extended_signals, [
445     AC_LANG_SAVE
446     AC_LANG_CPLUSPLUS
447     AC_TRY_RUN([
448     #define HAVE_SIGINFO_T 1
449     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
450 nigel 1.6 #include "../Unix/vm_alloc.cpp"
451     #include "../Unix/sigsegv.cpp"
452 nigel 1.1 ], ac_cv_have_extended_signals=yes, ac_cv_have_extended_signals=no,
453     dnl When cross-compiling, do not assume anything.
454     ac_cv_have_extended_signals=no
455     )
456     AC_LANG_RESTORE
457     ]
458     )
459 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
460     [Define if your system support extended signals.])
461    
462 nigel 1.6 dnl This program never returns (exits) on OS X
463 nigel 1.1 dnl Otherwise, check for subterfuges.
464 nigel 1.6 dnl if [[ "x$ac_cv_have_extended_signals" = "xno" ]]; then
465     dnl AC_CACHE_CHECK([whether we then have a subterfuge for your system],
466     dnl ac_cv_have_sigcontext_hack, [
467     dnl AC_LANG_SAVE
468     dnl AC_LANG_CPLUSPLUS
469     dnl AC_TRY_RUN([
470     dnl #define HAVE_SIGCONTEXT_SUBTERFUGE 1
471     dnl #define CONFIGURE_TEST_SIGSEGV_RECOVERY
472     dnl #include "../Unix/vm_alloc.cpp"
473     dnl #include "../Unix/sigsegv.cpp"
474     dnl ], ac_cv_have_sigcontext_hack=yes, ac_cv_have_sigcontext_hack=no,
475     dnl dnl When cross-compiling, do not assume anything.
476     dnl ac_cv_have_sigcontext_hack=no
477     dnl )
478     dnl AC_LANG_RESTORE
479     dnl ])
480     dnl AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
481     dnl [Define if we know a hack to replace siginfo_t->si_addr member.])
482     dnl fi
483 nigel 1.1
484 nigel 1.5 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
485     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
486     ac_cv_have_skip_instruction, [
487     AC_LANG_SAVE
488     AC_LANG_CPLUSPLUS
489     AC_TRY_RUN([
490     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
491     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
492 nigel 1.6 #include "../Unix/vm_alloc.cpp"
493     #include "../Unix/sigsegv.cpp"
494 nigel 1.5 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
495     dnl When cross-compiling, do not assume anything.
496     ac_cv_have_skip_instruction=no
497     )
498     AC_LANG_RESTORE
499     ]
500     )
501     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
502     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
503    
504 nigel 1.1 dnl Can we do Video on SEGV Signals ?
505     CAN_VOSF=no
506     if [[ "$ac_cv_have_extended_signals" = "yes" -o "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
507     CAN_VOSF=yes
508     fi
509    
510     dnl Determine the addressing mode to use
511     if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
512     ADDRESSING_MODE="real"
513     else
514     ADDRESSING_MODE=""
515     AC_MSG_CHECKING([for the addressing mode to use])
516     for am in $ADDRESSING_TEST_ORDER; do
517     case $am in
518     real)
519     dnl Requires ability to mmap() Low Memory globals
520     if [[ "x$ac_cv_can_map_lm" = "xno" ]]; then
521     continue
522     fi
523     dnl Requires VOSF screen updates
524     if [[ "x$CAN_VOSF" = "xno" ]]; then
525     continue
526     fi
527     dnl Real addressing will probably work.
528     ADDRESSING_MODE="real"
529     WANT_VOSF=yes dnl we can use VOSF and we need it actually
530     DEFINES="$DEFINES -DREAL_ADDRESSING"
531     break
532     ;;
533     direct)
534     dnl Requires VOSF screen updates
535     if [[ "x$CAN_VOSF" = "xyes" ]]; then
536     ADDRESSING_MODE="direct"
537     WANT_VOSF=yes dnl we can use VOSF and we need it actually
538     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
539     break
540     fi
541     ;;
542     banks)
543     dnl Default addressing mode
544     ADDRESSING_MODE="memory banks"
545     break
546     ;;
547     *)
548     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
549     esac
550     done
551     AC_MSG_RESULT($ADDRESSING_MODE)
552     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
553     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
554     ADDRESSING_MODE="memory banks"
555     fi
556     fi
557    
558 nigel 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
559     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
560     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
561     fi
562    
563 nigel 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
564     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
565 nigel 1.5 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
566 nigel 1.1 else
567     WANT_VOSF=no
568     fi
569    
570     dnl Check for GAS.
571     HAVE_GAS=no
572     AC_MSG_CHECKING(for GAS .p2align feature)
573     cat >conftest.S << EOF
574     .text
575     .p2align 5
576     EOF
577     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
578     AC_MSG_RESULT($HAVE_GAS)
579    
580     dnl Check for GCC 2.7 or higher.
581     HAVE_GCC27=no
582     AC_MSG_CHECKING(for GCC 2.7 or higher)
583     AC_EGREP_CPP(yes,
584     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
585     yes
586     #endif
587     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
588    
589     dnl Check for GCC 3.0 or higher.
590     HAVE_GCC30=no
591     AC_MSG_CHECKING(for GCC 3.0 or higher)
592     AC_EGREP_CPP(yes,
593     [#if __GNUC__ >= 3
594     yes
595     #endif
596     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
597    
598     dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
599 nigel 1.3 dnl Also set "-fno-exceptions" for C++ because exception handling requires
600     dnl the frame pointer.
601 nigel 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
602     CFLAGS="$CFLAGS -fomit-frame-pointer"
603 nigel 1.3 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
604 nigel 1.1 fi
605    
606     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
607     dnl As of 2001/08/02, this affects the following compilers:
608     dnl Official: probably gcc-3.1 (mainline CVS)
609     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
610     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
611     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
612     SAVED_CXXFLAGS="$CXXFLAGS"
613     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
614     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
615     AC_LANG_SAVE
616     AC_LANG_CPLUSPLUS
617     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
618     AC_LANG_RESTORE
619     ])
620     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
621     CXXFLAGS="$SAVED_CXXFLAGS"
622     fi
623     fi
624    
625     dnl Select appropriate CPU source and REGPARAM define.
626     ASM_OPTIMIZATIONS=none
627     CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
628 nigel 1.5
629     dnl (gb) JITSRCS will be emptied later if the JIT is not available
630     dnl Other platforms should define their own set of noflags file variants
631     CAN_JIT=no
632     JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
633    
634 nigel 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" -a "x$OS_TYPE" != "xfreebsd" ]]; then
635     dnl i386 CPU
636 nigel 1.5 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
637 nigel 1.1 if [[ "x$HAVE_GAS" = "xyes" ]]; then
638     ASM_OPTIMIZATIONS=i386
639 nigel 1.5 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
640 nigel 1.1 CPUSRCS="cpufast1.s cpufast2.s cpufast3.s cpufast4.s cpufast5.s cpufast6.s cpufast7.s cpufast8.s"
641 nigel 1.5 JITSRCS="cpufast1_nf.s cpufast2_nf.s cpufast3_nf.s cpufast4_nf.s cpufast5_nf.s cpufast6_nf.s cpufast7_nf.s cpufast8_nf.s $JITSRCS"
642 nigel 1.1 fi
643 nigel 1.5 CAN_JIT=yes
644 nigel 1.1 elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
645     dnl SPARC CPU
646     case "$target_os" in
647     solaris*)
648     AC_MSG_CHECKING(SPARC CPU architecture)
649     SPARC_TYPE=`Solaris/which_sparc`
650     AC_MSG_RESULT($SPARC_TYPE)
651     case "$SPARC_TYPE" in
652     SPARC_V8)
653     ASM_OPTIMIZATIONS="SPARC V8 architecture"
654     DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
655     CFLAGS="$CFLAGS -Wa,-Av8"
656     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
657     ;;
658     SPARC_V9)
659     ASM_OPTIMIZATIONS="SPARC V9 architecture"
660     DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
661     CFLAGS="$CFLAGS -Wa,-Av9"
662     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
663     ;;
664     esac
665     ;;
666     esac
667     elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
668     dnl Native m68k, no emulation
669     CPUINCLUDES="-I../native_cpu"
670     CPUSRCS="asm_support.s"
671     fi
672    
673 nigel 1.5 dnl Enable JIT compiler, if possible.
674     if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
675     JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
676     DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
677    
678     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
679     if [[ "x$WANT_MON" = "xyes" ]]; then
680     DEFINES="$DEFINES -DJIT_DEBUG=1"
681     else
682     AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
683     WANT_JIT_DEBUG=no
684     fi
685     fi
686    
687     dnl IEEE core is the only FPU emulator to use with the JIT compiler
688     case $FPE_CORE_TEST_ORDER in
689     ieee*) ;;
690     *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
691     esac
692     FPE_CORE_TEST_ORDER="ieee"
693     else
694     WANT_JIT=no
695     WANT_JIT_DEBUG=no
696     JITSRCS=""
697     fi
698    
699     dnl Utility macro used by next two tests.
700     dnl AC_EXAMINE_OBJECT(C source code,
701     dnl commands examining object file,
702     dnl [commands to run if compile failed]):
703     dnl
704     dnl Compile the source code to an object file; then convert it into a
705     dnl printable representation. All unprintable characters and
706     dnl asterisks (*) are replaced by dots (.). All white space is
707     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
708     dnl output, but runs of newlines are compressed to a single newline.
709     dnl Finally, line breaks are forcibly inserted so that no line is
710     dnl longer than 80 columns and the file ends with a newline. The
711     dnl result of all this processing is in the file conftest.dmp, which
712     dnl may be examined by the commands in the second argument.
713     dnl
714     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
715     [AC_LANG_SAVE
716     AC_LANG_C
717     dnl Next bit cribbed from AC_TRY_COMPILE.
718     cat > conftest.$ac_ext <<EOF
719     [#line __oline__ "configure"
720     #include "confdefs.h"
721     $1
722     ]EOF
723     if AC_TRY_EVAL(ac_compile); then
724     od -c conftest.o |
725     sed ['s/^[0-7]*[ ]*/ /
726     s/\*/./g
727     s/ \\n/*/g
728     s/ [0-9][0-9][0-9]/./g
729     s/ \\[^ ]/./g'] |
730     tr -d '
731     ' | tr -s '*' '
732     ' | fold | sed '$a\
733     ' > conftest.dmp
734     $2
735     ifelse($3, , , else
736     $3
737     )dnl
738     fi
739     rm -rf conftest*
740     AC_LANG_RESTORE])
741    
742     dnl Floating point format probe.
743     dnl The basic concept is the same as the above: grep the object
744     dnl file for an interesting string. We have to watch out for
745     dnl rounding changing the values in the object, however; this is
746     dnl handled by ignoring the least significant byte of the float.
747     dnl
748     dnl Does not know about VAX G-float or C4x idiosyncratic format.
749     dnl It does know about PDP-10 idiosyncratic format, but this is
750     dnl not presently supported by GCC. S/390 "binary floating point"
751     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
752     dnl as ASCII?)
753     dnl
754     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
755     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
756     [gcc_AC_EXAMINE_OBJECT(
757     [/* This will not work unless sizeof(double) == 8. */
758     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
759    
760     /* This structure must have no internal padding. */
761     struct possibility {
762     char prefix[8];
763     double candidate;
764     char postfix[8];
765     };
766    
767     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
768     struct possibility table [] =
769     {
770     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
771     C( 3.53802595280598432000e+18), /* D__float - VAX */
772     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
773     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
774     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
775     };],
776     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
777     ac_cv_c_float_format='IEEE (big-endian)'
778     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
779     ac_cv_c_float_format='IEEE (big-endian)'
780     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
781     ac_cv_c_float_format='IEEE (little-endian)'
782     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
783     ac_cv_c_float_format='IEEE (little-endian)'
784     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
785     ac_cv_c_float_format='VAX D-float'
786     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
787     ac_cv_c_float_format='PDP-10'
788     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
789     ac_cv_c_float_format='IBM 370 hex'
790 nigel 1.1 else
791 nigel 1.5 AC_MSG_ERROR(Unknown floating point format)
792     fi],
793     [AC_MSG_ERROR(compile failed)])
794     ])
795     # IEEE is the default format. If the float endianness isn't the same
796     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
797     # (which is a tristate: yes, no, default). This is only an issue with
798     # IEEE; the other formats are only supported by a few machines each,
799     # all with the same endianness.
800     format=IEEE_FLOAT_FORMAT
801     fbigend=
802     case $ac_cv_c_float_format in
803     'IEEE (big-endian)' )
804     if test $ac_cv_c_bigendian = no; then
805     fbigend=1
806     fi
807     ;;
808     'IEEE (little-endian)' )
809     if test $ac_cv_c_bigendian = yes; then
810     fbigend=0
811     fi
812     ;;
813     'VAX D-float' )
814     format=VAX_FLOAT_FORMAT
815     ;;
816     'PDP-10' )
817     format=PDP10_FLOAT_FORMAT
818     ;;
819     'IBM 370 hex' )
820     format=IBM_FLOAT_FORMAT
821     ;;
822     esac
823     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
824     [Define to the floating point format of the host machine.])
825     if test -n "$fbigend"; then
826     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
827     [Define to 1 if the host machine stores floating point numbers in
828     memory with the word containing the sign bit at the lowest address,
829     or to 0 if it does it the other way around.
830    
831     This macro should not be defined if the ordering is the same as for
832     multi-word integers.])
833 nigel 1.1 fi
834 nigel 1.5 ])
835 nigel 1.1
836 nigel 1.5 dnl Select appropriate FPU source.
837     gcc_AC_C_FLOAT_FORMAT
838     AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
839    
840     for fpe in $FPE_CORE_TEST_ORDER; do
841     case $fpe in
842     ieee)
843     case $ac_cv_c_float_format in
844     IEEE*)
845     FPE_CORE="IEEE fpu core"
846     DEFINES="$DEFINES -DFPU_IEEE"
847     FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
848     dnl Math functions not mandated by C99 standard
849     AC_CHECK_FUNCS(isnanl isinfl)
850     dnl Math functions required by C99 standard, but probably not
851     dnl implemented everywhere. In that case, we fall back to the
852     dnl regular variant for doubles.
853     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
854     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
855     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
856     AC_CHECK_FUNCS(floorl ceill)
857     break
858     ;;
859     esac
860     ;;
861     x86)
862     if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
863     FPE_CORE="i387 fpu core"
864     DEFINES="$DEFINES -DFPU_X86"
865     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
866     break
867     fi
868     ;;
869     uae)
870     FPE_CORE="uae fpu core"
871     DEFINES="$DEFINES -DFPU_UAE"
872     FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
873     break
874     ;;
875     *)
876     AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
877     ;;
878     esac
879     done
880     if [[ "x$FPE_CORE" = "x" ]]; then
881     AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
882 nigel 1.1 fi
883    
884     dnl Check for certain math functions
885     AC_CHECK_FUNCS(atanh)
886 nigel 1.5 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
887 nigel 1.1
888     dnl UAE CPU sources for all non-m68k-native architectures.
889     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
890     CPUINCLUDES="-I../uae_cpu"
891 nigel 1.5 CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp $FPUSRCS cpustbl.cpp cpudefs.cpp $CPUSRCS $JITSRCS"
892 nigel 1.1 fi
893    
894     dnl Remove the "-g" option if set for GCC.
895     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
896     CFLAGS=`echo $CFLAGS | sed -e 's/-g//g'`
897     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g//g'`
898     fi
899    
900     dnl Or if we have -Ofast
901     if [[ "x$HAVE_OFAST" = "xyes" ]]; then
902     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -Ofast"
903     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -Ofast"
904     CXXFLAGS="-LANG:std $CXXFLAGS"
905 nigel 1.5 LDFLAGS="$LDFLAGS -ipa"
906 nigel 1.1 fi
907    
908     dnl Generate Makefile.
909     AC_SUBST(DEFINES)
910     AC_SUBST(SYSSRCS)
911     AC_SUBST(CPUINCLUDES)
912     AC_SUBST(CPUSRCS)
913     AC_OUTPUT(Makefile)
914    
915     dnl Print summary.
916     echo
917     echo Basilisk II configuration summary:
918     echo
919 nigel 1.5 echo Multiple emulator windows .............. : $WANT_MWIN
920     echo Enable video on SEGV signals ........... : $WANT_VOSF
921     echo mon debugger support ................... : $WANT_MON
922     echo Use JIT compiler ....................... : $WANT_JIT
923     echo JIT debug mode ......................... : $WANT_JIT_DEBUG
924     echo Floating-Point emulation core .......... : $FPE_CORE
925     echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
926     echo Addressing mode ........................ : $ADDRESSING_MODE
927 nigel 1.1 echo
928 nigel 1.2 echo "Configuration done. Now type \"make\" (or \"make ide\")."
929 nigel 1.5
930