2 dnl At long last, the configure script!
7 [zamaz@users.sourceforge.net],
9 [http://sourceforge.net/projects/dgen],
12 dnl We'll need machine type later.
15 dnl Initialize Automake.
16 AM_INIT_AUTOMAKE([silent-rules])
17 AM_SILENT_RULES([yes])
20 dnl Check for standard programs.
30 dnl Set the value of make, if make doesn't already.
39 dnl Cross compilation stuff.
41 [test "x$cross_compiling" = xno],
42 [CC_FOR_BUILD="${CC}"]
43 [CXX_FOR_BUILD="${CXX}"]
44 [CPPFLAGS_FOR_BUILD="${CPPFLAGS}"]
45 [CFLAGS_FOR_BUILD="${CFLAGS}"]
46 [CXXFLAGS_FOR_BUILD="${CXXFLAGS}"]
47 [LDFLAGS_FOR_BUILD="${LDFLAGS}"]
48 [OBJEXT_FOR_BUILD="${OBJEXT}"]
49 [EXEEXT_FOR_BUILD="${EXEEXT}"]
52 [test "x$cross_compiling" = xyes],
53 [AC_MSG_CHECKING([for host C compiler])]
54 [CC_FOR_BUILD="${CC_FOR_BUILD-cc}"]
55 [AC_MSG_RESULT([$CC_FOR_BUILD])]
56 [AC_MSG_CHECKING([for host C++ compiler])]
57 [CXX_FOR_BUILD="${CXX_FOR_BUILD-c++}"]
58 [AC_MSG_RESULT([$CXX_FOR_BUILD])]
59 [AC_MSG_CHECKING([for suffix of host object files])]
62 # Sane values by default.
65 # Try to compile a program, find out default extensions.
68 cat <<EOF > conftest.c &&
69 int main(void) { return 0; }
71 $CC_FOR_BUILD -c conftest.c &&
73 for file in conftest.*
77 OBJEXT_FOR_BUILD="${file##*.}"
78 test -z "$OBJEXT_FOR_BUILD" &&
84 $CC_FOR_BUILD -o conftest$ext $file &&
87 EXEEXT_FOR_BUILD="$ext"
92 } 1>&AS_MESSAGE_LOG_FD 2>&1
95 [test "x$EXT_SUCCESS" = x1],
96 [AC_MSG_RESULT([$OBJEXT_FOR_BUILD])]
97 [AC_MSG_CHECKING([for suffix of host executables])]
99 [test "x$EXEEXT_FOR_BUILD" = x],
100 [AC_MSG_RESULT([none])],
101 [AC_MSG_RESULT([$EXEEXT_FOR_BUILD])]
103 [AC_MSG_RESULT([unable to determine])]
104 [AC_MSG_FAILURE([can't cross-compile if host objects \
105 extension isn't known])]
109 dnl Libraries used by dgen_tobin.
110 TOBIN_LIBS="${LIBS} ${TOBIN_LIBS}"
112 dnl Check for SDL libs.
113 AM_PATH_SDL([1.2.0], [], [AC_MSG_ERROR([SDL version >= 1.2.0 not found.])])
114 CFLAGS="$CFLAGS $SDL_CFLAGS"
115 CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
116 LIBS="$LIBS $SDL_LIBS"
118 dnl Check for the SDL_WM_ToggleFullScreen function.
119 AC_CHECK_FUNCS([SDL_WM_ToggleFullScreen])
121 dnl Check for ftello().
122 AC_CHECK_FUNCS([ftello])
129 [enable internal debugging [default=no]]
131 [USE_DEBUG=$enableval],
135 dnl Check for joystick support.
140 [enable joystick support [default=auto]]
142 [USE_JOYSTICK=$enableval],
146 [test "x$USE_JOYSTICK" != xno],
154 [test "x$enable_joystick" = xyes -a "x$USE_JOYSTICK" = xno],
155 [AC_MSG_FAILURE([joystick support seems unavailable])]
158 dnl Check for OpenGL support.
163 [enable OpenGL support [default=auto]]
165 [USE_OPENGL=$enableval],
169 [test "x$USE_OPENGL" != xno],
177 [test "x$cross_compiling" = xyes],
178 dnl When nothing works, use brute force.
189 [LIBS="-lopengl32 $LIBS"]
205 [test "x$enable_opengl" = xyes -a "x$USE_OPENGL" = xno],
206 [AC_MSG_FAILURE([OpenGL support seems unavailable])]
209 dnl Check for threads support.
214 [enable multi-threading support [default=auto]]
216 [USE_THREADS=$enableval],
220 [test "x$USE_THREADS" != xno],
228 [test "x$enable_threads" = xyes -a "x$USE_THREADS" = xno],
229 [AC_MSG_FAILURE([multi-threading support seems unavailable])]
232 dnl Check for libarchive. Note that older versions of libarchive don't have
233 dnl archive_read_support_format_raw().
238 [use libarchive for compressed ROMs [default=auto]]
240 [USE_LIBARCHIVE=$withval],
241 [USE_LIBARCHIVE=auto]
244 [test "x$USE_LIBARCHIVE" != xno],
249 [archive_read_support_format_raw],
250 [LIBS="-larchive $LIBS"]
251 [TOBIN_LIBS="-larchive $TOBIN_LIBS"]
252 [USE_LIBARCHIVE=yes],
259 dnl Check for glob.h.
260 AC_CHECK_HEADERS([glob.h])
262 dnl Try to add shell32.
263 AC_CHECK_LIB([shell32], [main])
265 dnl Check for ASM availability.
270 [disable all ASM-related options [default=auto]]
272 [USE_ASM=$enableval],
278 [test "x$USE_ASM" != xno],
283 [AC_PATH_PROG([NASM], [nasm])]
285 [test "x$NASM" != x],
292 [AC_MSG_NOTICE([ARM-specific ASM routines enabled])]
296 [AC_MSG_NOTICE([no ASM routines available for this target])]
297 [USE_ASM=unavailable]
302 [test "x$enable_asm" = xyes -a "x$USE_ASM" = xno],
303 [AC_MSG_FAILURE([unable to enable ASM routines])]
306 dnl Check for NASM output format.
310 [--with-nasm-format[[=format]]],
311 [use this output format for NASM (see "nasm -hf" output for]
312 [available formats) [default=auto]]
314 [NASM_FORMAT=$withval],
315 [AS_IF([test "x$NASM" != x], [NASM_FORMAT=auto], [NASM_FORMAT=])]
318 [test "x$NASM_FORMAT" = xauto],
319 [AC_MSG_CHECKING([for nasm output format])]
335 [AC_MSG_RESULT([failed])]
337 [can't determine what format NASM should use, \
338 please specify --with-nasm-format=format]
341 [AC_MSG_RESULT([$NASM_FORMAT])]
342 [AC_MSG_WARN([NASM format auto-detection is crappy at best])],
344 [test "x$NASM_FORMAT" != x],
345 [AC_MSG_NOTICE([NASM output format is $NASM_FORMAT])]
349 dnl Check for the need to prefix ASM globals with underscores.
350 dnl For ELF, also add -DNASM_STACK_NOEXEC.
352 [! test -z "$NASM_FORMAT"],
353 [AC_MSG_CHECKING([whether ASM globals require an underscore])]
358 [AC_MSG_RESULT([no])]
359 [NASM="$NASM -DNASM_STACK_NOEXEC"],
361 [AC_MSG_RESULT([yes])]
362 [NASM="$NASM --prefix _"]
366 dnl Crap TV filters support.
369 [AC_HELP_STRING([--disable-ctv], [disable Crap TV filters])],
370 [USE_CTV=$enableval],
374 dnl hqx filters support.
377 [AS_HELP_STRING([--disable-hqx], [disable hqx filters])],
378 [USE_HQX=$enableval],
382 dnl scale2x filters support.
385 [AS_HELP_STRING([--disable-scale2x], [disable scale2x filters])],
386 [USE_SCALE2X=$enableval],
390 dnl x86-specific ASM options.
393 [AC_HELP_STRING([--enable-x86-mmx], [enable MMX memcpy])],
394 dnl If --disable-asm isn't specified, MMX must be auto-detected,
395 dnl unless forced via --enable-x86-mmx.
396 [USE_X86_MMX=$enableval],
398 [test "x$USE_X86_ASM" != xno],
405 [AC_HELP_STRING([--enable-x86-ctv], [enable ASM Crap TV filters])],
406 dnl Disable this if --disable-ctv is given.
408 [test "x$USE_CTV" != xno],
409 [USE_X86_CTV=$enableval],
413 [test "x$USE_CTV" != xno],
414 [USE_X86_CTV=$USE_X86_ASM],
420 [AC_HELP_STRING([--enable-x86-tiles], [enable ASM tiles])],
421 [USE_X86_TILES=$enableval],
422 [USE_X86_TILES=$USE_X86_ASM]
426 [AC_HELP_STRING([--enable-x86-mz80], [use ASM version of MZ80])],
427 [USE_X86_MZ80=$enableval],
428 [USE_X86_MZ80=$USE_X86_ASM]
431 dnl If MMX is to be automatically enabled, make sure it is actually supported.
433 [test "x$USE_X86_MMX" = xauto],
434 [AC_MSG_CHECKING([for MMX support])]
436 [test "x$cross_compiling" = xyes],
437 USE_X86_MMX=$USE_X86_ASM
438 [AC_MSG_RESULT([$USE_X86_ASM (untested)])],
441 cat <<EOF > conftest.asm &&
447 xor eax, eax ; Return value of 0
450 $NASM -f $NASM_FORMAT -o conftest.$OBJEXT -- conftest.asm &&
451 $CC -o conftest$EXEEXT conftest.$OBJEXT &&
456 } 1>&AS_MESSAGE_LOG_FD 2>&1
458 [AC_MSG_RESULT([$USE_X86_MMX])]
463 [test "x$USE_X86_ASM" = xno && \
464 test "x$USE_X86_MMX" = xyes -o \
465 "x$USE_X86_CTV" = xyes -o \
466 "x$USE_X86_TILES" = xyes -o \
467 "x$USE_X86_MZ80" = xyes],
469 [x86 ASM support is unavailable, you can't use x86 options]
478 [include StarScream CPU core [default=auto]]
480 [WITH_STAR=$withval],
481 [WITH_STAR=$USE_X86_ASM]
484 [test "x$WITH_STAR" = xyes -a "x$USE_X86_ASM" = xno],
486 [StarScream can only be enabled on x86 targets with a \
495 [include Musashi CPU core [default=yes]]
497 [WITH_MUSA=$withval],
501 [test "x$WITH_MUSA" != xyes -a "x$WITH_STAR" != xyes],
502 [AC_MSG_WARN([neither Musashi nor StarScream are enabled])]
509 [include Cyclone 68000 CPU core [default=auto]]
511 [WITH_CYCLONE=$withval],
512 [WITH_CYCLONE=$USE_ARM_ASM]
515 [test "x$WITH_CYCLONE" = xyes -a "x$USE_ARM_ASM" = xno],
517 [Cyclone 68000 can only be enabled on ARM targets with a \
526 [include MZ80 CPU core [default=yes]]
528 [WITH_MZ80=$withval],
536 [include CZ80 CPU core [default=yes]]
538 [WITH_CZ80=$withval],
546 [include DrZ80 CPU core [default=auto]]
548 [WITH_DRZ80=$withval],
549 [WITH_DRZ80=$USE_ARM_ASM]
552 [test "x$WITH_DRZ80" = xyes -a "x$USE_ARM_ASM" = xno],
554 [DrZ80 can only be enabled on ARM targets with a \
559 dnl Check if debugger should be enabled.
564 [enable debugger [default=no]]
566 [USE_DEBUGGER=$enableval],
570 dnl Check if dZ80 is to be included.
575 [include dZ80 disassembler in debugger [default=auto]],
577 [WITH_DZ80=$withval],
578 [WITH_DZ80=$USE_DEBUGGER]
581 [test "x$WITH_DZ80" = xyes -a "x$USE_DEBUGGER" != xyes],
582 [AC_MSG_FAILURE([dZ80 is only meaningful if debugger is also enabled])]
585 dnl Check if VDP debugging should be enabled.
589 [--enable-debug-vdp],
590 [enable extra debugging for the VDP [default=auto]]
592 [USE_DEBUG_VDP=$enableval],
596 [test "x$USE_DEBUG_VDP" != xno -a "x$USE_DEBUG_VDP" != xyes],
598 [test "x$USE_DEBUG" = xyes -o "x$USE_DEBUGGER" = xyes],
604 dnl Check if Sega Pico emulation should be enabled.
609 [enable Sega Pico emulation (experimental) [default=no]]
611 [USE_PICO=$enableval],
615 dnl Check if VGM dumping functionality should be enabled.
620 [enable VGM dumping [default=no]]
622 [USE_VGMDUMP=$enableval],
626 dnl Check for Doxygen.
631 [build Doxygen documentation [default=auto]]
633 [WITH_DOXYGEN=$withval],
637 [test "x$WITH_DOXYGEN" != xno],
638 [AC_CHECK_PROGS([DOXYGEN], [doxygen])]
640 [test "x$DOXYGEN" = x],
642 [test "x$WITH_DOXYGEN" = xyes],
644 [Doxygen not found, try --without-doxygen.]
652 dnl Prevent dgen_tobin from being linked with unnecessary libraries.
656 dnl Define everything.
657 AS_IF([test "x$USE_OPENGL" = xyes], [AC_DEFINE([WITH_OPENGL])])
658 AS_IF([test "x$USE_LIBARCHIVE" = xyes], [AC_DEFINE([WITH_LIBARCHIVE])])
659 AS_IF([test "x$USE_DEBUGGER" = xyes], [AC_DEFINE([WITH_DEBUGGER])])
660 AS_IF([test "x$WITH_DZ80" = xyes], [AC_DEFINE([WITH_DZ80])])
661 AS_IF([test "x$USE_DEBUG" != xyes], [AC_DEFINE([NDEBUG])])
662 AS_IF([test "x$USE_DEBUG_VDP" = xyes], [AC_DEFINE([WITH_DEBUG_VDP])])
663 AS_IF([test "x$USE_PICO" = xyes], [AC_DEFINE([WITH_PICO])])
664 AS_IF([test "x$USE_VGMDUMP" = xyes], [AC_DEFINE([WITH_VGMDUMP])])
665 AS_IF([test "x$USE_JOYSTICK" = xyes], [AC_DEFINE([WITH_JOYSTICK])])
666 AS_IF([test "x$USE_THREADS" = xyes], [AC_DEFINE([WITH_THREADS])])
667 AS_IF([test "x$WITH_MUSA" = xyes], [AC_DEFINE([WITH_MUSA])])
668 AS_IF([test "x$WITH_STAR" = xyes], [AC_DEFINE([WITH_STAR])])
669 AS_IF([test "x$WITH_MZ80" = xyes], [AC_DEFINE([WITH_MZ80])])
670 AS_IF([test "x$WITH_CZ80" = xyes], [AC_DEFINE([WITH_CZ80])])
671 AS_IF([test "x$WITH_DRZ80" = xyes], [AC_DEFINE([WITH_DRZ80])])
672 AS_IF([test "x$WITH_CYCLONE" = xyes], [AC_DEFINE([WITH_CYCLONE])])
673 AS_IF([test "x$USE_ASM" = xyes], [AC_DEFINE([WITH_ASM])])
675 [test "x$USE_X86_ASM" = xyes],
676 [AC_DEFINE([WITH_X86_ASM])]
677 [AC_DEFINE([HAVE_MEMCPY_H])]
679 AS_IF([test "x$USE_CTV" = xyes], [AC_DEFINE([WITH_CTV])])
680 AS_IF([test "x$USE_HQX" = xyes], [AC_DEFINE([WITH_HQX])])
681 AS_IF([test "x$USE_SCALE2X" = xyes], [AC_DEFINE([WITH_SCALE2X])])
682 AS_IF([test "x$USE_X86_MZ80" = xyes], [AC_DEFINE([WITH_X86_MZ80])])
683 AS_IF([test "x$USE_X86_MMX" = xyes], [AC_DEFINE([WITH_X86_MMX])])
684 AS_IF([test "x$USE_X86_CTV" = xyes], [AC_DEFINE([WITH_X86_CTV])])
685 AS_IF([test "x$USE_X86_TILES" = xyes], [AC_DEFINE([WITH_X86_TILES])])
687 AM_CONDITIONAL([WITH_DEBUG_VDP], [test "x$USE_DEBUG_VDP" = xyes])
688 AM_CONDITIONAL([WITH_PICO], [test "x$USE_PICO" = xyes])
689 AM_CONDITIONAL([WITH_VGMDUMP], [test "x$USE_VGMDUMP" = xyes])
690 AM_CONDITIONAL([WITH_DEBUGGER], [test "x$USE_DEBUGGER" = xyes])
691 AM_CONDITIONAL([WITH_DZ80], [test "x$WITH_DZ80" = xyes])
692 AM_CONDITIONAL([WITH_CTV], [test "x$USE_CTV" = xyes])
693 AM_CONDITIONAL([WITH_HQX], [test "x$USE_HQX" = xyes])
694 AM_CONDITIONAL([WITH_SCALE2X], [test "x$USE_SCALE2X" = xyes])
695 AM_CONDITIONAL([WITH_MUSA], [test "x$WITH_MUSA" = xyes])
696 AM_CONDITIONAL([WITH_STAR], [test "x$WITH_STAR" = xyes])
697 AM_CONDITIONAL([WITH_MZ80], [test "x$WITH_MZ80" = xyes])
698 AM_CONDITIONAL([WITH_CZ80], [test "x$WITH_CZ80" = xyes])
699 AM_CONDITIONAL([WITH_DRZ80], [test "x$WITH_DRZ80" = xyes])
700 AM_CONDITIONAL([WITH_CYCLONE], [test "x$WITH_CYCLONE" = xyes])
701 AM_CONDITIONAL([WITH_X86_ASM], [test "x$USE_X86_ASM" = xyes])
702 AM_CONDITIONAL([WITH_X86_MZ80], [test "x$USE_X86_MZ80" = xyes])
703 AM_CONDITIONAL([WITH_X86_MMX], [test "x$USE_X86_MMX" = xyes])
704 AM_CONDITIONAL([WITH_X86_CTV], [test "x$USE_X86_CTV" = xyes])
705 AM_CONDITIONAL([WITH_X86_TILES], [test "x$USE_X86_TILES" = xyes])
706 AM_CONDITIONAL([WITH_DOXYGEN], [test "x$WITH_DOXYGEN" = xyes])
707 AM_COND_IF([WITH_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
709 AC_SUBST(CC_FOR_BUILD)
710 AC_SUBST(CXX_FOR_BUILD)
711 AC_SUBST(CPPFLAGS_FOR_BUILD)
712 AC_SUBST(CFLAGS_FOR_BUILD)
713 AC_SUBST(CXXFLAGS_FOR_BUILD)
714 AC_SUBST(LDFLAGS_FOR_BUILD)
715 AC_SUBST(OBJEXT_FOR_BUILD)
716 AC_SUBST(EXEEXT_FOR_BUILD)
718 AC_SUBST(NASM_FORMAT)
721 dnl The following shuts up automake when overriding *FLAGS macros.
746 Joystick: $USE_JOYSTICK
747 Multi-threading: $USE_THREADS
748 Crap TV filters: $USE_CTV
749 hqx filters: $USE_HQX
750 scale2x filters: $USE_SCALE2X
751 Compressed ROMs: $USE_LIBARCHIVE
752 Debugger: $USE_DEBUGGER
753 dZ80 disassembler: $WITH_DZ80
754 Debugging: $USE_DEBUG
755 VDP debugging: $USE_DEBUG_VDP
757 VGM dumping: $USE_VGMDUMP
760 Musashi M68K: $WITH_MUSA
761 StarScream: $WITH_STAR
762 Cyclone: $WITH_CYCLONE
767 ASM support ($USE_ASM)
770 MMX memcpy: $USE_X86_MMX
771 Crap TV filters: $USE_X86_CTV
772 Tiles: $USE_X86_TILES
774 Cyclone: $WITH_CYCLONE
777 Doxygen documentation: $WITH_DOXYGEN