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