* Check for <GL/glut.h> and <GLUT/glut.h> during the configure step instead of guessing their location at build time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index db865cb..330dd3e 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -38,10 +38,12 @@
#include <stdio.h>
#include <string.h>
-#ifdef __APPLE_CC__
+#if defined HAVE_GL_GLUT_H
+# include <GL/glut.h>
+#elif defined HAVE_GLUT_GLUT_H
# include <GLUT/glut.h>
#else
-# include <GL/glut.h>
+# error GLUT headers not present
#endif
#include "tb.h"
diff --git a/demo/FTGLMFontDemo.cpp b/demo/FTGLMFontDemo.cpp
index 4bceab9..fa21eb1 100644
--- a/demo/FTGLMFontDemo.cpp
+++ b/demo/FTGLMFontDemo.cpp
@@ -34,16 +34,18 @@
#include "config.h"
-#ifdef __APPLE_CC__
-# include <GLUT/glut.h>
-#else
-# include <GL/glut.h>
-#endif
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#if defined HAVE_GL_GLUT_H
+# include <GL/glut.h>
+#elif defined HAVE_GLUT_GLUT_H
+# include <GLUT/glut.h>
+#else
+# error GLUT headers not present
+#endif
+
#include "tb.h"
#include "FTGLExtrdFont.h"
diff --git a/demo/tb.c b/demo/tb.c
index d9526a5..f57041a 100644
--- a/demo/tb.c
+++ b/demo/tb.c
@@ -8,11 +8,15 @@
#include <math.h>
#include <assert.h>
-#ifdef __APPLE_CC__
- #include <GLUT/glut.h>
+
+#if defined HAVE_GL_GLUT_H
+# include <GL/glut.h>
+#elif defined HAVE_GLUT_GLUT_H
+# include <GLUT/glut.h>
#else
- #include <GL/glut.h>
+# error GLUT headers not present
#endif
+
#include "tb.h"
#include "trackball.h"
diff --git a/m4/glut.m4 b/m4/glut.m4
index d0494b4..bba7cda 100644
--- a/m4/glut.m4
+++ b/m4/glut.m4
@@ -19,34 +19,32 @@ AC_LANG_C
GLUT_SAVE_CPPFLAGS="$CPPFLAGS"
GLUT_SAVE_LIBS="$LIBS"
-if test "x$no_x" != xyes ; then
+if test "$no_x" != "yes"; then
GLUT_CFLAGS="$X_CFLAGS"
GLUT_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu $X_EXTRA_LIBS"
fi
-if test "x$with_glut_inc" != "xnone" ; then
- if test -d "$with_glut_inc" ; then
+if test "$with_glut_inc" != "none"; then
+ if test -d "$with_glut_inc"; then
GLUT_CFLAGS="-I$with_glut_inc"
else
GLUT_CFLAGS="$with_glut_inc"
fi
else
- GLUT_CFLAGS=
+ GLUT_CFLAGS=""
fi
+# Check for GLUT headers
CPPFLAGS="$GLUT_CFLAGS"
-AC_CHECK_HEADER([GL/glut.h], [HAVE_GLUT=yes], [HAVE_GLUT=no])
-AM_CONDITIONAL(HAVE_GLUT, [test "$HAVE_GLUT" = "yes"])
-
-if test "x$HAVE_GLUT" = xno ; then
- AC_MSG_WARN([GLUT headers not availabe, example program won't be compiled.])
-else
+AC_CHECK_HEADERS([GL/glut.h], [ac_cv_have_glut=yes],
+ [AC_CHECK_HEADERS([GLUT/glut.h], [ac_cv_have_glut=yes],
+ [ac_cv_have_glut=no])])
# Check for GLUT libraries
-
+if test "$ac_cv_have_glut" = "yes"; then
AC_MSG_CHECKING([for GLUT library])
- if test "x$with_glut_lib" != "x" ; then
- if test -d "$with_glut_lib" ; then
+ if test "$with_glut_lib" != ""; then
+ if test -d "$with_glut_lib"; then
LIBS="-L$with_glut_lib -lglut"
else
LIBS="$with_glut_lib"
@@ -54,42 +52,43 @@ else
else
LIBS="-lglut"
fi
+
AC_LINK_IFELSE(
[AC_LANG_CALL([],[glutInit])],
- [HAVE_GLUT=yes],
- [HAVE_GLUT=no])
-
- if test "x$HAVE_GLUT" = xno ; then
+ [ac_cv_have_glut=yes],
+ [ac_cv_have_glut=no])
+ if test "$ac_cv_have_glut" = "no"; then
# Try again with the GL libs
LIBS="-lglut $GL_LIBS"
AC_LINK_IFELSE(
[AC_LANG_CALL([],[glutInit])],
- [HAVE_GLUT=yes],
- [HAVE_GLUT=no])
+ [ac_cv_have_glut=yes],
+ [ac_cv_have_glut=no])
fi
- if test "x$HAVE_GLUT" = xno && test "x$GLUT_X_LIBS" != x ; then
+ if test "$ac_cv_have_glut" = "no" && test "$GLUT_X_LIBS" != ""; then
# Try again with the GL and X11 libs
LIBS="-lglut $GL_LIBS $GLUT_X_LIBS"
AC_LINK_IFELSE(
[AC_LANG_CALL([],[glutInit])],
- [HAVE_GLUT=yes],
- [HAVE_GLUT=no])
+ [ac_cv_have_glut=yes],
+ [ac_cv_have_glut=no])
fi
- if test "x$HAVE_GLUT" = xyes ; then
+ if test "$ac_cv_have_glut" = "yes"; then
AC_MSG_RESULT([yes])
- GLUT_LIBS=$LIBS
+ GLUT_LIBS="$LIBS"
else
AC_MSG_RESULT([no])
- AC_MSG_WARN([GLUT libraries not availabe, example program won't be compiled.])
fi
+fi
-# End check for GLUT libraries
-
+if test "$ac_cv_have_glut" = "no"; then
+ AC_MSG_WARN([GLUT headers not availabe, example program won't be compiled.])
fi
-AC_SUBST(HAVE_GLUT)
+AM_CONDITIONAL(HAVE_GLUT, [test "$ac_cv_have_glut" = "yes"])
+
AC_SUBST(GLUT_CFLAGS)
AC_SUBST(GLUT_LIBS)
AC_LANG_RESTORE
@@ -99,3 +98,4 @@ LIBS="$GLUT_SAVE_LIBS"
GLUT_X_CFLAGS=
GLUT_X_LIBS=
])
+
diff --git a/test/TestMain.cpp b/test/TestMain.cpp
index db4264a..6be5c8e 100644
--- a/test/TestMain.cpp
+++ b/test/TestMain.cpp
@@ -1,10 +1,14 @@
+#include "config.h"
+
#include <cppunit/TextTestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#ifdef __APPLE_CC__
- #include <GLUT/glut.h>
+#if defined HAVE_GL_GLUT_H
+# include <GL/glut.h>
+#elif defined HAVE_GLUT_GLUT_H
+# include <GLUT/glut.h>
#else
- #include <GL/glut.h>
+# error GLUT headers not present
#endif
int main(int argc, const char* argv[])
diff --git a/test/demo.cpp b/test/demo.cpp
index 8287a81..00ac5d9 100644
--- a/test/demo.cpp
+++ b/test/demo.cpp
@@ -1,10 +1,12 @@
#include <iostream>
#include <stdlib.h> // exit()
-#ifdef __APPLE_CC__
- #include <GLUT/glut.h>
+#if defined HAVE_GL_GLUT_H
+# include <GL/glut.h>
+#elif defined HAVE_GLUT_GLUT_H
+# include <GLUT/glut.h>
#else
- #include <GL/glut.h>
+# error GLUT headers not present
#endif
#include "FTGLOutlineFont.h"