libsdl: config tweaks, remove sdlmain lib

This patch contains changes to the libSDL port that were needed to build
the Hatari emulator using cmake.

- Since SDL programs cannot use the posix library (because sdl's init
  function needs a way to get hold of the Genode env), the sdl_main
  library must be used instead of the posix library. The sdl_main
  code implements the Libc::Component::construct function for the
  final binary. However, 3rd-party build systems are not aware of this
  Genode-specific peculiarity and thereby create binaries that leave
  libsdl uninitialized. This patch adds the sdl_main to libsdl by
  default and thereby eliminates the need for specifying the extra
  sdl_main library. Customizing the Libc::Component::construct is
  still possible by overriding the library-provided implementation
  in the main program.

- A few missing config definitions are added to compile Hatari
  successfully.

- Avoid reliance on the include/SDL convention in SDL_config.h

- Cmake relies on the upper-case naming of the library with no way
  to tweak this convention. So we install an symlink named `SDL.lib.so`
  when installing the library into the <build-dir>/bin/ directory.

Fixes #161
This commit is contained in:
Norman Feske
2019-05-14 10:44:33 +02:00
parent 5c353771ba
commit c070e64bd4
21 changed files with 31 additions and 30 deletions

View File

@@ -31,7 +31,7 @@
#ifndef _SDL_config_h
#define _SDL_config_h
#include <SDL/SDL_platform.h>
#include <SDL_platform.h>
#include "SDL_config_genode.h"
#endif /* _SDL_config_h */

View File

@@ -61,6 +61,8 @@
#define SDL_VIDEO_OPENGL 1
#define SDL_HAS_64BIT_TYPE 1
/* #define HAVE_MREMAP 0 */
#define HAVE_MALLOC
#define HAVE_CALLOC
@@ -77,7 +79,9 @@
#define HAVE_SNPRINTF
#define HAVE_VSNPRINTF
#define HAVE_STDIO_H 1
#define HAVE_STDIO_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_MATH_H 1
/* #define SDL_malloc malloc */
/* #define SDL_calloc calloc */

View File

@@ -81,6 +81,8 @@ SRC_C += cdrom/SDL_cdrom.c \
cdrom/dummy/SDL_syscdrom.c
INC_DIR += $(SDL_DIR)/src/cdrom
SRC_CC += sdl_main.cc
# we need libc
LIBS = libc mesa_api
@@ -90,3 +92,9 @@ vpath % $(REP_DIR)/src/lib/sdl
vpath % $(SDL_DIR)/src
CC_CXX_WARN_STRICT =
$(INSTALL_DIR)/sdl.lib.so: $(INSTALL_DIR)/SDL.lib.so
$(INSTALL_DIR)/SDL.lib.so:
$(VERBOSE)ln -sf sdl.lib.so $@

View File

@@ -1,7 +0,0 @@
SRC_CC = sdl_main.cc
LIBS += libc
vpath sdl_main.cc $(REP_DIR)/src/lib/sdl
CC_CXX_WARN_STRICT =

View File

@@ -1,3 +1,4 @@
_ZN4Libc9Component9constructERNS_3EnvE T
SDL_AddTimer T
SDL_AllocBlitMap T
SDL_AllocFormat T

View File

