a9018e12b8b7373350d1a9fa237c8adbe738d24c
[chaz/yoink] / configure.ac
1
2 #
3 # Yoink
4 # Process this file with autoconf to produce a configure script.
5 #
6
7 AC_PREREQ([2.60])
8
9 AC_INIT([Yoink], [0.1], [chaz@dogcows.com], [yoink])
10
11 AC_CANONICAL_TARGET
12
13 AC_CONFIG_SRCDIR([src/GameLayer.cc])
14 AC_CONFIG_MACRO_DIR([m4])
15
16 AM_INIT_AUTOMAKE
17
18
19 #
20 # Checks for programs.
21 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
23 AC_PROG_CXX
24 AC_PROG_CC
25 AC_PROG_CPP
26 AC_PROG_INSTALL
27 AC_PROG_RANLIB
28 AM_PROG_CC_C_O
29
30
31 #
32 # Configure platform-specific stuff.
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
35 case "${host}" in
36 *mingw32*)
37 MINGW32=yes
38 WIN32=yes
39 AC_PATH_PROGS([WINDRES], [windres $host_alias-windres $host_os-windres])
40 if test "x$WINDRES" = x
41 then
42 AC_MSG_ERROR([windres could not be found])
43 fi
44 AC_SUBST(WINDRES)
45 AC_PATH_PROGS([MAKENSIS], [makensis])
46 AC_SUBST(MAKENSIS)
47 ;;
48 *cygwin*)
49 CYGWIN=yes
50 WIN32=yes
51 ;;
52 *-apple-darwin*)
53 MACOSX=yes
54 LIBS="$LIBS -Wl,-framework"
55 ;;
56 *-linux-gnu*)
57 LINUX=yes
58 AC_PATH_PROGS([RPMBUILD], [rpmbuild])
59 AC_SUBST(RPMBUILD)
60 ;;
61 esac
62
63 AM_CONDITIONAL([LINUX], test "$LINUX" = "yes")
64 AM_CONDITIONAL([WIN32], test "$WIN32" = "yes")
65
66
67 #
68 # Checks for configuration arguments.
69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70
71 AC_ARG_ENABLE([developer],
72 [ --enable-developer use all compiler flags developers need],
73 [developer=$enableval],
74 [developer=no])
75
76 AC_ARG_ENABLE([debug],
77 [ --enable-debug include debugging symbols and features],
78 [debug=$enableval],
79 [debug=no])
80
81 AC_ARG_ENABLE([profile],
82 [ --enable-profile make a binary for use with gprof profiler],
83 [profile=$enableval],
84 [profile=no])
85
86 AC_ARG_ENABLE([extra-warnings],
87 [ --enable-extra-warnings make the gcc compiler give more warnings],
88 [extra_warnings=$enableval],
89 [extra_warnings=no])
90
91 AC_ARG_WITH([log-level],
92 [AS_HELP_STRING([--with-log-level=NUM],
93 [0, none... 1, errors... 4, everything (default: 3)])],
94 [log_level=$withval],
95 [log_level=3])
96
97 AC_ARG_ENABLE([double],
98 [ --enable-double use double-precision numbers],
99 [double=$enableval],
100 [double=no])
101
102
103 if test x$developer = xyes
104 then
105 debug=yes
106 log_level=4
107
108 if test x$WIN32 != xyes
109 then
110 # i haven't had much success with gprof profiling on win32
111 profile=yes
112 fi
113 fi
114
115 if test x$debug = xyes
116 then
117 CFLAGS="$CFLAGS -Wall -O0 -DDEBUG"
118 CXXFLAGS="$CXXFLAGS -Wall -O0 -DDEBUG"
119 else
120 CFLAGS="$CFLAGS -O2 -DNDEBUG"
121 CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
122 fi
123
124 if test x$profile = xyes
125 then
126 CFLAGS="$CFLAGS -pg"
127 CXXFLAGS="$CXXFLAGS -pg"
128 AC_DEFINE([PROFILING_ENABLED], 1,
129 [Define to 1 if profiling is built in.])
130 fi
131
132 if test x$extra_warnings = xyes
133 then
134 CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter"
135 CXXFLAGS="$CXXFLAGS -Wextra -Wno-unused-parameter"
136 fi
137
138 if test x$double = xyes
139 then
140 AC_DEFINE([USE_DOUBLE_PRECISION], 1,
141 [Define to 1 if you want to use double-precison numbers.])
142 fi
143
144
145 AC_DEFINE_UNQUOTED([YOINK_LOGLEVEL], [$log_level],
146 [Define to detail level of logging.])
147
148
149 if test "x$prefix" = xNONE
150 then
151 prefix="$ac_default_prefix"
152 fi
153
154 AC_ARG_WITH([assetdir],
155 [AS_HELP_STRING([--with-assetdir=DIR],
156 [real path to assets (default: $datarootdir/yoink)])],
157 [DATADIR="$withval"],
158 [eval DATADIR="$datarootdir/yoink"])
159
160 if test x$WIN32 = xyes
161 then
162 DATADIR="data"
163 fi
164
165 AC_SUBST([DATADIR])
166 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
167 [Define to path of game asset directory.])
168
169
170 #
171 # Split the version number into components.
172 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173
174 VERSION_MAJOR=$(echo $VERSION | cut -d. -f1)
175 VERSION_MINOR=$(echo $VERSION | cut -d. -f2)
176 VERSION_REVISION=$(echo $VERSION | cut -d. -f3)
177
178 AC_DEFINE_UNQUOTED([VERSION_MAJOR], [${VERSION_MAJOR:-0}],
179 [Define to major version number component.])
180
181 AC_DEFINE_UNQUOTED([VERSION_MINOR], [${VERSION_MINOR:-0}],
182 [Define to minor version number component.])
183
184 AC_DEFINE_UNQUOTED([VERSION_REVISION], [${VERSION_REVISION:-0}],
185 [Define to revision version number component.])
186
187 if test x$WIN32 = xyes
188 then
189 PVERSION="${VERSION_MAJOR:-0}.${VERSION_MINOR:-0}.${VERSION_REVISION:-0}.0"
190 AC_SUBST([PVERSION])
191 fi
192
193 # these are used in src/yoink.rc
194
195
196 #
197 # Checks for system functions/headers and compiler characteristics.
198 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199
200 AC_C_STRINGIZE
201 AC_C_INLINE
202
203 AC_TYPE_UINT8_T
204 AC_TYPE_UINT16_T
205 AC_TYPE_UINT32_T
206 AC_TYPE_SIZE_T
207 AC_TYPE_SSIZE_T
208
209 AC_FUNC_ERROR_AT_LINE
210 AC_FUNC_STRTOD
211 AC_CHECK_FUNCS([nanosleep strchr strcspn strrchr strstr])
212
213 AC_HEADER_STDBOOL
214 AC_HEADER_STDC
215 AC_CHECK_HEADERS([stddef.h stdint.h stdlib.h string.h unistd.h])
216
217
218 #
219 # Checks for build dependencies.
220 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
222 ##### boost #####
223 website="http://www.boost.org/"
224 BOOST_SMART_PTR
225 BOOST_STRING_ALGO
226 BOOST_BIND
227 BOOST_FUNCTION
228
229 ##### SDL #####
230 website="http://www.libsdl.org/"
231 AM_PATH_SDL([1.2.10],
232 [CFLAGS="$CFLAGS $SDL_CFLAGS"
233 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
234 LIBS="$LIBS $SDL_LIBS"])
235
236 ##### opengl, glu #####
237 website="http://www.mesa3d.org/"
238 AC_CHECK_HEADERS([GL/gl.h GL/glu.h],,
239 [missing=yes
240 echo "***** Missing GL headers ($website) *****"])
241 if test x$WIN32 == xyes
242 then
243 # autoconf library search macro doesn't find opengl32 on windows because it uses
244 # different name hashing, but it links fine; assume it's there
245 LIBS="$LIBS -lglu32 -lopengl32"
246 else
247 AC_SEARCH_LIBS([glEnable], [GL MesaGL],,
248 [missing=yes
249 echo "***** Missing libGL ($website) *****"])
250 AC_SEARCH_LIBS([gluDisk], [GLU MesaGLU],,
251 [missing=yes
252 echo "***** Missing libGLU ($website) *****"])
253 fi
254
255 ##### openal, alut #####
256 website="http://connect.creativelabs.com/openal/"
257 AC_CHECK_HEADERS([AL/al.h AL/alut.h],,
258 [missing=yes
259 echo "***** Missing OpenAL headers ($website) *****"])
260 AC_SEARCH_LIBS([alEnable], [openal openal32],,
261 [missing=yes
262 echo "***** Missing libopenal ($website) *****"])
263 AC_SEARCH_LIBS([alutInit], [alut],,
264 [missing=yes
265 echo "***** Missing libalut ($website) *****"])
266
267 ##### SDL_image #####
268 website="http://www.libsdl.org/projects/SDL_image/"
269 AC_CHECK_HEADERS([SDL/SDL_image.h],,
270 [missing=yes
271 echo "***** Missing SDL_image header ($website) *****"])
272 AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
273 [missing=yes
274 echo "***** Missing libSDL_image ($website) *****"])
275
276 ##### libvorbis #####
277 website="http://www.xiph.org/downloads/"
278 AC_CHECK_HEADERS([vorbis/codec.h vorbis/vorbisfile.h],,
279 [missing=yes
280 echo "***** Missing vorbis headers ($website) *****"])
281 AC_SEARCH_LIBS([ov_open], [vorbisfile],,
282 [missing=yes
283 echo "***** Missing libvorbisfile ($website) *****"])
284
285 ##### liblua #####
286 website="http://www.lua.org/"
287 AC_CHECK_HEADERS([lua.h],,
288 [missing=yes
289 echo "***** Missing lua headers ($website) *****"])
290 AC_SEARCH_LIBS([lua_load], [lua],,
291 [missing=yes
292 echo "***** Missing liblua ($website) *****"])
293
294 ##### librt (optional) #####
295 AC_SEARCH_LIBS([clock_gettime], [rt],
296 [AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
297 [Define to 1 if you have the 'clock_gettime' function.])])
298
299
300 if test x$missing == xyes
301 then
302 AC_MSG_ERROR([please install missing dependencies (see messages above)])
303 fi
304
305
306 #
307 # Find the data files to install.
308 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309
310 DATA_FILES=$(echo $(cd data; \
311 find . -name "*.lua" \
312 -o -name "*.ogg" \
313 -o -name "*.png" \
314 -o -name "yoinkrc"))
315 AC_SUBST([DATA_FILES])
316
317
318 #
319 # Create the build files.
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321
322 AC_CONFIG_FILES([Makefile
323 data/Makefile
324 doc/Makefile
325 doc/yoink.6
326 extra/Makefile
327 extra/yoink.spec
328 make-win32-installer.sh
329 src/Makefile])
330
331 AC_CONFIG_HEADERS([src/config.h])
332
333 AC_OUTPUT
334
335
336 #
337 # Print a friendly little message.
338 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339
340 echo ""
341 echo " Configuration complete! :-)"
342 echo ""
343 echo " Target: $target"
344 echo " Prefix: $prefix"
345 echo " Data Directory: $DATADIR"
346 echo " Log Level: $log_level"
347 echo " Debug: $debug"
348 echo " Profile: $profile"
349 echo " Extra Warnings: $extra_warnings"
350 echo ""
351 echo " To finish the installation, execute:"
352 echo " make"
353 echo " make install"
354 echo ""
355
This page took 0.047989 seconds and 3 git commands to generate.