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