-dnl The four "standard" OpenGL libraries are searched for: "-lGL",
-dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be) and
-dnl "-lglut".
-dnl
-dnl All of the libraries that are found (since "-lglut" or "-lGLX" might
-dnl be missing) are added to the shell output variable "GL_LIBS", along
-dnl with any other libraries that are necessary to successfully link an
-dnl OpenGL application (e.g. the X11 libraries). Care has been taken to
-dnl make sure that all of the libraries in "GL_LIBS" are listed in the
-dnl proper order.
-dnl
-dnl Additionally, the shell output variable "GL_CFLAGS" is set to any
-dnl flags (e.g. "-I" flags) that are necessary to successfully compile
-dnl an OpenGL application.
-dnl
-dnl The following shell variable (which are not output variables) are
-dnl also set to either "yes" or "no" (depending on which libraries were
-dnl found) to help you determine exactly what was found.
-dnl
-dnl have_GL
-dnl have_GLU
-dnl have_GLX
-dnl have_glut
-dnl
-dnl A complete little toy "Automake `make distcheck'" package of how to
-dnl use this macro is available at:
-dnl
-dnl ftp://ftp.slac.stanford.edu/users/langston/autoconf/ac_opengl-0.01.tar.gz
-dnl
-dnl Please note that as the ac_opengl macro and the toy example evolves,
-dnl the version number increases, so you may have to adjust the above
-dnl URL accordingly.
-dnl
-dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU>
-
-AC_DEFUN(FPTOOLS_HAVE_OPENGL,
-[
- AC_REQUIRE([AC_PROG_CC])
- AC_REQUIRE([AC_PATH_X])
- AC_REQUIRE([AC_PATH_XTRA])
- AC_REQUIRE([FPTOOLS_CHECK_LIBM])
-
-dnl Check for Mesa first if we were asked to.
- AC_ARG_ENABLE(Mesa,
-[ --enable-mesa
- Prefer Mesa over a vendor's native OpenGL library (default=no)
-],
- use_Mesa=$enableval,
- use_Mesa=no)
-
- if test x"$use_Mesa" = xyes; then
- GL_search_list="MesaGL GL opengl32"
- GLU_search_list="MesaGLU GLU glu32"
- GLX_search_list="MesaGLX GLX"
- else
- GL_search_list="GL opengl32 MesaGL"
- GLU_search_list="GLU glu32 MesaGLU"
- GLX_search_list="GLX MesaGLX"
- fi
-
- AC_LANG_SAVE
- AC_LANG_C
-
-dnl If we are running under X11 then add in the appropriate libraries.
- if test x"$no_x" != xyes; then
-dnl Add everything we need to compile and link X programs to GL_CFLAGS
-dnl and GL_X_LIBS/GLUT_X_LIBS.
- GL_CFLAGS="$CPPFLAGS $X_CFLAGS"
- GL_X_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBM"
- GLUT_X_LIBS="$X_LIBS $X_PRE_LIBS -lXmu -lXt -lXi -lXext -lX11 $X_EXTRA_LIBS $LIBM"
- fi
- GL_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$GL_CFLAGS"
-
- GL_save_LIBS="$LIBS"
- LIBS="$GL_X_LIBS"
-
- FPTOOLS_SEARCH_LIBS([#include <GL/gl.h>], glEnd, $GL_search_list, have_GL=yes, have_GL=no)
- FPTOOLS_SEARCH_LIBS([#include <GL/glu.h>], gluNewQuadric, $GLU_search_list, have_GLU=yes, have_GLU=no)
- FPTOOLS_SEARCH_LIBS([#include <GL/glx.h>], glXWaitX, $GLX_search_list, have_GLX=yes, have_GLX=no)
-
- if test -n "$LIBS"; then
- GL_LIBS="$LDFLAGS $LIBS"
- else
- GL_LIBS="$LDFLAGS"
- GL_CFLAGS=
- fi
-
- dnl Keep the GL/GLU/GLX libs, but expand the rest to what GLUT needs.
- dnl (Some systems, like OpenBSD, need the GL/GLU libs.)
- LIBS=`echo "$LIBS" | sed "s@$GL_X_LIBS@$GLUT_X_LIBS@"`
-
- FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop, glut32 glut, have_glut=yes, have_glut=no)
+dnl The quotes round "$(OSTYPE)" are essential, for the
+dnl Cygwin-sh case where OSTYPE is not set.
+case $HostPlatform in
+ i386-unknown-mingw32 | i386-unknown-cygwin32)
+ if test "${OSTYPE}" != "msys"
+ then
+ # convert $hardtop to a path that mingw will understand too
+ cyghardtop=${hardtop}
+ hardtop=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@/@g'`
+ hardtop_plat=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@\\\\\\\\@g'`
+ else
+dnl OK, so we're in the MSYS case. hardtop looks like /c/....
+dnl We want to make hardtop_plat into c:/...
+dnl Stop using [] for quotes temporarily, so we can use [] in the sed regexp
+changequote(, )dnl
+ hardtop_plat=`echo ${hardtop} | sed -e 's@^/\\([a-zA-Z]\\)/@\\1:/@g'`
+changequote([, ])dnl
+ fi
+ ;;
+ *)
+ hardtop_plat=${hardtop}
+ ;;
+esac
+AC_SUBST(hardtop)
+AC_SUBST(hardtop_plat)