diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 965f15ccf..878d93a5a 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -27,7 +27,7 @@ uqm_requirements() # Libraries always used - use_library SDL 1.2.8 || exit 1 + have_library SDL 1.2.8 || have_library SDL2 || exit 1 use_library libpng || exit 1 case "$HOST_SYSTEM" in @@ -194,25 +194,40 @@ uqm_prepare_config() esac - CHOICE_graphics_OPTIONS="pure opengl" - CHOICE_graphics_TITLE="OpenGL graphics support" - CHOICE_graphics_OPTION_pure_TITLE="Don't include OpenGL graphics support" + CHOICE_graphics_OPTIONS="pure opengl sdl2" + CHOICE_graphics_TITLE="Graphics Engine" + CHOICE_graphics_OPTION_pure_TITLE="SDL1 without OpenGL graphics support" CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action' graphics_pure_action() { - CFLAGS="$CFLAGS -DGFXMODULE_SDL" + CFLAGS="$CFLAGS -DGFXMODULE_SDL -DSDL_DIR=SDL" GFXMODULE=sdl HAVE_OPENGL=0 + use_library SDL 1.2.8 } - CHOICE_graphics_OPTION_opengl_TITLE="Include OpenGL graphics support" + CHOICE_graphics_OPTION_opengl_TITLE="SDL1 with OpenGL graphics support" CHOICE_graphics_OPTION_opengl_ACTION='graphics_opengl_action' CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl" graphics_opengl_action() { - CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL" + CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL -DSDL_DIR=SDL" GFXMODULE=sdl HAVE_OPENGL=1 - use_library opengl + use_library SDL 1.2.8 && use_library opengl } + CHOICE_graphics_OPTION_sdl2_TITLE="SDL2 with modern graphics support" + CHOICE_graphics_OPTION_sdl2_ACTION='graphics_sdl2_action' + graphics_sdl2_action() { + CFLAGS="$CFLAGS -DGFXMODULE_SDL -DSDL_DIR=SDL2" + GFXMODULE=sdl + HAVE_OPENGL=0 + use_library SDL2 + } + # TODO: Once SDL2 has parity to SDL1, make it the default if + # available. + # if have_library SDL2; then + # CHOICE_graphics_DEFAULT=sdl2 + # else CHOICE_graphics_DEFAULT=opengl + # fi CHOICE_sound_OPTIONS="mixsdl openal" CHOICE_sound_TITLE="Sound backend" diff --git a/sc2/build/unix/config_proginfo_host b/sc2/build/unix/config_proginfo_host index 409b9b17c..d05863eb7 100644 --- a/sc2/build/unix/config_proginfo_host +++ b/sc2/build/unix/config_proginfo_host @@ -75,6 +75,21 @@ case "$HOST_SYSTEM" in esac +### SDL2 ### +LIB_SDL2_NAME="Simple DirectMedia Layer version 2.x" +case "$HOST_SYSTEM" in + WINSCW|GCCE|ARMV5) + LIB_SDL2_DETECT="false" + ;; + *) + LIB_SDL2_DETECT="have_command sdl2-config" + LIB_SDL2_CFLAGS='$(sdl2-config --cflags)' + LIB_SDL2_LDFLAGS='$(sdl2-config --libs)' + LIB_SDL2_VERSION='$(sdl2-config --version)' + ;; +esac + + ### libpng ### LIB_libpng_NAME="libpng" # libpng generally integrates with pkg-config, but that also generally diff --git a/sc2/src/port.h b/sc2/src/port.h index 51fc606eb..8e3aa6386 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -461,16 +461,8 @@ typedef unsigned int wint_t; #endif /* defined (PORT_WANT_ERRNO) */ // Use SDL_INCLUDE to portably include the SDL files from the right location. -// TODO: Where the SDL and SDL_image headers are located could be detected -// from the build script. +// The SDL_DIR definition is provided by the build configuration. #ifdef __APPLE__ -# define SDL_DIR SDL -#else - // SDL_image.h directly under the include dir. -# undef SDL_DIR -#endif - -#ifdef SDL_DIR # define SDL_INCLUDE(file) #else # define SDL_INCLUDE(file)