acinclude/ax_check_compiler_flags.m4
author Sam Lantinga
Tue, 10 Jan 2017 08:54:33 -0800
changeset 10806 36f40b8cc979
parent 5029 5d7d48157be7
permissions -rw-r--r--
Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11

Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
say to use the OpenGL ES driver & EGL rather than the Open GL
driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
driver or the real OpenGL ES driver to take into account the
hint, the requested and supported ES version and whether ES 1.X
is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
     1 # ===========================================================================
     2 #  http://www.gnu.org/software/autoconf-archive/ax_check_compiler_flags.html
     3 # ===========================================================================
     4 #
     5 # SYNOPSIS
     6 #
     7 #   AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
     8 #
     9 # DESCRIPTION
    10 #
    11 #   Check whether the given compiler FLAGS work with the current language's
    12 #   compiler, or whether they give an error. (Warnings, however, are
    13 #   ignored.)
    14 #
    15 #   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
    16 #   success/failure.
    17 #
    18 # LICENSE
    19 #
    20 #   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
    21 #   Copyright (c) 2009 Matteo Frigo
    22 #
    23 #   This program is free software: you can redistribute it and/or modify it
    24 #   under the terms of the GNU General Public License as published by the
    25 #   Free Software Foundation, either version 3 of the License, or (at your
    26 #   option) any later version.
    27 #
    28 #   This program is distributed in the hope that it will be useful, but
    29 #   WITHOUT ANY WARRANTY; without even the implied warranty of
    30 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
    31 #   Public License for more details.
    32 #
    33 #   You should have received a copy of the GNU General Public License along
    34 #   with this program. If not, see <http://www.gnu.org/licenses/>.
    35 #
    36 #   As a special exception, the respective Autoconf Macro's copyright owner
    37 #   gives unlimited permission to copy, distribute and modify the configure
    38 #   scripts that are the output of Autoconf when processing the Macro. You
    39 #   need not follow the terms of the GNU General Public License when using
    40 #   or distributing such scripts, even though portions of the text of the
    41 #   Macro appear in them. The GNU General Public License (GPL) does govern
    42 #   all other use of the material that constitutes the Autoconf Macro.
    43 #
    44 #   This special exception to the GPL applies to versions of the Autoconf
    45 #   Macro released by the Autoconf Archive. When you make and distribute a
    46 #   modified version of the Autoconf Macro, you may extend this special
    47 #   exception to the GPL to apply to your modified version as well.
    48 
    49 #serial 9
    50 
    51 AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
    52 [AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
    53 AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
    54 dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
    55 AS_LITERAL_IF([$1],
    56   [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [
    57       ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
    58       _AC_LANG_PREFIX[]FLAGS="$1"
    59       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
    60         AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
    61         AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
    62       _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
    63   [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
    64    _AC_LANG_PREFIX[]FLAGS="$1"
    65    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
    66      eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
    67      eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
    68    _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
    69 eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])
    70 AC_MSG_RESULT($ax_check_compiler_flags)
    71 if test "x$ax_check_compiler_flags" = xyes; then
    72 	m4_default([$2], :)
    73 else
    74 	m4_default([$3], :)
    75 fi
    76 ])dnl AX_CHECK_COMPILER_FLAGS