Fix make debug check
[open-adventure.git] / Makefile
index b8582d5d66c1f34df008d45634ea9ea88897a123..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)
@@ -46,7 +47,7 @@ SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control linenoise/linenoi
 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,10 +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
+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: