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