/
Makefile.msvc
320 lines (251 loc) · 9.68 KB
/
Makefile.msvc
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
318
319
320
#############################################################################
# Common Makefile for Win64 VM using MSVC, e.g. 2017 Community, and gnu make
# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC
#
# Do make init to allow make -n to function.
#############################################################################
#############################################################################
# Parameters:
# VM the name of the exe to build, defaults to Squeak (=> Squeak.exe)
# VM_NAME the name the VM will print when reporting, defaults to $(VM)
# VMSRCDIR the directory containing the interpreter, optional cogit and interp.h
# CONFIGURATION configuration of VM to build from product, assert & debug
# THREADING whether to build a multi-threaded FFI VM
# COGDEFS supply any command-line defines to use, and may be null.
.PHONY: all
all: default
VM?=Squeak
VM_NAME?=$(VM)
CONFIGURATION=product
THREADING=single
export VM VM_NAME CONFIGURATION COGDEFS
# Is this a Croquet VM (defaults to OGL instead of D3D)?
CROQUET:=-DCROQUET
#############################################################################
# Default locations
#
ifeq ($(THREADING),multi)
ifeq ($(CONFIGURATION),product)
BUILD:=buildmt
else ifeq ($(CONFIGURATION),assert)
BUILD:=buildmtast
else
BUILD:=buildmtdbg
endif
else
ifeq ($(CONFIGURATION),product)
BUILD:=build
else ifeq ($(CONFIGURATION),assert)
BUILD:=buildast
else
BUILD:=builddbg
endif
endif
PLUGINSRCDIR:= ../../../src
export PLUGINSRCDIR
OBJDIR:= $(BUILD)/vm
PLATDIR:=../../../platforms
export PLATDIR
CROSSDIR:=$(PLATDIR)/Cross/vm
TPDIR:=$(PLATDIR)/Cross/third-party
export TPDIR
WIN32DIR:=$(PLATDIR)/win32/vm
WIN32PLUGINSDIR:=$(PLATDIR)/win32/plugins
WIN32MISCDIR:=$(PLATDIR)/win32/misc
WIN32UTILDIR:=$(PLATDIR)/win32/util
CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp)
WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp)
ifeq ($(THREADING),multi)
MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terpmt.c $(VMSRCDIR)/cogit.c)
else
MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terp.c $(VMSRCDIR)/cogit.c)
endif
VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC))
VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR)
#############################################################################
# Toolchain
#
include ../common/Makefile.msvc.flags
include ../common/Makefile.msvc.tools
#############################################################################
$(shell $(MKDIR) deps >/dev/null) # deps is the dependencies directory
#############################################################################
# The internal (.lib) and external (.dll) plugins
#
include plugins.ext
include plugins.int
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS)))
ifdef BIT_IDENTICAL_FLOATING_POINT
LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS)
export BIT_IDENTICAL_FLOATING_POINT
endif
.PHONY: libs dlls
libs: $(LIBS)
dlls: $(DLLS)
#############################################################################
# The third-party libraries
#
ifneq ($(THIRDPARTYLIBS),)
include ../common/Makefile.lib.extra
THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR)
endif
#############################################################################
# Generic VM source file definitions
#
VMOBJ:= $(VMSRC:.c=.o)
VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ))
#############################################################################
# SqueakVM definitions
#
VMEXE:= $(OBJDIR)/$(VM).exe
CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe
VMDEF:= $(VM).def
VMMAP:= $(OBJDIR)/$(VM).map
CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map
VMLIB:= $(VM).lib
VMRES:= $(VM).res
VMDEFIN:=$(VM).def.in
BTOBJ:= $(OBJDIR)/btext.o
ETOBJ:= $(OBJDIR)/etext.o
JMPASM:=_setjmp-x64.asm
JMPOBJ:=$(OBJDIR)/_setjmp-x64.o
.PRECIOUS: mkNamedPrims.exe
INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC)
.SUFFIXES:
.SUFFIXES: .ccg .cc .c .o .s .i .rc .res .cg .hg .ccg .cpp
#############################################################################
# Common build rules
#
default: print-settings init libs $(VMEXE) $(CONSOLEVMEXE) dlls $(APPPOST)
svnver:
echo $(RC) $(RCFLAGS)
productmt:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) default
product:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) default
assertmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) default
assert:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) default
debugmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) default
debug:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) default
# Do make init to allow make -n to function.
init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe
cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg
clean:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe build deps
cleanmt:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe buildmt deps
cleanast:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe buildast deps
cleanmtast:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe buildmtast deps
cleandbg:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe builddbg deps
cleanmtdbg:
$(RM) -rf sqNamedPrims.h mkNamedPrims.exe buildmtdbg deps
nukelibs:
$(RM) $(LIBS)
nukedlls:
$(RM) $(DLLS)
.PHONY : print-settings
print-settings:
$(info ---------------- Makefile settings ------------------)
$(info CONFIGURATION=$(CONFIGURATION))
$(info THREADING=$(THREADING))
$(info VPATH=$(VPATH))
$(info INCLUDES=$(INCLUDES))
$(info CFLAGS=$(CFLAGS))
$(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS))
$(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS))
$(info OBJDIR=$(OBJDIR))
$(info LIBS=$(LIBS))
$(info DLLS=$(DLLS))
$(info -----------------------------------------------------)
.PHONY : print-objects
print-objects:
$(info ---------------- Makefile objects ------------------)
$(info VMOBJ=$(VMOBJ))
$(info -----------------------------------------------------)
ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore)))
mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c
$(CC) -c $< -o mkNamedPrims.obj
$(LD) /out:$@ mkNamedPrims.obj /subsystem:console /defaultlib:libcmt
$(BTOBJ): $(WIN32MISCDIR)/btext.c
$(CC) -c $< -fomit-frame-pointer -Os $(DASH_O)$@
$(ETOBJ): $(WIN32MISCDIR)/etext.c
$(CC) -c $< -fomit-frame-pointer -Os $(DASH_O)$@
$(JMPOBJ): $(WIN32MISCDIR)/$(JMPASM)
$(CC) -c $< $(DASH_O)$@
vm: $(VMEXE) $(LIBS) $(DLLS)
TZ:=$(shell $(CBD)/date +%Z)
$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ)
$(CC) $(DASH_O)$(OBJDIR)/version.o $(ALLCFLAGS) -D'TZ="$(TZ)"' -c $(WIN32DIR)/version.c
$(LD) $(LDFLAGS) -OUT:$(VMEXE) -MAP:$(VMMAP) \
$(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ)
$(CONSOLEVMEXE): $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ)
$(CC) $(DASH_O)$(OBJDIR)/version.o $(ALLCFLAGS) -D'TZ="$(TZ)"' -c $(WIN32DIR)/version.c
$(LD) $(CONSOLELDFLAGS) -OUT:$(CONSOLEVMEXE) -MAP:$(CONSOLEVMMAP) \
$(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ)
$(OBJDIR):
@-$(MKDIR) $(BUILD)
$(MKDIR) $(OBJDIR)
ifneq ($(INTERNAL_PLUGINS),)
$(MKDIR) $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS))
endif
ifneq ($(EXTERNAL_PLUGINS),)
$(MKDIR) $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS))
endif
#############################################################################
# The exports for named primitives from Squeak (required by VM)
#
$(VMDEF) $(VMLIB): $(VMOBJ)
$(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ)
#############################################################################
# Building plugins
#
.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll
.PHONY: always
# Check for Makefile in win32 plugins directory otherwise use default Makefile
plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.msvc ../common/Makefile.msvc.plugin)))
# Internal plugin. Build as lib then link in lib
$(OBJDIR)/%.lib: always
@-$(MKDIR) $(BUILD)/$(*F)
$(RM) -f $(BUILD)/vm/$(*F).ignore
$(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) \
LIBNAME=$(*F) INTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \
COGDEFS="$(COGDEFS) -DSQUEAK_BUILTIN_PLUGIN=$(*F)" $(OBJDIR)/$(*F).lib
# External plugin. Build as dll and copy to vm dir ($(OBJDIR)).
$(OBJDIR)/%.dll: always
$(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o))
@-$(MKDIR) $(BUILD)/$(*F)
$(RM) -f $(BUILD)/$(*F).ignore
$(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) \
LIBNAME=$(*F) EXTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \
JMPOBJ=$(JMPOBJ) VMLIB=$(OBJDIR)/$(VMLIB) \
COGDEFS="$(COGDEFS) -DSQUEAK_EXTERNAL_PLUGIN=$(*F)" $(OBJDIR)/$(*F).dll
$(BUILD)/fdlibm/libm.a:
@-mkdir -p $(@D)
$(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \
TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote
#############################################################################
# Basic rules
#
include ../common/Makefile.msvc.rules
$(VMRES): $(VM).rc
$(RC) $(RCFLAGS) /Fo $@ $(VM).rc
$(CP) $(VM).exe.manifest $(OBJDIR)
$(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest
resource.o: $(VMRES)
$(CVTRES) /MACHINE:$(ARCH) /OUT:resource.o $(VMRES)
#############################################################################
# Extra specific dependencies
#
sqNamedPrims.h: plugins.int mkNamedPrims.exe
./mkNamedPrims.exe $(INTERNAL_PLUGINS) > sqNamedPrims.h
$(OBJDIR)/sqNamedPrims.o: $(CROSSDIR)/sqNamedPrims.c sqNamedPrims.h