Fix make debug check
[open-adventure.git] / Makefile
index 758408ab571a1d0ade40024445de83117d0ea7c5..43f1f9514caa1c1286ec093cbb47e5147d92d307 100644 (file)
--- a/Makefile
+++ b/Makefile
 #
 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
 
-.PHONY: debug indent release refresh dist linty html clean
+VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
 
-VERS=1.0
+.PHONY: debug indent release refresh dist linty html clean
+.PHONY: check coverage
 
 CC?=gcc
-CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic -O2
+CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -Wpedantic -O2
 LIBS=
 UNAME_S := $(shell uname -s)
 ifeq ($(UNAME_S),Linux)
@@ -38,7 +39,7 @@ endif
 
 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
-SOURCES=$(OBJS:.o=.c) advent.h adventure.text adventure.yaml Makefile control linenoise/linenoise.[ch] make_dungeon.py
+SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control linenoise/linenoise.[ch] make_dungeon.py
 
 .c.o:
        $(CC) $(CCFLAGS) $(DBX) -c $<
@@ -46,7 +47,7 @@ SOURCES=$(OBJS:.o=.c) advent.h adventure.text adventure.yaml Makefile control li
 advent:        $(OBJS) linenoise.o dungeon.o
        $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o linenoise.o $(LDFLAGS) $(LIBS)
 
-main.o:                advent.h dungeon.h
+main.o:                advent.h dungeon.h linenoise.o
 
 init.o:                advent.h dungeon.h
 
@@ -56,7 +57,7 @@ score.o:      advent.h dungeon.h
 
 misc.o:                advent.h dungeon.h
 
-cheat.o:       advent.h dungeon.h
+cheat.o:       advent.h dungeon.h linenoise.o
 
 saveresume.o:  advent.h dungeon.h
 
@@ -66,7 +67,14 @@ dungeon.o:   dungeon.c dungeon.h
 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
        python3 make_dungeon.py
 
-linenoise.o:   linenoise/linenoise.h
+linenoise.o: linenoise/linenoise.h
+       @test -s linenoise/linenoise.h || { echo -e "linenoise not present. Try:\n\
+               git submodule update --recursive --remote --init"; exit 1; }
+       $(CC) -c linenoise/linenoise.c
+
+linenoise-dbg: linenoise/linenoise.h
+       @test -s linenoise/linenoise.h || { echo -e "linenoise not present. Try:\n\
+               git submodule update --recursive --remote --init"; exit 1; }
        $(CC) $(CCFLAGS) -c linenoise/linenoise.c
 
 clean:
@@ -147,4 +155,4 @@ debug: CCFLAGS += -O0 --coverage -ggdb
 debug: linty
 debug: cheat
 
-
+debug-ln: linenoise-dbg debug