# $Id: Makefile.kmk 58667 2015-11-12 00:22:18Z vboxsync $ ## @file # VirtualBox Validation Kit - Bootsector Kit v3 # # # Copyright (C) 2006-2015 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # The contents of this file may alternatively be used under the terms # of the Common Development and Distribution License Version 1.0 # (CDDL) only, as it comes in the "COPYING.CDDL" file of the # VirtualBox OSE distribution, in which case the provisions of the # CDDL are applicable instead of those of the GPL. # # You may elect to license modified versions of this file under the # terms and conditions of either the GPL or the CDDL or both. # SUB_DEPTH = ../../../../.. include $(KBUILD_PATH)/subheader.kmk # # ----- Config.kmk: start ----- # # The bs3kit source directory. VBOX_PATH_BS3KIT_SRC = $(VBOX_PATH_VALIDATIONKIT_SRC)/bootsectors/bs3kit # Boot Sector post-link tool used below. BLDPROGS += VBoxBs3Linker VBoxBs3Linker_TEMPLATE = VBoxBldProg VBoxBs3Linker_SOURCES = $(VBOX_PATH_BS3KIT_SRC)/VBoxBs3Linker.cpp # 64-bit relocation conversion tool BLDPROGS += VBoxBs3ObjConverter VBoxBs3ObjConverter_TEMPLATE = VBoxBldProg VBoxBs3ObjConverter_SOURCES = $(VBOX_PATH_BS3KIT_SRC)/VBoxBs3ObjConverter.cpp # Dummy CP "linker" tool. TOOL_VBoxBsCpLd = Dummy copy linker. TOOL_VBoxBsCpLd_LINK_MISCBIN_OUTPUT = TOOL_VBoxBsCpLd_LINK_MISCBIN_DEPEND = TOOL_VBoxBsCpLd_LINK_MISCBIN_DEPORD = define TOOL_VBoxBsCpLd_LINK_MISCBIN_CMDS $(CP) -- $(objs) $(othersrc) "$(out)" endef # Dummy exit 1 "linker" tool. TOOL_VBoxBsUnusedLd = Dummy unused linker. TOOL_VBoxBsUnusedLd_LINK_MISCBIN_OUTPUT = TOOL_VBoxBsUnusedLd_LINK_MISCBIN_DEPEND = TOOL_VBoxBsUnusedLd_LINK_MISCBIN_DEPORD = define TOOL_VBoxBsUnusedLd_LINK_MISCBIN_CMDS echo "cannot use this template for linking" exit 1 endef # # elf cross compiling 64-bit gcc (mac): sudo port install x86_64-elf-gcc # TOOL_Bs3Gcc64Elf64 := AMD64/ELF64 gcc/g++ cross compiler for mac. TOOL_Bs3Gcc64Elf64_CC ?= x86_64-elf-gcc$(HOSTSUFF_EXE) -m64 TOOL_Bs3Gcc64Elf64_CXX ?= x86_64-elf-g++$(HOSTSUFF_EXE) -m64 ifdef SLKRUNS TOOL_Bs3Gcc64Elf64_CC += -fmessage-length=0 TOOL_Bs3Gcc64Elf64_CXX += -fmessage-length=0 endif TOOL_Bs3Gcc64Elf64_COBJSUFF ?= .o TOOL_Bs3Gcc64Elf64_CFLAGS ?= TOOL_Bs3Gcc64Elf64_CFLAGS.debug ?= -g TOOL_Bs3Gcc64Elf64_CFLAGS.profile ?= -O2 #-g -pg TOOL_Bs3Gcc64Elf64_CFLAGS.release ?= -O2 TOOL_Bs3Gcc64Elf64_CINCS ?= TOOL_Bs3Gcc64Elf64_CDEFS ?= TOOL_Bs3Gcc64Elf64_COMPILE_C_DEPEND = $(VBoxBs3ObjConverter_1_TARGET) TOOL_Bs3Gcc64Elf64_COMPILE_C_DEPORD = TOOL_Bs3Gcc64Elf64_COMPILE_C_OUTPUT = define TOOL_Bs3Gcc64Elf64_COMPILE_C_CMDS $(QUIET)$(TOOL_Bs3Gcc64Elf64_CC) -c\ $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef TOOL_Bs3Gcc64Elf64_CXXOBJSUFF ?= .o TOOL_Bs3Gcc64Elf64_CXXOBJSUFF ?= .o TOOL_Bs3Gcc64Elf64_CXXFLAGS ?= TOOL_Bs3Gcc64Elf64_CXXFLAGS.debug ?= -g0 # no debug info, thank you TOOL_Bs3Gcc64Elf64_CXXFLAGS.profile ?= -O2 #-g -pg TOOL_Bs3Gcc64Elf64_CXXFLAGS.release ?= -O2 TOOL_Bs3Gcc64Elf64_CXXINCS ?= TOOL_Bs3Gcc64Elf64_CXXDEFS ?= TOOL_Bs3Gcc64Elf64_COMPILE_CXX_DEPEND = $(VBoxBs3ObjConverter_1_TARGET) TOOL_Bs3Gcc64Elf64_COMPILE_CXX_DEPORD = TOOL_Bs3Gcc64Elf64_COMPILE_CXX_OUTPUT = define TOOL_Bs3Gcc64Elf64_COMPILE_CXX_CMDS $(QUIET)$(TOOL_Bs3Gcc64Elf64_CXX) -c\ $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ -o $(obj)\ $(abspath $(source)) $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" "" endef # # VCC elf cross compiling 64-bit gcc (mac): sudo port install x86_64-elf-gcc # TOOL_Bs3Vcc64 := Visual C++ 64-bit TOOL_Bs3Vcc64_CC = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_CC) TOOL_Bs3Vcc64_CXX = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_CXX) TOOL_Bs3Vcc64_COBJSUFF = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COBJSUFF) TOOL_Bs3Vcc64_CFLAGS = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_CFLAGS) TOOL_Bs3Vcc64_CFLAGS.debug = TOOL_Bs3Vcc64_CFLAGS.dbgopt = -O1 TOOL_Bs3Vcc64_CFLAGS.profile = -O1 TOOL_Bs3Vcc64_CFLAGS.release = -O1 TOOL_Bs3Vcc64_CINCS = $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_INC) TOOL_Bs3Vcc64_CDEFS = TOOL_Bs3Vcc64_COMPILE_C_DEPEND = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_DEPEND) $(VBoxBs3ObjConverter_1_TARGET) TOOL_Bs3Vcc64_COMPILE_C_DEPORD = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_DEPORD) TOOL_Bs3Vcc64_COMPILE_C_OUTPUT = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_OUTPUT) TOOL_Bs3Vcc64_COMPILE_C_OUTPUT_MAYBE = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_OUTPUT_MAYBE) define TOOL_Bs3Vcc64_COMPILE_C_CMDS $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_C_CMDS) -$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" endef TOOL_Bs3Vcc64_CXXOBJSUFF = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_CXXOBJSUFF) TOOL_Bs3Vcc64_CXXFLAGS = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_CXXFLAGS) TOOL_Bs3Vcc64_CXXFLAGS.debug = TOOL_Bs3Vcc64_CXXFLAGS.dbgopt = -O1 TOOL_Bs3Vcc64_CXXFLAGS.profile = -O1 TOOL_Bs3Vcc64_CXXFLAGS.release = -O1 TOOL_Bs3Vcc64_CXXINCS = $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_INC) TOOL_Bs3Vcc64_CXXDEFS = TOOL_Bs3Vcc64_COMPILE_CXX_DEPEND = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_CXX_DEPEND) $(VBoxBs3ObjConverter_1_TARGET) TOOL_Bs3Vcc64_COMPILE_CXX_DEPORD = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_CXX_DEPORD) TOOL_Bs3Vcc64_COMPILE_CXX_OUTPUT = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_CXX_OUTPUT) TOOL_Bs3Vcc64_COMPILE_CXX_OUTPUT_MAYBE = $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_CXX_OUTPUT_MAYBE) define TOOL_Bs3Vcc64_COMPILE_CXX_CMDS $(TOOL_$(VBOX_VCC_TOOL_STEM)AMD64_COMPILE_CXX_CMDS) $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" endef # Debug info format depends on what we use for 64-bit. if1of ($(KBUILD_HOST), win) BS3_OW_DBG_OPT = -hc BS3_OW_DBG_LDOPT = codeview else BS3_OW_DBG_OPT = -hd BS3_OW_DBG_LDOPT = dwarf endif # BS3Kit template for assembly and 16-bit code. TEMPLATE_VBoxBS3KitImg = Template for building BS3Kit test images. TEMPLATE_VBoxBS3KitImg_BLD_TRG = os-agnostic TEMPLATE_VBoxBS3KitImg_BLD_TRG_ARCH = x86 TEMPLATE_VBoxBS3KitImg_INST = $(INST_VALIDATIONKIT)bootsectors/ TEMPLATE_VBoxBS3KitImg_BINSUFF = .img TEMPLATE_VBoxBS3KitImg_MODE = 0644 TEMPLATE_VBoxBS3KitImg_ASTOOL = NASM TEMPLATE_VBoxBS3KitImg_ASFLAGS = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels TEMPLATE_VBoxBS3KitImg_ASDEFS = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__ TEMPLATE_VBoxBS3KitImg_DEFS = ARCH_BITS=16 IN_BS3KIT TEMPLATE_VBoxBS3KitImg_ARTOOL = OPENWATCOM-16 TEMPLATE_VBoxBS3KitImg_CTOOL = OPENWATCOM-16 TEMPLATE_VBoxBS3KitImg_CXXTOOL = OPENWATCOM-16 TEMPLATE_VBoxBS3KitImg_CFLAGS = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc $(BS3_OW_DBG_OPT) -d2 TEMPLATE_VBoxBS3KitImg_CXXFLAGS = -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecc -q -3 -wx -zl -zu -s -oafs -mc $(BS3_OW_DBG_OPT) -d2 TEMPLATE_VBoxBS3KitImg_INCS = $(VBOX_PATH_BS3KIT_SRC) . TEMPLATE_VBoxBS3KitImg_LDTOOL = OPENWATCOM-WL # option quiet, nofarcalls\ # disable 1014, 1023, 2120, 1080 TEMPLATE_VBoxBS3KitImg_LDFLAGS = system dos \ debug $(BS3_OW_DBG_LDOPT) all \ option quiet, map, statics, verbose, symfile, start=_start \ disable 1014, 1080, 1150 \ \ output raw offset=0x10000 \ order \ clname BS3CODE16 segaddr=0x1000 \ segment BS3TEXT16 \ segment text \ clname FAR_DATA \ segment BS3DATA16 \ segment BS3DATA16CONST \ segment BS3DATA16CONST2 \ segment BS3DATA16_DATA \ segment BS3DATA32 \ segment BS3DATA32_CONST \ segment BS3DATA32_CONST2 \ segment BS3DATA32_DATA \ segment DATA32 \ clname BS3CODE32 \ segment BS3TEXT32 \ segment TEXT32 \ clname CODE \ segment BS3TEXT64 \ segment TEXT64 \ segment .text \ segment .rdata \ clname DATA \ segment BS3DATA64 \ segment DATA64 \ segment .data TEMPLATE_VBoxBS3KitImg_DEPS = \ $(bs3-bootsector_1_TARGET) \ $(VBoxBs3Linker_1_TARGET) TEMPLATE_VBoxBS3KitImg_POST_CMDS = $(if $(eq $(tool_do),LINK_LIBRARY)\ ,,$(QUIET)$(MV_EXT) -f -- "$(out)" "$(out).tmp" \ $$(NLTAB)$(QUIET)$(VBoxBs3Linker_1_TARGET) -o $(out) $(bs3-bootsector_1_TARGET) $(out).tmp \ $$(NLTAB)$(QUIET)$(RM_EXT) -f -- "$(out).tmp") TEMPLATE_VBoxBS3KitImg_LIBS = \ $(PATH_OBJ)/bs3kit-common-16/bs3kit-common-16.lib \ $(PATH_OBJ)/bs3kit-common-32/bs3kit-common-32.lib \ $(PATH_OBJ)/bs3kit-common-64-asm/bs3kit-common-64-asm.lib \ $(PATH_OBJ)/bs3kit-common-64-c/bs3kit-common-64-c.lib # BS3Kit template for 32-bit code. TEMPLATE_VBoxBS3KitImg32 = Template for building BS3Kit test images. TEMPLATE_VBoxBS3KitImg32_BLD_TRG = os-agnostic TEMPLATE_VBoxBS3KitImg32_BLD_TRG_ARCH = x86 TEMPLATE_VBoxBS3KitImg32_INSTTYPE = none TEMPLATE_VBoxBS3KitImg32_ASTOOL = NASM TEMPLATE_VBoxBS3KitImg32_ASFLAGS = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels TEMPLATE_VBoxBS3KitImg32_ASDEFS = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__ TEMPLATE_VBoxBS3KitImg32_DEFS = ARCH_BITS=32 IN_BS3KIT TEMPLATE_VBoxBS3KitImg32_ARTOOL = OPENWATCOM TEMPLATE_VBoxBS3KitImg32_CTOOL = OPENWATCOM TEMPLATE_VBoxBS3KitImg32_CXXTOOL = OPENWATCOM TEMPLATE_VBoxBS3KitImg32_CFLAGS = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf $(BS3_OW_DBG_OPT) -d2 TEMPLATE_VBoxBS3KitImg32_CXXFLAGS = -nt=BS3TEXT32 -nd=BS3DATA32 -nc=BS3CODE32 -ecc -q -wx -zu -zl -s -oas -mf $(BS3_OW_DBG_OPT) -d2 TEMPLATE_VBoxBS3KitImg32_INCS = $(VBOX_PATH_BS3KIT_SRC) . TEMPLATE_VBoxBS3KitImg32_LDTOOL = VBoxBsUnusedLd # BS3Kit template for 64-bit code. TEMPLATE_VBoxBS3KitImg64 = Template for building BS3Kit test images. TEMPLATE_VBoxBS3KitImg64_BLD_TRG = os-agnostic TEMPLATE_VBoxBS3KitImg64_BLD_TRG_ARCH = amd64 TEMPLATE_VBoxBS3KitImg64_INSTTYPE = none TEMPLATE_VBoxBS3KitImg64_ASTOOL = NASM TEMPLATE_VBoxBS3KitImg64_ASFLAGS = -f obj -g --allow-64bit-code-anywhere -w+orphan-labels TEMPLATE_VBoxBS3KitImg64_ASDEFS = ASM_FORMAT_OMF RT_NOINC_SEGMENTS __NASM__ TEMPLATE_VBoxBS3KitImg64_DEFS = IN_BS3KIT ARCH_BITS=64 TEMPLATE_VBoxBS3KitImg64_ARTOOL = OPENWATCOM TEMPLATE_VBoxBS3KitImg64_INCS = $(VBOX_PATH_BS3KIT_SRC) . if1of ($(KBUILD_HOST), win) TEMPLATE_VBoxBS3KitImg64_CTOOL := Bs3Vcc64 TEMPLATE_VBoxBS3KitImg64_CXXTOOL := Bs3Vcc64 TEMPLATE_VBoxBS3KitImg64_CFLAGS = -Zi -O1 -Oi -GF -GS- -Gy -Gs65536 TEMPLATE_VBoxBS3KitImg64_CXXFLAGS = -Zi -O1 -Oi -GF -GS- -Gy -Gs65536 else if1of ($(KBUILD_HOST), darwin) TEMPLATE_VBoxBS3KitImg64_CTOOL := Bs3Gcc64Elf64 TEMPLATE_VBoxBS3KitImg64_CXXTOOL := Bs3Gcc64Elf64 else TEMPLATE_VBoxBS3KitImg64_CTOOL := $(VBOX_GCC_TOOL) TEMPLATE_VBoxBS3KitImg64_CXXTOOL := $(VBOX_GCC_TOOL) endif TEMPLATE_VBoxBS3KitImg64_CFLAGS = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_C) TEMPLATE_VBoxBS3KitImg64_CXXFLAGS = -m64 -maccumulate-outgoing-args -g -Os -fno-omit-frame-pointer $(VBOX_GCC_WARN_PEDANTIC_CXX) endif TEMPLATE_VBoxBS3KitImg64_LDTOOL = VBoxBsUnusedLd # BS3Kit template for the bootsector. TEMPLATE_VBoxBS3KitBS = Template for building BS3Kit test images. TEMPLATE_VBoxBS3KitBS_BLD_TRG = os-agnostic TEMPLATE_VBoxBS3KitBS_BLD_TRG_ARCH = x86 TEMPLATE_VBoxBS3KitBS_INST = $(INST_VALIDATIONKIT)bootsectors/ TEMPLATE_VBoxBS3KitBS_INSTTYPE = none TEMPLATE_VBoxBS3KitBS_BINSUFF = .img TEMPLATE_VBoxBS3KitBS_MODE = 0644 TEMPLATE_VBoxBS3KitBS_ASTOOL = YASM TEMPLATE_VBoxBS3KitBS_ASFLAGS = -f bin --mapfile TEMPLATE_VBoxBS3KitBS_ASDEFS = ASM_FORMAT_BIN RT_NOINC_SEGMENTS ARCH_BITS=16 __YASM__ TEMPLATE_VBoxBS3KitBS_INCS = $(VBOX_PATH_BS3KIT_SRC) . TEMPLATE_VBoxBS3KitBS_LDTOOL = VBoxBsCpLd # # ----- Config.kmk: end ----- # # The boot sector. MISCBINS += bs3-bootsector bs3-bootsector_TEMPLATE = VBoxBS3KitBS bs3-bootsector_SOURCES = bs3-bootsector.asm # Common sources to be compiled into _p16, _p32 and _p64 versions. VBOX_BS3KIT_COMMON_SOURCES = \ bs3-cmn-Shutdown.asm \ bs3-cmn-Panic.asm \ bs3-cmn-PrintU32.asm \ bs3-cmn-PrintStrColonSpaces.asm \ bs3-cmn-PrintStrSpacesColonSpace.c \ bs3-cmn-StrLen.c \ bs3-cmn-StrNLen.c \ bs3-cmn-StrCpy.c \ bs3-cmn-MemCpy.c \ bs3-cmn-MemPCpy.c \ bs3-cmn-MemMove.c \ # The BS3Kit library. LIBRARIES += bs3kit-common-16 bs3kit-common-16_TEMPLATE = VBoxBS3KitImg bs3kit-common-16_DEFS = TMPL_PE16 BS3_CMN_ONLY bs3kit-common-16_SOURCES = $(VBOX_BS3KIT_COMMON_SOURCES) # The 32-bit BS3Kit library. LIBRARIES += bs3kit-common-32 bs3kit-common-32_TEMPLATE = VBoxBS3KitImg32 bs3kit-common-32_DEFS = TMPL_PE32 BS3_CMN_ONLY bs3kit-common-32_SOURCES = $(VBOX_BS3KIT_COMMON_SOURCES) # The 64-bit BS3Kit library. LIBRARIES += bs3kit-common-64-asm bs3kit-common-64-asm_TEMPLATE = VBoxBS3KitImg64 bs3kit-common-64-asm_DEFS = TMPL_LM64 BS3_CMN_ONLY bs3kit-common-64-asm_SOURCES = $(filter %.asm,$(VBOX_BS3KIT_COMMON_SOURCES)) # The 64-bit BS3Kit library. LIBRARIES += bs3kit-common-64-c bs3kit-common-64-c_TEMPLATE = VBoxBS3KitImg64 bs3kit-common-64-c_DEFS = TMPL_LM64 BS3_CMN_ONLY bs3kit-common-64-c_SOURCES = $(filter-out %.asm,$(VBOX_BS3KIT_COMMON_SOURCES)) # # shutdown example. # MISCBINS += bs3-shutdown bs3-shutdown_TEMPLATE = VBoxBS3KitImg bs3-shutdown_SOURCES = bs3-first-rm.asm bs3-shutdown.c include $(FILE_KBUILD_SUB_FOOTER)