1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.69])
3AC_INIT([Exult],[1.7.0git],[],[exult],[http://exult.sourceforge.net/])
4AC_CONFIG_SRCDIR([exult.cc])
5
6
7# ---------------------------------------------------------------------
8# System/version info
9# ---------------------------------------------------------------------
10
11# check host/target systems
12# (build = system we're building on, host = system we're building for,
13# target = system the program we're building will build for)
14AC_CANONICAL_HOST
15AC_CANONICAL_TARGET
16
17AM_INIT_AUTOMAKE
18AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package Name])
19AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package Version])
20
21AC_CONFIG_HEADER([config.h])
22AC_CONFIG_MACRO_DIR([m4])
23
24AH_BOTTOM([
25#define USE_FMOPL_MIDI
26])
27
28
29# ---------------------------------------------------------------------
30# Host system settings
31# ---------------------------------------------------------------------
32
33AC_EXEEXT
34
35SYSLIBS=""
36ICON_FILE=""
37EXE_TARGET="exult$EXEEXT"
38EXULT_DATADIR="$datadir/exult"
39ARCH=""
40
41# Default C anc C++ compiler set
42cxx_compilers="g++ clang++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC"
43
44# determine windowing system from 'host'
45AC_MSG_CHECKING([windowing system])
46case "$host_os" in
47	linux*)
48		WINDOWING_SYSTEM="-DXWIN"
49		AC_MSG_RESULT([X11 (GNU/Linux)])
50		;;
51	mingw32* )
52		WINDOWING_SYSTEM="-D_WIN32"
53		AC_DEFINE(MINGW, 1, [Using MinGW])
54		AC_MSG_RESULT([Win32 (mingw32)])
55		CXXFLAGS="$CXXFLAGS -D_USE_MATH_DEFINES"
56		SYSLIBS="-luuid -lole32 -lwinmm -lstdc++ -lws2_32"
57		ICON_FILE="win32/exultico.o"
58		enable_timidity="no"
59		;;
60	cygwin* )
61		WINDOWING_SYSTEM="-D_WIN32"
62		AC_DEFINE(CYGWIN, 1, [Using Cygwin])
63		AC_MSG_RESULT([Win32 (cygwin)])
64		CXXFLAGS="$CXXFLAGS -mno-cygwin"
65		SYSLIBS="-lwinmm"
66		ICON_FILE="win32/exultico.o"
67		enable_timidity="no"
68		;;
69	openbsd* )
70		WINDOWING_SYSTEM="-DXWIN"
71		AC_DEFINE(OPENBSD, 1, [Using OpenBSD])
72		AC_MSG_RESULT([X11 (OpenBSD)])
73		SYSLIBS="-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga"
74		;;
75	freebsd* )
76		WINDOWING_SYSTEM="-DXWIN"
77		AC_DEFINE(NETBSD, 1, [Using NetBSD])
78		AC_MSG_RESULT([X11 (FreeBSD)])
79		CXXFLAGS="$CXXFLAGS -I/usr/local/include"
80		;;
81	netbsd* )
82		WINDOWING_SYSTEM="-DXWIN"
83		AC_MSG_RESULT([X11 (NetBSD)])
84		CXXFLAGS="$CXXFLAGS -I/usr/X11R6/include"
85		;;
86	solaris* )
87		WINDOWING_SYSTEM="-DXWIN"
88		AC_MSG_RESULT([X11 (Solaris)])
89		SYSLIBS="-lsocket -lX11"
90		;;
91	darwin*)
92		dnl We have a problem here: both Mac OS X and Darwin report
93		dnl the same signature "powerpc-apple-darwin*" - so we have
94		dnl to do more to distinguish them. Plain Darwin will propably
95		dnl use X-Windows; and it is of course lacking Cocoa. For
96		dnl now I am lazy and do not add proper detection code.
97
98		WINDOWING_SYSTEM="-DMACOSX"
99		AC_DEFINE(MACOSX, 1, [Using MacOSX])
100		AC_MSG_RESULT([Mac OS X])
101		SYSLIBS="-framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreMIDI"
102		CXXFLAGS="$CXXFLAGS -stdlib=libc++"
103		EXULT_DATADIR="/Library/Application\ Support/Exult/data"
104		ARCH=macosx
105		dnl swap around clang for OSX
106		cxx_compilers="clang++ g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC"
107		;;
108	*)
109		WINDOWING_SYSTEM="-DXWIN"
110		AC_MSG_RESULT([not sure... guessing X11])
111		;;
112esac
113
114if echo $host_os | grep "cygwin\|mingw" > /dev/null 2>&1; then
115	AC_CHECK_TOOL([WINDRES], [windres])
116	if test "x$WINDRES" = "x"; then
117		AC_MSG_ERROR([windres could not be found, please make sure this program is within your path.])
118	fi
119fi
120AC_SUBST(WINDRES)
121
122AM_CONDITIONAL(MACOSX, test x$ARCH = xmacosx)
123
124# ---------------------------------------------------------------------
125# Compilers and other tools
126# ---------------------------------------------------------------------
127
128AC_PROG_AWK
129
130AC_ARG_WITH(cxx, AS_HELP_STRING([--with-cxx=COMMAND], [Explicitly specify the C++ compiler to use]),[WITHCXX="$withval"],[WITHCXX="$CXX"])
131
132if test "x$WITHCXX" != "x"; then
133	cxx_compilers="$WITHCXX"
134fi
135
136AC_PROG_CXX([$cxx_compilers])
137
138AC_LANG([C++])
139
140AX_CXX_COMPILE_STDCXX_17([noext],[optional])
141if test "$HAVE_CXX17" = "0"; then
142	AX_CXX_COMPILE_STDCXX_14([noext],[mandatory])
143fi
144AC_PROG_CXXCPP
145
146AC_PROG_INSTALL
147AM_PROG_LEX
148AC_PROG_YACC
149AM_CONDITIONAL(LEXYACC, test -n "$YACC")
150
151AC_DISABLE_SHARED([])
152
153LT_INIT
154AC_SUBST(LIBTOOL_DEPS)
155
156# ---------------------------------------------------------------------
157# Checks for integer types with specific sizes.
158# ---------------------------------------------------------------------
159AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t],
160               [], [AC_MSG_ERROR([*** Cannot find suitably-sized signed integers!])],
161               [#include <cstdint>])
162AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t],
163               [], [AC_MSG_ERROR([*** Cannot find suitably-sized unsigned integers!])],
164               [#include <cstdint>])
165
166# ---------------------------------------------------------------------
167# Checks for header files.
168# ---------------------------------------------------------------------
169AC_HEADER_DIRENT
170AC_HEADER_STDC
171AC_CHECK_HEADERS(limits.h sys/time.h unistd.h)
172AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
173AC_CHECK_HEADERS(sys/wait.h signal.h getopt.h)
174AC_CHECK_HEADERS(png.h, AM_CONDITIONAL(HAVE_PNG,true), AM_CONDITIONAL(HAVE_PNG, false))
175
176# ---------------------------------------------------------------------
177# Checks for typedefs, structures, and compiler characteristics.
178# ---------------------------------------------------------------------
179AC_C_CONST
180AC_C_INLINE
181AC_TYPE_SIZE_T
182AC_HEADER_TIME
183AC_STRUCT_TM
184
185# ---------------------------------------------------------------------
186# Checks for library functions
187# ---------------------------------------------------------------------
188dnl Disabled this for now (undefined in autoconf < 2.5)
189dnl AC_FUNC_MALLOC
190
191AC_FUNC_MEMCMP
192
193AC_CHECK_FUNCS([atexit dup2 getcwd isascii memchr memmove memset mkdir pow select socket strcasecmp strchr strstr strtol strtoul getopt_long])
194
195AC_MSG_CHECKING([for getaddrinfo()])
196AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
197#if HAVE_SYS_TYPES_H
198#include <sys/types.h>
199#endif
200#if HAVE_SYS_SOCKET_H
201#include <sys/socket.h>
202#endif
203#if HAVE_NETDB_H
204#include <netdb.h>
205#endif
206]], [[
207	struct addrinfo a;
208	//getaddrinfo(0, 0, 0, 0);
209]])],[ac_cv_func_getaddrinfo=yes],[ac_cv_func_getaddrinfo=no])
210AC_MSG_RESULT($ac_cv_func_getaddrinfo)
211if test x$ac_cv_func_getaddrinfo = xyes ; then
212	AC_DEFINE(HAVE_GETADDRINFO, 1, [Have addrinfo/getaddrinfo])
213fi
214
215AC_MSG_CHECKING([for mkstemp()])
216AC_LINK_IFELSE([AC_LANG_PROGRAM([[
217#if HAVE_UNISTD_H
218#include <unistd.h>
219#endif
220#include <stdlib.h>
221]], [[
222	mkstemp(0);
223]])],[ac_cv_func_mkstemp=yes],[ac_cv_func_mkstemp=no])
224AC_MSG_RESULT($ac_cv_func_mkstemp)
225if test x$ac_cv_func_mkstemp = xyes ; then
226	AC_DEFINE(HAVE_MKSTEMP, 1, [Have mkstemp])
227fi
228
229# do we need special X11 libraries?
230AC_MSG_CHECKING([for special X11 libraries])
231if test x$x_libraries = xNONE; then
232	AC_MSG_RESULT(no)
233	unset x_libraries
234else
235	x_libraries="-L$x_libraries -lX11 -lXext"
236	AC_MSG_RESULT($x_libraries)
237	AC_SUBST(x_libraries)
238fi
239
240# ---------------------------------------------------------------------
241# Statically link libraries?
242# ---------------------------------------------------------------------
243
244AC_ARG_ENABLE(static-libraries, AS_HELP_STRING([--enable-static-libraries], [Enable static linking of libraries]),,enable_static_libs=no)
245AC_MSG_CHECKING([if we want to statically compile libraries])
246if test x$enable_static_libs != xno; then
247	AC_MSG_RESULT(yes)
248else
249	AC_MSG_RESULT(no)
250fi
251
252# ---------------------------------------------------------------------
253# Check for pkg-config
254# ---------------------------------------------------------------------
255PKG_PROG_PKG_CONFIG
256
257# ---------------------------------------------------------------------
258# SDL
259# ---------------------------------------------------------------------
260
261EXULT_CHECK_SDL(:,AC_MSG_ERROR([[*** SDL not found!]]))
262
263# ---------------------------------------------------------------------
264# libogg, libvorbis, libvorbisfile
265# ---------------------------------------------------------------------
266
267if test "x$PKG_CONFIG" != "x"; then
268	PKG_CHECK_MODULES(OGG, ogg >= 1.0 vorbis >= 1.0.1 vorbisfile, , AC_MSG_ERROR([*** must have Ogg/Vorbis installed!]))
269else
270	dnl old school test
271	m4_ifdef([XIPH_PATH_OGG], [
272		XIPH_PATH_OGG(, AC_MSG_ERROR([*** must have Ogg installed!]))
273		], AC_MSG_ERROR([*** must have Ogg installed!]))
274	m4_ifdef([XIPH_PATH_VORBIS], [
275		XIPH_PATH_VORBIS(, AC_MSG_ERROR([*** must have Vorbis installed!]))
276	], AC_MSG_ERROR([*** must have Vorbis installed!]))
277fi
278
279# ---------------------------------------------------------------------
280# Gtk (for ES)
281# ---------------------------------------------------------------------
282
283if test "x$PKG_CONFIG" != "x"; then
284	PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.16, have_gtk=yes, have_gtk=no)
285else
286	have_gtk=no
287fi
288
289# ---------------------------------------------------------------------
290# Gdk-Pixbuf (for Gnome shp thumbnailer)
291# ---------------------------------------------------------------------
292
293if test "x$PKG_CONFIG" != "x"; then
294	PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0, have_gdk_pixbuf=yes, have_gdk_pixbuf=no)
295else
296	have_gdk_pixbuf=no
297fi
298
299# ---------------------------------------------------------------------
300# Black magic for static linking.
301# ---------------------------------------------------------------------
302if test x$ARCH = xmacosx; then
303	AC_ARG_WITH(macosx-static-lib-path,
304		AS_HELP_STRING([--with-macosx-static-lib-path=path], [path to location of static library files (Mac OS X bundles only)]),
305		[with_macosx_static_lib_path="$withval"],
306		[with_macosx_static_lib_path=""])
307	if test x$with_macosx_static_lib_path != x; then
308		if test ! -d $with_macosx_static_lib_path; then
309			AC_MSG_ERROR([*** a directory is expected for --macosx-static-lib-path!])
310		fi
311		with_macosx_static_lib_path=`echo "$with_macosx_static_lib_path" | sed 's/\/*$//'`
312	else
313		enable_static_libs=no
314	fi
315fi
316
317if test x$enable_static_libs != xno; then
318	if test x$ARCH != xmacosx; then
319		# Assuming GCC. This is probably not portable.
320		STATIC_LD="-static"
321		LDFLAGS="$LDFLAGS -static"
322	else
323		# Apple has done its best to prevent the above from working, so we
324		# need this stuff here.
325		# Using -static doesn't work because of system libraries that cannot be
326		# linked statically; using the usual -Wl,-static -lvorbis -Wl,-dynamic
327		# also fails if there is a non-static version of libvorbis in the lib
328		# search path before or at the same location as the static lib because
329		# the linker tries to use these even with the flags. The only way to get
330		# reliable static compiles in Mac OS X is to hard-code the path to the
331		# static library and link to *that*.
332		# Damn you, Apple!
333
334		# SDL Mac OS X readme lists this as needed.
335		# We should have sdl-config by this point, or we would have
336		# died in EXULT_CHECK_SDL.
337		SDL_LIBS=`$SDL_CONFIG $sdl_config_args --static-libs`
338		OGG_LIBS="$with_macosx_static_lib_path/libogg.a"
339		VORBISFILE_LIBS="$with_macosx_static_lib_path/libvorbisfile.a"
340		VORBIS_LIBS="$with_macosx_static_lib_path/libvorbis.a -lm"
341		ZLIB_LIBS="$with_macosx_static_lib_path/libz.a"
342		MT32EMU_LIBS="$with_macosx_static_lib_path/libmt32emu.a"
343	fi
344fi
345
346# ---------------------------------------------------------------------
347# Mac OS X code signing
348# ---------------------------------------------------------------------
349
350AM_CONDITIONAL(WITH_OSX_CODE_SIGNATURE, false)
351AC_ARG_WITH(macosx-code-signature,
352	AS_HELP_STRING([--with-macosx-code-signature=identity], [identity for code signing (Mac OS X bundles only) @<:@default "Developer ID Application"@:>@]),
353	[with_macosx_code_signature="$withval"],
354	[with_macosx_code_signature=""])
355if test x$ARCH = xmacosx; then
356	if test x"$with_macosx_code_signature" != x; then
357		if test x"$with_macosx_code_signature" = xyes; then
358			with_macosx_code_signature="Developer ID Application"
359		fi
360		AM_CONDITIONAL(WITH_OSX_CODE_SIGNATURE, true)
361		OSX_CODE_SIGNATURE="$with_macosx_code_signature"
362		AC_SUBST(OSX_CODE_SIGNATURE)
363	fi
364fi
365
366# ---------------------------------------------------------------------
367# Optional components
368# ---------------------------------------------------------------------
369
370# Timidity midi driver
371AC_ARG_ENABLE(timidity_midi, AS_HELP_STRING([--disable-timidity-midi], [Disable built-in timidity midi]),,enable_timidity_midi=yes)
372AC_ARG_WITH(timidity, AS_HELP_STRING([--with-timidity=path], [path to timidity.cfg (optional)]),,)
373AC_MSG_CHECKING([if we want to use timidity midi])
374if test x$enable_timidity_midi = xyes; then
375	AC_MSG_RESULT(yes)
376	AC_DEFINE(USE_TIMIDITY_MIDI, 1, [Enable timidity midi])
377
378	if test x$with_timidity != x; then
379		if test ! -d $with_timidity; then
380			with_timidity=`echo "$with_timidity" | sed 's/timidity.cfg//'`
381		fi
382		AC_DEFINE_UNQUOTED(DEFAULT_TIMIDITY_PATH, "$with_timidity", [Default timidity path])
383	fi
384else
385	AC_MSG_RESULT(no)
386fi
387
388# ALSA midi driver
389AC_CHECK_HEADER(alsa/asoundlib.h, HAVEALSA=yes, HAVEALSA=no)
390AC_ARG_ENABLE(alsa, AS_HELP_STRING([--disable-alsa], [Disable ALSA midi support]),,enable_alsa=yes)
391AC_MSG_CHECKING([if we want to use ALSA midi])
392if test x$HAVEALSA = xyes; then
393	if test x$enable_alsa = xyes; then
394		AC_MSG_RESULT(yes)
395		AC_DEFINE(USE_ALSA_MIDI, 1, [Enable ALSA midi])
396		ALSA_LIBS="-lasound"
397	else
398		AC_MSG_RESULT(no)
399	fi
400else
401	AC_MSG_RESULT([no; libasound not found])
402fi
403
404# fluidsynth midi driver
405AC_CHECK_HEADER(fluidsynth.h, HAVEFLUIDSYNTH=yes, HAVEFLUIDSYNTH=no)
406AC_ARG_ENABLE(fluidsynth, AS_HELP_STRING([--disable-fluidsynth], [Disable fluidsynth midi support]),,enable_fluidsynth=yes)
407AC_MSG_CHECKING([if we want to use fluidsynth midi])
408if test x$HAVEFLUIDSYNTH = xyes; then
409		if test x$enable_fluidsynth = xyes; then
410				AC_MSG_RESULT(yes)
411				AC_DEFINE(USE_FLUIDSYNTH_MIDI, 1, [Enable fluidsynth midi])
412				FLUIDSYNTH_LIBS="-lfluidsynth"
413		else
414				AC_MSG_RESULT(no)
415		fi
416else
417		AC_MSG_RESULT([no; fluidsynth.h not found])
418fi
419
420# mt32emu midi driver
421AC_CHECK_HEADER(mt32emu/mt32emu.h, HAVEMT32EMU=yes, HAVEMT32EMU=no)
422AC_ARG_ENABLE(mt32emu, AS_HELP_STRING([--enable-mt32emu], [Enable built-in mt32emu support]),,enable_mt32emu=no)
423AC_MSG_CHECKING([if we should build mt32emu])
424if test x$HAVEMT32EMU = xyes; then
425	if test x$enable_mt32emu = xyes; then
426		AC_MSG_RESULT(yes)
427		AC_DEFINE(USE_MT32EMU_MIDI, 1, [Enable mt32emu])
428		AM_CONDITIONAL(BUILD_MT32EMU, true)
429		if test "x$PKG_CONFIG" != "x"; then
430			PKG_CHECK_MODULES(MT32EMU, mt32emu, ,
431				[
432					if test x$enable_static_libs = xno; then
433						MT32EMU_LIBS="-lmt32emu"
434						MT32EMU_CFLAGS=""
435					fi
436				])
437		elif test x$enable_static_libs = xno; then
438			MT32EMU_LIBS="-lmt32emu"
439			MT32EMU_CFLAGS=""
440		fi
441	else
442		AC_MSG_RESULT(no)
443		AM_CONDITIONAL(BUILD_MT32EMU, false)
444	fi
445else
446	AC_MSG_RESULT(no; mt32emu.h not found)
447	AM_CONDITIONAL(BUILD_MT32EMU, false)
448fi
449
450
451# zipped savegame support
452
453AC_ARG_ENABLE(zip-support, AS_HELP_STRING([--enable-zip-support], [Enable zipped savegame support @<:@default yes@:>@]),,enable_zip_support=yes)
454
455if test x$enable_zip_support = xyes ; then
456	AC_CHECK_HEADER(zlib.h,,enable_zip_support=no)
457fi
458
459AC_MSG_CHECKING([for zipped savegame support])
460
461if test x$enable_zip_support = xyes ; then
462	# disabled for now (non-portable):
463
464	# link statically against zlib if using gcc
465	# if test x$GCC = xyes ; then
466	#	ZLIB_LIBS="-Wl,-Bstatic -lz -Wl,-Bdynamic"
467	# else
468	if test x$enable_static_libs = xno -o x$ARCH != xmacosx; then
469		ZLIB_LIBS="-lz"
470	fi
471	# fi
472	AC_DEFINE(HAVE_ZIP_SUPPORT, 1, [Have zip support])
473	AC_MSG_RESULT(yes)
474else
475	AC_MSG_RESULT(no)
476fi
477
478# HQnX scaler
479AC_ARG_ENABLE(all_hq_scalers, AS_HELP_STRING([--enable-all-hq-scalers], [Enable hq2x, hq3x, hq4x scaler support @<:@default yes@:>@]),,enable_all_hq_scalers=yes)
480AC_MSG_CHECKING([if we should build all hq scaler])
481if test x$enable_all_hq_scalers = xyes; then
482	enable_hq2x=yes
483	enable_hq3x=yes
484	enable_hq4x=yes
485	AC_MSG_RESULT(yes)
486else
487	AC_MSG_RESULT(no)
488fi
489
490# HQ2X scaler
491AC_ARG_ENABLE(hq2x, AS_HELP_STRING([--enable-hq2x],[Enable hq2x scaler support @<:@default no@:>@]),,enable_hq2x=no)
492AC_MSG_CHECKING(if we should build the hq2x scaler)
493if test x$enable_hq2x = xyes; then
494	AC_MSG_RESULT(yes)
495	AC_DEFINE(USE_HQ2X_SCALER, 1, [Build hq2x scaler])
496else
497	AC_MSG_RESULT(no)
498fi
499
500# HQ3X scaler
501AC_ARG_ENABLE(hq3x, AS_HELP_STRING([--enable-hq3x],[Enable hq3x scaler support @<:@default no@:>@]),,enable_hq3x=no)
502AC_MSG_CHECKING(if we should build the hq3x scaler)
503if test x$enable_hq3x = xyes; then
504	AC_MSG_RESULT(yes)
505	AC_DEFINE(USE_HQ3X_SCALER, 1, [Build hq3x scaler])
506else
507	AC_MSG_RESULT(no)
508fi
509
510# HQ4X scaler
511AC_ARG_ENABLE(hq4x, AS_HELP_STRING([--enable-hq4x],[Enable hq4x scaler support @<:@default no@:>@]),,enable_hq4x=no)
512AC_MSG_CHECKING(if we should build the hq4x scaler)
513if test x$enable_hq4x = xyes; then
514	AC_MSG_RESULT(yes)
515	AC_DEFINE(USE_HQ4X_SCALER, 1, [Build hq4x scaler])
516else
517	AC_MSG_RESULT(no)
518fi
519
520# NxBR scalers
521AC_ARG_ENABLE(nxbr, AS_HELP_STRING([--enable-nxbr],[Enable 2xBR, 3xBR and 4xBR scaler support @<:@default yes@:>@]),,enable_nxbr=yes)
522AC_MSG_CHECKING([if we should build the 2xBR, 3xBR and 4xBR scalers])
523if test x$enable_nxbr = xyes; then
524	AC_MSG_RESULT(yes)
525	AC_DEFINE(USE_XBR_SCALER, 1, [Build NxBR scalers])
526else
527	AC_MSG_RESULT(no)
528fi
529
530# Midi Sfx
531
532AC_ARG_ENABLE(midi-sfx, AS_HELP_STRING([--enable-midi-sfx], [Support for Midi Sfx (sounds horrible) @<:@default no@:>@]),,enable_midi_sfx=no)
533AC_MSG_CHECKING([whether to enable midi sfx])
534if test x$enable_midi_sfx = xyes; then
535	AC_DEFINE(ENABLE_MIDISFX, 1, [Enable Midi Sfx])
536	AC_MSG_RESULT(yes)
537else
538	AC_MSG_RESULT(no)
539fi
540
541# ---------------------------------------------------------------------
542# support for Exult Studio
543# ---------------------------------------------------------------------
544AC_MSG_CHECKING([whether to enable support for Exult Studio])
545AC_ARG_ENABLE(exult-studio-support, AS_HELP_STRING([--enable-exult-studio-support], [Enable ExultStudio support @<:@default no@:>@]),,enable_exult_studio_support=no)
546if test "$WINDOWING_SYSTEM" != -DXWIN -a "$WINDOWING_SYSTEM" != -D_WIN32 -a "$WINDOWING_SYSTEM" != -DMACOSX; then
547	enable_exult_studio_support=no
548fi
549
550AC_ARG_ENABLE(macosx-x11-studio-support, AS_HELP_STRING([--enable-macosx-x11-studio-support], [Force Exult Studio X11 support in Mac OS X @<:@default no@:>@]),,enable_macosx_x11_studio_support=no)
551if test "$WINDOWING_SYSTEM" != -DMACOSX; then
552	enable_macosx_x11_studio_support=no
553fi
554
555if test x$enable_exult_studio_support = xyes ; then
556	AC_MSG_RESULT(yes)
557	AC_DEFINE(USE_EXULTSTUDIO, 1, [Use Exult Studio])
558	AC_CHECK_FUNC(xwin, AC_DEFINE(XWIN))
559	if test "$WINDOWING_SYSTEM" = -DMACOSX -a "$ac_cv_func_xwin" != yes; then
560		if test ! $sdl_patchlevel -gt "14"; then
561			echo "SDL2 2.0.15 or newer is needed for native drag'n'drop - switching to X11"
562			enable_macosx_x11_studio_support=yes
563		fi
564	fi
565
566	# due to bug 2129731 and 3139441 some Linux distributions need -lX11 explicitly set
567	# when enabling Exult Studio support or linking fails
568	if test "$WINDOWING_SYSTEM" = -DXWIN ; then
569		SYSLIBS="$SYSLIBS -lX11"
570	fi
571
572	if test x$enable_macosx_x11_studio_support = xyes ; then
573		enable_exult_studio_support=yes
574		SYSLIBS="$SYSLIBS -L/usr/X11R6/lib -lX11"
575		AC_DEFINE(XWIN, 1, [X11 (needed by Exult Studio X11 support in macOS)])
576	fi
577else
578	AC_MSG_RESULT(no)
579fi
580
581
582# ---------------------------------------------------------------------
583# Alternative directories
584# ---------------------------------------------------------------------
585
586DESKTOPDIR="${datadir}/applications"
587AC_ARG_WITH([desktopdir],
588	AS_HELP_STRING([--with-desktopdir=DIR],[change desktop directory]),
589	[case "${withval}" in
590		yes)
591		;;
592		no)
593		;;
594		*)
595			DESKTOPDIR="${withval}"
596		;;
597	esac])
598AC_SUBST([DESKTOPDIR])
599
600ICONDIR="${datadir}/icons"
601AC_ARG_WITH([icondir],
602	AS_HELP_STRING([--with-icondir=DIR],[change icon directory]),
603	[case "${withval}" in
604		yes)
605		;;
606		no)
607		;;
608		*)
609			ICONDIR="${withval}"
610		;;
611	esac])
612AC_SUBST([ICONDIR])
613
614
615# ---------------------------------------------------------------------
616# Workaround for 'ar' warning in libtool
617# ---------------------------------------------------------------------
618
619if test "x$AR_FLAGS" = "xcru" ; then
620	AR_FLAGS="cr"
621fi
622
623# ---------------------------------------------------------------------
624# Optimization options
625# ---------------------------------------------------------------------
626
627AC_ARG_WITH([optimization],
628            AS_HELP_STRING([--with-optimization=none|size|debug|light|normal|heavy],
629                           [Select optimization level @<:@default=from CXXFLAGS@:>@]),
630            [opt_level="$withval"], [opt_level=""])
631AC_MSG_CHECKING([desired optimization level])
632if test x$opt_level = x; then
633	AC_MSG_RESULT(from CXXFLAGS)
634else
635	# TODO: Maybe making a function to do these.
636	# Lets clean up CFLAGS of -O[0-3gs]?
637	for ccflag in $CFLAGS; do
638		AS_CASE([$ccflag],
639			[-O|-O0|-O1|-O2|-O3|-Os|-Og], [],
640			[NEWCFLAGS="$NEWCFLAGS $ccflag"])
641	done
642	CFLAGS="$NEWCFLAGS"
643
644	# Lets clean up CXXFLAGS of -O[0-3gs]?
645	for cxxflag in $CXXFLAGS; do
646		AS_CASE([$cxxflag],
647			[-O|-O0|-O1|-O2|-O3|-Os|-Og], [],
648			[NEWCXXFLAGS="$NEWCXXFLAGS $cxxflag"])
649	done
650	CXXFLAGS="$NEWCXXFLAGS"
651
652	if test x$opt_level = xnone; then
653		AC_MSG_RESULT(none)
654		DEBUG_FLAGS="$DEBUG_FLAGS -O0"
655	elif test x$opt_level = xsize; then
656		AC_MSG_RESULT(size)
657		AX_CHECK_COMPILE_FLAG([-Os], [have_os_opt=yes], [have_os_opt=no], [$DEBUG_FLAGS -Werror])
658		if test x$have_os_opt = xyes; then
659			DEBUG_FLAGS="$DEBUG_FLAGS -Os"
660		else
661			# Sane default if compiler does not support -Os
662			DEBUG_FLAGS="$DEBUG_FLAGS -O2"
663			for opt_flag in -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays -ftree-vect-loop-version
664			do
665				AX_CHECK_COMPILE_FLAG([$opt_flag], [DEBUG_FLAGS="$DEBUG_FLAGS $opt_flag"], [], [$DEBUG_FLAGS -Werror])
666			done
667		fi
668	elif test x$opt_level = xdebug; then
669		AC_MSG_RESULT(debug)
670		AX_CHECK_COMPILE_FLAG([-Og], [have_og_opt=yes], [have_og_opt=no], [$DEBUG_FLAGS -Werror])
671		if test x$have_og_opt = xyes; then
672			DEBUG_FLAGS="$DEBUG_FLAGS -Og"
673		else
674			# Sane default if compiler does not support -Og
675			DEBUG_FLAGS="$DEBUG_FLAGS -O1"
676			for opt_flag in -fno-branch-count-reg -fno-if-conversion -fno-if-conversion2 -fno-inline-functions-called-once -fno-move-loop-invariants -fno-ssa-phiopt -fno-tree-bit-ccp -fno-tree-pta -fno-tree-sra
677			do
678				AX_CHECK_COMPILE_FLAG([$opt_flag], [DEBUG_FLAGS="$DEBUG_FLAGS $opt_flag"], [], [$DEBUG_FLAGS -Werror])
679			done
680		fi
681	elif test x$opt_level = xlight; then
682		AC_MSG_RESULT(light)
683		DEBUG_FLAGS="$DEBUG_FLAGS -O1"
684	elif test x$opt_level = xnormal; then
685		AC_MSG_RESULT(normal)
686		DEBUG_FLAGS="$DEBUG_FLAGS -O2"
687	elif test x$opt_level = xheavy; then
688		AC_MSG_RESULT(heavy)
689		DEBUG_FLAGS="$DEBUG_FLAGS -O3"
690	else
691		AC_MSG_RESULT(invalid)
692		echo "Invalid option given for --with-optimization: $opt_level."
693		echo "Expected one of 'none', 'size', 'debug', 'light', 'normal', 'heavy'."
694		exit 1
695	fi
696fi
697
698# link-time optimization
699GB_ENABLE_LTO
700DEBUG_FLAGS="$DEBUG_FLAGS $LTO_CFLAGS"
701
702
703# ---------------------------------------------------------------------
704# Debugging options
705# ---------------------------------------------------------------------
706
707AC_ARG_WITH([debug],
708            AS_HELP_STRING([--with-debug=no|messages|symbols|full|extreme],
709                           [Enable debug mode @<:@default=from CXXFLAGS@:>@]),
710            [dbg_level="$withval"], [dbg_level=""])
711AC_MSG_CHECKING([whether to enable debugging mode])
712if test x$dbg_level = x; then
713	AC_MSG_RESULT(from CXXFLAGS)
714else
715	# TODO: Maybe making a function to do these.
716	# Lets clean up CFLAGS of -g[0-3]?
717	for ccflag in $CFLAGS; do
718		AS_CASE([$ccflag],
719			[-g|-g1|-g2|-g3], [],
720			[NEWCFLAGS="$NEWCFLAGS $ccflag"])
721	done
722	CFLAGS="$NEWCFLAGS"
723
724	# Lets clean up CXXFLAGS of -g[0-3]?
725	for cxxflag in $CXXFLAGS; do
726		AS_CASE([$cxxflag],
727			[-g|-g1|-g2|-g3], [],
728			[NEWCXXFLAGS="$NEWCXXFLAGS $cxxflag"])
729	done
730	CXXFLAGS="$NEWCXXFLAGS"
731
732	if test x$dbg_level = xno; then
733		AC_MSG_RESULT(no)
734	elif test x$dbg_level = xmessages; then
735		AC_MSG_RESULT(messages only)
736		AC_DEFINE(DEBUG, 1, [Enable debug mode])
737	elif test x$dbg_level = xsymbols -o x$dbg_level = xfull -o x$dbg_level = xextreme; then
738		AC_MSG_RESULT($dbg_level)
739		if test x$dbg_level != xsymbols; then
740			AC_DEFINE(DEBUG, 1, [Enable debug mode])
741		fi
742		if test x$dbg_level = xextreme; then
743			DEBUG_FLAGS="$DEBUG_FLAGS -g3"
744		else
745			DEBUG_FLAGS="$DEBUG_FLAGS -g"
746		fi
747		# TODO: Maybe add warning that -O0 and -Og work better for debug symbols?
748	else
749		AC_MSG_RESULT(invalid)
750		echo "Invalid option given for --with-debug: $dbg_level."
751		echo "Expected one of 'no', 'messages', 'symbols', 'full', 'extreme'."
752		exit 1
753	fi
754fi
755
756AC_ARG_WITH([sanitizers],
757            AS_HELP_STRING([--with-sanitizers=no|address|thread|memory|undefined|dataflow|safe-stack],
758                           [Enable sanitizers @<:@default no@:>@]),
759            [enable_sanitizers="$withval"], [enable_sanitizers="no"])
760AC_MSG_CHECKING([whether to enable sanitizers])
761case "${enable_sanitizers}" in
762	no)
763		AC_MSG_RESULT(no)
764		CHK_SAN=""
765	;;
766	address|thread|memory|undefined|dataflow|safe-stack)
767		AC_MSG_RESULT($enable_sanitizers)
768		CHK_SAN="-fsanitize=$enable_sanitizers"
769	;;
770	*)
771		AC_MSG_RESULT(invalid)
772		echo "Invalid option given for --with-sanitizers: $enable_sanitizers."
773		echo "Expected one of 'no', 'address', 'thread', 'memory', 'yes'."
774		exit 1
775	;;
776esac
777
778SANITIZERS=""
779for cxx_flag in $CHK_SAN
780do
781	AX_CHECK_COMPILE_FLAG([$cxx_flag], [SANITIZERS="$SANITIZERS $cxx_flag"], [], [$CXXFLAGS -Werror])
782done
783
784CXXFLAGS="$CXXFLAGS $SANITIZERS"
785
786# SDL parachute?
787AC_ARG_ENABLE(sdl-parachute, AS_HELP_STRING([--enable-sdl-parachute], [Use SDL parachute @<:@default yes@:>@]),,enable_sdl_parachute=yes)
788AC_MSG_CHECKING([if we should disable the SDL parachute])
789if test x$enable_sdl_parachute = xno; then
790	AC_MSG_RESULT(yes)
791	AC_DEFINE(NO_SDL_PARACHUTE, 1, [Disable SDL parachute])
792else
793	AC_MSG_RESULT(no)
794fi
795
796
797# ---------------------------------------------------------------------
798# Warning level
799# ---------------------------------------------------------------------
800
801CHK_WARN="-Wall -Wextra -pedantic"
802CHK_WARN="$CHK_WARN -Walloc-zero -Walloca"
803CHK_WARN="$CHK_WARN -Wc++14-compat -Wc++17-compat -Wbool-compare -Wbool-operation"
804CHK_WARN="$CHK_WARN -Wcatch-value=3 -Wcast-align -Wcast-align=strict -Wcast-qual -Wcast-function-type"
805CHK_WARN="$CHK_WARN -Wconditionally-supported -Wctor-dtor-privacy -Wdisabled-optimization"
806CHK_WARN="$CHK_WARN -Wduplicated-branches -Wduplicated-cond -Wextra-semi"
807CHK_WARN="$CHK_WARN -Wformat-nonliteral -Wformat-security"
808CHK_WARN="$CHK_WARN -Wlogical-not-parentheses -Wlogical-op"
809CHK_WARN="$CHK_WARN -Wmissing-include-dirs -Wnon-virtual-dtor -Wnull-dereference"
810CHK_WARN="$CHK_WARN -Wold-style-cast -Woverloaded-virtual -Wplacement-new"
811CHK_WARN="$CHK_WARN -Wredundant-decls -Wshift-negative-value -Wshift-overflow"
812CHK_WARN="$CHK_WARN -Wtrigraphs -Wundef -Wuninitialized -Wuseless-cast -Wwrite-strings"
813# Warnings that give lots of warnings
814#CHK_WARN="$CHK_WARN -Wformat-signedness -Wcast-align=strict -Weffc++ -Wpadded -Wshadow -Wsign-conversion"
815# GCC attributes
816#CHK_WARN="$CHK_WARN -Wsuggest-attribute=cold -Wsuggest-attribute=const -Wsuggest-attribute=format -Wsuggest-attribute=malloc -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure"
817# C++11 and newer
818#CHK_WARN="$CHK_WARN -Wsuggest-final-methods -Wsuggest-final-types -Wsuggest-override -Wzero-as-null-pointer-constant"
819CHK_WARN="$CHK_WARN -Wzero-as-null-pointer-constant"
820# Clang warnings
821CHK_WARN="$CHK_WARN -Wunused-const-variables -Wabsolute-value -Wdeprecated-register -Wmismatched-tags -Wunused-private-field"
822
823# Eliminate some spurious warnings due to low optimization level.
824if test x$opt_level = xnone -o x$opt_level = xdebug; then
825	CHK_WARN="$CHK_WARN -Wno-maybe-uninitialized"
826fi
827
828# Warnings give errors
829AC_ARG_ENABLE(warning-errors, AS_HELP_STRING([--enable-warning-errors], [Turn all warnings into errors @<:@default no@:>@]),,enable_warning_errors=no)
830if test x$enable_warning_errors = xyes; then
831	CHK_WARN="-Werror $CHK_WARN"
832fi
833
834# Pedantic warnings give errors
835AC_ARG_ENABLE(pedantic-errors, AS_HELP_STRING([--enable-pedantic-errors], [Turn all pedantic warnings into errors @<:@default no@:>@]),,enable_pedantic_errors=no)
836if test x$enable_pedantic_errors = xyes; then
837	CHK_WARN="-pedantic-errors $CHK_WARN"
838fi
839
840WARNINGS=""
841for cxx_flag in $CHK_WARN
842do
843	AX_CHECK_COMPILE_FLAG([$cxx_flag], [WARNINGS="$WARNINGS $cxx_flag"], [], [$DEBUG_FLAGS -Werror])
844done
845
846DEBUG_FLAGS="$DEBUG_FLAGS $WARNINGS"
847
848
849# --------------------
850# External features
851# --------------------
852
853# Build any external programs?
854AC_ARG_ENABLE(tools, AS_HELP_STRING([--disable-tools], [Only build the main program]),,enable_tools=yes)
855AC_MSG_CHECKING([whether to build only the main program])
856if test x$enable_tools = xno; then
857	AC_MSG_RESULT(yes)
858	AM_CONDITIONAL(BUILD_TOOLS, false)
859	enable_gtk_interface=no
860	enable_gimp_plugin=no
861	enable_compiler=no
862else
863	AM_CONDITIONAL(BUILD_TOOLS, true)
864	AC_MSG_RESULT(no)
865fi
866
867# Build compiler?
868AC_ARG_ENABLE(compiler, AS_HELP_STRING([--enable-compiler], [Build the usecode compiler @<:@default no@:>@]),,enable_compiler=no)
869AC_MSG_CHECKING([whether to build the usecode compiler])
870if test x$enable_compiler = xno; then
871	AC_MSG_RESULT(no)
872	AM_CONDITIONAL(BUILD_COMPILER, false)
873else
874	AC_MSG_RESULT(yes)
875	AM_CONDITIONAL(BUILD_COMPILER, true)
876fi
877
878# Build data files?
879AC_ARG_ENABLE(data, AS_HELP_STRING([--enable-data], [Create the data files @<:@default yes@:>@]),,enable_data=yes)
880AC_MSG_CHECKING([whether to build the data files])
881if test x$enable_data = xno; then
882	AC_MSG_RESULT(no)
883	AM_CONDITIONAL(DATA_FILES, false)
884else
885	AM_CONDITIONAL(DATA_FILES, true)
886	AC_MSG_RESULT(yes)
887fi
888
889# Build mods?
890AC_ARG_ENABLE(mods, AS_HELP_STRING([--enable-mods], [Build the Exult mods (requires usecode compiler) @<:@default no@:>@]),,enable_mods=no)
891AC_MSG_CHECKING([whether to build the Exult mods])
892if test x$enable_mods = xno -o x$enable_compiler = xno; then
893	AC_MSG_RESULT(no)
894	AM_CONDITIONAL(BUILD_MODS, false)
895else
896	AM_CONDITIONAL(BUILD_MODS, true)
897	AC_MSG_RESULT(yes)
898fi
899
900# Freetype2 (optional, used in ExultStudio, shapes/fontgen.cc)
901AC_PATH_PROG(FT2CONFIG, freetype-config)
902if test -n "$FT2CONFIG"; then
903	AC_DEFINE(HAVE_FREETYPE2, 1, [Have freetype2])
904	FREETYPE2_LIBS=`$FT2CONFIG --libs`
905	AC_SUBST(FREETYPE2_LIBS)
906	FREETYPE2_INCLUDES=`$FT2CONFIG --cflags`
907	AC_SUBST(FREETYPE2_INCLUDES)
908fi
909
910# exult-studio
911AC_ARG_ENABLE(exult-studio, AS_HELP_STRING([--enable-exult-studio], [Build Exult Studio @<:@default no@:>@]),,enable_exult_studio=no)
912AC_MSG_CHECKING([whether to build Exult Studio])
913if test x$enable_exult_studio = xyes; then
914	AC_MSG_RESULT(yes)
915	if test x$have_gtk = xno; then
916		echo "Umm, but we don't have any Gtk+ stuff."
917		echo "Try again, either with Gtk-3.16 or newer, or with --disable-exult-studio"
918		exit 1
919	fi
920	AM_CONDITIONAL(BUILD_STUDIO, true)
921else
922	AM_CONDITIONAL(BUILD_STUDIO, false)
923	AC_MSG_RESULT(no)
924fi
925
926# Usecode debugger
927AC_ARG_WITH([usecode-debugger],
928            AS_HELP_STRING([--with-usecode-debugger=no|console|yes],
929                           [Experimental and buggy support for usecode debugging @<:@default no@:>@]),
930            [enable_usecode_debugger="$withval"], [enable_usecode_debugger="no"])
931AC_MSG_CHECKING([whether to enable the usecode debugger])
932if test x$enable_usecode_debugger = xconsole -o x$enable_usecode_debugger = xyes; then
933	AC_MSG_RESULT(yes)
934	if test x$enable_usecode_debugger = xconsole; then
935		AC_DEFINE(USECODE_CONSOLE_DEBUGGER, 1, [Enable Usecode debugging on console])
936	elif test x$enable_exult_studio != xyes; then
937		echo "But we are not building Exult Studio."
938		echo "Try again, either with --enable-exult-studio, or without the usecode debugger"
939		exit 1
940	elif test x$enable_exult_studio_support != xyes; then
941		echo "But we are not building Exult with Exult Studio support."
942		echo "Try again, either with --enable-exult-studio-support, or without the usecode debugger"
943		exit 1
944	fi
945	AC_DEFINE(USECODE_DEBUGGER, 1, [Enable Usecode debugging])
946else
947	AC_MSG_RESULT(no)
948fi
949
950# Usecode container
951AC_ARG_ENABLE(usecode-container, AS_HELP_STRING([--enable-usecode-container], [Enable display of usecode container for debugging purposes @<:@default no@:>@]),,enable_usecode_container=no)
952AC_MSG_CHECKING([whether to display the usecode container in Gumps])
953if test x$enable_usecode_container = xyes; then
954	AC_MSG_RESULT(yes)
955	AC_DEFINE(SHOW_USECODE_CONTAINER, 1, [Display Usecode container])
956else
957	AC_MSG_RESULT(no)
958fi
959
960# Show non-readied objects
961AC_ARG_ENABLE(nonreadied-objects, AS_HELP_STRING([--enable-nonreadied-objects], [Enable display of non-readied objects for debugging purposes @<:@default no@:>@]),,enable_nonreadied_objects=no)
962AC_MSG_CHECKING([whether to display non-readied objects in Gumps])
963if test x$enable_nonreadied_objects = xyes; then
964	AC_MSG_RESULT(yes)
965	AC_DEFINE(SHOW_NONREADIED_OBJECTS, 1, [Display non-readied objects])
966else
967	AC_MSG_RESULT(no)
968fi
969
970# gnome-shp-thumbnailer
971AC_ARG_ENABLE(gnome-shp-thumbnailer, AS_HELP_STRING([--enable-gnome-shp-thumbnailer], [Build Gnome SHP Thumbnailer @<:@default no@:>@]),,enable_gnome_shp_thumbnailer=no)
972AC_MSG_CHECKING([whether to build the Gnome SHP Thumbnailer])
973if test x$enable_gnome_shp_thumbnailer = xyes; then
974	AC_MSG_RESULT(yes)
975	if test x$have_gdk_pixbuf = xno; then
976		echo "Umm, but we don't have any Gdk-Pixbuf stuff."
977		echo "Try again, either with Gdk-Pixbuf-2.0, or with --disable-gnome-shp-thumbnailer"
978		exit 1
979	fi
980	AM_CONDITIONAL(BUILD_GTHUMB, true)
981else
982	AM_CONDITIONAL(BUILD_GTHUMB, false)
983	AC_MSG_RESULT(no)
984fi
985
986# GIMP plugin
987AM_CONDITIONAL(GIMP_PLUGIN, false)
988AC_ARG_ENABLE(gimp-plugin, AS_HELP_STRING([--enable-gimp-plugin], [Build the GIMP plugin @<:@default no@:>@]),,enable_gimp_plugin=no)
989AC_MSG_CHECKING([whether to build the GIMP plugin])
990if test x$enable_gimp_plugin = xyes; then
991	AC_MSG_RESULT(yes)
992	AC_MSG_CHECKING([for gimptool])
993	AC_CHECK_PROGS(GIMPTOOL, gimptool-2.0 gimptool-1.3 gimptool-1.2 gimptool)
994	if test -z "$GIMPTOOL"; then
995		AC_MSG_RESULT([no, not building GIMP plugin])
996	else
997		AC_MSG_CHECKING([for GIMP version])
998		gimp_version=`$GIMPTOOL --version | awk 'BEGIN { FS = "."; } { print $1 * 1000 + $2*100+$3;}'`
999		if test "$gimp_version" -ge 1312; then
1000			AC_MSG_RESULT([found >= 1.3.12])
1001			AC_SUBST(GIMPTOOL)
1002			AM_CONDITIONAL(GIMP_PLUGIN, true)
1003			GIMP_PLUGIN_PREFIX=`$GIMPTOOL --gimpplugindir`
1004			GIMP_PLUGIN_PREFIX="$GIMP_PLUGIN_PREFIX/plug-ins"
1005			AC_SUBST(GIMP_PLUGIN_PREFIX)
1006			AC_DEFINE(HAVE_GIMP, 1, [Have GIMP])
1007			GIMP_INCLUDES=`$GIMPTOOL --cflags`
1008			GIMP_LIBS=`$GIMPTOOL --libs`
1009			AC_SUBST(GIMP_INCLUDES)
1010			AC_SUBST(GIMP_LIBS)
1011		elif test "$gimp_version" -ge 1200 -a \
1012				"$gimp_version" -lt 1300; then
1013			AC_MSG_RESULT([found 1.2.x])
1014			AC_SUBST(GIMPTOOL)
1015			AM_CONDITIONAL(GIMP_PLUGIN, true)
1016			GIMP_PLUGIN_PREFIX=`$GIMPTOOL --gimpplugindir`
1017			GIMP_PLUGIN_PREFIX="$GIMP_PLUGIN_PREFIX/plug-ins"
1018			AC_SUBST(GIMP_PLUGIN_PREFIX)
1019			AC_DEFINE(HAVE_GIMP, 1, [Have GIMP])
1020			AC_DEFINE(HAVE_GIMP_1_2, 1, [Have GIMP 1.2.x])
1021			GIMP_INCLUDES=`$GIMPTOOL --cflags`
1022			GIMP_LIBS=`$GIMPTOOL --libs`
1023			AC_SUBST(GIMP_INCLUDES)
1024			AC_SUBST(GIMP_LIBS)
1025		else
1026			AC_MSG_RESULT([found < 1.2.00 - disabling plugin])
1027		fi
1028	fi
1029else
1030	AC_MSG_RESULT(no)
1031fi
1032
1033# ----------------------------------------------------------------
1034# If we are cross-compiling, look for expack and head2data in PATH
1035# ----------------------------------------------------------------
1036
1037AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
1038
1039AS_IF([ test $cross_compiling = yes ], [
1040	if test x$enable_data = xyes; then
1041		AC_PATH_PROG(EXPACK, expack, no)
1042		echo "While cross compiling you need to have a build system native"
1043		echo "expack in your path to generate Exult's data files."
1044		echo "After you natively compiled Exult you will find expack in the tools subfolder."
1045  		if test x$EXPACK = xno; then
1046			AC_MSG_ERROR([Could not find expack in your path, cannot generate data files.])
1047		fi
1048	fi
1049
1050	if test x$enable_tools = xyes; then
1051		AC_PATH_PROG(HEAD2DATA, head2data, no)
1052		echo "While cross compiling you need to have a build system native"
1053		echo "head2data in your path to build part of Exult's tools."
1054		echo "After you natively compiled Exult you will find head2data"
1055		echo "in the usecode/ucxt subfolder."
1056		if test x$HEAD2DATA = xno; then
1057			AC_MSG_ERROR([Could not find head2data in your path, cannot generate data files for tools.])
1058		fi
1059	fi
1060])
1061
1062# ------------------
1063# Generate output
1064# ------------------
1065
1066AC_SUBST(SDL_CFLAGS)
1067AC_SUBST(SDL_LIBS)
1068AC_SUBST(OGG_LIBS)
1069AC_SUBST(VORBISFILE_LIBS)
1070AC_SUBST(VORBIS_LIBS)
1071AC_SUBST(WINDOWING_SYSTEM)
1072AC_SUBST(EXE_TARGET)
1073AC_SUBST(EXULT_DATADIR)
1074AC_SUBST(SYSLIBS)
1075AC_SUBST(ICON_FILE)
1076AC_SUBST(DEBUG_FLAGS)
1077AC_SUBST(ZLIB_LIBS)
1078AC_SUBST(MT32EMU_LIBS)
1079AC_SUBST(MT32EMU_CFLAGS)
1080AC_SUBST(FLUIDSYNTH_LIBS)
1081AC_SUBST(ALSA_LIBS)
1082AC_SUBST(WARNINGS)
1083AC_SUBST(AR_FLAGS)
1084
1085AC_CONFIG_FILES([
1086exult.spec
1087Info.plist
1088macosx/exult_studio_info.plist
1089Makefile
1090audio/Makefile
1091audio/midi_drivers/Makefile
1092audio/midi_drivers/timidity/Makefile
1093conf/Makefile
1094content/Makefile
1095content/sifixes/Makefile
1096content/si/Makefile
1097content/bgkeyring/Makefile
1098content/bg/Makefile
1099content/islefaq/Makefile
1100files/Makefile
1101files/sha1/Makefile
1102files/zip/Makefile
1103gamemgr/Makefile
1104gumps/Makefile
1105pathfinder/Makefile
1106flic/Makefile
1107tools/Makefile
1108data/Makefile
1109docs/Makefile
1110desktop/Makefile
1111objs/Makefile
1112imagewin/Makefile
1113shapes/Makefile
1114shapes/shapeinf/Makefile
1115usecode/Makefile
1116usecode/compiler/Makefile
1117usecode/ucxt/Makefile
1118usecode/ucxt/Docs/Makefile
1119usecode/ucxt/data/Makefile
1120usecode/ucxt/include/Makefile
1121usecode/ucxt/src/Makefile
1122mapedit/Makefile
1123server/Makefile
1124])
1125AC_OUTPUT
1126
1127dnl ****************
1128dnl Configure Status
1129dnl ****************
1130
1131echo
1132echo Exult v$VERSION
1133echo
1134echo SDL........................ : `$SDL_CONFIG --version`
1135if test x$have_gtk = xyes; then
1136echo GLIB....................... : `$PKG_CONFIG --modversion glib-2.0`
1137echo GTK+....................... : `$PKG_CONFIG --modversion gtk+-3.0`
1138fi
1139if test x$have_gdk_pixbuf = xyes; then
1140echo GDK-Pixbuf................. : `$PKG_CONFIG --modversion gdk-pixbuf-2.0`
1141fi
1142echo
1143echo Build tools................ : $enable_tools
1144echo Build usecode compiler..... : $enable_compiler
1145echo Build Exult mods........... : $enable_mods
1146echo Build Exult Studio......... : $enable_exult_studio
1147echo Exult Studio support....... : $enable_exult_studio_support
1148echo
1149if test x$enable_all_hq_scalers = xyes; then
1150echo Build all HQ scalers....... : $enable_all_hq_scalers
1151else
1152echo Build HQ2X scaler.......... : $enable_hq2x
1153echo Build HQ3X scaler.......... : $enable_hq3x
1154echo Build HQ4X scaler.......... : $enable_hq4x
1155fi
1156echo Build NxBR scalers......... : $enable_nxbr
1157
1158if test x$ARCH = xmacosx; then
1159	if test x$enable_static_libs != xno; then
1160		echo
1161		echo Mac OS X static libs....... : $with_macosx_static_lib_path
1162	fi
1163fi
1164if test x"$with_macosx_code_signature" != x; then
1165	echo
1166	echo Mac OS X code sign ID...... : $with_macosx_code_signature
1167fi
1168if test ${cross_compiling} = yes; then
1169	echo
1170	echo Cross Compiling for $host
1171	if test x$enable_data = xyes; then
1172		echo expack path................ : $EXPACK
1173	fi
1174	if test x$enable_tools = xyes; then
1175		echo head2data path............. : $HEAD2DATA
1176	fi
1177fi
1178echo
1179echo "Now type 'make' to build Exult"
1180