Update documentation about the libedit conversion.
[open-adventure.git] / Makefile
1 # Makefile for the open-source release of adventure 2.5
2
3 # The libedit (aka: editline) library is required to build. On
4 # Debian or Ubuntu:
5 #
6 # apt-get install libedit-dev
7
8 # You will also need Python 3 YAML.  Under Debian or ubuntu:
9 #
10 # apt-get install python3-yaml
11 #
12 # If you have pip installed,
13 #
14 # pip3 install PyYAML
15 #
16 # If you are using MacPorts on OS X:
17 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
18 #
19 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
20
21 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
22
23 .PHONY: debug indent release refresh dist linty html clean
24 .PHONY: check coverage
25
26 CC?=gcc
27 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -Wpedantic -O2
28 LIBS=-ledit
29 UNAME_S := $(shell uname -s)
30 ifeq ($(UNAME_S),Linux)
31         LIBS+=-lrt
32 endif
33
34 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
35 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
36 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py
37
38 .c.o:
39         $(CC) $(CCFLAGS) $(DBX) -c $<
40
41 advent: $(OBJS) dungeon.o
42         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
43
44 main.o:         advent.h dungeon.h
45
46 init.o:         advent.h dungeon.h
47
48 actions.o:      advent.h dungeon.h
49
50 score.o:        advent.h dungeon.h
51
52 misc.o:         advent.h dungeon.h
53
54 cheat.o:        advent.h dungeon.h
55
56 saveresume.o:   advent.h dungeon.h
57
58 dungeon.o:      dungeon.c dungeon.h
59         $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
60
61 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
62         python3 make_dungeon.py
63
64 clean:
65         rm -f *.o advent cheat *.html *.gcno *.gcda
66         rm -f dungeon.c dungeon.h
67         rm -f README advent.6 MANIFEST *.tar.gz
68         rm -f *~
69         rm -f .*~
70         rm -rf coverage advent.info
71         cd tests; $(MAKE) --quiet clean
72
73
74 cheat: $(CHEAT_OBJS) dungeon.o
75         $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
76
77 check: advent cheat
78         cd tests; $(MAKE) --quiet
79
80 coverage: debug cheat
81         cd tests; $(MAKE) coverage --quiet
82
83 .SUFFIXES: .adoc .html .6
84
85 # Requires asciidoc and xsltproc/docbook stylesheets.
86 .adoc.6:
87         a2x --doctype manpage --format manpage $<
88 .adoc.html:
89         asciidoc $<
90 .adoc:
91         asciidoc $<
92
93 html: advent.html history.html hints.html
94
95 # README.adoc exists because that filename is magic on GitLab.
96 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
97 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
98
99 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
100 # This is a requirement for testing dist in GitLab's CI pipeline
101 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
102         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
103         @(ln -s . advent-$(VERS))
104         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
105         @(rm advent-$(VERS))
106
107 indent:
108         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
109
110 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
111         shipper version=$(VERS) | sh -e -x
112
113 refresh: advent.html notes.html history.html
114         shipper -N -w version=$(VERS) | sh -e -x
115
116 dist: advent-$(VERS).tar.gz
117
118 linty: CCFLAGS += -W
119 linty: CCFLAGS += -Wall
120 linty: CCFLAGS += -Wextra
121 linty: CCFLAGS += -Wundef
122 linty: CCFLAGS += -Wstrict-prototypes
123 linty: CCFLAGS += -Wmissing-prototypes
124 linty: CCFLAGS += -Wmissing-declarations
125 linty: CCFLAGS += -Wshadow
126 linty: CCFLAGS += -Wfloat-equal
127 linty: CCFLAGS += -Wcast-align
128 linty: CCFLAGS += -Wwrite-strings
129 linty: CCFLAGS += -Waggregate-return
130 linty: CCFLAGS += -Wcast-qual
131 linty: CCFLAGS += -Wswitch-enum
132 linty: CCFLAGS += -Wwrite-strings
133 linty: CCFLAGS += -Wunreachable-code
134 linty: CCFLAGS += -Winit-self
135 linty: CCFLAGS += -Wpointer-arith
136 linty: advent
137
138 debug: CCFLAGS += -O0 --coverage -ggdb
139 debug: linty
140 debug: cheat
141