1AC_INIT(Crispy Doom, 5.10.3,
2        fabian@greffrath.com, crispy-doom)
3
4PACKAGE_SHORTNAME=${PACKAGE_NAME% Doom}
5PACKAGE_SHORTDESC="Limit-removing enhanced-resolution Doom source port"
6PACKAGE_COPYRIGHT="Copyright (C) 1993-2021"
7PACKAGE_LICENSE="GNU General Public License, version 2"
8PACKAGE_MAINTAINER="Fabian Greffrath"
9PACKAGE_URL="http://fabiangreffrath.github.io/crispy-doom"
10PACKAGE_RDNS="io.github.fabiangreffrath"
11PACKAGE_BUGREPORT="https://github.com/fabiangreffrath/crispy-doom/issues"
12
13AC_CONFIG_AUX_DIR(autotools)
14AC_CANONICAL_HOST
15
16orig_CFLAGS="$CFLAGS"
17
18AM_PROG_AR
19AC_PROG_CC
20AC_PROG_RANLIB
21AC_CHECK_PROG(HAVE_PYTHON, python3.8, true, false)
22
23OPT_LEVEL=2
24
25# If this is gcc, we have some options we'd like to turn on.  Turn on
26# optimisation and debugging symbols.
27
28if test "$GCC" = "yes"
29then
30        WARNINGS="-Wall -Wdeclaration-after-statement -Wredundant-decls"
31        CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS"
32fi
33
34PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.7])
35PKG_CHECK_MODULES(SDLMIXER, [SDL2_mixer >= 2.0.2])
36PKG_CHECK_MODULES(SDLNET, [SDL2_net >= 2.0.0])
37
38# Check for bash-completion.
39AC_ARG_ENABLE([bash-completion],
40AS_HELP_STRING([--disable-bash-completion], [Disable bash-completion])
41)
42AS_IF([test "x$enable_bash_completion" != xno], [
43    AS_IF([test "x$HAVE_PYTHON" = xfalse], [
44        AC_MSG_WARN([Building bash-completion requires Python, but Python not found])
45        enable_bash_completion=no
46    ])
47])
48
49# Check for doc.
50AC_ARG_ENABLE([doc],
51AS_HELP_STRING([--disable-doc], [Disable documentation])
52)
53AS_IF([test "x$enable_doc" != xno], [
54    AS_IF([test "x$HAVE_PYTHON" = xfalse], [
55        AC_MSG_WARN([Building documentation requires Python, but Python not found])
56        enable_doc=no
57    ])
58])
59
60# Check for fonts.
61AC_ARG_ENABLE([fonts],
62AS_HELP_STRING([--disable-fonts], [Disable fonts])
63)
64AS_IF([test "x$enable_fonts" != xno], [
65    AS_IF([test "x$HAVE_PYTHON" = xfalse], [
66        AC_MSG_WARN([Building fonts require Python, but Python not found])
67        enable_fonts=no
68    ])
69])
70
71# Check for icons.
72AC_ARG_ENABLE([icons],
73AS_HELP_STRING([--disable-icons], [Disable icons])
74)
75AS_IF([test "x$enable_icons" != xno], [
76    AS_IF([test "x$HAVE_PYTHON" = xfalse], [
77        AC_MSG_WARN([Building icons require Python, but Python not found])
78        enable_icons=no
79    ])
80])
81
82# [Crispy] Check for zlib.
83AC_ARG_WITH([zlib],
84AS_HELP_STRING([--without-zlib],
85    [Build without zlib @<:@default=check@:>@]),
86[],
87[
88    [with_zlib=check]
89])
90AS_IF([test "x$with_zlib" != xno], [
91    PKG_CHECK_MODULES(LIBZ, zlib, [
92        AC_DEFINE([HAVE_LIBZ], [1], [zlib installed])
93    ], [
94        AS_IF([test "x$with_zlib" != xcheck], [AC_MSG_FAILURE(
95            [--with-zlib was given, but test for zlib failed])
96        ])
97    ])
98])
99
100# Check for libsamplerate.
101AC_ARG_WITH([libsamplerate],
102AS_HELP_STRING([--without-libsamplerate],
103    [Build without libsamplerate @<:@default=check@:>@]),
104[],
105[
106    [with_libsamplerate=check]
107])
108AS_IF([test "x$with_libsamplerate" != xno], [
109    PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.8, [
110        AC_DEFINE([HAVE_LIBSAMPLERATE], [1], [libsamplerate installed])
111    ], [
112        AS_IF([test "x$with_libsamplerate" != xcheck], [AC_MSG_FAILURE(
113            [--with-libsamplerate was given, but test for libsamplerate failed])
114        ])
115    ])
116])
117
118# Check for libpng.
119AC_ARG_WITH([libpng],
120AS_HELP_STRING([--without-libpng],
121    [Build without libpng @<:@default=check@:>@]),
122[],
123[
124    [with_libpng=check]
125])
126AS_IF([test "x$with_libpng" != xno], [
127    PKG_CHECK_MODULES(PNG, libpng >= 1.2.50, [
128        AC_DEFINE([HAVE_LIBPNG], [1], [libpng installed])
129    ], [
130        AS_IF([test "x$with_libpng" != xcheck], [AC_MSG_FAILURE(
131            [--with-libpng was given, but test for libpng failed])
132        ])
133    ])
134])
135
136# [crispy] true-color rendering as a compile-time option
137AC_ARG_ENABLE([truecolor],
138AS_HELP_STRING([--enable-truecolor],
139    [true-color rendering (experimental) @<:@default=no@:>@]))
140AS_IF([test "x$enable_truecolor" = "xyes"], [
141    AC_DEFINE([CRISPY_TRUECOLOR], [1], [true-color rendering])
142])
143
144# TODO: We currently link everything against libraries that don't need it.
145# Use the specific library CFLAGS/LIBS variables instead of setting them here.
146CFLAGS="$CFLAGS $SDL_CFLAGS ${SAMPLERATE_CFLAGS:-} ${PNG_CFLAGS:-} ${LIBZ_CFLAGS:-}"
147LDFLAGS="$LDFLAGS $SDL_LIBS ${SAMPLERATE_LIBS:-} ${PNG_LIBS:-} ${LIBZ_LIBS:-}"
148AC_CHECK_LIB(m, log)
149
150# [crispy] use stdlib's qsort() function for sorting the vissprites[] array
151AC_CHECK_FUNCS(qsort)
152
153AC_CHECK_HEADERS([dirent.h linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])
154AC_CHECK_FUNCS(mmap ioperm)
155AC_CHECK_DECLS([strcasecmp, strncasecmp], [], [], [[#include <strings.h>]])
156
157# OpenBSD I/O i386 library for I/O port access.
158# (64 bit has the same thing with a different name!)
159
160AC_CHECK_LIB(i386, i386_iopl)
161AC_CHECK_LIB(amd64, amd64_iopl)
162
163case "$host" in
164  *-*-mingw* | *-*-cygwin* | *-*-msvc* )
165    AC_CHECK_TOOL(WINDRES, windres, )
166    ;;
167  *)
168    WINDRES=
169    ;;
170esac
171
172AC_CHECK_TOOL(OBJDUMP, objdump, )
173AC_CHECK_TOOL(STRIP, strip, )
174
175AC_ARG_ENABLE([werror], AS_HELP_STRING([--enable-werror], [Treat warnings as errors]))
176
177AS_IF([test "x$enable_werror" = "xyes"], [
178        CFLAGS="$CFLAGS -Werror"
179])
180
181AM_CONDITIONAL(HAVE_WINDRES, test "$WINDRES" != "")
182AM_CONDITIONAL(HAVE_BASH_COMPLETION, [test "x$enable_bash_completion" != xno])
183AM_CONDITIONAL(HAVE_DOC, [test "x$enable_doc" != xno])
184AM_CONDITIONAL(HAVE_FONTS, [test "x$enable_fonts" != xno])
185AM_CONDITIONAL(HAVE_ICONS, [test "x$enable_icons" != xno])
186
187dnl Automake v1.8.0 is required, please upgrade!
188
189AM_INIT_AUTOMAKE([1.8.0 foreign])
190m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
191
192WINDOWS_RC_VERSION=`echo $PACKAGE_VERSION | sed 's/-.*//; s/\./, /g; s/$/, 0/'`
193
194dnl Without a hyphen. This is used for the bash-completion scripts.
195PROGRAM_SPREFIX=$(echo $PACKAGE_SHORTNAME | tr A-Z a-z)
196
197dnl With a hyphen, used almost everywhere else.
198PROGRAM_PREFIX=${PROGRAM_SPREFIX}-
199
200AC_SUBST(PROGRAM_PREFIX)
201AC_DEFINE_UNQUOTED(PROGRAM_PREFIX, "$PROGRAM_PREFIX",
202                   Change this when you create your awesome forked version)
203AC_SUBST(PROGRAM_SPREFIX)
204
205AM_CONFIG_HEADER(config.h:config.hin)
206
207AC_SUBST(WINDOWS_RC_VERSION)
208AC_SUBST(SDLMIXER_CFLAGS)
209AC_SUBST(SDLMIXER_LIBS)
210
211AC_SUBST(SDLNET_CFLAGS)
212AC_SUBST(SDLNET_LIBS)
213
214AC_SUBST(ac_aux_dir)
215
216AC_SUBST(PACKAGE_SHORTNAME)
217AC_SUBST(PACKAGE_SHORTDESC)
218AC_SUBST(PACKAGE_COPYRIGHT)
219AC_SUBST(PACKAGE_LICENSE)
220AC_SUBST(PACKAGE_MAINTAINER)
221AC_SUBST(PACKAGE_URL)
222AC_SUBST(PACKAGE_RDNS)
223AC_SUBST(PACKAGE_BUGREPORT)
224
225dnl Shut up the datarootdir warnings.
226AC_DEFUN([AC_DATAROOTDIR_CHECKED])
227
228AC_OUTPUT([
229Makefile
230man/Makefile
231man/bash-completion/Makefile
232man/bash-completion/doom.template
233man/bash-completion/heretic.template
234man/bash-completion/hexen.template
235man/bash-completion/strife.template
236midiproc/Makefile
237opl/Makefile
238opl/examples/Makefile
239pcsound/Makefile
240pkg/Makefile
241pkg/config.make
242pkg/osx/Info.plist
243rpm.spec
244data/Makefile
245src/Makefile
246src/Doom.metainfo.xml
247src/Doom.desktop
248src/Doom_Screensaver.desktop
249src/doom/Makefile
250src/Heretic.metainfo.xml
251src/Heretic.desktop
252src/heretic/Makefile
253src/Hexen.metainfo.xml
254src/Hexen.desktop
255src/hexen/Makefile
256src/resource.rc
257src/setup-res.rc
258src/setup/Makefile
259src/setup/Setup.desktop
260src/setup/setup-manifest.xml
261src/Strife.metainfo.xml
262src/Strife.desktop
263src/strife/Makefile
264textscreen/Makefile
265textscreen/examples/Makefile
266textscreen/fonts/Makefile
267])
268
269