summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: eb00278528333b7f0eeda8ce292a717eb6d092de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Process this file with autoconf to produce a configure script.
#
# Copyright (C) 2013  Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program.  If not, see
# <http://www.gnu.org/licenses/>.

AC_INIT([boukengine], [0.1.0], [mailto:pj@pehjota.net], [boukengine],
	[http://www.pehjota.net/projects/overworld-rpg/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([src/main.c])

AM_INIT_AUTOMAKE([gnu dist-bzip2 dist-xz subdir-objects])

AC_PROG_CC()
AM_PROG_CC_C_O()

AC_C_INLINE()

AC_CHECK_HEADERS([stdlib.h string.h inttypes.h],
	[],
	[AC_MSG_ERROR([cannot find or include standard C library headers])])

AC_TYPE_SIZE_T()

AC_FUNC_MALLOC()
AC_CHECK_FUNCS([memset strdup strndup],
	[],
	[AC_MSG_ERROR([cannot find standard C library functions])])

PKG_PROG_PKG_CONFIG()
PKG_CHECK_MODULES([SDL], [sdl])
PKG_CHECK_MODULES([SDL_IMAGE], [SDL_image])
PKG_CHECK_MODULES([ZLIB], [zlib])
PKG_CHECK_MODULES([EXPAT], [expat])
PKG_CHECK_MODULES([LUA], [lua >= 5.1], [],
	[PKG_CHECK_MODULES([LUA], [lua5.1 >= 5.1], [],
		[PKG_CHECK_MODULES([LUA], [lua-5.1 >= 5.1])])
	])

dnl AC_ARG_VAR([XCF2PNG], [path to xcf2png utility])
AC_ARG_WITH(
	[system-xcf2png],
	[AS_HELP_STRING([--with-system-xcf2png[=PATH]], [use system xcf2png])],
	[
		case "${withval}" in
			'yes'|'')
				AC_PATH_PROG([XCF2PNG], [xcf2png])
				if test -z "${XCF2PNG}"; then
					AC_MSG_ERROR([xcf2png not found])
				fi
				embedded_xcf2png=false
				;;
			'no')
				embedded_xcf2png=true
				;;
			*)
				XCF2PNG="${withval}"
				AC_SUBST([XCF2PNG])
				embedded_xcf2png=false
				;;
		esac
	],
	[
		embedded_xcf2png=true
	]
)
if ${embedded_xcf2png}; then
	AS_MKDIR_P([3rdparty/xcftools])
	XCF2PNG='3rdparty/xcftools/xcf2png$(EXEEXT)'
	abs_srcdir="$(cd "${srcdir}" && pwd)"
	(
		cd 3rdparty/xcftools
		"${SHELL}" "${abs_srcdir}/3rdparty/xcftools/configure"
	)
fi
AM_CONDITIONAL([EMBEDDED_XCF2PNG], [${embedded_xcf2png}])

if test "x$GCC" = "xyes"; then
	GCC_CFLAGS="-pedantic -Wall -Wextra -Werror"
	GCC_CFLAGS="${GCC_CFLAGS} -Wformat=2 -Wswitch -Wswitch-enum"
	GCC_CFLAGS="${GCC_CFLAGS} -Wdeclaration-after-statement -Wundef -Wshadow"
	GCC_CFLAGS="${GCC_CFLAGS} -Wpointer-arith -Wbad-function-cast"
	GCC_CFLAGS="${GCC_CFLAGS} -Wcast-qual -Wcast-align -Wwrite-strings"
	#GCC_CFLAGS="${GCC_CFLAGS} -Wconversion"
	GCC_CFLAGS="${GCC_CFLAGS} -Wlogical-op -Waggregate-return"
	GCC_CFLAGS="${GCC_CFLAGS} -Wstrict-prototypes -Wold-style-definition"
	GCC_CFLAGS="${GCC_CFLAGS} -Wmissing-prototypes -Wmissing-declarations"
	GCC_CFLAGS="${GCC_CFLAGS} -Wredundant-decls -Wnested-externs"
	GCC_CFLAGS="${GCC_CFLAGS} -Wunreachable-code -Winline"
	GCC_CFLAGS="${GCC_CFLAGS} -Wdisabled-optimization"
	GCC_CFLAGS="${GCC_CFLAGS} -fstack-protector -Wstack-protector"
fi
AC_SUBST(GCC_CFLAGS)

AC_ARG_ENABLE([debug-tmx],
	[AC_HELP_STRING([--enable-debug-tmx],
		[enable debug output from TMX parser])],
	[enable_debug_tmx=yes],
	[])
if test "x$enable_debug_tmx" = "xyes"; then
	AC_DEFINE([DEBUG_TMX], [1],
		[Define to 1 to enable debug output from TMX parser.])
fi

AC_ARG_ENABLE([debug-compression],
	[AC_HELP_STRING([--enable-debug-compression],
		[enable debug output from tile data inflation])],
	[enable_debug_compression=yes],
	[])
if test "x$enable_debug_compression" = "xyes"; then
	AC_DEFINE([DEBUG_COMPRESSION], [1],
		[Define to 1 to enable debug output from tile data inflation.])
fi

AC_ARG_ENABLE([debug-render],
	[AC_HELP_STRING([--enable-debug-render],
		[enable debug output from map layer blits and area rendering])],
	[enable_debug_render=yes],
	[])
if test "x$enable_debug_render" = "xyes"; then
	AC_DEFINE([DEBUG_RENDER], [1],
		[Define to 1 to enable debug output from map layer blits and
			area rendering.])
fi

AC_ARG_ENABLE([debug-palettes],
	[AC_HELP_STRING([--enable-debug-palettes],
		[enable debug output with surface palette colors listings])],
	[enable_debug_palettes=yes],
	[])
if test "x$enable_debug_palettes" = "xyes"; then
	AC_DEFINE([DEBUG_PALETTES], [1],
		[Define to 1 to enable debug output with surface palette colors
			listings.])
fi

AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT()