# Targets
#
-.PHONY: all help dist clean distclean install install_dumb uninstall uninstall_dumb
+.PHONY: all help dist clean distclean install install_dumb uninstall uninstall_dumb hash
-$(NAME): $(CURSES_DIR)/defines.h $(COMMON_TARGET) $(CURSES_TARGET) $(BLORB_TARGET)
+$(NAME): hash $(COMMON_DIR)/defines.h $(CURSES_DIR)/curses_defines.h $(COMMON_TARGET) $(CURSES_TARGET) $(BLORB_TARGET)
ifeq ($(SOUND), ao)
$(CC) -o $(BINNAME)$(EXTENSION) $(TARGETS) $(LIB) $(CURSES) $(SOUND_LIB)
else ifeq ($(SOUND), none)
####################################
# Get the defines set up just right
#
-$(CURSES_DIR)/defines.h:
+$(COMMON_DIR)/defines.h:
@echo "Generating $@"
@echo "#define VERSION \"$(VERSION)\"" > $@
+
+$(CURSES_DIR)/curses_defines.h:
+ @echo "Generating $@"
@echo "#define CONFIG_DIR \"$(CONFIG_DIR)\"" >> $@
@echo "#define SOUND \"$(SOUND)\"" >> $@
@echo "#define SAMPLERATE $(SAMPLERATE)" >> $@
rm -f $(PREFIX)/bin/d$(NAME)
rm -f $(MAN_PREFIX)/man/man6/d$(NAME).6
-dist: distclean
+dist: distclean hash
mkdir $(distdir)
@for file in `ls`; do \
if test $$file != $(distdir); then \
clean:
rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a
- rm -f $(CURSES_DIR)/defines.h
+ rm -f $(COMMON_DIR)/defines.h
+ rm -f $(CURSES_DIR)/curses_defines.h
find . -name *.o -exec rm -f {} \;
find . -name *.O -exec rm -f {} \;
-rm -rf $(distdir)
-rm -f $(distdir).tar $(distdir).tar.gz
+# If we're building from a Git repository, fetch the commit tag and put
+# it into $(COMMON_DIR)/git_hash.h.
+# If not, that should mean that we're building from a tarball. In that
+# case, $(COMMON_DIR)/git_hash.h should already be there.
+hash:
+ifneq ($(and $(wildcard .git),$(shell which git)),)
+ @echo "Creating $(COMMON_DIR)/git_hash.h"
+ @echo "#define GIT_HASH \"$$(git rev-parse HEAD)\"" > $(COMMON_DIR)/git_hash.h
+ @echo "#define GIT_TAG \"$$(git describe --tags)\"" >> $(COMMON_DIR)/git_hash.h
+ @echo "#define GIT_BRANCH \"$$(git rev-parse --abbrev-ref HEAD)\"" >> $(COMMON_DIR)/git_hash.h
+else
+ ifneq ($(wildcard $(COMMON_DIR)/git_hash.h),)
+ @echo "Found $(COMMON_DIR)/git_hash.h"
+ else
+ $(error $(COMMON_DIR)/git_hash.h is missing!.)
+ endif
+endif
+
help:
@echo
@echo "Targets:"
@echo " distclean"
@echo " dist"
@echo
-
-f # foreground color \t -S # transcript width\n\
-F Force color mode \t -t set Tandy bit\n\
-h # screen height \t -u # slots for multiple undo\n\
- -i ignore fatal errors \t -w # screen width\n\
- -l # left margin \t -x expand abbreviations g/x/z\n\
- -o watch object movement"
+ -i ignore fatal errors \t -v print version information\n\
+ -l # left margin \t -w # screen width\n\
+ -o watch object movement \t -x expand abbreviations g/x/z"
/*
char stripped_story_name[FILENAME_MAX+1];
static int zoptopt = 0;
static char *zoptarg = NULL;
+static void print_version(void);
static int getconfig(char *);
static int getbool(char *);
static int getcolor(char *);
/* Parse the options */
do {
- c = zgetopt(argc, argv, "aAb:c:def:Fh:il:oOpPqr:s:S:tu:w:xZ:");
+ c = zgetopt(argc, argv, "aAb:c:def:Fh:il:oOpPqr:s:S:tu:vw:xZ:");
switch(c) {
case 'a': f_setup.attribute_assignment = 1; break;
case 'A': f_setup.attribute_testing = 1; break;
case 'S': f_setup.script_cols = atoi(zoptarg); break;
case 't': u_setup.tandy_bit = 1; break;
case 'u': f_setup.undo_slots = atoi(zoptarg); break;
+ case 'v': print_version(); exit(2); break;
case 'w': u_setup.screen_width = atoi(zoptarg); break;
case 'x': f_setup.expand_abbreviations = 1; break;
case 'Z': f_setup.err_report_mode = atoi(zoptarg);
} while (c != EOF);
if (zoptind != argc - 1) {
- printf("FROTZ V%s\t", VERSION);
+ printf("FROTZ V%s\t", GIT_TAG);
#ifndef NO_SOUND
printf("Audio output enabled.");
+#else
+ printf("Audio output disabled.");
#endif
putchar('\n');
fputc ('\n', stderr);
return '?';
}/* zgetopt */
+
+
+static void print_version(void)
+{
+ printf("FROTZ V%s\t", VERSION);
+#ifndef NO_SOUND
+ printf("Audio output enabled.");
+#else
+ printf("Audio output disabled.");
+#endif
+ 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(" Frotz was originally written by Stefan Jokisch\n");
+ printf(" It was ported to Unix by Galen Hazelwood.\n");
+ printf(" The core and Unix port are currently maintained by David Griffith.\n");
+ printf(" See https://github.com/DavidGriffith/frotz for Frotz's homepage\n\n");
+ return;
+}