1 # Makefile for the open-source release of adventure 2.5
3 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
5 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
7 .PHONY: debug indent release refresh dist linty html clean
11 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2
12 LIBS=$(shell pkg-config --libs libedit)
13 INC+=$(shell pkg-config --cflags libedit)
15 UNAME_S := $(shell uname -s)
16 ifeq ($(UNAME_S),Linux)
20 OBJS=main.o init.o actions.o score.o misc.o saveresume.o
21 CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o
22 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py
25 $(CC) $(CCFLAGS) $(INC) $(DBX) -c $<
27 advent: $(OBJS) dungeon.o
28 $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
30 main.o: advent.h dungeon.h
32 init.o: advent.h dungeon.h
34 actions.o: advent.h dungeon.h
36 score.o: advent.h dungeon.h
38 misc.o: advent.h dungeon.h
40 cheat.o: advent.h dungeon.h
42 saveresume.o: advent.h dungeon.h
44 dungeon.o: dungeon.c dungeon.h
45 $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
47 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
48 python3 make_dungeon.py
51 rm -f *.o advent cheat *.html *.gcno *.gcda
52 rm -f dungeon.c dungeon.h
53 rm -f README advent.6 MANIFEST *.tar.gz
56 rm -rf coverage advent.info
57 cd tests; $(MAKE) --quiet clean
60 cheat: $(CHEAT_OBJS) dungeon.o
61 $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
64 cd tests; $(MAKE) --quiet
67 cd tests; $(MAKE) coverage --quiet
69 .SUFFIXES: .adoc .html .6
71 # Requires asciidoc and xsltproc/docbook stylesheets.
73 a2x --doctype manpage --format manpage $<
79 html: advent.html history.html hints.html
81 # README.adoc exists because that filename is magic on GitLab.
82 DOCS=COPYING NEWS README.adoc TODO advent.adoc history.adoc notes.adoc hints.adoc advent.6
83 TESTFILES=tests/*.log tests/*.chk tests/README tests/decheck tests/Makefile
85 # Can't use GNU tar's --transform, needs to build under Alpine Linux.
86 # This is a requirement for testing dist in GitLab's CI pipeline
87 advent-$(VERS).tar.gz: $(SOURCES) $(DOCS)
88 @find $(SOURCES) $(DOCS) $(TESTFILES) -print | sed s:^:advent-$(VERS)/: >MANIFEST
89 @(ln -s . advent-$(VERS))
90 (tar -T MANIFEST -czvf advent-$(VERS).tar.gz)
94 astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
96 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
97 shipper version=$(VERS) | sh -e -x
99 refresh: advent.html notes.html history.html
100 shipper -N -w version=$(VERS) | sh -e -x
102 dist: advent-$(VERS).tar.gz
105 linty: CCFLAGS += -Wall
106 linty: CCFLAGS += -Wextra
107 linty: CCGLAGS += -Wpedantic
108 linty: CCFLAGS += -Wundef
109 linty: CCFLAGS += -Wstrict-prototypes
110 linty: CCFLAGS += -Wmissing-prototypes
111 linty: CCFLAGS += -Wmissing-declarations
112 linty: CCFLAGS += -Wshadow
113 linty: CCFLAGS += -Wfloat-equal
114 linty: CCFLAGS += -Wcast-align
115 linty: CCFLAGS += -Wwrite-strings
116 linty: CCFLAGS += -Waggregate-return
117 linty: CCFLAGS += -Wcast-qual
118 linty: CCFLAGS += -Wswitch-enum
119 linty: CCFLAGS += -Wwrite-strings
120 linty: CCFLAGS += -Wunreachable-code
121 linty: CCFLAGS += -Winit-self
122 linty: CCFLAGS += -Wpointer-arith
125 debug: CCFLAGS += -O0 --coverage -ggdb