1dnl Process this file with autoconf to produce a configure script.
2dnl $Id: configure.ac 4995 2013-05-24 19:54:19Z zubzero $
3
4dnl This program is free software; you can redistribute it and/or modify
5dnl it under the terms of the GNU General Public License as published by
6dnl the Free Software Foundation; either version 2 of the License, or
7dnl (at your option) any later version.
8dnl
9dnl This program is distributed in the hope that it will be useful,
10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl GNU General Public License for more details.
13dnl
14dnl You should have received a copy of the GNU General Public License along
15dnl with this program; if not, write to the Free Software Foundation, Inc.,
16dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17dnl
18dnl Author contact information:
19dnl
20dnl E-mail: philip-fuse@shadowmagic.org.uk
21
22dnl Package version
23m4_define([fuse_version], [1.1.1])
24
25dnl Product full version
26m4_define([fuse_major_version], [1])
27m4_define([fuse_minor_version], [1])
28m4_define([fuse_micro_version], [1])
29m4_define([fuse_nano_version],  [0])
30m4_define([fuse_full_version], [fuse_major_version.fuse_minor_version.fuse_micro_version.fuse_nano_version])
31m4_define([fuse_rc_version], [fuse_major_version,fuse_minor_version,fuse_micro_version,fuse_nano_version])
32
33dnl Package info
34m4_define([fuse_copyright], ["(c) 1999-2013 Philip Kendall and others"])
35m4_define([fuse_url], [http://fuse-emulator.sourceforge.net/])
36m4_define([fuse_bugreport], [http://sourceforge.net/p/fuse-emulator/bugs/])
37
38AC_INIT([fuse],[fuse_version],[fuse_bugreport],[fuse],[fuse_url])
39AC_CONFIG_SRCDIR(fuse.c)
40AC_CONFIG_MACRO_DIR([m4])
41AC_CONFIG_HEADERS(config.h)
42AC_CANONICAL_HOST
43
44dnl Use automake to produce `Makefile.in'
45AM_INIT_AUTOMAKE
46
47dnl Substitutions for .in files
48FUSE_FULL_VERSION=fuse_full_version
49FUSE_COPYRIGHT=fuse_copyright
50FUSE_URL=fuse_url
51AC_SUBST(FUSE_FULL_VERSION)
52AC_SUBST(FUSE_COPYRIGHT)
53AC_SUBST(FUSE_URL)
54
55dnl Definitions for config.h
56AC_DEFINE([FUSE_RC_VERSION], [fuse_rc_version],
57          [Define version information for win32 executables])
58AC_DEFINE([FUSE_COPYRIGHT], [fuse_copyright], [Define copyright of Fuse])
59
60dnl Checks for programs.
61AC_PROG_CC
62AC_PROG_RANLIB
63AC_PATH_PROG(PERL, perl)
64AC_SUBST(PERL)
65AM_PROG_LEX
66AC_PROG_YACC
67LT_INIT
68
69dnl Check for host specific programs
70WINDRES_OBJ=
71case "$host_os" in
72  mingw32*)
73    AC_CHECK_TOOL([WINDRES], [windres], [no])
74    if test "$WINDRES" != no; then
75      WINDRES_OBJ="windres.o"
76    fi
77    AC_CHECK_PROGS([MAN2HTML], [man2html])
78    AC_CHECK_PROGS([GROFF], [groff])
79    AC_CHECK_PROGS([UNIX2DOS], [unix2dos])
80    ;;
81esac
82AC_SUBST(WINDRES_OBJ)
83
84dnl Generate commandy.h
85YFLAGS="$YFLAGS -d"
86AC_SUBST(YFLAGS)
87
88dnl Check for big endianness
89AC_C_BIGENDIAN
90
91dnl Checks for header files.
92AC_HEADER_STDC
93AC_CHECK_HEADERS(
94  libgen.h \
95  siginfo.h \
96  strings.h \
97  sys/soundcard.h \
98  sys/audio.h \
99  sys/audioio.h
100)
101
102dnl Checks for typedefs, structures, and compiler characteristics.
103AC_C_CONST
104AC_C_INLINE
105
106dnl Checks for library functions.
107AC_CHECK_FUNCS(dirname geteuid getopt_long mkstemp fsync)
108AC_CHECK_LIB([m],[cos])
109
110dnl Allow the user to say that various libraries are in one place
111AC_ARG_WITH(local-prefix,
112[  --with-local-prefix=PFX local libraries installed in PFX (optional)],
113CPPFLAGS="$CPPFLAGS -I$withval/include"; LDFLAGS="$LDFLAGS -L$withval/lib",
114if test "$prefix" != "NONE"; then
115  CPPFLAGS="$CPPFLAGS -I$prefix/include"; LDFLAGS="$LDFLAGS -L$prefix/lib"
116fi)
117
118dnl Select a user interface
119
120dnl Try various UI options; set the `ui' variable when we've got one
121dnl we like, and then don't look at the other options
122
123AC_PATH_XTRA
124
125dnl Look for Win32 UI (default=no)
126AC_MSG_CHECKING(whether Win32 UI requested)
127AC_ARG_WITH(win32,
128[  --with-win32            use Win32 for user interface],
129if test "$withval" = no; then win32=no; else win32=yes; fi,
130win32=no)
131AC_MSG_RESULT($win32)
132if test "$win32" = yes; then
133  AC_CHECK_HEADER(windows.h,
134                  LIBS="$LIBS -mwindows -lcomctl32 -lwinmm";
135                  AC_DEFINE([UI_WIN32], 1, [Defined if Win32 UI in use])
136                  AC_DEFINE([WINVER], 0x0400, [Minimal supported version of Windows is 95 or NT4])
137                  AC_DEFINE([_WIN32_IE], 0x400, [Internet Explorer is 4.0 or higher is required])
138                  AC_DEFINE([WIN32_LEAN_AND_MEAN],, [Exclude rarely used stuff from Windows headers <windows.h>])
139                  UI=win32; UI_LIBS="ui/win32/libuiwin32.a",
140                  AC_MSG_ERROR([Win32 UI not found]))
141fi
142
143dnl Look for svgalib (default=no)
144AC_MSG_CHECKING(whether svgalib UI requested)
145AC_ARG_WITH(svgalib,
146[  --with-svgalib          use svgalib for user interface],
147if test "$withval" = no; then svgalib=no; else svgalib=yes; fi,
148svgalib=no)
149AC_MSG_RESULT($svgalib)
150if test "$svgalib" = yes; then
151  AC_CHECK_HEADER(vga.h,
152                  LIBS="$LIBS -lvga";
153                  AC_DEFINE([UI_SVGA], 1, [Defined if svgalib UI in use])
154		  AC_DEFINE([USE_WIDGET], 1,
155		            [Defined if we're using a widget-based UI])
156                  UI=svga; WIDGET=widget;
157                  UI_LIBS="ui/svga/libuisvga.a ui/widget/libwidget.a",
158                  AC_MSG_ERROR([svgalib not found]))
159fi
160
161dnl Look for framebuffer interface for SA1110 (default=no)
162if test -z "$UI"; then
163  AC_MSG_CHECKING(whether framebuffer UI requested)
164  AC_ARG_WITH(fb,
165  [  --with-fb               use framebuffer for user interface],
166  if test "$withval" = no; then fb=no; else fb=yes; fi,
167  fb=no)
168  AC_MSG_RESULT($fb)
169  if test "$fb" = yes; then
170    AC_DEFINE([UI_FB], 1, [Defined if framebuffer UI in use])
171    AC_DEFINE([USE_WIDGET], 1, [Defined if we're using a widget-based UI])
172    UI=fb; WIDGET=widget;
173    UI_LIBS="ui/fb/libuifb.a ui/widget/libwidget.a"
174    dnl Look for libgpm (default=yes)
175    AC_MSG_CHECKING(whether gpm requested)
176    AC_ARG_WITH(gpm,
177    [  --without-gpm           don't use libgpm for e.g. Kempston mouse],
178    if test "$withval" = no; then gpm=no; else gpm=yes; fi,
179    gpm=yes)
180    AC_MSG_RESULT($gpm)
181    dnl Note: we use libdl to get libgpm at runtime
182    if test "$gpm" = yes; then
183      AC_CHECK_HEADER(gpm.h,
184		      UI_LIBS="$UI_LIBS -ldl";
185		      AC_DEFINE([HAVE_GPM_H], 1, [Defined if gpm in use]),
186		      AC_MSG_ERROR([libgpm not found]))
187    fi
188  fi
189fi
190
191dnl Look for Wii interface (default = 0)
192if test -z "$UI"; then
193  AC_MSG_CHECKING(whether Wii UI requested)
194  AC_ARG_WITH(wii,
195  [  --with-wii               use Wii FB for user interface],
196  if test "$withval" = no; then wii=no; else wii=yes; fi,
197  wii=no)
198  AC_MSG_RESULT($wii)
199  if test "$wii" = yes; then
200    AC_DEFINE([UI_WII], 1, [Defined if Wii UI in use])
201    AC_DEFINE([USE_WIDGET], 1, [Defined if we're using a widget-based UI])
202    AC_DEFINE([USE_JOYSTICK], 1, [Defined if we're using hardware joysticks])
203    UI=wii; WIDGET=widget;
204    UI_LIBS="ui/wii/libuiwii.a ui/widget/libwidget.a"
205    host_os=wii
206    dnl Look for libgpm (default=yes)
207    AC_MSG_CHECKING(whether gpm requested)
208    AC_ARG_WITH(gpm,
209    [  --without-gpm           don't use libgpm for e.g. Kempston mouse],
210    if test "$withval" = no; then gpm=no; else gpm=yes; fi,
211    gpm=yes)
212    AC_MSG_RESULT($gpm)
213    dnl Note: we use libdl to get libgpm at runtime
214    if test "$gpm" = yes; then
215      AC_CHECK_HEADER(gpm.h,
216		      UI_LIBS="$UI_LIBS -ldl";
217		      AC_DEFINE([HAVE_GPM_H], 1, [Defined if gpm in use]),
218		      AC_MSG_ERROR([libgpm not found]))
219    fi
220  fi
221fi
222
223dnl Look for SDL (default=no)
224if test -z "$UI"; then
225  AC_MSG_CHECKING(whether SDL UI requested)
226  AC_ARG_WITH(sdl,
227  [  --with-sdl              use SDL for user interface],
228  if test "$withval" = no; then sdl=no; else sdl=yes; fi,
229  sdl=no)
230  AC_MSG_RESULT($sdl)
231  if test "$sdl" = yes; then
232    SDL_VERSION=1.2.4
233    AM_PATH_SDL($SDL_VERSION,
234		AC_DEFINE([UI_SDL], 1, [Defined if the SDL UI in use])
235		AC_DEFINE([USE_WIDGET], 1,
236		          [Defined if we're using a widget-based UI])
237		UI=sdl; WIDGET=widget;
238	        UI_LIBS="ui/sdl/libuisdl.a ui/widget/libwidget.a",
239                AC_MSG_ERROR([SDL version $SDL_VERSION not found]))
240  fi
241fi
242
243dnl Look for GTK+ (default=yes)
244if test -z "$UI"; then
245  AC_MSG_CHECKING(whether GTK+ UI requested)
246  AC_ARG_WITH(gtk,
247  [  --without-gtk           don't use GTK+ for user interface],
248  if test "$withval" = no; then gtk=no; else gtk=yes; fi,
249  gtk=yes)
250  AC_MSG_RESULT($gtk)
251
252  if test "$gtk" = yes; then
253
254    AC_ARG_ENABLE(gtk3,
255      AS_HELP_STRING([--enable-gtk3],[prefer GTK+ 3 to GTK+ 2]),
256      if test "$enableval" = yes; then gtk3=yes; else gtk3=no; fi,
257      gtk3=auto
258    )
259
260    if test "$gtk3" = yes; then
261      PKG_CHECK_MODULES(GTK, [gtk+-3.0],,
262        AC_MSG_ERROR([GTK+ not found])
263      )
264
265    elif test "$gtk3" = no; then
266      AM_PATH_GTK_2_0(2.18.0,,
267        AC_MSG_WARN([GTK+ not found. Reverting to Xlib])
268        gtk=no
269      )
270
271    elif test "$gtk3" = auto; then
272      AM_PATH_GTK_2_0(2.18.0,
273        gtk3=no,
274      )
275
276      if test "$gtk3" = auto; then
277        PKG_CHECK_MODULES(GTK, [gtk+-3.0],
278          gtk3=yes,
279          AC_MSG_WARN([GTK+ not found. Reverting to Xlib])
280          gtk3=no
281          gtk=no
282        )
283      fi
284    fi
285
286  fi
287
288  if test "$gtk" = yes; then
289    AC_DEFINE([UI_GTK], 1, [Defined if GTK+ UI is in use])
290    AC_DEFINE([HAVE_LIB_GLIB], 1, [Defined if we've got glib])
291    UI=gtk; UI_LIBS="ui/gtk/libuigtk.la"
292  fi
293fi
294
295AM_CONDITIONAL(HAVE_GTK2, test "$gtk3" != yes)
296
297if test "$UI" = gtk; then
298  AC_PATH_XTRA
299fi
300
301dnl Look for Xlib UI (default=yes)
302if test -z "$UI"; then
303  if test "$with_x" = no; then
304    AC_MSG_ERROR([Please specify --with-svgalib or --with-fb, not --without-x.])
305  fi
306  AC_PATH_XTRA
307  CFLAGS="$CFLAGS $X_CFLAGS";
308  LDFLAGS="$LDFLAGS $X_LIBS";
309  LIBS="$LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS";
310
311  dnl This apparently needed for SVR4 systems to link correctly
312  dnl Basically the same as a part of AC_PATH_XTRA, but using `gethostname'
313  dnl instead of `gethostbyname'.
314  dnl Thanks to Erik Kunze for pointing out this problem
315  AC_CHECK_FUNC(gethostname)
316  if test $ac_cv_func_gethostname = no; then
317    AC_CHECK_LIB(nsl, gethostname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
318  fi
319  AC_CHECK_FUNC(connect)
320  if test $ac_cv_func_connect = no; then
321    AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
322	         $X_EXTRA_LIBS)
323  fi
324
325  dnl Check for the MIT-SHM extension
326  AC_CHECK_HEADERS( X11/extensions/XShm.h,,,[[
327	#include <sys/ipc.h>
328	#include <sys/shm.h>
329	#include <X11/Xlib.h>
330	]])
331  AC_CHECK_LIB( Xext, XShmAttach, LIBS="$LIBS -lXext" )
332
333  AC_DEFINE([UI_X], 1, [Defined if Xlib UI in use])
334  UI=xlib; WIDGET=widget;
335  AC_DEFINE([USE_WIDGET], 1, [Defined if we're using a widget-based UI])
336  UI_LIBS="ui/xlib/libuixlib.a ui/widget/libwidget.a"
337fi
338
339AC_SUBST(UI)
340AC_SUBST(UI_LIBS)
341AC_SUBST(WIDGET)
342AM_CONDITIONAL(WIDGET, test x$WIDGET != x)
343
344# If we're not using GTK+, must either find glib or use the replacement
345# (as supplied by libspectrum)
346if test "$UI" != gtk; then
347  AC_MSG_CHECKING(whether to use glib)
348  AC_ARG_WITH(glib,
349  [  --without-glib          don't use glib],
350  if test "$withval" = no; then glib=no; else glib=yes; fi,
351  glib=yes)
352  AC_MSG_RESULT($glib)
353  if test "$glib" = yes; then
354    AM_PATH_GLIB_2_0(
355      2.20.0,
356      AC_DEFINE([HAVE_LIB_GLIB], 1, [Defined if we've got glib])
357      LIBS="$LIBS `pkg-config --libs glib-2.0`",
358      AC_MSG_WARN(glib not found - using libspectrum's replacement)
359    )
360  fi
361fi
362
363dnl Check that libspectrum is available
364AC_ARG_WITH(libspectrum-prefix,
365[  --with-libspectrum-prefix=PFX where libspectrum is installed (optional)],
366LIBSPEC_CFLAGS=-I$withval/include; LIBSPEC_LIBS=-L$withval/lib,
367LIBSPEC_CFLAGS=""; LIBSPEC_LIBS="")
368ac_save_CPPFLAGS="$CPPFLAGS"
369CPPFLAGS="$CPPFLAGS $LIBSPEC_CFLAGS $GTK_CFLAGS $GLIB_CFLAGS"
370AC_CHECK_HEADERS(libspectrum.h,LIBSPEC_LIBS="$LIBSPEC_LIBS -lspectrum",
371	         AC_MSG_ERROR(Sorry - I need libspectrum to be available))
372CPPFLAGS="$ac_save_CPPFLAGS"
373AC_SUBST(LIBSPEC_CFLAGS)
374AC_SUBST(LIBSPEC_LIBS)
375
376dnl Check if supplied libspectrum has support for compressed szx files
377AC_MSG_CHECKING(whether libspectrum supports compressed szx snaps)
378ac_save_CPPFLAGS="$CPPFLAGS"
379CPPFLAGS="$CPPFLAGS $LIBSPEC_CFLAGS"
380AC_COMPILE_IFELSE(
381  [AC_LANG_PROGRAM([[#include <libspectrum.h>]],
382    [[
383      int test = LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION;
384    ]])
385  ],
386  [AUTOLOAD_SNAPS=compressed; LIBSPEC_HAVE_ZLIB=yes; AC_MSG_RESULT(yes)],
387  [AUTOLOAD_SNAPS=uncompressed; LIBSPEC_HAVE_ZLIB=""; AC_MSG_RESULT(no)]
388)
389CPPFLAGS="$ac_save_CPPFLAGS"
390AC_SUBST(AUTOLOAD_SNAPS)
391AC_SUBST(LIBSPEC_HAVE_ZLIB)
392AC_CONFIG_LINKS([
393	lib/disk_plus3.szx:lib/"$AUTOLOAD_SNAPS"/disk_plus3.szx
394	lib/tape_128.szx:lib/"$AUTOLOAD_SNAPS"/tape_128.szx
395	lib/tape_16.szx:lib/"$AUTOLOAD_SNAPS"/tape_16.szx
396	lib/tape_2048.szx:lib/"$AUTOLOAD_SNAPS"/tape_2048.szx
397	lib/tape_2068.szx:lib/"$AUTOLOAD_SNAPS"/tape_2068.szx
398	lib/tape_48.szx:lib/"$AUTOLOAD_SNAPS"/tape_48.szx
399	lib/tape_plus2.szx:lib/"$AUTOLOAD_SNAPS"/tape_plus2.szx
400	lib/tape_plus2a.szx:lib/"$AUTOLOAD_SNAPS"/tape_plus2a.szx
401	lib/tape_plus3.szx:lib/"$AUTOLOAD_SNAPS"/tape_plus3.szx
402	lib/tape_plus3e.szx:lib/"$AUTOLOAD_SNAPS"/tape_plus3e.szx
403	lib/tape_pentagon.szx:lib/"$AUTOLOAD_SNAPS"/tape_pentagon.szx
404	lib/tape_scorpion.szx:lib/"$AUTOLOAD_SNAPS"/tape_scorpion.szx
405	lib/tape_se.szx:lib/"$AUTOLOAD_SNAPS"/tape_se.szx
406	lib/tape_ts2068.szx:lib/"$AUTOLOAD_SNAPS"/tape_ts2068.szx])
407
408dnl Check whether to use zlib (the UNIX version is called z, Win32 zdll)
409AC_MSG_CHECKING(whether to use zlib)
410AC_ARG_WITH(zlib,
411[  --without-zlib          don't use zlib],
412if test "$withval" = no; then zlib=no; else zlib=yes; fi,
413zlib=yes)
414AC_MSG_RESULT($zlib)
415if test "$zlib" = yes; then
416  AC_CHECK_HEADERS(
417    zlib.h,
418    AC_SEARCH_LIBS(compress2, z zdll)
419  )
420fi
421
422dnl Check if supplied libspectrum has support for bz2 compressed files
423AC_MSG_CHECKING(whether libspectrum supports compressed bz2 files)
424ac_save_CPPFLAGS="$CPPFLAGS"
425CPPFLAGS="$CPPFLAGS $LIBSPEC_CFLAGS"
426AC_COMPILE_IFELSE(
427  [AC_LANG_PROGRAM([[#include <libspectrum.h>]],
428    [[
429      int test = LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION;
430    ]])
431  ],
432  [LIBSPEC_HAVE_BZ2=yes; AC_MSG_RESULT(yes)],
433  [LIBSPEC_HAVE_BZ2=""; AC_MSG_RESULT(no)]
434)
435CPPFLAGS="$ac_save_CPPFLAGS"
436AC_SUBST(LIBSPEC_HAVE_BZ2)
437
438dnl Check if supplied libspectrum has support for wav files
439AC_MSG_CHECKING(whether libspectrum supports wav files)
440ac_save_CPPFLAGS="$CPPFLAGS"
441CPPFLAGS="$CPPFLAGS $LIBSPEC_CFLAGS"
442AC_COMPILE_IFELSE(
443  [AC_LANG_PROGRAM([[#include <libspectrum.h>]],
444    [[
445      int test = LIBSPECTRUM_SUPPORTS_AUDIOFILE;
446    ]])
447  ],
448  [LIBSPEC_HAVE_AUDIOFILE=yes; AC_MSG_RESULT(yes)],
449  [LIBSPEC_HAVE_AUDIOFILE=""; AC_MSG_RESULT(no)]
450)
451CPPFLAGS="$ac_save_CPPFLAGS"
452AC_SUBST(LIBSPEC_HAVE_AUDIOFILE)
453
454dnl Check if a version of libpng which supplies png_write_png is available
455AC_MSG_CHECKING(whether PNG support requested)
456AC_ARG_WITH(png,
457[  --without-png           don't use libpng],
458if test "$withval" = no; then libpng=no; else libpng=yes; fi,
459libpng=yes)
460AC_MSG_RESULT($libpng)
461if test "$libpng" = yes; then
462  AC_PATH_PROG([LIBPNG_CONFIG], [libpng-config])
463  if test -n "$LIBPNG_CONFIG"; then
464    PNG_CFLAGS=`libpng-config --cflags`
465    PNG_LIBS=`libpng-config --ldflags`
466    AC_DEFINE([USE_LIBPNG], 1, [Defined if we're going to be using the installed libpng])
467  else
468    ac_save_CPPFLAGS="$CPPFLAGS"
469    CPPFLAGS="$CPPFLAGS $PNG_CFLAGS"
470    ac_save_LDFLAGS="$LDFLAGS"
471    LDFLAGS="$PNG_LIBS $LDFLAGS"
472
473    AC_CHECK_LIB( png, png_write_png,
474      [AC_CHECK_HEADER(
475        png.h,
476        [AC_DEFINE([USE_LIBPNG], 1, [Defined if we're going to be using the installed libpng]) PNG_LIBS='-lpng -lm -lz'],
477        [AC_CHECK_HEADERS(libpng/png.h,
478                     [CPPFLAGS="$ac_save_CPPFLAGS $PNG_CFLAGS/libpng"
479                      AC_DEFINE([USE_LIBPNG], 1, [Defined if we're going to be using the installed libpng]) PNG_LIBS='-lpng -lm -lz'],
480                     [AC_MSG_WARN(png.h not found - saving screenshots disabled)
481                      PNG_LIBS='']
482        )],
483      )],
484      [AC_MSG_WARN(png_write_png not found - saving screenshots disabled)
485       PNG_LIBS='']
486    )
487
488    CPPFLAGS="$ac_save_CPPFLAGS"
489    LDFLAGS="$ac_save_LDFLAGS"
490  fi
491
492  AC_SUBST(PNG_LIBS)
493fi
494
495dnl Check if a version of libasound which supplies pcm is available
496AC_MSG_CHECKING(whether ALSA requested)
497AC_ARG_WITH(alsa,
498[  --without-alsa          don't use libasound (ALSA)],
499if test "$withval" = no; then libasound=no; else libasound=yes; fi,
500libasound=yes)
501AC_MSG_RESULT($libasound)
502if test "$libasound" = yes; then
503  AC_CHECK_LIB( asound, snd_pcm_hw_params_set_period_size_near,
504    [AC_CHECK_HEADER(
505      alsa/asoundlib.h,
506      [alsa_available=yes],
507      [AC_MSG_WARN(alsa/asoundlib.h not found - no ALSA output)]
508    )],
509    [AC_MSG_WARN(snd_pcm_hw_params_set_period_size_near not found - no ALSA output)]
510  )
511fi
512
513dnl Check if a version of libao which supplies ao_open_live is available
514AC_MSG_CHECKING(whether libao requested)
515AC_ARG_WITH(libao,
516[  --with-libao            use libao for sound output],
517if test "$withval" = no; then libao=no; else libao=yes; fi,
518libao=no)
519AC_MSG_RESULT($libao)
520if test "$libao" = yes; then
521  AC_CHECK_LIB( ao, ao_open_live,
522    [AC_CHECK_HEADER(
523      ao/ao.h,
524      [ao_available=yes],
525      [AC_MSG_WARN(ao/ao.h not found - no libao sound output)]
526    )],
527    [AC_MSG_WARN(ao_open_live not found - no libao sound output)]
528  )
529fi
530
531dnl Check if DirectSound is available
532AC_CHECK_HEADER(
533  dsound.h,
534  [dxsound_available=yes],
535  [AC_MSG_WARN(dsound.h not found - no DirectSound output)],
536  [#define DIRECTSOUND_VERSION 0x0700
537   #include <windows.h>
538   #include <mmsystem.h>]
539)
540
541dnl Check if MS Windows Multimedia API sound is available
542AC_CHECK_HEADER(
543  mmsystem.h,
544  [win32sound_available=yes],
545  [AC_MSG_WARN(mmsystem.h not found - no MS Windows Multimedia API sound output)],
546  [#include <windows.h>]
547)
548
549dnl Check if CoreAudio is available
550AC_CHECK_HEADER(
551  CoreAudio/AudioHardware.h,
552  [coreaudio_available=yes],
553  [AC_MSG_WARN(CoreAudio/AudioHardware.h not found - no CoreAudio sound output)]
554)
555
556dnl
557dnl Decide which sound routines to use
558dnl
559
560AC_MSG_CHECKING(which sound routines to use)
561if test "$UI" = sdl; then
562  SOUND_LIBADD='sdlsound.$(OBJEXT)' SOUND_LIBS='' sound_fifo=yes
563  AC_MSG_RESULT(SDL)
564elif test "$dxsound_available" = yes; then
565  SOUND_LIBADD='dxsound.$(OBJEXT)' SOUND_LIBS='-ldsound -lole32 -ldxguid'
566  AC_MSG_RESULT(DirectX)
567  AC_DEFINE([DIRECTSOUND_VERSION], 0x0700, [DirectX 7 or higher is required])
568elif test "$win32sound_available" = yes; then
569  SOUND_LIBADD='win32sound.$(OBJEXT)' SOUND_LIBS='-lwinmm'
570  AC_MSG_RESULT(win32sound)
571elif test "$alsa_available" = yes; then
572  SOUND_LIBADD='alsasound.$(OBJEXT)' SOUND_LIBS='-lasound'
573  AC_MSG_RESULT(ALSA)
574elif test "$ao_available" = yes; then
575  SOUND_LIBADD='aosound.$(OBJEXT)' SOUND_LIBS='-lao'
576  AC_MSG_RESULT(libao)
577elif test "$ac_cv_header_dsound_h" = yes; then
578  # Later selection between these two
579  SOUND_LIBADD='sunsound.$(OBJEXT) hpsound.$(OBJEXT)' SOUND_LIBS=''
580  AC_MSG_RESULT(Solaris or HP/UX)
581elif test "$ac_cv_header_sys_soundcard_h" = yes; then
582  SOUND_LIBADD='osssound.$(OBJEXT)' SOUND_LIBS=''
583  AC_MSG_RESULT(OSS)
584elif test "$ac_cv_header_sys_audioio_h" = yes; then
585  dnl OpenBSD
586  SOUND_LIBADD='sunsound.$(OBJEXT)' SOUND_LIBS=''
587  AC_MSG_RESULT(OpenBSD)
588elif test "$coreaudio_available" = yes; then
589  SOUND_LIBADD='coreaudiosound.$(OBJEXT)' SOUND_LIBS='-framework CoreAudio -framework AudioUnit -framework CoreServices' sound_fifo=yes
590  AC_MSG_RESULT(CoreAudio)
591elif test "$wii" = yes; then
592  SOUND_LIBADD='wiisound.$(OBJEXT)' SOUND_LIBS='' sound_fifo=yes
593  AC_MSG_RESULT(Wii)
594else
595  SOUND_LIBADD='nullsound.$(OBJEXT)' SOUND_LIBS=''
596  AC_MSG_RESULT(none)
597  AC_DEFINE([NO_SOUND], 1, [Defined if no sound code is present])
598fi
599
600if test "$sound_fifo" = yes; then
601  dnl Strange construct used here as += doesn't seem to work on OS X
602  SOUND_LIBADD="$SOUND_LIBADD"' sfifo.$(OBJEXT)'
603  AC_DEFINE([SOUND_FIFO], 1, [Defined if the sound code uses a fifo])
604fi
605
606AC_SUBST(SOUND_LIBADD)
607AC_SUBST(SOUND_LIBS)
608
609dnl Are we supplying the ROMs or relying on another package?
610AC_MSG_CHECKING(where to find the Spectrum ROM images)
611AC_ARG_WITH(roms-dir,
612  [  --with-roms-dir=DIR     location of the Spectrum ROM images],
613  ,
614  unset withval
615)
616if test "$withval" = ""; then
617  echo 'we supply them'
618else
619  echo "$withval"
620  AC_DEFINE_UNQUOTED(ROMSDIR, "$withval", [Location of the ROM images])
621fi
622
623AC_MSG_CHECKING(whether hardware joystick support requested)
624  AC_ARG_WITH(joystick,
625  [  --without-joystick      use a real joystick for Kempston emulation etc.],
626  if test "$withval" = no; then stick=no; else stick=yes; fi,
627  stick=yes)
628AC_MSG_RESULT($stick)
629if test "$stick" = yes; then
630  dnl We prefer to use UI-specific joystick code. (Default.)
631  dnl If there is none, or you override this here, we use libjsw.
632  dnl (svgalib appears to dislike switched joysticks on the parallel port...)
633  case "$UI" in
634    svga|sdl|win32)
635      dnl Libraries such as svgalib provide their own joystick code.
636      AC_MSG_CHECKING([whether to use $UI's joystick support])
637      AC_ARG_ENABLE(ui-joystick,
638      AS_HELP_STRING([--disable-ui-joystick], [use libjsw joystick code (where supported)]),
639      if test "$enableval" = no; then libjsw=yes; else libjsw=no; fi,
640      libjsw=no)
641      if test "$libjsw" = yes; then
642        AC_MSG_RESULT([no, use libjsw])
643      else
644        AC_MSG_RESULT(yes)
645        AC_DEFINE([USE_JOYSTICK], 1, [Defined if we're using hardware joysticks])
646      fi
647      ;;
648    gtk|xlib)
649      dnl These UIs could use SDL library for handling joysticks
650      AC_MSG_CHECKING([whether to use $UI's joystick support])
651      AC_ARG_ENABLE(ui-joystick,
652      AS_HELP_STRING([--disable-ui-joystick], [use libjsw joystick code (where supported)]),
653      if test "$enableval" = no; then libjsw=yes; else libjsw=no; fi,
654      libjsw=no)
655      if test "$libjsw" = yes; then
656        AC_MSG_RESULT([no, use libjsw])
657      else
658        AC_MSG_RESULT(yes)
659        SDL_VERSION=1.2.4
660        AM_PATH_SDL($SDL_VERSION,
661          LIBS="$LIBS `sdl-config --libs`"
662          CPPFLAGS="$CPPFLAGS `sdl-config --cflags`"
663          AC_DEFINE([USE_JOYSTICK], 1, [Defined if we're using hardware joysticks]),
664          AC_MSG_WARN([SDL version $SDL_VERSION not found - joystick support disabled]))
665      fi
666      ;;
667    wii)
668      dnl Wii UI check this elsewhere
669      AC_MSG_RESULT(yes)
670      libjsw=no
671      ;;
672    *)
673      dnl Our only option is libjsw.
674      libjsw=yes
675      ;;
676  esac
677  if test "$libjsw" = yes; then
678    dnl Look for libjsw. If missing, use QAOP<space>.
679    AC_CHECK_HEADERS(jsw.h,
680                     LIBS="$LIBS -ljsw";
681		     AC_DEFINE([USE_JOYSTICK], 1,
682		               [Defined if we're using hardware joysticks]),
683                     AC_MSG_WARN(jsw.h not found - joystick support disabled))
684  fi
685fi
686
687dnl See if libxml2 is available (for the config file handling)
688AC_MSG_CHECKING(whether libxml2 support requested)
689  AC_ARG_WITH(libxml2,
690  [  --without-libxml2       use a libxml2 for settings],
691  if test "$withval" = no; then libxml2=no; else libxml2=yes; fi,
692  libxml2=yes)
693AC_MSG_RESULT($libxml2)
694if test "$libxml2" = yes; then
695  AM_PATH_XML2(2.0.0,AC_DEFINE([HAVE_LIB_XML2], 1,
696               [Defined if we've got libxml2]),
697               AC_MSG_WARN(libxml2 not found - config file will use ini format))
698fi
699
700dnl Work out which timer routines to use
701AC_MSG_CHECKING(which timer routines to use)
702if test "$UI" = sdl; then
703  TIMER_LIBADD='sdl.$(OBJEXT)'
704  AC_MSG_RESULT(SDL)
705else
706  TIMER_LIBADD='native.$(OBJEXT)'
707  AC_MSG_RESULT(native)
708fi
709AC_SUBST(TIMER_LIBADD)
710
711dnl See if sockets are supported
712AC_MSG_CHECKING([whether sockets support requested])
713AC_ARG_ENABLE(sockets,
714AS_HELP_STRING([--disable-sockets], [do not use sockets]),
715if test "$enableval" = yes; then sockets=yes; else sockets=no; fi,
716sockets=yes)
717AC_MSG_RESULT($sockets)
718if test "$sockets" = yes; then
719case "$host_os" in
720  mingw32*)
721    AC_CHECK_HEADER([winsock2.h], [LIBS="$LIBS -lws2_32"], [sockets=no])
722    ;;
723  *)
724    AC_CHECK_HEADER([sys/socket.h],, [sockets=no])
725    ;;
726esac
727fi
728AM_CONDITIONAL(HAVE_SOCKETS, test "$sockets" = yes)
729
730dnl See if POSIX threads are supported
731AC_MSG_CHECKING([whether pthread support requested])
732AC_ARG_WITH(pthread,
733AS_HELP_STRING([--without-pthread],[do not use POSIX threads]),
734if test "$withval" = no; then pthread=no; else pthread=yes; fi,
735pthread=yes)
736AC_MSG_RESULT($pthread)
737if test "$pthread" = yes; then
738  AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS"
739              CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
740              CC="$PTHREAD_CC"],
741             [AC_MSG_WARN(POSIX threads not found - some peripherals disabled)
742              pthread=no])
743fi
744if test "$pthread" = yes -a "$sockets" = yes; then
745  build_spectranet=yes
746  AC_DEFINE([BUILD_SPECTRANET], 1, [Defined if we support spectranet])
747else
748  build_spectranet=no
749fi
750AM_CONDITIONAL(BUILD_SPECTRANET, test "$build_spectranet" = yes)
751
752dnl See if Linux TAP devices are supported
753AC_MSG_CHECKING(whether Linux TAP devices are supported)
754ac_save_CPPFLAGS="$CPPFLAGS"
755CPPFLAGS="$CPPFLAGS $LIBSPEC_CFLAGS"
756AC_COMPILE_IFELSE(
757  [AC_LANG_PROGRAM([[
758      #include <linux/if_tun.h>
759      #include <net/if.h>
760      #include <sys/ioctl.h>
761    ]],[[
762      int test1 = IFF_TAP | IFF_NO_PI;
763      int test2 = TUNSETIFF;
764    ]])
765  ],
766  [AC_DEFINE([BUILD_SPECCYBOOT], 1, [Define to 1 if SpeccyBoot is supported.])
767  linux_tap=yes
768  AC_MSG_RESULT(yes)],
769  [AC_MSG_RESULT(no)]
770)
771CPPFLAGS="$ac_save_CPPFLAGS"
772AM_CONDITIONAL(HAVE_TUNTAP, test x$linux_tap != x)
773AM_CONDITIONAL(BUILD_SPECCYBOOT, test x$linux_tap != x)
774
775dnl Work out which standard routines we're missing
776AC_MSG_CHECKING(which standard routines we're missing)
777missing_routines=''
778if test "$ac_cv_func_dirname" = no; then
779  missing_routines="$missing_routines"'dirname '
780fi
781AM_CONDITIONAL(COMPAT_DIRNAME, test "$ac_cv_func_dirname" = no)
782if test "$ac_cv_func_getopt_long" = no; then
783  case "$host_os" in
784    amigaos|morphos)
785      dnl Our getopt_long replacement doesn't work, so don't use it
786      ;;
787    *)
788      compat_getopt=yes
789      missing_routines="$missing_routines"'getopt_long '
790      ;;
791  esac
792fi
793AM_CONDITIONAL(COMPAT_GETOPT, test "$compat_getopt" = yes)
794if test "$ac_cv_func_mkstemp" = no; then
795  missing_routines="$missing_routines"'mkstemp '
796fi
797AM_CONDITIONAL(COMPAT_MKSTEMP, test "$ac_cv_func_mkstemp" = no)
798if test "x$missing_routines" = x; then
799  missing_routines='(none)'
800fi
801AC_MSG_RESULT($missing_routines)
802
803dnl Work out which compatibility routines to use
804AC_MSG_CHECKING(which compatibility routines to use)
805case "$host_os" in
806  amigaos)
807    COMPAT_OSNAME='amiga'
808    ;;
809  linux*)
810    COMPAT_OSNAME='linux'
811    ;;
812  morphos)
813    COMPAT_OSNAME='morphos'
814    ;;
815  mingw32*)
816    COMPAT_OSNAME='win32'
817    ;;
818  wii)
819    COMPAT_OSNAME='wii'
820    ;;
821  *)
822    COMPAT_OSNAME='unix'
823    ;;
824esac
825AC_MSG_RESULT($COMPAT_OSNAME)
826COMPAT_SUBDIR="compat/$COMPAT_OSNAME"
827AC_SUBST(COMPAT_SUBDIR)
828AC_SUBST(COMPAT_OSNAME)
829AM_CONDITIONAL(COMPAT_WIN32, test "$COMPAT_OSNAME" = 'win32')
830
831dnl Decide whether to install desktop and mime files
832AC_ARG_ENABLE(desktop-integration,
833AS_HELP_STRING([--enable-desktop-integration], [add menu entry and file associations]),
834if test "$enableval" = yes; then desktopintegration=yes; else desktopintegration=no; fi,
835desktdesktopintegration=no)
836AC_MSG_CHECKING(whether to install desktop file)
837AC_MSG_RESULT($desktopintegration)
838AM_CONDITIONAL(DESKTOP_INTEGRATION, test "$desktopintegration" = yes)
839AC_CHECK_PROGS(GTK_UPDATE_ICON_CACHE,gtk-update-icon-cache,true)
840
841dnl Where to install the desktop and mime files
842AC_ARG_WITH(desktop-dir,
843AS_HELP_STRING([--with-desktop-dir=DIR], [location of desktop files (default=datadir)]),
844if test "$withval" = no; then desktopdir=no; else desktopdir=yes; fi,
845desktopdir=no)
846if test "$desktopdir" = yes; then
847  DESKTOP_DATADIR=$with_desktop_dir
848else
849  DESKTOP_DATADIR="$datadir"
850fi
851AM_CONDITIONAL(DESKTOP_DATADIR, test "$desktopdir" == yes)
852AC_SUBST(DESKTOP_DATADIR)
853
854dnl Do we want the low memory compile?
855AC_MSG_CHECKING(whether low memory compile requested)
856AC_ARG_ENABLE(smallmem,
857[  --enable-smallmem       low memory compile needed],
858if test "$enableval" = yes; then
859    smallmem=yes;
860else
861    smallmem=no;
862fi,
863smallmem=no)
864if test "$smallmem" = no; then
865    AC_DEFINE([HAVE_ENOUGH_MEMORY], 1, [Defined if we've got enough memory to compile z80_ops.c])
866fi
867AC_MSG_RESULT($smallmem)
868
869dnl Do we want lots of warning messages?
870AC_MSG_CHECKING(whether lots of warnings requested)
871AC_ARG_ENABLE(warnings,
872[  --enable-warnings       give lots of warnings if using gcc],
873if test "$enableval" = yes; then
874    warnings=yes;
875else
876    warnings=no;
877fi,
878warnings=no)
879AC_MSG_RESULT($warnings)
880
881dnl If it appears we're using gcc as our compiler, turn on warnings
882if test "$ac_cv_prog_gcc" = yes; then
883    CFLAGS="$CFLAGS -Wall"
884    dnl And possibly lots of warnings
885    if test "$warnings" = yes; then
886        CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Winline -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -W -Wsign-compare"
887    fi
888fi
889
890AC_CONFIG_FILES([
891Makefile
892compat/amiga/Makefile
893compat/linux/Makefile
894compat/morphos/Makefile
895compat/unix/Makefile
896compat/wii/Makefile
897compat/win32/Makefile
898data/Makefile
899debugger/Makefile
900hacking/Makefile
901lib/Makefile
902machines/Makefile
903man/Makefile
904peripherals/Makefile
905peripherals/disk/Makefile
906peripherals/ide/Makefile
907peripherals/nic/Makefile
908peripherals/flash/Makefile
909perl/Makefile
910perl/Fuse/Makefile
911pokefinder/Makefile
912roms/Makefile
913sound/Makefile
914timer/Makefile
915ui/Makefile
916ui/fb/Makefile
917ui/wii/Makefile
918ui/gtk/Makefile
919ui/svga/Makefile
920ui/sdl/Makefile
921ui/scaler/Makefile
922ui/widget/Makefile
923ui/win32/fuse.manifest
924ui/win32/Makefile
925ui/win32/icons/Makefile
926ui/win32/installer/fuse.nsi
927ui/xlib/Makefile
928unittests/Makefile
929z80/Makefile
930z80/tests/Makefile])
931
932AC_OUTPUT
933