45ccfc4752bee029923710bb3bbfb73270251df0
[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.61)
8
9 AC_INIT([Yoink],[0.1],[chaz@dogcows.com],[yoink])
10
11 AC_CANONICAL_TARGET
12
13 AC_CONFIG_SRCDIR([src/version.c])
14 AC_CONFIG_MACRO_DIR([m4])
15
16 AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip])
17
18
19 #
20 # Determine the target platform.
21 #
22
23 case "${host}" in
24 *mingw32*) WIN32=yes ;;
25 *-apple-darwin*) MACOSX=yes ;;
26 *netbsd*) NETBSD=yes ;;
27 esac
28
29 AM_CONDITIONAL([WIN32], [test x$WIN32 = xyes])
30 AM_CONDITIONAL([MACOSX], [test x$MACOSX = xyes])
31 AM_CONDITIONAL([NETBSD], [test x$NETBSD = xyes])
32
33
34 #
35 # Checks for configuration arguments.
36 #
37
38 AC_ARG_ENABLE([debug],
39 [AS_HELP_STRING([--enable-debug],
40 [include debugging symbols and code paths])],
41 [debug=$enableval],
42 [debug=no])
43
44 AC_ARG_ENABLE([double-precision],
45 [AS_HELP_STRING([--enable-double-precision],
46 [use doubles instead of floats])],
47 [double_precision=$enableval],
48 [double_precision=no])
49
50 AC_ARG_ENABLE([profile],
51 [AS_HELP_STRING([--enable-profile],
52 [make a binary with code profiling instructions])],
53 [profile=$enableval],
54 [profile=no])
55
56 AC_ARG_ENABLE([extra-warnings],
57 [AS_HELP_STRING([--enable-extra-warnings],
58 [make the gcc compiler give more warnings])],
59 [extra_warnings=$enableval],
60 [extra_warnings=no])
61
62 AC_ARG_ENABLE([link-sh],
63 [AS_HELP_STRING([--enable-link-sh],
64 [give the executable fewer direct dependencies])],
65 [link_sh=$enableval],
66 [link_sh=no])
67
68 AC_ARG_ENABLE([clock_gettime],
69 [AS_HELP_STRING([--enable-clock_gettime],
70 [use clock_gettime() instead of SDL_GetTicks()])],
71 [clock_gettime=$enableval],
72 [clock_gettime=no])
73
74 AC_ARG_ENABLE([threads],
75 [AS_HELP_STRING([--enable-threads],
76 [use threads for concurrency where appropriate])],
77 [threads=$enableval],
78 [threads=no])
79
80 AC_ARG_WITH([gtk],
81 [AS_HELP_STRING([--with-gtk],
82 [use gtk2 modal dialogs])],
83 [gtk=$withval],
84 [gtk=no])
85
86 AC_ARG_WITH([qt4],
87 [AS_HELP_STRING([--with-qt4],
88 [use qt4 modal dialogs; overridden by --with-gtk])],
89 [qt4=$withval],
90 [qt4=no])
91
92
93 if test x$debug = xyes
94 then
95 CFLAGS="$CFLAGS -DDEBUG -ggdb -O0 -Wall -Wno-uninitialized"
96 CXXFLAGS="$CXXFLAGS -DDEBUG -ggdb -O0 -Wall -Wno-uninitialized"
97 else
98 CFLAGS="$CFLAGS -DNDEBUG"
99 CXXFLAGS="$CXXFLAGS -DNDEBUG"
100 fi
101
102 if test x$double_precision = xyes
103 then
104 AC_DEFINE([USE_DOUBLE_PRECISION], 1,
105 [Define to 1 if you want to use doubles instead of floats.])
106 fi
107
108 if test x$profile = xyes
109 then
110 CFLAGS="$CFLAGS -pg"
111 CXXFLAGS="$CXXFLAGS -pg"
112 AC_DEFINE([PROFILING_ENABLED], 1,
113 [Define to 1 if profiling is built in.])
114 fi
115
116 if test x$extra_warnings = xyes
117 then
118 CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter"
119 CXXFLAGS="$CXXFLAGS -Wextra -Wno-unused-parameter"
120 fi
121
122 AM_CONDITIONAL([LINK_SH], [test x$link_sh = xyes])
123
124 if test x$threads = xyes
125 then
126 AC_DEFINE([USE_THREADS], 1,
127 [Define to 1 if you want to use threads when applicable.])
128 fi
129
130 if test x$gtk = xyes
131 then
132 AC_DEFINE([USE_GTK], 1,
133 [Define to 1 if you want to use GTK+ modal dialogs.])
134 elif test x$qt4 = xyes
135 then
136 AC_DEFINE([USE_QT4], 1,
137 [Define to 1 if you want to use QT4 modal dialogs.])
138 fi
139
140
141 if test "x$prefix" = xNONE
142 then
143 prefix="$ac_default_prefix"
144 fi
145
146 if test x$WIN32 = xyes
147 then
148 DATADIR="data"
149 else
150 eval eval DATADIR="${datadir}/$PACKAGE"
151 fi
152
153 AC_SUBST([DATADIR])
154 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
155 [Define to the path of the game asset directory.])
156
157
158 ####
159 AC_MSG_NOTICE([Checks for programs.])
160 ####
161
162 AC_PROG_CXX
163 AC_PROG_CC
164 AC_PROG_INSTALL
165 AC_PROG_RANLIB
166 AM_PROG_CC_C_O
167
168 PKG_PROG_PKG_CONFIG
169
170 AC_PATH_PROGS([CUT], [cut])
171 if test x$CUT = x
172 then
173 AC_MSG_ERROR([The cut program is required.])
174 fi
175
176 AC_PATH_PROGS([FIND], [find])
177 if test x$FIND = x
178 then
179 AC_MSG_ERROR([The find program is required.])
180 fi
181
182 if test x$WIN32 = xyes
183 then
184 AC_PATH_PROGS([WINDRES],
185 [windres $host_alias-windres $host_os-windres])
186 if test x$WINDRES = x
187 then
188 AC_MSG_ERROR([The windres program is required.])
189 fi
190
191 AC_PATH_PROGS([ZIP], [zip])
192 if test x$ZIP = x
193 then
194 AC_MSG_WARN([The zip program is needed to build a portable package.])
195 fi
196
197 AC_PATH_PROGS([MAKENSIS], [makensis])
198 if test x$MAKENSIS = x
199 then
200 AC_MSG_WARN([The makensis program is needed to build an installer.])
201 fi
202
203 AC_PATH_PROGS([GROFF], [groff])
204 if test x$GROFF = x
205 then
206 AC_MSG_WARN([The groff program is needed to create the manual page.])
207 fi
208 elif test x$NETBSD = xyes
209 then
210 AC_PATH_PROGS([PKGLINT], [pkglint])
211 fi
212
213 AM_CONDITIONAL([HAVE_MAKENSIS], [test x$MAKENSIS != x])
214
215 ####
216 AC_MSG_NOTICE([Checks for libraries.])
217 ####
218
219 ##### SDL #####
220 website="http://www.libsdl.org/"
221 PKG_CHECK_MODULES([SDL], [sdl],
222 [LIBS="$LIBS $SDL_LIBS"
223 CFLAGS="$CFLAGS $SDL_CFLAGS"
224 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"],
225 [missing=yes
226 AC_MSG_WARN([Missing SDL ($website)])])
227
228 ##### opengl, glu #####
229 website="http://www.mesa3d.org/"
230 PKG_CHECK_MODULES([OPENGL], [gl glu],
231 [LIBS="$LIBS $OPENGL_LIBS"
232 CFLAGS="$CFLAGS $OPENGL_CFLAGS"
233 CXXFLAGS="$CXXFLAGS $OPENGL_CFLAGS"],
234 [missing=yes
235 AC_MSG_WARN([Missing OpenGL ($website)])])
236
237 ##### libpng #####
238 website="http://www.libpng.org/pub/png/libpng.html"
239 PKG_CHECK_MODULES([PNG], [libpng],
240 [LIBS="$LIBS $PNG_LIBS"
241 CFLAGS="$CFLAGS $PNG_CFLAGS"
242 CXXFLAGS="$CXXFLAGS $PNG_CFLAGS"],
243 [missing=yes
244 AC_MSG_WARN([Missing libpng ($website)])])
245
246 ##### openal #####
247 website="http://connect.creativelabs.com/openal/"
248 PKG_CHECK_MODULES([OPENAL], [openal],
249 [LIBS="$LIBS $OPENAL_LIBS"
250 CFLAGS="$CFLAGS $OPENAL_CFLAGS"
251 CXXFLAGS="$CXXFLAGS $OPENAL_CFLAGS"],
252 [missing=yes
253 AC_MSG_WARN([Missing OpenAL ($website)])])
254
255 ##### libvorbis #####
256 website="http://www.xiph.org/downloads/"
257 PKG_CHECK_MODULES([VORBIS], [vorbisfile],
258 [LIBS="$LIBS $VORBIS_LIBS"
259 CFLAGS="$CFLAGS $VORBIS_CFLAGS"
260 CXXFLAGS="$CXXFLAGS $VORBIS_CFLAGS"],
261 [missing=yes
262 AC_MSG_WARN([Missing libvorbisfile ($website)])])
263
264 ##### liblua #####
265 website="http://www.lua.org/"
266 PKG_CHECK_MODULES([LUA], [lua],
267 [LIBS="$LIBS $LUA_LIBS"
268 CFLAGS="$CFLAGS $LUA_CFLAGS"
269 CXXFLAGS="$CXXFLAGS $LUA_CFLAGS"],
270 [missing=yes
271 AC_MSG_WARN([Missing liblua ($website)])])
272
273 ##### GTK+ 2.0 #####
274 if test x$gtk = xyes
275 then
276 website="http://www.gtk.org/"
277 PKG_CHECK_MODULES([GTK], [gtk+-2.0],
278 [LIBS="$LIBS $GTK_LIBS"
279 CFLAGS="$CFLAGS $GTK_CFLAGS"
280 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"],
281 [missing=yes
282 AC_MSG_WARN([Missing GTK+-2.0 ($website)])])
283 fi
284
285 ##### QT4 #####
286 if test x$qt4 = xyes
287 then
288 website="http://qt.nokia.com/"
289 PKG_CHECK_MODULES([QT4], [QtGui],
290 [LIBS="$LIBS $QT4_LIBS"
291 CFLAGS="$CFLAGS $QT4_CFLAGS"
292 CXXFLAGS="$CXXFLAGS $QT4_CFLAGS"],
293 [missing=yes
294 AC_MSG_WARN([Missing QT4 ($website)])])
295 fi
296
297 if test x$missing = xyes
298 then
299 AC_MSG_ERROR([You are missing some required libraries.])
300 fi
301
302
303 ####
304 AC_MSG_NOTICE([Checks for header files.])
305 ####
306
307 AC_HEADER_STDBOOL
308 AC_HEADER_STDC
309 AC_CHECK_HEADERS([byteswap.h stddef.h stdint.h stdlib.h string.h unistd.h])
310
311 BOOST_SMART_PTR
312 BOOST_STRING_ALGO
313 BOOST_BIND
314 BOOST_FUNCTION
315
316
317 ####
318 AC_MSG_NOTICE([Checks for types.])
319 ####
320
321 AC_TYPE_UINT8_T
322 AC_TYPE_UINT16_T
323 AC_TYPE_UINT32_T
324 AC_TYPE_UINT64_T
325 AC_TYPE_SIZE_T
326
327
328 ####
329 AC_MSG_NOTICE([Checks for compiler characteristics.])
330 ####
331
332 AC_C_STRINGIZE
333 AC_C_INLINE
334
335
336 ####
337 AC_MSG_NOTICE([Checks for library functions.])
338 ####
339
340 AC_FUNC_ERROR_AT_LINE
341 AC_FUNC_STRTOD
342 AC_CHECK_FUNCS([nanosleep strchr strcspn strrchr strstr])
343
344 if test x$clock_gettime = xyes
345 then
346 AC_SEARCH_LIBS([clock_gettime], [rt],
347 [clock_gettime=yes],
348 [clock_gettime=no])
349 if test x$clock_gettime = xyes
350 then
351 AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
352 [Define to 1 if you have the 'clock_gettime' function.])
353 else
354 AC_MSG_WARN([Falling back to SDL_GetTicks().])
355 fi
356 fi
357
358
359 #
360 # Find the game resources to install.
361 #
362
363 DATA_FILES=$(echo $(cd data && find . -name "*.lua" \
364 -o -name "*.ogg" \
365 -o -name "*.png" \
366 -o -name "yoinkrc"))
367 AC_SUBST([DATA_FILES])
368
369
370 #
371 # Split the version number into components.
372 # These definitions are used in the win32 resource file, src/yoink.rc.
373 #
374
375 VERSION_MAJOR=$(echo $VERSION | cut -d. -f1)
376 VERSION_MINOR=$(echo $VERSION | cut -d. -f2)
377 VERSION_REVISION=$(echo $VERSION | cut -d. -f3)
378
379 AC_DEFINE_UNQUOTED([VERSION_MAJOR], [${VERSION_MAJOR:-0}],
380 [Define to major version number component.])
381
382 AC_DEFINE_UNQUOTED([VERSION_MINOR], [${VERSION_MINOR:-0}],
383 [Define to minor version number component.])
384
385 AC_DEFINE_UNQUOTED([VERSION_REVISION], [${VERSION_REVISION:-0}],
386 [Define to revision version number component.])
387
388 PVERSION="${VERSION_MAJOR:-0}.${VERSION_MINOR:-0}.${VERSION_REVISION:-0}.0"
389 AC_SUBST([PVERSION])
390
391 if githead=$(git log -n1 --date=short --pretty=format:"%h (%ad)")
392 then
393 AC_DEFINE_UNQUOTED([YOINK_GITHEAD], ["$githead"],
394 [Define to the git commit currently checked out.])
395 fi
396
397
398 #
399 # Create the build files.
400 #
401
402 AC_CONFIG_FILES([Makefile
403 data/Makefile
404 doc/yoink.6
405 src/Makefile])
406
407 AC_CONFIG_HEADERS([src/config.h])
408
409 AC_OUTPUT
410
411
412 #
413 # Print a friendly little message.
414 #
415
416 echo ""
417 echo " Configuration complete! :-)"
418 echo ""
419 echo " Host: $target"
420 echo " Prefix: $prefix"
421 echo " Data: $DATADIR"
422 echo ""
423 echo " CXX: $CXX"
424 echo " CXXFLAGS: $(echo $CXXFLAGS)"
425 echo " LIBS: $(echo $LIBS)"
426 echo ""
427 echo " To finish the installation, execute:"
428 echo " make"
429 echo " make install"
430 echo ""
431
This page took 0.050824 seconds and 3 git commands to generate.