Fix external link problems.
authorTimo Korvola <tkorvola@iki.fi>
Wed, 28 Feb 2018 22:55:12 +0000 (00:55 +0200)
committerTimo Korvola <tkorvola@iki.fi>
Wed, 28 Feb 2018 22:55:12 +0000 (00:55 +0200)
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
src/sdl/Makefile
src/sdl/sf_images.c
src/sdl/sf_util.c

index 248969d7e7e5f3ce67f796f8985c6295f1d4491a..1211d24ea872ad639eb235c78aa3343b2fc64e24 100644 (file)
--- 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)
index 68f26e07ed713c5dd3455cb18c442cd6c592f854..acaf66b2a5cb1ea9cb3fd48f2d6ea008a6c00282 100644 (file)
@@ -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 \
index ae044b348903a070786d15896d33bace830093ab..28b6a1b20cf182439def11aa921404e5a37a5298 100644 (file)
@@ -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);
 
index 410692396ba3587fb4c9bae828f6023b3b5baf95..a8f32b02615d4b0fc2c4d0def8cfaf7bb74e3924 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "sf_frotz.h"
 
+f_setup_t f_setup;
 
 typedef void (*CLEANFUNC)();