diff --git a/autoconf/m4/ax_check_lib_using_header.m4 b/autoconf/m4/ax_check_lib_using_header.m4 new file mode 100644 index 0000000000..642fcd7891 --- /dev/null +++ b/autoconf/m4/ax_check_lib_using_header.m4 @@ -0,0 +1,24 @@ +dnl AX_CHECK_LIB_USING_HEADER(lib, function, header, [action-if-found], [action-if-not-found]) +dnl As AC_CHECK_LIB except "function" must be a fully valid function call and "header" the header file in which that function is defined. The benefit is that this can find functions whose symbols have been decorated, e.g. a lot of MinGW stuff. + +AC_DEFUN([AX_CHECK_LIB_USING_HEADER], +[ +dnl # On Windows OpenGL functions' library symbols don't match their function names. So we have to do it the hard way. + + AC_MSG_CHECKING(for $2 in $1 using $3) + + AC_LANG_PUSH(C) + + LIBS_SAVE=$LIBS + LIBS="$LIBS -l$1" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include <$3>], [$2])], + [AC_MSG_RESULT(yes) + $4], + [AC_MSG_RESULT(no) + $5] + ) + LIBS=$LIBS_SAVE + + AC_LANG_POP(C) +]) \ No newline at end of file diff --git a/autoconf/m4/bzip.m4 b/autoconf/m4/bzip.m4 index 1d41610384..b3dbd20b5b 100644 --- a/autoconf/m4/bzip.m4 +++ b/autoconf/m4/bzip.m4 @@ -2,11 +2,10 @@ AC_DEFUN([SM_BZIP], [ AC_REQUIRE([SM_STATIC]) -dnl # XXX: AC_CHECK_LIB doesn't work correctly on MinGW for BZip. -dnl # Hardcoding it because I'm so fed up with this shit. - if test "$host_os" != "mingw32"; then - AC_CHECK_LIB(bz2, BZ2_bzCompressInit, have_bzip=yes, have_bzip=no) - fi + AX_CHECK_LIB_USING_HEADER(bz2, + 'BZ2_bzCompressInit((bz_stream*) NULL, 0, 0, 0)', + bzlib.h, have_bzip=yes, have_bzip=no) + AC_CHECK_HEADER(bzlib.h, have_bzip_header=yes, have_bzip_header=no) AC_ARG_WITH(static-bzip, AS_HELP_STRING([--with-static-bzip],[Statically link bzip]), with_static_bzip=$withval, with_static_bzip=no) diff --git a/autoconf/m4/opengl.m4 b/autoconf/m4/opengl.m4 index a29119a366..42791d5a3a 100644 --- a/autoconf/m4/opengl.m4 +++ b/autoconf/m4/opengl.m4 @@ -1,23 +1,3 @@ -AC_DEFUN([SM_OPENGL_TRY_LIB], -[ -dnl # On Windows OpenGL functions' library symbols don't match their function names. So we have to do it the hard way. - - AC_MSG_CHECKING(for glBegin in $1) - - AC_LANG_PUSH(C) - - LIBS_SAVE=$LIBS - LIBS="$LIBS $1" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([#include ], [glBegin(GL_POINTS)])], - [AC_MSG_RESULT(yes) - $2], - AC_MSG_RESULT(no) - ) - LIBS=$LIBS_SAVE - - AC_LANG_POP(C) -]) AC_DEFUN([SM_OPENGL], [ @@ -28,10 +8,10 @@ AC_DEFUN([SM_OPENGL], GL_LIBS="" - SM_OPENGL_TRY_LIB(-lGL, [GL_LIBS="-lGL"]) + AX_CHECK_LIB_USING_HEADER(GL, 'glBegin(GL_POINTS)', GL/gl.h, [GL_LIBS="-lGL"]) if test x$GL_LIBS = "x"; then - SM_OPENGL_TRY_LIB(-lopengl32, [GL_LIBS="-lopengl32"]) + AX_CHECK_LIB_USING_HEADER(opengl32, 'glBegin(GL_POINTS)', GL/gl.h, [GL_LIBS="-lopengl32"]) fi if test x$GL_LIBS = "x"; then AC_MSG_ERROR("No usable OpenGL library found.") diff --git a/configure.ac b/configure.ac index 64204f3e95..4570ae7430 100644 --- a/configure.ac +++ b/configure.ac @@ -183,12 +183,9 @@ if test "$with_prof" = "yes"; then fi SM_OPENGL -if test "$host_os" != "mingw32"; then - SM_X11 - GL_CFLAGS="$GL_CFLAGS $XCFLAGS" - GL_LIBS="$GL_LIBS $XLIBS" - # XXX Actually use GL_* (probably should replace $X* for the most part) -fi +SM_X11 +GL_CFLAGS="$GL_CFLAGS $XCFLAGS" +GL_LIBS="$GL_LIBS $XLIBS" have_libpng=yes SM_STATIC @@ -333,7 +330,22 @@ AC_CHECK_DECL(strtof, , AC_DEFINE([NEED_STRTOF],1,[Need strtof]), [#include ]) -PKG_CHECK_MODULES( [GLEW], [glew >= 1.3.5], LIBS="$LIBS -lGLEW" ) +have_glew="no" +AX_CHECK_LIB_USING_HEADER(GLEW, 'glewInit()', GL/glew.h, + have_glew="yes" + LIBS="$LIBS -lGLEW", + , + [$LIBS]) + +test $have_glew = "no" && { AX_CHECK_LIB_USING_HEADER(glew32, 'glewInit()', GL/glew.h, + have_glew="yes" + LIBS="$LIBS -lglew32", + , + [$LIBS]) } + +test $have_glew = "no" && AC_MSG_ERROR("Could not find GLEW.") + +AC_CHECK_DECL(GLEW_VERSION_2_1, , AC_MSG_ERROR("GLEW 1.3.5 or newer is required."), [#include ]) AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[Build test programs]), enable_tests=$enableval, enable_tests=no) AM_CONDITIONAL(BUILD_TESTS, test "$enable_tests" = "yes" ) diff --git a/src/Makefile.am b/src/Makefile.am index 1f92952f28..3a6ee315a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ AM_CXXFLAGS += -fno-exceptions # generates enormous output. AM_CXXFLAGS += -finline-limit=300 -AM_CXXFLAGS += $(XCFLAGS) +AM_CXXFLAGS += $(GL_CFLAGS) LIBS += LIBS += -lpthread -lrt @@ -637,7 +637,7 @@ endif main_LDADD = \ $(VIDEO_LIBS) \ $(AUDIO_LIBS) \ - $(XLIBS) \ + $(GL_LIBS) \ libtomcrypt.a libtommath.a nodist_stepmania_SOURCES = ver.cpp