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