-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhas_opengl.m4
207 lines (170 loc) · 5.7 KB
/
has_opengl.m4
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
dnl #########################################################################
dnl Synopsis:
dnl AC_PATH_GL
dnl Purpose:
dnl To seek and find your Qt installation
dnl Access:
dnl
dnl --with-gl-dir where the root of gl is installed (/usr/local/gl)
dnl --with-gl-include where the gl includes are. (/usr/local/gl/include)
dnl --with-gl-lib where the gl library is installed. (/usr/local/gl/lib)
dnl --enable-mesagl If you always want MesaGL instead of just GL
dnl Defines: (to DEFS or config.h)
dnl None
dnl Substitutions: (to Makefile from Makefile.in)
dnl GL_CFLAGS - Path to GL includes (-Iwhateverincdir)
dnl GL_LIBS - Linkpath and libraryname (-Lwhateverlibdir -lgl)
dnl Requirements:
dnl AC_PATH_XTRA must be called first, for now
dnl Returns:
dnl values in GL_CFLAGS and GL_LIBS, or configure will stop on error
dnl #########################################################################
AC_DEFUN(AC_PATH_GL,
[
AC_PROVIDE([$0])
AC_REQUIRE([AC_PATH_XTRA])
ac_cv_with_gl_dir=
ac_cv_with_gl_lib=
ac_cv_with_gl_inc=
ac_cv_enable_mesagl=
GL_CFLAGS=
GL_LIBS=
GL_LFLAGS=
AC_MSG_CHECKING("if you want to use the OpenGL extensions")
use_opengl=no
AC_ARG_WITH(gl-dir,
[ --with-gl-dir where the root of gl is installed (/usr/local/gl) ],
[ ac_cv_with_gl_dir="$withval" ; use_opengl=yes ])
AC_ARG_WITH(opengl,
[ --with-opengl where the root of gl is installed (/usr/local/gl) ],
[ ac_cv_with_gl_dir="$withval" ; use_opengl=yes ])
AC_ARG_WITH(gl-include,
[ --with-gl-include where the gl includes are. (/usr/local/gl/include) ],
[ ac_cv_with_gl_inc="$withval" ; use_opengl=yes ])
AC_ARG_WITH(gl-lib,
[ --with-gl-lib where the gl library is installed. (/usr/local/gl/lib)],
[ ac_cv_with_gl_lib="$withval" ; use_opengl=yes ])
AC_ARG_ENABLE(mesagl,
[ --enable-mesagl If you always want MesaGL instead of just GL ],
[ ac_cv_enable_mesagl="$enableval" ; use_opengl=yes ],
[ ac_cv_enable_mesagl="no" ])
if test "$use_opengl" = yes; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING("we like Mesa GL instead of just OpenGL")
AC_MSG_RESULT("$ac_cv_enable_mesagl")
dnl try to set some paths
AC_MSG_CHECKING("for Gl location")
for ac_dir in \
${GLDIR} \
${ac_cv_with_gl_dir} \
/usr/gl \
/usr/local/gl \
/usr/share/gl \
/usr/GL \
/usr/local/GL \
/usr/share/GL \
/usr/MesaGL \
/usr/local/MesaGL \
/usr/share/MesaGL \
; \
do
if test -n "$ac_dir" && test -d "$ac_dir"; then
ac_cv_with_gl_dir="$ac_dir"
break;
fi
done
if test ! -n "$ac_cv_with_gl_dir"; then
AC_MSG_RESULT("don\'t know...")
else
AC_MSG_RESULT("$ac_cv_with_gl_dir")
fi
dnl check for libraries and includes
dnl TODO: use the value of $ac_cv_with_gl_inc first if it existed!
AC_MSG_CHECKING("for Gl include paths")
AC_TRY_CPP([#include <GL/gl.h>],
[
AC_MSG_RESULT(["Good, includes in your path"])
],
[
AC_MSG_RESULT(["Not in your path, searching..."])
for ac_dir in \
$ac_cv_with_gl_dir/include \
$ac_cv_with_gl_inc \
/usr/local/MesaGL/include \
/usr/local/include \
/usr/share/MesaGL/include \
/usr/share/include \
/usr/MesaGL/include \
/usr/include \
/usr/include/GL \
/usr/X11R6/include \
/usr/include/X11 \
/usr/local/X11R6/include \
/usr/local/X11/include \
; \
do
AC_MSG_CHECKING(["in $ac_dir"])
if test -r "$ac_dir/GL/gl.h"; then
ac_cv_with_gl_inc=$ac_dir
break
fi
AC_MSG_RESULT(["no"])
done
if test -n "$ac_cv_with_gl_inc" ; then
AC_MSG_RESULT(["yes"])
GL_CFLAGS="-I${ac_cv_with_gl_inc}"
else
AC_MSG_ERROR(["Can\'t find the Gl includes"])
fi
])
AC_MSG_RESULT(["+ Gl libraries ${ac_cv_with_gl_lib}, Gl includes ${ac_cv_with_gl_inc}"])
SAVE_LIBS="${LIBS}"
if test ! -n "${ac_cv_with_gl_lib}" && test -n "${ac_cv_with_gl_dir}"; then
ac_cv_with_gl_lib="${ac_cv_with_gl_dir}/lib"
elif test ! -n "${ac_cv_with_gl_lib}"; then
ac_cv_with_gl_lib="."
fi
if test "$ac_cv_enable_mesagl" = no; then
AC_CHECK_LIB(GL, main,
[
if test "${ac_cv_with_gl_lib}" = "."; then
GL_LFLAGS=
else
GL_LFLAGS="-L${ac_cv_with_gl_lib}"
fi
GL_LIBS="-lGLU -lGL $X_PRE_LIBS -lXext -lm"
AC_SUBST(GL_LIBS)
AC_SUBST(GL_LFLAGS)
],
[
GL_LIBS=no
],
[-L$ac_cv_with_gl_lib $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXext -lm])
fi
if test "$ac_cv_enable_mesagl" = yes || test "${GL_LIBS}" = no; then
if test "$ac_cv_enable_mesagl" = yes; then
AC_MSG_WARN(["Will not link with standard Gl, trying to force the Mesa library..."])
else
AC_MSG_WARN(["Can\'t not link with Gl, trying the Mesa library..."])
fi
AC_CHECK_LIB(MesaGL, main,
[
if test "${ac_cv_with_gl_lib}" = "."; then
GL_LFLAGS=
else
GL_LFLAGS="-L${ac_cv_with_gl_lib}"
fi
GL_LIBS="-lMesaGLU -lMesaGL -lXext -lm"
AC_SUBST(GL_LFLAGS)
AC_SUBST(GL_LIBS)
],
[
AC_MSG_ERROR(["You need to install \(Mesa\) OpenGL first: can\'t find either the GL or MesaGL library"])
], [-L$ac_cv_with_gl_lib $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXext -lm])
fi
LIBS="${SAVE_LIBS}"
AC_SUBST(GL_CFLAGS)
else
AC_MSG_RESULT('no')
fi
])