Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/gui.git] / adm_local / 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       if test "x${opengl_dir}" = "x/usr"
53       then
54         OGL_LIBS=""
55       else
56         OGL_LIBS="-L${opengl_dir}/lib"
57       fi
58       AC_MSG_RESULT(select OpenGL distribution in ${opengl_dir})
59    else
60       AC_MSG_RESULT(no gl.h header file in ${opengl_dir}/include/GL)
61    fi
62 fi
63
64 if  test "x$OpenGL_ok" = "xno"
65 then
66   AC_CHECK_HEADERS(GL/gl.h, [OpenGL_ok=yes])
67 fi
68
69 if  test "x$OpenGL_ok" = "xno"
70 then
71 # under SunOS ?
72   AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h,
73                   [OpenGL_ok=yes]
74                   OGL_INCLUDES="-I/usr/openwin/share/include/")
75 fi
76
77 if  test "x$OpenGL_ok" = "xno"
78 then
79 # under IRIX ?
80   AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h,
81                   [OpenGL_ok=yes]
82                   OGL_INCLUDES="-I/opt/graphics/OpenGL/include")
83 fi
84 if  test "x$OpenGL_ok" = "xno"
85 then
86 # some linux OpenGL servers hide the includes in /usr/X11R6/include/GL
87   AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h,
88                   [OpenGL_ok=yes]
89                   OGL_INCLUDES="-I/usr/X11R6/include")
90 fi
91
92 if  test "x$OpenGL_ok" = "xyes"
93 then
94   AC_CHECKING(for OpenGL library)
95   OpenGL_ok=no
96   for i in $dirs; do
97     if test -r "$i/libGL.so"; then
98 dnl      AC_MSG_RESULT(in $i)
99       if test "x$i" = "x/usr/lib"
100       then
101         OGL_LIBS=""
102       else
103         OGL_LIBS="-L$i"
104       fi
105       break
106     fi
107 # under IRIX ?
108     if test -r "$i/libGL.sl"; then
109 dnl      AC_MSG_RESULT(in $i)
110       if test "x$i" = "x/usr/lib"
111       then
112         OGL_LIBS=""
113       else
114         OGL_LIBS="-L$i"
115       fi
116       break
117     fi
118   done
119   LDFLAGS_old="$LDFLAGS"
120   LDFLAGS="$LDFLAGS $OGL_LIBS"
121   AC_CHECK_LIB(GL,glBegin,OpenGL_ok=yes,OpenGL_ok=no)
122   LDFLAGS="$LDFLAGS_old"
123 fi
124
125 if test "x$OpenGL_ok" = "xyes" ; then
126   OGL_LIBS="$OGL_LIBS -lGL"
127 fi
128
129
130 OpenGLU_ok=no
131 LDFLAGS_old="$LDFLAGS"
132 LDFLAGS="$LDFLAGS $OGL_LIBS"
133 AC_CHECK_LIB(GLU,gluBeginSurface,OpenGLU_ok=yes,OpenGLU_ok=no)
134 LDFLAGS="$LDFLAGS_old"
135
136 if test "x$OpenGLU_ok" = "xyes" ; then
137   OGL_LIBS="$OGL_LIBS -lGLU"
138 fi
139
140 # Save cache
141 AC_CACHE_SAVE
142
143 ])dnl