From bab0d4c7c501650e0dee0048b3d32848859beab5 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 7 Oct 2012 09:25:50 +0000 Subject: [PATCH] build: put the OpenGL detection code in a separate .m4 file and assume that the OpenGL framework on OS X provides GL version 2 at least. --- .gitignore | 5 ++ Makefile.am | 1 + bootstrap | 4 +- build/autotools/m4/lol-gl.m4 | 127 +++++++++++++++++++++++++++++++++++ configure.ac | 118 +------------------------------- 5 files changed, 136 insertions(+), 119 deletions(-) create mode 100644 build/autotools/m4/lol-gl.m4 diff --git a/.gitignore b/.gitignore index d5a8d091..e9a0d850 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,11 @@ Makefile Makefile.in aclocal.m4 +build/autotools/m4/libtool.m4 +build/autotools/m4/ltoptions.m4 +build/autotools/m4/ltsugar.m4 +build/autotools/m4/ltversion.m4 +build/autotools/m4/lt~obsolete.m4 autom4te.cache config.h.in config.h diff --git a/Makefile.am b/Makefile.am index cf26ff37..112f1f14 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,7 @@ DIST_SUBDIRS = $(SUBDIRS) binaries EXTRA_DIST = bootstrap TODO AUTOMAKE_OPTIONS = dist-bzip2 +ACLOCAL_AMFLAGS = -I build/autotools/m4 check: lolcheck diff --git a/bootstrap b/bootstrap index 550ea92a..7feb173f 100755 --- a/bootstrap +++ b/bootstrap @@ -119,7 +119,7 @@ if test -n "$auxdir"; then if test ! -d "$auxdir"; then mkdir "$auxdir" fi - aclocalflags="${aclocalflags} -I $auxdir -I ." + aclocalflags="-I $auxdir -I . ${aclocalflags}" fi # Honour M4PATH because sometimes M4 doesn't @@ -128,7 +128,7 @@ IFS=: tmp="$M4PATH" for x in $tmp; do if test -n "$x"; then - aclocalflags="${aclocalflags} -I $x" + aclocalflags="-I $x ${aclocalflags}" fi done IFS=$save_IFS diff --git a/build/autotools/m4/lol-gl.m4 b/build/autotools/m4/lol-gl.m4 new file mode 100644 index 00000000..882aec9e --- /dev/null +++ b/build/autotools/m4/lol-gl.m4 @@ -0,0 +1,127 @@ + +# LOL_CHECK_OPENGL() +# ------------------ +AC_DEFUN([LOL_CHECK_OPENGL], +[ +dnl Find which version of OpenGL to use +ac_cv_my_have_gl="no" +ac_cv_my_stop_looking_for_gl="no" + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + LIBS_save="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,OpenGL" + AC_MSG_CHECKING(for -framework OpenGL) + AC_TRY_LINK([], [], + [AC_MSG_RESULT(yes) + ac_cv_my_have_gl="yes" + GL_LIBS="${GL_LIBS} -framework OpenGL" + CXXFLAGS="${CXXFLAGS} -ObjC++" + AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)], + [AC_MSG_RESULT(no)]) + LIBS="$LIBS_save" +fi + +dnl Use the Raspberry Pi libraries? +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + AC_CHECK_HEADERS(bcm_host.h, + [AC_CHECK_LIB(vcos, main, + [ac_cv_my_have_gl="yes" + ac_cv_my_stop_looking_for_gl="yes" + AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) + dnl FIXME: -lEGL does not belong here but the configure test fails + dnl when cross-compiling, so we add it manually here. + GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])]) +fi + +dnl Use the PS3 PSGL? +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + AC_CHECK_HEADERS(PSGL/psgl.h, + [ac_cv_my_have_gl="yes" + ac_cv_my_stop_looking_for_gl="yes"]) +fi + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + PKG_CHECK_MODULES(GLES2, glesv2, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) + GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}" + GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"], + [:]) +fi + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + AC_CHECK_HEADER(GLES2/gl2.h, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) + AC_CHECK_LIB(GLESv2, glEnable, + [GL_LIBS="${GL_LIBS} -lGLESv2"])]) +fi + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + PKG_CHECK_MODULES(GL, gl, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)], + [:]) +fi + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + AC_CHECK_LIB(GL, glEnable, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish + GL_LIBS="-lGL"]) +fi + +if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then + AC_CHECK_HEADER(GL/gl.h, + [LIBS_save="$LIBS" + LIBS="$LIBS -lopengl32" + AC_MSG_CHECKING(for glLoadIdentity in -lopengl32) + AC_TRY_LINK([#include ], + [glLoadIdentity();], + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack + AC_MSG_RESULT(yes) + GL_LIBS="-lopengl32"], + [AC_MSG_RESULT(no)]) + LIBS="$LIBS_save"]) +fi + +if test "${ac_cv_my_have_gl}" = "no"; then + AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]]) +fi + + +dnl Use Glew? +ac_cv_my_have_glew="no" +PKG_CHECK_MODULES(GLEW, glew, + [ac_cv_my_have_glew="yes" + GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}" + GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"], + [:]) +AC_CHECK_HEADER(glew.h, + [LIBS_save="${LIBS}" + LIBS="${LIBS} -lglew32 ${GL_LIBS}" + AC_MSG_CHECKING(for glewInit in -lglew32) + AC_TRY_LINK( + [#include ], + [glewInit();], + [ac_cv_my_have_glew="yes" + GL_LIBS="-lglew32 ${GL_LIBS}" + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)]) + LIBS="${LIBS_save}"]) +if test "${ac_cv_my_have_glew}" != "no"; then + AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) + AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew) +fi +AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no") + +dnl Poor man's GL feature detection if all else failed. +save_LIBS="${LIBS}" +LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}" +AC_CHECK_FUNCS(glBegin) +LIBS="${save_LIBS}" + +])# LOL_CHECK_OPENGL + + diff --git a/configure.ac b/configure.ac index 17ee4bb7..31bba620 100644 --- a/configure.ac +++ b/configure.ac @@ -152,123 +152,7 @@ dnl Are we on a Direct3D 9 platform? #fi #AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no") - -dnl Find which version of OpenGL to use -ac_cv_my_have_gl="no" -ac_cv_my_stop_looking_for_gl="no" - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - LIBS_save="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,OpenGL" - AC_MSG_CHECKING(for -framework OpenGL) - AC_TRY_LINK([], [], - [AC_MSG_RESULT(yes) - GL_LIBS="${GL_LIBS} -framework OpenGL" - CXXFLAGS="${CXXFLAGS} -ObjC++"], - [AC_MSG_RESULT(no)]) - LIBS="$LIBS_save" -fi - -dnl Use the Raspberry Pi libraries? -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - AC_CHECK_HEADERS(bcm_host.h, - [AC_CHECK_LIB(vcos, main, - [ac_cv_my_have_gl="yes" - ac_cv_my_stop_looking_for_gl="yes" - AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) - dnl FIXME: -lEGL does not belong here but the configure test fails - dnl when cross-compiling, so we add it manually here. - GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])]) -fi - -dnl Use the PS3 PSGL? -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - AC_CHECK_HEADERS(PSGL/psgl.h, - [ac_cv_my_have_gl="yes" - ac_cv_my_stop_looking_for_gl="yes"]) -fi - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - PKG_CHECK_MODULES(GLES2, glesv2, - [ac_cv_my_have_gl="yes" - AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) - GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}" - GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"], - [:]) -fi - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - AC_CHECK_HEADER(GLES2/gl2.h, - [ac_cv_my_have_gl="yes" - AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) - AC_CHECK_LIB(GLESv2, glEnable, - [GL_LIBS="${GL_LIBS} -lGLESv2"])]) -fi - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - PKG_CHECK_MODULES(GL, gl, - [ac_cv_my_have_gl="yes" - AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)], - [:]) -fi - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - AC_CHECK_LIB(GL, glEnable, - [ac_cv_my_have_gl="yes" - AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish - GL_LIBS="-lGL"]) -fi - -if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then - AC_CHECK_HEADER(GL/gl.h, - [LIBS_save="$LIBS" - LIBS="$LIBS -lopengl32" - AC_MSG_CHECKING(for glLoadIdentity in -lopengl32) - AC_TRY_LINK([#include ], - [glLoadIdentity();], - [ac_cv_my_have_gl="yes" - AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack - AC_MSG_RESULT(yes) - GL_LIBS="-lopengl32"], - [AC_MSG_RESULT(no)]) - LIBS="$LIBS_save"]) -fi - -if test "${ac_cv_my_have_gl}" = "no"; then - AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]]) -fi - - -dnl Use Glew? -ac_cv_my_have_glew="no" -PKG_CHECK_MODULES(GLEW, glew, - [ac_cv_my_have_glew="yes" - GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}" - GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"], - [:]) -AC_CHECK_HEADER(glew.h, - [LIBS_save="${LIBS}" - LIBS="${LIBS} -lglew32 ${GL_LIBS}" - AC_MSG_CHECKING(for glewInit in -lglew32) - AC_TRY_LINK( - [#include ], - [glewInit();], - [ac_cv_my_have_glew="yes" - GL_LIBS="-lglew32 ${GL_LIBS}" - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)]) - LIBS="${LIBS_save}"]) -if test "${ac_cv_my_have_glew}" != "no"; then - AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) - AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew) -fi -AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no") - -dnl Poor man's GL feature detection if all else failed. -save_LIBS="${LIBS}" -LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}" -AC_CHECK_FUNCS(glBegin) -LIBS="${save_LIBS}" +LOL_CHECK_OPENGL() dnl Use SDL? (always required on Linux or Win32)