@@ -1,9 +1,8 @@
MIRROR_FROM_REP_DIR := lib/symbols/sdl lib/import/import-sdl.mk \
lib/mk/sdlmain.mk
MIRROR_FROM_LIBPORTS := lib/mk/mesa_api.mk
content: $(MIRROR_FROM_REP_DIR) $(MIRROR_FROM_LIBPORTS) src/lib/sdl include LICENSE
content: $(MIRROR_FROM_REP_DIR) $(MIRROR_FROM_LIBPORTS) include LICENSE
$(MIRROR_FROM_REP_DIR):
$(mirror_from_rep_dir)
@@ -25,9 +24,5 @@ include:
cp -r $(MESA_PORT_DIR)/include/* $@/
cp -r $(GENODE_DIR)/repos/libports/include/EGL $@/
src/lib/sdl:
mkdir -p $@
cp -r $(REP_DIR)/src/lib/sdl/sdl_main.cc $@/
LICENSE:
cp $(SDL_PORT_DIR)/src/lib/sdl/COPYING $@

View File

@@ -1 +1 @@
2018-03-18 2cdaa5c32a93a5acf0ee7159f96e9f01d67ab8d2
2019-05-14 cb3175a6545ea045864baa9783f4ac54a3206826

View File

@@ -1 +1 @@
2019-01-02 155b546298117fca760a633abcd79080e124df6c
2019-05-14 598e91be62c73d18bad160f5f2438a855c4f0ed1

View File

@@ -30,7 +30,7 @@ INC_DIR += $(PRG_DIR) \
$(ABUSE_SRC)/net \
$(ABUSE_SRC)/ui
LIBS += base abuse_imlib libc libm stdcxx sdlmain sdl sdl_image sdl_mixer sdl_net
LIBS += base abuse_imlib libc libm stdcxx sdl sdl_image sdl_mixer sdl_net
CC_WARN += \
-Wno-unused-but-set-variable \

View File

@@ -18,7 +18,7 @@ INC_DIR += $(ATARI800_DIR)/src $(PRG_DIR)
CC_WARN := -Wall -Wno-unused-but-set-variable -Wno-logical-not-parentheses
LIBS += sdl sdlmain zlib libc libpng
LIBS += sdl zlib libc libpng
$(TARGET): atari800_rom.tar
atari800_rom.tar:

View File

@@ -3,7 +3,7 @@ include $(REP_DIR)/lib/import/import-av.inc
TARGET = avplay
SRC_C = avplay.c cmdutils.c libc_dummies.c
LIBS += avfilter avformat avcodec avutil avresample swscale
LIBS += base sdl sdlmain libc libm
LIBS += base sdl libc libm
CC_WARN += -Wno-parentheses -Wno-switch -Wno-uninitialized \
-Wno-format-zero-length -Wno-pointer-sign

View File

@@ -83,6 +83,6 @@ INC_DIR += $(CHOCOLATE_DOOM_DIR)/src
INC_DIR += $(CHOCOLATE_DOOM_DIR)/src/$(GAME)
INC_DIR += $(CHOCOLATE_DOOM_DIR)/textscreen
LIBS := base sdl sdlmain libc libm sdl_mixer sdl_net
LIBS := base sdl libc libm sdl_mixer sdl_net
# vi:set ft=make :

View File

@@ -55,6 +55,6 @@ CC_WARN += -Wno-unused-variable -Wno-unused-function -Wno-switch -Wno-unused-val
-Wno-sign-compare -Wno-narrowing -Wno-missing-braces -Wno-array-bounds \
-Wno-parentheses
LIBS += libpng libc sdl sdlmain sdl_net stdcxx zlib
LIBS += libpng libc sdl sdl_net stdcxx zlib
CC_CXX_WARN_STRICT =

View File

@@ -9,7 +9,7 @@ INC_DIR += $(GRAFX2_DIR)
CC_OPT += -DGENODE -DNOTTF=1
LIBS += libc libpng sdlmain sdl sdl_image libm zlib base
LIBS += libc libpng sdl sdl_image libm zlib base
$(TARGET): grafx2_data.tar
grafx2_data.tar:

View File

@@ -1,5 +1,5 @@
TARGET = ltris
LIBS = libc libm stdcxx sdlmain sdl sdl_mixer
LIBS = libc libm stdcxx sdl sdl_mixer
LTRIS_DIR := $(call select_from_ports,ltris)/src/app/ltris

View File

@@ -55,7 +55,7 @@ vpath getenv.cc $(PRG_DIR)
INC_DIR += $(NUMPTY_DIR) $(NUMPTY_DIR)/Box2D/Include
LIBS += base stdcxx libc libm
LIBS += sdlmain sdl sdl_image sdl_ttf zlib
LIBS += sdl sdl_image sdl_ttf zlib
CC_OPT_Canvas := -DGENODE

View File

@@ -7,7 +7,7 @@ SRC_C := $(notdir $(wildcard $(OPENTYRIAN_SRC)/*.c))
vpath %.c $(OPENTYRIAN_SRC)
LIBS += libc libm sdlmain sdl sdl_net base
LIBS += libc libm sdl sdl_net base
CC_OPT += -std=c99 -DTARGET_UNIX

View File

@@ -10,7 +10,7 @@ vpath %.cpp $(SUPERTUX_DIR)/src
INC_DIR += $(SUPERTUX_DIR)/src
LIBS += stdcxx
LIBS += sdl sdlmain sdl_image sdl_mixer zlib
LIBS += sdl sdl_image sdl_mixer zlib
$(TARGET): supertux_data.tar
supertux_data.tar:

View File

@@ -2,7 +2,7 @@ TARGET := tuxmath
TUXMATH_DIR := $(call select_from_ports,tuxmath)/src/app/tuxmath
LIBS += libc libm sdlmain sdl sdl_image sdl_mixer sdl_ttf sdl_net tuxmath_t4k
LIBS += libc libm sdl sdl_image sdl_mixer sdl_ttf sdl_net tuxmath_t4k
INC_DIR += $(REP_DIR)/src/app/tuxmath \
$(TUXMATH_DIR)/t4k/src

View File

@@ -118,7 +118,7 @@ CC_OPT += -DNO_ALSA_AUDIO -DNO_OSS_AUDIO -DNO_SUN_AUDIO
CC_OPT += -DDEMOBUILD
LIBS = libc libm sdl sdlmain sdl_mixer
LIBS = libc libm sdl sdl_mixer
vpath % $(UHEXEN2_DIR)/common
vpath % $(UHEXEN2_DIR)/engine/hexen2

View File

@@ -1,5 +1,5 @@
TARGET := test-sdl
LIBS := libc sdl sdlmain
LIBS := libc sdl
SRC_CC := main.cc
CC_CXX_WARN_STRICT =