~ubuntu-branches/debian/sid/3depict/sid

« back to all changes in this revision

Viewing changes to m4/gl.m4

  • Committer: Bazaar Package Importer
  • Author(s): D Haley
  • Date: 2010-08-09 21:23:50 UTC
  • Revision ID: james.westby@ubuntu.com-20100809212350-cg6yumndhwi3bqws
Tags: upstream-0.0.1
ImportĀ upstreamĀ versionĀ 0.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl FTGL_CHECK_GL()
 
2
dnl Check for OpenGL development environment and GLU >= 1.2
 
3
dnl
 
4
AC_DEFUN([FTGL_CHECK_GL],
 
5
[dnl
 
6
AC_REQUIRE([AC_PROG_CC])
 
7
AC_REQUIRE([AC_PATH_X])
 
8
AC_REQUIRE([AC_PATH_XTRA])
 
9
 
 
10
AC_ARG_WITH([--with-gl-inc],
 
11
    AC_HELP_STRING([--with-gl-inc=DIR],[Directory where GL/gl.h is installed]))
 
12
AC_ARG_WITH([--with-gl-lib],
 
13
    AC_HELP_STRING([--with-gl-lib=DIR],[Directory where OpenGL libraries are installed]))
 
14
AC_ARG_WITH([--with-glu-lib],
 
15
    AC_HELP_STRING([--with-glu-lib=DIR],[Directory where OpenGL GLU library is installed]))
 
16
 
 
17
AC_LANG_SAVE
 
18
AC_LANG_C
 
19
 
 
20
GL_SAVE_CPPFLAGS="$CPPFLAGS"
 
21
GL_SAVE_LIBS="$LIBS"
 
22
 
 
23
if test "x$no_x" != xyes ; then
 
24
    GL_CFLAGS="$X_CFLAGS"
 
25
    GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu $X_EXTRA_LIBS"
 
26
fi
 
27
 
 
28
if test "x$with_gl_inc" != "xnone" ; then
 
29
    if test -d "$with_gl_inc" ; then
 
30
        GL_CFLAGS="-I$with_gl_inc"
 
31
    else
 
32
        GL_CFLAGS="$with_gl_inc"
 
33
    fi
 
34
else
 
35
    GL_CFLAGS=
 
36
fi
 
37
 
 
38
CPPFLAGS="$GL_CFLAGS"
 
39
AC_CHECK_HEADER([GL/gl.h], [AC_DEFINE([HAVE_GL_GL_H], 1, [Define to 1 if you have the <GL/gl.h header])], [
 
40
        AC_CHECK_HEADER([OpenGL/gl.h], [AC_DEFINE([HAVE_OPENGL_GL_H], 1, [Define to 1 if you have the <OpenGL/gl.h header])], [
 
41
                AC_MSG_ERROR([GL/gl.h or OpenGL/gl.h is needed, please specify its location with --with-gl-inc.  If this still fails, please contact henryj@paradise.net.nz, include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
 
42
        ])
 
43
])
 
44
 
 
45
dnl check whether the OpenGL framework is available
 
46
AC_MSG_CHECKING([for OpenGL framework (Darwin-specific)])
 
47
FRAMEWORK_OPENGL=""
 
48
PRELIBS="$LIBS"
 
49
LIBS="$LIBS -Xlinker -framework -Xlinker OpenGL"
 
50
# -Xlinker is used because libtool is busted prior to 1.6 wrt frameworks
 
51
AC_TRY_LINK([#include <OpenGL/gl.h>], [glBegin(GL_POINTS)],
 
52
    [GL_DYLIB="/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
 
53
     FRAMEWORK_OPENGL="-Xlinker -framework -Xlinker OpenGL -dylib_file $GL_DYLIB: $GL_DYLIB"
 
54
     ac_cv_search_glBegin="$FRAMEWORK_OPENGL"
 
55
     AC_MSG_RESULT(yes)],
 
56
    [AC_MSG_RESULT(no)])
 
57
if test x"$FRAMEWORK_OPENGL" != "x"; then
 
58
  with_gl_lib="$FRAMEWORK_OPENGL"
 
59
fi
 
60
AC_SUBST(FRAMEWORK_OPENGL)
 
61
LIBS="$PRELIBS"
 
62
 
 
63
AC_MSG_CHECKING([for GL library])
 
64
echo host=$host
 
65
AS_CASE([$host],
 
66
  [*-mingw32], [GL_GL_LIBS="-lopengl32"
 
67
                GL_GLU_LIBS="-lglu32"],
 
68
  [GL_GL_LIBS="-lGL"
 
69
   GL_GLU_LIBS="-lGLU"]
 
70
)
 
71
 
 
72
if test "x$with_gl_lib" != "x" ; then
 
73
    if test -d "$with_gl_lib" ; then
 
74
        LIBS="-L$with_gl_lib $GL_GL_LIBS"
 
75
    else
 
76
        LIBS="$with_gl_lib"
 
77
    fi
 
78
else
 
79
    LIBS="$GL_GL_LIBS"
 
80
fi
 
81
AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes],[
 
82
dnl This is done here so that we can check for the Win32 version of the
 
83
dnl GL library, which may not use cdecl calling convention.
 
84
 AC_TRY_LINK([#include <GL/gl.h>],[glBegin(GL_POINTS)],[HAVE_GL=yes],[HAVE_GL=no])]
 
85
)
 
86
 
 
87
if test "x$HAVE_GL" = xno ; then
 
88
    if test "x$GL_X_LIBS" != x ; then
 
89
        LIBS="$GL_GL_LIBS $GL_X_LIBS"
 
90
        AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
 
91
    fi
 
92
fi
 
93
if test "x$HAVE_GL" = xyes ; then
 
94
    AC_MSG_RESULT([yes])
 
95
    GL_LIBS=$LIBS
 
96
else
 
97
    AC_MSG_RESULT([no])
 
98
    AC_MSG_ERROR([GL library could not be found, please specify its location with --with-gl-lib.  If this still fails, please contact henryj@paradise.net.nz, include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
 
99
fi
 
100
 
 
101
AC_CHECK_HEADER([GL/glu.h], [AC_DEFINE([HAVE_GL_GLU_H], 1, [Define to 1 if you have the <GL/glu.h header])], [
 
102
        AC_CHECK_HEADER([OpenGL/glu.h], [AC_DEFINE([HAVE_OPENGL_GLU_H], 1, [Define to 1 if you have the <OpenGL/glu.h header])], [
 
103
                AC_MSG_ERROR([GL/glu.h or OpenGL/glu.h is needed, please specify its location with --with-gl-inc.  If this still fails, please contact henryj@paradise.net.nz, include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
 
104
        ])
 
105
])
 
106
AC_MSG_CHECKING([for GLU version >= 1.2])
 
107
AC_TRY_COMPILE([
 
108
#ifdef HAVE_GL_GLU_H
 
109
#  include <GL/glu.h>
 
110
#endif
 
111
#ifdef HAVE_OPENGL_GLU_H
 
112
#  include <OpenGL/glu.h>
 
113
#endif
 
114
], [
 
115
#if !defined(GLU_VERSION_1_2)
 
116
#error GLU too old
 
117
#endif
 
118
               ],
 
119
               [AC_MSG_RESULT([yes])],
 
120
               [AC_MSG_RESULT([no])
 
121
                AC_MSG_ERROR([GLU >= 1.2 is needed to compile this library])
 
122
               ])
 
123
 
 
124
if test "x$FRAMEWORK_OPENGL" = "x" ; then
 
125
 
 
126
AC_MSG_CHECKING([for GLU library])
 
127
if test "x$with_glu_lib" != "x" ; then
 
128
    if test -d "$with_glu_lib" ; then
 
129
        LIBS="$GL_LIBS -L$with_glu_lib $GL_GLU_LIBS"
 
130
    else
 
131
        LIBS="$GL_LIBS $with_glu_lib"
 
132
    fi
 
133
else
 
134
    LIBS="$GL_LIBS $GL_GLU_LIBS"
 
135
fi
 
136
AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [
 
137
dnl This is done here so that we can check for the Win32 version of the
 
138
dnl GL library, which may not use cdecl calling convention.
 
139
 AC_TRY_LINK([#include <GL/glu.h>],[gluNewTess()],[HAVE_GLU=yes],[HAVE_GLU=no])]
 
140
)
 
141
if test "x$HAVE_GLU" = xno ; then
 
142
    if test "x$GL_X_LIBS" != x ; then
 
143
        LIBS="$GL_GLU_LIBS $GL_LIBS $GL_X_LIBS"
 
144
        AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
 
145
    fi
 
146
fi
 
147
if test "x$HAVE_GLU" = xyes ; then
 
148
    AC_MSG_RESULT([yes])
 
149
    GL_LIBS="$LIBS"
 
150
else
 
151
    AC_MSG_RESULT([no])
 
152
    AC_MSG_ERROR([GLU library could not be found, please specify its location with --with-gl-lib.  If this still fails, please contact henryj@paradise.net.nz, include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
 
153
fi
 
154
 
 
155
fi
 
156
 
 
157
AC_SUBST(GL_CFLAGS)
 
158
AC_SUBST(GL_LIBS)
 
159
 
 
160
CPPFLAGS="$GL_SAVE_CPPFLAGS"
 
161
LIBS="$GL_SAVE_LIBS"
 
162
AC_LANG_RESTORE
 
163
GL_X_LIBS=""
 
164
])