Make include of dependency platform-generic
[open-adventure.git] / Makefile
1 # Makefile for the open-source release of adventure 2.5
2
3 # To build with save/resume disabled, pass CCFLAGS="-D ADVENT_NOSAVE"
4
5 VERS=$(shell sed -n <NEWS '/^[0-9]/s/:.*//p' | head -1)
6
7 .PHONY: debug indent release refresh dist linty html clean
8 .PHONY: check coverage
9
10 CC?=gcc
11 CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2
12 LIBS=$(shell pkg-config --libs libedit)
13 INC+=$(shell pkg-config --cflags libedit)
14
15 UNAME_S := $(shell uname -s)
16 ifeq ($(UNAME_S),Linux)
17         LIBS+=-lrt
18 endif
19
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
23
24 .c.o:
25         $(CC) $(CCFLAGS) $(INC) $(DBX) -c $<
26
27 advent: $(OBJS) dungeon.o
28         $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) dungeon.o $(LDFLAGS) $(LIBS)
29
30 main.o:         advent.h dungeon.h
31
32 init.o:         advent.h dungeon.h
33
34 actions.o:      advent.h dungeon.h
35
36 score.o:        advent.h dungeon.h
37
38 misc.o:         advent.h dungeon.h
39
40 cheat.o:        advent.h dungeon.h
41
42 saveresume.o:   advent.h dungeon.h
43
44 dungeon.o:      dungeon.c dungeon.h
45         $(CC) $(CCFLAGS) $(DBX) -c dungeon.c
46
47 dungeon.c dungeon.h: make_dungeon.py adventure.yaml
48         python3 make_dungeon.py
49
50 clean:
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
54         rm -f *~
55         rm -f .*~
56         rm -rf coverage advent.info
57         cd tests; $(MAKE) --quiet clean
58
59
60 cheat: $(CHEAT_OBJS) dungeon.o
61         $(CC) $(CCFLAGS) $(DBX) -o cheat $(CHEAT_OBJS) dungeon.o $(LDFLAGS) $(LIBS)
62
63 check: advent cheat
64         cd tests; $(MAKE) --quiet
65
66 coverage: debug cheat
67         cd tests; $(MAKE) coverage --quiet
68
69 .SUFFIXES: .adoc .html .6
70
71 # Requires asciidoc and xsltproc/docbook stylesheets.
72 .adoc.6:
73         a2x --doctype manpage --format manpage $<
74 .adoc.html:
75         asciidoc $<
76 .adoc:
77         asciidoc $<
78
79 html: advent.html history.html hints.html
80
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
84
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)
91         @(rm advent-$(VERS))
92
93 indent:
94         astyle -n -A3 --pad-header --min-conditional-indent=1 --pad-oper *.c
95
96 release: advent-$(VERS).tar.gz advent.html history.html hints.html notes.html
97         shipper version=$(VERS) | sh -e -x
98
99 refresh: advent.html notes.html history.html
100         shipper -N -w version=$(VERS) | sh -e -x
101
102 dist: advent-$(VERS).tar.gz
103
104 linty: CCFLAGS += -W
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
123 linty: advent
124
125 debug: CCFLAGS += -O0 --coverage -ggdb
126 debug: linty
127 debug: cheat
128