-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)
-
- if test -n "$LIBS"; then
- GLUT_LIBS="$LDFLAGS $LIBS"
- fi
-
- AC_CACHE_CHECK([OpenGL flags], mdl_cv_gl_cflags, [mdl_cv_gl_cflags="$GL_CFLAGS"])
- GL_CFLAGS="$mdl_cv_gl_cflags"
- AC_SUBST(GL_CFLAGS)
- AC_CACHE_CHECK([OpenGL libs], mdl_cv_gl_libs, [mdl_cv_gl_libs="$GL_LIBS"])
- GL_LIBS="$mdl_cv_gl_libs"
- AC_SUBST(GL_LIBS)
- AC_CACHE_CHECK([GLUT libs], mdl_cv_glut_libs, [mdl_cv_glut_libs="$GLUT_LIBS"])
- GLUT_LIBS="$mdl_cv_glut_libs"
- AC_SUBST(GLUT_LIBS)
-
-dnl Reset GL_X_LIBS/GLUT_X_LIBS regardless, since they were just temporary variables
-dnl and we don't want to be global namespace polluters.
- GL_X_LIBS=
- GLUT_X_LIBS=
-
- LIBS="$GL_save_LIBS"
- CPPFLAGS="$GL_save_CPPFLAGS"
-
- AC_LANG_RESTORE
-])
+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)