-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
198 lines (147 loc) · 4.25 KB
/
Makefile
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Note:
#
# unit.i - a template interface of a unit (an mcp include file)
#
# unit_impl.i - a template implementation of a unit (an mcp
# include file)
#
# unit.pas.mcp - the unit template to be processed by
# mcp; it &includes unit.i and unit_impl.i
#
# unit.mac - mcp macros exported from the unit
#
# unit_impl.mac - mcp macros used only in the implementation of the
# unit
#
# unit.mcp - mcp defines automatically generated from unit.i with
# mktempl
#
# unit_impl.mcp - mcp defines automatically generated from unit_impl.i with
# mktempl
#
# unit.defs - mcp defines from interfaces of units used by the unit;
# generated automatically by mkdeps
#
# unit.pas is generated from unit.pas.mcp, but it also depends on
# unit.i and unit_impl.i (which are &included in unit.pas.mcp), and on
# unit.mcp and unit_impl.mcp
ifneq ($(findstring test, $(MAKECMDGOALS)),)
TEST = true
DEBUG = true
endif
ifneq ($(findstring tests, $(MAKECMDGOALS)),)
TEST = true
DEBUG = true
endif
ifneq ($(findstring check, $(MAKECMDGOALS)),)
RELEASE = true
endif
ifneq ($(findstring smart, $(MAKECMDGOALS)),)
SMART = true
endif
ifneq ($(findstring release, $(MAKECMDGOALS)),)
RELEASE = true
endif
ifneq ($(findstring debug, $(MAKECMDGOALS)),)
DEBUG = true
endif
ifneq ($(findstring windows, $(MAKECMDGOALS)),)
WINDOWS = true
endif
ifneq ($(findstring docs, $(MAKECMDGOALS)),)
DOCS = true
endif
override OPTS += -fPIC -Si -S2 -Sh -Futests/units
ifdef SMART
override OPTS += -CX
endif
ifdef RELEASE
override OPTS += -Ur -O3 -v0
endif
ifdef DEBUG
override OPTS += -vewn -Sa -g -gl -gh -dDEBUG_PASCAL_ADT
endif
ifdef TEST
override OPTS += -dTEST_PASCAL_ADT
endif
ifdef WINDOWS
override OPTS += -dPASCAL_ADT_WINDOWS -Twin32
endif
ifdef DOCS
override MCP_OPTS += -dMCP_SRCDOC
endif
VPATH = tests:tests/units
obj_suffix :=.o
prog_suffix :=
static_lib_suffix :=.a
dynamic_lib_suffix :=.so
FPC := fpc
MCP := tools/mcp
MKTEMPL := tools/mktempl
override MCP_OPTS += --ignore-case
MKTEMPL_OPTS := -f -p _mcp_prefix -p Key:_mcp_key_prefix -p Item:_mcp_item_prefix
PASMCPFILES := $(wildcard *.pas.mcp)
MACFILES := $(wildcard *.mac)
MCPFILES := $(patsubst %.i, %.mcp, $(wildcard *.i))
INTERFACE_I_FILES := $(patsubst %.pas.mcp, %.i, $(wildcard *.pas.mcp))
PASFILES := adtmsg.pas adtexcept.pas
ALLPASFILES := $(patsubst %.pas.mcp, %.pas, $(wildcard *.pas.mcp))
ADTUNITS := $(patsubst %.pas, %$(obj_suffix), $(ALLPASFILES))
TESTPROGS := $(patsubst %.pas, %$(prog_suffix), $(wildcard tests/*.pas))
TESTUNITS := $(patsubst %.pas, %$(obj_suffix), $(wildcard tests/units/*.pas))
DEMOPROGS := $(patsubst %.pas, %$(prog_suffix), $(wildcard demo/customer/*.pas))
TOOLSDEPS := $(wildcard tools/*.pas tools/*.c tools/*.h)
.PHONY : test install static dynamic smart all units tests debug demo windows docs clean cleandocs cleanprogs fastclean tools check
all : units tests
test : units tests
cd tests && ./testall.sh
install :
./install.sh
static : units
ppumove -s -o pascaladt$(VER)$(static_lib_suffix) *.ppu
dynamic : units
ppumove -o pascaladt$(VER)$(dynamic_lib_suffix) *.ppu
smart : units
ppumove -s -o pascaladt$(VER)$(static_lib_suffix) *.ppu
units : $(ADTUNITS)
tests : units $(TESTPROGS) $(TESTUNITS)
debug : units tests
demo : units $(DEMOPROGS)
windows : units
tools : tools.dep
tools.dep : $(TOOLSDEPS)
cd tools; $(MAKE)
touch tools.dep
docs : $(ALLPASFILES)
if [ ! -d docs ]; then mkdir docs; fi
srcdoc -bd -t "PascalAdt $(VER) documentation" -o ./docs *.pas ./docsrc/*.txt ./docsrc/*.srd
# output from the cleanup script should be ignored - it would produce
# too much grabage
clean :
-./cleanup.sh noprompt > /dev/null 2>&1
-cd tools; $(MAKE) clean > /dev/null 2>&1
cleandocs :
-rm -rf docs
cleanprogs :
-cd tests; ./rmtestprogs.sh > /dev/null 2>&1
fastclean :
-./cleanup.sh fast > /dev/null 2>&1
check : tests
cd tests; ./testall.sh
Makefile : deps.mak
deps.mak : $(PASFILES) $(PASMCPFILES) tools.dep
tools/mkdeps *.pas.mcp tests/*.pas tests/units/*.pas > deps.mak
touch Makefile
include deps.mak
adtmap.mcp : adtmap.i
$(MKTEMPL) -f -p _mcp_map_prefix adtmap.i
adtmap_impl.mcp : adtmap_impl.i
$(MKTEMPL) -f -p _mcp_map_prefix adtmap_impl.i
%$(prog_suffix) : %.pas
$(FPC) $(OPTS) -o$@ $<
%$(obj_suffix) : %.pas
$(FPC) $(OPTS) -o$@ $<
%.pas : %.pas.mcp
$(MCP) $(MCP_OPTS) $<
%.mcp : %.i
$(MKTEMPL) $(MKTEMPL_OPTS) $<