62a4ee4fc91dd1bb775f6af2cebaa49b6f8ed2d4
[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 # If you are using MacPorts on OS X:
23 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
24
25 VERS=1.0
26
27 CC?=gcc
28 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic 
29 LIBS=
30 UNAME_S := $(shell uname -s)
31 ifeq ($(UNAME_S),Linux)
32         LIBS=-lrt
33 endif
34
35 OBJS=main.o init.o actions.o score.o misc.o saveresume.o common.o
36 SOURCES=$(OBJS:.o=.c) dungeon.c advent.h common.h adventure.text Makefile control linenoise/linenoise.[ch] newdungeon.py
37
38 .c.o:
39         $(CC) $(CCFLAGS) $(DBX) -c $<
40
41 advent: $(OBJS) linenoise.o newdb.o
42         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) newdb.o linenoise.o $(LDFLAGS) $(LIBS)
43
44 main.o:         advent.h database.h common.h newdb.h
45
46 init.o:         advent.h database.h common.h newdb.h
47
48 actions.o:      advent.h database.h common.h newdb.h
49
50 score.o:        advent.h database.h common.h newdb.h
51
52 misc.o:         advent.h database.h common.h newdb.h
53
54 saveresume.o:   advent.h database.h common.h newdb.h
55
56 common.o:       common.h
57
58 newdb.o:        newdb.c newdb.h
59         $(CC) $(CCFLAGS) $(DBX) -c newdb.c
60
61 database.h: dungeon
62         ./dungeon
63
64 newdb.c newdb.h:
65         python3 newdungeon.py
66
67 linenoise.o:    linenoise/linenoise.h
68         $(CC) -c linenoise/linenoise.c
69
70 dungeon: dungeon.o common.o
71         $(CC) $(CCFLAGS) -o $@ dungeon.o common.o
72
73 clean:
74         rm -f *.o advent *.html database.h dungeon *.gcno *.gcda
75         rm -f newdb.c newdb.h
76         rm -f README advent.6 MANIFEST *.tar.gz
77         rm -f *~
78         rm -f .*~
79         cd tests; $(MAKE) --quiet clean
80
81 check: advent
82         cd tests; $(MAKE) --quiet
83
84 .SUFFIXES: .adoc .html .6
85
86 # Requires asciidoc and xsltproc/docbook stylesheets.
87 .adoc.6:
88         a2x --doctype manpage --format manpage $<
89 .adoc.html:
90         asciidoc $<
91 .adoc:
92         asciidoc $<
93
94 html: advent.html history.html hints.html
95
96 # README.adoc exists because that filename is magic on GitLab.
97 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
98 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
99
100 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
101 # This is a requirement for testing dist in GitLab's CI pipeline
102 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
103         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
104         @(ln -s . advent-$(VERS))
105         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
106         @(rm advent-$(VERS))
107
108 indent:
109         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
110
111 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
112         shipper version=$(VERS) | sh -e -x
113
114 refresh: advent.html
115         shipper -N -w version=$(VERS) | sh -e -x
116
117 dist: advent-$(VERS).tar.gz
118
119 linty: CCFLAGS += -W -Wall -Wextra -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wfloat-equal -Wcast-align -Wwrite-strings -Waggregate-return -Wcast-qual -Wswitch-enum -Wwrite-strings -Wunreachable-code -Winit-self -Wpointer-arith -O2 
120 linty: advent
121
122 debug: CCFLAGS += -O0 --coverage -g
123 debug: advent