Because (almost) everything is done in handlers now, merge the action files.
[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
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
25 SOURCES=$(OBJS:.o=.c) dungeon.c advent.h sizes.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 sizes.h
34
35 init.o:         advent.h database.h database.c sizes.h
36
37 actions.o:      advent.h database.h database.c sizes.h
38
39 score.o:        advent.h database.h database.c sizes.h
40
41 misc.o:  advent.h database.h database.c sizes.h
42
43 database.o:     database.c database.h sizes.h
44         $(CC) $(CCFLAGS) $(DBX) -c database.c
45
46 database.c database.h: dungeon
47         ./dungeon
48
49 linenoise.o:    linenoise/linenoise.h
50         $(CC) $(CCFLAGS) $(DBX) -c linenoise/linenoise.c
51
52 dungeon: dungeon.c
53         $(CC) $(CCFLAGS) -o $@ $<
54
55 clean:
56         rm -f *.o advent *.html database.[ch] dungeon *.gcno *.gcda
57         rm -f README advent.6 MANIFEST *.tar.gz
58         rm -f *~
59         cd tests; $(MAKE) --quiet clean
60
61 check: advent
62         cd tests; $(MAKE) --quiet
63
64 .SUFFIXES: .adoc .html .6
65
66 # Requires asciidoc and xsltproc/docbook stylesheets.
67 .adoc.6:
68         a2x --doctype manpage --format manpage $<
69 .adoc.html:
70         asciidoc $<
71 .adoc:
72         asciidoc $<
73
74 html: advent.html history.html hints.html
75
76 # README.adoc exists because that filename is magic on GitLab.
77 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc hints.adoc advent.6
78 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
79
80 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
81 # This is a requirement for testing dist in GitLab's CI pipeline
82 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
83         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
84         @(ln -s . advent-$(VERS))
85         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
86         @(rm advent-$(VERS))
87
88 release: advent-$(VERS).tar.gz advent.html history.html hints.html
89         shipper version=$(VERS) | sh -e -x
90
91 refresh: advent.html
92         shipper -N -w version=$(VERS) | sh -e -x
93
94 dist: advent-$(VERS).tar.gz
95
96 debug: CCFLAGS += -O0 --coverage
97 debug: advent