From 975e429161a389a14d8650c5be31cec5eb0d70de Mon Sep 17 00:00:00 2001 From: David Griffith Date: Mon, 3 Sep 2018 22:19:48 -0700 Subject: [PATCH] Add compile-time option to disable Blorb for the Dumb interface. --- Makefile | 10 ++++++++++ src/dumb/Makefile | 4 ++++ src/dumb/dumb_blorb.c | 6 ++++++ src/dumb/dumb_blorb.h | 4 ++++ src/dumb/dumb_init.c | 4 ++++ 5 files changed, 28 insertions(+) diff --git a/Makefile b/Makefile index f6e83b4..99edeb2 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,10 @@ CURSES ?= -lncurses # #NO_MEMMOVE = yes +# Uncomment this if you want to disable the compilation of Blorb support. +# +#NO_BLORB = yes + ######################################################################### # This section is where Frotz is actually built. # Under normal circumstances, nothing in this section should be changed. @@ -140,8 +144,10 @@ CURSES_DEFINES = $(CURSES_DIR)/ux_defines.h DUMB_DIR = $(SRCDIR)/dumb DUMB_LIB = $(DUMB_DIR)/frotz_dumb.a +ifndef NO_BLORB BLORB_DIR = $(SRCDIR)/blorb BLORB_LIB = $(BLORB_DIR)/blorblib.a +endif SDL_DIR = $(SRCDIR)/sdl SDL_LIB = $(SDL_DIR)/frotz_sdl.a @@ -219,9 +225,13 @@ ifdef NO_STRRCHR endif ifdef NO_MEMMOVE @echo "#define NO_MEMMOVE" >> $@ +endif +ifdef NO_BLORB + @echo "#define NO_BLORB" >> $@ endif @echo "#endif /* COMMON_DEFINES_H */" >> $@ + curses_defines: $(CURSES_DEFINES) $(CURSES_DEFINES): @echo "** Generating $@" diff --git a/src/dumb/Makefile b/src/dumb/Makefile index 1640326..d6165d5 100644 --- a/src/dumb/Makefile +++ b/src/dumb/Makefile @@ -12,12 +12,16 @@ ARFLAGS = rc .DELETE_ON_ERROR: $(TARGET): $(OBJECTS) +ifndef NO_BLORB $(AR) $(ARFLAGS) $@ $? $(RANLIB) $@ @echo "** Done with dumb interface." +endif clean: rm -f $(TARGET) $(OBJECTS) %.o: %.c +ifndef NO_BLORB $(CC) $(CFLAGS) -fPIC -fpic -o $@ -c $< +endif diff --git a/src/dumb/dumb_blorb.c b/src/dumb/dumb_blorb.c index 26efd27..ced0074 100644 --- a/src/dumb/dumb_blorb.c +++ b/src/dumb/dumb_blorb.c @@ -19,6 +19,7 @@ * Or visit http://www.fsf.org/ */ + #include #include #include @@ -30,6 +31,9 @@ #include "dumb_frotz.h" #include "dumb_blorb.h" +/* Don't build any of this if we don't want Blorb support. */ +#ifndef NO_BLORB + f_setup_t f_setup; FILE *blorb_fp; @@ -174,3 +178,5 @@ static int isblorb(FILE *fp) return 1; } + +#endif /* NO_BLORB */ diff --git a/src/dumb/dumb_blorb.h b/src/dumb/dumb_blorb.h index ec84be0..e85a8c9 100644 --- a/src/dumb/dumb_blorb.h +++ b/src/dumb/dumb_blorb.h @@ -5,6 +5,8 @@ * */ +#ifndef NO_BLORB + #include "../blorb/blorb.h" #include "../blorb/blorblow.h" @@ -41,3 +43,5 @@ extern bb_result_t blorb_res; bb_err_t dumb_blorb_init(char *); void dumb_blorb_stop(void); + +#endif /* NO_BLORB */ diff --git a/src/dumb/dumb_init.c b/src/dumb/dumb_init.c index fb0429d..8854b3d 100644 --- a/src/dumb/dumb_init.c +++ b/src/dumb/dumb_init.c @@ -217,6 +217,7 @@ FILE *os_load_story(void) { FILE *fp; +#ifndef NO_BLORB switch (dumb_blorb_init(f_setup.story_file)) { case bb_err_NoBlorb: // printf("No blorb file found.\n\n"); @@ -237,6 +238,9 @@ FILE *os_load_story(void) /* Is this a Blorb file containing Zcode? */ if (f_setup.exec_in_blorb) fseek(fp, blorb_res.data.startpos, SEEK_SET); +#else + fp = fopen(f_setup.story_file, "rb"); +#endif /* NO_BLORB */ return fp; } -- 2.34.1