Refining Makefiles. Needs work with implicit declarations and signed/unsigned.
authorDavid Griffith <dave@661.org>
Fri, 3 May 2019 04:07:30 +0000 (21:07 -0700)
committerDavid Griffith <dave@661.org>
Sun, 5 May 2019 00:37:39 +0000 (17:37 -0700)
Makefile
src/curses/Makefile

index 4c1349f532a0a046991edcab18c1d9b124edeb70..08521441a3f3befa4efec386f8d57f5628ccae5a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -58,23 +58,22 @@ BUFFSIZE ?= 4096
 # Default sample rate converter type
 DEFAULT_CONVERTER ?= SRC_SINC_MEDIUM_QUALITY
 
-#
 # Comment this out if you don't want UTF-8 support
 USE_UTF8 ?= yes
 
-#
 # The OE dipthong is not a latin1 character, but it seems the zmachine
 # can handle it, and it is tested for in terpetude.  Comment this out
 # if you don't want to support the OE dipthong
 HANDLE_OE_DIPTHONG ?= yes
 
 # Comment this out if your machine's version of curses doesn't support color.
-#
 COLOR ?= yes
 
-# If this matters, you can choose -lcurses or -lncurses
-# For UTF-8 support -lncursesw needs to be used
-CURSES ?= -lncursesw
+# Select your chosen version of curses.  Unless something old is going
+# on, ncursesw should be used because that's how UTF8 is supported.
+#CURSES ?= curses
+#CURSES ?= ncurses
+CURSES ?= ncursesw
 
 # Uncomment this if you want to disable the compilation of Blorb support.
 #NO_BLORB = yes
@@ -110,6 +109,7 @@ AR ?= $(shell which ar)
 
 export CC
 export CFLAGS
+export CURSES_CFLAGS
 export MAKEFLAGS
 export AR
 export RANLIB
@@ -145,8 +145,22 @@ export CFLAGS
 
 # Compile time options handling
 #
+ifeq ($(CURSES), curses)
+  CURSES_LDFLAGS += -lcurses
+  CURSES_DEFINE = USE_CURSES_H
+endif
+ifeq ($(CURSES), ncurses)
+  CURSES_LDFLAGS += -lncurses
+  CURSES_DEFINE = USE_NCURSES_H
+endif
+ifeq ($(CURSES), ncursesw)
+  CURSES_LDFLAGS += -lncursesw -ltinfo
+  CURSES_CFLAGS += -D_XOPEN_SOURCE_EXTENDED
+  CURSES_DEFINE = USE_NCURSES_H
+endif
+
 ifeq ($(SOUND), ao)
-  CURSES_LDFLAGS = -lao -ldl -lpthread -lm \
+  CURSES_LDFLAGS += -lao -ldl -lpthread -lm \
        -lsndfile -lvorbisfile -lmodplug -lsamplerate
 endif
 
@@ -192,8 +206,7 @@ SFROTZ_BIN = sfrotz$(EXTENSION)
 curses: $(FROTZ_BIN)
 ncurses: $(FROTZ_BIN)
 $(FROTZ_BIN): $(COMMON_LIB) $(CURSES_LIB) $(BLORB_LIB) $(COMMON_LIB)
-       $(CC) $(CFLAGS) $+ -o $@$(EXTENSION) $(CURSES) $(LDFLAGS) \
-               $(CURSES_LDFLAGS)
+       $(CC) $(CFLAGS) $(CURSES_CFLAGS) $+ -o $@$(EXTENSION) $(LDFLAGS) $(CURSES_LDFLAGS)
        @echo "** Done building Frotz with curses interface"
 
 dumb: $(DFROTZ_BIN)
@@ -265,6 +278,7 @@ $(CURSES_DEFINES):
        @echo "** Generating $@"
        @echo "#ifndef CURSES_DEFINES_H" > $@
        @echo "#define CURSES_DEFINES_H" >> $@
+       @echo "#define $(CURSES_DEFINE)" >> $@
        @echo "#define CONFIG_DIR \"$(SYSCONFDIR)\"" >> $@
        @echo "#define SOUND \"$(SOUND)\"" >> $@
        @echo "#define SAMPLERATE $(SAMPLERATE)" >> $@
index 2867246556f876f569509582f26d3a669340845f..4dd176e9a8019d745aba0da3826ff4f638413ccf 100644 (file)
@@ -35,4 +35,4 @@ clean:
        rm -f $(TARGET) $(OBJECTS)
 
 %.o: %.c
-       $(CC) $(CFLAGS) -fPIC -fpic -o $@ -c $<
+       $(CC) $(CFLAGS) $(CURSES_CFLAGS) -fPIC -fpic -o $@ -c $<