1dnl Process this file with autoconf to produce a configure script.
2
3dnl This program is free software; you can redistribute it and/or modify
4dnl it under the terms of the GNU General Public License as published by
5dnl the Free Software Foundation; either version 2 of the License, or
6dnl (at your option) any later version.
7dnl
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11dnl GNU General Public License for more details.
12dnl
13dnl You should have received a copy of the GNU General Public License along
14dnl with this program; if not, write to the Free Software Foundation, Inc.,
15dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16dnl
17dnl Author contact information:
18dnl
19dnl E-mail: philip-fuse@shadowmagic.org.uk
20
21dnl Package version
22m4_define([fuse_utils_version], [1.4.3])
23
24dnl Product full version
25m4_define([fuse_utils_major_version], [1])
26m4_define([fuse_utils_minor_version], [4])
27m4_define([fuse_utils_micro_version], [3])
28m4_define([fuse_utils_nano_version],  [0])
29m4_define([fuse_utils_full_version],
30          [fuse_utils_major_version.fuse_utils_minor_version.fuse_utils_micro_version.fuse_utils_nano_version])
31m4_define([fuse_utils_rc_version],
32          [fuse_utils_major_version,fuse_utils_minor_version,fuse_utils_micro_version,fuse_utils_nano_version])
33
34dnl Package info
35m4_define([fuse_url], [http://fuse-emulator.sourceforge.net/])
36m4_define([fuse_bugreport], [http://sourceforge.net/p/fuse-emulator/bugs/])
37
38AC_INIT([fuse-utils],[fuse_utils_version],[fuse_bugreport],
39        [fuse-utils],[fuse_url])
40AC_CONFIG_SRCDIR([tzxlist.c])
41AC_CONFIG_MACRO_DIR([m4])
42AC_CONFIG_HEADERS([config.h])
43AC_CANONICAL_HOST
44
45dnl Use automake to produce `Makefile.in'
46AM_INIT_AUTOMAKE([1.11 subdir-objects])
47AM_SILENT_RULES([yes])
48
49dnl Definitions for config.h
50AC_DEFINE([FUSE_UTILS_RC_VERSION], [fuse_utils_rc_version],
51          [Define version information for win32 executables])
52
53dnl Checks for programs.
54AC_PROG_CC
55AC_PROG_CXX
56LT_INIT
57
58dnl Check for host specific programs.
59case "$host_os" in
60  mingw32*)
61    AC_CHECK_TOOL([WINDRES], [windres])
62    AC_CHECK_PROGS([MAN2HTML], [man2html])
63    AC_CHECK_PROGS([GROFF], [groff])
64    AC_CHECK_PROGS([UNIX2DOS], [unix2dos])
65    ;;
66esac
67AM_CONDITIONAL([HAVE_WINDRES], [test "$WINDRES" != ""])
68
69dnl Check non C89 functions
70AC_CHECK_FUNCS(fdopen signal)
71
72dnl Check for big endianness
73AC_C_BIGENDIAN
74
75dnl Check for header files
76AC_CHECK_HEADERS(strings.h)
77AC_CHECK_HEADERS(termios.h)
78
79dnl Check for zlib (the UNIX version is called z, Win32 zdll)
80AC_MSG_CHECKING(whether to use zlib)
81AC_ARG_WITH(zlib,
82[  --without-zlib          don't use zlib],
83if test "$withval" = no; then zlib=no; else zlib=yes; fi,
84zlib=yes)
85AC_MSG_RESULT($zlib)
86have_zlib="no"
87if test "$zlib" = yes; then
88  AC_CHECK_HEADERS(
89    zlib.h,
90    [AC_SEARCH_LIBS(compress2, z zdll)
91     have_zlib="yes"]
92  )
93fi
94
95dnl Allow the user to say that various libraries are in one place
96AC_ARG_WITH(local-prefix,
97[  --with-local-prefix=PFX local libraries installed in PFX (optional)],
98CPPFLAGS="$CPPFLAGS -I$withval/include";
99CXXFLAGS="$CXXFLAGS -I$withval/include";
100LDFLAGS="$LDFLAGS -L$withval/lib",
101if test "$prefix" != "NONE"; then
102  CPPFLAGS="$CPPFLAGS -I$prefix/include";
103  CXXFLAGS="$CXXFLAGS -I$prefix/include";
104  LDFLAGS="$LDFLAGS -L$prefix/lib"
105fi)
106
107dnl Check if libjpeg is available and supports jpeg_write_scanlines
108AC_MSG_CHECKING(whether to use libjpeg)
109AC_ARG_WITH(libjpeg,
110  [  --without-libjpeg        don't use libjpeg],
111  if test "$withval" = no; then libjpeg=no; else libjpeg=yes; fi,
112  libjpeg=yes
113)
114AC_MSG_RESULT($libjpeg)
115
116have_libjpeg="no"
117if test "$libjpeg" = yes; then
118  AC_CHECK_HEADER(
119    jpeglib.h,
120    [AC_CHECK_LIB( jpeg, jpeg_write_scanlines,
121      [AC_DEFINE([USE_LIBJPEG], 1,
122        [Defined if we're going to be using the installed libjpeg])
123        JPEG_LIBS='-ljpeg'
124        have_libjpeg="yes"],
125      [AC_MSG_WARN(jpeg_write_scanlines not found - jpeg output not supported...)],
126    )],
127    [AC_MSG_WARN(jpeglib.h not found - jpeg output not supported...)]
128  )
129fi
130AM_CONDITIONAL(HAVE_LIBJPEG, test "$have_libjpeg" = "yes")
131AC_SUBST(JPEG_LIBS)
132
133dnl Check if a version of libpng which supplies png_write_png is available
134AC_MSG_CHECKING(whether to use libpng)
135AC_ARG_WITH(libpng,
136  [  --without-libpng        don't use libpng],
137  if test "$withval" = no; then libpng=no; else libpng=yes; fi,
138  libpng=yes
139)
140AC_MSG_RESULT($libpng)
141have_libpng="no"
142if test "$libpng" = yes; then
143  AC_CHECK_HEADER(
144    png.h,
145    [AC_CHECK_LIB( png, png_write_png,
146      [AC_DEFINE([USE_LIBPNG], 1,
147        [Defined if we're going to be using the installed libpng])
148        PNG_LIBS='-lpng'
149        have_libpng="yes"],
150      [AC_MSG_WARN(png_write_png not found - PNG output not supported...)],
151    )],
152    [AC_MSG_WARN(png.h not found - PNG output not supported...)]
153  )
154fi
155AM_CONDITIONAL(HAVE_LIBPNG, test "$have_libpng" = "yes")
156AC_SUBST(PNG_LIBS)
157
158dnl Check whether to use libgcrypt
159AC_MSG_CHECKING(whether to use libgcrypt)
160AC_ARG_WITH(libgcrypt,
161[  --without-libgcrypt     don't use libgcrypt],
162if test "$withval" = no; then libgcrypt=no; else libgcrypt=yes; fi,
163libgcrypt=yes)
164AC_MSG_RESULT($libgcrypt)
165if test "$libgcrypt" = yes; then
166  AC_CHECK_HEADERS(gcrypt.h,LIBS="$LIBS -lgcrypt",libgcrypt=no)
167fi
168AM_CONDITIONAL(BUILD_RZXCHECK, test "$libgcrypt" = yes)
169
170dnl Do we want lots of warning messages?
171AC_MSG_CHECKING(whether lots of warnings requested)
172AC_ARG_ENABLE(warnings,
173[  --enable-warnings       give lots of warnings if using gcc],
174if test "$enableval" = yes; then
175    warnings=yes;
176else
177    warnings=no;
178fi,
179warnings=no)
180AC_MSG_RESULT($warnings)
181
182dnl If it appears we're using gcc as our compiler, turn on warnings
183if test "$ac_cv_c_compiler_gnu" = yes; then
184    CFLAGS="$CFLAGS -Wall"
185    CXXFLAGS="$CXXFLAGS -Wall"
186    dnl And possibly lots of warnings
187    if test "$warnings" = yes; then
188        CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Winline -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -W -Wsign-compare"
189    fi
190fi
191
192dnl Check that libspectrum is available and that it is new enough
193PKG_CHECK_MODULES([LIBSPECTRUM], [libspectrum >= 1.4.3])
194
195dnl Check if supplied libspectrum has its own internal GLib replacement
196AC_MSG_CHECKING(whether libspectrum has its own internal GLib replacement)
197ac_save_CPPFLAGS="$CPPFLAGS"
198CPPFLAGS="$CPPFLAGS $LIBSPECTRUM_CFLAGS"
199AC_PREPROC_IFELSE(
200  [AC_LANG_SOURCE([
201#include <libspectrum.h>
202#if LIBSPECTRUM_HAS_GLIB_REPLACEMENT == 0
203#error "GLib replacement not found"
204#endif
205  ])],
206  [fakeglib=yes; AC_MSG_RESULT(yes)],
207  [fakeglib=no; AC_MSG_RESULT(no)]
208)
209CPPFLAGS="$ac_save_CPPFLAGS"
210
211# If we're not libspectrum's own internal GLib replacement, we must use the
212# real thing
213AS_IF([test "$fakeglib" = no], [
214  PKG_CHECK_MODULES(
215    [GLIB],
216    [glib-2.0 >= 2.0.0],
217    [AC_DEFINE([HAVE_LIB_GLIB], 1, [Defined if we've got GLib])
218      LIBSPECTRUM_LIBS="$LIBSPECTRUM_LIBS $GLIB_LIBS"],
219    [AC_MSG_ERROR([GLib not found, and libspectrum has no internal replacement])]
220  )
221])
222
223# Look for audiofile (default=yes)
224AC_MSG_CHECKING(whether to use audiofile)
225AC_ARG_WITH(audiofile,
226[  --without-audiofile     don't use audiofile],
227if test "$withval" = no; then audiofile=no; else audiofile=yes; fi,
228audiofile=yes)
229AC_MSG_RESULT($audiofile)
230if test "$audiofile" = yes; then
231  PKG_CHECK_MODULES(
232    AUDIOFILE,
233    audiofile,
234    AC_DEFINE([HAVE_LIB_AUDIOFILE], 1, [Defined if we've got audiofile]),
235    true
236  )
237  if test -z "$AUDIOFILE_LIBS"; then
238    AM_PATH_AUDIOFILE(
239      0.2.3,
240      AC_DEFINE([HAVE_LIB_AUDIOFILE], 1, [Defined if we've got audiofile]),
241      audiofile=no
242    )
243  fi
244fi
245AM_CONDITIONAL(BUILD_AUDIOTOOLS, test "$audiofile" = yes)
246
247# Look for iconv (default=yes)
248AC_MSG_CHECKING(whether to use iconv)
249AC_ARG_WITH(iconv,
250[  --without-iconv         don't use iconv],
251if test "$withval" = no; then iconv=no; else iconv=yes; fi,
252iconv=yes)
253AC_MSG_RESULT($iconv)
254if test "$iconv" = yes; then
255  AC_CHECK_HEADERS(locale.h)
256  AC_CHECK_FUNCS(setlocale)
257  AM_ICONV()
258fi
259AC_SUBST(LTLIBICONV)
260
261dnl Work out which compatibility routines to use
262AC_MSG_CHECKING(which compatibility routines to use)
263case "$host_os" in
264  amigaos)
265    COMPAT_OSNAME='amiga'
266    ;;
267  mingw32*)
268    COMPAT_OSNAME='win32'
269    ;;
270  *)
271    COMPAT_OSNAME='unix'
272  ;;
273esac
274AC_MSG_RESULT($COMPAT_OSNAME)
275AM_CONDITIONAL(COMPAT_AMIGA, test "$COMPAT_OSNAME" = 'amiga')
276AM_CONDITIONAL(COMPAT_UNIX, test "$COMPAT_OSNAME" = 'unix')
277AM_CONDITIONAL(COMPAT_WIN32, test "$COMPAT_OSNAME" = 'win32')
278
279if test "$ac_cv_func_getopt_long" = no; then
280  case "$host_os" in
281    amigaos|morphos)
282      dnl Our getopt_long replacement doesn't work, so don't use it
283      ;;
284    *)
285      compat_getopt=yes
286      missing_routines="$missing_routines"'getopt_long '
287      ;;
288  esac
289fi
290AM_CONDITIONAL(COMPAT_GETOPT, test "$compat_getopt" = yes)
291if test "$ac_cv_func_mkstemp" = no; then
292  missing_routines="$missing_routines"'mkstemp '
293fi
294
295AC_CONFIG_FILES([
296  Makefile
297  fuse-utils.qpg
298])
299
300AC_OUTPUT
301
302dnl Status summary
303echo ""
304echo "***********************************************"
305echo "*** The Fuse utils are ready to be compiled ***"
306echo "***********************************************"
307echo ""
308echo "zlib support: $have_zlib"
309echo "libjpeg support: $have_libjpeg"
310echo "libpng support: $have_libpng"
311echo "libgcrypt support: $libgcrypt"
312echo "libaudiofile support: $audiofile"
313echo "libspectrum's internal GLib replacement: $fakeglib"
314echo ""
315echo "Type 'make' to compile the Fuse utils"
316echo ""
317