-
Notifications
You must be signed in to change notification settings - Fork 108
/
Makefile.plugin
199 lines (167 loc) · 5.91 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
#############################################################################
# Generic Makefile for plugins on Win32
#############################################################################
#
# The following variables can be overridden in the platform Makefile, e.g.
# platforms/win32/plugins/BochsIA32Plugin/Makefile. Look at
# platforms/win32/plugins/*/Makefile for examples.
#
# EXCLUDESRC defines patterns of source files to not compile, e.g. %/dump.c
# PREREQUISITES supplies names of files that must exist to make lib or bundle
# 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 src/vm source directory?
# PLATDIR: Where is the root of the platforms tree?
# BUILDDIR: Which directory should objects be compiled into?
#############################################################################
# Standard directory locations:
# CROSSDIR: The location of the cross platform sources
# WIN32DIR: The location of the win32 sources
# MAKERDIR: The location of the VMMaker generated sources
# BUILDDIR: The location where the plugin is built
#
CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME)
WIN32DIR:= $(PLATDIR)/win32/plugins/$(LIBNAME)
MAKERDIR:= $(PLUGINSRCDIR)/plugins/$(LIBNAME)
BUILDDIR:= $(BUILD)/$(LIBNAME)
# Support directory locations
CROSSVMDIR:=$(PLATDIR)/Cross/vm
WIN32VMDIR:=$(PLATDIR)/win32/vm
INCLUDES:= -I. \
-I$(VMSRCDIR) -I$(WIN32VMDIR) -I$(CROSSVMDIR) \
-I$(MAKERDIR) -I$(WIN32DIR) -I$(CROSSDIR)
#############################################################################
# If no source files were given, use standard set
#
CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp)
WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp)
MAKERSRC:= $(wildcard $(MAKERDIR)/*.c)
LIBSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC))
ifneq ($(EXCLUDESRC),)
LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC))
endif
#############################################################################
# C compiler settings (gcc 4.x)
#
include ../common/Makefile.tools
# overrides of default toolchain settings
ifeq ($(CONFIGURATION),product)
OFLAGS:= -O1 -march=pentium4 -momit-leaf-frame-pointer -funroll-loops
NDEBUG:=-DNDEBUG
DEBUGVM=0
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -O1 -march=pentium4 -fno-omit-frame-pointer
DEBUGVM=0
NDEBUG:=
else
OFLAGS:= -march=pentium4
DEBUGVM=1
NDEBUG:=
endif
XDEFS:=
DEFS:= $(WINVER) -DWIN32=1 -DNO_ISNAN \
-DNO_SERVICE \
$(NDEBUG) -DLSB_FIRST -DVM_NAME=\"$(VM)\" -DX86 $(XDEFS)
CFLAGS:= -msse2 -ggdb2 -m32 -mdll \
-mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) $(COGDEFS)
#############################################################################
# DLL 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++.
#
OPTSTRIP:= echo not doing strip
.SUFFIXES: .c .cpp .o .s .rc .res .dep
#############################################################################
# Plugin settings
#
OBJDIR:= $(BUILD)/$(LIBNAME)
VMDIR:= $(BUILD)/vm
PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib
PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll
LIBOBJ ?= $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LIBSRC)))
LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ))
ifdef BIT_IDENTICAL_FLOATING_POINT
LIBOBJ+=$(BUILD)/fdlibm/libm.a $(LIBS)
endif
VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR)
all: $(PLUGINLIB) $(PLUGINDLL)
.PHONY : print-settings
print-settings:
$(info ---------------- Makefile settings ------------------)
$(info VPATH=$(VPATH))
$(info INCLUDES=$(INCLUDES))
$(info CFLAGS=$(CFLAGS))
$(info ALLFLAGS=$(ALLFLAGS))
$(info PLUGINSRCDIR=$(PLUGINSRCDIR))
$(info VMSRCDIR=$(VMSRCDIR))
$(info CROSSDIR=$(CROSSDIR))
$(info WIN32DIR=$(WIN32DIR))
$(info MAKERDIR=$(MAKERDIR))
$(info CROSSSRC=$(CROSSSRC))
$(info WIN32SRC=$(WIN32SRC))
$(info MAKERSRC=$(MAKERSRC))
$(info LIBSRC=$(LIBSRC))
$(info LIBOBJ=$(LIBOBJ))
$(info OBJDIR=$(OBJDIR))
$(info VMDIR=$(VMDIR))
$(info PLUGINLIB=$(PLUGINLIB))
$(info PLUGINDLL=$(PLUGINDLL))
$(info -----------------------------------------------------)
$(OBJDIR):
mkdir $(OBJDIR)
$(VMDIR):
mkdir $(VMDIR)
# If any prerequisites are declared all must exist to continue
ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES)))
$(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ)
-$(RM) $(PLUGINLIB)
$(AR) $(ARFLAGS) $(PLUGINLIB) $(LIBOBJ)
$(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ)
$(DLLTOOL) \
--output-def $(OBJDIR)/$(LIBNAME).def \
--output-exp $(OBJDIR)/$(LIBNAME).exp \
--output-lib $(OBJDIR)/$(LIBNAME).lib \
$(DLLTOOLEXTRAS) \
$(LIBOBJ)
ifneq ($(LINK_WITH_GCC),)
$(CC) -shared \
-m32 \
-def $(OBJDIR)/$(LIBNAME).def \
-o $(VMDIR)/$(LIBNAME).dll \
--entry _DllMain@12 \
$(GCCLINKEXTRAS) \
$(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS)
else ifneq ($(LINK_WITH_GPP),)
$(CXX) -shared \
-m32 \
-def $(OBJDIR)/$(LIBNAME).def \
-o $(VMDIR)/$(LIBNAME).dll \
--entry _DllMain@12 \
$(GPPLINKEXTRAS) \
$(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS)
else
$(DLLWRAP) -mwindows \
-def $(OBJDIR)/$(LIBNAME).def \
-o $(VMDIR)/$(LIBNAME).dll \
--entry _DllMain@12 \
$(DLLWRAPEXTRAS) \
$(OBJDIR)/$(LIBNAME).exp \
$(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS)
endif
$(OPTSTRIP) --strip-all $(VMDIR)/$(LIBNAME).dll
-$(RM) $(OBJDIR)/$(LIBNAME).lib
#############################################################################
# Rules for automated builds
#
include ../common/Makefile.rules
else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES))
# If any prerequisites are missing simply create a .ignore file
$(PLUGINLIB): FORCE
$(warning $(PLUGINLIB) has missing prerequisites. Not building.)
echo >$(basename $(PLUGINLIB)).ignore
$(PLUGINDLL): FORCE
$(warning $(PLUGINDLL) has missing prerequisites. Not building.)
echo >$(basename $(PLUGINDLL)).ignore
FORCE:
endif # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES))