From 7552d352b6355a77ea2b6b346172f347427ed771 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 29 Mar 2013 15:42:19 +0100 Subject: [PATCH] libports/SDL: Add ttf, image, mixer, loadso --- libports/lib/mk/sdl.mk | 106 +++++------------- libports/lib/mk/sdl_image.mk | 12 ++ libports/lib/mk/sdl_mixer.mk | 19 ++++ libports/lib/mk/sdl_ttf.mk | 8 ++ libports/ports/sdl.inc | 2 + libports/ports/sdl.mk | 29 +++-- libports/ports/sdl_image.inc | 2 + libports/ports/sdl_image.mk | 40 +++++++ libports/ports/sdl_mixer.inc | 2 + libports/ports/sdl_mixer.mk | 38 +++++++ libports/ports/sdl_ttf.inc | 2 + libports/ports/sdl_ttf.mk | 40 +++++++ libports/src/lib/sdl/SDL_config_genode.h | 2 + libports/src/lib/sdl/loadso/SDL_loadso.cc | 38 +++++++ libports/src/lib/sdl/timer/SDL_systimer.cc | 7 +- .../src/test/libports/sdl_image/target.mk | 5 + .../src/test/libports/sdl_mixer/target.mk | 5 + libports/src/test/libports/sdl_ttf/target.mk | 5 + 18 files changed, 269 insertions(+), 93 deletions(-) create mode 100644 libports/lib/mk/sdl_image.mk create mode 100644 libports/lib/mk/sdl_mixer.mk create mode 100644 libports/lib/mk/sdl_ttf.mk create mode 100644 libports/ports/sdl.inc create mode 100644 libports/ports/sdl_image.inc create mode 100644 libports/ports/sdl_image.mk create mode 100644 libports/ports/sdl_mixer.inc create mode 100644 libports/ports/sdl_mixer.mk create mode 100644 libports/ports/sdl_ttf.inc create mode 100644 libports/ports/sdl_ttf.mk create mode 100644 libports/src/lib/sdl/loadso/SDL_loadso.cc create mode 100644 libports/src/test/libports/sdl_image/target.mk create mode 100644 libports/src/test/libports/sdl_mixer/target.mk create mode 100644 libports/src/test/libports/sdl_ttf/target.mk diff --git a/libports/lib/mk/sdl.mk b/libports/lib/mk/sdl.mk index a10091381..9b8f97c01 100644 --- a/libports/lib/mk/sdl.mk +++ b/libports/lib/mk/sdl.mk @@ -1,18 +1,19 @@ -# -# SDL library -# +include $(REP_DIR)/ports/sdl.inc -SDL = SDL-1.2.13 SDL_DIR = $(REP_DIR)/contrib/$(SDL) # build shared object SHARED_LIB = yes +# use default warning level for 3rd-party code +CC_WARN = + # backends -SRC_CC = SDL_genode_fb_video.cc \ - SDL_genode_fb_events.cc \ - SDL_genodeaudio.cc \ - SDL_systimer.cc +SRC_CC = video/SDL_genode_fb_video.cc \ + video/SDL_genode_fb_events.cc \ + audio/SDL_genodeaudio.cc \ + timer/SDL_systimer.cc \ + loadso/SDL_loadso.cc INC_DIR += $(REP_DIR)/include/SDL \ $(REP_DIR)/src/lib/sdl \ @@ -27,101 +28,48 @@ SRC_C = SDL.c \ INC_DIR += $(REP_DIR)/src/lib/sdl # stdlib files -SRC_C += SDL_getenv.c \ - SDL_string.h +SRC_C += stdlib/SDL_getenv.c \ + stdlib/SDL_string.h # thread subsystem -SRC_C += SDL_thread.c \ - SDL_systhread.c \ - SDL_syscond.c \ - SDL_sysmutex.c \ - SDL_syssem.c +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 += SDL_cpuinfo.c +SRC_C += cpuinfo/SDL_cpuinfo.c # timer subsystem -SRC_C += SDL_timer.c +SRC_C += timer/SDL_timer.c INC_DIR += $(SDL_DIR)/src/timer # video subsystem -SRC_C += SDL_blit_0.c \ - SDL_blit.c \ - SDL_cursor.c \ - SDL_RLEaccel.c \ - SDL_video.c \ - SDL_yuv_sw.c \ - SDL_blit_1.c \ - SDL_blit_N.c \ - SDL_gamma.c \ - SDL_stretch.c \ - SDL_yuv.c \ - SDL_blit_A.c \ - SDL_bmp.c \ - SDL_pixels.c \ - SDL_surface.c \ - SDL_yuv_mmx.c +SRC_C += $(addprefix video/,$(notdir $(wildcard $(SDL_DIR)/src/video/*.c))) INC_DIR += $(SDL_DIR)/src/video # event subsystem -SRC_C += SDL_events.c \ - SDL_keyboard.c \ - SDL_mouse.c \ - SDL_resize.c \ - SDL_active.c \ - SDL_quit.c +SRC_C += $(addprefix events/,$(notdir $(wildcard $(SDL_DIR)/src/events/*.c))) INC_DIR += $(SDL_DIR)/src/events # audio subsystem -SRC_C += SDL_audio.c \ - SDL_audiocvt.c \ - SDL_audiodev.c \ - SDL_mixer.c \ - SDL_mixer_m68k.c \ - SDL_mixer_MMX.c \ - SDL_mixer_MMX_VC.c \ - SDL_wave.c - +SRC_C += $(addprefix audio/,$(notdir $(wildcard $(SDL_DIR)/src/audio/*.c))) INC_DIR += $(SDL_DIR)/src/audio # file I/O subsystem -SRC_C += SDL_rwops.c +SRC_C += file/SDL_rwops.c # joystick subsystem -SRC_C += SDL_joystick.c \ - SDL_sysjoystick.c +SRC_C += joystick/SDL_joystick.c \ + joystick/dummy/SDL_sysjoystick.c INC_DIR += $(SDL_DIR)/src/joystick # we need libc LIBS = libc pthread -# dim build noise for contrib code -CC_OPT_SDL_RLEaccel += -Wno-unused-but-set-variable -CC_OPT_SDL_bmp += -Wno-unused-but-set-variable -CC_OPT_SDL_stretch += -Wno-unused-but-set-variable -CC_OPT_SDL_wave += -Wno-unused-but-set-variable +# backend path +vpath % $(REP_DIR)/src/lib/sdl -# backend pathes -vpath % $(REP_DIR)/src/lib/sdl -vpath % $(REP_DIR)/src/lib/sdl/audio -vpath % $(REP_DIR)/src/lib/sdl/timer -vpath % $(REP_DIR)/src/lib/sdl/video - -# contribution pathes -vpath SDL_syscond.c $(SDL_DIR)/src/thread/generic -vpath SDL_sysmutex.c $(SDL_DIR)/src/thread/generic - -vpath %.c $(SDL_DIR)/src -vpath %.c $(SDL_DIR)/src/stdlib -vpath %.c $(SDL_DIR)/src/video -vpath %.c $(SDL_DIR)/src/video/dummy -vpath %.c $(SDL_DIR)/src/audio -vpath %.c $(SDL_DIR)/src/thread -vpath %.c $(SDL_DIR)/src/thread/pthread -vpath %.c $(SDL_DIR)/src/timer -vpath %.c $(SDL_DIR)/src/events -vpath %.c $(SDL_DIR)/src/cpuinfo -vpath %.c $(SDL_DIR)/src/file -vpath %.c $(SDL_DIR)/src/joystick -vpath %.c $(SDL_DIR)/src/joystick/dummy +vpath % $(SDL_DIR)/src diff --git a/libports/lib/mk/sdl_image.mk b/libports/lib/mk/sdl_image.mk new file mode 100644 index 000000000..5b1fcea66 --- /dev/null +++ b/libports/lib/mk/sdl_image.mk @@ -0,0 +1,12 @@ +include $(REP_DIR)/ports/sdl_image.inc + +SRC_C = $(notdir $(wildcard $(REP_DIR)/contrib/$(SDL_IMAGE)/IMG*.c)) +LIBS += libc libm sdl jpeg libpng zlib + +SUPPORTED_FORMATS = PNG JPG TGA PNM + +CC_OPT += $(addprefix -DLOAD_,$(SUPPORTED_FORMATS)) + +vpath %.c $(REP_DIR)/contrib/$(SDL_IMAGE) + +SHARED_LIB = yes diff --git a/libports/lib/mk/sdl_mixer.mk b/libports/lib/mk/sdl_mixer.mk new file mode 100644 index 000000000..d2a2150a8 --- /dev/null +++ b/libports/lib/mk/sdl_mixer.mk @@ -0,0 +1,19 @@ +include $(REP_DIR)/ports/sdl_mixer.inc + +# exclude example programs +FILTER_OUT = playmus.c playwave.c + +ALL_SDL_MIXER_SRC_C = $(notdir $(wildcard $(REP_DIR)/contrib/$(SDL_MIXER)/*.c)) + +SRC_C = $(filter-out $(FILTER_OUT), $(ALL_SDL_MIXER_SRC_C)) + +LIBS += libc libm sdl + +# suppress warnings of 3rd-party code +CC_OPT_music = -Wno-unused-label -Wno-unused-function +CC_OPT_load_aiff = -Wno-unused-but-set-variable +CC_OPT_wavestream = -Wno-unused-but-set-variable + +vpath %.c $(REP_DIR)/contrib/$(SDL_MIXER) + +SHARED_LIB = yes diff --git a/libports/lib/mk/sdl_ttf.mk b/libports/lib/mk/sdl_ttf.mk new file mode 100644 index 000000000..1f5a2f891 --- /dev/null +++ b/libports/lib/mk/sdl_ttf.mk @@ -0,0 +1,8 @@ +include $(REP_DIR)/ports/sdl_ttf.inc + +SRC_C = SDL_ttf.c +LIBS += libc libm freetype sdl + +vpath %.c $(REP_DIR)/contrib/$(SDL_TTF) + +SHARED_LIB = yes diff --git a/libports/ports/sdl.inc b/libports/ports/sdl.inc new file mode 100644 index 000000000..41673a24c --- /dev/null +++ b/libports/ports/sdl.inc @@ -0,0 +1,2 @@ +SDL_VERSION = 1.2.13 +SDL = SDL-$(SDL_VERSION) diff --git a/libports/ports/sdl.mk b/libports/ports/sdl.mk index 92f903e17..ab7df4bf4 100644 --- a/libports/ports/sdl.mk +++ b/libports/ports/sdl.mk @@ -1,17 +1,17 @@ -SDL_VERSION = 1.2.13 -SDL = SDL-$(SDL_VERSION) -SDL_TGZ = $(SDL).tar.gz -SDL_URL = http://www.libsdl.org/release/$(SDL_TGZ) +include ports/sdl.inc + +SDL_TGZ = $(SDL).tar.gz +SDL_URL = http://www.libsdl.org/release/$(SDL_TGZ) # # Interface to top-level prepare Makefile # -# Register SDL port as lower case to be consitent with the +# Register SDL port as lower case to be consistent with the # other libraries. # PORTS += sdl-$(SDL_VERSION) -prepare-sdl: $(CONTRIB_DIR)/$(SDL) include/SDL +prepare-sdl: $(CONTRIB_DIR)/$(SDL) include/SDL/SDL_platform.h $(CONTRIB_DIR)/$(SDL): clean-sdl @@ -30,13 +30,18 @@ $(CONTRIB_DIR)/$(SDL): $(DOWNLOAD_DIR)/$(SDL_TGZ) # # Install SDL headers # -include/SDL: - $(VERBOSE)mkdir -p $@ - $(VERBOSE)for i in `find $(CONTRIB_DIR)/$(SDL)/include -name *.h`; do \ +# Use 'SDL_platform.h' as representative of the header files to be installed. +# +include/SDL/SDL_platform.h: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)for i in `find $(CONTRIB_DIR)/$(SDL)/include -name "*.h"`; do \ ln -fs ../../$$i include/SDL/; done - $(VERBOSE)ln -fs ../../src/lib/sdl/SDL_config.h $@ - $(VERBOSE)ln -fs ../../src/lib/sdl/SDL_config_genode.h $@ + $(VERBOSE)ln -fs ../../src/lib/sdl/SDL_config.h $(dir $@) + $(VERBOSE)ln -fs ../../src/lib/sdl/SDL_config_genode.h $(dir $@) clean-sdl: - $(VERBOSE)rm -rf include/SDL + $(VERBOSE)for i in `find $(CONTRIB_DIR)/$(SDL)/include -name "*.h"`; do \ + rm -f include/SDL/`basename $$i`; done + $(VERBOSE)rm -f $(addprefix include/SDL/,SDL_config_genode.h SDL_config.h) + $(VERBOSE)rmdir include/SDL 2>/dev/null || true $(VERBOSE)rm -rf $(CONTRIB_DIR)/$(SDL) diff --git a/libports/ports/sdl_image.inc b/libports/ports/sdl_image.inc new file mode 100644 index 000000000..de3fc61d2 --- /dev/null +++ b/libports/ports/sdl_image.inc @@ -0,0 +1,2 @@ +SDL_IMAGE_VERSION = 1.2.12 +SDL_IMAGE = SDL_image-$(SDL_IMAGE_VERSION) diff --git a/libports/ports/sdl_image.mk b/libports/ports/sdl_image.mk new file mode 100644 index 000000000..d4df62369 --- /dev/null +++ b/libports/ports/sdl_image.mk @@ -0,0 +1,40 @@ +include ports/sdl_image.inc + +SDL_IMAGE_TGZ = $(SDL_IMAGE).tar.gz +SDL_IMAGE_URL = http://www.libsdl.org/projects/SDL_image/release/$(SDL_IMAGE_TGZ) + +# +# Interface to top-level prepare Makefile +# +# Register SDL_image port as lower case to be consistent with the +# other libraries. +# +PORTS += sdl_image-$(SDL_IMAGE_VERSION) + +prepare-sdl_image: $(CONTRIB_DIR)/$(SDL_IMAGE) include/SDL/SDL_image.h + +$(CONTRIB_DIR)/$(SDL_IMAGE): clean-sdl_image + +# +# Port-specific local rules +# +$(DOWNLOAD_DIR)/$(SDL_IMAGE_TGZ): + $(VERBOSE)wget -c -P $(DOWNLOAD_DIR) $(SDL_IMAGE_URL) && touch $@ + +$(CONTRIB_DIR)/$(SDL_IMAGE): $(DOWNLOAD_DIR)/$(SDL_IMAGE_TGZ) + $(VERBOSE)tar xfz $< \ + --exclude Xcode --exclude VisualC --exclude Xcode-iOS \ + --exclude VisualCE --exclude Watcom-OS2.zip \ + -C $(CONTRIB_DIR) && touch $@ + +# +# Install SDL_image headers +# +include/SDL/SDL_image.h: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -fs ../../$(CONTRIB_DIR)/$(SDL_IMAGE)/SDL_image.h include/SDL/ + +clean-sdl_image: + $(VERBOSE)rm -rf include/SDL/SDL_image.h + $(VERBOSE)rmdir include/SDL 2>/dev/null || true + $(VERBOSE)rm -rf $(CONTRIB_DIR)/$(SDL_IMAGE) diff --git a/libports/ports/sdl_mixer.inc b/libports/ports/sdl_mixer.inc new file mode 100644 index 000000000..9a3e81d55 --- /dev/null +++ b/libports/ports/sdl_mixer.inc @@ -0,0 +1,2 @@ +SDL_MIXER_VERSION = 1.2.12 +SDL_MIXER = SDL_mixer-$(SDL_MIXER_VERSION) diff --git a/libports/ports/sdl_mixer.mk b/libports/ports/sdl_mixer.mk new file mode 100644 index 000000000..b9a520bd4 --- /dev/null +++ b/libports/ports/sdl_mixer.mk @@ -0,0 +1,38 @@ +include ports/sdl_mixer.inc + +SDL_MIXER_TGZ = $(SDL_MIXER).tar.gz +SDL_MIXER_URL = http://www.libsdl.org/projects/SDL_mixer/release/$(SDL_MIXER_TGZ) + +# +# Interface to top-level prepare Makefile +# +# Register SDL_mixer port as lower case to be consistent with the +# other libraries. +# +PORTS += sdl_mixer-$(SDL_MIXER_VERSION) + +prepare-sdl_mixer: $(CONTRIB_DIR)/$(SDL_MIXER) include/SDL/SDL_mixer.h + +$(CONTRIB_DIR)/$(SDL_MIXER): clean-sdl_mixer + +# +# Port-specific local rules +# +$(DOWNLOAD_DIR)/$(SDL_MIXER_TGZ): + $(VERBOSE)wget -c -P $(DOWNLOAD_DIR) $(SDL_MIXER_URL) && touch $@ + +$(CONTRIB_DIR)/$(SDL_MIXER): $(DOWNLOAD_DIR)/$(SDL_MIXER_TGZ) + $(VERBOSE)tar xfz $< \ + -C $(CONTRIB_DIR) && touch $@ + +# +# Install SDL_mixer headers +# +include/SDL/SDL_mixer.h: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -fs ../../$(CONTRIB_DIR)/$(SDL_MIXER)/SDL_mixer.h include/SDL/ + +clean-sdl_mixer: + $(VERBOSE)rm -rf include/SDL/SDL_mixer.h + $(VERBOSE)rmdir include/SDL 2>/dev/null || true + $(VERBOSE)rm -rf $(CONTRIB_DIR)/$(SDL_MIXER) diff --git a/libports/ports/sdl_ttf.inc b/libports/ports/sdl_ttf.inc new file mode 100644 index 000000000..a6ed80eec --- /dev/null +++ b/libports/ports/sdl_ttf.inc @@ -0,0 +1,2 @@ +SDL_TTF_VERSION = 2.0.11 +SDL_TTF = SDL_ttf-$(SDL_TTF_VERSION) diff --git a/libports/ports/sdl_ttf.mk b/libports/ports/sdl_ttf.mk new file mode 100644 index 000000000..774c5297f --- /dev/null +++ b/libports/ports/sdl_ttf.mk @@ -0,0 +1,40 @@ +include ports/sdl_ttf.inc + +SDL_TTF_TGZ = $(SDL_TTF).tar.gz +SDL_TTF_URL = http://www.libsdl.org/projects/SDL_ttf/release/$(SDL_TTF_TGZ) + +# +# Interface to top-level prepare Makefile +# +# Register SDL_ttf port as lower case to be consistent with the +# other libraries. +# +PORTS += sdl_ttf-$(SDL_TTF_VERSION) + +prepare-sdl_ttf: $(CONTRIB_DIR)/$(SDL_TTF) include/SDL/SDL_ttf.h + +$(CONTRIB_DIR)/$(SDL_TTF): clean-sdl_ttf + +# +# Port-specific local rules +# +$(DOWNLOAD_DIR)/$(SDL_TTF_TGZ): + $(VERBOSE)wget -c -P $(DOWNLOAD_DIR) $(SDL_TTF_URL) && touch $@ + +$(CONTRIB_DIR)/$(SDL_TTF): $(DOWNLOAD_DIR)/$(SDL_TTF_TGZ) + $(VERBOSE)tar xfz $< \ + --exclude Xcode --exclude VisualC --exclude Xcode-iOS \ + --exclude Watcom-Win32.zip \ + -C $(CONTRIB_DIR) && touch $@ + +# +# Install SDL_ttf headers +# +include/SDL/SDL_ttf.h: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -fs ../../$(CONTRIB_DIR)/$(SDL_TTF)/SDL_ttf.h include/SDL/ + +clean-sdl_ttf: + $(VERBOSE)rm -rf include/SDL/SDL_ttf.h + $(VERBOSE)rmdir include/SDL 2>/dev/null || true + $(VERBOSE)rm -rf $(CONTRIB_DIR)/$(SDL_TTF) diff --git a/libports/src/lib/sdl/SDL_config_genode.h b/libports/src/lib/sdl/SDL_config_genode.h index 89af77dc9..a686a58e4 100644 --- a/libports/src/lib/sdl/SDL_config_genode.h +++ b/libports/src/lib/sdl/SDL_config_genode.h @@ -75,6 +75,8 @@ #define HAVE_SNPRINTF #define HAVE_VSNPRINTF +#define HAVE_STDIO_H 1 + /* #define SDL_malloc malloc */ /* #define SDL_calloc calloc */ /* #define SDL_realloc realloc */ diff --git a/libports/src/lib/sdl/loadso/SDL_loadso.cc b/libports/src/lib/sdl/loadso/SDL_loadso.cc new file mode 100644 index 000000000..372d902b7 --- /dev/null +++ b/libports/src/lib/sdl/loadso/SDL_loadso.cc @@ -0,0 +1,38 @@ +/* + * \brief Genode-specific shared-object backend + * \author Norman Feske + * \date 2013-03-29 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +extern "C" { + +#include + +#include "SDL_config.h" +#include "SDL_loadso.h" + +void *SDL_LoadObject(const char *sofile) +{ + return dlopen(sofile, 0); +} + + +void *SDL_LoadFunction(void *handle, const char *name) +{ + return dlsym(handle, name); +} + + +void SDL_UnloadObject(void* handle) +{ + dlclose(handle); +} + +} diff --git a/libports/src/lib/sdl/timer/SDL_systimer.cc b/libports/src/lib/sdl/timer/SDL_systimer.cc index f9a8fe3d9..dd0a9d0c7 100644 --- a/libports/src/lib/sdl/timer/SDL_systimer.cc +++ b/libports/src/lib/sdl/timer/SDL_systimer.cc @@ -23,6 +23,9 @@ extern "C" { #include "SDL_timer_c.h" +static Uint32 jiffies = 0; + + void SDL_StartTicks(void) { } @@ -30,8 +33,7 @@ void SDL_StartTicks(void) Uint32 SDL_GetTicks (void) { - printf("SDL_GetTicks() called - not implemented yet\n"); - return 0; + return jiffies; } @@ -56,6 +58,7 @@ static int RunTimer(void *unused) SDL_ThreadedTimerCheck(); } SDL_Delay(1); + jiffies++; } return(0); } diff --git a/libports/src/test/libports/sdl_image/target.mk b/libports/src/test/libports/sdl_image/target.mk new file mode 100644 index 000000000..1457fe651 --- /dev/null +++ b/libports/src/test/libports/sdl_image/target.mk @@ -0,0 +1,5 @@ +TARGET = test-sdl_image +LIBS = libc sdl_image +SRC_CC = main.cc + +vpath main.cc $(PRG_DIR)/.. diff --git a/libports/src/test/libports/sdl_mixer/target.mk b/libports/src/test/libports/sdl_mixer/target.mk new file mode 100644 index 000000000..29b354c7c --- /dev/null +++ b/libports/src/test/libports/sdl_mixer/target.mk @@ -0,0 +1,5 @@ +TARGET = test-sdl_mixer +LIBS = libc sdl_mixer +SRC_CC = main.cc + +vpath main.cc $(PRG_DIR)/.. diff --git a/libports/src/test/libports/sdl_ttf/target.mk b/libports/src/test/libports/sdl_ttf/target.mk new file mode 100644 index 000000000..816e846c8 --- /dev/null +++ b/libports/src/test/libports/sdl_ttf/target.mk @@ -0,0 +1,5 @@ +TARGET = test-sdl_ttf +LIBS = libc sdl_ttf +SRC_CC = main.cc + +vpath main.cc $(PRG_DIR)/..