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