Files
genode-world/lib/mk/sdl.mk
Norman Feske c070e64bd4 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
2019-05-14 11:45:43 +02:00

101 lines
2.2 KiB
Makefile

SDL_PORT_DIR := $(call select_from_ports,sdl)
SDL_DIR := $(SDL_PORT_DIR)/src/lib/sdl
# build shared object
SHARED_LIB = yes
# use default warning level for 3rd-party code
CC_WARN =
INC_DIR += $(SDL_PORT_DIR)/include
INC_DIR += $(SDL_PORT_DIR)/include/SDL
#
# In case we use the depot add the location
# to the global include path.
#
ifeq ($(CONTRIB),)
REP_INC_DIR += include/SDL
endif
# backends
SRC_CC = video/SDL_genode_fb_video.cc \
video/SDL_genode_fb_events.cc \
audio/SDL_genodeaudio.cc \
loadso/SDL_loadso.cc
INC_DIR += $(REP_DIR)/include/SDL \
$(REP_DIR)/src/lib/sdl \
$(REP_DIR)/src/lib/sdl/thread \
$(REP_DIR)/src/lib/sdl/video
# main files
SRC_C = SDL.c \
SDL_error.c \
SDL_fatal.c
INC_DIR += $(REP_DIR)/src/lib/sdl
# stdlib files
SRC_C += stdlib/SDL_getenv.c \
stdlib/SDL_string.h
# thread subsystem
SRC_C += thread/SDL_thread.c \
thread/pthread/SDL_systhread.c \
thread/generic/SDL_syscond.c \
thread/generic/SDL_sysmutex.c \
thread/pthread/SDL_syssem.c
INC_DIR += $(SDL_DIR)/src/thread
# cpuinfo subsystem
SRC_C += cpuinfo/SDL_cpuinfo.c
# timer subsystem
SRC_C += timer/SDL_timer.c \
timer/unix/SDL_systimer.c
INC_DIR += $(SDL_DIR)/src/timer
# video subsystem
SRC_C += $(addprefix video/,$(notdir $(wildcard $(SDL_DIR)/src/video/*.c)))
INC_DIR += $(SDL_DIR)/src/video
# event subsystem
SRC_C += $(addprefix events/,$(notdir $(wildcard $(SDL_DIR)/src/events/*.c)))
INC_DIR += $(SDL_DIR)/src/events
# audio subsystem
SRC_C += $(addprefix audio/,$(notdir $(wildcard $(SDL_DIR)/src/audio/*.c)))
INC_DIR += $(SDL_DIR)/src/audio
# file I/O subsystem
SRC_C += file/SDL_rwops.c
# joystick subsystem
SRC_C += joystick/SDL_joystick.c \
joystick/dummy/SDL_sysjoystick.c
INC_DIR += $(SDL_DIR)/src/joystick
# cdrom subsystem
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
# backend path
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 $@