Index: /trunk/kBuild/tools/XGCCAMD64LINUX.kmk
===================================================================
--- /trunk/kBuild/tools/XGCCAMD64LINUX.kmk	(revision 459)
+++ /trunk/kBuild/tools/XGCCAMD64LINUX.kmk	(revision 459)
@@ -0,0 +1,256 @@
+# $Id: GCC3.kmk 380 2005-12-18 13:52:47Z bird $
+## @file
+#
+# kBuild Tool Config - GCC Cross compiler for AMD64 (aka x86_64).
+#
+# Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+TOOL_XGCCAMD64LINUX                    := GCC Cross Compiler for AMD64
+
+#
+# Determin some stuff dynamically.
+#
+_TOOL_XGCCAMD64LINUX_PREFIX            :=
+_TOOL_XGCCAMD64LINUX_EXEC_PREFIX       :=
+_TOOL_XGCCAMD64LINUX_SUFF_EXE          :=
+ifeq ($(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH),linux.amd64)
+# not x-compile.
+PATH_TOOL_XGCCAMD64LINUX               :=
+else # x-compile:
+# find the latest xgcc build.
+_TOOL_XGCCAMD64LINUX_PREFIX            := x86_64-unknown-linux-gnu-
+ifndef PATH_TOOL_XGCCAMD64LINUX
+PATH_TOOL_XGCCAMD64LINUX               := $(sort $(wildcard $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)/x86_64-unknown-linux-gnu/*))
+ifeq ($(filter-out win64,$(BUILD_PLATFORM)),) # these can use the windows build.
+_TOOL_XGCCAMD64LINUX_EXEC_PREFIX       := $(EXEC_X86_WIN32)
+PATH_TOOL_XGCCAMD64LINUX               := $(sort $(wildcard $(PATH_DEV)/x86.win32/x86_64-unknown-linux-gnu/*))
+endif
+ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
+PATH_TOOL_XGCCAMD64LINUX               := $(call lastword,$(PATH_TOOL_XGCCAMD64LINUX))
+endif
+endif # !PATH_TOOL_XGCCAMD64LINUX
+endif
+ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
+_TOOL_XGCCAMD64LINUX_PREFIX            := $(_TOOL_XGCCAMD64LINUX_EXEC_PREFIX) $(PATH_TOOL_XGCCAMD64LINUX)/bin/$(_TOOL_XGCCAMD64LINUX_PREFIX)
+endif
+
+
+TOOL_XGCCAMD64LINUX_CC                 := $(_TOOL_XGCCAMD64LINUX_PREFIX)gcc$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_COBJSUFF           := .o
+TOOL_XGCCAMD64LINUX_CFLAGS             := -g
+TOOL_XGCCAMD64LINUX_CFLAGS.debug       := -O0
+TOOL_XGCCAMD64LINUX_CFLAGS.release     := -O2
+TOOL_XGCCAMD64LINUX_CFLAGS.profile     := -O2 #-pg
+TOOL_XGCCAMD64LINUX_CINCS              :=
+TOOL_XGCCAMD64LINUX_CDEFS              :=
+
+TOOL_XGCCAMD64LINUX_CXX                := $(_TOOL_XGCCAMD64LINUX_PREFIX)g++$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_CXXOBJSUFF         := .o
+TOOL_XGCCAMD64LINUX_CXXOBJSUFF         := .o
+TOOL_XGCCAMD64LINUX_CXXFLAGS           := -g
+TOOL_XGCCAMD64LINUX_CXXFLAGS.debug     := -O0
+TOOL_XGCCAMD64LINUX_CXXFLAGS.release   := -O2
+TOOL_XGCCAMD64LINUX_CXXFLAGS.profile   := -O2 #-pg
+TOOL_XGCCAMD64LINUX_CXXINCS            :=
+TOOL_XGCCAMD64LINUX_CXXDEFS            :=
+
+TOOL_XGCCAMD64LINUX_AS                 := $(_TOOL_XGCCAMD64LINUX_PREFIX)as$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_ASOBJSUFF          := .o
+
+TOOL_XGCCAMD64LINUX_AR                 := $(_TOOL_XGCCAMD64LINUX_PREFIX)ar$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_ARFLAGS            := cr
+TOOL_XGCCAMD64LINUX_ARLIBSUFF          := .a
+
+TOOL_XGCCAMD64LINUX_LD                 := $(_TOOL_XGCCAMD64LINUX_PREFIX)g++$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_LD_SYSMOD          := $(_TOOL_XGCCAMD64LINUX_PREFIX)ld$(HOSTSUFF_EXE)
+TOOL_XGCCAMD64LINUX_LDFLAGS            :=
+TOOL_XGCCAMD64LINUX_LDFLAGS.debug      := -g
+TOOL_XGCCAMD64LINUX_LDFLAGS.release    := -s
+ifndef TOOL_XGCCAMD64LINUX_LDFLAGS.$(BUILD_TARGET)
+TOOL_XGCCAMD64LINUX_LDFLAGS.dll        := -shared
+else
+TOOL_XGCCAMD64LINUX_LDFLAGS.dll        := $(TOOL_XGCCAMD64LINUX_LDFLAGS.$(BUILD_TARGET))
+endif
+TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod     := -r
+TOOL_XGCCAMD64LINUX_LD_SONAME           = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
+ifeq ($(BUILD_TARGET),os2)
+TOOL_XGCCAMD64LINUX_LD_MAP              = -Zmap=$(1)
+else
+TOOL_XGCCAMD64LINUX_LD_MAP              = -Wl,-Map -Wl,$(1) -Wl,--cref
+endif
+ifeq ($(BUILD_TARGET),os2)
+TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP       = -Zmap=$(1)
+else
+TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP       = -Map $(1) --cref
+endif
+ifdef SLKRUNS
+TOOL_XGCCAMD64LINUX_CC  += -fmessage-length=0
+TOOL_XGCCAMD64LINUX_CXX += -fmessage-length=0
+endif
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
+TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
+TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
+define TOOL_XGCCAMD64LINUX_COMPILE_C_CMDS
+	$(TOOL_XGCCAMD64LINUX_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(call ABSPATH,$(source))
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
+TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
+TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
+define TOOL_XGCCAMD64LINUX_COMPILE_CXX_CMDS
+	$(TOOL_XGCCAMD64LINUX_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(call ABSPATH,$(source))
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(out)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
+TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
+TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
+define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
+	$(APPEND) $(out).ar-script "CREATE $(out)"
+	$(foreach o, $(objs)\
+		,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
+	$(foreach srclib, $(filter %.a %.lib,$(othersrc))\
+		,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
+	$(APPEND) $(out).ar-script "SAVE"
+	$(APPEND) $(out).ar-script "END"
+	$(TOOL_XGCCAMD64LINUX_AR) -M < $(out).ar-script
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(out)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
+TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
+TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD = 
+define TOOL_XGCCAMD64LINUX_LINK_PROGRAM_CMDS
+	$(TOOL_XGCCAMD64LINUX_LD) $(flags) -o $(out) $(objs)\
+		$(foreach p,$(libpath), -L$(p))\
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
+		$(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
+endef
+
+
+## Link DLL
+# @param    $(target)   Normalized main target name.
+# @param    $(out)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
+TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
+TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
+define TOOL_XGCCAMD64LINUX_LINK_DLL_CMDS
+	$(TOOL_XGCCAMD64LINUX_LD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.dll) $(flags) -o $(out)\
+		$(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_XGCCAMD64LINUX_LD_SONAME,$(target),$(out)))\
+		$(objs)\
+		$(foreach p,$(libpath), -L$(p))\
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
+		$(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
+endef
+
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(out)		System module name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
+TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
+TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
+define TOOL_XGCCAMD64LINUX_LINK_SYSMOD_CMDS
+	$(TOOL_XGCCAMD64LINUX_LD_SYSMOD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
+		$(foreach p,$(libpath), -L$(p))\
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
+		$(call TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP,$(outbase).map)
+endef
+
