Simplification.
[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
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) compile.c advent.h funcs.h adventure.text Makefile control
15
16 .c.o:
17         $(CC) $(CCFLAGS) $(DBX) -c $<
18
19 advent: $(OBJS) database.o
20         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) database.o $(LDFLAGS) $(LIBS)
21
22 main.o:         advent.h funcs.h database.h
23
24 init.o:         advent.h funcs.h database.h
25
26 actions1.o:     advent.h funcs.h database.h
27
28 actions2.o:     advent.h funcs.h
29
30 score.o:        advent.h database.h
31
32 misc.o:         advent.h database.h
33
34 database.o:     database.h
35
36 compile: compile.c
37         $(CC) $(CCFLAGS) -o $@ $<
38
39 database.c database.h: compile adventure.text
40         ./compile
41         $(CC) $(CCFLAGS) $(DBX) -c database.c
42
43 html: index.html advent.html history.html hints.html
44
45 clean:
46         rm -f *.o advent *.html database.[ch] compile *.gcno *.gcda
47         rm -f README advent.6 MANIFEST
48         cd tests; $(MAKE) --quiet clean
49
50 check: advent
51         cd tests; $(MAKE) --quiet
52
53 .SUFFIXES: .adoc .html .6
54
55 # Requires asciidoc and xsltproc/docbook stylesheets.
56 .adoc.6:
57         a2x --doctype manpage --format manpage $<
58 .adoc.html:
59         asciidoc $<
60 .adoc:
61         asciidoc $<
62
63 # README.adoc exists because that filename is magic on GitLab.
64 DOCS=COPYING NEWS README.adoc TODO \
65         advent.adoc history.adoc index.adoc hints.adoc advent.6
66
67 # Can't use GNU tar's --transform, needs to build under Alpine Linux
68 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
69         @ls $(SOURCES) $(DOCS) | sed s:^:advent-$(VERS)/: >MANIFEST
70         @(cd ..; ln -s advent advent-$(VERS))
71         (cd ..; tar -czvf advent/advent-$(VERS).tar.gz `cat advent/MANIFEST`)
72         @(cd ..; rm advent-$(VERS))
73
74 dist: advent-$(VERS).tar.gz
75
76 debug: CCFLAGS += -O0 --coverage
77 debug: advent