Adding a "nosound" target to build curses interface without audio support.
authorDavid Griffith <dave@661.org>
Sat, 13 Jul 2019 06:55:22 +0000 (23:55 -0700)
committerDavid Griffith <dave@661.org>
Sat, 13 Jul 2019 07:07:37 +0000 (00:07 -0700)
Previously if you wanted to build Frotz without sound support, you
needed to edit the Makefile.

Makefile
src/curses/Makefile
src/curses/ux_audio.c
src/curses/ux_sema.h

index 8c4de6a2514eb9a26ee094fe24a7a54f58f92e47..067393705b94b03c0e7f1b28f7a21da02e9b5f4e 100644 (file)
--- 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) \
index d8cf718a8fffac711a683ae4c78ff53c667cc33f..bbfe7abacae5cf4a9ca5a2997a749d2b88d0c57e 100644 (file)
@@ -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 $<
index ce4aa65f029b55cec162f810d0a78f5deff684c0..405921064049fa0252d15a596d5a6d8db0b53849 100644 (file)
 #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 <ao/ao.h>
 #include <sndfile.h>
 #include <samplerate.h>
index baf3656a3a6bc56f6f3559e9b063f99bff956c3a..b23170733496ebca9ff778a686d2c2f0d2a4d213 100644 (file)
@@ -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 <dispatch/dispatch.h>
 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 <semaphore.h>
 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 */