dungeon now outputs just database.h
[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 VERS=1.0
23
24 CC?=gcc
25 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wall -Wpedantic -g
26 LIBS=
27 UNAME_S := $(shell uname -s)
28 ifeq ($(UNAME_S),Linux)
29         LIBS=-lrt
30 endif
31
32 OBJS=main.o init.o actions.o score.o misc.o saveresume.o common.o
33 SOURCES=$(OBJS:.o=.c) dungeon.c advent.h common.h adventure.text Makefile control linenoise/linenoise.[ch] newdungeon.py
34
35 .c.o:
36         $(CC) $(CCFLAGS) $(DBX) -c $<
37
38 advent: $(OBJS) linenoise.o newdb.o
39         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) newdb.o linenoise.o $(LDFLAGS) $(LIBS)
40
41 main.o:         advent.h database.h common.h newdb.h
42
43 init.o:         advent.h database.h common.h newdb.h
44
45 actions.o:      advent.h database.h common.h
46
47 score.o:        advent.h database.h common.h newdb.h
48
49 misc.o:         advent.h database.h common.h newdb.h
50
51 saveresume.o:   advent.h database.h common.h
52
53 common.o:       common.h
54
55 newdb.o:        newdb.c newdb.h
56         $(CC) $(CCFLAGS) $(DBX) -c newdb.c
57
58 database.h: dungeon
59         ./dungeon
60
61 newdb.c newdb.h:
62         python3 newdungeon.py
63
64 linenoise.o:    linenoise/linenoise.h
65         $(CC) -c linenoise/linenoise.c
66
67 dungeon: dungeon.o common.o
68         $(CC) $(CCFLAGS) -o $@ dungeon.o common.o
69
70 clean:
71         rm -f *.o advent *.html database.h dungeon *.gcno *.gcda
72         rm -f newdb.c newdb.h
73         rm -f README advent.6 MANIFEST *.tar.gz
74         rm -f *~
75         cd tests; $(MAKE) --quiet clean
76
77 check: advent
78         cd tests; $(MAKE) --quiet
79
80 .SUFFIXES: .adoc .html .6
81
82 # Requires asciidoc and xsltproc/docbook stylesheets.
83 .adoc.6:
84         a2x --doctype manpage --format manpage $<
85 .adoc.html:
86         asciidoc $<
87 .adoc:
88         asciidoc $<
89
90 html: advent.html history.html hints.html
91
92 # README.adoc exists because that filename is magic on GitLab.
93 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
94 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
95
96 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
97 # This is a requirement for testing dist in GitLab's CI pipeline
98 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
99         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
100         @(ln -s . advent-$(VERS))
101         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
102         @(rm advent-$(VERS))
103
104 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
105         shipper version=$(VERS) | sh -e -x
106
107 refresh: advent.html
108         shipper -N -w version=$(VERS) | sh -e -x
109
110 dist: advent-$(VERS).tar.gz
111
112 debug: CCFLAGS += -O0 --coverage -g
113 debug: advent