1 dnl Process this file with autoconf to produce a configure script.
4 AM_INIT_AUTOMAKE(lxdream, 0.9.1)
6 AM_CONFIG_HEADER(config.h)
11 m4_include([m4/ccforbuild.m4])
20 AC_CHECK_SIZEOF([void *])
23 _AM_DEPENDENCIES([OBJC])
25 AC_PATH_PROG(POD2MAN, [pod2man])
26 AC_PATH_PROG(POD2HTML, [pod2html])
28 dnl ---------------- enable/with flags ------------------
30 AC_ARG_ENABLE( strict-warn,
31 AS_HELP_STRING( [--enable-strict-warn], [Enable strict compilation warnings]),
32 [if test "$enableval" == "yes"; then
35 AC_ARG_ENABLE( translator,
36 AS_HELP_STRING( [--disable-translator], [Disable the SH4 translator (Enabled by default)]),
37 [true], [enable_translator=yes] )
38 AC_ARG_ENABLE( optimized,
39 AS_HELP_STRING( [--disable-optimized], [Disable compile-time optimizations (Enabled by default)]),
40 [true], [enable_optimized=yes] )
41 AC_ARG_ENABLE( shared,
42 AS_HELP_STRING( [--enable-shared], [Build drivers as shared libraries (Enabled if available)]),
43 [if test "$enableval" == "yes"; then enable_shared=yes; else enable_shared=no; fi], [enable_shared=cond] )
44 AC_ARG_ENABLE( profiled,
45 AS_HELP_STRING( [--enable-profiled], [Enable profiling build]),
46 [if test "$enableval" == "yes"; then
50 AS_HELP_STRING( [--enable-trace], [Enable generation of IO traces (warning: hurts performance)]),
51 [if test "$enableval" == "yes"; then
52 AC_DEFINE(ENABLE_TRACE_IO, 1, [Enable IO tracing])
55 AS_HELP_STRING( [--enable-watch], [Enable watchpoints in the debugger (warning: hurts performance)]),
56 [if test "$enableval" == "yes"; then
57 AC_DEFINE(ENABLE_WATCH, 1, [Enable watchpoints])
59 AC_ARG_ENABLE( sh4stats,
60 AS_HELP_STRING( [--enable-sh4stats], [Enable statistics on executed sh4 instructions]),
61 [if test "$enableval" == "yes"; then
62 AC_DEFINE(ENABLE_SH4STATS, 1, [Enable SH4 statistics])
65 AS_HELP_STRING( [--with-osmesa], [Build with the osmesa GL library (software rendering)]),
68 AS_HELP_STRING( [--with-gtk], [Build with the GTK UI. Default on X11 systems]), [with_gtk=yes], [with_gtk=x11] )
70 AS_HELP_STRING( [--with-esd], [Build with support for the ESounD audio system]) )
72 AS_HELP_STRING( [--with-pulse], [Build with support for the PulseAudio audio system]) )
74 AS_HELP_STRING( [--with-sdl], [Build with support for SDL audio]) )
77 dnl ------------ Check if we're building on Darwin --------------
79 dnl For starters, do we have a working objective-c compiler?
81 AC_CHECK_HEADER([Cocoa/Cocoa.h], [
84 LIBS="$LIBS -framework AppKit -framework Carbon"
85 LIBS="$LIBS -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib -framework OpenGL"
86 LXDREAMCPPFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_4 -mdynamic-no-pic"
87 LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"
88 AC_DEFINE(HAVE_COCOA,[1],[Have Cocoa framework])
89 AC_DEFINE(APPLE_BUILD,[1],[Building on an apple platform. Things are different...])
90 if test "x$with_gtk" = "xx11"; then
93 ], [], [AC_INCLUDES_DEFAULT])
95 AC_OBJC_VERSION([ OBJCOPT="-O2"
96 OBJCFLAGS="$OBJCFLAGS -fno-strict-aliasing" ],
97 [ OBJCOPT="-O2" ], [] )
98 AC_CHECK_OBJCFLAG([-msse2])
99 AC_CHECK_OBJCFLAG([-mfpmath=sse])
102 AM_CONDITIONAL(GUI_COCOA, [test "$HAVE_COCOA" = 'yes' -a "$with_gtk" = "no"])
103 if test "x$HAVE_COCOA" = 'xyes' -a "x$with_gtk" = "xno"; then
104 AC_DEFINE(OSX_BUNDLE, [1], [Generating a bundled application])
107 dnl ------------------ C Compiler flags -----------------------
108 CFLAGS_FOR_BUILD="-O2 -std=c99"
109 CFLAGS="-g -fexceptions"
110 OBJCFLAGS="-g -fexceptions"
111 AC_DEFINE(HAVE_EXCEPTIONS, [1], [Have exception stack-frame information])
114 AC_CC_VERSION([ CCOPT="-O2"
115 CFLAGS="$CFLAGS -fno-strict-aliasing" ],
116 [ CCOPT="$CFLAGS -fast"
117 CFLAGS="$CFLAGS -fno-strict-aliasing" ],
118 [ CCOPT="$CFLAGS -O2" ])
119 AC_CHECK_CFLAG([-msse2])
120 AC_CHECK_CFLAG([-mfpmath=sse])
122 if test "x$enable_optimized" = "xyes"; then
123 CFLAGS="$CFLAGS $CCOPT"
124 OBJCFLAGS="$OBJCFLAGS $OBJCOPT"
125 if test "x$enable_profiled" != "xyes"; then
126 dnl -fomit-frame-pointer can't be used with -pg
127 CFLAGS="$CFLAGS -fomit-frame-pointer"
128 OBJCFLAGS="$OBJCFLAGS -fomit-frame-pointer"
132 OBJCFLAGS="$OBJCFLAGS -g3"
135 if test "x$enable_profiled" = "xyes"; then
137 LDFLAGS="$LDFLAGS -pg";
138 OBJCFLAGS="$OBJCFLAGS -pg";
141 if test "x$enable_strictwarn" = "xyes"; then
142 CFLAGS="$CFLAGS -Wall -Werror -Wno-unused"
143 OBJCFLAGS="$OBJCFLAGS -Wall -Werror -Wno-unused"
146 if test "x$enable_shared" != "xno"; then
147 AC_DEFINE(ENABLE_SHARED, [1], [Enable shared-library plugins])
148 if test "x$APPLE_BUILD" = "xyes"; then
150 PLUGINLDFLAGS="-dynamiclib -undefined dynamic_lookup"
153 PLUGINLDFLAGS="-shared"
157 dnl Check for dlfcn.h and dlopen() (in libdl or libc)
158 AC_CHECK_HEADER( [dlfcn.h], [
159 AC_SEARCH_LIBS( [dlopen], [dl], [have_dlopen=yes]) ])
160 if test "x$have_dlopen" != "xyes"; then
161 if test "x$enable_shared" == "xyes"; then
162 AC_MSG_ERROR( "--enable-shared not supported on your system - can't find a working dlopen" )
164 AC_MSG_WARN("Statically linking all plugins")
168 dnl Check if linker accepts -rdynamic
169 AC_MSG_CHECKING([if linker accepts -rdynamic])
170 old_LDFLAGS="$LDFLAGS"
171 LDFLAGS="$LDFLAGS -rdynamic"
172 AC_LINK_IFELSE( [AC_LANG_SOURCE([int main() { return 0; }])], [
173 LXDREAMLDFLAGS="-rdynamic"
177 AC_MSG_RESULT([no]) ])
178 LDFLAGS="$old_LDFLAGS"
181 AC_SUBST(PLUGINCFLAGS)
182 AC_SUBST(PLUGINLDFLAGS)
183 AC_SUBST(LXDREAMLDFLAGS)
185 AM_CONDITIONAL(BUILD_SHARED, [test "x$have_dlopen" = "xyes"])
188 AC_DEFINE(HAVE_FASTCALL, [1], [Use fast register-passing calling conventions])
190 AC_CHECK_FORCEINLINE()
191 AC_DEFINE_UNQUOTED(FORCEINLINE, [$FORCEINLINE], [Forcibly inline code])
192 AC_CHECK_FRAME_ADDRESS( [
193 AC_DEFINE(HAVE_FRAME_ADDRESS, [1], [Define if we have a working builtin frame_address])
194 ], [ AC_MSG_WARN([Memory exceptions will be slow]) ])
196 AC_SUBST(LXDREAMCPPFLAGS)
197 AC_SEARCH_LIBS(listen, [socket])
198 AC_SEARCH_LIBS(inet_ntoa,[nsl])
200 dnl ----------- Check for mandatory dependencies --------------
201 dnl Check for libpng (required)
202 PKG_CHECK_MODULES(LIBPNG, [libpng] )
204 dnl Implied by libpng, but check explicitly just in case
205 AC_CHECK_LIB(z, uncompress, [], [
206 echo "Zlib (libz.so) could not be found, but is required."
209 if test "x$with_gtk" = "xno"; then
210 dnl Check for GLIB only
211 PKG_CHECK_MODULES(GLIB, glib-2.0)
214 PKG_CHECK_MODULES(GTK, gtk+-2.0, [
216 AC_DEFINE([HAVE_GTK],1,[Have GTK libraries])
219 dnl Which GTK port do we have?
220 LIBS="$LIBS $GTK_LIBS"
221 AC_CHECK_FUNC(gdk_x11_display_get_xdisplay, [
223 AC_DEFINE([HAVE_GTK_X11],1,[Building with GTK+X11]) ], [])
224 dnl Add -lX11 explicitly as some pkg-configs get it wrong
225 GTK_LIBS="$GTK_LIBS -lX11"
227 AC_CHECK_FUNC(gdk_quartz_window_get_nsview, [
229 AC_DEFINE([HAVE_GTK_OSX],1,[Building with GTK+Cocoa]) ], [])
230 if test "x$HAVE_GTK_X11$HAVE_GTK_OSX" = "x"; then
231 AC_MSG_FAILURE( [Unable to identify GTK platform] )
236 PKG_CHECK_MODULES(GLIB_FOR_BUILD, glib-2.0)
239 AM_CONDITIONAL(GUI_GTK, [test "$HAVE_GTK" = 'yes'])
241 PKG_CHECK_MODULES(LIBISOFS, [libisofs-1] )
242 dnl AC_CHECK_HEADER([libisofs/libisofs.h], [
243 dnl AC_CHECK_LIB(isofs, [iso_data_source_new_from_file], [
244 dnl LIBS="$LIBS -lisofs"
245 dnl ], [ AC_MSG_FAILURE( ["Libisofs library not found, but is required"]) ])],
246 dnl [ AC_MSG_FAILURE( ["Libisofs headers not found, but is required"]) ])
248 dnl ------------------ Video driver support -------------------
249 AS_IF([test "x$with_osmesa" != xno], [
251 dnl User requested OSMesa (ie pure software rendering)
252 AC_CHECK_LIB([OSMesa], [OSMesaCreateContext], [],
253 [AC_MSG_FAILURE( [--with-osmesa was given, but OSMesa library could not be found])])
254 AC_CHECK_HEADER([GL/osmesa.h], [],
255 [AC_MSG_FAILURE( [--with-osmesa was given, but osmesa.h could not be found])])
257 VIDEO_DRIVERS="$VIDEO_DRIVERS osmesa"
258 AC_DEFINE([HAVE_OSMESA],1,[Building with the OSMesa video driver]) ], [
260 dnl Otherwise we want a real GL library (unless we're on darwin, in which case it's already
261 dnl taken care of above).
262 if test "x$APPLE_BUILD" != 'xyes'; then
263 PKG_CHECK_MODULES(LIBGL, [gl] )
264 dnl AC_CHECK_LIB(GL, glVertex3f, [], [
265 dnl AC_MSG_FAILURE( ["The OpenGL library (libGL.so) could not be found, but is required."])])
266 dnl AC_CHECK_HEADER([GL/gl.h], [], [
267 dnl AC_MSG_FAILURE( ["The OpenGL header files (eg GL/gl.h) could not be found, but are required."])])
268 LIBS="$LIBS $LIBGL_LIBS";
269 CPPFLAGS="$CPPFLAGS $LIBGL_CFLAGS";
271 AC_CHECK_FUNC(NSOpenGLGetVersion, [
273 VIDEO_DRIVERS="$VIDEO_DRIVERS nsgl"
274 AC_DEFINE([HAVE_NSGL],1, [Have NSOpenGL support]) ] )
277 dnl Now work out how to get from the UI to GL - this is usually the painful part.
278 if test "x$HAVE_GTK_X11" = "xyes"; then
279 if test "x$APPLE_BUILD" = "xyes"; then
280 LIBS="$LIBS -L/usr/X11/lib -lGL"
282 AC_CHECK_FUNC(glXQueryVersion, [
284 VIDEO_DRIVERS="$VIDEO_DRIVERS glx"
285 AC_DEFINE([HAVE_GLX], 1, [Have GLX support]) ] )
292 AM_CONDITIONAL(VIDEO_OSMESA, [test "x$HAVE_OSMESA" = "xyes"])
293 AM_CONDITIONAL(VIDEO_GLX, [test "x$HAVE_GLX" = "xyes"])
294 AM_CONDITIONAL(VIDEO_NSGL, [test "x$HAVE_NSGL" = "xyes"])
296 dnl Check for optional (but highly desireable) OpenGL features
297 AC_CHECK_FUNC(glGenFramebuffers, [ AC_DEFINE([HAVE_OPENGL_FBO],1,[Have 2.0 framebuffer_object support]) ], [])
298 AC_CHECK_FUNC(glGenFramebuffersEXT, [ AC_DEFINE([HAVE_OPENGL_FBO_EXT],1,[Have EXT_framebuffer_object support]) ], [])
299 AC_CHECK_FUNC(glCreateShader, [ AC_DEFINE([HAVE_OPENGL_SHADER],1,[Have 2.0 shader support]) ], [])
300 AC_CHECK_FUNC(glCreateShaderObjectARB, [ AC_DEFINE([HAVE_OPENGL_SHADER_ARB],1,[Have ARB shader support]) ], [])
301 AC_CHECK_FUNC(glClampColorARB, [ AC_DEFINE([HAVE_OPENGL_CLAMP_COLOR],1,[Have Color Clamp]) ], [])
302 AC_CHECK_FUNC(glClearDepthf, [ AC_DEFINE([HAVE_OPENGL_CLEAR_DEPTHF],1,[Have glClearDepthf function]) ], [])
303 AC_CHECK_FUNC(glAreTexturesResident, [ AC_DEFINE([HAVE_OPENGL_TEX_RESIDENT],1,[Have glAreTexturesResident]) ], [])
304 AC_CHECK_FUNC(glTexEnvi, [ AC_DEFINE([HAVE_OPENGL_FIXEDFUNC],1,[Have OpenGL fixed-functionality]) ], [])dnl glTexEnvi is a pretty fair proxy for this.
309 dnl ------------------- SH4 translator target -------------------
311 if test "x$enable_translator" != "xno"; then
313 i386|i486|i586|i686|x86_64)
315 AC_DEFINE_UNQUOTED(SH4_TRANSLATOR,[TARGET_X86], [SH4 Translator to use (if any)] );;
318 AM_CONDITIONAL(BUILD_SH4X86, [test "$SH4_TRANSLATOR" = "x86"])
320 dnl ------------------ Optional driver support -------------------
321 dnl Check for Apple CoreAudio
322 AC_CHECK_HEADER([CoreAudio/CoreAudio.h], [
324 LIBS="$LIBS -framework CoreAudio"
325 AUDIO_DRIVERS="$AUDIO_DRIVERS osx"
326 AC_DEFINE([HAVE_CORE_AUDIO], 1, [Have Apple CoreAudio support]) ],[true ])
327 AM_CONDITIONAL( AUDIO_OSX, [test "$HAVE_CORE_AUDIO" = 'yes'] )
329 dnl Check for SDL (only used for audio at the moment)
330 if test "x$with_sdl" != "xno"; then
331 PKG_CHECK_MODULES(SDL, [sdl], [
333 AUDIO_DRIVERS="$AUDIO_DRIVERS sdl"
334 AC_DEFINE([HAVE_SDL],1,[Have SDL support])
336 if test "x$with_sdl" = "xyes"; then
337 AC_MSG_FAILURE( ["SDL libraries could not be found (but were required)] )
341 AM_CONDITIONAL( AUDIO_SDL, [test "$HAVE_SDL" = 'yes'] )
343 dnl Check for pulseaudio
344 if test "x$with_pulse" != "xno"; then
345 PKG_CHECK_MODULES(PULSE, [libpulse-simple], [
347 AUDIO_DRIVERS="$AUDIO_DRIVERS pulse"
348 AC_DEFINE([HAVE_PULSE],1,[Have pulseaudio support])
350 if test "x$with_pulse" = "xyes"; then
351 AC_MSG_FAILURE( [PulseAudio audio package could not be found (but was required)] )
355 AM_CONDITIONAL( AUDIO_PULSE, [test "$HAVE_PULSE" = 'yes'] )
358 if test "x$with_esd" != "xno"; then
359 PKG_CHECK_MODULES(ESOUND, [esound], [
361 AUDIO_DRIVERS="$AUDIO_DRIVERS esd"
362 AC_DEFINE([HAVE_ESOUND],1,[Have esound support])
364 if test "x$with_esd" = "xyes"; then
365 AC_MSG_FAILURE( [ESounD audio package could not be found (but was required)] )
369 AM_CONDITIONAL( AUDIO_ESOUND, [test "$HAVE_ESOUND" = 'yes'] )
371 dnl Check for alsa support
372 PKG_CHECK_MODULES(ALSA, [alsa], [
374 AUDIO_DRIVERS="$AUDIO_DRIVERS alsa"
375 AC_DEFINE([HAVE_ALSA],1,[Have alsa support]) ], [true])
376 AM_CONDITIONAL( AUDIO_ALSA, [test "$HAVE_ALSA" = 'yes'] )
379 dnl Check for native cdrom support. There can be only one.
380 AC_CHECK_HEADER([linux/cdrom.h], [
382 dnl Some kernel versions have non-c99 compliant headers - check here
383 AC_MSG_CHECKING([C99 compliant kernel headers])
385 CFLAGS="$CFLAGS $STDCFLAG"
386 AC_TRY_COMPILE([#include <linux/cdrom.h>], [], [AC_MSG_RESULT([Yes])], [
388 STDCFLAG="-std=gnu99"])
391 AC_CHECK_HEADER([IOKit/IOKitLib.h], [
393 LIBS="$LIBS -framework IOKit"],[true])
394 AM_CONDITIONAL(CDROM_LINUX, [test "x$CDROM_DRIVER" = "xlinux"])
395 AM_CONDITIONAL(CDROM_OSX, [test "x$CDROM_DRIVER" = "xosx"])
396 AM_CONDITIONAL(CDROM_NONE, [test "x$CDROM_DRIVER" = "x"])
397 if test "x$CDROM_DRIVER" = "xlinux"; then
398 AC_DEFINE([HAVE_LINUX_CDROM],1,[Using the linux native CDROM driver])
401 AC_CHECK_HEADER([linux/joystick.h], [
402 HAVE_LINUX_JOYSTICK_H=yes
403 AC_DEFINE([HAVE_LINUX_JOYSTICK], 1, [Have linux joystick support])
404 INPUT_DRIVERS="$INPUT_DRIVERS joy_linux" ],
405 [ echo "Linux Joystick support not found, building without it."] )
406 AM_CONDITIONAL(JOY_LINUX, [test "$HAVE_LINUX_JOYSTICK_H" = "yes"])
409 if test "x$with_lirc" != "xno"; then
410 AC_CHECK_HEADER([lirc/lirc_client.h], [
411 HAVE_LIRC_CLIENT_H=yes
412 AC_DEFINE([HAVE_LIRC],1,[Have LIRC support])
413 INPUT_DRIVERS="$INPUT_DRIVERS lirc"
415 [ echo "LIRC support not found, building without it." ] )
417 AM_CONDITIONAL(INPUT_LIRC, [test "$HAVE_LIRC_CLIENT_H" = "yes"])
419 dnl Check for cross-compiler availability - needed for system tests
420 AC_PATH_PROG(SHCC, [sh-elf-gcc])
421 AC_PATH_PROG(SHLD, [sh-elf-ld])
422 AC_PATH_PROG(SHOBJCOPY, [sh-elf-objcopy])
423 AC_PATH_PROG(ARMCC, [arm-elf-gcc])
424 AC_PATH_PROG(ARMLD, [arm-elf-ld])
425 AC_PATH_PROG(ARMOBJCOPY, [arm-elf-objcopy])
427 if test "x$SHCC" = "x" -o "x$SHLD" = "x" -o "x$SHOBJCOPY" = "x"; then
429 echo "Warning: SH4 cross-compiler not found, system tests will be disabled."
433 if test "x$ARMCC" = "x" -o "x$ARMLD" = "x" -o "x$ARMOBJCOPY" = "x"; then
435 echo "Warning: ARM cross-compiler not found, AICA tests will be disabled."
439 AM_CONDITIONAL(BUILD_SYSTEST, [test "$BUILD_SH" = "yes"])
440 AM_CONDITIONAL(BUILD_ARMTEST, [test "$BUILD_ARM" = "yes"])
442 CFLAGS="$CFLAGS $STDCFLAG"
444 dnl ----------------------- All done, finish up -----------------------
445 GETTEXT_PACKAGE=lxdream
448 AC_SUBST(LXDREAM_LIBS)
449 AC_SUBST(GETTEXT_PACKAGE)
450 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[translation domain])
452 dnl Add the languages which your application supports here.
453 ALL_LINGUAS="de es it nl pt_BR"
466 dnl ------------------------- Print out a summary ----------------------
469 echo "Configuration complete"
472 if test "x$HAVE_GTK" = x; then
473 if test "x$HAVE_COCOA" = x; then
474 echo " User interface: none"
476 echo " User interface: Cocoa"
479 echo " User interface: GTK"
482 if test "x$SH4_TRANSLATOR" = "x"; then
483 echo " SH4 translator: None (emulation core only)"
485 echo " SH4 translator: $SH4_TRANSLATOR"
488 if test "x$VIDEO_DRIVERS" = "x"; then
489 echo " Video drivers: none (no supported GL found)"
491 echo " Video drivers: $VIDEO_DRIVERS"
494 if test "x$AUDIO_DRIVERS" = "x"; then
495 echo " Audio drivers: none (no supported output devices found)"
497 echo " Audio drivers: $AUDIO_DRIVERS"
500 if test "x$INPUT_DRIVERS" = "x"; then
501 echo " Input drivers: none (no supported input devices found)"
503 echo " Input drivers: $INPUT_DRIVERS"
506 if test "x$CDROM_DRIVER" = "x"; then
507 echo " CD-ROM driver: none (no supported cd-rom devices found)"
509 echo " CD-ROM driver: $CDROM_DRIVER"
.