Makefile.kmk revision 61629542b22048ae51d3152ea3babb52a9075f19
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# $Id$
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller## @file
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# The Recompiler Makefile.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# There are a few of complicating factors here, esp. on AMD64 systems:
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# * op.c doesn't compile work correctly with gcc 4. For this we've
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# checked in op.S, which is the reason why we don't compile op.c
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# directly but always compile via the assembly file.s
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# * On 64-bit Windows we lack a compiler and have to resort to a
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# linux cross compiler building an ELF relocatable module which
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# we then load using a wrapper module. Thus the REM_MOD mess.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# * On platforms using the 64-bit GCC ABI, we're not allowed to
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# generate non-PIC shared objects, and op.c requires the code
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# to be non-PIC. We apply the same trick as we developed for
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# 64-bit windows.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# Copyright (C) 2006 InnoTek Systemberatung GmbH
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# This file is part of VirtualBox Open Source Edition (OSE), as
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# available from http://www.virtualbox.org. This file is free software;
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# you can redistribute it and/or modify it under the terms of the GNU
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# General Public License as published by the Free Software Foundation,
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# distribution. VirtualBox OSE is distributed in the hope that it will
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller# be useful, but WITHOUT ANY WARRANTY of any kind.
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan Miller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# If you received this file as part of a commercial VirtualBox
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller# distribution, then only the terms of your commercial VirtualBox
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# license agreement apply instead of the previous paragraph.
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan Miller#
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan Miller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan MmillerDEPTH = ../../..
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerinclude $(PATH_KBUILD)/header.kmk
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# todo this is a BUILD_PLATFORM binary, to a target binary!
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan MmillerBLDPROGS = dyngen
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerifeq ($(BUILD_TARGET_ARCH),amd64)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller SYSMODS = VBoxREM2
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller REM_MOD = VBoxREM2
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerelse
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller REM_MOD = VBoxREM
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerendif
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan MmillerDLLS = VBoxREM
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan MmillerIMPORT_LIBS = VBoxREMImp
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan MillerOTHER_CLEAN = \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_$(REM_MOD))/op.h \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_$(REM_MOD))/opc.h \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_$(REM_MOD))/gen-op.h \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_$(REM_MOD))/opc.h
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# A private hack for gcc 4.1 - no longer required. gcc 4.1.1 works fine for everything.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#ifeq ($(USERNAME).$(BUILD_TARGET),bird.linux)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# TOOL_GCC3_CC = gcc-3.4.6
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# TOOL_GCC3_CXX = gcc-3.4.6
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# TOOL_GCC3_LD = g++-3.4.6
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# override VBOX_GCC_Wno-variadic-macros=
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller# override VBOX_USING_GCC4=
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#endif
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# L4 must use the no-crt path because it's lacking math stuff it seems...
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# Darwin must use the non-crt path because it can't compile op.c nativly.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# All the AMD64 target must use the no-crt path because ELF doesn't like op.c
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# when stuffed into a shared library and windows doesn't have 64-bit gcc (yet).
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan Miller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerifeq ($(filter-out l4 darwin freebsd,$(BUILD_TARGET)),)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller REM_USE_NOCRT := 1
4898977f579fcb4eb88439686577754e34599f13Brendan Millerendif
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerifeq ($(BUILD_TARGET_ARCH),amd64)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller REM_USE_NOCRT := 1
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerendif
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# The dyngen build tool.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerifeq ($(BUILD_PLATFORM),win)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller dyngen_TOOL = MINGW32
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller dyngen_SDKS = W32API
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller # On 64-bit Windows we pretend to be 32-bit.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller dyngen_BLD_TRG_ARCH = x86
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller dyngen_BLD_TRG_CPU = i386
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller dyngen_CFLAGS = -Wall -g -fno-strict-aliasing
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller ifeq ($(BUILD_TARGET_ARCH),amd64)
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunnington dyngen_DEFS += HOST_X86_64=1
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller endif
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunningtonelse
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller dyngen_TEMPLATE = VBOXBLDPROG
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Millerendif
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Millerdyngen_INCS = \
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunnington InnoTek \
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunnington target-i386 \
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunnington fpu
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerdyngen_SOURCES = dyngen.c
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller# The VBoxREM.[dll|so|..] or VBoxREM2.rel.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller$(REM_MOD)_DEFS = IN_REM_R3 REM_INCLUDE_CPU_H
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller#$(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.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller$(REM_MOD)_INCS = \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller InnoTek \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller InnoTek/crt\
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller target-i386 \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller fpu \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_$(REM_MOD)) \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(PATH_ROOT)/src/VBox/VMM
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller
47191265a0ac73f0ac0db0330969ce6920adaa1fBrendan Miller$(REM_MOD)_SOURCES = \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller VBoxRecompiler.c \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller cpu-exec.c \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller exec.c \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller translate-all.c \
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller translate-op.c \
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller fpu/softfloat-native.c \
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller target-i386/helper.c \
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller target-i386/helper2.c \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller target-i386/translate.c \
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller InnoTek/testmath.c
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerifeq ($(filter-out win os2,$(BUILD_TARGET)),)
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(REM_MOD)_SOURCES += target-i386/op.c
641b861c668fdb84b7ed44966216b36863ffb608Brendan Mmiller FILE_OP_OBJ = $(PATH_$(REM_MOD)_target-i386/op.c)/op.o
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmillerelse # The remaining targets can be using gcc-4 and needs checking.
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller $(REM_MOD)_SOURCES += $(PATH_$(REM_MOD))/op.S
932eacec6c157231777c9b1d1326c8ed1f0a8d99Brendan Mmiller FILE_OP_OBJ = $(PATH_$(REM_MOD)_$(PATH_$(REM_MOD))/op.S)/op.o
$(REM_MOD)_CLEAN = $(FILE_OP_OBJ) $(PATH_$(REM_MOD))/op.S.dep
endif
$(REM_MOD)_SOURCES.os2 = $(REM_MOD).def
$(REM_MOD)_SOURCES.win.x86 = $(REM_MOD).def
ifdef REM_USE_NOCRT
$(REM_MOD)_TEMPLATE = VBOXNOCRTGAS
$(REM_MOD)_DEFS += LOG_USE_C99
$(REM_MOD)_CFLAGS.amd64 = -O2
$(REM_MOD)_CFLAGS.debug = -O0
$(REM_MOD)_CFLAGS.darwin = -fno-common -mdynamic-no-pic
ifdef ($(BUILD_TARGET_ARCH),x86)
$(REM_MOD)_CFLAGS.release+= -fomit-frame-pointer -fno-gcse
endif
# This doesn't fit in IPRT because it requires GAS and is LGPL.
$(REM_MOD)_SOURCES += \
InnoTek/e_powl-$(BUILD_TARGET_ARCH).S
ifeq ($(REM_MOD),VBoxREM)
$(REM_MOD)_LIBS = \
$(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB) \
$(LIB_VMM) \
$(LIB_RUNTIME)
$(REM_MOD)_LIBS.darwin = \
$(TARGET_VBoxREMImp)
# $(PATH_BIN)/VBoxREMImp.dylib
$(REM_MOD)_LDFLAGS.darwin = -read_only_relocs suppress -multiply_defined warning #-install_name @executable_path/$(REM_MOD).dylib#
else
$(REM_MOD)_LIBS = \
$(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB)
$(REM_MOD)_SYSSUFF = .rel
endif
else # !REM_USE_NOCRT
$(REM_MOD)_TOOL = GCC3
$(REM_MOD)_TOOL.win.x86 = MINGW32
$(REM_MOD)_TOOL.win.amd64 = XGCCAMD64LINUX
$(REM_MOD)_SDKS.win.x86 = W32API ## @todo do we really need this now?
$(REM_MOD)_ASFLAGS = -x assembler-with-cpp ## @todo didn't I make this default already?
$(REM_MOD)_CFLAGS = -Wall -g
$(REM_MOD)_CFLAGS.debug = -O0
$(REM_MOD)_CFLAGS.release += -fomit-frame-pointer -fno-gcse
$(REM_MOD)_CFLAGS.profile = $($(REM_MOD)_CFLAGS.release)
$(REM_MOD)_CFLAGS.kprofile = $($(REM_MOD)_CFLAGS.release)
$(REM_MOD)_CFLAGS.l4 = -nostdinc
ifeq ($(BUILD_TARGET),l4)
$(REM_MOD)_INCS += $(VBOX_L4_GCC3_INCS) $(L4_INCDIR)
endif
$(REM_MOD)_DEFS += IN_RING3 LOG_USE_C99
#$(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.
# these defines are probably all irrelevant now:
$(REM_MOD)_DEFS += _GNU_SOURCE _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _REENTRANT
$(REM_MOD)_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib -Wl,--no-undefined
$(REM_MOD)_LDFLAGS.darwin = -read_only_relocs suppress -install_name @executable_path/$(REM_MOD).dylib -multiple_defined warning
ifeq ($(BUILD_TARGET_ARCH),amd64)
$(REM_MOD)_LIBS = $(FILE_TOOL_GCC3_LIBGCC)
else # x86
$(REM_MOD)_LIBS = \
$(LIB_VMM) \
$(LIB_RUNTIME)
$(REM_MOD)_LIBS.win.x86 = \
mingw32 \
user32 gdi32 winmm ws2_32 iphlpapi dxguid
$(REM_MOD)_LIBS.linux = \
$(LIB_UUID) \
m \
util \
rt \
$(LIB_PTHREAD)
$(REM_MOD)_LIBS.l4 = \
gcc \
$(L4_LIBDIR)/libvboxserver.s.so \
$(L4_LIBDIR)/libdl.s.so \
$(L4_LIBDIR)/libuc.0.s.so
endif # x86
endif # !REM_USE_NOCRT
# Extra flags for these source modules.
target-i386/op.c_CFLAGS = -O2 -fno-strict-aliasing -fomit-frame-pointer -falign-functions=0 -fno-reorder-blocks -fno-optimize-sibling-calls
target-i386/op.c_CFLAGS.x86 = -fno-gcse -fno-instrument-functions -mpreferred-stack-boundary=2
target-i386/op.c_CFLAGS.darwin.x86 = -m128bit-long-double -mpreferred-stack-boundary=4 ## @todo This means we can't use staged/op-elf-x86.s...
target-i386/helper.c_CFLAGS.x86 = -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-gcse
cpu-exec.c_CFLAGS.x86 = -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-gcse
#
# The math testcase as a standalone program for testing and debugging purposes.
#
## @todo This is a bit messy because of MINGW32.
#BLDPROGS += testmath
testmath_TOOL = GCC3
testmath_TOOL.win.x86 = MINGW32
testmath_SDKS.win.x86 = W32API
ifeq ($(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH),win.amd64)
# 64-bit windows: Pretend to be 32-bit.
testmath_BLD_TRG = win32
testmath_BLD_TRG_ARCH = x86
testmath_BLD_TRG_CPU = i386
endif
testmath_ASTOOL = $(VBOX_ASTOOL)
ifeq ($(filter-out win32 win64,$(BUILD_PLATFORM)),)
testmath_ASFLAGS = -f win32 -DNASM_FORMAT_PE $(VBOX_ASFLAGS) -w+orphan-labels
else
testmath_ASFLAGS = -f elf -DNASM_FORMAT_ELF $(VBOX_ASFLAGS) -w+orphan-labels
endif
testmath_ASFLAGS.amd64 = -m amd64
testmath_CFLAGS = -Wall -g
testmath_CFLAGS.release = -O3
testmath_LDFLAGS = -g
testmath_DEFS = MATHTEST_STANDALONE
testmath_SOURCES = InnoTek/testmath.c
#testmath_SOURCES += $(PATH_LIB)/RuntimeR3NoCRTGCC$(VBOX_SUFF_LIB)
ifeq ($(BUILD_TARGET_ARCH),amd64)
#
# The VBoxREM2 wrapper.
#
VBoxREM_TEMPLATE = VBOXR3
VBoxREM_DEFS = IN_REM_R3
VBoxREM_SOURCES = \
VBoxREMWrapper.cpp \
VBoxREMWrapperA.asm
VBoxREM_LDFLAGS.darwin = -install_name @executable_path/VBoxREM.dylib
VBoxREM_LIBS = \
$(LIB_VMM) \
$(LIB_RUNTIME)
endif
#
# The VBoxREM import library.
#
VBoxREMImp_TEMPLATE = VBOXR3
ifeq ($(BUILD_TARGET),darwin)
VBoxREMImp_INST = $(INST_LIB)
endif
VBoxREMImp_SOURCES.win = VBoxREM.def
VBoxREMImp_SOURCES.os2 = $(PATH_TARGET)/VBoxREMOS2.def
ifeq ($(filter win os2,$(BUILD_TARGET)),)
VBoxREMImp_SOURCES = $(PATH_TARGET)/VBoxREMImp.c
VBoxREMImp_CLEAN = $(PATH_TARGET)/VBoxREMImp.c
endif
VBoxREMImp_SONAME.linux = VBoxREM.so
VBoxREMImp_SONAME.l4 = VBoxREM.s.so
VBoxREMImp_LDFLAGS.darwin = -install_name @executable_path/VBoxREM.dylib
#VBoxREMImp_LDFLAGS.darwin = -install_name VBoxREM.dylib
VBoxREMImp_LDFLAGS.l4 = -T$(L4_LIBDIR)/../main_rel.ld -nostdlib
$(PATH_TARGET)/VBoxREMImp.c: VBoxREM.def deftoimp.sed | $(call DIRDEP,$(PATH_TARGET))
$(MKDIR) -p $(PATH_TARGET)
$(SED) -f deftoimp.sed VBoxREM.def > $@.tmp
$(MV) -f $@.tmp $@
$(VBoxREMImp_SOURCES.os2): VBoxREM.def $(MAKEFILE) | $(call DIRDEP,$(PATH_TARGET))
$(SED) \
-e 's/^[ \t][ \t]*REMR3/ _REMR3/' \
-e 's/\.[Dd][Ll][Ll]//' \
-e 's/^LIBRARY .*/LIBRARY VBoxREM INITINSTANCE TERMINSTANCE\nDATA MULTIPLE\n/' \
VBoxREM.def > $@.tmp
$(MV) -f $@.tmp $@
include $(PATH_KBUILD)/footer.kmk
#
# Generate the op.S file somehow...
#
# Gathering the flags, defines and include dirs for the command is a lot
# of work. Unfortunately, there is only a highly specialized kBuild function
# for doing this, so we're currently left to our own devices here.
#
# Add something like VBOX_RECOMPILER_OP_GCC = gcc-3.4.6 to LocalConfig.kmk
# to be 100% sure that you get a working op.S. My gcc 4.1.1 seems to work
# fine, so feel free to try VBOX_RECOMPILER_OP_GCC = gcc.
#
# The op-undefined.lst is generated by finding all the undefined symbols
# in one (or more) ELF op.o files using nm.
#
ifeq ($(USERNAME).$(BUILD_TARGET),bird.linux)
VBOX_RECOMPILER_OP_GCC ?= $(TOOL_$(VBOX_GCC_TOOL)_CC) # gcc 4.1.1 works fine for me.
endif
ifndef VBOX_RECOMPILER_OP_GCC
ifeq ($(BUILD_TARGET).$(BUILD_TARGET_ARCH),darwin.x86)
VBOX_RECOMPILER_OP_GCC ?= i386-elf-gcc-3.4.3 # (port install i386-gcc-elf)
VBOX_RECOMPILER_OP_GCC_OK := yes
VBOX_RECOMPILER_OP_GCC_INCS ?= $(abspath $(dir $(shell LC_ALL=C $(VBOX_RECOMPILER_OP_GCC) -print-libgcc-file-name)))/include
endif
ifndef VBOX_RECOMPILER_OP_GCC
VBOX_RECOMPILER_OP_GCC := $(TOOL_$(VBOX_GCC_TOOL)_CC)
VBOX_RECOMPILER_OP_GCC_OK := dunno
endif
else
# If set, assume it's an OK compiler.
VBOX_RECOMPILER_OP_GCC_OK := yes
endif
# The command sans -o op.S.tmp.
COMPILE_OP_CMDS = $(VBOX_RECOMPILER_OP_GCC) \
-S -s \
$(filter-out -g -O0, \
$($(REM_MOD)_CFLAGS) $($(REM_MOD)_CFLAGS.$(BUILD_TYPE)) $($(REM_MOD)_CFLAGS.$(BUILD_TARGET)) $($(REM_MOD)_CFLAGS.$(BUILD_TARGET_ARCH)) $($(REM_MOD)_CFLAGS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
$(target-i386/op.c_CFLAGS) $(target-i386/op.c_CFLAGS.$(BUILD_TARGET)) $(target-i386/op.c_CFLAGS.$(BUILD_TARGET_ARCH)) $(target-i386/op.c_CFLAGS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
) \
$(addprefix -I, \
$($(REM_MOD)_CINCS.$(BUILD_TARGET_ARCH)) $($(REM_MOD)_CINCS.$(BUILD_TARGET)) $($(REM_MOD)_CINCS) $(CINCS) \
$($(REM_MOD)_INCS.$(BUILD_TARGET_ARCH)) $($(REM_MOD)_INCS.$(BUILD_TARGET)) $($(REM_MOD)_INCS) $(INCS) \
) \
$(addprefix -D, \
$($(REM_MOD)_CDEFS.$(BUILD_TARGET_ARCH)) $($(REM_MOD)_CDEFS.$(BUILD_TARGET)) $($(REM_MOD)_CDEFS) $(CDEFS.$(BUILD_TARGET)) $(CDEFS.$(BUILD_TYPE)) $(CDEFS) \
$($(REM_MOD)_DEFS.$(BUILD_TARGET_ARCH)) $($(REM_MOD)_DEFS.$(BUILD_TARGET)) $($(REM_MOD)_DEFS) $(DEFS.$(BUILD_TARGET)) $(DEFS.$(BUILD_TYPE)) $(DEFS) \
) \
-Wp,-MD,$(PATH_$(REM_MOD))/op.S.dep \
-Wp,-MT,$(PATH_$(REM_MOD))/op.S \
-Wp,-MP \
target-i386/op.c
# Use the right GCC includes.
ifdef VBOX_RECOMPILER_OP_GCC_INCS
COMPILE_OP_CMDS := $(subst $(VBOX_PATH_GCC_INCS),$(VBOX_RECOMPILER_OP_GCC_INCS),$(COMPILE_OP_CMDS))
endif
# Drop incompatible options when using the cross-compiler on darwin.
ifeq ($(BUILD_TARGET),darwin)
ifeq ($(filter-out i386-elf-gcc%, $(VBOX_RECOMPILER_OP_GCC)),)
COMPILE_OP_CMDS := $(filter-out -mdynamic-no-pic, $(COMPILE_OP_CMDS))
endif
endif
# include the dependencies
-include $(PATH_$(REM_MOD))/op.S.dep
# The rule.
$(PATH_$(REM_MOD))/op.S: \
target-i386/op.c \
staged/op-elf-$(BUILD_TARGET_ARCH).S \
op-validate.sed \
op-darwin.sed \
op-undefined.lst \
$(comp-cmds COMPILE_OP_CMDS,COMPILE_OP_CMDS_PREV,FORCE) \
| $(call DIRDEP,$(PATH_$(REM_MOD)))
$(RM) -f $@ $@.tmp $@.tmp2 $@.dep
ifeq ($(VBOX_RECOMPILER_OP_GCC_OK),yes)
$(call MSG_L1,Compiling $< => $@)
$(addsuffix $(SP)\$(NL)$(TAB) ,$(COMPILE_OP_CMDS)) -o $@.tmp
else ifeq ($(VBOX_RECOMPILER_OP_GCC_OK),dunno)
major_ver=`$(VBOX_RECOMPILER_OP_GCC) --version | $(SED) -e '/GCC/!d' -e 's/^.* (GCC) \([2-9]\)\..*$$/\1/'`; \
if test "$$major_ver" = "3"; then \
$(ECHO_EXT) "Compiling $< => $@" && \
$(addsuffix $(SP)\$(NL)$(TAB)$(TAB) ,$(COMPILE_OP_CMDS)) -o $@.tmp; \
else \
$(ECHO_EXT) "Using staged op.S (gcc major ver $$major_ver)" && \
$(CP_EXT) -f staged/op-elf-$(BUILD_TARGET_ARCH).S $@.tmp; \
fi
else
$(CP) staged/op-elf-$(BUILD_TARGET_ARCH).S $@.tmp
endif
$(SED) -f op-validate.sed $@.tmp
ifeq ($(BUILD_TARGET),darwin)
$(SED) -f op-darwin.sed $@.tmp > $@.tmp2
$(SED) -e 's/^\(.*\)$$/#define \1 _\1/' op-undefined.lst > $@.tmp
$(CAT_EXT) $@.tmp2 >> $@.tmp
endif
$(MV) -f $@.tmp $@
$(QUIET2)$(APPEND) "$@.dep"
$(QUIET2)$(APPEND) "$@.dep" 'define COMPILE_OP_CMDS_PREV'
$(QUIET2)$(APPEND) "$@.dep" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$@.dep" ',$(COMPILE_OP_CMDS))'
$(QUIET2)$(APPEND) "$@.dep" 'endef'
# Hack for crosscompiling.
DYNGEN = $(PATH_dyngen)/dyngen$(HOSTSUFF_EXE)
DYNGEN_EXEC = $(DYNGEN)
ifneq ($(BUILD_PLATFORM),$(BUILD_TARGET)) # hack for crosscompiling.
ifeq ($(BUILD_TARGET),win)
DYNGEN = $(PATH_dyngen)/dyngen.exe
DYNGEN_EXEC := $(EXEC_X86_WIN32) $(DYNGEN_EXEC)
endif
endif
# The dyngen rules.
$(PATH_$(REM_MOD))/op.h: $(FILE_OP_OBJ) $(DYNGEN)
$(call MSG_L1,dyngen => $@)
$(QUIET)$(DYNGEN_EXEC) -o $@ $<
$(PATH_$(REM_MOD))/opc.h: $(FILE_OP_OBJ) $(DYNGEN)
$(call MSG_L1,dyngen => $@)
$(QUIET)$(DYNGEN_EXEC) -c -o $@ $<
$(PATH_$(REM_MOD))/gen-op.h: $(FILE_OP_OBJ) $(DYNGEN)
$(call MSG_L1,dyngen => $@)
$(QUIET)$(DYNGEN_EXEC) -g -o $@ $<
# Dyngen dependants (sp?).
translate-all.c \
translate-op.c \
target-i386/translate.c \
: $(PATH_$(REM_MOD))/op.h $(PATH_$(REM_MOD))/opc.h $(PATH_$(REM_MOD))/gen-op.h
# Some aliases
do_dyngen: $(PATH_$(REM_MOD))/gen-op.h $(PATH_$(REM_MOD))/opc.h $(PATH_$(REM_MOD))/op.h
importlib: $(LIB_REM)
op.S: $(PATH_$(REM_MOD))/op.S