1 dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License.
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl Lesser General Public License for more details.
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 AC_DEFUN([CHECK_OPENGL],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CPP])dnl
26 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
32 [AC_HELP_STRING([--with-opengl=DIR],[root directory path of OpenGL installation])],
33 [opengl_dir="$withval"],
34 [dirs="/usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/graphics/OpenGL/lib64 /opt/graphics/OpenGL/lib /usr/openwin/lib64 /usr/openwin/lib /usr/X11R6/lib64 /usr/X11R6/lib"])dnl
36 AC_CHECKING(for OpenGL)
37 AC_CHECKING(for OpenGL headers)
51 if test "x${opengl_dir}" != "x" ; then
52 AC_MSG_RESULT(for opengl_dir: $opengl_dir)
53 AC_CHECK_HEADER([${opengl_dir}/include/GL/gl.h],
54 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I${opengl_dir}/include"],
55 [OpenGL_headers_ok=no])
56 if test "x${OpenGL_headers_ok}" = "xyes" ; then
57 AC_CHECKING(for default OpenGL library)
58 if test "x${opengl_dir}" = "x/usr" ; then
61 OGL_LIBS="-L${opengl_dir}/lib"
63 LDFLAGS_old="$LDFLAGS"
64 LDFLAGS="$LDFLAGS $OGL_LIBS"
69 if test "x${OpenGL_libs_ok}" = "xyes" ; then
72 [OpenGL_libs_ok=yes ; OpenGL_ok=yes; OGL_LIBS="$OGL_LIBS -lGL"],
75 LDFLAGS="$LDFLAGS_old"
79 if test "x${OpenGL_headers_ok}" = "xno" ; then
80 AC_CHECK_HEADER(GL/gl.h,
81 [OpenGL_headers_ok=yes],
82 [OpenGL_headers_ok=no])
86 if test "x${OpenGL_headers_ok}" = "xno" ; then
87 AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h,
88 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/usr/openwin/share/include/"],
89 [OpenGL_headers_ok=no])
93 if test "x${OpenGL_headers_ok}" = "xno" ; then
94 AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h,
95 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/opt/graphics/OpenGL/include"],
96 [OpenGL_headers_ok=no])
99 # some linux OpenGL servers hide the includes in /usr/X11R6/include/GL
100 if test "x${OpenGL_headers_ok}" = "xno" ; then
101 AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h,
102 [OpenGL_headers_ok=yes; OGL_INCLUDES="-I/usr/X11R6/include"],
103 [OpenGL_headers_ok=no])
106 if test "x${OpenGL_headers_ok}" = "xyes" ; then
107 AC_CHECKING(for OpenGL library)
108 for idir in $dirs; do
109 if test -r "${idir}/libGL.so"; then
110 AC_MSG_RESULT(in ${idir})
111 if test "x${idir}" = "x/usr/lib64" -o "x${idir}" = "x/usr/lib" ; then
114 GL_LIB_PATH="-L${idir}"
119 if test -r "${idir}/libGL.sl"; then
120 AC_MSG_RESULT(in ${idir})
121 if test "x${idir}" = "x/usr/lib64" -o "x${idir}" = "x/usr/lib" ; then
124 GL_LIB_PATH="-L${idir}"
129 LDFLAGS_old="${LDFLAGS}"
130 LDFLAGS="${LDFLAGS} ${GL_LIB_PATH}"
133 [OpenGL_libs_ok=yes],
135 if test "x${OpenGL_libs_ok}" = "xyes" ; then
138 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GL_LIB_PATH} -lGL"],
141 LDFLAGS="$LDFLAGS_old"
144 if test "x${OpenGL_libs_ok}" = "xyes" ; then
145 for idir in $dirs; do
146 if test -r "${idir}/libGLU.so"; then
147 AC_MSG_RESULT(in ${idir})
148 if test "x${idir}" = "x/usr/lib64" -o "x${idir}" = "x/usr/lib" ; then
151 GLU_LIB_PATH="-L${idir}"
156 if test -r "${idir}/libGLU.sl"; then
157 AC_MSG_RESULT(in ${idir})
158 if test "x${idir}" = "x/usr/lib64" -o "x${idir}" = "x/usr/lib" ; then
161 GLU_LIB_PATH="-L${idir}"
167 # workaround a problem with libGL library location
168 for idir in $dirs; do
169 if test -r "${idir}/libGLU.la"; then
170 GLU_LA_PATH="${idir}/libGLU.la"
171 GL_LA_PATH_TO_CHECK=`cat ${GLU_LA_PATH} | awk '{ for(i=1;i<NF;i++){ if(gsub("libGL.la","&",$i)>0) print $i } }'`
172 if test -z ${GL_LA_PATH_TO_CHECK} || test -r ${GL_LA_PATH_TO_CHECK}; then
176 for jdir in $dirs; do
177 if test -r "${jdir}/libGL.la"; then
178 GL_LA_PATH="${jdir}/libGL.la"
179 # copy the libGLU.la file and set correct libGL.la path in it
180 NEW_GLU_LA_PATH=${ROOT_BUILDDIR}
181 NEW_GLU_LA_FILE="${NEW_GLU_LA_PATH}/libGLU.la"
182 sed -e "s%${GL_LA_PATH_TO_CHECK}%${GL_LA_PATH}%" ${GLU_LA_PATH} > "${NEW_GLU_LA_FILE}"
183 chmod -f --reference=${GLU_LA_PATH} "${NEW_GLU_LA_FILE}"
184 # set a new libGLU.la path
185 GLU_LIB_PATH="-L${NEW_GLU_LA_PATH}"
186 # create a simbolic link to libGLU.so
187 for kdir in $dirs; do
188 if test -r "${kdir}/libGLU.so"; then
189 cp -fs "${kdir}/libGLU.so" "${NEW_GLU_LA_PATH}/libGLU.so"
200 LDFLAGS_old="${LDFLAGS}"
201 LDFLAGS="${LDFLAGS} ${OGL_LIBS} ${GLU_LIB_PATH}"
204 [OpenGL_libs_ok=yes],
206 if test "x${OpenGL_libs_ok}" = "xyes" ; then
209 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GLU_LIB_PATH} -lGLU"],
212 LDFLAGS="$LDFLAGS_old"
215 if test "x${OpenGL_headers_ok}" = "xyes" ; then
216 if test "x${OpenGL_libs_ok}" = "xyes" ; then
221 AC_MSG_RESULT(for OpenGL_headers_ok: $OpenGL_headers_ok)
222 AC_MSG_RESULT(for OpenGL_libs_ok: $OpenGL_libs_ok)
223 AC_MSG_RESULT(for OpenGL_ok: $OpenGL_ok)
225 AC_SUBST(OGL_INCLUDES)