From daf70f43ad755d2dcdeddbc93700a4b25acfb648 Mon Sep 17 00:00:00 2001 From: Timo Korvola Date: Tue, 27 Mar 2018 22:32:39 +0300 Subject: [PATCH] Get rid of common/defines.h. Version info is now in common/version.c, the only file that needs to be recompiled every time. Global constants, not defines. The declarations are in frotz.h. --- Makefile | 35 ++++++++++++++++------------------- src/common/Makefile | 2 +- src/common/frotz.h | 3 +++ src/curses/ux_init.c | 8 +++----- src/dumb/dumb_init.c | 6 ++---- src/sdl/sf_util.c | 3 +-- src/sdl/sf_video.c | 5 ++--- 7 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index d34ffca..fa69d14 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ SRCDIR = src COMMON_DIR = $(SRCDIR)/common COMMON_LIB = $(COMMON_DIR)/frotz_common.a -COMMON_DEFINES = $(COMMON_DIR)/defines.h +COMMON_DEFINES = $(COMMON_DIR)/version.c HASH = $(COMMON_DIR)/git_hash.h CURSES_DIR = $(SRCDIR)/curses @@ -152,19 +152,19 @@ $(SUBDIRS): $(MAKE) -C $@ $(SUB_CLEAN): - $(MAKE) -C $(@:%-clean=%) clean + -$(MAKE) -C $(@:%-clean=%) clean # Main programs -frotz: $(COMMON_LIB) $(CURSES_LIB) $(BLORB_LIB) - $(CC) $(CFLAGS) $^ -o $@$(EXTENSION) $(CURSES) $(LDFLAGS) +frotz: $(COMMON_LIB) $(CURSES_LIB) $(BLORB_LIB) $(COMMON_LIB) + $(CC) $(CFLAGS) $+ -o $@$(EXTENSION) $(CURSES) $(LDFLAGS) -dfrotz: $(COMMON_LIB) $(DUMB_LIB) $(BLORB_LIB) - $(CC) $(CFLAGS) $^ -o $@$(EXTENSION) +dfrotz: $(COMMON_LIB) $(DUMB_LIB) $(BLORB_LIB) $(COMMON_LIB) + $(CC) $(CFLAGS) $+ -o $@$(EXTENSION) -sfrotz: $(COMMON_LIB) $(SDL_LIB) $(BLORB_LIB) - $(CC) $(CFLAGS) $^ -o $@$(EXTENSION) $(LDFLAGS) $(SDL_LDFLAGS) +sfrotz: $(COMMON_LIB) $(SDL_LIB) $(BLORB_LIB) $(COMMON_LIB) + $(CC) $(CFLAGS) $+ -o $@$(EXTENSION) $(LDFLAGS) $(SDL_LDFLAGS) # Libs @@ -177,16 +177,12 @@ sfrotz: $(COMMON_LIB) $(SDL_LIB) $(BLORB_LIB) $(CC) $(CFLAGS) -fPIC -fpic -o $@ -c $< common_lib: $(COMMON_LIB) -$(COMMON_LIB): curses_lib: $(CURSES_LIB) -$(CURSES_LIB): dumb_lib: $(DUMB_LIB) -$(DUMB_LIB): blorb_lib: $(BLORB_LIB) -$(BLORB_LIB): # Defines @@ -194,10 +190,11 @@ $(BLORB_LIB): common_defines: $(COMMON_DEFINES) $(COMMON_DEFINES): @echo "Generating $@" - @echo "#define VERSION \"$(VERSION)\"" > $@ - @echo "#define VERSION_MAJOR \"$(MAJOR)\"" >> $@ - @echo "#define VERSION_MINOR \"$(MINOR)\"" >> $@ - @echo "#define BUILD_DATE_TIME \"$(BUILD_DATE_TIME)\"" >> $@ + @echo "#include \"frotz.h\"" > $@ + @echo "const char frotz_version[] = \"$(VERSION)\";" >> $@ + @echo "const char frotz_v_major[] = \"$(MAJOR)\";" >> $@ + @echo "const char frotz_v_minor[] = \"$(MINOR)\";" >> $@ + @echo "const char frotz_v_build[] = \"$(BUILD_DATE_TIME)\";" >> $@ curses_defines: $(CURSES_DEFINES) $(CURSES_DEFINES): @@ -258,8 +255,8 @@ frotz-$(GIT_TAG).tar.gz: git archive --format=tar.gz -o "frotz-$(GIT_TAG).tar.gz" "$(GIT_TAG)" clean: $(SUB_CLEAN) - rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a $(COMMON_DIR)/defines.h \ - $(COMMON_DIR)/git_hash.h $(CURSES_DIR)/defines.h \ + rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a $(COMMON_DEFINES) \ + $(COMMON_DIR)/git_hash.h $(CURSES_DEFINES) \ $(OBJECTS) frotz*.tar.gz help: @@ -281,4 +278,4 @@ help: blorb_lib common_lib curses_lib dumb_lib \ install install_dfrotz install_dumb \ uninstall uninstall_dfrotz uninstall_dumb $(SUBDIRS) $(SUB_CLEAN) \ - $(COMMON_DIR)/defines.h $(CURSES_DIR)/defines.h + $(COMMON_DIR)/version.c $(CURSES_DIR)/defines.h diff --git a/src/common/Makefile b/src/common/Makefile index accf788..00d36fa 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -2,7 +2,7 @@ SOURCES = buffer.c err.c fastmem.c files.c getopt.c hotkey.c input.c \ main.c math.c object.c process.c quetzal.c random.c redirect.c \ - screen.c sound.c stream.c table.c text.c variable.c + screen.c sound.c stream.c table.c text.c variable.c version.c HEADERS = frotz.h setup.h unused.h diff --git a/src/common/frotz.h b/src/common/frotz.h index 2448d3d..b02f1a2 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -145,6 +145,9 @@ typedef struct { #define STACK_SIZE 1024 #endif +extern const char + frotz_version[], frotz_v_major[], frotz_v_minor[], frotz_v_build[]; + /* Assorted filename extensions */ #define EXT_SAVE ".qzl" diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index e5d3630..66126b8 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -45,8 +45,6 @@ #include "ux_frotz.h" #include "ux_blorb.h" -#include "../common/defines.h" - volatile sig_atomic_t terminal_resized = 0; static void sigwinch_handler(int); @@ -298,7 +296,7 @@ void os_process_arguments (int argc, char *argv[]) } while (c != EOF); if (zoptind != argc - 1) { - printf("FROTZ V%s\t", VERSION); + printf("FROTZ V%s\t", frotz_version); #ifndef NO_SOUND printf("Audio output enabled."); @@ -1135,7 +1133,7 @@ error: static void print_version(void) { - printf("FROTZ V%s\t", VERSION); + printf("FROTZ V%s\t", frotz_version); #ifndef NO_SOUND printf("Audio output enabled."); #else @@ -1144,7 +1142,7 @@ static void print_version(void) printf("\nGit commit:\t%s\n", GIT_HASH); printf("Git tag:\t%s\n", GIT_TAG); printf("Git branch:\t%s\n", GIT_BRANCH); - printf("Build:\t\t%s\n", BUILD_DATE_TIME); + printf("Build:\t\t%s\n", frotz_v_build); printf(" Frotz was originally written by Stefan Jokisch.\n"); printf(" It complies with standard 1.0 of Graham Nelson's specification.\n"); printf(" It was ported to Unix by Galen Hazelwood.\n"); diff --git a/src/dumb/dumb_init.c b/src/dumb/dumb_init.c index 5244886..11d65d3 100644 --- a/src/dumb/dumb_init.c +++ b/src/dumb/dumb_init.c @@ -23,8 +23,6 @@ #include "dumb_frotz.h" #include "dumb_blorb.h" -#include "../common/defines.h" - f_setup_t f_setup; static char *my_strdup(char *); @@ -130,7 +128,7 @@ void os_process_arguments(int argc, char *argv[]) } while (c != EOF); if (((argc - zoptind) != 1) && ((argc - zoptind) != 2)) { - printf("FROTZ V%s\tDumb interface.\n", VERSION); + printf("FROTZ V%s\tDumb interface.\n", frotz_version); puts(INFORMATION); printf("\t-Z # error checking mode (default = %d)\n" "\t %d = don't report errors %d = report first error\n" @@ -302,7 +300,7 @@ char *my_strdup(char *src) static void print_version(void) { - printf("FROTZ V%s\t", VERSION); + printf("FROTZ V%s\t", frotz_version); printf("Dumb interface.\n"); printf("Git commit:\t%s\n", GIT_HASH); printf("Git tag:\t%s\n", GIT_TAG); diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index 9644a04..41fd783 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -12,7 +12,6 @@ #include #endif -#include "../common/defines.h" #include "sf_frotz.h" f_setup_t f_setup; @@ -147,7 +146,7 @@ static char *info2 = static void usage() { char **p = infos; int i=0,len=0; - printf(info1,VERSION,BUILD_DATE_TIME); + printf(info1, frotz_version, frotz_v_build); while (*p) { if (i) diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index e976e5a..38fa815 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -9,7 +9,6 @@ #include "generic.h" -#include "../common/defines.h" #include "sf_frotz.h" static SDL_Rect blitrect = {0,0,0,0}; @@ -422,8 +421,8 @@ void sf_initvideo( int W, int H, int full) Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER | SDL_INIT_AUDIO; - sprintf(banner,"SDL Frotz v%s - %s (z%d)",VERSION, - f_setup.story_name,h_version); + sprintf(banner, "SDL Frotz v%s - %s (z%d)", + frotz_version, f_setup.story_name, h_version); desired_bpp = 32; video_flags = 0; -- 2.34.1