2 dnl At long last, the configure script!
6 dnl We'll need machine type later
10 AM_INIT_AUTOMAKE(dgen-sdl, 1.23)
12 dnl Before we check for cc and c++, check for the --with-extra-opt switch, so
13 dnl we can add the optimizations.
14 AC_ARG_WITH(extra-opt,
15 [ --with-extra-opt Add extra optimizations (egcs/GCC >= 2.95 only)],
19 if test x$ADD_OPT \!= xno; then
22 CFLAGS="$CFLAGS -O3 -mpentium -march=pentium -fstrength-reduce -fomit-frame-pointer -frerun-cse-after-loop -funroll-loops -ffast-math -malign-functions=5 -malign-jumps=5 -malign-loops=5 -malign-double -fno-exceptions -fno-rtti"
23 CXXFLAGS="$CXXFLAGS -O3 -mpentium -march=pentium -fstrength-reduce -fomit-frame-pointer -frerun-cse-after-loop -funroll-loops -ffast-math -malign-functions=5 -malign-jumps=5 -malign-loops=5 -malign-double -fno-exceptions -fno-rtti"
26 CFLAGS="$CFLAGS -O3 -ffast-math -fomit-frame-pointer -fno-exceptions -fno-rtti -funroll-loops -frerun-cse-after-loop"
27 CXXFLAGS="$CXXFLAGS -O3 -ffast-math -fomit-frame-pointer -fno-exceptions -fno-rtti -funroll-loops -frerun-cse-after-loop"
32 dnl Check for standard programs
42 dnl Set the value of make, if make doesn't already
51 dnl Check for SDL libs
52 AM_PATH_SDL(1.0.0, true, AC_MSG_ERROR([*** SDL version >= 1.0.0 not found.]))
54 CFLAGS="$CFLAGS $SDL_CFLAGS"
55 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
58 dnl Add SDL cflags to CPPFLAGS, just to check for SDL_joystick header
59 OLD_CPPFLAGS=$CPPFLAGS
60 CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
64 dnl Check for SDL joystick
66 AC_CHECK_HEADER(SDL_joystick.h, JOYSTICK_SUPPORT=SDL,
67 dnl Check for Linux joystick as a backup
68 AC_CHECK_HEADER(linux/joystick.h, JOYSTICK_SUPPORT=LINUX))
70 dnl Check for X (so we can find the OpenGL headers)
72 CFLAGS="$CFLAGS $X_CFLAGS"
73 CXXFLAGS="$CXXFLAGS $X_CFLAGS"
76 dnl Check for OpenGL support in SDL
78 [ --without-opengl Don't use SDL OpenGL support],
79 OPENGL_SUPPORT=$withval, OPENGL_SUPPORT=yes)
80 if test x$OPENGL_SUPPORT \!= xno; then
81 AC_MSG_CHECKING([for OpenGL support in SDL])
82 AC_TRY_COMPILE([#include <SDL.h>], [int foo() { int x = SDL_OPENGL; }],
83 OPENGL_SUPPORT=yes, OPENGL_SUPPORT=no)
84 AC_MSG_RESULT($OPENGL_SUPPORT)
85 # Check for the GL libs
86 if test x$OPENGL_SUPPORT \!= xno; then
89 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
90 LIBS="$LIBS $SDL_LIBS"
91 AC_CHECK_LIB(GL, glBegin,
92 AC_CHECK_HEADER(GL/gl.h, , OPENGL_SUPPORT=no),
101 if test x$OPENGL_SUPPORT \!= xno; then
102 AC_DEFINE(SDL_OPENGL_SUPPORT)
103 SDL_LIBS="$SDL_LIBS -lGL"
106 CPPFLAGS=$OLD_CPPFLAGS
108 if test x$JOYSTICK_SUPPORT \!= xno; then
109 AC_DEFINE(JOYSTICK_SUPPORT)
110 AC_DEFINE_UNQUOTED(${JOYSTICK_SUPPORT}_JOYSTICK_SUPPORT)
111 EXTRAOBJS="$EXTRAOBJS md-phil.o"
115 LIBS="$LIBS $SDL_LIBS"
116 dnl Check for the SDL_WM_ToggleFullScreen function
117 AC_CHECK_FUNCS(SDL_WM_ToggleFullScreen)
120 dnl Check for an Intel chip
121 AC_MSG_CHECKING([for x86 processor])
125 dnl Check if the user explicitly asked to not use nasm
127 [ --without-nasm Don't use NASM for assembler routines],
130 if test x$USENASM \!= xno; then
132 AC_CHECK_PROG(NASM, nasm, nasm, [not found])
133 if test x$NASM \!= "xnot found"; then
134 dnl Find NASM object format
135 AC_MSG_CHECKING([for NASM object format])
136 cat >___DgSdFmTTeSt.asm <<EOF
148 for FMT in elf aout aoutb coff; do
149 $NASM -f $FMT ___DgSdFmTTeSt.asm
150 if $CC -o ___DgSdFmTTeSt ___DgSdFmTTeSt.o >&5
157 if test \! -z "$NASM_FMT"; then
158 AC_MSG_RESULT([$NASM_FMT])
161 dnl ELF doesn't use underscores, aout&coff do
162 if test x$NASM_FMT = xelf; then
164 CHOP_="sed -e '/^_/s/^_//' -e '/_/s/\([][,.+ *:-]\)_/\1/g'"
169 AM_CONDITIONAL(NO_USCORE,
170 test x$NASM_FMT = xelf)
174 [ --without-mmx Don't use MMX routines, even if supported],
177 AC_MSG_CHECKING([for MMX])
178 cat >___DgSdMmXTeSt.asm <<EOF
188 xor eax, eax ; Return value of 0
191 $NASM -f $NASM_FMT ___DgSdMmXTeSt.asm
192 $CC -o ___DgSdMmXTeSt ___DgSdMmXTeSt.o >&5
196 if test x$USEMMX \!= xno -a x$MMXE = x0; then
204 AC_MSG_RESULT([not found])
216 if test x$ASM = xfalse; then
218 *** NASM is necessary on x86 platforms for assembler optimizations.
219 *** A package most likely came with your Unix distribution, but if one didn't,
220 *** it can be found at http://www.web-sites.co.uk/nasm/ (or at
221 *** http://www.bebits.com/ for BeOS)
233 dnl We are free to use assembler! :)
235 EXTRAOBJS="$EXTRAOBJS asm_tiles.o ctv.o"
239 EXTRAOBJS="$EXTRAOBJS mmx_memcpy.o"
241 AC_DEFINE(memcpy, mmx_memcpy)
243 EXTRAOBJS="$EXTRAOBJS asm_memcpy.o"
244 AC_DEFINE(memcpy, asm_memcpy)
246 if test -f mz80/makez80.c; then
252 dnl Use ZZ80 if MZ80 isn't here
253 AC_MSG_CHECKING([whether MZ80 is available])
254 if test -z "$MZ80"; then
256 EXTRAOBJS="$EXTRAOBJS zz80.o"
261 dnl Figure out what emus we're using (StarScream, Musashi, or both)
263 [ --without-star Don't use StarScream assembler CPU core if available],
264 USESTAR=$withval, USESTAR=yes)
266 [ --without-musa Don't use Musashi C CPU core],
267 USEMUSA=$withval, USEMUSA=yes)
269 AC_MSG_CHECKING([whether StarScream is available])
270 if test x$ASM = xfalse -o \! -f star/star.c -o x$USESTAR = xno; then
272 dnl We have to use musa
273 if test x$USEMUSA = xno; then
274 AC_MSG_ERROR([*** You have disabled both CPU cores. You need at least one.])
276 CPUDIRS="$CPUDIRS musa"
277 MUSA="-Lmusa -lmusa68"
278 AC_DEFINE(COMPILE_WITH_MUSA)
281 if test x$USEMUSA \!= xno; then
282 CPUDIRS="$CPUDIRS musa"
283 MUSA="-Lmusa -lmusa68"
284 AC_DEFINE(COMPILE_WITH_MUSA)
286 CPUDIRS="$CPUDIRS star"
287 STAR="star/starcpu.o"
288 AC_DEFINE(COMPILE_WITH_STAR)