Index: trunk/kBuild/tools/GCC3OMF.kmk
===================================================================
--- trunk/kBuild/tools/GCC3OMF.kmk	(revision 182)
+++ trunk/kBuild/tools/GCC3OMF.kmk	(revision 182)
@@ -0,0 +1,232 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - OS/2 GCC v3 OMF.
+#
+# Copyright (c) 2004 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_GCC3OMF                    := OS/2 GCC v3 OMF
+
+TOOL_GCC3OMF_CC                 := gcc$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_COBJSUFF           := .o
+TOOL_GCC3OMF_CFLAGS             := -g -Zomf
+TOOL_GCC3OMF_CFLAGS.debug       := -O0
+TOOL_GCC3OMF_CFLAGS.release     := -O2
+TOOL_GCC3OMF_CFLAGS.profile     := -O2 #-pg
+TOOL_GCC3OMF_CINCS              :=
+TOOL_GCC3OMF_CDEFS              :=
+
+TOOL_GCC3OMF_CXX                := g++$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_CXXOBJSUFF         := .o
+TOOL_GCC3OMF_CXXOBJSUFF         := .o
+TOOL_GCC3OMF_CXXFLAGS           := -g -Zomf
+TOOL_GCC3OMF_CXXFLAGS.debug     := -O0
+TOOL_GCC3OMF_CXXFLAGS.release   := -O2
+TOOL_GCC3OMF_CXXFLAGS.profile   := -O2 #-pg
+TOOL_GCC3OMF_CXXINCS            :=
+TOOL_GCC3OMF_CXXDEFS            :=
+
+TOOL_GCC3OMF_AS                 := emxomfas$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_ASOBJSUFF          := .obj
+
+TOOL_GCC3OMF_AR                 := emxomfar$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_ARFLAGS            := cr
+TOOL_GCC3OMF_ARLIBSUFF          := .lib
+
+TOOL_GCC3OMF_LD                 := g++$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_LD_SYSMOD          := emxomfld$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_LDFLAGS            := -Zomf
+TOOL_GCC3OMF_LDFLAGS.debug      := -g
+TOOL_GCC3OMF_LDFLAGS.release    := -s
+ifndef TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET)
+TOOL_GCC3OMF_LDFLAGS.dll        := -shared
+else
+TOOL_GCC3OMF_LDFLAGS.dll        := $(TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET))
+endif
+TOOL_GCC3OMF_LDFLAGS.sysmod     := -r
+
+ifdef SLKRUNS
+TOOL_GCC3OMF_CC  += -fmessage-length=0
+TOOL_GCC3OMF_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    $(outbase)  Output basename (full). Use this for list files and such.
+# @param	$(objsuff)  Object suffix.
+define TOOL_GCC3OMF_COMPILE_C
+#$ (warning dbg: TOOL_GCC3OMF_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(dirdep) $(source)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3OMF_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(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    $(outbase)  Output basename (full). Use this for list files and such.
+# @param	$(objsuff)  Object suffix.
+define TOOL_GCC3OMF_COMPILE_CXX
+#$ (warning dbg: TOOL_GCC3OMF_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(dirdep) $(source)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3OMF_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+		
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param	$(dirdep)   Directory creation dependency.
+# @param	$(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3OMF_LINK_LIBRARY
+#$ (warning dbg: TOOL_GCC3OMF_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
+$(lib): $(dirdep) $(objs) $(deps)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+	$(TOOL_GCC3OMF_AR) $(flags) $$@ $(objs)
+	
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		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.
+define TOOL_GCC3OMF_LINK_PROGRAM
+#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif	
+	$(TOOL_GCC3OMF_LD) $(flags) -o $$@ $(objs) \
+	$(foreach p,$(libpath), -L$(p)) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif	
+	
+endef
+
+
+## Link DLL
+# @param    $(target)   Normalized main target name.
+# @param    $(dll)		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.
+define TOOL_GCC3OMF_LINK_DLL
+#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(dll): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif	
+	$(TOOL_GCC3OMF_LD) $(TOOL_GCC3OMF_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
+	$(foreach p,$(libpath), -L$(p)) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif	
+	
+endef
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(sys)		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.
+define TOOL_GCC3OMF_LINK_SYSMOD
+#$ (warning dbg: TOOL_GCC3OMF_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(sys): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif	
+	$(TOOL_GCC3OMF_LD_SYSMOD) $(TOOL_GCC3OMF_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif	
+
+endef
+													
