/
Makefile.common
176 lines (133 loc) · 5.54 KB
/
Makefile.common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#######################################################################
include ../mk/include_guard.mk
#
# Common rules for building Alan Interpreters
ifneq ($(EMACS),)
JREGROUTPUT = -noansi
endif
ifneq ($(BUILDNUMBER),)
# For snapshots we use buildnumber for version info in app and in filenames
BUILDVERSION = -$(BUILDNUMBER)
endif
CFLAGS += -g -Wall -MMD -funsigned-char -DBUILD=$(BUILDNUMBER)
# Default extension for shared dynamic libraries
SOEXTENSION ?= so
#######################################################################
.PHONY: unit
ifneq ($(CGREEN),yes)
unit:
@echo "No unit tests run, Cgreen not available"
else
unit: cgreenrunnertests isolated_unittests
endif
#######################################################################
.PHONY: clean
clean:
-rm -rf $(UNITTESTS_OBJDIR) $(ARUNOBJDIR) $(WINARUNOBJDIR) arun{,.exe} winarun{,.exe} MacArun*.zip gargoyle*.tgz gargoyle*.pkg ../bin/arun{,.exe} ../bin/winarun{,.exe} ../bin/dumpacd{,.exe} ../bin/glkarun{,.exe} arun.res
###################################################################
#
# Run all tests!
# Interpreter is tested through the regression tests
UNITOUTPUT ?= -c
.PHONY: test
test:
@../bin/jregr -bin ../bin -dir ../regression $(JREGROUTPUT)
@../bin/jregr -bin ../bin -dir ../regression/versions/interpreter $(JREGROUTPUT)
@../bin/jregr -bin ../bin -dir ../regression/tracing $(JREGROUTPUT)
@../bin/jregr -bin ../bin -dir ../regression/saving $(JREGROUTPUT)
@../bin/jregr -bin ../bin -dir ../regression/debug $(JREGROUTPUT)
@../bin/jregr -bin ../bin -dir ../regression/platforms $(JREGROUTPUT)
@../bin/jregr -dir ../regression/restore $(JREGROUTPUT) # Uses sh not the executables
#######################################################################
# Standard console Arun
ARUNOBJDIR = .arun
ARUNOBJECTS = $(addprefix $(ARUNOBJDIR)/,${ARUNSRCS:.c=.o}) $(ARUNOBJDIR)/alan.version.o
# Dependencies
-include $(ARUNOBJECTS:.o=.d)
# Rule to compile objects to subdirectory
$(ARUNOBJECTS): $(ARUNOBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(ARUNOBJDIR):
@mkdir $(ARUNOBJDIR)
arun: $(ARUNOBJDIR) $(ARUNOBJECTS)
$(CC) $(LDFLAGS) -o $@$(EXEEXT) $(ARUNOBJECTS) $(LDLIBS)
cp -f $@$(EXEEXT) ../bin/
#######################################################################
# Build glkterm based arun => glkarun
ifdef GLKARUN_ENABLED
EXTRA_TARGETS += glkarun
else
$(info NOT ENABLED: glkarun - Arun with curses text Glk)
endif
GLKTERM_DEFS = -DHAVE_GLK
GLKTERM_INCLUDE ?= -I$(GLKTERM_ROOT)
GLKTERM_LIBDIR ?= $(GLKTERM_ROOT)
GLKTERM_LIB = -L$(GLKTERM_LIBDIR) -lglkterm
glkarun: CFLAGS += $(GLKTERM_INCLUDE) $(GLKTERM_DEFS)
glkarun: LDLIBS = $(GLKTERM_LIB) $(CURSESLIB)
GLKARUNOBJDIR = .glkarun
GLKARUNOBJECTS = $(addprefix $(GLKARUNOBJDIR)/,${GLKARUNSRCS:.c=.o}) $(GLKARUNOBJDIR)/alan.version.o
-include $(GLKARUNOBJECTS:.o=.d)
$(GLKARUNOBJECTS): $(GLKARUNOBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(GLKARUNOBJDIR):
@mkdir $(GLKARUNOBJDIR)
glkarun: $(GLKARUNOBJDIR) $(GLKARUNOBJECTS)
$(CC) $(LDFLAGS) -o $@ $(GLKARUNOBJECTS) $(LDLIBS)
cp -f $@ ../bin/
#######################################################################
#
# CGreen unit tests of two types:
# - using a main program
# - using cgreen-runner which finds and runs all tests in shared libraries
#
UNITTESTS_OBJDIR = .unittests
CGREENLINKLIB ?= -lcgreen
UNITTESTS_USING_MAIN_OBJECTS = $(addprefix $(UNITTESTS_OBJDIR)/,${UNITTESTS_USING_MAIN_SRCS:.c=.o}) $(UNITTESTS_OBJDIR)/alan.version.o
UNITTESTS_USING_RUNNER_OBJECTS = $(addprefix $(UNITTESTS_OBJDIR)/,${UNITTESTS_USING_RUNNER_SRCS:.c=.o}) $(UNITTESTS_OBJDIR)/alan.version.o
UNITTESTS_ALL_OBJECTS = $(addprefix $(UNITTESTS_OBJDIR)/,${UNITTESTS_ALL_SRCS:.c=.o}) $(UNITTESTS_OBJDIR)/alan.version.o
# Dependencies, if they don't exist yet
-include $(UNITTESTS_USING_MAIN_OBJECTS:.o=.d)
# Rule to compile objects to subdirectory
$(UNITTESTS_OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(UNITTESTS_OBJDIR)/%_tests.o: %_tests.c
$(CC) $(CFLAGS) -o $@ -c $<
# Build the DLL...
unittests.$(SOEXTENSION): $(UNITTESTS_OBJDIR) $(UNITTESTS_USING_RUNNER_OBJECTS) sources.mk
$(CC) $(LDFLAGS) -shared -o $@ $(UNITTESTS_USING_RUNNER_OBJECTS) $(CGREENLINKLIB)
# ... that can be run with the cgreen runner
cgreenrunnertests: CFLAGS += $(CGREENINCLUDE)
cgreenrunnertests: unittests.$(SOEXTENSION)
cgreen-runner ./$^ --suite interpreter_unit_tests $(UNITOUTPUT)
#####################################################################
# Build isolated unittests in shared libs for each module where it can
# be tested in total isolation (with everything else mocked away,
# except some extra objects) using Cgreen
ISOLATED_UNITTESTS_EXTRA_MODULES = memory options lists sysdep
isolated_unittests: SUITE = Interpreter
include ../mk/isolated_unittests.mk
#######################################################################
#
# dumpacd:
#
# Dump Acode file into text format
#
-include .dumpacd/*.d
DUMPACDSRCS = dumpacd.c reverse.c lists.c sysdep.c compatibility.c types.c alan.version.o
DUMPACDOBJDIR = .dumpacd
$(DUMPACDOBJDIR):
@mkdir $(DUMPACDOBJDIR)
DUMPACDOBJECTS = $(addprefix $(DUMPACDOBJDIR)/,${DUMPACDSRCS:.c=.o}) $(DUMPACDOBJDIR)/spa.o
$(DUMPACDOBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(DUMPACDOBJDIR)/spa.o: ../compiler/spa.c
$(CC) $(CFLAGS) -o $@ -c $<
dumpacd: $(DUMPACDOBJDIR) $(DUMPACDOBJECTS)
$(CC) $(LDFLAGS) -o dumpacd -ggdb $(DUMPACDOBJECTS)
cp $@ ../bin/
# Extra dependencies for WinGLK case, really needed? How to make them work in subdirs?
readline.o : resources.h
glkstart.o: glkstart.c args.h types.h sysdep.h acode.h main.h \
glkstart.h glkio.h resources.h utils.h
glkio.o: glkio.c glkio.h