1 | # $Id: Makefile.kmk 9561 2008-06-10 09:14:37Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # The Recompiler Makefile.
|
---|
4 | #
|
---|
5 | # There are a few of complicating factors here, esp. on AMD64 systems:
|
---|
6 | #
|
---|
7 | # * op.c doesn't compile work correctly with gcc 4. For this we've
|
---|
8 | # checked in op.S, which is the reason why we don't compile op.c
|
---|
9 | # directly but always compile via the assembly file.s
|
---|
10 | # * On 64-bit Windows we lack a compiler and have to resort to a
|
---|
11 | # linux cross compiler building an ELF relocatable module which
|
---|
12 | # we then load using a wrapper module. Thus the REM_MOD mess.
|
---|
13 | # * On platforms using the 64-bit GCC ABI, we're not allowed to
|
---|
14 | # generate non-PIC shared objects, and op.c requires the code
|
---|
15 | # to be non-PIC. We apply the same trick as we developed for
|
---|
16 | # 64-bit windows.
|
---|
17 | #
|
---|
18 |
|
---|
19 | #
|
---|
20 | # Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
21 | #
|
---|
22 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
23 | # available from http://www.virtualbox.org. This file is free software;
|
---|
24 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
25 | # General Public License (GPL) as published by the Free Software
|
---|
26 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
27 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
28 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
29 | #
|
---|
30 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
31 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
32 | # additional information or have any questions.
|
---|
33 | #
|
---|
34 |
|
---|
35 |
|
---|
36 | DEPTH = ../..
|
---|
37 | include $(KBUILD_PATH)/header.kmk
|
---|
38 |
|
---|
39 |
|
---|
40 | BLDPROGS = dyngen
|
---|
41 | ifneq ($(or $(eq $(KBUILD_TARGET_ARCH),amd64) , $(VBOX_TARGET_MAC_OS_X_VERSION_10_5)),)
|
---|
42 | SYSMODS = VBoxREM2
|
---|
43 | REM_MOD = VBoxREM2
|
---|
44 | else
|
---|
45 | REM_MOD = VBoxREM
|
---|
46 | endif
|
---|
47 | DLLS = VBoxREM
|
---|
48 | IMPORT_LIBS = VBoxREMImp
|
---|
49 |
|
---|
50 | OTHER_CLEAN = \
|
---|
51 | $(PATH_$(REM_MOD))/op.h \
|
---|
52 | $(PATH_$(REM_MOD))/opc.h \
|
---|
53 | $(PATH_$(REM_MOD))/gen-op.h \
|
---|
54 | $(PATH_$(REM_MOD))/opc.h
|
---|
55 |
|
---|
56 | DEFS += REM_PHYS_ADDR_IN_TLB
|
---|
57 |
|
---|
58 | #
|
---|
59 | # L4 must use the no-crt path because it's lacking math stuff it seems...
|
---|
60 | # Darwin must use the non-crt path because it can't compile op.c nativly.
|
---|
61 | # All the AMD64 target must use the no-crt path because ELF doesn't like op.c
|
---|
62 | # when stuffed into a shared library and windows doesn't have 64-bit gcc (yet).
|
---|
63 | #
|
---|
64 | ifeq ($(filter-out l4 darwin freebsd,$(KBUILD_TARGET)),)
|
---|
65 | REM_USE_NOCRT := 1
|
---|
66 | endif
|
---|
67 | ifeq ($(REM_MOD),VBoxREM2)
|
---|
68 | REM_USE_NOCRT := 1
|
---|
69 | endif
|
---|
70 |
|
---|
71 |
|
---|
72 | #
|
---|
73 | # The dyngen build tool.
|
---|
74 | #
|
---|
75 | ifeq ($(KBUILD_HOST),win)
|
---|
76 | dyngen_TOOL = MINGW32
|
---|
77 | dyngen_SDKS = W32API
|
---|
78 | # On 64-bit Windows we pretend to be 32-bit.
|
---|
79 | dyngen_BLD_TRG_ARCH = x86
|
---|
80 | dyngen_BLD_TRG_CPU = i386
|
---|
81 | dyngen_CFLAGS = -Wall -g -fno-strict-aliasing
|
---|
82 | else
|
---|
83 | dyngen_TEMPLATE = VBOXBLDPROG
|
---|
84 | endif
|
---|
85 | ifeq ($(KBUILD_TARGET_ARCH),amd64)
|
---|
86 | dyngen_DEFS += HOST_X86_64=1
|
---|
87 | endif
|
---|
88 | dyngen_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations
|
---|
89 | dyngen_INCS := \
|
---|
90 | Sun \
|
---|
91 | target-i386 \
|
---|
92 | fpu \
|
---|
93 | $(PATH_SUB_CURRENT)
|
---|
94 | dyngen_SOURCES = dyngen.c
|
---|
95 |
|
---|
96 |
|
---|
97 | #
|
---|
98 | # The VBoxREM.[dll|so|..] or VBoxREM2.rel.
|
---|
99 | #
|
---|
100 | $(REM_MOD)_DEFS = IN_REM_R3 REM_INCLUDE_CPU_H
|
---|
101 | #$(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.
|
---|
102 |
|
---|
103 | $(REM_MOD)_INCS = \
|
---|
104 | Sun \
|
---|
105 | Sun/crt\
|
---|
106 | target-i386 \
|
---|
107 | fpu \
|
---|
108 | $(PATH_$(REM_MOD)) \
|
---|
109 | $(PATH_ROOT)/src/VBox/VMM \
|
---|
110 | $(PATH_CURRENT)
|
---|
111 |
|
---|
112 | $(REM_MOD)_SOURCES = \
|
---|
113 | VBoxRecompiler.c \
|
---|
114 | cpu-exec.c \
|
---|
115 | exec.c \
|
---|
116 | translate-all.c \
|
---|
117 | translate-op.c \
|
---|
118 | fpu/softfloat-native.c \
|
---|
119 | target-i386/helper.c \
|
---|
120 | target-i386/helper2.c \
|
---|
121 | target-i386/translate.c
|
---|
122 | $(REM_MOD)_SOURCES.debug = \
|
---|
123 | Sun/testmath.c
|
---|
124 | ifeq ($(filter-out win os2,$(KBUILD_TARGET)),)
|
---|
125 | $(REM_MOD)_SOURCES += target-i386/op.c
|
---|
126 | FILE_OP_OBJ = $(PATH_$(REM_MOD)_target-i386/op.c)/op.o
|
---|
127 | else # The remaining targets can be using gcc-4 and needs checking.
|
---|
128 | $(REM_MOD)_SOURCES += $(PATH_$(REM_MOD))/op.S
|
---|
129 | FILE_OP_OBJ = $(PATH_$(REM_MOD)_$(PATH_$(REM_MOD))/op.S)/op.o
|
---|
130 | $(REM_MOD)_CLEAN = $(FILE_OP_OBJ) $(PATH_$(REM_MOD))/op.S.dep
|
---|
131 | endif
|
---|
132 | $(REM_MOD)_SOURCES.win.x86 = $(REM_MOD).def
|
---|
133 | ifneq ($(REM_MOD),VBoxREM2)
|
---|
134 | $(REM_MOD)_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
|
---|
135 | endif
|
---|
136 |
|
---|
137 |
|
---|
138 | ifdef REM_USE_NOCRT
|
---|
139 | $(REM_MOD)_TEMPLATE = VBOXNOCRTGAS
|
---|
140 | $(REM_MOD)_DEFS += LOG_USE_C99 $(ARCH_BITS_DEFS)
|
---|
141 | $(REM_MOD)_CFLAGS.amd64 = -O2
|
---|
142 | $(REM_MOD)_CFLAGS.debug = -O0
|
---|
143 | ifdef ($(KBUILD_TARGET_ARCH),x86)
|
---|
144 | $(REM_MOD)_CFLAGS.release+= -fomit-frame-pointer -fno-gcse
|
---|
145 | endif
|
---|
146 |
|
---|
147 | # This doesn't fit in IPRT because it requires GAS and is LGPL.
|
---|
148 | $(REM_MOD)_SOURCES += \
|
---|
149 | Sun/e_powl-$(KBUILD_TARGET_ARCH).S
|
---|
150 |
|
---|
151 | ifeq ($(REM_MOD),VBoxREM)
|
---|
152 | $(REM_MOD)_LIBS = \
|
---|
153 | $(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB) \
|
---|
154 | $(LIB_VMM) \
|
---|
155 | $(LIB_RUNTIME)
|
---|
156 | ifeq ($(KBUILD_TARGET),l4)
|
---|
157 | $(REM_MOD)_LIBS += \
|
---|
158 | $(L4_LIBDIR)/libuc.0.s.so
|
---|
159 | endif
|
---|
160 | $(REM_MOD)_LIBS.darwin = \
|
---|
161 | $(TARGET_VBoxREMImp)
|
---|
162 | $(REM_MOD)_LDFLAGS.darwin = -read_only_relocs suppress -multiply_defined warning #-install_name @executable_path/$(REM_MOD).dylib#
|
---|
163 | $(REM_MOD)_CFLAGS.darwin = -fno-common -mdynamic-no-pic
|
---|
164 | else
|
---|
165 | $(REM_MOD)_LIBS = \
|
---|
166 | $(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB)
|
---|
167 | $(REM_MOD)_SYSSUFF = .rel
|
---|
168 | $(REM_MOD)_LDFLAGS.darwin = -nostdlib -static
|
---|
169 | $(REM_MOD)_CFLAGS.darwin = -fno-common -static -mno-dynamic-no-pic
|
---|
170 | endif
|
---|
171 |
|
---|
172 | else # !REM_USE_NOCRT
|
---|
173 |
|
---|
174 | $(REM_MOD)_TOOL = GXX3
|
---|
175 | $(REM_MOD)_TOOL.solaris = GXX3PLAIN
|
---|
176 | $(REM_MOD)_TOOL.win.x86 = MINGW32
|
---|
177 | $(REM_MOD)_TOOL.win.amd64 = XGCCAMD64LINUX
|
---|
178 | $(REM_MOD)_SDKS.win.x86 = W32API ## @todo do we really need this now?
|
---|
179 | $(REM_MOD)_ASFLAGS = -x assembler-with-cpp ## @todo didn't I make this default already?
|
---|
180 | $(REM_MOD)_CFLAGS = -Wall -g
|
---|
181 | $(REM_MOD)_CFLAGS.debug = -O0
|
---|
182 | $(REM_MOD)_CFLAGS.release += -fomit-frame-pointer -fno-gcse
|
---|
183 | $(REM_MOD)_CFLAGS.profile = $($(REM_MOD)_CFLAGS.release)
|
---|
184 | $(REM_MOD)_CFLAGS.kprofile = $($(REM_MOD)_CFLAGS.release)
|
---|
185 | $(REM_MOD)_CFLAGS.l4 = -nostdinc
|
---|
186 | ifeq ($(KBUILD_TARGET),l4)
|
---|
187 | $(REM_MOD)_INCS += $(VBOX_L4_GCC3_INCS) $(L4_INCDIR)
|
---|
188 | endif
|
---|
189 |
|
---|
190 | $(REM_MOD)_DEFS += IN_RING3 LOG_USE_C99 $(ARCH_BITS_DEFS)
|
---|
191 | #$(REM_MOD)_DEFS += 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.
|
---|
192 | # these defines are probably all irrelevant now:
|
---|
193 | $(REM_MOD)_DEFS += _GNU_SOURCE _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _REENTRANT
|
---|
194 |
|
---|
195 | $(REM_MOD)_LDFLAGS.darwin = -read_only_relocs suppress -install_name @executable_path/$(REM_MOD).dylib -multiple_defined warning
|
---|
196 | $(REM_MOD)_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib -Wl,--no-undefined
|
---|
197 | $(REM_MOD)_LDFLAGS.linux = $(VBOX_LD_as_needed)
|
---|
198 | $(REM_MOD)_LDFLAGS.os2 = -Zomf
|
---|
199 | $(REM_MOD)_LDFLAGS.debug = -g
|
---|
200 | $(REM_MOD)_LDFLAGS.solaris = -mimpure-text
|
---|
201 | ifdef VBOX_SOLARIS_10
|
---|
202 | $(REM_MOD)_DEFS.solaris += HOST_SOLARIS=10
|
---|
203 | else # solaris 11
|
---|
204 | $(REM_MOD)_DEFS.solaris += HOST_SOLARIS=11
|
---|
205 | endif
|
---|
206 | ifeq ($(KBUILD_TARGET_ARCH),amd64)
|
---|
207 | $(REM_MOD)_LIBS = $(FILE_TOOL_GCC3_LIBGCC)
|
---|
208 | else # x86
|
---|
209 | $(REM_MOD)_LIBS = \
|
---|
210 | $(LIB_VMM) \
|
---|
211 | $(LIB_RUNTIME)
|
---|
212 | $(REM_MOD)_LIBS.win.x86 = \
|
---|
213 | mingw32 \
|
---|
214 | user32 gdi32 winmm ws2_32 iphlpapi dxguid
|
---|
215 | $(REM_MOD)_LIBS.linux = \
|
---|
216 | $(LIB_UUID) \
|
---|
217 | m \
|
---|
218 | util \
|
---|
219 | rt \
|
---|
220 | $(LIB_PTHREAD)
|
---|
221 | $(REM_MOD)_LIBS.l4 = \
|
---|
222 | gcc \
|
---|
223 | $(L4_LIBDIR)/libvboxserver.s.so \
|
---|
224 | $(L4_LIBDIR)/libdl.s.so \
|
---|
225 | $(L4_LIBDIR)/libuc.0.s.so
|
---|
226 | endif # x86
|
---|
227 |
|
---|
228 | endif # !REM_USE_NOCRT
|
---|
229 |
|
---|
230 | # Extra flags for these source modules.
|
---|
231 | target-i386/op.c_CFLAGS = -O2 -fno-strict-aliasing -fomit-frame-pointer -falign-functions=0 -fno-reorder-blocks -fno-optimize-sibling-calls
|
---|
232 | target-i386/op.c_CFLAGS.x86 = -fno-gcse -fno-instrument-functions -mpreferred-stack-boundary=2
|
---|
233 | target-i386/op.c_CFLAGS.darwin.x86 = -m128bit-long-double -mpreferred-stack-boundary=4
|
---|
234 | target-i386/helper.c_CFLAGS.x86 = -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-gcse
|
---|
235 | cpu-exec.c_CFLAGS.x86 = -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-gcse
|
---|
236 | cpu-exec.c_CFLAGS.solaris.amd64 = -O2 -fomit-frame-pointer -fno-strict-aliasing
|
---|
237 |
|
---|
238 |
|
---|
239 | #
|
---|
240 | # The math testcase as a standalone program for testing and debugging purposes.
|
---|
241 | #
|
---|
242 | ## @todo This is a bit messy because of MINGW32.
|
---|
243 | #BLDPROGS += testmath
|
---|
244 | testmath_TOOL = GXX3
|
---|
245 | testmath_TOOL.win.x86 = MINGW32
|
---|
246 | testmath_SDKS.win.x86 = W32API
|
---|
247 | ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),win.amd64)
|
---|
248 | # 64-bit windows: Pretend to be 32-bit.
|
---|
249 | testmath_BLD_TRG = win32
|
---|
250 | testmath_BLD_TRG_ARCH = x86
|
---|
251 | testmath_BLD_TRG_CPU = i386
|
---|
252 | endif
|
---|
253 | testmath_ASTOOL = $(VBOX_ASTOOL)
|
---|
254 | ifeq ($(filter-out win32 win64,$(KBUILD_HOST)),)
|
---|
255 | testmath_ASFLAGS = -f win32 -DNASM_FORMAT_PE $(VBOX_ASFLAGS) -w+orphan-labels
|
---|
256 | else
|
---|
257 | testmath_ASFLAGS = -f elf -DNASM_FORMAT_ELF $(VBOX_ASFLAGS) -w+orphan-labels
|
---|
258 | endif
|
---|
259 | testmath_ASFLAGS.amd64 = -m amd64
|
---|
260 | testmath_CFLAGS = -Wall -g
|
---|
261 | testmath_CFLAGS.release = -O3
|
---|
262 | testmath_LDFLAGS = -g
|
---|
263 | testmath_DEFS = MATHTEST_STANDALONE
|
---|
264 | testmath_SOURCES = Sun/testmath.c
|
---|
265 | #testmath_SOURCES += $(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB)
|
---|
266 |
|
---|
267 |
|
---|
268 | ifeq ($(REM_MOD),VBoxREM2)
|
---|
269 | #
|
---|
270 | # The VBoxREM2 wrapper.
|
---|
271 | #
|
---|
272 | VBoxREM_TEMPLATE = VBOXR3
|
---|
273 | VBoxREM_DEFS = IN_REM_R3
|
---|
274 | VBoxREM_SOURCES = \
|
---|
275 | VBoxREMWrapper.cpp \
|
---|
276 | VBoxREMWrapperA.asm
|
---|
277 | VBoxREM_LDFLAGS.darwin = -install_name @executable_path/VBoxREM.dylib
|
---|
278 | VBoxREM_LIBS = \
|
---|
279 | $(LIB_VMM) \
|
---|
280 | $(LIB_RUNTIME)
|
---|
281 | endif
|
---|
282 |
|
---|
283 |
|
---|
284 | #
|
---|
285 | # The VBoxREM import library.
|
---|
286 | #
|
---|
287 | VBoxREMImp_TEMPLATE = VBOXR3
|
---|
288 | ifeq ($(KBUILD_TARGET),darwin)
|
---|
289 | VBoxREMImp_INST = $(INST_LIB)
|
---|
290 | endif
|
---|
291 | VBoxREMImp_SOURCES.win = VBoxREM.def
|
---|
292 | VBoxREMImp_SOURCES.os2 = $(PATH_TARGET)/VBoxREMOS2.def
|
---|
293 | ifeq ($(filter win os2,$(KBUILD_TARGET)),)
|
---|
294 | VBoxREMImp_SOURCES = $(PATH_TARGET)/VBoxREMImp.c
|
---|
295 | VBoxREMImp_CLEAN = $(PATH_TARGET)/VBoxREMImp.c
|
---|
296 | endif
|
---|
297 | ifneq ($(filter-out darwin os2 win,$(KBUILD_TARGET)),)
|
---|
298 | VBoxREMImp_SONAME = VBoxREM$(SUFF_DLL)
|
---|
299 | endif
|
---|
300 | VBoxREMImp_LDFLAGS.darwin = -install_name @executable_path/VBoxREM.dylib
|
---|
301 | #VBoxREMImp_LDFLAGS.darwin = -install_name VBoxREM.dylib
|
---|
302 | VBoxREMImp_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib
|
---|
303 |
|
---|
304 | $(PATH_TARGET)/VBoxREMImp.c: VBoxREM.def Sun/deftoimp.sed Makefile.kmk | $(call DIRDEP,$(PATH_TARGET))
|
---|
305 | $(call MSG_GENERATE,,$@)
|
---|
306 | $(QUIET)$(MKDIR) -p $(PATH_TARGET)
|
---|
307 | $(QUIET)$(APPEND) [email protected] '#ifdef VBOX_HAVE_VISIBILITY_HIDDEN'
|
---|
308 | $(QUIET)$(APPEND) [email protected] '# define EXPORT __attribute__((visibility("default")))'
|
---|
309 | $(QUIET)$(APPEND) [email protected] '#else'
|
---|
310 | $(QUIET)$(APPEND) [email protected] '# define EXPORT'
|
---|
311 | $(QUIET)$(APPEND) [email protected] '#endif'
|
---|
312 | $(QUIET)$(APPEND) [email protected] ''
|
---|
313 | $(QUIET)$(SED) -f Sun/deftoimp.sed VBoxREM.def >> [email protected]
|
---|
314 | $(QUIET)$(MV) -f [email protected] $@
|
---|
315 |
|
---|
316 | $(VBoxREMImp_SOURCES.os2): VBoxREM.def $(MAKEFILE) | $(call DIRDEP,$(PATH_TARGET))
|
---|
317 | $(SED) \
|
---|
318 | -e 's/^[ \t][ \t]*REMR3/ _REMR3/' \
|
---|
319 | -e 's/\.[Dd][Ll][Ll]//' \
|
---|
320 | -e 's/^LIBRARY .*/LIBRARY VBoxREM INITINSTANCE TERMINSTANCE\nDATA MULTIPLE\n/' \
|
---|
321 | VBoxREM.def > [email protected]
|
---|
322 | $(MV) -f [email protected] $@
|
---|
323 |
|
---|
324 |
|
---|
325 |
|
---|
326 | include $(KBUILD_PATH)/footer.kmk
|
---|
327 |
|
---|
328 |
|
---|
329 | #
|
---|
330 | # Generate the op.S file somehow...
|
---|
331 | #
|
---|
332 | # Gathering the flags, defines and include dirs for the command is a lot
|
---|
333 | # of work. Unfortunately, there is only a highly specialized kBuild function
|
---|
334 | # for doing this, so we're currently left to our own devices here.
|
---|
335 | #
|
---|
336 | # Add something like VBOX_RECOMPILER_OP_GCC = gcc-3.4.6 to LocalConfig.kmk
|
---|
337 | # to be 100% sure that you get a working op.S. My gcc 4.1.1 seems to work
|
---|
338 | # fine, so feel free to try VBOX_RECOMPILER_OP_GCC = gcc.
|
---|
339 | #
|
---|
340 | # The op-undefined.lst is generated by finding all the undefined symbols
|
---|
341 | # in one (or more) ELF op.o files using nm.
|
---|
342 | #
|
---|
343 | ifndef VBOX_RECOMPILER_OP_GCC
|
---|
344 | ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),darwin.x86)
|
---|
345 | VBOX_RECOMPILER_OP_GCC ?= $(notdir $(firstword $(which i386-elf-gcc-3.4 i386-elf-gcc-3.4.6 i386-elf-gcc-3.4.3 i386-elf-gcc) i386-elf-gcc)) # (port install i386-gcc-elf)
|
---|
346 | VBOX_RECOMPILER_OP_GCC_OK := yes
|
---|
347 | VBOX_RECOMPILER_OP_GCC_INCS ?= $(abspath $(dir $(shell LC_ALL=C $(VBOX_RECOMPILER_OP_GCC) -print-libgcc-file-name)))/include
|
---|
348 | endif
|
---|
349 | ifndef VBOX_RECOMPILER_OP_GCC
|
---|
350 | VBOX_RECOMPILER_OP_GCC := $(TOOL_$(VBOX_GCC_TOOL)_CC)
|
---|
351 | VBOX_RECOMPILER_OP_GCC_OK := dunno
|
---|
352 | endif
|
---|
353 | else
|
---|
354 | # If set, assume it's an OK compiler.
|
---|
355 | VBOX_RECOMPILER_OP_GCC_OK := yes
|
---|
356 | endif
|
---|
357 |
|
---|
358 |
|
---|
359 | # The command sans -o op.S.tmp.
|
---|
360 | COMPILE_OP_CMDS = $(VBOX_RECOMPILER_OP_GCC) \
|
---|
361 | -S -s \
|
---|
362 | $(filter-out -g -O0, \
|
---|
363 | $($(REM_MOD)_CFLAGS) $($(REM_MOD)_CFLAGS.$(KBUILD_TYPE)) $($(REM_MOD)_CFLAGS.$(KBUILD_TARGET)) $($(REM_MOD)_CFLAGS.$(KBUILD_TARGET_ARCH)) $($(REM_MOD)_CFLAGS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
364 | $(target-i386/op.c_CFLAGS) $(target-i386/op.c_CFLAGS.$(KBUILD_TARGET)) $(target-i386/op.c_CFLAGS.$(KBUILD_TARGET_ARCH)) $(target-i386/op.c_CFLAGS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
365 | ) \
|
---|
366 | $(addprefix -I, \
|
---|
367 | $($(REM_MOD)_CINCS.$(KBUILD_TARGET_ARCH)) $($(REM_MOD)_CINCS.$(KBUILD_TARGET)) $($(REM_MOD)_CINCS) $(CINCS) \
|
---|
368 | $($(REM_MOD)_INCS.$(KBUILD_TARGET_ARCH)) $($(REM_MOD)_INCS.$(KBUILD_TARGET)) $($(REM_MOD)_INCS) $(INCS) \
|
---|
369 | ) \
|
---|
370 | $(addprefix -D, \
|
---|
371 | $($(REM_MOD)_CDEFS.$(KBUILD_TARGET_ARCH)) $($(REM_MOD)_CDEFS.$(KBUILD_TARGET)) $($(REM_MOD)_CDEFS) $(CDEFS.$(KBUILD_TARGET)) $(CDEFS.$(KBUILD_TARGET_ARCH)) $(CDEFS.$(KBUILD_TYPE)) $(CDEFS) \
|
---|
372 | $($(REM_MOD)_DEFS.$(KBUILD_TARGET_ARCH)) $($(REM_MOD)_DEFS.$(KBUILD_TARGET)) $($(REM_MOD)_DEFS) $(DEFS.$(KBUILD_TARGET)) $(DEFS.$(KBUILD_TARGET_ARCH)) $(DEFS.$(KBUILD_TYPE)) $(DEFS) \
|
---|
373 | ) \
|
---|
374 | -Wp,-MD,$(PATH_$(REM_MOD))/op.S.dep \
|
---|
375 | -Wp,-MT,$(PATH_$(REM_MOD))/op.S \
|
---|
376 | -Wp,-MP \
|
---|
377 | target-i386/op.c
|
---|
378 |
|
---|
379 | # Use the right GCC includes.
|
---|
380 | ifdef VBOX_RECOMPILER_OP_GCC_INCS
|
---|
381 | COMPILE_OP_CMDS := $(subst $(VBOX_PATH_GCC_INCS),$(VBOX_RECOMPILER_OP_GCC_INCS),$(COMPILE_OP_CMDS))
|
---|
382 | endif
|
---|
383 |
|
---|
384 | # Drop incompatible options when using the cross-compiler on darwin.
|
---|
385 | ifeq ($(KBUILD_TARGET),darwin)
|
---|
386 | ifeq ($(filter-out i386-elf-gcc%, $(VBOX_RECOMPILER_OP_GCC)),)
|
---|
387 | COMPILE_OP_CMDS := $(filter-out -mdynamic-no-pic -mno-dynamic-no-pic -fno-stack-protector, $(COMPILE_OP_CMDS))
|
---|
388 | endif
|
---|
389 | else if1of ($(KBUILD_TARGET),linux)
|
---|
390 | ifneq ($(TOOL_$(VBOX_GCC_TOOL)_CC),$(VBOX_RECOMPILER_OP_GCC))
|
---|
391 | VBOX_RECOMPILER_OP_CHECK_CC_GCC = $(shell \
|
---|
392 | if $(VBOX_RECOMPILER_OP_GCC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
|
---|
393 | then echo "$(1)"; \
|
---|
394 | else echo "$(2)"; fi; )
|
---|
395 | COMPILE_OP_CMDS := \
|
---|
396 | $(filter-out -fno-stack-protector, $(COMPILE_OP_CMDS)) \
|
---|
397 | $(call VBOX_RECOMPILER_OP_CHECK_CC_GCC,-fno-stack-protector)
|
---|
398 | endif
|
---|
399 | endif
|
---|
400 |
|
---|
401 | # include the dependencies
|
---|
402 | -include $(PATH_$(REM_MOD))/op.S.dep
|
---|
403 |
|
---|
404 | # The rule.
|
---|
405 | $(PATH_$(REM_MOD))/op.S: \
|
---|
406 | target-i386/op.c \
|
---|
407 | Sun/staged-op-elf-$(KBUILD_TARGET_ARCH).S \
|
---|
408 | Sun/op-validate.sed \
|
---|
409 | Sun/op-darwin.sed \
|
---|
410 | Sun/op-undefined.lst \
|
---|
411 | Makefile.kmk \
|
---|
412 | $(comp-cmds COMPILE_OP_CMDS,COMPILE_OP_CMDS_PREV,FORCE) \
|
---|
413 | | $(call DIRDEP,$(PATH_$(REM_MOD)))
|
---|
414 | $(RM) -f $@ [email protected] [email protected] [email protected]
|
---|
415 | ifeq ($(VBOX_RECOMPILER_OP_GCC_OK),yes)
|
---|
416 | $(call MSG_COMPILE,VBoxREM,$<,$@,AS)
|
---|
417 | $(addsuffix $(SP)\$(NL)$(TAB) ,$(COMPILE_OP_CMDS)) -o [email protected]
|
---|
418 | else ifeq ($(VBOX_RECOMPILER_OP_GCC_OK),dunno) # (permit 3.x.x and 4.1.x+ for now)
|
---|
419 | major_ver=`$(VBOX_RECOMPILER_OP_GCC) -dumpversion | $(SED) -e 's/^\([2-9]\)\..*$$/\1/'`; \
|
---|
420 | minor_ver=`$(VBOX_RECOMPILER_OP_GCC) -dumpversion | $(SED) -e 's/^[2-9]\.\([0-9]\)\..*$$/\1/'`; \
|
---|
421 | bugfix_ver=`$(VBOX_RECOMPILER_OP_GCC) -dumpversion | $(SED) -e 's/^[2-9]\.[0-9]\.\([0-9]\).*$$/\1/'`; \
|
---|
422 | if test "$$major_ver" = "3" -o "(" "$$major_ver" = "4" -a "$$minor_ver" != "0" ")"; then \
|
---|
423 | $(ECHO_EXT) "Compiling $< => $@ [gcc v$${major_ver}.$${minor_ver}.$${bugfix_ver}]" && \
|
---|
424 | $(addsuffix $(SP)\$(NL)$(TAB)$(TAB) ,$(COMPILE_OP_CMDS)) -o [email protected]; \
|
---|
425 | else \
|
---|
426 | $(ECHO_EXT) "Using staged op.S [gcc v$${major_ver}.$${minor_ver}.$${bugfix_ver}]" && \
|
---|
427 | $(CP_EXT) -f Sun/staged-op-elf-$(KBUILD_TARGET_ARCH).S [email protected]; \
|
---|
428 | fi
|
---|
429 | else
|
---|
430 | $(CP) Sun/staged-op-elf-$(KBUILD_TARGET_ARCH).S [email protected]
|
---|
431 | endif
|
---|
432 | $(SED) -f Sun/op-validate.sed [email protected]
|
---|
433 | ifeq ($(KBUILD_TARGET),darwin)
|
---|
434 | $(SED) -f Sun/op-darwin.sed [email protected] > [email protected]
|
---|
435 | $(SED) -e 's/^\(.*\)$$/#define \1 _\1/' Sun/op-undefined.lst > [email protected]
|
---|
436 | $(CAT_EXT) [email protected] >> [email protected]
|
---|
437 | endif
|
---|
438 | $(MV) -f [email protected] $@
|
---|
439 | $(QUIET2)$(APPEND) "[email protected]"
|
---|
440 | $(QUIET2)$(APPEND) "[email protected]" 'define COMPILE_OP_CMDS_PREV'
|
---|
441 | $(QUIET2)$(APPEND) "[email protected]" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "[email protected]" ',$(COMPILE_OP_CMDS))'
|
---|
442 | $(QUIET2)$(APPEND) "[email protected]" 'endef'
|
---|
443 |
|
---|
444 |
|
---|
445 | # Hack for crosscompiling.
|
---|
446 | DYNGEN = $(PATH_dyngen)/dyngen$(HOSTSUFF_EXE)
|
---|
447 | DYNGEN_EXEC = $(DYNGEN)
|
---|
448 | ifneq ($(KBUILD_HOST),$(KBUILD_TARGET)) # hack for crosscompiling.
|
---|
449 | ifeq ($(KBUILD_TARGET),win)
|
---|
450 | DYNGEN = $(PATH_dyngen)/dyngen.exe
|
---|
451 | DYNGEN_EXEC := $(EXEC_X86_WIN32) $(DYNGEN_EXEC)
|
---|
452 | endif
|
---|
453 | endif
|
---|
454 |
|
---|
455 | # The dyngen rules.
|
---|
456 | $(PATH_$(REM_MOD))/op.h: $(FILE_OP_OBJ) $(DYNGEN)
|
---|
457 | $(call MSG_TOOL,dyngen,VBoxREM,$<,$@)
|
---|
458 | $(QUIET)$(DYNGEN_EXEC) -o $@ $<
|
---|
459 |
|
---|
460 | $(PATH_$(REM_MOD))/opc.h: $(FILE_OP_OBJ) $(DYNGEN)
|
---|
461 | $(call MSG_TOOL,dyngen,VBoxREM,$<,$@)
|
---|
462 | $(QUIET)$(DYNGEN_EXEC) -c -o $@ $<
|
---|
463 |
|
---|
464 | $(PATH_$(REM_MOD))/gen-op.h: $(FILE_OP_OBJ) $(DYNGEN)
|
---|
465 | $(call MSG_TOOL,dyngen,VBoxREM,$<,$@)
|
---|
466 | $(QUIET)$(DYNGEN_EXEC) -g -o $@ $<
|
---|
467 |
|
---|
468 | # Dyngen dependants (sp?).
|
---|
469 | translate-all.c \
|
---|
470 | translate-op.c \
|
---|
471 | target-i386/translate.c \
|
---|
472 | : $(PATH_$(REM_MOD))/op.h $(PATH_$(REM_MOD))/opc.h $(PATH_$(REM_MOD))/gen-op.h
|
---|
473 |
|
---|
474 |
|
---|
475 | # Some aliases
|
---|
476 | do_dyngen: $(PATH_$(REM_MOD))/gen-op.h $(PATH_$(REM_MOD))/opc.h $(PATH_$(REM_MOD))/op.h
|
---|
477 | importlib: $(LIB_REM)
|
---|
478 | op.S: $(PATH_$(REM_MOD))/op.S
|
---|
479 |
|
---|