From 3f1671d2035c82b579cac034df5ea607c9d47ac8 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Fri, 12 Jul 2019 23:55:22 -0700 Subject: [PATCH] Adding a "nosound" target to build curses interface without audio support. Previously if you wanted to build Frotz without sound support, you needed to edit the Makefile. --- Makefile | 21 +++++++++++++++++---- src/curses/Makefile | 2 +- src/curses/ux_audio.c | 3 ++- src/curses/ux_sema.h | 8 ++++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8c4de6a..0673937 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,9 @@ export SYSCONFDIR export INCLUDEDIR export LIBDIR export COLOR +export SOUND +export NOSOUND +export CURSES_SOUND_LDFLAGS NAME = frotz VERSION = 2.45pre @@ -170,9 +173,11 @@ ifeq ($(CURSES), ncursesw) endif ifeq ($(SOUND), ao) - CURSES_LDFLAGS += -lao -ldl -lpthread -lm \ + CURSES_SOUND_LDFLAGS += -lao -ldl -lpthread -lm \ -lsndfile -lvorbisfile -lmodplug -lsamplerate endif +# To report if Frotz compiled with or without sound support +CURSES_SOUND = enabled # Source locations @@ -206,19 +211,26 @@ DOS_DIR = $(SRCDIR)/dos SUBDIRS = $(COMMON_DIR) $(CURSES_DIR) $(SDL_DIR) $(DUMB_DIR) $(BLORB_DIR) $(DOS_DIR) SUB_CLEAN = $(SUBDIRS:%=%-clean) - FROTZ_BIN = frotz$(EXTENSION) DFROTZ_BIN = dfrotz$(EXTENSION) SFROTZ_BIN = sfrotz$(EXTENSION) DOS_BIN = frotz.exe + # Build recipes # curses: $(FROTZ_BIN) ncurses: $(FROTZ_BIN) $(FROTZ_BIN): $(COMMON_LIB) $(CURSES_LIB) $(BLORB_LIB) $(COMMON_LIB) - $(CC) $(CFLAGS) $(CURSES_CFLAGS) $+ -o $@$(EXTENSION) $(LDFLAGS) $(CURSES_LDFLAGS) + $(CC) $(CFLAGS) $(CURSES_CFLAGS) $+ -o $@$(EXTENSION) $(LDFLAGS) $(CURSES_LDFLAGS) $(CURSES_SOUND_LDFLAGS) @echo "** Done building Frotz with curses interface" + @echo "** Audio support $(CURSES_SOUND)" + +nosound: nosound_helper $(FROTZ_BIN) +nosound_helper: + $(eval NOSOUND= -DNO_SOUND) + $(eval CURSES_SOUND_LDFLAGS= ) + $(eval CURSES_SOUND= disabled) dumb: $(DFROTZ_BIN) $(DFROTZ_BIN): $(COMMON_LIB) $(DUMB_LIB) $(BLORB_LIB) $(COMMON_LIB) @@ -392,6 +404,7 @@ distclean: clean help: @echo "Targets:" @echo " frotz: (default target) the standard curses edition" + @echo " nosound: the standard curses edition without sound support" @echo " dumb: for dumb terminals and wrapper scripts" @echo " sdl: for SDL graphics and sound" @echo " all: build curses, dumb, and SDL versions" @@ -412,7 +425,7 @@ help: .SUFFIXES: .c .o .h .PHONY: all clean dist curses ncurses dumb sdl hash help \ - common_defines curses_defines \ + common_defines curses_defines nosound nosound_helper\ blorb_lib common_lib curses_lib dumb_lib \ install install_dfrotz install_sfrotz \ $(SUBDIRS) $(SUB_CLEAN) \ diff --git a/src/curses/Makefile b/src/curses/Makefile index d8cf718..bbfe7ab 100644 --- a/src/curses/Makefile +++ b/src/curses/Makefile @@ -35,4 +35,4 @@ clean: rm -f $(TARGET) $(OBJECTS) %.o: %.c - $(CC) $(CFLAGS) $(CURSES_CFLAGS) -fPIC -fpic -o $@ -c $< + $(CC) $(CFLAGS) $(CURSES_CFLAGS) $(NOSOUND) -fPIC -fpic -o $@ -c $< diff --git a/src/curses/ux_audio.c b/src/curses/ux_audio.c index ce4aa65..4059210 100644 --- a/src/curses/ux_audio.c +++ b/src/curses/ux_audio.c @@ -43,10 +43,11 @@ #include "ux_audio.h" f_setup_t f_setup; -ux_sem_t sound_done; /* 1 if the sound is done */ #ifndef NO_SOUND +ux_sem_t sound_done; /* 1 if the sound is done */ + #include #include #include diff --git a/src/curses/ux_sema.h b/src/curses/ux_sema.h index baf3656..b231707 100644 --- a/src/curses/ux_sema.h +++ b/src/curses/ux_sema.h @@ -28,6 +28,8 @@ * at https://stackoverflow.com/questions/27736618/why-are-sem-init-sem-getvalue-sem-destroy-deprecated-on-mac-os-x-and-w */ +#ifndef NO_SOUND + #ifdef MACOS #include struct ux_sema { @@ -35,7 +37,7 @@ struct ux_sema { }; typedef struct ux_sema ux_sem_t; -/* +/* * Note that the current implementation does not check return codes * so use void to make things simpler on the MAC side */ @@ -69,7 +71,7 @@ static inline int ux_sem_trywait(ux_sem_t *sem) #include typedef sem_t ux_sem_t; -/* +/* * Note that the current implementation does not check return codes * so use void to make things simpler on the MAC side */ @@ -93,3 +95,5 @@ static inline int ux_sem_trywait(ux_sem_t *sem) return sem_trywait(sem); } #endif + +#endif /* NO_SOUND */ -- 2.34.1