4 # Process this file with autoconf to produce a configure script.
9 AC_INIT([Yoink],[0.1],[chaz@dogcows.com],[yoink])
13 AC_CONFIG_SRCDIR([src/version.c])
14 AC_CONFIG_MACRO_DIR([m4])
16 AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip])
20 # Determine the target platform.
24 *mingw32*) WIN32=yes ;;
25 *-apple-darwin*) MACOSX=yes ;;
26 *netbsd*) NETBSD=yes ;;
29 AM_CONDITIONAL([WIN32], [test x$WIN32 = xyes])
30 AM_CONDITIONAL([MACOSX], [test x$MACOSX = xyes])
31 AM_CONDITIONAL([NETBSD], [test x$NETBSD = xyes])
35 # Checks for configuration arguments.
38 AC_ARG_ENABLE([debug],
39 [AS_HELP_STRING([--enable-debug],
40 [include debugging symbols and code paths])],
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])
50 AC_ARG_ENABLE([profile],
51 [AS_HELP_STRING([--enable-profile],
52 [make a binary with code profiling instructions])],
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],
62 AC_ARG_ENABLE([link-sh],
63 [AS_HELP_STRING([--enable-link-sh],
64 [give the executable fewer direct dependencies])],
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],
74 AC_ARG_ENABLE([threads],
75 [AS_HELP_STRING([--enable-threads],
76 [use threads for concurrency where appropriate])],
81 [AS_HELP_STRING([--with-gtk],
82 [use gtk2 modal dialogs])],
87 [AS_HELP_STRING([--with-qt4],
88 [use qt4 modal dialogs; overridden by --with-gtk])],
93 if test x$debug = xyes
95 CFLAGS="$CFLAGS -DDEBUG -ggdb -O0 -Wall -Wno-uninitialized"
96 CXXFLAGS="$CXXFLAGS -DDEBUG -ggdb -O0 -Wall -Wno-uninitialized"
98 CFLAGS="$CFLAGS -DNDEBUG"
99 CXXFLAGS="$CXXFLAGS -DNDEBUG"
102 if test x$double_precision = xyes
104 AC_DEFINE([USE_DOUBLE_PRECISION], 1,
105 [Define to 1 if you want to use doubles instead of floats.])
108 if test x$profile = xyes
111 CXXFLAGS="$CXXFLAGS -pg"
112 AC_DEFINE([PROFILING_ENABLED], 1,
113 [Define to 1 if profiling is built in.])
116 if test x$extra_warnings = xyes
118 CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter"
119 CXXFLAGS="$CXXFLAGS -Wextra -Wno-unused-parameter"
122 AM_CONDITIONAL([LINK_SH], [test x$link_sh = xyes])
124 if test x$threads = xyes
126 AC_DEFINE([USE_THREADS], 1,
127 [Define to 1 if you want to use threads when applicable.])
132 AC_DEFINE([USE_GTK], 1,
133 [Define to 1 if you want to use GTK+ modal dialogs.])
134 elif test x$qt4 = xyes
136 AC_DEFINE([USE_QT4], 1,
137 [Define to 1 if you want to use QT4 modal dialogs.])
141 if test "x$prefix" = xNONE
143 prefix="$ac_default_prefix"
146 if test x$WIN32 = xyes
150 eval eval DATADIR="${datadir}/$PACKAGE"
154 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
155 [Define to the path of the game asset directory.])
159 AC_MSG_NOTICE([Checks for programs.])
170 AC_PATH_PROGS([CUT], [cut])
173 AC_MSG_ERROR([The cut program is required.])
176 AC_PATH_PROGS([FIND], [find])
179 AC_MSG_ERROR([The find program is required.])
182 if test x$WIN32 = xyes
184 AC_PATH_PROGS([WINDRES],
185 [windres $host_alias-windres $host_os-windres])
186 if test x$WINDRES = x
188 AC_MSG_ERROR([The windres program is required.])
191 AC_PATH_PROGS([ZIP], [zip])
194 AC_MSG_WARN([The zip program is needed to build a portable package.])
197 AC_PATH_PROGS([MAKENSIS], [makensis])
198 if test x$MAKENSIS = x
200 AC_MSG_WARN([The makensis program is needed to build an installer.])
203 AC_PATH_PROGS([GROFF], [groff])
206 AC_MSG_WARN([The groff program is needed to create the manual page.])
208 elif test x$NETBSD = xyes
210 AC_PATH_PROGS([PKGLINT], [pkglint])
213 AM_CONDITIONAL([HAVE_MAKENSIS], [test x$MAKENSIS != x])
216 AC_MSG_NOTICE([Checks for libraries.])
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"],
226 AC_MSG_WARN([Missing SDL ($website)])])
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"],
235 AC_MSG_WARN([Missing OpenGL ($website)])])
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"],
244 AC_MSG_WARN([Missing libpng ($website)])])
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"],
253 AC_MSG_WARN([Missing OpenAL ($website)])])
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"],
262 AC_MSG_WARN([Missing libvorbisfile ($website)])])
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"],
271 AC_MSG_WARN([Missing liblua ($website)])])
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"],
282 AC_MSG_WARN([Missing GTK+-2.0 ($website)])])
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"],
294 AC_MSG_WARN([Missing QT4 ($website)])])
297 if test x$WIN32 = xyes
299 # On Windows, sockets are in the ws2_32 library.
300 LIBS="$LIBS -lws2_32"
303 if test x$missing = xyes
305 AC_MSG_ERROR([You are missing some required libraries.])
310 AC_MSG_NOTICE([Checks for header files.])
315 AC_CHECK_HEADERS([arpa/inet.h byteswap.h fcntl.h stddef.h stdint.h stdlib.h string.h unistd.h])
324 AC_MSG_NOTICE([Checks for types.])
335 AC_MSG_NOTICE([Checks for compiler characteristics.])
343 AC_MSG_NOTICE([Checks for library functions.])
346 AC_FUNC_ERROR_AT_LINE
348 AC_CHECK_FUNCS([fcntl ioctl nanosleep strchr strcspn strrchr strstr])
350 if test x$clock_gettime = xyes
352 AC_SEARCH_LIBS([clock_gettime], [rt],
355 if test x$clock_gettime = xyes
357 AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
358 [Define to 1 if you have the 'clock_gettime' function.])
360 AC_MSG_WARN([Falling back to SDL_GetTicks().])
366 # Find the game resources to install.
369 DATA_FILES=$(echo $(cd data && find . -name "*.lua" \
373 AC_SUBST([DATA_FILES])
377 # Split the version number into components.
378 # These definitions are used in the win32 resource file, src/yoink.rc.
381 VERSION_MAJOR=$(echo $VERSION | cut -d. -f1)
382 VERSION_MINOR=$(echo $VERSION | cut -d. -f2)
383 VERSION_REVISION=$(echo $VERSION | cut -d. -f3)
385 AC_DEFINE_UNQUOTED([VERSION_MAJOR], [${VERSION_MAJOR:-0}],
386 [Define to major version number component.])
388 AC_DEFINE_UNQUOTED([VERSION_MINOR], [${VERSION_MINOR:-0}],
389 [Define to minor version number component.])
391 AC_DEFINE_UNQUOTED([VERSION_REVISION], [${VERSION_REVISION:-0}],
392 [Define to revision version number component.])
394 PVERSION="${VERSION_MAJOR:-0}.${VERSION_MINOR:-0}.${VERSION_REVISION:-0}.0"
397 if githead=$(git log -n1 --date=short --pretty=format:"%h (%ad)")
399 AC_DEFINE_UNQUOTED([YOINK_GITHEAD], ["$githead"],
400 [Define to the git commit currently checked out.])
405 # Create the build files.
408 AC_CONFIG_FILES([Makefile
413 AC_CONFIG_HEADERS([src/config.h])
419 # Print a friendly little message.
423 echo " Configuration complete! :-)"
425 echo " Host: $target"
426 echo " Prefix: $prefix"
427 echo " Data: $DATADIR"
430 echo " CXXFLAGS: $(echo $CXXFLAGS)"
431 echo " LIBS: $(echo $LIBS)"
433 echo " To finish the installation, execute:"