Index: /trunk/kBuild/tools/GXX32.kmk
===================================================================
--- /trunk/kBuild/tools/GXX32.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX32.kmk	(revision 3258)
@@ -38,4 +38,5 @@
 TOOL_GXX32_CC  ?= gcc$(HOSTSUFF_EXE) -m32
 TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
+TOOL_GXX32_PCH ?= $(TOOL_GXX32_CXX)
 TOOL_GXX32_AS  ?= gcc$(HOSTSUFF_EXE) -m32
 TOOL_GXX32_AR  ?= ar$(HOSTSUFF_EXE)
@@ -80,5 +81,4 @@
 
 TOOL_GXX32_CXXOBJSUFF       ?= .o
-TOOL_GXX32_CXXOBJSUFF       ?= .o
 TOOL_GXX32_CXXFLAGS         ?=
 TOOL_GXX32_CXXFLAGS.debug   ?= -g
@@ -88,4 +88,12 @@
 TOOL_GXX32_CXXDEFS          ?=
 
+TOOL_GXX32_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX32_PCHFLAGS         ?= $(TOOL_GXX32_CXXFLAGS)
+TOOL_GXX32_PCHFLAGS.debug   ?= $(TOOL_GXX32_CXXFLAGS.debug)
+TOOL_GXX32_PCHFLAGS.profile ?= $(TOOL_GXX32_CXXFLAGS.profile)
+TOOL_GXX32_PCHFLAGS.release ?= $(TOOL_GXX32_CXXFLAGS.release)
+TOOL_GXX32_PCHINCS          ?= $(TOOL_GXX32_CXXINCS)
+TOOL_GXX32_PCHDEFS          ?= $(TOOL_GXX32_CXXDEFS)
+
 TOOL_GXX32_ASFLAGS          ?= -x assembler-with-cpp
 TOOL_GXX32_ASFLAGS.debug    ?= -g
@@ -116,8 +124,8 @@
 TOOL_GXX32_COMPILE_C_DEPEND =
 TOOL_GXX32_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX32_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX32_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX32_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -131,9 +139,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX32_COMPILE_C_OUTPUT =
-define TOOL_GXX32_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX32_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -141,10 +145,52 @@
 		-o $(obj)\
 		$(abspath $(source))
+endif
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
 ## 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_GXX32_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX32_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX32_COMPILE_CXX_DEPORD         =
+TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
+define TOOL_GXX32_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
+	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
+		--kObjCache-cpp $(outbase).ii\
+		$(TOOL_GXX32_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		$(abspath $(source))\
+		--kObjCache-cc $(obj)\
+		$(TOOL_GXX32_CXX) -c\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
+		-o $(obj)\
+		-
+else
+	$(QUIET)$(TOOL_GXX32_CXX) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
 # @param    $(target)   Normalized main target name.
 # @param    $(source)   Source filename (relative).
@@ -158,34 +204,16 @@
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
 # @param    $(objsuff)  Object suffix.
-TOOL_GXX32_COMPILE_CXX_DEPEND =
-TOOL_GXX32_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX32_COMPILE_CXX_OUTPUT = $(outbase).ii
-define TOOL_GXX32_COMPILE_CXX_CMDS
-	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
-		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX32_CXX) -E -o -\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		$(abspath $(source))\
-		--kObjCache-cc $(obj)\
-		$(TOOL_GXX32_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
-		-o $(obj)\
-		-
+TOOL_GXX32_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX32_COMPILE_PCH_DEPEND =
+TOOL_GXX32_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX32_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX32_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX32_COMPILE_CXX_OUTPUT =
-define TOOL_GXX32_COMPILE_CXX_CMDS
-	$(QUIET)$(TOOL_GXX32_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
@@ -231,8 +259,8 @@
 	$(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
 	$(QUIET)$(APPEND) -n $(out).ar-script \
-		$(foreach o,$(objs), 'ADDMOD $(o)') \
+		$(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
 		$(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
 	$(if $(filter %.def %.imp %.dll,$(othersrc))\
-		,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
+		,$(TOOL_GXX32_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
 		 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
 	$(QUIET)$(APPEND) $(out).ar-script 'SAVE'
@@ -263,5 +291,5 @@
 TOOL_GXX32_LINK_PROGRAM_DEPORD =
 define TOOL_GXX32_LINK_PROGRAM_CMDS
-	$(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
@@ -298,5 +326,5 @@
 	$(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
 		$(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
@@ -331,5 +359,5 @@
 TOOL_GXX32_LINK_SYSMOD_DEPORD =
 define TOOL_GXX32_LINK_SYSMOD_CMDS
-	$(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
 		$(filter %.def, $(othersrc))\
 		$(foreach p,$(libpath), -L$(p))\
Index: /trunk/kBuild/tools/GXX3OMF.kmk
===================================================================
--- /trunk/kBuild/tools/GXX3OMF.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX3OMF.kmk	(revision 3258)
@@ -37,4 +37,5 @@
 TOOL_GXX3OMF_CC  ?= gcc$(HOSTSUFF_EXE)
 TOOL_GXX3OMF_CXX ?= g++$(HOSTSUFF_EXE)
+TOOL_GXX3OMF_PCH ?= $(TOOL_GXX3OMF_CXX)
 TOOL_GXX3OMF_AS  ?= gcc$(HOSTSUFF_EXE)
 TOOL_GXX3OMF_AR  ?= emxomfar$(HOSTSUFF_EXE)
@@ -67,5 +68,4 @@
 
 TOOL_GXX3OMF_CXXOBJSUFF       ?= .o
-TOOL_GXX3OMF_CXXOBJSUFF       ?= .o
 TOOL_GXX3OMF_CXXFLAGS         ?= -Zomf
 TOOL_GXX3OMF_CXXFLAGS.debug   ?= -g
@@ -75,4 +75,12 @@
 TOOL_GXX3OMF_CXXDEFS          ?=
 
+TOOL_GXX3OMF_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX3OMF_PCHFLAGS         ?= $(TOOL_GXX3OMF_CXXFLAGS)
+TOOL_GXX3OMF_PCHFLAGS.debug   ?= $(TOOL_GXX3OMF_CXXFLAGS.debug)
+TOOL_GXX3OMF_PCHFLAGS.profile ?= $(TOOL_GXX3OMF_CXXFLAGS.profile)
+TOOL_GXX3OMF_PCHFLAGS.release ?= $(TOOL_GXX3OMF_CXXFLAGS.release)
+TOOL_GXX3OMF_PCHINCS          ?= $(TOOL_GXX3OMF_CXXINCS)
+TOOL_GXX3OMF_PCHDEFS          ?= $(TOOL_GXX3OMF_CXXDEFS)
+
 TOOL_GXX3OMF_ASFLAGS          ?= -x assembler-with-cpp -Zomf
 TOOL_GXX3OMF_ASFLAGS.debug    ?= -g
@@ -108,8 +116,8 @@
 TOOL_GXX3OMF_COMPILE_C_DEPEND =
 TOOL_GXX3OMF_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX3OMF_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX3OMF_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX3OMF_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX3OMF_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX3OMF_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -123,17 +131,13 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX3OMF_COMPILE_C_OUTPUT =
-define TOOL_GXX3OMF_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX3OMF_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
 		-o $(obj)\
 		$(abspath $(source))
+endif
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
@@ -142,22 +146,22 @@
 # @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_GXX3OMF_COMPILE_CXX_DEPEND =
-TOOL_GXX3OMF_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX3OMF_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX3OMF_COMPILE_CXX_OUTPUT = $(outbase).ii
+# @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_GXX3OMF_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX3OMF_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX3OMF_COMPILE_CXX_DEPORD         =
+TOOL_GXX3OMF_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX3OMF_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX3OMF_CXX) -E -o -\
+		$(TOOL_GXX3OMF_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
 		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
@@ -165,20 +169,43 @@
 		--kObjCache-cc $(obj)\
 		$(TOOL_GXX3OMF_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
 		-o $(obj)\
 		-
+else
+	$(QUIET)$(TOOL_GXX3OMF_CXX) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX3OMF_COMPILE_CXX_OUTPUT =
-define TOOL_GXX3OMF_COMPILE_CXX_CMDS
-	$(QUIET)$(TOOL_GXX3OMF_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \
+
+
+## Precompile C++ header.
+# @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_GXX3OMF_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX3OMF_COMPILE_PCH_DEPEND =
+TOOL_GXX3OMF_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX3OMF_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX3OMF_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
 		-o $(obj)\
 		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
@@ -251,5 +278,5 @@
 		 $(NL)$(TAB)$(QUIET)$(QUIET)$(TOOL_GXX3OMF_AR_IMP) -o $(out) @$(outbase).rsp\
 		 $(NL)$(TAB)$(QUIET)$(RM) -f $(outbase).rsp)
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(flags) $(out) $(objs) $(filter-out %.def %.imp %.dll,$(othersrc))
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(flags) $(out) $(filter-out %.h.gch,$(objs)) $(filter-out %.def %.imp %.dll,$(othersrc))
 	$(QUIET)$(TOOL_GXX3OMF_AR) @$(outbase).rsp
 endef
@@ -277,5 +304,5 @@
 		$(flags)\
 		-o $(out)\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(othersrc)\
@@ -308,5 +335,5 @@
 		$(flags)\
 		-o $(out)\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(othersrc)\
@@ -339,5 +366,5 @@
 		$(flags)\
 		-o $(out)\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(othersrc)\
Index: /trunk/kBuild/tools/GXX3PLAIN.kmk
===================================================================
--- /trunk/kBuild/tools/GXX3PLAIN.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX3PLAIN.kmk	(revision 3258)
@@ -37,4 +37,5 @@
 TOOL_GXX3PLAIN_CC  ?= gcc$(HOSTSUFF_EXE)
 TOOL_GXX3PLAIN_CXX ?= g++$(HOSTSUFF_EXE)
+TOOL_GXX3PLAIN_PCH ?= $(TOOL_GXX3PLAIN_CXX)
 TOOL_GXX3PLAIN_AS  ?= gcc$(HOSTSUFF_EXE)
 TOOL_GXX3PLAIN_AR  ?= ar$(HOSTSUFF_EXE)
@@ -74,5 +75,4 @@
 
 TOOL_GXX3PLAIN_CXXOBJSUFF       ?= .o
-TOOL_GXX3PLAIN_CXXOBJSUFF       ?= .o
 TOOL_GXX3PLAIN_CXXFLAGS         ?=
 TOOL_GXX3PLAIN_CXXFLAGS.debug   ?= -g
@@ -82,4 +82,12 @@
 TOOL_GXX3PLAIN_CXXDEFS          ?=
 
+TOOL_GXX3PLAIN_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX3PLAIN_PCHFLAGS         ?= $(TOOL_GXX3PLAIN_CXXFLAGS)
+TOOL_GXX3PLAIN_PCHFLAGS.debug   ?= $(TOOL_GXX3PLAIN_CXXFLAGS.debug)
+TOOL_GXX3PLAIN_PCHFLAGS.profile ?= $(TOOL_GXX3PLAIN_CXXFLAGS.profile)
+TOOL_GXX3PLAIN_PCHFLAGS.release ?= $(TOOL_GXX3PLAIN_CXXFLAGS.release)
+TOOL_GXX3PLAIN_PCHINCS          ?= $(TOOL_GXX3PLAIN_CXXINCS)
+TOOL_GXX3PLAIN_PCHDEFS          ?= $(TOOL_GXX3PLAIN_CXXDEFS)
+
 TOOL_GXX3PLAIN_ASFLAGS          ?= -x assembler-with-cpp
 TOOL_GXX3PLAIN_ASFLAGS.debug    ?= -g
@@ -108,8 +116,8 @@
 TOOL_GXX3PLAIN_COMPILE_C_DEPEND =
 TOOL_GXX3PLAIN_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX3PLAIN_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX3PLAIN_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -123,9 +131,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX3PLAIN_COMPILE_C_OUTPUT =
-define TOOL_GXX3PLAIN_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX3PLAIN_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -133,10 +137,52 @@
 		-o $(obj)\
 		$(abspath $(source))
+endif
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
 ## 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_GXX3PLAIN_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD         =
+TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
+define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
+	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
+		--kObjCache-cpp $(outbase).ii\
+		$(TOOL_GXX3PLAIN_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		$(abspath $(source))\
+		--kObjCache-cc $(obj)\
+		$(TOOL_GXX3PLAIN_CXX) -c\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
+		-o $(obj)\
+		-
+else
+	$(QUIET)$(TOOL_GXX3PLAIN_CXX) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
 # @param    $(target)   Normalized main target name.
 # @param    $(source)   Source filename (relative).
@@ -150,34 +196,16 @@
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
 # @param    $(objsuff)  Object suffix.
-TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND =
-TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
-define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
-	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
-		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX3PLAIN_CXX) -E -o -\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		$(abspath $(source))\
-		--kObjCache-cc $(obj)\
-		$(TOOL_GXX3PLAIN_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
-		-o $(obj)\
-		-
+TOOL_GXX3PLAIN_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX3PLAIN_COMPILE_PCH_DEPEND =
+TOOL_GXX3PLAIN_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX3PLAIN_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX3PLAIN_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT =
-define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
-	$(QUIET)$(TOOL_GXX3PLAIN_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
@@ -221,5 +249,5 @@
 TOOL_GXX3PLAIN_LINK_LIBRARY_DEPORD =
 define TOOL_GXX3PLAIN_LINK_LIBRARY_CMDS
-	$(call xargs,$(QUIET)$(TOOL_GXX3PLAIN_AR) $(flags) $(out),$(objs))
+	$(call xargs,$(QUIET)$(TOOL_GXX3PLAIN_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs)))
 	$(foreach lib,$(othersrc)\
 		,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
@@ -254,5 +282,5 @@
 TOOL_GXX3PLAIN_LINK_PROGRAM_DEPORD =
 define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS
-	$(QUIET)$(TOOL_GXX3PLAIN_LD) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(TOOL_GXX3PLAIN_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
 		$(filter %.def, $(othersrc))\
 		$(foreach p,$(libpath), -L$(p))\
@@ -282,5 +310,5 @@
 	$(QUIET)$(TOOL_GXX3PLAIN_LD) $(TOOL_GXX3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
 		$(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3PLAIN_LD_SONAME,$(target),$(out)))\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(filter %.def, $(othersrc))\
 		$(foreach p,$(libpath), -L$(p))\
@@ -313,5 +341,5 @@
 	$(QUIET)$(if $(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD))\
 		$(TOOL_GXX3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out) \
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(filter %.def, $(othersrc))\
 		$(foreach p,$(libpath), -L$(p))\
Index: /trunk/kBuild/tools/GXX42MACHO.kmk
===================================================================
--- /trunk/kBuild/tools/GXX42MACHO.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX42MACHO.kmk	(revision 3258)
@@ -39,4 +39,5 @@
 TOOL_GXX42MACHO_CC        ?= $(TOOL_GXX42MACHO_PREFIX)gcc$(TOOL_GXX42MACHO_SUFFIX)
 TOOL_GXX42MACHO_CXX       ?= $(TOOL_GXX42MACHO_PREFIX)g++$(TOOL_GXX42MACHO_SUFFIX)
+TOOL_GXX42MACHO_PCH ?= $(TOOL_GXX42MACHO_CXX)
 TOOL_GXX42MACHO_OBJC      ?= $(TOOL_GXX42MACHO_PREFIX)gcc$(TOOL_GXX42MACHO_SUFFIX)
 TOOL_GXX42MACHO_OBJCXX    ?= $(TOOL_GXX42MACHO_PREFIX)gcc$(TOOL_GXX42MACHO_SUFFIX)
@@ -76,4 +77,12 @@
 TOOL_GXX42MACHO_CXXINCS          ?=
 TOOL_GXX42MACHO_CXXDEFS          ?=
+
+TOOL_GXX42MACHO_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX42MACHO_PCHFLAGS         ?= $(TOOL_GXX42MACHO_CXXFLAGS)
+TOOL_GXX42MACHO_PCHFLAGS.debug   ?= $(TOOL_GXX42MACHO_CXXFLAGS.debug)
+TOOL_GXX42MACHO_PCHFLAGS.profile ?= $(TOOL_GXX42MACHO_CXXFLAGS.profile)
+TOOL_GXX42MACHO_PCHFLAGS.release ?= $(TOOL_GXX42MACHO_CXXFLAGS.release)
+TOOL_GXX42MACHO_PCHINCS          ?= $(TOOL_GXX42MACHO_CXXINCS)
+TOOL_GXX42MACHO_PCHDEFS          ?= $(TOOL_GXX42MACHO_CXXDEFS)
 
 TOOL_GXX42MACHO_OBJCOBJSUFF      ?= .o
@@ -155,8 +164,8 @@
 TOOL_GXX42MACHO_COMPILE_C_DEPEND =
 TOOL_GXX42MACHO_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX42MACHO_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX42MACHO_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX42MACHO_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX42MACHO_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX42MACHO_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -170,9 +179,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_GXX42MACHO_COMPILE_C_OUTPUT =
-define TOOL_GXX42MACHO_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX42MACHO_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -180,7 +185,7 @@
 		-o $(obj)\
 		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KUSE_OBJCACHE
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
 
 
@@ -189,21 +194,22 @@
 # @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_GXX42MACHO_COMPILE_CXX_DEPEND =
-TOOL_GXX42MACHO_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX42MACHO_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX42MACHO_COMPILE_CXX_OUTPUT = $(outbase).ii
+# @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_GXX42MACHO_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX42MACHO_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX42MACHO_COMPILE_CXX_DEPORD         =
+TOOL_GXX42MACHO_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX42MACHO_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX42MACHO_CXX) -E -o -\
+		$(TOOL_GXX42MACHO_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
 		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
@@ -211,20 +217,43 @@
 		--kObjCache-cc $(obj)\
 		$(TOOL_GXX42MACHO_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_GXX42MACHO_COMPILE_CXX_OUTPUT =
-define TOOL_GXX42MACHO_COMPILE_CXX_CMDS
+else
 	$(QUIET)$(TOOL_GXX42MACHO_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
+# @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_GXX42MACHO_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX42MACHO_COMPILE_PCH_DEPEND =
+TOOL_GXX42MACHO_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX42MACHO_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX42MACHO_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
 
 
@@ -356,5 +385,5 @@
 TOOL_GXX42MACHO_LINK_LIBRARY_DEPORD =
 define TOOL_GXX42MACHO_LINK_LIBRARY_CMDS
-	$(if $(strip $(objs)),$(call xargs,$(QUIET)$(TOOL_GXX42MACHO_AR) $(flags) $(out),$(objs)))
+	$(if $(strip $(filter-out %.h.gch,$(objs))),$(call xargs,$(QUIET)$(TOOL_GXX42MACHO_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs))))
 	$(foreach lib,$(othersrc)\
 		,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
@@ -389,5 +418,5 @@
 TOOL_GXX42MACHO_LINK_PROGRAM_DEPORD =
 define TOOL_GXX42MACHO_LINK_PROGRAM_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX42MACHO_LD) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
@@ -420,5 +449,5 @@
 TOOL_GXX42MACHO_LINK_DLL_DEPORD =
 define TOOL_GXX42MACHO_LINK_DLL_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX42MACHO_LD) $(TOOL_GXX42MACHO_LDFLAGS.dll) $(flags) -o $(out)\
 		$(call TOOL_GXX42MACHO_LD_SONAME,$(target),$(out))\
@@ -452,5 +481,5 @@
 TOOL_GXX42MACHO_LINK_SYSMOD_DEPORD =
 define TOOL_GXX42MACHO_LINK_SYSMOD_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX42MACHO_LD_SYSMOD) $(TOOL_GXX42MACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
Index: /trunk/kBuild/tools/GXX4MACHO.kmk
===================================================================
--- /trunk/kBuild/tools/GXX4MACHO.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX4MACHO.kmk	(revision 3258)
@@ -39,4 +39,5 @@
 TOOL_GXX4MACHO_CC        ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX)
 TOOL_GXX4MACHO_CXX       ?= $(TOOL_GXX4MACHO_PREFIX)g++$(TOOL_GXX4MACHO_SUFFIX)
+TOOL_GXX4MACHO_PCH ?= $(TOOL_GXX4MACHO_CXX)
 TOOL_GXX4MACHO_OBJC      ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX)
 TOOL_GXX4MACHO_OBJCXX    ?= $(TOOL_GXX4MACHO_PREFIX)gcc$(TOOL_GXX4MACHO_SUFFIX)
@@ -76,4 +77,12 @@
 TOOL_GXX4MACHO_CXXINCS          ?=
 TOOL_GXX4MACHO_CXXDEFS          ?=
+
+TOOL_GXX4MACHO_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX4MACHO_PCHFLAGS         ?= $(TOOL_GXX4MACHO_CXXFLAGS)
+TOOL_GXX4MACHO_PCHFLAGS.debug   ?= $(TOOL_GXX4MACHO_CXXFLAGS.debug)
+TOOL_GXX4MACHO_PCHFLAGS.profile ?= $(TOOL_GXX4MACHO_CXXFLAGS.profile)
+TOOL_GXX4MACHO_PCHFLAGS.release ?= $(TOOL_GXX4MACHO_CXXFLAGS.release)
+TOOL_GXX4MACHO_PCHINCS          ?= $(TOOL_GXX4MACHO_CXXINCS)
+TOOL_GXX4MACHO_PCHDEFS          ?= $(TOOL_GXX4MACHO_CXXDEFS)
 
 TOOL_GXX4MACHO_OBJCOBJSUFF      ?= .o
@@ -155,8 +164,8 @@
 TOOL_GXX4MACHO_COMPILE_C_DEPEND =
 TOOL_GXX4MACHO_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX4MACHO_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX4MACHO_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX4MACHO_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX4MACHO_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -170,9 +179,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_C_OUTPUT =
-define TOOL_GXX4MACHO_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX4MACHO_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -180,10 +185,52 @@
 		-o $(obj)\
 		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KUSE_OBJCACHE
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(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_GXX4MACHO_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX4MACHO_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX4MACHO_COMPILE_CXX_DEPORD         =
+TOOL_GXX4MACHO_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
+define TOOL_GXX4MACHO_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
+	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
+		--kObjCache-cpp $(outbase).ii\
+		$(TOOL_GXX4MACHO_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		$(abspath $(source))\
+		--kObjCache-cc $(obj)\
+		$(TOOL_GXX4MACHO_CXX) -c\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
+		-o $(obj)\
+		-
+else
+	$(QUIET)$(TOOL_GXX4MACHO_CXX) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
 # @param    $(target)   Normalized main target name.
 # @param    $(source)   Source filename (relative).
@@ -197,78 +244,16 @@
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
 # @param    $(objsuff)  Object suffix.
-TOOL_GXX4MACHO_COMPILE_CXX_DEPEND =
-TOOL_GXX4MACHO_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX4MACHO_COMPILE_CXX_OUTPUT = $(outbase).ii
-define TOOL_GXX4MACHO_COMPILE_CXX_CMDS
-	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
-		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX4MACHO_CXX) -E -o -\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		$(abspath $(source))\
-		--kObjCache-cc $(obj)\
-		$(TOOL_GXX4MACHO_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
-		-o $(obj)\
-		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_CXX_OUTPUT =
-define TOOL_GXX4MACHO_COMPILE_CXX_CMDS
-	$(QUIET)$(TOOL_GXX4MACHO_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+TOOL_GXX4MACHO_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX4MACHO_COMPILE_PCH_DEPEND =
+TOOL_GXX4MACHO_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX4MACHO_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX4MACHO_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
 		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
 		-o $(obj)\
 		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
-
-
-## Compile Objective-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_GXX4MACHO_COMPILE_OBJC_DEPEND =
-TOOL_GXX4MACHO_COMPILE_OBJC_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_OBJC_USES_KOBJCACHE = 1
-TOOL_GXX4MACHO_COMPILE_OBJC_OUTPUT = $(outbase).mi
-define TOOL_GXX4MACHO_COMPILE_OBJC_CMDS
-	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
-		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX4MACHO_OBJC) -E -o -\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		$(abspath $(source))\
-		--kObjCache-cc $(obj)\
-		$(TOOL_GXX4MACHO_OBJC) -c\
-		$(flags) -fpreprocessed -x objective-c \
-		-o $(obj)\
-		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_GXX4MACHO_COMPILE_OBJC_OUTPUT =
-define TOOL_GXX4MACHO_COMPILE_OBJC_CMDS
-	$(QUIET)$(TOOL_GXX4MACHO_OBJC) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
 
 
@@ -356,5 +341,5 @@
 TOOL_GXX4MACHO_LINK_LIBRARY_DEPORD =
 define TOOL_GXX4MACHO_LINK_LIBRARY_CMDS
-	$(if $(strip $(objs)),$(call xargs,$(QUIET)$(TOOL_GXX4MACHO_AR) $(flags) $(out),$(objs)))
+	$(if $(strip $(filter-out %.h.gch,$(objs))),$(call xargs,$(QUIET)$(TOOL_GXX4MACHO_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs))))
 	$(foreach lib,$(othersrc)\
 		,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
@@ -389,5 +374,5 @@
 TOOL_GXX4MACHO_LINK_PROGRAM_DEPORD =
 define TOOL_GXX4MACHO_LINK_PROGRAM_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX4MACHO_LD) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
@@ -420,5 +405,5 @@
 TOOL_GXX4MACHO_LINK_DLL_DEPORD =
 define TOOL_GXX4MACHO_LINK_DLL_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX4MACHO_LD) $(TOOL_GXX4MACHO_LDFLAGS.dll) $(flags) -o $(out)\
 		$(call TOOL_GXX4MACHO_LD_SONAME,$(target),$(out))\
@@ -452,5 +437,5 @@
 TOOL_GXX4MACHO_LINK_SYSMOD_DEPORD =
 define TOOL_GXX4MACHO_LINK_SYSMOD_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_GXX4MACHO_LD_SYSMOD) $(TOOL_GXX4MACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
Index: /trunk/kBuild/tools/GXX64.kmk
===================================================================
--- /trunk/kBuild/tools/GXX64.kmk	(revision 3257)
+++ /trunk/kBuild/tools/GXX64.kmk	(revision 3258)
@@ -38,4 +38,5 @@
 TOOL_GXX64_CC  ?= gcc$(HOSTSUFF_EXE) -m64
 TOOL_GXX64_CXX ?= g++$(HOSTSUFF_EXE) -m64
+TOOL_GXX64_PCH ?= $(TOOL_GXX64_CXX)
 TOOL_GXX64_AS  ?= gcc$(HOSTSUFF_EXE) -m64
 TOOL_GXX64_AR  ?= ar$(HOSTSUFF_EXE)
@@ -80,5 +81,4 @@
 
 TOOL_GXX64_CXXOBJSUFF       ?= .o
-TOOL_GXX64_CXXOBJSUFF       ?= .o
 TOOL_GXX64_CXXFLAGS         ?=
 TOOL_GXX64_CXXFLAGS.debug   ?= -g
@@ -88,4 +88,12 @@
 TOOL_GXX64_CXXDEFS          ?=
 
+TOOL_GXX64_PCHOBJSUFF       ?= .h.gch
+TOOL_GXX64_PCHFLAGS         ?= $(TOOL_GXX64_CXXFLAGS)
+TOOL_GXX64_PCHFLAGS.debug   ?= $(TOOL_GXX64_CXXFLAGS.debug)
+TOOL_GXX64_PCHFLAGS.profile ?= $(TOOL_GXX64_CXXFLAGS.profile)
+TOOL_GXX64_PCHFLAGS.release ?= $(TOOL_GXX64_CXXFLAGS.release)
+TOOL_GXX64_PCHINCS          ?= $(TOOL_GXX64_CXXINCS)
+TOOL_GXX64_PCHDEFS          ?= $(TOOL_GXX64_CXXDEFS)
+
 TOOL_GXX64_ASFLAGS          ?= -x assembler-with-cpp
 TOOL_GXX64_ASFLAGS.debug    ?= -g
@@ -116,8 +124,8 @@
 TOOL_GXX64_COMPILE_C_DEPEND =
 TOOL_GXX64_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX64_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_GXX64_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_GXX64_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_GXX64_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_GXX64_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -131,9 +139,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX64_COMPILE_C_OUTPUT =
-define TOOL_GXX64_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_GXX64_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -141,10 +145,52 @@
 		-o $(obj)\
 		$(abspath $(source))
+endif
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
 ## 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_GXX64_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_GXX64_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX64_COMPILE_CXX_DEPORD         =
+TOOL_GXX64_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
+define TOOL_GXX64_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
+	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
+		--kObjCache-cpp $(outbase).ii\
+		$(TOOL_GXX64_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		$(abspath $(source))\
+		--kObjCache-cc $(obj)\
+		$(TOOL_GXX64_CXX) -c\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
+		-o $(obj)\
+		-
+else
+	$(QUIET)$(TOOL_GXX64_CXX) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
 # @param    $(target)   Normalized main target name.
 # @param    $(source)   Source filename (relative).
@@ -158,34 +204,16 @@
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
 # @param    $(objsuff)  Object suffix.
-TOOL_GXX64_COMPILE_CXX_DEPEND =
-TOOL_GXX64_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_GXX64_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_GXX64_COMPILE_CXX_OUTPUT = $(outbase).ii
-define TOOL_GXX64_COMPILE_CXX_CMDS
-	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
-		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_GXX64_CXX) -E -o -\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		$(abspath $(source))\
-		--kObjCache-cc $(obj)\
-		$(TOOL_GXX64_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
-		-o $(obj)\
-		-
+TOOL_GXX64_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_GXX64_COMPILE_PCH_DEPEND =
+TOOL_GXX64_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_GXX64_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_GXX64_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
 	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
 endef
-else # !KBUILD_USE_KOBJCACHE
-TOOL_GXX64_COMPILE_CXX_OUTPUT =
-define TOOL_GXX64_COMPILE_CXX_CMDS
-	$(QUIET)$(TOOL_GXX64_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
 
 
@@ -231,5 +259,5 @@
 	$(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
 	$(QUIET)$(APPEND) -n $(out).ar-script \
-		$(foreach o,$(objs), 'ADDMOD $(o)') \
+		$(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
 		$(foreach o,$(othersrc), 'ADDLIB $(o)')
 	$(QUIET)$(APPEND) $(out).ar-script 'SAVE'
@@ -259,5 +287,5 @@
 TOOL_GXX64_LINK_PROGRAM_DEPORD =
 define TOOL_GXX64_LINK_PROGRAM_CMDS
-	$(QUIET)$(TOOL_GXX64_LD) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(TOOL_GXX64_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
@@ -293,5 +321,5 @@
 	$(QUIET)$(TOOL_GXX64_LD) $(TOOL_GXX64_LDFLAGS.dll) $(flags) -o $(out)\
 		$(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX64_LD_SONAME,$(target),$(out)))\
-		$(objs)\
+		$(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
@@ -325,5 +353,5 @@
 TOOL_GXX64_LINK_SYSMOD_DEPORD =
 define TOOL_GXX64_LINK_SYSMOD_CMDS
-	$(QUIET)$(TOOL_GXX64_LD_SYSMOD) $(TOOL_GXX64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(TOOL_GXX64_LD_SYSMOD) $(TOOL_GXX64_LDFLAGS.sysmod) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
 		$(foreach p,$(libpath), -L$(p))\
 		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
Index: /trunk/kBuild/tools/LLVMGXX42MACHO.kmk
===================================================================
--- /trunk/kBuild/tools/LLVMGXX42MACHO.kmk	(revision 3257)
+++ /trunk/kBuild/tools/LLVMGXX42MACHO.kmk	(revision 3258)
@@ -39,4 +39,5 @@
 TOOL_LLVMGXX42MACHO_CC        ?= $(TOOL_LLVMGXX42MACHO_PREFIX)gcc$(TOOL_LLVMGXX42MACHO_SUFFIX)
 TOOL_LLVMGXX42MACHO_CXX       ?= $(TOOL_LLVMGXX42MACHO_PREFIX)g++$(TOOL_LLVMGXX42MACHO_SUFFIX)
+TOOL_LLVMGXX42MACHO_PCH ?= $(TOOL_LLVMGXX42MACHO_CXX)
 TOOL_LLVMGXX42MACHO_OBJC      ?= $(TOOL_LLVMGXX42MACHO_PREFIX)gcc$(TOOL_LLVMGXX42MACHO_SUFFIX)
 TOOL_LLVMGXX42MACHO_OBJCXX    ?= $(TOOL_LLVMGXX42MACHO_PREFIX)gcc$(TOOL_LLVMGXX42MACHO_SUFFIX)
@@ -76,4 +77,12 @@
 TOOL_LLVMGXX42MACHO_CXXINCS          ?=
 TOOL_LLVMGXX42MACHO_CXXDEFS          ?=
+
+TOOL_LLVMGXX42MACHO_PCHOBJSUFF       ?= .h.gch
+TOOL_LLVMGXX42MACHO_PCHFLAGS         ?= $(TOOL_LLVMGXX42MACHO_CXXFLAGS)
+TOOL_LLVMGXX42MACHO_PCHFLAGS.debug   ?= $(TOOL_LLVMGXX42MACHO_CXXFLAGS.debug)
+TOOL_LLVMGXX42MACHO_PCHFLAGS.profile ?= $(TOOL_LLVMGXX42MACHO_CXXFLAGS.profile)
+TOOL_LLVMGXX42MACHO_PCHFLAGS.release ?= $(TOOL_LLVMGXX42MACHO_CXXFLAGS.release)
+TOOL_LLVMGXX42MACHO_PCHINCS          ?= $(TOOL_LLVMGXX42MACHO_CXXINCS)
+TOOL_LLVMGXX42MACHO_PCHDEFS          ?= $(TOOL_LLVMGXX42MACHO_CXXDEFS)
 
 TOOL_LLVMGXX42MACHO_OBJCOBJSUFF      ?= .o
@@ -155,8 +164,8 @@
 TOOL_LLVMGXX42MACHO_COMPILE_C_DEPEND =
 TOOL_LLVMGXX42MACHO_COMPILE_C_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_LLVMGXX42MACHO_COMPILE_C_USES_KOBJCACHE = 1
-TOOL_LLVMGXX42MACHO_COMPILE_C_OUTPUT = $(outbase).i
+TOOL_LLVMGXX42MACHO_COMPILE_C_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
+TOOL_LLVMGXX42MACHO_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_LLVMGXX42MACHO_COMPILE_C_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).i\
@@ -170,9 +179,5 @@
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_LLVMGXX42MACHO_COMPILE_C_OUTPUT =
-define TOOL_LLVMGXX42MACHO_COMPILE_C_CMDS
+else
 	$(QUIET)$(TOOL_LLVMGXX42MACHO_CC) -c\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
@@ -180,7 +185,7 @@
 		-o $(obj)\
 		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KUSE_OBJCACHE
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
 
 
@@ -189,21 +194,22 @@
 # @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_LLVMGXX42MACHO_COMPILE_CXX_DEPEND =
-TOOL_LLVMGXX42MACHO_COMPILE_CXX_DEPORD =
-ifdef KBUILD_USE_KOBJCACHE
-TOOL_LLVMGXX42MACHO_COMPILE_CXX_USES_KOBJCACHE = 1
-TOOL_LLVMGXX42MACHO_COMPILE_CXX_OUTPUT = $(outbase).ii
+# @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_LLVMGXX42MACHO_COMPILE_CXX_OUTPUT         = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
+TOOL_LLVMGXX42MACHO_COMPILE_CXX_DEPEND         = $($(target)_1_GCC_PCH_FILE)
+TOOL_LLVMGXX42MACHO_COMPILE_CXX_DEPORD         =
+TOOL_LLVMGXX42MACHO_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
 define TOOL_LLVMGXX42MACHO_COMPILE_CXX_CMDS
+if "$(use_objcache)" != ""
 	$(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
 		--kObjCache-cpp $(outbase).ii\
-		$(TOOL_LLVMGXX42MACHO_CXX) -E -o -\
+		$(TOOL_LLVMGXX42MACHO_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
+		,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
 		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
 		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
@@ -211,20 +217,43 @@
 		--kObjCache-cc $(obj)\
 		$(TOOL_LLVMGXX42MACHO_CXX) -c\
-		$(flags) -fpreprocessed -x c++\
+		$(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
 		-o $(obj)\
 		-
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-else  # !KBUILD_USE_KOBJCACHE
-TOOL_LLVMGXX42MACHO_COMPILE_CXX_OUTPUT =
-define TOOL_LLVMGXX42MACHO_COMPILE_CXX_CMDS
+else
 	$(QUIET)$(TOOL_LLVMGXX42MACHO_CXX) -c\
-		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
-		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
-		-o $(obj)\
-		$(abspath $(source))
-	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
-endef
-endif # !KBUILD_USE_KOBJCACHE
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj) $(if-expr defined($(target)_PCH_HDR) \
+		,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
+		$(abspath $(source))
+endif
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
+
+
+## Precompile C++ header.
+# @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_LLVMGXX42MACHO_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
+TOOL_LLVMGXX42MACHO_COMPILE_PCH_DEPEND =
+TOOL_LLVMGXX42MACHO_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
+define TOOL_LLVMGXX42MACHO_COMPILE_PCH_CMDS
+	$(QUIET)$(TOOL_LLVMGXX42MACHO_PCH) -c\
+		$(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
+		-o $(obj)\
+		$(abspath $(source))
+	$(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
+	$(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
+endef
 
 
@@ -356,5 +385,5 @@
 TOOL_LLVMGXX42MACHO_LINK_LIBRARY_DEPORD =
 define TOOL_LLVMGXX42MACHO_LINK_LIBRARY_CMDS
-	$(if $(strip $(objs)),$(call xargs,$(QUIET)$(TOOL_LLVMGXX42MACHO_AR) $(flags) $(out),$(objs)))
+	$(if $(strip $(filter-out %.h.gch,$(objs))),$(call xargs,$(QUIET)$(TOOL_LLVMGXX42MACHO_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs))))
 	$(foreach lib,$(othersrc)\
 		,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
@@ -389,5 +418,5 @@
 TOOL_LLVMGXX42MACHO_LINK_PROGRAM_DEPORD =
 define TOOL_LLVMGXX42MACHO_LINK_PROGRAM_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_LLVMGXX42MACHO_LD) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
@@ -420,5 +449,5 @@
 TOOL_LLVMGXX42MACHO_LINK_DLL_DEPORD =
 define TOOL_LLVMGXX42MACHO_LINK_DLL_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_LLVMGXX42MACHO_LD) $(TOOL_LLVMGXX42MACHO_LDFLAGS.dll) $(flags) -o $(out)\
 		$(call TOOL_LLVMGXX42MACHO_LD_SONAME,$(target),$(out))\
@@ -452,5 +481,5 @@
 TOOL_LLVMGXX42MACHO_LINK_SYSMOD_DEPORD =
 define TOOL_LLVMGXX42MACHO_LINK_SYSMOD_CMDS
-	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(filter-out %.h.gch,$(objs))
 	$(QUIET)$(TOOL_LLVMGXX42MACHO_LD_SYSMOD) $(TOOL_LLVMGXX42MACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
 		-filelist $(outbase).rsp\
