VirtualBox

source: vbox/trunk/src/recompiler_new/Makefile.kmk@ 18914

Last change on this file since 18914 was 18914, checked in by vboxsync, 16 years ago

Recompiler: Make the recompiler work on FreeBSD (some math functions have a different name)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1# $Id: Makefile.kmk 18914 2009-04-15 20:48:56Z vboxsync $
2## @file
3# The Recompiler Sub-Makefile.
4#
5#
6# Copyright (C) 2006-2007 Sun Microsystems, Inc.
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17# Clara, CA 95054 USA or visit http://www.sun.com if you need
18# additional information or have any questions.
19#
20
21
22SUB_DEPTH = ../..
23include $(KBUILD_PATH)/subheader.kmk
24
25#
26# Globals
27#
28VBOX_PATH_RECOMPILER_SRC := $(PATH_SUB_CURRENT)
29
30# For 32-bit targets when enabled 64-bit guests we build 2 REM DLLs:
31# with 64-bit support (slow and buggy at the moment) VBOXREM64
32# only 32-bit support (faster, stable, but not suitable for 64-bit guests) VBOXREM32
33# During the runtime, we load appropriate library from VBOXREM, depending on guest settings.
34# 64-bit targets have 64-bit enabled REM by default, so is not part of this mess
35ifeq ($(KBUILD_TARGET_ARCH),x86)
36 ifdef VBOX_WITH_64_BITS_GUESTS
37 VBOX_USE_REM64 := 1
38 endif
39endif
40
41
42TEMPLATE_DUMMY = dummy template (move to kBuild) ## @todo Will be there in the next update, remove this.
43
44if 0
45 #
46 # Template useful for forcing a specific gcc version in case it comes in handy.
47 #
48 TOOL_MYGCC = description
49 TOOL_MYGCC_EXTENDS = GCC3
50 TOOL_MYGCC_CC = $(firstword $(which gcc-4.2 gcc-4.1 gcc-3.4 gcc-3.4.6 gcc-3.3 gcc-3.3.6 gcc-3.2))
51 TOOL_MYGCC_COMPILE_C_DEPEND =
52 TOOL_MYGCC_COMPILE_C_DEPORD =
53 TOOL_MYGCC_COMPILE_C_OUTPUT =
54 define TOOL_MYGCC_COMPILE_C_CMDS
55 $(QUIET)$(TOOL_MYGCC_CC) -c\
56 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
57 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
58 -o $(obj)\
59 $(abspath $(source))
60 endef
61 #Usage: target-i386/op_helper.c_TOOL = MYGCC
62endif
63
64## @todo Note to self (bird): Convert this mess to use NAME (that property didn't exist when the REM_MOD hack was first made I think).
65
66# For 64-bit Windows we currently use gcc (due to MSVC unaware of such a novel
67# thing as C99, a lot of GCC extensions deployed by QEMU and calling convention
68# differences) to cross-compile code to Linux/ELF and dynamically generate invocation wrappers.
69if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.amd64)
70 VBOX_USE_REM2 = 1
71 REM_MOD := VBoxREM2
72else
73 REM_MOD := VBoxREM
74endif
75
76#
77# Target lists (some of them anyways).
78#
79ifdef VBOX_USE_REM2
80 SYSMODS += VBoxREM2
81else
82 ifndef VBOX_USE_REM64
83 DLLS += VBoxREM
84 endif
85endif
86
87
88#
89# The VBoxREM.[dll|so|..] or VBoxREM2.rel.
90#
91ifeq ($(KBUILD_TARGET),win)
92$(REM_MOD)_TEMPLATE = DUMMY
93$(REM_MOD)_TOOL.win.x86 = MINGW32
94$(REM_MOD)_TOOL.win.amd64 = XGCCAMD64LINUX
95$(REM_MOD)_SDKS.win.x86 = W32API
96$(REM_MOD)_ASFLAGS = -x assembler-with-cpp
97$(REM_MOD)_CFLAGS = -Wall -g -fno-omit-frame-pointer -fno-strict-aliasing
98$(REM_MOD)_CFLAGS.debug = -O0
99$(REM_MOD)_CFLAGS.release += -fno-gcse -O2
100$(REM_MOD)_CFLAGS.profile = $($(REM_MOD)_CFLAGS.release)
101$(REM_MOD)_DEFS += IN_RING3 $(ARCH_BITS_DEFS)
102# workaround the regparm bug in gcc <= 3.3
103$(REM_MOD)_DEFS.win.x86 += GCC_WITH_BUGGY_REGPARM
104else # !win
105$(REM_MOD)_TEMPLATE = VBOXR3NP
106# workaround the regparm bug in gcc <= 3.3
107$(REM_MOD)_DEFS = $(if $(VBOX_GCC_BUGGY_REGPARM),GCC_WITH_BUGGY_REGPARM,)
108endif # !win
109$(REM_MOD)_DEFS += IN_REM_R3 REM_INCLUDE_CPU_H
110#$(REM_MOD)_DEFS += REM_PHYS_ADDR_IN_TLB
111$(REM_MOD)_DEFS += VBOX_WITH_NEW_RECOMPILER
112#$(REM_MOD)_DEFS += DEBUG_ALL_LOGGING DEBUG_DISAS DEBUG_PCALL DEBUG_EXEC DEBUG_FLUSH DEBUG_IOPORT DEBUG_SIGNAL DEBUG_TLB_CHECK DEBUG_TB_INVALIDATE DEBUG_TLB # Enables huge amounts of debug logging.
113#$(REM_MOD)_DEFS += DEBUG_TMP_LOGGING # log qemu parts to "/tmp/vbox-qemu.log" - does not work with VBoxREM2.
114$(REM_MOD)_DEFS.linux = _GNU_SOURCE
115ifdef VBOX_SOLARIS_10
116 $(REM_MOD)_DEFS.solaris = HOST_SOLARIS=10
117else
118 $(REM_MOD)_DEFS.solaris = HOST_SOLARIS=11
119endif
120$(REM_MOD)_DEFS.freebsd += _BSD
121
122$(REM_MOD)_INCS = \
123 Sun \
124 target-i386 \
125 tcg \
126 fpu \
127 $(PATH_$(REM_MOD)) \
128 $(PATH_ROOT)/src/VBox/VMM \
129 .
130ifn1of ($($(REM_MOD)_DEFS),DEBUG_TMP_LOGGING)
131$(REM_MOD)_DEFS += LOG_USE_C99
132$(REM_MOD)_INCS <= \
133 Sun/crt
134endif
135
136$(REM_MOD)_SOURCES = \
137 VBoxRecompiler.c \
138 cpu-exec.c \
139 exec.c \
140 translate-all.c \
141 host-utils.c \
142 cutils.c \
143 tcg/tcg.c \
144 tcg/tcg-dyngen.c \
145 tcg/tcg-runtime.c \
146 fpu/softfloat-native.c \
147 target-i386/op_helper.c \
148 target-i386/helper.c \
149 target-i386/translate.c
150
151ifeq ($(KBUILD_TARGET_ARCH),amd64)
152 $(REM_MOD)_DEFS += __x86_64__
153 $(REM_MOD)_INCS += tcg/x86_64
154else
155 $(REM_MOD)_DEFS += __i386__
156 $(REM_MOD)_INCS += tcg/i386
157endif
158
159ifneq ($(KBUILD_TARGET),freebsd)
160$(REM_MOD)_SOURCES.debug += \
161 Sun/testmath.c
162endif
163$(REM_MOD)_SOURCES.win.x86 = $(PATH_VBoxREMImp)/VBoxREMWin.def
164ifndef VBOX_USE_REM2
165 $(REM_MOD)_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
166endif
167ifdef VBOX_USE_REM2
168## @todo spread out where it belongs.
169$(REM_MOD)_TEMPLATE = VBOXNOCRTGAS
170$(REM_MOD)_DEFS += LOG_USE_C99 $(ARCH_BITS_DEFS)
171
172# This doesn't fit in IPRT because it requires GAS and is LGPL.
173$(REM_MOD)_SOURCES += \
174 Sun/e_powl-$(KBUILD_TARGET_ARCH).S
175
176$(REM_MOD)_INCS += \
177 Sun/crt
178$(REM_MOD)_SYSSUFF = .rel
179endif
180ifdef VBOX_USE_REM2
181$(REM_MOD)_LIBS = \
182 $(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB)
183else
184$(REM_MOD)_LIBS = \
185 $(LIB_VMM) \
186 $(LIB_RUNTIME)
187$(REM_MOD)_LIBS.darwin = \
188 $(TARGET_VBoxREMImp)
189endif
190
191## @todo clean up this, there are some duplicates with the template here I think.
192$(REM_MOD)_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(REM_MOD).dylib
193$(REM_MOD)_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib -Wl,--no-undefined
194$(REM_MOD)_LDFLAGS.linux = $(VBOX_LD_as_needed)
195$(REM_MOD)_LDFLAGS.os2 = -Zomf
196$(REM_MOD)_LDFLAGS.debug = -g
197$(REM_MOD)_LDFLAGS.solaris = -mimpure-text
198
199
200if defined(VBOX_USE_REM2) || defined(VBOX_USE_REM64)
201#
202# The VBoxREM2 wrapper.
203#
204DLLS += VBoxREMWrapper
205VBoxREMWrapper_TEMPLATE = VBOXR3
206VBoxREMWrapper_NAME = VBoxREM
207VBoxREMWrapper_DEFS = IN_REM_R3 $(if $(VBOX_WITH_VMI),VBOX_WITH_VMI,)
208VBoxREMWrapper_DEFS += VBOX_WITH_NEW_RECOMPILER
209 ifdef VBOX_USE_REM64
210VBoxREMWrapper_DEFS += VBOX_USE_BITNESS_SELECTOR
211 endif
212VBoxREMWrapper_SOURCES = \
213 VBoxREMWrapper.cpp \
214 $(if $(VBOX_USE_REM2),VBoxREMWrapperA.asm)
215VBoxREMWrapper_LIBS = \
216 $(LIB_VMM) \
217 $(LIB_RUNTIME)
218VBoxREMWrapper_LIBS.darwin += \
219 $(TARGET_VBoxREMImp)
220#VBoxREMWrapper_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxREM.dylib
221endif
222
223
224ifdef VBOX_USE_REM64
225 DLLS += VBoxREM32
226 VBoxREM32_EXTENDS = VBoxREM
227 VBoxREM32_EXTENDS_BY = appending
228 VBoxREM32_TEMPLATE = $(VBoxREM_TEMPLATE)
229 VBoxREM32_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxREM32.dylib
230 VBoxREM32_LIBS.darwin = $(LIB_REM)
231
232 DLLS += VBoxREM64
233 VBoxREM64_EXTENDS = VBoxREM
234 VBoxREM64_EXTENDS_BY = appending
235 VBoxREM64_TEMPLATE = $(VBoxREM_TEMPLATE)
236 VBoxREM64_DEFS = VBOX_ENABLE_VBOXREM64
237 VBoxREM64_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxREM64.dylib
238 VBoxREM64_LIBS.darwin = $(LIB_REM)
239
240endif # USE_VBOXREM64
241
242
243#
244# The VBoxREM import library.
245#
246# This is a HACK to get around (a) the cyclic dependency between VBoxVMM and
247# VBoxREM during linking and (b) the recursive build ordering which means VBoxREM
248# won't be built until after all the other DLLs.
249#
250IMPORT_LIBS += VBoxREMImp
251VBoxREMImp_TEMPLATE = VBOXR3
252 ifn1of ($(KBUILD_TARGET), os2 win)
253VBoxREMImp_NAME = VBoxREM
254 endif
255VBoxREMImp_INST = $(INST_LIB)
256VBoxREMImp_SOURCES.win = $(PATH_VBoxREMImp)/VBoxREMWin.def
257VBoxREMImp_CLEAN.win = $(PATH_VBoxREMImp)/VBoxREMWin.def
258VBoxREMImp_SOURCES.os2 = $(PATH_VBoxREMImp)/VBoxREMOS2.def
259VBoxREMImp_CLEAN.os2 = $(PATH_VBoxREMImp)/VBoxREMOS2.def
260 ifn1of ($(KBUILD_TARGET), os2 win)
261VBoxREMImp_SOURCES = $(PATH_VBoxREMImp)/VBoxREMImp.c
262VBoxREMImp_CLEAN = $(PATH_VBoxREMImp)/VBoxREMImp.c
263 endif
264 ifn1of ($(KBUILD_TARGET), darwin os2 win)
265VBoxREMImp_SONAME = VBoxREM$(SUFF_DLL)
266 endif
267VBoxREMImp_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxREM.dylib
268VBoxREMImp_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib
269
270$$(PATH_VBoxREMImp)/VBoxREMImp.c: $(VBOX_PATH_RECOMPILER_SRC)/VBoxREM.def $(VBOX_PATH_RECOMPILER_SRC)/Sun/deftoimp.sed $(MAKEFILE_CURRENT) | $$(dir $$@)
271 $(call MSG_GENERATE,,$@)
272 $(QUIET)$(APPEND) -t $@ '#ifdef VBOX_HAVE_VISIBILITY_HIDDEN'
273 $(QUIET)$(APPEND) $@ '# define EXPORT __attribute__((visibility("default")))'
274 $(QUIET)$(APPEND) $@ '#else'
275 $(QUIET)$(APPEND) $@ '# define EXPORT'
276 $(QUIET)$(APPEND) $@ '#endif'
277 $(QUIET)$(APPEND) $@ ''
278 $(QUIET)$(SED) -f $(VBOX_PATH_RECOMPILER_SRC)/Sun/deftoimp.sed --append $@ $<
279
280$$(PATH_VBoxREMImp)/VBoxREMOS2.def: $(VBOX_PATH_RECOMPILER_SRC)/VBoxREM.def $(MAKEFILE_CURRENT) | $$(dir $$@)
281 $(SED) \
282 -e 's/^[ \t][ \t]*REMR3/ _REMR3/' \
283 -e 's/\.[Dd][Ll][Ll]//' \
284 -e 's/^LIBRARY .*/LIBRARY VBoxREM INITINSTANCE TERMINSTANCE\nDATA MULTIPLE\n/' \
285 --output $@ \
286 $<
287
288$$(PATH_VBoxREMImp)/VBoxREMWin.def: $(VBOX_PATH_RECOMPILER_SRC)/VBoxREM.def $(MAKEFILE_CURRENT) | $$(dir $$@)
289 $(CP) -f $< $@
290
291
292#
293# The math testcase as a standalone program for testing and debugging purposes.
294#
295## @todo This is a bit messy because of MINGW32.
296testmath_ASFLAGS.amd64 = -m amd64
297testmath_CFLAGS = -Wall -g
298testmath_CFLAGS.release = -O3
299testmath_LDFLAGS = -g
300testmath_DEFS = MATHTEST_STANDALONE
301testmath_DEFS += VBOX_WITH_NEW_RECOMPILER
302testmath_SOURCES = Sun/testmath.c
303
304
305include $(KBUILD_PATH)/subfooter.kmk
306
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette