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