VirtualBox

source: vbox/trunk/src/recompiler/Makefile.kmk@ 16560

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

small fix

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

© 2023 Oracle
ContactPrivacy policyTerms of Use