Salome HOME
a1672effa24636247446f43fda8c4c72f0d6fc2f
[modules/yacs.git] / src / wrappergen / src / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / check_opengl.m4
1 dnl Copyright (C) 2006-2022  CEA/DEN, EDF R&D
2 dnl
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.
7 dnl
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.
12 dnl
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
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
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
24
25 AC_LANG_SAVE
26 AC_LANG_CPLUSPLUS
27
28 AC_ARG_WITH(opengl,
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
32
33 AC_CHECKING(for OpenGL)
34 AC_CHECKING(for OpenGL headers)
35
36 OGL_INCLUDES=""
37 OGL_LIBS=""
38
39 GL_LIB_PATH=""
40 GLU_LIB_PATH=""
41
42 OpenGL_ok=no
43 OpenGL_libs_ok=no
44 OpenGL_headers_ok=no
45
46 dnl openGL headers
47 # by default
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
56       OGL_LIBS=""
57     else
58       OGL_LIBS="-L${opengl_dir}/lib"
59     fi
60     LDFLAGS_old="$LDFLAGS"
61     LDFLAGS="$LDFLAGS $OGL_LIBS"
62     AC_CHECK_LIB([GL],
63                  [glBegin],
64                  [OpenGL_libs_ok=yes],
65                  [OpenGL_libs_ok=no])
66     if test "x${OpenGL_libs_ok}" = "xyes" ; then
67       AC_TRY_LINK([],
68                   [],
69                   [OpenGL_libs_ok=yes ; OpenGL_ok=yes; OGL_LIBS="$OGL_LIBS -lGL"],
70                   [OpenGL_libs_ok=no])
71     fi
72     LDFLAGS="$LDFLAGS_old"
73   fi
74 fi
75
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])
80 fi
81
82 # under SunOS ?
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])
87 fi
88
89 # under IRIX ?
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])
94 fi
95
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])
101 fi
102
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
109         GL_LIB_PATH=""
110       else
111         GL_LIB_PATH="-L${idir}"
112       fi
113       break
114     fi
115     # under IRIX ?
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
119         GL_LIB_PATH=""
120       else
121         GL_LIB_PATH="-L${idir}"
122       fi
123       break
124     fi
125   done
126   LDFLAGS_old="${LDFLAGS}"
127   LDFLAGS="${LDFLAGS} ${GL_LIB_PATH}"
128   AC_CHECK_LIB([GL],
129                [glBegin],
130                [OpenGL_libs_ok=yes],
131                [OpenGL_libs_ok=no])
132   if test "x${OpenGL_libs_ok}" = "xyes" ; then
133     AC_TRY_LINK([],
134                 [],
135                 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GL_LIB_PATH} -lGL"],
136                 [OpenGL_libs_ok=no])
137   fi
138   LDFLAGS="$LDFLAGS_old"
139 fi
140
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
146         GLU_LIB_PATH=""
147       else
148         GLU_LIB_PATH="-L${idir}"
149       fi
150       break
151     fi
152     # under IRIX ?
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
156         GLU_LIB_PATH=""
157       else
158         GLU_LIB_PATH="-L${idir}"
159       fi
160       break
161     fi
162   done
163   LDFLAGS_old="${LDFLAGS}"
164   LDFLAGS="${LDFLAGS} ${OGL_LIBS} ${GLU_LIB_PATH}"
165   AC_CHECK_LIB([GLU],
166                [gluBeginSurface],
167                [OpenGL_libs_ok=yes],
168                [OpenGL_libs_ok=no])
169   if test "x${OpenGL_libs_ok}" = "xyes" ; then
170     AC_TRY_LINK([],
171                 [],
172                 [OpenGL_libs_ok=yes ; OGL_LIBS="${OGL_LIBS} ${GLU_LIB_PATH} -lGLU"],
173                 [OpenGL_libs_ok=no])
174   fi
175   LDFLAGS="$LDFLAGS_old"
176 fi
177
178 if test "x${OpenGL_headers_ok}" = "xyes" ; then
179   if test "x${OpenGL_libs_ok}" = "xyes" ; then
180     OpenGL_ok=yes
181   fi
182 fi
183
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)
187
188 AC_SUBST(OGL_INCLUDES)
189 AC_SUBST(OGL_LIBS)
190
191 AC_LANG_RESTORE
192
193 ])dnl