From 6663542cbe63920b2a453e560777a5f665475caf Mon Sep 17 00:00:00 2001 From: Timo Korvola Date: Thu, 1 Mar 2018 00:55:12 +0200 Subject: [PATCH] Fix external link problems. Now it is just that lots of os_whatever functions are missing from the SDL front end. Many of them (e.g., file I/O) could probably be shared. --- Makefile | 25 ++++++++++++++++++++++--- src/sdl/Makefile | 4 ++-- src/sdl/sf_images.c | 6 +----- src/sdl/sf_util.c | 1 + 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 248969d..1211d24 100644 --- a/Makefile +++ b/Makefile @@ -149,9 +149,25 @@ DUMB_OBJECT = $(DUMB_DIR)/dumb_init.o \ BLORB_DIR = $(SRCDIR)/blorb BLORB_OBJECT = $(BLORB_DIR)/blorblib.o +SDL_DIR = $(SRCDIR)/sdl +SDL_LIB = $(SDL_DIR)/frotz_sdl.a +export SDL_PKGS = libpng libjpeg sdl SDL_mixer freetype2 zlib +SDL_LDFLAGS = `pkg-config $(SDL_PKGS) --libs` -lz + OBJECTS = $(COMMON_OBJECT) $(CURSES_OBJECT) $(DUMB_OBJECT) $(BLORB_OBJECT) -all: frotz dfrotz +SUBDIRS = $(SDL_DIR) +SUB_CLEAN = $(SUBDIRS:%=%-clean) + +all: frotz dfrotz sfrotz + +$(SDL_LIB): | $(SDL_DIR) + +$(SUBDIRS): + $(MAKE) -C $@ + +$(SUB_CLEAN): + $(MAKE) -C $(@:%-clean=%) clean # Main programs @@ -161,6 +177,9 @@ frotz: $(SRCDIR)/frotz_common.a $(SRCDIR)/frotz_curses.a $(SRCDIR)/blorblib.a dfrotz: $(SRCDIR)/frotz_common.a $(SRCDIR)/frotz_dumb.a $(SRCDIR)/blorblib.a $(CC) $(CFLAGS) $^ -o $@$(EXTENSION) $(LDFLAGS) +sfrotz: $(SRCDIR)/frotz_common.a $(SDL_LIB) $(SRCDIR)/blorblib.a + $(CC) $(CFLAGS) $^ -o $@$(EXTENSION) $(LDFLAGS) $(SDL_LDFLAGS) + # Libs %.a: @@ -244,7 +263,7 @@ dist: frotz-$(GIT_TAG).tar.gz frotz-$(GIT_TAG).tar.gz: git archive --format=tar.gz -o "frotz-$(GIT_TAG).tar.gz" "$(GIT_TAG)" -clean: +clean: $(SUB_CLEAN) rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a $(COMMON_DIR)/defines.h \ $(COMMON_DIR)/git_hash.h $(CURSES_DIR)/defines.h \ $(OBJECTS) frotz*.tar.gz @@ -266,4 +285,4 @@ help: .PHONY: all clean dist dumb hash help \ blorb_lib common_lib curses_lib dumb_lib \ install install_dfrotz install_dumb \ - uninstall uninstall_dfrotz uninstall_dumb + uninstall uninstall_dfrotz uninstall_dumb $(SUBDIRS) $(SUB_CLEAN) diff --git a/src/sdl/Makefile b/src/sdl/Makefile index 68f26e0..acaf66b 100644 --- a/src/sdl/Makefile +++ b/src/sdl/Makefile @@ -1,9 +1,9 @@ # For GNU Make. -PKGS = sdl SDL_mixer freetype2 +SDL_PKGS ?= libpng libjpeg libsdl SDL_mixer freetype2 zlib CC = gcc -CFLAGS += `pkg-config $(PKGS) --cflags` +CFLAGS += `pkg-config $(SDL_PKGS) --cflags` ARFLAGS = rvU SOURCES = sf_aiffwav.c sf_fonts.c sf_msg_en.c sf_resource.c sf_util.c \ diff --git a/src/sdl/sf_images.c b/src/sdl/sf_images.c index ae044b3..28b6a1b 100644 --- a/src/sdl/sf_images.c +++ b/src/sdl/sf_images.c @@ -124,11 +124,7 @@ static int loadpng( byte *data, int length, sf_picture *graphic) if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8) png_set_palette_to_rgb(png_ptr); if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - #ifdef __WIN32__ - os_fatal("Missing png_set_gray_1_2_4_to_8\n"); - #else - png_set_gray_1_2_4_to_8(png_ptr); - #endif + png_set_expand_gray_1_2_4_to_8(png_ptr); if (png_get_valid(png_ptr,info_ptr,PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index 4106923..a8f32b0 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -11,6 +11,7 @@ #include "sf_frotz.h" +f_setup_t f_setup; typedef void (*CLEANFUNC)(); -- 2.34.1