1AC_INIT(ocp, 0.2.90, stian.skjelstad@gmail.com)
2AC_DEFINE(DLLVERSION, [0x0000025a])
3
4AC_CANONICAL_HOST
5
6
7AC_MSG_CHECKING([GIT submodules are checked out])
8if ! test -f playgmi/timidity-git/Makefile.am; then
9  AC_MSG_ERROR([playgmi/timidity-git is missing - please execute 'git submodule update --init --recursive'])
10else
11  AC_MSG_RESULT([ok])
12fi
13
14AC_ARG_WITH(debug, [  --with-debug            compile with debug-flags and without SIGALRM],
15if test "x$with_debug" = "xyes"; then
16for i in $CFLAGS; do
17  new_CFLAGS="$new_CFLAGS `echo $i|grep -- -L`";
18  new_CFLAGS="$new_CFLAGS `echo $i|grep -- -I`";
19done;
20CFLAGS="$new_CFLAGS -g"
21for i in $CXXFLAGS; do
22  new_CXXFLAGS="$new_CFLAGS `echo $i|grep -- -L`";
23  new_CXXFLAGS="$new_CFLAGS `echo $i|grep -- -I`";
24done;
25CXXFLAGS="$new_CXXFLAGS -g"
26AC_DEFINE(KICKSTART_GDB, 1) AC_DEFINE(DISABLE_SIGALRM)
27fi
28)
29
30AC_HEADER_TIME
31
32AC_PROG_CC
33AX_PROG_CC_FOR_BUILD
34AC_PROG_CXX
35AC_PROG_CPP
36AC_PROG_CXXCPP
37AC_PROG_MAKE_SET
38AC_SUBST(DESKTOP_FILE_INSTALL)
39
40AC_C_BIGENDIAN
41
42AC_SUBST(SHARED_FLAGS)
43AC_SUBST(LIB_SUFFIX)
44AC_SUBST(PTHREAD_LIBS)
45AC_SUBST(HAIKU)
46target=`$CC -dumpmachine`
47case "$target" in
48	*-darwin*)
49		SHARED_FLAGS="-dynamiclib -flat_namespace -undefined suppress"
50		CFLAGS="$CFLAGS -fno-common"
51		CXXFLAGS="$CXXFLAGS -fno-common"
52		LIB_SUFFIX=.dylib
53		PTHREAD_LIBS=-pthread
54		;;
55	*-haiku*)
56		SHARED_FLAGS=-shared
57		LIB_SUFFIX=.so
58		PTHREAD_LIBS=
59		with_desktop_file_install=no
60		HAIKU=1
61		;;
62	*)
63		SHARED_FLAGS=-shared
64		LIB_SUFFIX=.so
65		PTHREAD_LIBS=-pthread
66		;;
67esac
68AC_DEFINE_UNQUOTED(LIB_SUFFIX, "$LIB_SUFFIX")
69
70AC_SUBST(DIR_SUFFIX)
71AC_ARG_WITH(dir_suffix, [  --with-dir-suffix=      append this on all paths. Defaults to -$PACKAGE_VERSION], DIR_SUFFIX=$with_dir_suffix, DIR_SUFFIX=-$PACKAGE_VERSION)
72AC_DEFINE_UNQUOTED(DIR_SUFFIX, "$DIR_SUFFIX")
73
74AC_ARG_WITH(x11, [  --with-x11              force/disable x11 support],, with_x11=auto)
75
76AC_ARG_WITH(adplug, [  --with-adplug           force/disable adplug support],, with_adplug=auto)
77
78AC_ARG_WITH(mad, [  --with-mad              force/disable mad mpeg audio support],, with_mad=auto)
79
80AC_ARG_WITH(alsa, [  --with-alsa             force/disable alsa support],, with_alsa=auto)
81AC_ARG_WITH(oss,  [  --with-oss              force/disable oss support],, with_oss=auto)
82
83AC_ARG_WITH(lzw, [  --with-lzw              force/disable lzw support (enabled by default)],, with_lzw=yes)
84
85AC_ARG_WITH(lzh, [  --with-lzh              force/disable lzh support in .ym files(enabled by default)],, with_lzh=yes)
86
87AC_ARG_WITH(coreaudio, [  --with-coreaudio        force/disable osx coreaudio support (autodetect by default)],, with_coreaudio=auto)
88AC_ARG_WITH(flac, [  --with-flac             force/disable FLAC support (autodetect by default)],, with_flac=auto)
89
90AC_ARG_WITH(sdl,  [  --with-sdl              force/disable SDL video support (autodetect by default)],, with_sdl=auto)
91AC_ARG_WITH(sdl2, [  --with-sdl2             force/disable SDL2 video support (autodetect by default)],, with_sdl2=auto)
92AC_ARG_WITH(desktop_file_install, [  --without-desktop_file_install Do not install .desktop file (SDL and X11 normally does this)],, with_desktop_file_install=auto)
93
94AC_ARG_WITH(dumptools, [  --with-dumptools        enable building the different fileformat dump utilities],, with_dumptools=no)
95
96AC_ARG_WITH(unifontdir, [  --with-unifontdir=/path the path to where ttf-unifont in located (used by X11, SDL1.x and SDL2)],, with_unifontdir="${datarootdir}/fonts/truetype/unifont")
97
98# normally, this is done automatically first when running AC_OUTPUT, but we need them expanded now
99test "x$prefix" = xNONE && prefix=$ac_default_prefix
100# Let make expand exec_prefix.
101test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
102
103AC_DEFUN([AS_AC_EXPAND],
104[
105  EXP_VAR=[$1]
106  FROM_VAR=[$2]
107dnl first expand prefix and exec_prefix if necessary
108  prefix_save=$prefix
109  exec_prefix_save=$exec_prefix
110dnl if no prefix given, then use /usr/local, the default prefix
111  full_var="$FROM_VAR"
112dnl loop until it doesn"t change anymore
113  while true; do
114    new_full_var="`eval echo $full_var`"
115    if test "x$new_full_var" = "x$full_var"; then break; fi
116    full_var=$new_full_var
117  done
118dnl clean up
119  full_var=$new_full_var
120  AC_SUBST([$1], "$full_var")
121dnl restore prefix and exec_prefix
122  prefix=$prefix_save
123  exec_prefix=$exec_prefix_save
124])
125
126AC_MSG_CHECKING([gcc version])
127cc_version=`( $CC -dumpversion ) 2>&1`
128if test "$?" -gt 0 || test x$cc_version = x; then
129	AC_MSG_ERROR([not found])
130else
131	case $cc_version in
132		'')
133			AC_MSG_ERROR([not found]);
134			;;
135# old GCC versions in the 2.95.xx family are known to produce bad crashing binaries (it is still out there on some old systems. In general the all versions before 3.0 is risky
136		2.95.[[2-9]]|2.95.[[2-9]][[-]].*)
137			AC_MSG_ERROR([$cc_version, bad])
138			;;
139		*)
140			AC_MSG_RESULT([$cc_version, ok])
141			;;
142       esac
143fi
144
145AC_MSG_CHECKING([for broken signed char to signed int in loops (gcc version 4.1.1)])
146AC_RUN_IFELSE(
147[AC_LANG_SOURCE([
148#include <stdio.h>
149#include <unistd.h>
150void failcheck(signed int source, signed int filter)
151{
152	if ((source>128)&&(filter>0))
153		_exit(1);
154}
155
156int main(int arg, char *argv@<:@@:>@)
157{
158	int j;
159	for (j=0; j<256; j++)
160	{
161		signed char j2=(signed char)j;
162		signed int j3=j2;
163		failcheck(j, j3);
164	}
165	return 0;
166}
167])],
168	AC_MSG_RESULT([ok]),
169	AC_MSG_ERROR([failed.
170Try to remove any -O flag or to add -fwrapv to CFLAGS and CXXFLAGS]),
171AC_DEFINE(GCC_411_RUNTIMECHECK, 1)
172)
173
174AC_MSG_CHECKING([for PIC])
175org_cflags="$CFLAGS"
176CFLAGS="$CFLAGS -fPIC"
177AC_LINK_IFELSE(
178	[AC_LANG_PROGRAM([[]],[[]])],
179	[AC_MSG_RESULT(-fPIC)
180	CXXFLAGS="$CXXFLAGS -fPIC"]
181	,
182	[CFLAGS="$org_cflags -fpic"
183	AC_LINK_IFELSE(
184		[AC_LANG_PROGRAM([[]],[[]])],
185		[AC_MSG_RESULT(-fpic)
186		CXXFLAGS="$CXXFLAGS -fpic"]
187		,
188		[CFLAGS="$org_cflags"
189		AC_MSG_RESULT(not supported)]
190	])
191)
192
193AC_CHECK_FUNCS(memmem)
194AC_CHECK_FUNCS(getopt)
195AC_CHECK_FUNCS(popen)
196AC_CHECK_FUNCS(qsort)
197AC_CHECK_FUNCS(gettimeofday)
198AC_CHECK_FUNCS(sleep)
199AC_CHECK_FUNCS(sysconf)
200AC_CHECK_FUNCS(strerror)
201AC_CHECK_FUNCS(strdup)
202AC_CHECK_FUNCS(strstr)
203AC_CHECK_FUNCS(strupr)
204AC_CHECK_FUNCS(getcwd)
205AC_CHECK_FUNCS(snprintf)
206AC_CHECK_FUNCS(usleep)
207AC_CHECK_FUNCS(vsnprintf)
208AC_CHECK_FUNCS(strncasecmp)
209AC_CHECK_FUNCS(mkstemp)
210AC_CHECK_FUNCS(strlcpy)
211AC_CHECK_FUNCS(strlcat)
212
213AC_SUBST(MATH_LIBS)
214AC_CHECK_FUNCS(sqrt,
215               MATH_LIBS=,
216               AC_CHECK_LIB(m,
217                            sqrt,
218                            MATH_LIBS=-lm,
219                            AC_MSG_ERROR("libm not found")
220                           )
221              )
222
223AC_STRUCT_DIRENT_D_TYPE
224
225AC_CONFIG_HEADERS([config.h] [playsid/sidplayfp-config/config.h])
226
227AC_HEADER_STDC
228
229AC_CHECK_HEADER(dirent.h,
230                AC_DEFINE(HAVE_DIRENT_H, 1),
231               )
232AC_CHECK_HEADER(fcntl.h,
233                AC_DEFINE(HAVE_FCNTL_H, 1),
234               )
235AC_CHECK_HEADER(getopt.h,
236                AC_DEFINE(HAVE_GETOPT_H, 1),
237               )
238AC_CHECK_HEADER(ndir.h,
239                AC_DEFINE(HAVE_NDIR_H, 1),
240               )
241AC_CHECK_HEADER(sys/ndir.h,
242                AC_DEFINE(HAVE_SYS_NDIR_H, 1),
243               )
244AC_CHECK_HEADER(sys/dir.h,
245                AC_DEFINE(HAVE_SYS_DIR_H, 1),
246               )
247AC_CHECK_HEADER(stdint.h,
248                AC_DEFINE(HAVE_STDINT_H, 1),
249               )
250AC_CHECK_HEADER(inttypes.h,
251                AC_DEFINE(HAVE_INTTYPES_H, 1),
252               )
253AC_CHECK_HEADER(byteswap.h,
254                AC_DEFINE(HAVE_BYTESWAP_H, 1),
255               )
256AC_CHECK_HEADER(unistd.h,
257                AC_DEFINE(HAVE_UNISTD_H, 1),
258               )
259AC_CHECK_HEADER(limits.h,
260                AC_DEFINE(HAVE_LIMITS_H, 1),
261               )
262AC_CHECK_HEADER(string.h,
263                AC_DEFINE(HAVE_STRING_H, 1),
264                [ AC_DEFINE(NO_STRING_H,1,Define to 1 if you do not have <string.h>.)]
265               )
266AC_CHECK_HEADER(strings.h,
267                AC_DEFINE(HAVE_STRINGS_H, 1),
268               )
269AC_CHECK_HEADER(errno.h,
270                AC_DEFINE(HAVE_ERRNO_H, 1),
271               )
272AC_CHECK_HEADER(sys/cdefs.h,
273                AC_DEFINE(HAVE_SYS_CDEFS_H, 1),
274               )
275AC_CHECK_HEADER(sys/stat.h,
276                AC_DEFINE(HAVE_SYS_STAT_H, 1),
277               )
278AC_CHECK_HEADER(sys/time.h,
279                AC_DEFINE(HAVE_SYS_TIME_H, 1),
280               )
281AC_CHECK_HEADER(sys/types.h,
282                AC_DEFINE(HAVE_SYS_TYPES_H, 1),
283               )
284AC_CHECK_HEADER(sys/param.h,
285                AC_DEFINE(HAVE_SYS_PARAM_H, 1),
286               )
287AC_CHECK_HEADER(machine/endian.h,
288                AC_DEFINE(HAVE_MACHINE_ENDIAN_H, 1),
289               )
290AC_CHECK_HEADER(pwd.h,
291                AC_DEFINE(HAVE_PWD_H, 1),
292               )
293
294AC_CHECK_FUNC(getpwnam, HAVE_GETPWNAM=1; AC_DEFINE(HAVE_GETPWNAM) )
295
296dnl timidity patch dir
297AC_ARG_WITH(timidity-default-path,
298  AS_HELP_STRING([--with-timidity-default-path=DIR], [Where timidity.cfg is  (PREFIX/share/timidity)]),
299  [timiditypkgdatadir=$withval],
300  [
301   if test "x$prefix" != "xNONE"; then
302      timiditypkgdatadir='${prefix}/share/timidity'
303   else
304      timiditypkgdatadir='/usr/local/share/timidity'
305   fi
306  ])
307tmpdefpath="`eval \"echo ${timiditypkgdatadir}\"`"
308AC_DEFINE_UNQUOTED(TIMIDITY_DEFAULT_PATH,"$tmpdefpath",place to install patches)
309AC_DEFINE(TIMIDITYPKGDATADIR,TIMIDITY_DEFAULT_PATH,a compatibility matter. ignore it.)
310
311dnl We first check for ncursesw, if that fails we revert back to ncurses
312AX_WITH_CURSES
313if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
314	AC_MSG_ERROR([requires either NcursesW or Ncurses library])
315fi
316if test "x$ax_cv_curses_color" != xyes; then
317	AC_MSG_ERROR([requires an X/Open-compatible Curses library with color])
318fi
319push_LIBS=$LIBS
320LIBS=$CURSES_LIB
321AC_CHECK_FUNCS(resize_term)
322LIBS=$push_LIBS
323
324AC_CHECK_LIB(z, zlibVersion, , AC_MSG_ERROR("zlib not found"))
325AC_CHECK_HEADER(zlib.h, , AC_MSG_ERROR("zlib header files was not found"))
326
327AC_CHECK_LIB(bz2, BZ2_bzDecompress, , AC_MSG_ERROR([bzip2 library not found (libbz2-dev)]))
328AC_CHECK_HEADER(bzlib.h, , AC_MSG_ERROR([bzip2 header file not found (libbz2-dev)]))
329
330AC_SUBST(DL_LIBS)
331dnl -lc is dirty hack here
332push_LIBS=$LIBS
333LIBS=
334dnl refresh LIB list
335AC_LANG_PUSH(C)
336AC_CHECK_FUNC(dlopen, DL_LIBS="",AC_CHECK_LIB(dl, dlopen, DL_LIBS="-ldl", AC_MSG_ERROR("dlopen not found")))
337LIBS=$push_LIBS
338AC_LANG_POP
339
340AC_SUBST(MAD_CFLAGS)
341AC_SUBST(MAD_LIBS)
342AC_SUBST(LIBJPEG_CFLAGS)
343AC_SUBST(LIBJPEG_LIBS)
344AC_SUBST(LIBPNG_CFLAGS)
345AC_SUBST(LIBPNG_LIBS)
346if test "x$with_mad" != "xno"; then
347	AC_MSG_CHECKING([mad support])
348	MAD_LIBS=`pkg-config --libs mad 2> /dev/null`
349	MAD_CFLAGS=`pkg-config --cflags mad 2> /dev/null`
350	if test "$?" = 0; then
351		AC_MSG_RESULT("$MAD_CFLAGS $MAD_LIBS")
352	else
353		AC_MSG_RESULT([pkg-config failed]);
354	dnl Fall back to non-pkg-config method
355		AC_CHECK_LIB(mad, mad_stream_init, , if test "x$with_mad" = "xyes"; then AC_MSG_ERROR("libmad not found"); else with_mad="no"; fi)
356		if test "x$with_mad" != "xno"; then
357			AC_CHECK_HEADER(mad.h, , if test "x$with_mad" = "xyes"; then AC_MSG_ERROR("libmad header files was not found"); else with_mad="no"; fi)
358		fi
359		if test "x$with_mad" != "xno"; then
360			MAD_LIBS="-lmad"
361			MAD_CFLAGS=""
362			LIBS=$push_LIBS
363		fi
364	fi
365fi
366
367AC_MSG_CHECKING([libjpeg / libjpeg-turbo support])
368LIBJPEG_LIBS=`pkg-config --libs libjpeg 2> /dev/null`
369LIBJPEG_CFLAGS=`pkg-config --cflags libjpeg 2> /dev/null`
370if test "$?" = 0; then
371	AC_MSG_RESULT("$LIBJPEG_CFLAGS $LIBJPEG_LIBS")
372else
373	AC_MSG_ERROR([pkg-config failed]);
374fi
375
376AC_MSG_CHECKING([libpng support])
377LIBPNG_LIBS=`pkg-config --libs libpng 2> /dev/null`
378LIBPNG_CFLAGS=`pkg-config --cflags libpng 2> /dev/null`
379if test "$?" = 0; then
380	AC_MSG_RESULT("$LIBPNG_CFLAGS $LIBPNG_LIBS")
381else
382	AC_MSG_ERROR([pkg-config failed]);
383fi
384
385AC_SUBST(HAVE_MAD)
386if test "x$with_mad" = "xno"; then
387	HAVE_MAD=0
388else
389	HAVE_MAD=1
390	AC_DEFINE(HAVE_MAD)
391fi
392
393AC_SUBST(OGG_CFLAGS)
394AC_SUBST(OGG_LIBS)
395AC_MSG_CHECKING([ogg support])
396OGG_LIBS=`pkg-config --libs ogg 2> /dev/null`
397OGG_CFLAGS=`pkg-config --cflags ogg 2> /dev/null`
398if test "$?" = 0; then
399	AC_MSG_RESULT("$OGG_CFLAGS $OGG_LIBS")
400else
401	AC_MSG_RESULT([pkg-config failed]);
402dnl Fall back to non-pkg-config method
403	AC_CHECK_LIB(ogg, ogg_sync_init, , AC_MSG_ERROR("ogg libraries not found"))
404	OGG_LIBS="-logg"
405	OGG_CFLAGS=""
406	LIBS=$push_LIBS
407fi
408
409AC_SUBST(VORBIS_CFLAGS)
410AC_SUBST(VORBIS_LIBS)
411AC_MSG_CHECKING([vorbis support])
412VORBIS_LIBS=`pkg-config --libs vorbis 2> /dev/null`
413VORBIS_CFLAGS=`pkg-config --cflags vorbis 2> /dev/null`
414if test "$?" = 0; then
415	AC_MSG_RESULT("$VORBIS_CFLAGS $VORBIS_LIBS")
416else
417	AC_MSG_RESULT([pkg-config failed]);
418dnl Fall back to non-pkg-config method
419	AC_CHECK_LIB(vorbis, vorbis_bitrate_init, , AC_MSG_ERROR("vorbis libraries not found"), -logg)
420	AC_CHECK_HEADER(vorbis/codec.h, , AC_MSG_ERROR("libvorbis header files was not found"))
421	VORBIS_LIBS="-lvorbis"
422	VORBIS_CFLAGS=""
423	LIBS=$push_LIBS
424fi
425
426AC_SUBST(VORBISFILE_CFLAGS)
427AC_SUBST(VORBISFILE_LIBS)
428AC_MSG_CHECKING([vorbisfile support])
429VORBISFILE_LIBS=`pkg-config --libs vorbisfile 2> /dev/null`
430VORBISFILE_CFLAGS=`pkg-config --cflags vorbisfile 2> /dev/null`
431if test "$?" = 0; then
432	AC_MSG_RESULT("$VORBISFILE_CFLAGS $VORBISFILE_LIBS")
433else
434	AC_MSG_RESULT([pkg-config failed]);
435dnl Fall back to non-pkg-config method
436
437	AC_CHECK_LIB(vorbisfile, ov_pcm_seek_lap, AC_DEFINE(HAVE_OV_PCM_SEEK_LAP, 1),
438		AC_CHECK_LIB(vorbisfile, ov_pcm_seek, AC_DEFINE(HAVE_OV_PCM_SEEK, 1), AC_MSG_ERROR("vorbis libraries not found"), -logg -lvorbis)
439	)
440	AC_CHECK_HEADER(vorbis/vorbisfile.h,, AC_MSG_ERROR("libvorbis header files were not found"))
441	VORBISFILE_LIBS="-lvorbisfile"
442	VORBISFILE_CFLAGS=""
443	LIBS=$push_LIBS
444fi
445
446AC_SUBST(FLAC_CFLAGS)
447AC_SUBST(FLAC_LIBS)
448if test "x$with_flac" != "xno"; then
449	AC_CHECK_LIB(FLAC, FLAC__seekable_stream_decoder_process_until_end_of_metadata, FLAC_LIBS="-lFLAC",
450		AC_CHECK_LIB(FLAC, FLAC__stream_decoder_process_until_end_of_metadata, FLAC_LIBS="-lFLAC",
451			if test "x$with_flac" = "xyes"; then AC_MSG_ERROR("libFLAC not found"); else with_flac="no"; fi,
452		-lz),
453	-lz)
454	LIBS=$push_LIBS
455fi
456if test "x$with_flac" != "xno"; then
457	AC_CHECK_HEADER(FLAC/all.h, FLAC_CFLAGS="", if test "x$with_flac" = "xyes"; then AC_MSG_ERROR("libFLAC header files were not found"); else with_flac="no"; fi)
458fi
459AC_SUBST(HAVE_FLAC)
460AC_SUBST(FLAC_INI)
461if test "x$with_flac" = "xno"; then
462	HAVE_FLAC=
463	FLAC_INI=
464else
465	HAVE_FLAC=1
466	FLAC_INI=flacptype
467fi
468
469if test "x$with_x11" != "xno"; then
470	AC_CHECK_HEADER(X11/extensions/xf86vmode.h, , if test "x$with_x11" = "xyes"; then AC_MSG_ERROR("xvidmode header files was not found"); else with_x11="no"; fi,
471[#include <X11/Xlib.h>
472])
473fi
474if test "x$with_x11" != "xno"; then
475	AC_CHECK_HEADER(X11/extensions/XShm.h, , if test "x$with_x11" = "xyes"; then AC_MSG_ERROR("XShm header files was not found"); else with_x11="no"; fi,
476[#include <X11/Xlib.h>
477])
478fi
479if test "x$with_x11" != "xno"; then
480	AC_CHECK_HEADER(X11/xpm.h, , if test "x$with_x11" = "xyes"; then AC_MSG_ERROR("xpm header files was not found"); else with_x11="no"; fi,
481[#include <X11/Xlib.h>
482])
483fi
484if test "x$with_x11" != "xno"; then
485	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, X11_LIBS="-lXpm -lX11 -L/usr/X11R6/lib", if test "x$with_x11" = "xyes"; then AC_MSG_ERROR(["Xpm/X11 not found (expected to be found in /usr/X11R6/lib)"]); else with_x11="no"; fi, -lXpm -lX11 -L/usr/X11R6/lib)
486	LIBS=$push_LIBS
487fi
488if test "x$with_x11" != "xno"; then
489	AC_CHECK_LIB(Xext, XShmQueryExtension, X11_LIBS="-lXext $X11_LIBS", if test "x$with_x11" = "xyes"; then AC_MSG_ERROR(["SHM/X11 not found (expected to be found in /usr/X11R6/lib)"]); else with_x11="no"; fi, -lX11 -lXext -L/usr/X11R6/lib)
490	LIBS=$push_LIBS
491fi
492if test "x$with_x11" != "xno"; then
493	AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, X11_LIBS="-lXxf86vm $X11_LIBS", if test "x$with_x11" = "xyes"; then AC_MSG_ERROR(["xvidmode was not found (expected to be found in /usr/X11R6/lib)"]); else with_x11="no"; fi, -lX11 -lXext -L/usr/X11R6/lib)
494	LIBS=$push_LIBS
495fi
496AC_SUBST(HAVE_X11)
497if test "x$with_x11" = "xno"; then
498	X11_LIBS=
499	HAVE_X11=
500else
501	HAVE_X11=1
502	AC_DEFINE(HAVE_X11)
503fi
504
505if test "x$with_sdl" = "xyes" && test "x$with_sdl2" = "xyes"; then
506	AC_MSG_ERROR("Can not use both --with-sdl and --with-sdl2")
507fi
508
509if test "x$with_sdl" = "xyes"; then
510	with_sdl2="no"
511fi
512
513if test "x$with_sdl2" = "xyes"; then
514	with_sdl="no"
515fi
516
517AC_SUBST(SDL2_CFLAGS)
518AC_SUBST(SDL2_LIBS)
519if test "x$with_sdl2" != "xno"; then
520	AM_PATH_SDL2(["2.0.0"], with_sdl2=yes;, if test "x$with_sdl2" = "xyes"; then AC_MSG_ERROR("libSDL2 was not found"); else with_sdl2="no"; fi)
521fi
522SDL2_CFLAGS=$SDL_CFLAGS
523SDL2_LIBS=$SDL_LIBS
524SDL_CFLAGS=
525SDL_LIBS=
526AC_SUBST(HAVE_SDL2)
527
528if test "x$with_sdl2" = "xno"; then
529	HAVE_SDL2=
530else
531	HAVE_SDL2=1
532	AC_DEFINE(HAVE_SDL2)
533	with_sdl="no"
534fi
535
536org_cflags="$CFLAGS"
537org_cppflags="$CPPFLAGS"
538AC_SUBST(SDL_CFLAGS)
539AC_SUBST(SDL_LIBS)
540if test "x$with_sdl" != "xno"; then
541	AC_MSG_CHECKING([SDL support])
542	SDL_LIBS=`pkg-config --libs sdl 2> /dev/null`
543	SDL_CFLAGS=`pkg-config --cflags sdl 2> /dev/null`
544	if test "$?" = 0; then
545		AC_MSG_RESULT("$SDL_CFLAGS $SDL_LIBS")
546	else
547		AC_MSG_RESULT([pkg-config failed])
548
549		AC_CHECK_LIB(SDL, SDL_Init, SDL_LIBS="-lSDL", if test "x$with_sdl" = "xyes"; then AC_MSG_ERROR("libSDL was not found"); else with_sdl="no"; fi)
550
551		if test "x$with_sdl" != "xno"; then
552			CFLAGS="$CFLAGS -I/usr/include/SDL"
553			CPPFLAGS="$CPPFLAGS -I/usr/include/SDL"
554			AC_CHECK_HEADER(SDL.h, SDL_CFLAGS="-I/usr/include/SDL", if test "x$with_sdl" = "xyes"; then AC_MSG_ERROR("SDL header files not found"); else with_sdl="no"; fi)
555		fi
556	fi
557fi
558AC_SUBST(HAVE_SDL)
559if test "x$with_sdl" = "xno"; then
560	HAVE_SDL=
561else
562	HAVE_SDL=1
563	AC_DEFINE(HAVE_SDL)
564fi
565CFLAGS="$org_cflags"
566CPPFLAGS="$org_cflags"
567
568AC_SUBST(FREETYPE2_LIBS)
569AC_SUBST(FREETYPE2_CFLAGS)
570if test "x$HAVE_SDL" = "x1" || test "x$HAVE_SDL2" = "x1" || test "x$HAVE_X11" = "x1"; then
571	AC_MSG_CHECKING([freetype2 support])
572	FREETYPE2_LIBS=`pkg-config --libs freetype2 2> /dev/null`
573	FREETYPE2_CFLAGS=`pkg-config --cflags freetype2 2> /dev/null`
574	if test "$?" = 0; then
575		AC_MSG_RESULT("$FREETYPE2_CFLAGS $FREETYPE2_LIBS")
576	else
577		AC_MSG_RESULT([pkg-config failed]);
578	dnl Fall back to non-pkg-config method
579		AC_CHECK_LIB(freetype, FT_Init_FreeType, ,AC_MSG_ERROR("libfreetype not found"))
580		AC_CHECK_HEADER(ft2built.h, , AC_MSG_ERROR("libfreetype header files was not found"))
581	fi
582
583dnl locate the ttf-unifont
584	AS_AC_EXPAND(UNIFONTDIR, $with_unifontdir)
585	AC_CHECK_FILE($UNIFONTDIR/unifont.ttf, , AC_MSG_ERROR([$UNIFONTDIR/unifont.ttf not found - please use --with-unifontdir=/path/ (needed by X11, SDL1.x and SDL2)]))
586	AC_CHECK_FILE($UNIFONTDIR/unifont_csur.ttf, , AC_MSG_ERROR([$UNIFONTDIR/unifont_csur.ttf not found - please use --with-unifontdir=/path/ (needed by X11, SDL1.x and SDL2)]))
587	AC_CHECK_FILE($UNIFONTDIR/unifont_upper.ttf, , AC_MSG_ERROR([$UNIFONTDIR/unifont_upper.ttf not found - please use --with-unifontdir=/path/ (needed by X11, SDL1.x and SDL2)]))
588	AC_DEFINE_UNQUOTED(UNIFONTDIR, "$UNIFONTDIR")
589fi
590
591AC_LANG_PUSH(C++)
592org_cxxflags="$CXXFLAGS"
593org_cppflags="$CPPFLAGS"
594AC_SUBST(ADPLUG_CXXFLAGS)
595AC_SUBST(ADPLUG_LIBS)
596if test "x$with_adplug" != "xno"; then
597	AC_MSG_CHECKING([Adplug support])
598	ADPLUG_LIBS=`pkg-config --libs adplug 2> /dev/null`
599	ADPLUG_CXXFLAGS=`pkg-config --cflags adplug 2> /dev/null`
600	if test "$?" = 0; then
601		AC_MSG_RESULT("$ADPLUG_CXXFLAGS $ADPLUG_LIBS")
602	else
603		AC_MSG_RESULT([pkg-config failed]);
604dnl Fall back to non-pkg-config method
605		AC_CHECK_HEADER(adplug/adplug.h, ,with_adplug_failed=yes)
606		if test "x$with_adplug_failed" = "xyes"; then
607			CXXFLAGS="$CXXFLAGS -I/usr/include/libbinio"
608			CPPFLAGS="$CPPFLAGS -I/usr/include/libbinio"
609			unset ac_cv_header_adplug_adplug_h
610			AC_MSG_NOTICE("Trying again with -I/usr/include/libbinio")
611			AC_CHECK_HEADER(adplug/adplug.h,
612				ADPLUG_CXXFLAGS="-I/usr/include/libbinio",
613				if test "x$with_adplug" = "xyes"; then AC_MSG_ERROR("Adplug header files was not found"); else with_adplug="no"; fi
614			)
615		fi
616		if test "x$with_adplug" != "xno"; then
617			AC_CHECK_LIB(adplug, docell0, ADPLUG_LIBS="-ladplug", if test "x$with_adplug" = "xyes"; then AC_MSG_ERROR("Adplug was not found"); else with_adplug="no"; fi)
618			LIBS=$push_LIBS
619		fi
620	fi
621fi
622CXXFLAGS="$org_cxxflags"
623CPPFLAGS="$org_cppflags"
624
625if test "x$with_adplug" != "xno"; then
626AC_MSG_CHECKING([If AdPlug was compiled with another C++ ABI])
627	CXXFLAGS="$CXXFLAGS $ADPLUG_CXXFLAGS"
628	LIBS="$LIBS $ADPLUG_LIBS"
629
630	AC_LINK_IFELSE(
631		[AC_LANG_PROGRAM([[#include <adplug/emuopl.h>]],[[CEmuopl opl = CEmuopl(48000, 1, 1);]])],
632		[],
633		[AC_MSG_ERROR("Adplug was compiled with a different c++ compiler")]
634	)
635
636	AC_RUN_IFELSE(
637		[AC_LANG_PROGRAM([[
638#include <adplug/adplug.h>
639#include <adplug/players.h>
640#include <adplug/player.h>
641                                 ]],[[
642	int j;
643	CPlayers::const_iterator i;
644
645	for (i = CAdPlug::players.begin(); i != CAdPlug::players.end(); i++)
646	{
647		for (j = 0; (*i)->get_extension(j); j++)
648		{
649			if (CFileProvider::extension("OPL", (*i)->get_extension(j)))
650			{
651				return 0;
652			}
653		}
654	}
655	return 0;
656                                 ]])],
657		[AC_MSG_RESULT([ok])],
658		[AC_MSG_ERROR("Adplug was compiled with a different c++ compiler")]
659	)
660	LIBS=$push_LIBS
661	CXXFLAGS="$org_cxxflags"
662	CPPFLAGS="$org_cppflags"
663fi
664
665if test "x$with_adplug" != "xno"; then
666AC_MSG_CHECKING([If libbinio used by AdPlug contains bugs https://github.com/adplug/libbinio/issues/2])
667	CXXFLAGS="$CXXFLAGS $ADPLUG_CXXFLAGS"
668	LIBS="$LIBS $ADPLUG_LIBS"
669
670	AC_RUN_IFELSE(
671		[AC_LANG_PROGRAM([[
672#include <binio.h>
673#include <binstr.h>
674#include <cstdlib>
675#include <string.h>
676#include <adplug/adplug.h>
677#include <adplug/fprovide.h>
678#include <string.h>
679                                 ]],[[
680	binisstream *f = new binisstream((void *)"foobar", 6);
681	long size;
682	char test[6] = {1,2,3,4,5,6};
683
684	f->seek(0, binio::End);
685	size = f->pos();
686	f->seek(0);
687
688	if (f->readString(test, size) != 6) return -1;
689
690	/* test should contain "foobar" if all is correct */
691	return memcmp(test, "foobar", 6);
692                                 ]])],
693		[AC_MSG_RESULT([ok])],
694		[AC_MSG_ERROR("libbinio fails to use memoryobjects")]
695	)
696	LIBS=$push_LIBS
697	CXXFLAGS="$org_cxxflags"
698	CPPFLAGS="$org_cppflags"
699fi
700
701dnl SIDPLAY specifics
702AC_MSG_CHECKING([GIT submodules are checked out])
703if ! test -f playsid/libsidplayfp-git/src/sidemu.cpp; then
704  AC_MSG_ERROR([playsid/libsidplayfp-git is missing - please execute 'git submodule update --init --recursive'])
705else if ! test -f playsid/libsidplayfp-git/src/builders/resid-builder/resid/sid.h; then
706  AC_MSG_ERROR([playsid/libsidplayfp-git/src/builders/resid-builder/resid is missing - please execute 'git submodule update --init --recursive'])
707else
708  AC_MSG_RESULT([ok])
709fi
710
711  AC_MSG_RESULT([ok])
712fi
713origCXX="$CXX"
714origCXXFLAGS="$CXXFLAGS"
715AC_LANG_PUSH([C++])
716HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H=1
717HAVE_SIDPLAYFP_BUILDERS_RESID_H=1
718RESID_INLINING=1
719RESID_INLINE=inline
720AX_CXX_COMPILE_STDCXX_11([noext], [optional])
721AC_ARG_VAR([XA], [6502 assembler - must be full path])
722AC_PATH_PROG([XA],[xa])
723if test -z "$XA"; then
724  AC_MSG_ERROR([xa is needed for compiling 6502 assembler used by libsidplayfp])
725fi
726AC_PATH_PROG([HEXDUMP],[hexdump])
727if test -z "$HEXDUMP"; then
728  AC_MSG_ERROR([hexdump is needed for compiling libsidplayfp])
729fi
730AC_PATH_PROG([PERL], [perl])
731if test -z "$PERL"; then
732  AC_MSG_ERROR([perl is needed for compiling libsidplayfp])
733fi
734dnl TODO HAVE_VISIBILITY
735AX_CHECK_COMPILE_FLAG([-fvisibility=hidden -fvisibility-inlines-hidden], [HAVE_VISIBILITY=1;has_visibility=yes], [has_visibility=no])
736AC_CHECK_SIZEOF([short])
737AC_CHECK_SIZEOF([int])
738AS_IF([test $ac_cv_sizeof_short -ne 2],
739  [AC_MSG_ERROR([LIBSIDPLAYFP: size of short must be 16 bit])]
740)
741AS_IF([test $ac_cv_sizeof_int -lt 4],
742  [AC_MSG_ERROR([LIBSIDPLAYFP: only 32 bit or better CPUs are supported])]
743)
744AS_IF([test "x${ac_cv_header_stdint_h}" != "xyes"],
745  [AC_MSG_ERROR([Required header stdint.h not found])]
746)
747AC_CHECK_DECL(
748    [strcasecmp],
749    [AC_CHECK_FUNCS([strcasecmp])],
750    [AC_CHECK_DECL(
751        [stricmp],
752        [AC_CHECK_FUNCS([stricmp])]
753    )]
754)
755AC_CHECK_DECL(
756    [strncasecmp],
757    [AC_CHECK_FUNCS([strncasecmp])],
758    [AC_CHECK_DECL(
759        [strnicmp],
760        [AC_CHECK_FUNCS([strnicmp])]
761    )]
762)
763if test "x$with_debug" = "xyes"; then
764  $CXXFLAGS="$CXXFLAGS -DDEBUG=1"
765fi
766AC_CACHE_CHECK([for working bool], ac_cv_cxx_bool,
767[AC_COMPILE_IFELSE(
768  [AC_LANG_PROGRAM([],
769    [[bool flag;]])],
770  [ac_cv_cxx_bool=yes],
771  [ac_cv_cxx_bool=no])]
772)
773AS_IF([test "x$ac_cv_cxx_bool" = "xno"],
774  [HAVE_BOOL=0],
775  [HAVE_BOOL=1]
776)
777dnl TODO RESID_BRANCH_HINTS
778dnl Enable branch prediction hints.
779AC_ARG_ENABLE([branch-hints],
780  [AS_HELP_STRING([--enable-branch-hints],
781    [enable static branch prediction hints [default=yes]])],
782  [],
783  [enable_branch_hints=yes]
784)
785AS_IF([test "$enable_branch_hints" != no],
786  [RESID_BRANCH_HINTS=1],
787  [RESID_BRANCH_HINTS=0]
788)
789AC_CACHE_CHECK([for log1p], [resid_cv_log1p],
790  [AC_TRY_COMPILE([#include <math.h>], [ log1p(1); ],
791    resid_cv_log1p=yes, resid_cv_log1p=no)])
792AS_IF([test "$resid_cv_log1p" = no],
793  [HAVE_LOG1P=0],
794  [HAVE_LOG1P=1]
795)
796AC_CACHE_CHECK([for __builtin_expect], [resid_cv_builtin_expect],
797  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() { __builtin_expect(0, 0); }])],
798    [resid_cv_builtin_expect=yes], [resid_cv_builtin_expect=no])]
799)
800AS_IF([test "$resid_cv_builtin_expect" = no],
801  [HAVE_BUILTIN_EXPECT=0],
802  [HAVE_BUILTIN_EXPECT=1]
803)
804LIBSIDPLAYCXX="$CXX -DHAVE_CONFIG_H=1 -DSIDTUNE_NO_STDIN_LOADER=1 -DPACKAGE_NAME=\\\"sidplayfp\\\" -DVERSION=\\\"2.0.1\\\" -DPACKAGE_VERSION=\\\"2.0.1-1\\\" -DPACKAGE_URL=\\\"\\\""
805LIBSIDPLAYCXXFLAGS="$CXXFLAGS"
806AC_SUBST(LIBSIDPLAYCXX)
807AC_SUBST(LIBSIDPLAYCXXFLAGS)
808AC_LANG_POP
809CXX=$origCXX
810CXXFLAGS=$origCXXFLAGS
811NEW_8580_FILTER=0
812
813AC_SUBST(HAVE_BOOL)
814AC_SUBST(HAVE_LOG1P)
815AC_SUBST(HAVE_BUILTIN_EXPECT)
816AC_SUBST(RESID_INLINING)
817AC_SUBST(RESID_INLINE)
818AC_SUBST(RESID_BRANCH_HINTS)
819AC_SUBST(NEW_8580_FILTER)
820AC_SUBST(HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H)
821AC_SUBST(HAVE_SIDPLAYFP_BUILDERS_RESID_H)
822AC_LANG_POP()
823
824AC_SUBST(ALSA_CFLAGS)
825AC_SUBST(ALSA_LIBS)
826if test "x$with_alsa" != "xno"; then
827	AC_MSG_CHECKING([Alsa support])
828	ALSA_LIBS=`pkg-config --libs alsa 2> /dev/null`
829	ALSA_CFLAGS=`pkg-config --cflags alsa 2> /dev/null`
830	if test "$?" = 0; then
831		AC_MSG_RESULT("$ALSA_CFLAGS $ALSA_LIBS")
832	else
833		if test "x$with_alsa" = "xyes"; then
834			AC_MSG_ERROR([pkg-config failed]);
835		else
836			AC_MSG_RESULT([pkg-config failed]);
837			with_alsa="no"
838		fi
839	fi
840fi
841
842AC_SUBST(HAVE_ALSA)
843if test "x$with_alsa" = "xno"; then
844	HAVE_ALSA=0
845else
846	HAVE_ALSA=1
847fi
848
849AC_SUBST(HAVE_ADPLUG)
850AC_SUBST(ADPLUG_INI)
851if test "x$with_adplug" = "xno"; then
852	HAVE_ADPLUG=
853	ADPLUG_INI=
854else
855	HAVE_ADPLUG=1
856	ADPLUG_INI=opltype
857fi
858
859AC_SUBST(LINUX)
860AC_SUBST(CDROM_SUPPORT)
861AC_SUBST(X11_LIBS)
862AC_SUBST(CDROM_INI)
863AC_SUBST(HAVE_FRAMEBUFFER)
864HAVE_FRAMEBUFFER=1
865LINUX=1
866	AC_CHECK_HEADER(linux/limits.h, , AC_MSG_RESULT([linux kernel header files was not found]);LINUX=)
867if test "$LINUX+set" != "+set"; then
868	AC_CHECK_HEADER(linux/major.h, , AC_MSG_RESULT([linux kernel header files was not found]);LINUX=)
869fi
870if test "$LINUX+set" != "+set"; then
871	AC_CHECK_HEADER(linux/fb.h, AC_DEFINE(HAVE_FRAMEBUFFER), AC_MSG_RESULT([linux kernel header files was not found]);LINUX=;HAVE_FRAMEBUFFER=)
872fi
873if test "$LINUX+set" != "+set"; then
874	AC_CHECK_HEADER(linux/cdrom.h, CDROM_SUPPORT=1;CDROM_INI="cdrom", AC_MSG_RESULT([linux cdrom kernel header files was not found]))
875fi
876
877AC_SUBST(HAVE_OSS)
878AC_SUBST(OSS_LIBS)
879AC_SUBST(OSS_CFLAGS)
880if test "x$with_oss" != "xno"; then
881	AC_MSG_CHECKING([liboss])
882	OSS_LIBS=`pkg-config --libs liboss 2> /dev/null`
883	OSS_CFLAGS=`pkg-config --cflags liboss 2> /dev/null`
884	if test "$?" = 0; then
885		AC_MSG_RESULT("$OSS_CFLAGS $OSS_LIBS")
886		HAVE_OSS=1
887	else
888		AC_MSG_RESULT([pkg-config failed]);
889dnl Fall back to non-pkg-config method
890		AC_CHECK_HEADER(sys/soundcard.h,
891			HAVE_OSS=1
892			AC_DEFINE(HAVE_SYS_SOUNDCARD_H),
893			if test "x$with_oss" = "xyes"; then AC_MSG_ERROR([kernel OSS header file was not found], 1); else with_oss="no"; HAVE_OSS=0;fi)
894	fi
895fi
896
897AC_SUBST(HAVE_COREAUDIO)
898AC_SUBST(COREAUDIO_CFLAGS)
899AC_SUBST(COREAUDIO_LIBS)
900if test "x$with_coreaudio" != "xno"; then
901	AC_CHECK_HEADER(CoreServices/CoreServices.h, HAVE_COREAUDIO=1, if test "x$with_coreaudio" = "xyes"; then AC_MSG_ERROR([CoreAudio not found], 1); else with_coreaudio="no"; HAVE_COREAUDIO=0; fi)
902fi
903if test "x$with_coreaudio" != "xno"; then
904	AC_CHECK_HEADER(AudioUnit/AudioUnit.h, HAVE_COREAUDIO=1, if test "x$with_coreaudio" = "xyes"; then AC_MSG_ERROR([CoreAudio not found], 1); else with_coreaudio="no"; HAVE_COREAUDIO=0; fi)
905fi
906if test "x$with_coreaudio" != "xno"; then
907	AC_CHECK_HEADER(AudioToolbox/AudioToolbox.h, HAVE_COREAUDIO=1, if test "x$with_coreaudio" = "xyes"; then AC_MSG_ERROR([CoreAudio not found], 1); else with_coreaudio="no"; HAVE_COREAUDIO=0; fi)
908fi
909if test "x$with_coreaudio" != "xno"; then
910	AC_CHECK_HEADER(CoreAudio/CoreAudio.h, HAVE_COREAUDIO=1, if test "x$with_coreaudio" = "xyes"; then AC_MSG_ERROR([CoreAudio not found], 1); else with_coreaudio="no"; HAVE_COREAUDIO=0; fi)
911fi
912if test "x$with_coreaudio" != "xno"; then
913	COREAUDIO_CFLAGS=""
914	COREAUDIO_LIBS="-framework CoreAudio -framework Carbon -framework AudioUnit"
915fi
916
917AS_AC_EXPAND(LIBDIR, $libdir/$PACKAGE_NAME$DIR_SUFFIX)
918AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR")
919
920AS_AC_EXPAND(BINDIR, $exec_prefix/bin)
921
922AS_AC_EXPAND(PREFIX, $prefix)
923AS_AC_EXPAND(DOCDIR, $docdir)
924AS_AC_EXPAND(INFODIR, $infodir)
925AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
926AS_AC_EXPAND(DATADIR, $datadir)
927AS_AC_EXPAND(DATAROOTDIR, $datarootdir)
928AC_DEFINE_UNQUOTED(DATADIR, "$DATADIR")
929AC_DEFINE_UNQUOTED(PREFIX, "$PREFIX")
930
931AC_ARG_WITH(efence, [  --with-efence           Enable usage of efence],
932EFENCE_LIBS="-lefence"
933AC_DEFINE(HAVE_EFENCE, 1)
934)
935AC_SUBST(EFENCE_LIBS)
936
937AC_ARG_WITH(duma, [  --with-duma             Enable usage of duma],
938DUMA_LIBS="-lduma"
939AC_DEFINE(HAVE_DUMA, 1)
940)
941AC_SUBST(DUMA_LIBS)
942
943
944AC_SUBST(HAVE_MAKEINFO)
945AC_CHECK_PROG(HAVE_MAKEINFO, makeinfo, yes,)
946
947AC_SUBST(HAVE_LZW)
948AC_MSG_CHECKING([Include lzw support (used by GIF and arcZIP)])
949if test "x$with_lzw" = "xyes"; then
950	AC_MSG_RESULT([yes])
951	AC_DEFINE(HAVE_LZW, 1)
952	HAVE_LZW=1
953else
954	AC_MSG_RESULT([no])
955fi
956
957AC_SUBST(HAVE_LZH)
958AC_MSG_CHECKING([Include lzh support (used by .ym file support)])
959if test "x$with_lzh" = "xyes"; then
960	AC_MSG_RESULT([yes])
961	AC_DEFINE(HAVE_LZH, 1)
962	HAVE_LZH=1
963else
964	AC_MSG_RESULT([no])
965fi
966
967AC_MSG_CHECKING("cp -f implies --remove-destination")
968cp -f --remove-destination Rules.make.in Rules.make.in.tmp > /dev/null 2>&1
969if test "$?" -ne 0; then
970	AC_MSG_RESULT([yes])
971	CP="cp -f"
972else
973	AC_MSG_RESULT([no])
974	CP="cp -f --remove-destination"
975fi
976rm -f Rules.make.in.tmp
977AC_SUBST(CP)
978
979AC_ARG_WITH(libiconv,
980	[AS_HELP_STRING([--with-libiconv=], [@<:@auto/no/gnu/native@:>@ what kind of libiconv library to use])],
981	[with_libiconv=$withval],
982	[with_libiconv=auto])
983
984found_iconv=no
985case $with_libiconv in
986	auto)
987		# Check in the C library first
988		AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
989		# Check if we have GNU libiconv
990		if test $found_iconv = "no"; then
991			AC_CHECK_LIB(iconv, libiconv_open, [ICONV_LIBS=-liconv; with_libiconv=gnu; found_iconv=yes])
992		fi
993		# Check if we have a iconv in -liconv, possibly from vendor
994		if test $found_iconv = "no"; then
995			AC_CHECK_LIB(iconv, iconv_open, [ICONV_LIBS=-liconv; with_libiconv=native; found_iconv=yes])
996		fi
997		;;
998	no)
999		AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
1000		;;
1001	gnu|yes)
1002		AC_CHECK_LIB(iconv, libiconv_open, [ICONV_LIBS=-liconv; with_libiconv=gnu; found_iconv=yes])
1003		;;
1004	native)
1005		AC_CHECK_LIB(iconv, iconv_open, [ICONV_LIBS=-liconv; with_libiconv=native; found_iconv=yes])
1006		;;
1007esac
1008LIBS=$push_LIBS
1009
1010if test "x$found_iconv" = "xno" ; then
1011	AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
1012fi
1013AC_SUBST(ICONV_LIBS)
1014
1015case $with_libiconv in
1016	gnu)
1017		AC_DEFINE(USE_LIBICONV_GNU, 1, [Using GNU libiconv])
1018		;;
1019	native)
1020		AC_DEFINE(USE_LIBICONV_NATIVE, 1, [Using a native implementation of iconv in a separate library])
1021		;;
1022esac
1023
1024if ! test "x$with_desktop_file_install" = "xno"; then
1025	if test "x$with_x11" != "xno" || test "x$with_sdl" != "xno" || test "x$with_sdl2" != "xno"; then
1026		AC_CHECK_PROG(DESKTOP_FILE_INSTALL,desktop-file-install,desktop-file-install,failed)
1027		if test "x$DESKTOP_FILE_INSTALL" = "xfailed"; then
1028			AC_MSG_ERROR([Cannot find desktop-file-install (required by x11 and SDL driver).])
1029		fi
1030	fi
1031fi
1032
1033if test "x$with_dumptools" = "xyes"; then
1034	BUILD_DUMPTOOLS=1
1035fi
1036AC_SUBST(BUILD_DUMPTOOLS)
1037
1038AC_CONFIG_FILES(Rules.make)
1039AC_CONFIG_FILES(Makefile)
1040AC_CONFIG_FILES(goodies/helpc/Makefile)
1041AC_CONFIG_FILES(goodies/pack/Makefile)
1042AC_CONFIG_FILES(ocp.ini)
1043AC_CONFIG_FILES(desktop/opencubicplayer.desktop)
1044
1045AC_CONFIG_FILES(doc/opencp.dox)
1046AC_CONFIG_FILES(doc/texi/faq.texi)
1047AC_CONFIG_FILES(doc/texi/ocp.texi)
1048AC_CONFIG_FILES(playsid/libsidplayfp-git/src/builders/resid-builder/resid/siddefs.h)
1049AC_CONFIG_FILES(playsid/libsidplayfp-git/src/builders/residfp-builder/residfp/siddefs-fp.h)
1050
1051AC_OUTPUT
1052
1053echo
1054if test "x$with_debug" = "xyes"; then
1055	echo "debug:             ON"
1056else
1057	echo "debug:             OFF"
1058fi
1059
1060if test "x$with_adplug" = "xno"; then
1061	echo "adplug:            OFF"
1062else
1063	echo "adplug:            ON"
1064fi
1065if test "x$with_mad" = "xno"; then
1066	echo "mad:               OFF"
1067else
1068	echo "mad:               ON"
1069fi
1070echo "sidplayfp:         GIT/builtin"
1071if test "x$with_flac" = "xno"; then
1072	echo "FLAC:              OFF"
1073else
1074	echo "FLAC:              ON"
1075fi
1076if test "x$with_x11" = "xno"; then
1077	echo "x11:               OFF"
1078else
1079	echo "x11:               ON  (UNIFONTDIR="$UNIFONTDIR")"
1080fi
1081if test "x$with_sdl" = "xno"; then
1082	echo "SDL:               OFF"
1083else
1084	echo "SDL:               ON  (UNIFONTDIR="$UNIFONTDIR")"
1085fi
1086if test "x$with_sdl2" = "xno"; then
1087	echo "SDL2:              OFF"
1088else
1089	echo "SDL2:              ON  (UNIFONTDIR="$UNIFONTDIR")"
1090fi
1091if test "x$with_alsa" = "xno"; then
1092	echo "ALSA:              OFF"
1093else
1094	echo "ALSA:              ON"
1095fi
1096if test "x$with_oss" = "xno"; then
1097	echo "OSS:               OFF"
1098else
1099	echo "OSS:               ON"
1100fi
1101if test "x$with_coreaudio" = "xno"; then
1102	echo "CoreAudio:         OFF"
1103else
1104	echo "CoreAudio:         ON"
1105fi
1106if test "$LINUX+set" != "+set"; then
1107	echo "linux cdrom:       ON"
1108	echo "linux framebuffer: ON"
1109else
1110	echo "linux cdrom:       OFF"
1111	echo "linux framebuffer: OFF"
1112fi
1113if test "x$with_lzw" = "xno"; then
1114	echo "include LZW:       OFF"
1115else
1116	echo "include LZW:       ON"
1117fi
1118if test "x$with_lzh" = "xno"; then
1119	echo "include LZH:       OFF"
1120else
1121	echo "include LZH:       ON"
1122fi
1123if test "x$with_dumptools" = "xyes"; then
1124	echo "include DumpTools: ON"
1125else
1126	echo "include DumpTools: OFF"
1127fi
1128