Get rid of common/defines.h.
authorTimo Korvola <tkorvola@iki.fi>
Tue, 27 Mar 2018 19:32:39 +0000 (22:32 +0300)
committerTimo Korvola <tkorvola@iki.fi>
Tue, 27 Mar 2018 19:34:35 +0000 (22:34 +0300)
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
src/common/Makefile
src/common/frotz.h
src/curses/ux_init.c
src/dumb/dumb_init.c
src/sdl/sf_util.c
src/sdl/sf_video.c

index d34ffca833b2c27f4bcf9e11ff02491997d6e3d7..fa69d14f8eba068095b4ae3926b158f16e3aee28 100644 (file)
--- 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
index accf78882ab4632661ae4289824a37c9935925f3..00d36fa9a5b7a580c45ca36bc0eda1738a0a7732 100644 (file)
@@ -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
 
index 2448d3d44a1cb36b8f1dab836061aef3be0f71df..b02f1a2441f8e4f6da36ec53de1cf657e5c013e9 100644 (file)
@@ -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"
index e5d3630561108e8f4d17f1b7eac5ddb078adeb43..66126b8c103a7f1950a5c2e42af6b15b85724aec 100644 (file)
@@ -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");
index 5244886adf54cc237e4a1f200bc672ea935a6209..11d65d3292f145be399ee4f9301e0d2abb57331a 100644 (file)
@@ -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);
index 9644a0447b8404649580f6cf4e1d3ca061c37e0f..41fd783b70736a933e22859b060f855b7e6a80b5 100644 (file)
@@ -12,7 +12,6 @@
 #include <io.h>
 #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)
index e976e5adbfb0bd8cbac73cf119938db764a0d8d7..38fa815d1e3dd9526b4962367e53856366caf991 100644 (file)
@@ -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;