/
Makefile.plugin
233 lines (196 loc) · 7.53 KB
/
Makefile.plugin
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
#############################################################################
# Generic Makefile for plugins on Cocoa Mac OS X
# Do make getversion to get make -n to work
#
# The following variables can be overridden in the platform Makefile, e.g.
# platforms/iOS/plugins/AioPlugin/Makefile. Look at
# platforms/iOS/plugins/*/Makefile for examples.
#
# CFLAGS adds additional compilation flags to source file compilation
# XCFLAGS adds additional compilation flags after all other flags
# EXCLUDESRC defines patterns of source files to not compile, e.g. %/dump.c
# EXTRALIBS defines additional libraries to link into an external plugin bundle
# INCDIRS defines additonal directories in which to search for includes
# LIBSRC overrides the set of files to compile (if EXCLUDESRC inconvenient)
# LINK_WITH_CPP set to non-empty to link external plugin bundle with c++ runtime
# SRCDIRS supplies additional directories containing files to compile.
# PREREQUISITES supplies names of files that must exist to make lib or bundle
# THIRDPARTYLIBS supplies names for third-party libraries that needs to be built
$(info $$(LIBNAME): $(LIBNAME))
# VM config flags.
ifeq ($(CONFIGURATION),product)
OFLAGS:= -g -Os
AT_MOST_OPT_LEVEL_ONE:=-O1
DEBUGVM=-DDEBUGVM=0 -DNDEBUG=1
BUILD:=build
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -g -O1 -fno-omit-frame-pointer
AT_MOST_OPT_LEVEL_ONE:=-O1
DEBUGVM=-DDEBUGVM=0
BUILD:=buildast
else
OFLAGS:= -g -O0 -fno-omit-frame-pointer
AT_MOST_OPT_LEVEL_ONE:=-O0
DEBUGVM=-DDEBUGVM=1
BUILD:=builddbg
endif
CFLAGS:= $(CFLAGS) $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(XDEFS)
# The following are the four key locations (set via invocation):
# PLUGINSRCDIR: Where is the root of the src/plugins source tree?
# VMSRCDIR: Where is the root of the src vm source tree?
# PLATDIR: Where is the root of the platforms tree?
#############################################################################
# Standard directory locations:
# CROSSDIR: The location of the cross platform sources
# OSXPLGDIR: The location of the iOS sources
# MAKERDIR: The location of the VMMaker generated sources
# BUILDDIR: The location where the plugin is built
#
#PLUGINSRCDIR:= ../../src/plugins
ifeq ($(USEPLUGINASDYLIB),TRUE)
# I do not like to use lib "as is" because that will strip all "lib" occurences, but I do not
# find any better solution :(
LIBDIR:=$(subst lib,,$(LIBNAME))
else
LIBDIR:=$(LIBNAME)
endif
CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBDIR)
OSXDIR:= $(PLATDIR)/iOS/vm/OSX
OSXPLGDIR:= $(PLATDIR)/iOS/plugins/$(LIBDIR)
UNIXDIR:= $(PLATDIR)/unix/vm
MAKERDIR:= $(PLUGINSRCDIR)/$(LIBDIR)
BUILDDIR:= $(BUILD)/$(LIBDIR)
# Support directory locations
CROSSVMDIR:=$(PLATDIR)/Cross/vm
OSXVMDIR:=$(PLATDIR)/iOS/vm/OSX
MAKERVMDIR:=$(VMSRCDIR)
# INCDIRS are where include files are searched for. A superset of SRCDIRS.
INCDIRS:= $(MAKERVMDIR) $(CROSSVMDIR) $(MAKERDIR) $(OSXPLGDIR) $(OSXVMDIR) $(CROSSDIR) $(INCDIRS)
INCLUDES:= $(addprefix -I,. $(INCDIRS))
#############################################################################
# If no source files were given, use standard set
#
SRCDIRS:=$(SRCDIRS) $(MAKERDIR) $(CROSSDIR) $(OSXPLGDIR)
LIBSRC?= $(foreach d,$(SRCDIRS),$(wildcard $(d)/*.c) $(wildcard $(d)/*.cpp) $(wildcard $(d)/*.m))
ifneq ($(EXCLUDESRC),)
LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC))
endif
#############################################################################
# bundle settings
#
# Note: By default DLLTOOL/DLLWRAP do the work for everything related to plugins
# but if LINK_WITH_GCC we use gcc and if LINK_WITH_GPP we use g++.
#
DLLTOOL:= dlltool
DLLWRAP:= dllwrap -mno-cygwin
#OPTSTRIP:= strip # for production
OPTSTRIP:= echo not doing strip
#############################################################################
# Plugin settings
#
OBJDIR:= $(BUILD)/$(LIBNAME)
VMDIR:= $(BUILD)/vm
PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib
PLUGINBUNDLE:= $(VMDIR)/$(LIBNAME).bundle
PLUGINEXE:= $(PLUGINBUNDLE)/Contents/MacOS/$(LIBNAME)
PLUGINDYLIB:= $(VMDIR)/$(LIBNAME).dylib
# https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html
PLUGINPLIST:= $(PLUGINBUNDLE)/Contents/Info.plist
PLUGINICONS:= $(PLUGINBUNDLE)/Contents/Resources/SqueakPlugin.icns
LIBOBJ?=$(notdir $(LIBSRC))
LIBOBJ:=$(patsubst %.c,%.o,$(patsubst %.m,%.o,$(patsubst %.cpp,%.o,$(LIBOBJ))))
LIBOBJ:=$(addprefix $(OBJDIR)/,$(LIBOBJ))
VPATH:= $(SRCDIRS)
# If plugins change from internal to external they must be recompiled.
$(BUILD)/$(LIBNAME)/$(LIBNAME).o: plugins.int plugins.ext
#############################################################################
# Rules for automated builds
include ../common/Makefile.rules
all: $(PLUGINLIB) $(PLUGINBUNDLE) $(PLUGINDYLIB)
print-settings:
@echo ---------------- Makefile.plugin settings ------------------
@echo PWD=$(shell pwd)
@echo MAKEFILE=$(MAKEFILE)
@echo VPATH=$(VPATH)
@echo INCLUDES=$(INCLUDES)
@echo CFLAGS=$(CFLAGS)
@echo PLUGINSRCDIR=$(PLUGINSRCDIR)
@echo VMSRCDIR=$(VMSRCDIR)
@echo CROSSDIR=$(CROSSDIR)
@echo OSXPLGDIR=$(OSXPLGDIR)
@echo OSXDIR=$(OSXDIR)
@echo MAKERDIR=$(MAKERDIR)
@echo CROSSSRC=$(CROSSSRC)
@echo OSXSRC=$(OSXSRC)
@echo MAKERSRC=$(MAKERSRC)
@echo SRCDIRS=$(SRCDIRS)
@echo INCDIRS=$(INCDIRS)
@echo LIBSRC=$(LIBSRC)
@echo LIBOBJ=$(LIBOBJ)
@echo OBJDIR=$(OBJDIR)
@echo VMDIR=$(VMDIR)
@echo PLUGINLIB=$(PLUGINLIB)
@echo PLUGINEXE=$(PLUGINEXE)
@echo PLUGINBUNDLE=$(PLUGINBUNDLE)
@echo deps=$(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC))))
@echo -----------------------------------------------------
$(OBJDIR):
mkdir -p $(OBJDIR)
$(VMDIR):
mkdir -p $(VMDIR)
# If any prerequisites are declared all must exist to continue
ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES)))
$(PLUGINLIB): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
-rm $(PLUGINLIB)
ar -rc $(PLUGINLIB) $(LIBOBJ)
# Either link with normal compiler/linker or with cpp compiler/linker. If
# LINK_WITH_CPP is set, use e.g. clang++
$(PLUGINBUNDLE): $(PLUGINREQS) $(PLUGINEXE) $(PLUGINICONS) $(PLUGINPLIST)
$(PLUGINEXE): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
mkdir -p $(PLUGINBUNDLE)/Contents/MacOS
ifneq ($(LINK_WITH_CPP),)
$(LDCXX) \
$(BFLAGS) \
$(LIBOBJ) $(EXTRALIBS) \
-o $(PLUGINBUNDLE)/Contents/MacOS/$(LIBNAME)
else
$(LD) \
$(BFLAGS) \
$(LIBOBJ) $(EXTRALIBS) \
-o $(PLUGINBUNDLE)/Contents/MacOS/$(LIBNAME)
endif
$(PLUGINICONS): $(OSXDIR)/SqueakPlugin.icns
mkdir -p $(PLUGINBUNDLE)/Contents/Resources
cp -p $< $@
$(PLUGINPLIST): $(PLATDIR)/iOS/plugins/Info.plist getversion
mkdir -p $(PLUGINBUNDLE)/Contents
sed "s/\$$(VERSION)/`./getversion VERSION_TAG`/" $< | \
sed "s/\$(LIBNAME)/$(LIBNAME)/" > $(PLUGINPLIST)
$(PLUGINDYLIB): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
ifneq ($(LINK_WITH_CPP),)
$(LDCXX) \
$(DYFLAGS) \
-install_name @executable_path/Plugins/$(LIBNAME).dylib \
$(LIBOBJ) $(EXTRALIBS) \
-o $(VMDIR)/$(LIBNAME).dylib
else
$(LD) \
$(DYFLAGS) \
-install_name @executable_path/Plugins/$(LIBNAME).dylib \
$(LIBOBJ) $(EXTRALIBS) \
-o $(VMDIR)/$(LIBNAME).dylib
endif
getversion:
make -f ../common/Makefile.vm getversion
else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES))
# If any prerequisites are missing simply create a .ignore file
#$(info $$(PREREQUISITES): $(abspath $(PREREQUISITES)))
#$(info $$(realpath $$(PREREQUISITES)): $(realpath $(PREREQUISITES)))
$(PLUGINLIB): FORCE
$(warning $(PLUGINLIB) has missing prerequisites. Not building.)
echo >$(basename $(PLUGINLIB)).ignore
$(PLUGINBUNDLE): FORCE
$(warning $(PLUGINBUNDLE) has missing prerequisites. Not building.)
echo >$(basename $(PLUGINBUNDLE)).ignore
FORCE:
endif