Salome HOME
sources v1.2
[modules/kernel.git] / salome_adm / unix / config_files / check_opengl.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22 AC_DEFUN([CHECK_OPENGL],[
23 AC_REQUIRE([AC_PROG_CC])dnl
24 AC_REQUIRE([AC_PROG_CPP])dnl
25 AC_ARG_WITH(opengl,
26    [  --with-opengl=DIR root directory path of OpenGL installation ],
27    [
28       opengl_dir="$withval"
29       local_opengl=yes
30     ], [
31       dirs="/usr/lib /usr/local/lib /opt/graphics/OpenGL/lib /usr/openwin/lib /usr/X11R6/lib"
32     ])dnl
33
34 AC_CHECKING(for OpenGL)
35
36 AC_SUBST(OGL_INCLUDES)
37 AC_SUBST(OGL_LIBS)
38
39 OGL_INCLUDES=""
40 OGL_LIBS=""
41
42 OpenGL_ok=no
43
44 dnl openGL headers
45
46 # by default
47
48 if test "x$local_opengl" = "xyes" ; then
49    if test -f "${opengl_dir}/include/GL/gl.h" ; then
50       OpenGL_ok=yes
51       OGL_INCLUDES="-I${opengl_dir}/include"
52       OGL_LIBS="-L${opengl_dir}/lib"
53       AC_MSG_RESULT(select OpenGL distribution in ${opengl_dir})
54    else
55       AC_MSG_RESULT(no gl.h header file in ${opengl_dir}/include/GL)
56    fi
57 fi
58
59 if  test "x$OpenGL_ok" = "xno"
60 then
61   AC_CHECK_HEADERS(GL/gl.h, [OpenGL_ok=yes])
62 fi
63
64 if  test "x$OpenGL_ok" = "xno"
65 then
66 # under SunOS ?
67   AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h,
68                   [OpenGL_ok=yes]
69                   OGL_INCLUDES="-I/usr/openwin/share/include/")
70 fi
71
72 if  test "x$OpenGL_ok" = "xno"
73 then
74 # under IRIX ?
75   AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h,
76                   [OpenGL_ok=yes]
77                   OGL_INCLUDES="-I/opt/graphics/OpenGL/include")
78 fi
79 if  test "x$OpenGL_ok" = "xno"
80 then
81 # some linux OpenGL servers hide the includes in /usr/X11R6/include/GL
82   AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h,
83                   [OpenGL_ok=yes]
84                   OGL_INCLUDES="-I/usr/X11R6/include")
85 fi
86
87 if  test "x$OpenGL_ok" = "xyes"
88 then
89   AC_CHECKING(for OpenGL library)
90   OpenGL_ok=no
91   for i in $dirs; do
92     if test -r "$i/libGL.so"; then
93 dnl      AC_MSG_RESULT(in $i)
94       OGL_LIBS="-L$i"
95       break
96     fi
97 # under IRIX ?
98     if test -r "$i/libGL.sl"; then
99 dnl      AC_MSG_RESULT(in $i)
100       OGL_LIBS="-L$i"
101       break
102     fi
103   done
104   LDFLAGS_old="$LDFLAGS"
105   LDFLAGS="$LDFLAGS $OGL_LIBS"
106   AC_CHECK_LIB(GL,glBegin,OpenGL_ok=yes,OpenGL_ok=no)
107   LDFLAGS="$LDFLAGS_old"
108 fi
109
110 if test "x$OpenGL_ok" = "xyes" ; then
111   OGL_LIBS="$OGL_LIBS -lGL"
112 fi
113
114
115 OpenGLU_ok=no
116 LDFLAGS_old="$LDFLAGS"
117 LDFLAGS="$LDFLAGS $OGL_LIBS"
118 AC_CHECK_LIB(GLU,gluBeginSurface,OpenGLU_ok=yes,OpenGLU_ok=no)
119 LDFLAGS="$LDFLAGS_old"
120
121 if test "x$OpenGLU_ok" = "xyes" ; then
122   OGL_LIBS="$OGL_LIBS -lGLU"
123 fi
124
125 # Save cache
126 AC_CACHE_SAVE
127
128 ])dnl