-CFLAGS="$CFLAGS $SDL_CFLAGS"
-LDFLAGS="$LDFLAGS $SDL_LIBS"
-
-dnl Checks for additional libraries.
-AC_CHECK_LIB(SDL_mixer, SDL_OpenAudio, ,AC_MSG_ERROR(SDL_mixer library required))
-AC_CHECK_LIB(SDL_image, IMG_Load, ,AC_MSG_ERROR(SDL_image library required))
-AC_CHECK_LIB(GL, glBegin, ,AC_MSG_ERROR(GL library required))
-
-# FIXME: Evil
-CFLAGS="-DDATA_PREFIX=\\\"$PWD/data\\\" -DLINUX"
+XIPH_PATH_VORBIS(, [AC_MSG_ERROR([Please install libvorbis])])
+XIPH_PATH_OGG(, [AC_MSG_ERROR([Please install libogg])])
+
+NP_FINDLIB([SDLIMAGE], [SDL_image], [SDL_image >= 1.2],
+ NP_LANG_PROGRAM([#include <SDL_image.h>], [IMG_Load("");]),
+ [], [-lSDL_image],
+ [],
+ [AC_MSG_ERROR([Please install SDLImage >= 1.2.1])],
+ [$SDL_CFLAGS], [$SDL_LIBS])
+
+NP_FINDLIB([PHYSFS], [physfs], [physfs >= 1.0.0],
+ NP_LANG_PROGRAM([
+#include <stdio.h>
+#include <physfs.h>
+#if PHYSFS_VER_MAJOR < 1
+# error PHYSFS is too old
+#endif]),
+ [], [-lphysfs],
+ [],
+ [AC_MSG_ERROR([Please install physfs >= 1.0])])
+
+NP_FINDLIB([OPENAL], [OpenAL], [OpenAL],
+ NP_LANG_PROGRAM([#include <AL/al.h>],
+ [alcOpenDevice(0);]),
+ [], [-lopenal],
+ [],
+ [AC_MSG_ERROR([Please intall OpenAL])],
+ [], [])
+
+AX_CHECK_GL
+if test "$no_gl" = "yes"; then
+ AC_MSG_ERROR([Please install opengl libraries and headers])
+fi