-AC_PREREQ(2.60)
-AC_INIT([yoink],[0.1],[chaz@dogcows.com])
-AM_INIT_AUTOMAKE
+
+#
+# Yoink
+# Process this file with autoconf to produce a configure script.
+#
+
+AC_PREREQ([2.60])
+
+AC_INIT([Yoink], [0.1], [chaz@dogcows.com], [yoink])
+
+AC_CANONICAL_TARGET
+
AC_CONFIG_SRCDIR([src/YoinkApp.cc])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE
+
+
+#
+# Checks for programs.
+#
-AC_PROG_CC
AC_PROG_CXX
-AC_PROG_RANLIB
+#AC_PROG_AWK
+AC_PROG_CC
+AC_PROG_CPP
AC_PROG_INSTALL
-AM_PROG_CC_C_O
+#AC_PROG_LN_S
+#AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
-AC_HEADER_STDC
+#
+# Checks for configuration arguments.
+#
-AC_SEARCH_LIBS([glClear], [GL], [have_opengl=yes])
-if test ! "x${have_opengl}" = xyes
-then
- AC_MSG_ERROR([libGL is required])
-fi
+AC_ARG_ENABLE([debug],
+ [ --enable-debug include debugging symbols and features],
+ [debug=$enableval
+ if test x$debug = xyes
+ then
+ CFLAGS="-Wall -Werror -gstabs+ -O0 -DDEBUG"
+ CXXFLAGS="-Wall -Werror -gstabs+ -O0 -DDEBUG"
+ else
+ CFLAGS="-O2 -DNDEBUG"
+ CXXFLAGS="-O2 -DNDEBUG"
+ fi],
+ [CFLAGS="-O2 -DNDEBUG"
+ CXXFLAGS="-O2 -DNDEBUG"])
-AC_SEARCH_LIBS([SDL_Init], [SDL], [have_sdl=yes])
-if test ! "x${have_sdl}" = xyes
+AC_ARG_ENABLE([profile],
+ [ --enable-profile make a binary for use with gprof],
+ [profile=$enableval
+ if test x$profile = xyes
+ then
+ CFLAGS="$CFLAGS -pg"
+ CXXFLAGS="$CXXFLAGS -pg"
+ fi])
+
+
+if test x$prefix = xNONE
then
- AC_MSG_ERROR([libSDL is required])
+ prefix="$ac_default_prefix"
fi
-AC_SEARCH_LIBS([IMG_Load], [SDL_image], [have_sdlimage=yes])
-if test ! "x${have_sdlimage}" = xyes
+AC_ARG_WITH([assetdir],
+ [AS_HELP_STRING([--with-assetdir=DIR],
+ [real path to game assets (default: $datarootdir/yoink)])],
+ [DATADIR="$withval"],
+ [eval DATADIR="$datarootdir/yoink"])
+
+AC_SUBST([DATADIR])
+AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
+ [Define to path of game asset directory.])
+
+CONFIGFILES="\$HOME/.yoinkrc:/etc/yoinkrc"
+
+AC_DEFINE_UNQUOTED([YOINK_CONFIGFILES], ["$CONFIGFILES"],
+ [Define to colon-delimited configuration file paths.])
+
+
+#
+# Checks for libraries.
+#
+
+AM_PATH_SDL([1.2.10],
+ [CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"])
+
+#BOOST_REQUIRE([1.35])
+#CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+BOOST_SMART_PTR
+BOOST_STRING_ALGO
+BOOST_BIND
+BOOST_FUNCTION
+
+AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
+ [AC_MSG_ERROR([libSDL_image is required])])
+
+AC_SEARCH_LIBS([Sound_Init], [SDL_sound],,
+ [AC_MSG_ERROR([libSDL_sound is required])])
+
+AC_SEARCH_LIBS([glBegin], [GL],,
+ [AC_MSG_ERROR([libGL is required])])
+
+AC_SEARCH_LIBS([gluPerspective], [GLU],,
+ [AC_MSG_ERROR([libGLU is required])])
+
+AC_SEARCH_LIBS([alGenBuffers], [openal],,
+ [AC_MSG_ERROR([libopenal is required])])
+
+AC_SEARCH_LIBS([alutInit], [alut],,
+ [AC_MSG_ERROR([libalut is required])])
+
+AC_SEARCH_LIBS([clock_gettime], [rt],
+ [AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
+ [Define to 1 if you have the 'clock_gettime' function.])])
+
+
+#
+# Checks for header files.
+#
+
+AC_HEADER_STDBOOL
+AC_HEADER_STDC
+AC_CHECK_HEADERS([stddef.h stdint.h stdlib.h string.h unistd.h])
+
+
+#
+# Checks for typedefs, structures, and compiler characteristics.
+#
+
+AC_C_STRINGIZE
+AC_C_INLINE
+
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+
+
+#
+# Checks for library functions.
+#
+
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_STRTOD
+AC_CHECK_FUNCS([nanosleep strchr strcspn strrchr strstr])
+
+
+#
+# Find the data files to install.
+#
+
+DATA_FILES=$(echo $(cd data; \
+ find . -name "*.json" \
+ -o -name "*.ogg" \
+ -o -name "*.png" \
+ -o -name "*.xm" \
+ -o -name "yoinkrc"))
+AC_SUBST([DATA_FILES])
+
+
+#
+# Create the build files.
+#
+
+AC_CONFIG_FILES([Makefile
+ data/Makefile
+ doc/Makefile
+ doc/yoink.6
+ extra/yoink.spec
+ src/Makefile
+ yajl/Makefile])
+
+AC_CONFIG_HEADERS([src/config.h])
+
+AC_OUTPUT
+
+
+#
+# Print a friendly little message.
+#
+
+echo "======================================"
+echo " Configuration complete!"
+echo ""
+
+echo " Prefix: $prefix"
+echo " Data: $DATADIR"
+echo ""
+
+if test x$debug = xyes
then
- AC_MSG_ERROR([libSDL_image is required])
+ echo " * Debugging enabled."
+ echo ""
fi
-AC_SEARCH_LIBS([clock_gettime], [rt], [have_librt=yes])
-if test "x${have_librt}" = xyes
+if test x$profile = xyes
then
- AC_DEFINE([HAVE_LIBRT], 1, [high-resolution timer enabled])
+ echo " * Profiling enabled."
+ echo ""
fi
-AC_CONFIG_FILES([Makefile
- yajl/Makefile
- src/Makefile])
-AC_OUTPUT
+echo " To finish the installation, execute:"
+echo " make"
+echo " make install"
+echo "======================================"