Improve test coverage.
[open-adventure.git] / Makefile
1 # Makefile for the open-source release of adventure 2.5
2
3 # Note: If you're building from the repository rather than the source tarball,
4 # do this to get the linenoise library where you can use it:
5 #
6 # git submodule update --recursive --remote --init
7 #
8 # Therafter, you can update it like this:
9 #
10 # git submodule update --recursive --remote
11 #
12 # but this should seldom be necessary as that library is pretty stable.
13 #
14 # You will also need Python 3 YAML.  Under Debian or ubuntu:
15 #
16 # apt-get install python3-yaml
17 #
18 # If you have pip installed,
19 #
20 # pip3 install PyYAML
21 #
22 # If you are using MacPorts on OS X:
23 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
24 #
25 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
26
27 VERS=1.0
28
29 CC?=gcc
30 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic -g
31 LIBS=
32 UNAME_S := $(shell uname -s)
33 ifeq ($(UNAME_S),Linux)
34         LIBS=-lrt
35 endif
36
37 OBJS=main.o init.o actions.o score.o misc.o saveresume.o common.o
38 SOURCES=$(OBJS:.o=.c) dungeon.c advent.h common.h adventure.text Makefile control linenoise/linenoise.[ch] newdungeon.py
39
40 .c.o:
41         $(CC) $(CCFLAGS) $(DBX) -c $<
42
43 advent: $(OBJS) linenoise.o newdb.o
44         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) newdb.o linenoise.o $(LDFLAGS) $(LIBS)
45
46 main.o:         advent.h database.h common.h newdb.h
47
48 init.o:         advent.h database.h common.h newdb.h
49
50 actions.o:      advent.h database.h common.h newdb.h
51
52 score.o:        advent.h database.h common.h newdb.h
53
54 misc.o:         advent.h database.h common.h newdb.h
55
56 saveresume.o:   advent.h database.h common.h newdb.h
57
58 common.o:       common.h
59
60 newdb.o:        newdb.c newdb.h
61         $(CC) $(CCFLAGS) $(DBX) -c newdb.c
62
63 database.h: dungeon
64         ./dungeon
65
66 newdb.c newdb.h:
67         python3 newdungeon.py
68
69 linenoise.o:    linenoise/linenoise.h
70         $(CC) -c linenoise/linenoise.c
71
72 dungeon: dungeon.o common.o
73         $(CC) $(CCFLAGS) -o $@ dungeon.o common.o
74
75 clean:
76         rm -f *.o advent *.html database.h dungeon *.gcno *.gcda
77         rm -f newdb.c newdb.h
78         rm -f README advent.6 MANIFEST *.tar.gz
79         rm -f *~
80         rm -f .*~
81         cd tests; $(MAKE) --quiet clean
82
83 check: advent
84         cd tests; $(MAKE) --quiet
85
86 .SUFFIXES: .adoc .html .6
87
88 # Requires asciidoc and xsltproc/docbook stylesheets.
89 .adoc.6:
90         a2x --doctype manpage --format manpage $<
91 .adoc.html:
92         asciidoc $<
93 .adoc:
94         asciidoc $<
95
96 html: advent.html history.html hints.html
97
98 # README.adoc exists because that filename is magic on GitLab.
99 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
100 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
101
102 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
103 # This is a requirement for testing dist in GitLab's CI pipeline
104 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
105         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
106         @(ln -s . advent-$(VERS))
107         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
108         @(rm advent-$(VERS))
109
110 indent:
111         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
112
113 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
114         shipper version=$(VERS) | sh -e -x
115
116 refresh: advent.html
117         shipper -N -w version=$(VERS) | sh -e -x
118
119 dist: advent-$(VERS).tar.gz
120
121 linty: CCFLAGS += -W -Wall -Wextra -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wfloat-equal -Wcast-align -Wwrite-strings -Waggregate-return -Wcast-qual -Wswitch-enum -Wwrite-strings -Wunreachable-code -Winit-self -Wpointer-arith -O2 
122 linty: advent
123
124 debug: CCFLAGS += -O0 --coverage -g
125 debug: advent