1 # Makefile for the open-source release of adventure 2.5
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:
6 # git submodule update --recursive --remote --init
8 # Therafter, you can update it like this:
10 # git submodule update --recursive --remote
12 # but this should seldom be necessary as that library is pretty stable.
14 # You will also need Python 3 YAML. Under Debian or ubuntu:
16 # apt-get install python3-yaml
18 # If you have pip installed,
22 # If you are using MacPorts on OS X:
23 # port install py3{5,6}-yaml as appropriate for your Python 3 version.
25 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
27 .PHONY: debug indent release refresh dist linty html clean
32 CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic -O2
34 UNAME_S := $(shell uname -s)
35 ifeq ($(UNAME_S),Linux)
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) dungeon.c advent.h common.h adventure.text Makefile control linenoise/linenoise.[ch] newdungeon.py
44 $(CC) $(CCFLAGS) $(DBX) -c $<
46 advent: $(OBJS) linenoise.o newdb.o
47 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) newdb.o linenoise.o $(LDFLAGS) $(LIBS)
49 main.o: advent.h database.h common.h newdb.h
51 init.o: advent.h database.h common.h newdb.h
53 actions.o: advent.h database.h common.h newdb.h
55 score.o: advent.h database.h common.h newdb.h
57 misc.o: advent.h database.h common.h newdb.h
59 cheat.o: advent.h database.h common.h newdb.h
61 saveresume.o: advent.h database.h common.h newdb.h
65 dungeon.o: common.h newdb.h
67 newdb.o: newdb.c newdb.h
68 $(CC) $(CCFLAGS) $(DBX) -c newdb.c
73 newdb.c newdb.h: newdungeon.py adventure.yaml
76 linenoise.o: linenoise/linenoise.h
77 $(CC) -c linenoise/linenoise.c
79 dungeon: dungeon.o common.o
80 $(CC) $(CCFLAGS) -o $@ dungeon.o common.o
83 rm -f *.o advent *.html database.h dungeon *.gcno *.gcda
85 rm -f README advent.6 MANIFEST *.tar.gz
88 cd tests; $(MAKE) --quiet clean
91 cheat: $(CHEAT_OBJS) linenoise.o newdb.o
92 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) linenoise.o newdb.o $(LDFLAGS) $(LIBS)
95 cd tests; $(MAKE) --quiet
97 .SUFFIXES: .adoc .html .6
99 # Requires asciidoc and xsltproc/docbook stylesheets.
101 a2x --doctype manpage --format manpage $<
107 html: advent.html history.html hints.html
109 # README.adoc exists because that filename is magic on GitLab.
110 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
111 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
113 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
114 # This is a requirement for testing dist in GitLab's CI pipeline
115 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
116 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
117 @(ln -s . advent-$(VERS))
118 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
122 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
124 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
125 shipper version=$(VERS) | sh -e -x
127 refresh: advent.html notes.html history.html
128 shipper -N -w version=$(VERS) | sh -e -x
130 dist: advent-$(VERS).tar.gz
133 linty: CCFLAGS += -Wall
134 linty: CCFLAGS += -Wextra
135 linty: CCFLAGS += -Wundef
136 linty: CCFLAGS += -Wstrict-prototypes
137 linty: CCFLAGS += -Wmissing-prototypes
138 linty: CCFLAGS += -Wmissing-declarations
139 linty: CCFLAGS += -Wshadow
140 linty: CCFLAGS += -Wfloat-equal
141 linty: CCFLAGS += -Wcast-align
142 linty: CCFLAGS += -Wwrite-strings
143 linty: CCFLAGS += -Waggregate-return
144 linty: CCFLAGS += -Wcast-qual
145 linty: CCFLAGS += -Wswitch-enum
146 linty: CCFLAGS += -Wwrite-strings
147 linty: CCFLAGS += -Wunreachable-code
148 linty: CCFLAGS += -Winit-self
149 linty: CCFLAGS += -Wpointer-arith
152 debug: CCFLAGS += -O0 --coverage -ggdb