| 178 | 
        kaklik | 
        1 | 
        dnl @synopsis MDL_HAVE_OPENGL | 
      
      
         | 
         | 
        2 | 
        dnl | 
      
      
         | 
         | 
        3 | 
        dnl Search for OpenGL. We search first for Mesa (a GPL'ed version of | 
      
      
         | 
         | 
        4 | 
        dnl Mesa) before a vendor's version of OpenGL, unless we were | 
      
      
         | 
         | 
        5 | 
        dnl specifically asked not to with `--with-Mesa=no' or | 
      
      
         | 
         | 
        6 | 
        dnl `--without-Mesa'. | 
      
      
         | 
         | 
        7 | 
        dnl | 
      
      
         | 
         | 
        8 | 
        dnl The four "standard" OpenGL libraries are searched for: "-lGL", | 
      
      
         | 
         | 
        9 | 
        dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be) | 
      
      
         | 
         | 
        10 | 
        dnl and "-lglut". | 
      
      
         | 
         | 
        11 | 
        dnl | 
      
      
         | 
         | 
        12 | 
        dnl All of the libraries that are found (since "-lglut" or "-lGLX" | 
      
      
         | 
         | 
        13 | 
        dnl might be missing) are added to the shell output variable "GL_LIBS", | 
      
      
         | 
         | 
        14 | 
        dnl along with any other libraries that are necessary to successfully | 
      
      
         | 
         | 
        15 | 
        dnl link an OpenGL application (e.g. the X11 libraries). Care has been | 
      
      
         | 
         | 
        16 | 
        dnl taken to make sure that all of the libraries in "GL_LIBS" are | 
      
      
         | 
         | 
        17 | 
        dnl listed in the proper order. | 
      
      
         | 
         | 
        18 | 
        dnl | 
      
      
         | 
         | 
        19 | 
        dnl Additionally, the shell output variable "GL_CFLAGS" is set to any | 
      
      
         | 
         | 
        20 | 
        dnl flags (e.g. "-I" flags) that are necessary to successfully compile | 
      
      
         | 
         | 
        21 | 
        dnl an OpenGL application. | 
      
      
         | 
         | 
        22 | 
        dnl | 
      
      
         | 
         | 
        23 | 
        dnl The following shell variable (which are not output variables) are | 
      
      
         | 
         | 
        24 | 
        dnl also set to either "yes" or "no" (depending on which libraries were | 
      
      
         | 
         | 
        25 | 
        dnl found) to help you determine exactly what was found. | 
      
      
         | 
         | 
        26 | 
        dnl | 
      
      
         | 
         | 
        27 | 
        dnl   have_GL | 
      
      
         | 
         | 
        28 | 
        dnl   have_GLU | 
      
      
         | 
         | 
        29 | 
        dnl   have_GLX | 
      
      
         | 
         | 
        30 | 
        dnl   have_glut | 
      
      
         | 
         | 
        31 | 
        dnl | 
      
      
         | 
         | 
        32 | 
        dnl A complete little toy "Automake `make distcheck'" package of how to | 
      
      
         | 
         | 
        33 | 
        dnl use this macro is available at: | 
      
      
         | 
         | 
        34 | 
        dnl | 
      
      
         | 
         | 
        35 | 
        dnl   ftp://ftp.slac.stanford.edu/users/langston/autoconf/ac_opengl-0.01.tar.gz | 
      
      
         | 
         | 
        36 | 
        dnl | 
      
      
         | 
         | 
        37 | 
        dnl Please note that as the ac_opengl macro and the toy example | 
      
      
         | 
         | 
        38 | 
        dnl evolves, the version number increases, so you may have to adjust | 
      
      
         | 
         | 
        39 | 
        dnl the above URL accordingly. | 
      
      
         | 
         | 
        40 | 
        dnl | 
      
      
         | 
         | 
        41 | 
        dnl minor bugfix by ahmet inan <auto@ainan.org> | 
      
      
         | 
         | 
        42 | 
        dnl | 
      
      
         | 
         | 
        43 | 
        dnl @category InstalledPackages | 
      
      
         | 
         | 
        44 | 
        dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU> | 
      
      
         | 
         | 
        45 | 
        dnl @version 2002-09-25 | 
      
      
         | 
         | 
        46 | 
        dnl @license GPLWithACException | 
      
      
         | 
         | 
        47 | 
          | 
      
      
         | 
         | 
        48 | 
        AC_DEFUN([MDL_HAVE_OPENGL], | 
      
      
         | 
         | 
        49 | 
        [ | 
      
      
         | 
         | 
        50 | 
          AC_REQUIRE([AC_PROG_CC]) | 
      
      
         | 
         | 
        51 | 
          AC_REQUIRE([AC_PATH_X]) | 
      
      
         | 
         | 
        52 | 
          AC_REQUIRE([AC_PATH_XTRA]) | 
      
      
         | 
         | 
        53 | 
          | 
      
      
         | 
         | 
        54 | 
          AC_CACHE_CHECK([for OpenGL], mdl_cv_have_OpenGL, | 
      
      
         | 
         | 
        55 | 
          [ | 
      
      
         | 
         | 
        56 | 
        dnl Check for Mesa first, unless we were asked not to. | 
      
      
         | 
         | 
        57 | 
            AC_ARG_WITH([--with-Mesa], | 
      
      
         | 
         | 
        58 | 
                           [Prefer the Mesa library over a vendors native OpenGL library (default=yes)], | 
      
      
         | 
         | 
        59 | 
                           with_Mesa_help_string) | 
      
      
         | 
         | 
        60 | 
            AC_ARG_ENABLE(Mesa, $with_Mesa_help_string, use_Mesa=$enableval, use_Mesa=yes) | 
      
      
         | 
         | 
        61 | 
          | 
      
      
         | 
         | 
        62 | 
            if test x"$use_Mesa" = xyes; then | 
      
      
         | 
         | 
        63 | 
               GL_search_list="MesaGL   GL" | 
      
      
         | 
         | 
        64 | 
              GLU_search_list="MesaGLU GLU" | 
      
      
         | 
         | 
        65 | 
              GLX_search_list="MesaGLX GLX" | 
      
      
         | 
         | 
        66 | 
            else | 
      
      
         | 
         | 
        67 | 
               GL_search_list="GL  MesaGL" | 
      
      
         | 
         | 
        68 | 
              GLU_search_list="GLU MesaGLU" | 
      
      
         | 
         | 
        69 | 
              GLX_search_list="GLX MesaGLX" | 
      
      
         | 
         | 
        70 | 
            fi | 
      
      
         | 
         | 
        71 | 
          | 
      
      
         | 
         | 
        72 | 
            AC_LANG_SAVE | 
      
      
         | 
         | 
        73 | 
            AC_LANG_C | 
      
      
         | 
         | 
        74 | 
          | 
      
      
         | 
         | 
        75 | 
        dnl If we are running under X11 then add in the appropriate libraries. | 
      
      
         | 
         | 
        76 | 
        if test x"$no_x" != xyes; then | 
      
      
         | 
         | 
        77 | 
        dnl Add everything we need to compile and link X programs to GL_X_CFLAGS | 
      
      
         | 
         | 
        78 | 
        dnl and GL_X_LIBS. | 
      
      
         | 
         | 
        79 | 
          GL_CFLAGS="$X_CFLAGS" | 
      
      
         | 
         | 
        80 | 
          GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS" | 
      
      
         | 
         | 
        81 | 
        fi | 
      
      
         | 
         | 
        82 | 
            GL_save_CPPFLAGS="$CPPFLAGS" | 
      
      
         | 
         | 
        83 | 
            CPPFLAGS="$GL_CFLAGS" | 
      
      
         | 
         | 
        84 | 
          | 
      
      
         | 
         | 
        85 | 
            GL_save_LIBS="$LIBS" | 
      
      
         | 
         | 
        86 | 
            LIBS="$GL_X_LIBS" | 
      
      
         | 
         | 
        87 | 
          | 
      
      
         | 
         | 
        88 | 
          | 
      
      
         | 
         | 
        89 | 
            # Save the "AC_MSG_RESULT file descriptor" to FD 8. | 
      
      
         | 
         | 
        90 | 
            exec 8>&AC_FD_MSG | 
      
      
         | 
         | 
        91 | 
          | 
      
      
         | 
         | 
        92 | 
            # Temporarily turn off AC_MSG_RESULT so that the user gets pretty | 
      
      
         | 
         | 
        93 | 
            # messages. | 
      
      
         | 
         | 
        94 | 
            exec AC_FD_MSG>/dev/null | 
      
      
         | 
         | 
        95 | 
          | 
      
      
         | 
         | 
        96 | 
            AC_SEARCH_LIBS(glAccum,          $GL_search_list, have_GL=yes,   have_GL=no) | 
      
      
         | 
         | 
        97 | 
            AC_SEARCH_LIBS(gluBeginCurve,   $GLU_search_list, have_GLU=yes,  have_GLU=no) | 
      
      
         | 
         | 
        98 | 
            AC_SEARCH_LIBS(glXChooseVisual, $GLX_search_list, have_GLX=yes,  have_GLX=no) | 
      
      
         | 
         | 
        99 | 
            AC_SEARCH_LIBS(glutInit,        glut,             have_glut=yes, have_glut=no) | 
      
      
         | 
         | 
        100 | 
          | 
      
      
         | 
         | 
        101 | 
          | 
      
      
         | 
         | 
        102 | 
          | 
      
      
         | 
         | 
        103 | 
            # Restore pretty messages. | 
      
      
         | 
         | 
        104 | 
            exec AC_FD_MSG>&8 | 
      
      
         | 
         | 
        105 | 
          | 
      
      
         | 
         | 
        106 | 
            if test -n "$LIBS"; then | 
      
      
         | 
         | 
        107 | 
              mdl_cv_have_OpenGL=yes | 
      
      
         | 
         | 
        108 | 
              GL_LIBS="$LIBS" | 
      
      
         | 
         | 
        109 | 
              AC_SUBST(GL_CFLAGS) | 
      
      
         | 
         | 
        110 | 
              AC_SUBST(GL_LIBS) | 
      
      
         | 
         | 
        111 | 
            else | 
      
      
         | 
         | 
        112 | 
              mdl_cv_have_OpenGL=no | 
      
      
         | 
         | 
        113 | 
              GL_CFLAGS= | 
      
      
         | 
         | 
        114 | 
            fi | 
      
      
         | 
         | 
        115 | 
          | 
      
      
         | 
         | 
        116 | 
        dnl Reset GL_X_LIBS regardless, since it was just a temporary variable | 
      
      
         | 
         | 
        117 | 
        dnl and we don't want to be global namespace polluters. | 
      
      
         | 
         | 
        118 | 
            GL_X_LIBS= | 
      
      
         | 
         | 
        119 | 
          | 
      
      
         | 
         | 
        120 | 
            LIBS="$GL_save_LIBS" | 
      
      
         | 
         | 
        121 | 
            CPPFLAGS="$GL_save_CPPFLAGS" | 
      
      
         | 
         | 
        122 | 
          | 
      
      
         | 
         | 
        123 | 
            AC_LANG_RESTORE | 
      
      
         | 
         | 
        124 | 
          | 
      
      
         | 
         | 
        125 | 
        dnl bugfix: dont forget to cache this variables, too | 
      
      
         | 
         | 
        126 | 
            mdl_cv_GL_CFLAGS="$GL_CFLAGS" | 
      
      
         | 
         | 
        127 | 
            mdl_cv_GL_LIBS="$GL_LIBS" | 
      
      
         | 
         | 
        128 | 
            mdl_cv_have_GL="$have_GL" | 
      
      
         | 
         | 
        129 | 
            mdl_cv_have_GLU="$have_GLU" | 
      
      
         | 
         | 
        130 | 
            mdl_cv_have_GLX="$have_GLX" | 
      
      
         | 
         | 
        131 | 
            mdl_cv_have_glut="$have_glut" | 
      
      
         | 
         | 
        132 | 
          ]) | 
      
      
         | 
         | 
        133 | 
          GL_CFLAGS="$mdl_cv_GL_CFLAGS" | 
      
      
         | 
         | 
        134 | 
          GL_LIBS="$mdl_cv_GL_LIBS" | 
      
      
         | 
         | 
        135 | 
          have_GL="$mdl_cv_have_GL" | 
      
      
         | 
         | 
        136 | 
          have_GLU="$mdl_cv_have_GLU" | 
      
      
         | 
         | 
        137 | 
          have_GLX="$mdl_cv_have_GLX" | 
      
      
         | 
         | 
        138 | 
          have_glut="$mdl_cv_have_glut" | 
      
      
         | 
         | 
        139 | 
        ]) | 
      
      
         | 
         | 
        140 | 
        dnl endof bugfix -ainan |