Jettison MAKEWD(), GETTXT(), vocab(), GETIN(), and the old db compiler.
[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 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
26
27 .PHONY: debug indent release refresh dist linty html clean
28
29 VERS=1.0
30
31 CC?=gcc
32 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic -O2
33 LIBS=
34 UNAME_S := $(shell uname -s)
35 ifeq ($(UNAME_S),Linux)
36         LIBS=-lrt
37 endif
38
39 OBJS=main.o init.o actions.o score.o misc.o saveresume.o common.o
40 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o common.o
41 SOURCES=$(OBJS:.o=.c) advent.h common.h adventure.text adventure.yaml Makefile control linenoise/linenoise.[ch] newdungeon.py
42
43 .c.o:
44         $(CC) $(CCFLAGS) $(DBX) -c $<
45
46 advent: $(OBJS) linenoise.o newdb.o
47         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) newdb.o linenoise.o $(LDFLAGS) $(LIBS)
48
49 main.o:         advent.h common.h newdb.h
50
51 init.o:         advent.h common.h newdb.h
52
53 actions.o:      advent.h common.h newdb.h
54
55 score.o:        advent.h common.h newdb.h
56
57 misc.o:         advent.h common.h newdb.h
58
59 cheat.o:        advent.h common.h newdb.h
60
61 saveresume.o:   advent.h common.h newdb.h
62
63 common.o:       common.h
64
65 newdb.o:        newdb.c newdb.h
66         $(CC) $(CCFLAGS) $(DBX) -c newdb.c
67
68 newdb.c newdb.h: newdungeon.py adventure.yaml
69         python3 newdungeon.py
70
71 linenoise.o:    linenoise/linenoise.h
72         $(CC) $(CCFLAGS) -c linenoise/linenoise.c
73
74 clean:
75         rm -f *.o advent cheat *.html *.gcno *.gcda
76         rm -f newdb.c newdb.h
77         rm -f README advent.6 MANIFEST *.tar.gz
78         rm -f *~
79         rm -f .*~
80         rm -rf coverage advent.info
81         cd tests; $(MAKE) --quiet clean
82
83
84 cheat: $(CHEAT_OBJS) linenoise.o newdb.o 
85         $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) linenoise.o newdb.o $(LDFLAGS) $(LIBS)
86
87 check: advent cheat
88         cd tests; $(MAKE) --quiet
89
90 coverage: debug cheat
91         cd tests; $(MAKE) coverage --quiet
92
93 .SUFFIXES: .adoc .html .6
94
95 # Requires asciidoc and xsltproc/docbook stylesheets.
96 .adoc.6:
97         a2x --doctype manpage --format manpage $<
98 .adoc.html:
99         asciidoc $<
100 .adoc:
101         asciidoc $<
102
103 html: advent.html history.html hints.html
104
105 # README.adoc exists because that filename is magic on GitLab.
106 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
107 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
108
109 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
110 # This is a requirement for testing dist in GitLab's CI pipeline
111 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
112         @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
113         @(ln -s . advent-$(VERS))
114         (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
115         @(rm advent-$(VERS))
116
117 indent:
118         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
119
120 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
121         shipper version=$(VERS) | sh -e -x
122
123 refresh: advent.html notes.html history.html
124         shipper -N -w version=$(VERS) | sh -e -x
125
126 dist: advent-$(VERS).tar.gz
127
128 linty: CCFLAGS += -W
129 linty: CCFLAGS += -Wall
130 linty: CCFLAGS += -Wextra
131 linty: CCFLAGS += -Wundef
132 linty: CCFLAGS += -Wstrict-prototypes
133 linty: CCFLAGS += -Wmissing-prototypes
134 linty: CCFLAGS += -Wmissing-declarations
135 linty: CCFLAGS += -Wshadow
136 linty: CCFLAGS += -Wfloat-equal
137 linty: CCFLAGS += -Wcast-align
138 linty: CCFLAGS += -Wwrite-strings
139 linty: CCFLAGS += -Waggregate-return
140 linty: CCFLAGS += -Wcast-qual
141 linty: CCFLAGS += -Wswitch-enum
142 linty: CCFLAGS += -Wwrite-strings
143 linty: CCFLAGS += -Wunreachable-code
144 linty: CCFLAGS += -Winit-self
145 linty: CCFLAGS += -Wpointer-arith
146 linty: advent
147
148 debug: CCFLAGS += -O0 --coverage -ggdb
149 debug: linty
150 debug: cheat
151
152