-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
317 lines (255 loc) · 6.56 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
###################
# XBASIC Makefile #
###################
SRCDIR=src
SPINDIR=spin
OBJDIR=obj/$(OS)
BINDIR=bin/$(OS)
DRVDIR=include
DIRS = $(OBJDIR) $(BINDIR)
CC=gcc
ECHO=echo
MKDIR=mkdir -p
CFLAGS=-Wall -I$(SRCDIR)/common -I$(SRCDIR)/runtime -I$(SRCDIR)/loader
LDFLAGS=$(CFLAGS)
SPINFLAGS=-Ogxr
ifeq ($(OS),linux)
CFLAGS += -DLINUX
BSTC=bstc.linux
EXT=
OSINT=osint_linux
endif
ifeq ($(OS),cygwin)
CFLAGS += -DCYGWIN
BSTC=bstc
EXT=.exe
OSINT=osint_cygwin
endif
ifeq ($(OS),macosx)
CFLAGS += -DMACOSX
BSTC=bstc.osx
EXT=
OSINT=osint_linux
endif
##################
# DEFAULT TARGET #
##################
.PHONY: all
all: xbcom xload xbint bin2xbasic cache-drivers
run:
$(BINDIR)/xbcom -p15 coginit.bas -r -t
#################
# CLEAN TARGETS #
#################
.PHONY: clean clean-for-release
clean:
@rm -f -r $(OBJDIR)
@rm -f -r $(BINDIR)
@rm -f $(DRVDIR)/*.dat
.PHONY:
clean-all: clean
@rm -f -r obj
@rm -f -r bin
@rm -f $(DRVDIR)/*.dat
.PHONY: clean-for-release
clean-for-release:
@rm -f samples/*.bai
@rm -f samples/*.dat
@rm -f samples/*.tmp
@rm -f samples/*/*.bai
@rm -f samples/*/*.dat
@rm -f samples/*/*.tmp
#####################
# OBJECT FILE LISTS #
#####################
COMOBJS=\
$(OBJDIR)/xb_api.o \
$(OBJDIR)/db_compiler.o \
$(OBJDIR)/db_expr.o \
$(OBJDIR)/db_generate.o \
$(OBJDIR)/db_pasm.o \
$(OBJDIR)/db_scan.o \
$(OBJDIR)/db_statement.o \
$(OBJDIR)/db_symbols.o \
$(OBJDIR)/db_types.o \
$(OBJDIR)/db_wrimage.o
INTOBJS=\
$(OBJDIR)/db_runtime.o \
$(OBJDIR)/db_vmfcn.o \
$(OBJDIR)/db_vmimage.o \
$(OBJDIR)/db_vmint.o \
$(OBJDIR)/db_platform.o
COMMONOBJS=\
$(OBJDIR)/db_config.o \
$(OBJDIR)/db_vmdebug.o \
$(OBJDIR)/db_system.o \
$(OBJDIR)/mem_malloc.o
LOADEROBJS=\
$(OBJDIR)/db_loader.o \
$(OBJDIR)/db_packet.o \
$(OBJDIR)/PLoadLib.o \
$(OBJDIR)/$(OSINT).o \
$(OBJDIR)/serial_helper.o \
$(OBJDIR)/hub_loader.o \
$(OBJDIR)/flash_loader.o \
$(OBJDIR)/xbasic_vm.o
XBCOMOBJS=\
$(OBJDIR)/xbcom.o \
$(COMOBJS) \
$(LOADEROBJS) \
$(COMMONOBJS)
XBINTOBJS=\
$(OBJDIR)/xbint.o \
$(INTOBJS) \
$(COMMONOBJS)
XLOADOBJS=\
$(OBJDIR)/xload.o \
$(LOADEROBJS) \
$(OBJDIR)/db_config.o \
$(OBJDIR)/db_system.o
HDRS=\
$(SRCDIR)/compiler/db_compiler.h \
$(SRCDIR)/compiler/xb_api.h \
$(SRCDIR)/common/db_config.h \
$(SRCDIR)/common/db_image.h \
$(SRCDIR)/common/db_system.h \
$(SRCDIR)/runtime/db_vm.h \
$(SRCDIR)/runtime/db_vmdebug.h \
$(SRCDIR)/runtime/db_vmimage.h
############################################
# SOURCES NEEDED BY THE VISUAL C++ PROJECT #
############################################
HELPER_SRCS=\
$(OBJDIR)/serial_helper.c \
$(OBJDIR)/hub_loader.c \
$(OBJDIR)/flash_loader.c \
$(OBJDIR)/xbasic_vm.c
.PHONY: spin-binaries
spin-binaries: $(OBJDIR) bin2c $(HELPER_SRCS)
SPIN_SRCS=\
$(SPINDIR)/serial_helper.spin \
$(SPINDIR)/hub_loader.spin \
$(SPINDIR)/flash_loader.spin \
$(SPINDIR)/packet_driver.spin \
$(SPINDIR)/vm_runtime.spin \
$(SPINDIR)/vm_interface.spin \
$(SPINDIR)/cache_interface.spin \
$(SPINDIR)/TV.spin \
$(SPINDIR)/TV_Text.spin \
$(SPINDIR)/FullDuplexSerial.spin \
$(SPINDIR)/xbasic_vm.spin \
$(SPINDIR)/c3_cache.spin \
$(SPINDIR)/ssf_cache.spin
#################
# CACHE DRIVERS #
#################
CACHE_DRIVERS=\
$(DRVDIR)/c3_cache.dat \
$(DRVDIR)/ssf_cache.dat
.PHONY: cache-drivers
cache-drivers: $(CACHE_DRIVERS)
##################
# SPIN TO BINARY #
##################
$(OBJDIR)/serial_helper.binary: $(SPINDIR)/serial_helper.spin $(SPIN_SRCS)
@$(BSTC) $(SPINFLAGS) -b -o $(basename $@) $<
@$(ECHO) $@
$(OBJDIR)/%_loader.binary: $(SPINDIR)/%_loader.spin $(SPIN_SRCS)
@$(BSTC) $(SPINFLAGS) -b -o $(basename $@) $<
@$(ECHO) $@
$(OBJDIR)/%.c: $(OBJDIR)/%.binary
@$(BINDIR)/bin2c$(EXT) $< $@
@$(ECHO) $@
###############
# SPIN TO DAT #
###############
$(DRVDIR)/%.dat: $(SPINDIR)/%.spin $(SPIN_SRCS)
@$(BSTC) $(SPINFLAGS) -c -o $(basename $@) $<
@$(ECHO) $@
$(OBJDIR)/%.dat: $(SPINDIR)/%.spin $(SPIN_SRCS)
@$(BSTC) $(SPINFLAGS) -c -o $(basename $@) $<
@$(ECHO) $@
$(OBJDIR)/%.c: $(OBJDIR)/%.dat
@$(BINDIR)/bin2c$(EXT) $< $@
@$(ECHO) $@
################
# MAIN TARGETS #
################
.PHONY: xbcom
xbcom: $(BINDIR)/xbcom$(EXT)
$(BINDIR)/xbcom$(EXT): $(BINDIR) $(OBJDIR) bin2c $(XBCOMOBJS)
@$(CC) $(LDFLAGS) $(XBCOMOBJS) -o $@
@$(ECHO) $@
.PHONY: xbint
xbint: $(BINDIR)/xbint$(EXT)
$(BINDIR)/xbint$(EXT): $(BINDIR) $(OBJDIR) $(XBINTOBJS)
@$(CC) $(LDFLAGS) $(XBINTOBJS) -o $@
@$(ECHO) $@
.PHONY: xload
xload: $(BINDIR)/xload$(EXT)
$(BINDIR)/xload$(EXT): $(BINDIR) $(OBJDIR) bin2c $(XLOADOBJS)
@$(CC) $(LDFLAGS) $(XLOADOBJS) -o $@
@$(ECHO) $@
#########
# RULES #
#########
$(OBJDIR)/%.o: $(SRCDIR)/compiler/%.c $(HDRS)
@$(CC) $(CFLAGS) -c $< -o $@
@$(ECHO) $@
$(OBJDIR)/%.o: $(SRCDIR)/runtime/%.c $(HDRS)
@$(CC) $(CFLAGS) -c $< -o $@
@$(ECHO) $@
$(OBJDIR)/%.o: $(SRCDIR)/loader/%.c $(HDRS)
@$(CC) $(CFLAGS) -c $< -o $@
@$(ECHO) $@
$(OBJDIR)/%.o: $(SRCDIR)/common/%.c $(HDRS)
@$(CC) $(CFLAGS) -c $< -o $@
@$(ECHO) $@
$(OBJDIR)/%.o: $(OBJDIR)/%.c $(HDRS)
@$(CC) $(CFLAGS) -c $< -o $@
@$(ECHO) $@
#########
# TOOLS #
#########
.PHONY: bin2c
bin2c: $(BINDIR)/bin2c$(EXT)
$(BINDIR)/bin2c$(EXT): $(OBJDIR) $(SRCDIR)/tools/bin2c.c
@$(CC) $(CFLAGS) $(LDFLAGS) $(SRCDIR)/tools/bin2c.c -o $@
@$(ECHO) $@
.PHONY: bin2xbasic
bin2xbasic: $(BINDIR)/bin2xbasic$(EXT)
$(BINDIR)/bin2xbasic$(EXT): $(BINDIR) $(OBJDIR) $(SRCDIR)/tools/bin2xbasic.c
@$(CC) $(CFLAGS) $(LDFLAGS) $(SRCDIR)/tools/bin2xbasic.c -o $@
@$(ECHO) $@
###############
# DIRECTORIES #
###############
$(DIRS):
$(MKDIR) $@
###################
# RELEASE TARGETS #
###################
.PHONY: release
release:
rm -rf ../xbasic-rel/xbasic
mkdir -p ../xbasic-rel/xbasic
cp -r src ../xbasic-rel/xbasic
cp -r pasm ../xbasic-rel/xbasic
cp -r spin ../xbasic-rel/xbasic
cp -r include ../xbasic-rel/xbasic
cp -r samples ../xbasic-rel/xbasic
cp syntax.txt ../xbasic-rel/xbasic
cp makefile* ../xbasic-rel/xbasic
cp setenv.* ../xbasic-rel/xbasic
cp *.docx ../xbasic-rel/xbasic
.PHONY: release-win
release-win: $(CACHE_DRIVERS) clean-for-release
rm -rf ../xbasic-rel/xbasic-win
mkdir -p ../xbasic-rel/xbasic-win
mkdir -p ../xbasic-rel/xbasic-win/bin
cp xbcom/Release/xbcom.exe ../xbasic-rel/xbasic-win/bin
cp -r include ../xbasic-rel/xbasic-win
cp -r samples ../xbasic-rel/xbasic-win
cp syntax.txt ../xbasic-rel/xbasic-win
cp setenv.bat ../xbasic-rel/xbasic-win
cp *.docx ../xbasic-rel/xbasic-win