1 dnl Copyright (C) 2006-2021 CEA/DEN, EDF R&D
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 dnl Lesser General Public License for more details.
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 AC_DEFUN([CHECK_OPENGL],[
21 AC_REQUIRE([AC_PROG_CC])dnl
22 AC_REQUIRE([AC_PROG_CPP])dnl
23 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
29 [AC_HELP_STRING([--with-opengl=DIR],[root directory path of OpenGL installation])],
30 [opengl_dir="$withval"],
31 [dirs="/usr/lib${LIB_LOCATION_SUFFIX} /usr/local/lib${LIB_LOCATION_SUFFIX} /opt/graphics/OpenGL/lib${LIB_LOCATION_SUFFIX} /usr/openwin/lib${LIB_LOCATION_SUFFIX} /usr/X11R6/lib${LIB_LOCATION_SUFFIX}"])dnl
33 AC_CHECKING(for OpenGL)
34 AC_CHECKING(for OpenGL headers)
48 if test "x${opengl_dir}" != "x" ; then
49 AC_MSG_RESULT(for opengl_dir: $opengl_dir)
50 AC_CHECK_HEADER([${opengl_dir}/include/GL/gl.h],
51 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I${opengl_dir}/include"],
52 [OpenGL_headers_ok=no])
53 if test "x${OpenGL_headers_ok}" = "xyes" ; then
54 AC_CHECKING(for default OpenGL library)
55 if test "x${opengl_dir}" = "x/usr" ; then
58 OGL_LIBS="-L${opengl_dir}/lib"
60 LDFLAGS_old="$LDFLAGS"
61 LDFLAGS="$LDFLAGS $OGL_LIBS"
66 if test "x${OpenGL_libs_ok}" = "xyes" ; then
69 [OpenGL_libs_ok=yes ; OpenGL_ok=yes; OGL_LIBS="$OGL_LIBS -lGL"],
72 LDFLAGS="$LDFLAGS_old"
76 if test "x${OpenGL_headers_ok}" = "xno" ; then
77 AC_CHECK_HEADER(GL/gl.h,
78 [OpenGL_headers_ok=yes],
79 [OpenGL_headers_ok=no])
83 if test "x${OpenGL_headers_ok}" = "xno" ; then
84 AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h,
85 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/usr/openwin/share/include/"],
86 [OpenGL_headers_ok=no])
90 if test "x${OpenGL_headers_ok}" = "xno" ; then
91 AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h,
92 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/opt/graphics/OpenGL/include"],
93 [OpenGL_headers_ok=no])
96 # some linux OpenGL servers hide the includes in /usr/X11R6/include/GL
97 if test "x${OpenGL_headers_ok}" = "xno" ; then
98 AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h,
99 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/usr/X11R6/include"],
100 [OpenGL_headers_ok=no])
103 if test "x${OpenGL_headers_ok}" = "xyes" ; then
104 AC_CHECKING(for OpenGL library)
105 for idir in $dirs; do
106 if test -r "${idir}/libGL.so"; then
107 AC_MSG_RESULT(in ${idir})
108 if test "x${idir}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
111 GL_LIB_PATH="-L${idir}"
116 if test -r "${idir}/libGL.sl"; then
117 AC_MSG_RESULT(in ${idir})
118 if test "x${idir}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
121 GL_LIB_PATH="-L${idir}"
126 LDFLAGS_old="${LDFLAGS}"
127 LDFLAGS="${LDFLAGS} ${GL_LIB_PATH}"
130 [OpenGL_libs_ok=yes],
132 if test "x${OpenGL_libs_ok}" = "xyes" ; then
135 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GL_LIB_PATH} -lGL"],
138 LDFLAGS="$LDFLAGS_old"
141 if test "x${OpenGL_libs_ok}" = "xyes" ; then
142 for idir in $dirs; do
143 if test -r "${idir}/libGLU.so"; then
144 AC_MSG_RESULT(in ${idir})
145 if test "x${idir}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
148 GLU_LIB_PATH="-L${idir}"
153 if test -r "${idir}/libGLU.sl"; then
154 AC_MSG_RESULT(in ${idir})
155 if test "x${idir}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
158 GLU_LIB_PATH="-L${idir}"
163 LDFLAGS_old="${LDFLAGS}"
164 LDFLAGS="${LDFLAGS} ${OGL_LIBS} ${GLU_LIB_PATH}"
167 [OpenGL_libs_ok=yes],
169 if test "x${OpenGL_libs_ok}" = "xyes" ; then
172 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GLU_LIB_PATH} -lGLU"],
175 LDFLAGS="$LDFLAGS_old"
178 if test "x${OpenGL_headers_ok}" = "xyes" ; then
179 if test "x${OpenGL_libs_ok}" = "xyes" ; then
184 AC_MSG_RESULT(for OpenGL_headers_ok: $OpenGL_headers_ok)
185 AC_MSG_RESULT(for OpenGL_libs_ok: $OpenGL_libs_ok)
186 AC_MSG_RESULT(for OpenGL_ok: $OpenGL_ok)
188 AC_SUBST(OGL_INCLUDES)