/
Makefile.vm
347 lines (288 loc) · 11.5 KB
/
Makefile.vm
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#############################################################################
# Generic Makefile for Mac OS VM
# Do make getversion to get make -n to work
#
# This is designed to be invoked by Makefile in a specific build directory via
# include ../common/Makefile.app
#
# Parameters:
# VMSRCDIR defines the locaton of the VM source to build. Required.
#
# COGDEFS supply any command-line defines to use, and may be null.
#
# SDK optional specific SDK instead of oldest suitable available version,
# e.g. SDK:=MacOSX10.13.sdk
#
# TARGET_VERSION_MIN optional oldest supported target instead of default 10.7
# e.g. TARGET_VERSION_MIN:=10.11
#
# LINK_WITH_CXX optional, use clang++ to link. Simply set to non-empty
#
# The name of the VM to build, e.g. Squeak or "Newspeak Virtual Machine"
# and its short name, e.g. Squeak or Newspeak, used to choose app icon files.
VM?=Squeak
export VM
SYSTEM?=$(VM)
# PLUGINSRCDIR defines the locaton of the plugin source, the subsets of which
# selected by plugins.int and plugins.ext will be built.
PLUGINSRCDIR?=../../src/plugins
export PLUGINSRCDIR
# CONFIGURATION defines what version of the VM to build, product, assert or
# debug. The default is overridden in the mvm script
CONFIGURATION?=product
export CONFIGURATION
#############################################################################
# Build directories
#
ifeq ($(CONFIGURATION),assert)
BUILD:=buildast
else ifeq ($(CONFIGURATION),debug)
BUILD:=builddbg
else # default CONFIGURATION=product
BUILD:=build
endif
ifeq ($(THREADING),multi)
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c)
else
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c)
endif
$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory
BLDDIR:= $(BUILD)
export BLDDIR
OBJDIR:= $(BLDDIR)/vm
PLATDIR:=../../platforms
export PLATDIR
CROSSDIR:=$(PLATDIR)/Cross/vm
TPDIR:=$(PLATDIR)/Cross/third-party
OSXDIR:=$(PLATDIR)/iOS/vm/OSX
OSXCOMMONDIR:=$(PLATDIR)/iOS/vm/Common
OSXCLASSESDIR:=$(PLATDIR)/iOS/vm/Common/Classes
OSXPLUGINSDIR:=$(PLATDIR)/iOS/plugins
UNIXVMDIR:=$(PLATDIR)/unix/vm
CROSSSRC:= $(wildcard $(CROSSDIR)/*.c)
#XEX:= ... %/sqMacV2Browser.m ...
XEX:=%/sqSqueakMainApplication+screen.m %/sqMacV2Window.m \
%/SqViewBitmapConversion.m
OSXSRC=$(wildcard $(OSXDIR)/*.c) $(wildcard $(OSXDIR)/*.m) \
$(wildcard $(OSXCOMMONDIR)/*.c) $(wildcard $(OSXCOMMONDIR)/*.m) \
$(wildcard $(OSXCLASSESDIR)/*.c) $(wildcard $(OSXCLASSESDIR)/*.m)
OSXSRC:=$(filter-out $(XEX),$(OSXSRC))
UNIXSRC:=$(addprefix $(UNIXVMDIR)/,aio.c sqUnixHeartbeat.c sqUnixSpurMemory.c \
sqUnixThreads.c sqUnixVMProfile.c)
VMSRC:= $(MAKERSRC) $(CROSSSRC) $(OSXSRC) $(UNIXSRC)
VMOBJ:= $(notdir $(VMSRC))
VMOBJ:= $(VMOBJ:.c=.o)
VMOBJ:= $(VMOBJ:.m=.o)
VMOBJ:= $(VMOBJ:.cpp=.o)
VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ))
# N.B. Most important that OSXCOMMONDIR precede OSXDIR so that the above
# exclusion of OSXDIR/sqSqueakMainApplication+screen.m works, since there
# exists a OSXCOMMONDIR/sqSqueakMainApplication+screen.m.
SRCDIRS:=$(VMSRCDIR) $(OSXCOMMONDIR) $(OSXCLASSESDIR) $(OSXDIR) $(UNIXVMDIR) $(CROSSDIR)
VPATH:=$(SRCDIRS)
# Additonal includes are required, eg for SoundPlugin/sqSqueakSoundCoreAudio.h
PluginIncludes := FilePlugin HostWindowPlugin SoundPlugin
OSPluginIncludes := FilePlugin HostWindowPlugin SoundPlugin
SRCDIRS:=$(SRCDIRS) \
$(addprefix $(PLATDIR)/Cross/plugins/,$(PluginIncludes)) \
$(addprefix $(OSXPLUGINSDIR)/,$(OSPluginIncludes))
# The internal (.lib) and external (.bundle) plugins
#
include plugins.int
include plugins.ext
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
BUNDLES:= $(addprefix $(OBJDIR)/, $(addsuffix .bundle, $(EXTERNAL_PLUGINS)))
ifdef BIT_IDENTICAL_FLOATING_POINT
LIBS:=$(LIBS) $(BLDDIR)/fdlibm/libm.a
endif
# VM config flags.
ifeq ($(CONFIGURATION),debug)
OFLAGS:= -g -O0 -fno-omit-frame-pointer
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -g -O1 -fno-omit-frame-pointer
DEBUGVM=-DDEBUGVM=0
else # default CONFIGURATION=product
OFLAGS:= -g -Os
DEBUGVM=-DDEBUGVM=0 -DNDEBUG=1 # Define NDEBUG for production to exclude asserts
endif
TZ:=$(shell date +%Z)
DEFS:= $(COGDEFS) -DUSE_GLOBAL_STRUCT=0 -DNO_ISNAN=1 \
-DUSE_INLINE_MEMORY_ACCESSORS -D'TZ="$(TZ)"' \
-DUSE_METAL=1 -DHAVE_CONFIG_H=1
XDEFS:= -DSQUEAK_BUILTIN_PLUGIN
CFLAGS:= $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(DEFS) $(XDEFS)
INCLUDES:= $(addprefix -I,. $(SRCDIRS))
#############################################################################
# Linker settings
#
LD:= gcc
#############################################################################
# Ensure version control info is up-to-date, and extract it from the file.
#
SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h
ifneq ($(shell grep 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),)
$(shell bash -c "cd ../../scripts; ./updateSCCSVersions")
endif
SVNREV:= $(shell sed -e "s/^static.*GitRawRevisionString.*Rev: \([0-9][0-9]*\).*/\\1/p" -e d $(SCCSVER))
#############################################################################
# Common build rules
#
include ../common/Makefile.rules
svnver:
@-echo $(SVNREV)
getversion: $(OSXCOMMONDIR)/version.c deps/version.d $(CROSSDIR)/sqSCCSVersion.h
$(CC) -x c -DVERSION_PROGRAM=1 $(ALLFLAGS) $(INCLUDES) $< -o $@
$(POSTCOMPILE)
-include deps/version.d
product:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product $(@,product=) default
assert:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert $(@,assert=) default
debug:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug $(@,debug=) default
productilc:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product build/vm/validImage
assertilc:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert buildast/vm/validImage
debugilc:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug builddbg/vm/validImage
cleanallvm: cleandeps cleanvm cleanvmast cleanvmdbg cleangv
cleandeps:
rm -rf deps
cleanvm:
rm -rf sqNamedPrims.h build
cleanvmast:
rm -rf sqNamedPrims.h buildast
cleanvmdbg:
rm -rf sqNamedPrims.h builddbg
cleangv:
rm -rf getversion getversion.*
print-source:
$(info ---------------- Makefile.vm sources ------------------)
$(info CROSSSRC=$(CROSSSRC))
$(info OSXSRC=$(OSXSRC))
$(info MAKERSRC=$(MAKERSRC))
$(info UNIXSRC=$(UNIXSRC))
$(info VMSRC=$(VMSRC))
print-settings:
$(info ---------------- Makefile.vm settings ------------------)
$(info CONFIGURATION=$(CONFIGURATION))
$(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 BUNDLES=$(BUNDLES))
$(info SDK=$(SDK))
$(info -----------------------------------------------------)
print-deps:
$(info ---------------- Makefile.vm dep files ------------------)
$(info deps=$(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC)))))
$(info ---------------- Makefile.vm dep files ------------------)
print-objects:
$(info ---------------- Makefile.vm objects ------------------)
$(info VMOBJ=$(VMOBJ))
$(info -----------------------------------------------------)
ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore)))
$(OBJDIR)/$(VM): $(OBJDIR) $(VMOBJ) $(LIBS)
$(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(OSXCOMMONDIR)/version.c
ifneq ($(LINK_WITH_CXX),)
$(LDCXX) -arch $(TARGET_ARCH) -mmacosx-version-min=$(TARGET_VERSION_MIN) \
-isysroot $(SDK) $(CXXVERFLAGS) $(LDFLAGS) $(FRAMEWORKS) \
-Wl,-headerpad_max_install_names \
-o $(OBJDIR)/$(VM) $(VMOBJ) $(filter-out $(call ignore), $(LIBS))
else
$(CC) -arch $(TARGET_ARCH) -mmacosx-version-min=$(TARGET_VERSION_MIN) \
-isysroot $(SDK) $(LDFLAGS) $(FRAMEWORKS) \
-Wl,-headerpad_max_install_names \
-o $(OBJDIR)/$(VM) $(VMOBJ) $(filter-out $(call ignore), $(LIBS))
endif
$(OBJDIR)/validImage: $(OBJDIR)/validImage.o $(OBJDIR)/sqUnixSpurMemory.o $(OBJDIR)/sqHeapMap.o
$(LD) -arch $(TARGET_ARCH) -o $@ $^
$(OBJDIR):
@-mkdir -p $(BLDDIR)
mkdir -p $(OBJDIR)
ifneq ($(INTERNAL_PLUGINS),)
mkdir -p $(addprefix $(BLDDIR)/, $(INTERNAL_PLUGINS))
endif
ifneq ($(EXTERNAL_PLUGINS),)
mkdir -p $(addprefix $(BLDDIR)/, $(EXTERNAL_PLUGINS))
endif
validImage: $(OBJDIR) $(OBJDIR)/validImage
#############################################################################
# Building plugins
#
.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle $(OBJDIR)/%.dylib
ifeq ($(USEPLUGINASDYLIB),TRUE)
plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(subst lib,,$(1))/Makefile ../common/Makefile.plugin))
else
plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin))
endif
# Internal plugin. Build as lib then link in lib
# Check for Makefile in iOS plugins directory otherwise use default Makefile
# N.B. PLATDIR *must* be a relative path for this to work
$(OBJDIR)/%.lib: FORCE
@-mkdir -p $(BLDDIR)/$(*F)
test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).* || true
rm -f $(BUILD)/vm/$(*F).ignore
$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
ARCH=$(TARGET_ARCH) TARGET_VERSION_MIN=$(TARGET_VERSION_MIN) \
VMSRCDIR=$(VMSRCDIR) \
LIBNAME=$(*F) COGDEFS="$(COGDEFS)" XDEFS=-DSQUEAK_BUILTIN_PLUGIN \
CXXVERFLAGS="$(CXXVERFLAGS)" $(PLUGINHACK) \
$(OBJDIR)/$(*F).lib
prereqs/%.lib:
@-ls -rlt $(call plugin-makefile,$(*F)) $(wildcard $(*F).ignore) \
$(wildcard $(PLUGINSRCDIR)/$(*F)/*.c) \
$(wildcard $(PLATDIR)/Cross/plugins/$(*F)/*.*) \
$(wildcard $(OSXPLUGINSDIR)/$(*F)/*.*)
# It would be nice to have this abbreviation but it creates havoc eem 2/2016
#%.lib: $(OBJDIR)/%.lib
# make $(MAKEFLAGS) $<
# External plugin. Build as bundle and copy to vm dir ($(OBJDIR)).
# Check for Makefile in iOS plugins directory otherwise use default Makefile
$(OBJDIR)/%.bundle: FORCE
@-mkdir -p $(BLDDIR)/$(*F)
test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).* || true
rm -f $(BUILD)/vm/$(*F).ignore
$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
ARCH=$(TARGET_ARCH) TARGET_VERSION_MIN=$(TARGET_VERSION_MIN) \
VMSRCDIR=$(VMSRCDIR) \
LIBNAME=$(*F) COGDEFS="$(COGDEFS)" \
THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \
CXXVERFLAGS="$(CXXVERFLAGS)" $(PLUGINHACK) \
$(OBJDIR)/$(*F).bundle
# External plugin. Made in the "Pharo way": as a simple dylib to be included in
# Plugins directory
$(OBJDIR)/%.dylib: FORCE
@-mkdir -p $(BLDDIR)/$(*F)
test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).* || true
rm -f $(BUILD)/vm/$(*F).ignore
$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
ARCH=$(TARGET_ARCH) TARGET_VERSION_MIN=$(TARGET_VERSION_MIN) \
VMSRCDIR=$(VMSRCDIR) \
LIBNAME=$(*F) USEPLUGINASDYLIB=TRUE COGDEFS="$(COGDEFS)" \
THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \
CXXVERFLAGS="$(CXXVERFLAGS)" $(PLUGINHACK) \
$(OBJDIR)/$(*F).dylib
# It would be nice to have this abbreviation but it creates havoc eem 2/2016
#%.bundle: $(OBJDIR)/%.bundle
# make $(MAKEFLAGS) $<
$(BLDDIR)/fdlibm/libm.a:
@-mkdir -p $(@D)
$(MAKE) CFLAGS="$(OFLAGS) -arch $(TARGET_ARCH) -D_IEEE_LIBM -isysroot $(SDK)" -C $(@D) \
TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote
FORCE:
.PRECIOUS: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle
#############################################################################
# Extra specific dependencies
#
sqNamedPrims.h: plugins.int
$(PLATDIR)/Cross/util/mkNamedPrims.sh plugins.int > sqNamedPrims.h
$(OBJDIR)/sqNamedPrims.o: sqNamedPrims.c sqNamedPrims.h