Index: trunk/kBuild/header.kmk
===================================================================
--- trunk/kBuild/header.kmk	(revision 841)
+++ trunk/kBuild/header.kmk	(revision 844)
@@ -795,4 +795,9 @@
  # @param 3     The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
  MSG_LINK     ?= $(call MSG_L1,Linking $1,=> $2)
+ ## Merging a library into the target (during library linking).
+ # @param 1     Target name.
+ # @param 2     The output library name.
+ # @param 3     The input library name.
+ MSG_AR_MERGE ?= $(call MSG_L1,Merging $2 into $1, ($2))
  ## Creating a directory (build).
  # @param 1     Directory name.
Index: trunk/kBuild/msgstyles/brief.kmk
===================================================================
--- trunk/kBuild/msgstyles/brief.kmk	(revision 841)
+++ trunk/kBuild/msgstyles/brief.kmk	(revision 844)
@@ -71,4 +71,9 @@
 # @param 3     The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
 MSG_LINK     ?= $(call MSG_L1,$(if $(eq $3,LINK_LIBRARY),AR,LD)   $1,=> $2)
+## Merging a library into the target (during library linking).
+# @param 1     Target name.
+# @param 2     The output library name.
+# @param 3     The input library name.
+MSG_AR_MERGE ?= $(NO_SUCH_VARIABLE)
 ## Creating a directory (build).
 # @param 1     Directory name.
Index: trunk/kBuild/tools/GCC4MACHO.kmk
===================================================================
--- trunk/kBuild/tools/GCC4MACHO.kmk	(revision 841)
+++ trunk/kBuild/tools/GCC4MACHO.kmk	(revision 844)
@@ -31,6 +31,5 @@
 TOOL_GCC4MACHO_CXX ?= g++$(HOSTSUFF_EXE)
 TOOL_GCC4MACHO_AS  ?= gcc$(HOSTSUFF_EXE)
-TOOL_GCC4MACHO_AR_IMP ?= $(ECHO) not supported!
-TOOL_GCC4MACHO_LD ?= g++$(HOSTSUFF_EXE)
+TOOL_GCC4MACHO_LD  ?= g++$(HOSTSUFF_EXE)
 TOOL_GCC4MACHO_LD_SYSMOD ?= g++$(HOSTSUFF_EXE)
 ifndef TOOL_GCC4MACHO_LDFLAGS.$(BUILD_TARGET)
@@ -41,6 +40,4 @@
 TOOL_GCC4MACHO_LDFLAGS.sysmod ?= -r
 #TOOL_GCC4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
-TOOL_GCC4MACHO_LD_MAP ?=
-TOOL_GCC4MACHO_LD_SYSMOD_MAP ?=
 
 ifdef SLKRUNS
@@ -168,5 +165,14 @@
 TOOL_GCC4MACHO_LINK_LIBRARY_DEPORD =
 define TOOL_GCC4MACHO_LINK_LIBRARY_CMDS
-	$(QUIET)$(TOOL_GCC4MACHO_AR) $(flags) $(out) $(objs) $(othersrc)
+	$(call xargs,$(QUIET)$(TOOL_GCC4MACHO_AR) $(flags) $(out),$(objs))
+	$(foreach lib,$(othersrc)\
+		,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
+		$(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
+		$(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
+		$(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
+			&& $(TOOL_GCC4MACHO_AR) -x $(abspath $(lib)) \
+			&& $(TOOL_GCC4MACHO_AR) $(flags) $(out) *) \
+		$(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
+		$(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
 endef
 
@@ -185,12 +191,13 @@
 # @param    $(custom_post)  Custom step invoked after linking.
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
-TOOL_GCC4MACHO_LINK_PROGRAM_OUTPUT = $(outbase).map
+TOOL_GCC4MACHO_LINK_PROGRAM_OUTPUT = $(outbase).map $(outbase).rsp
 TOOL_GCC4MACHO_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
 TOOL_GCC4MACHO_LINK_PROGRAM_DEPORD =
 define TOOL_GCC4MACHO_LINK_PROGRAM_CMDS
-	$(QUIET)$(TOOL_GCC4MACHO_LD) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(TOOL_GCC4MACHO_LD) $(flags) -o $(out)\
+		-filelist $(outbase).rsp\
 		$(foreach p,$(libpath), -L$(p))\
-		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
-		$(call TOOL_GCC4MACHO_LD_MAP,$(outbase).map)
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
 endef
 
@@ -209,14 +216,14 @@
 # @param    $(custom_post)  Custom step invoked after linking.
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
-TOOL_GCC4MACHO_LINK_DLL_OUTPUT = $(outbase).map
+TOOL_GCC4MACHO_LINK_DLL_OUTPUT = $(outbase).rsp
 TOOL_GCC4MACHO_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
 TOOL_GCC4MACHO_LINK_DLL_DEPORD =
 define TOOL_GCC4MACHO_LINK_DLL_CMDS
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
 	$(QUIET)$(TOOL_GCC4MACHO_LD) $(TOOL_GCC4MACHO_LDFLAGS.dll) $(flags) -o $(out)\
-		$(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC4MACHO_LD_SONAME,$(target),$(out)))\
-		$(objs)\
+		$(call TOOL_GCC4MACHO_LD_SONAME,$(target),$(out))\
+		-filelist $(outbase).rsp\
 		$(foreach p,$(libpath), -L$(p))\
-		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
-		$(call TOOL_GCC4MACHO_LD_MAP,$(outbase).map)
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
 endef
 
@@ -235,12 +242,13 @@
 # @param    $(custom_post)  Custom step invoked after linking.
 # @param    $(outbase)  Output basename (full). Use this for list files and such.
-TOOL_GCC4MACHO_LINK_SYSMOD_OUTPUT = $(outbase).map
+TOOL_GCC4MACHO_LINK_SYSMOD_OUTPUT = $(outbase).rsp
 TOOL_GCC4MACHO_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
 TOOL_GCC4MACHO_LINK_SYSMOD_DEPORD =
 define TOOL_GCC4MACHO_LINK_SYSMOD_CMDS
-	$(QUIET)$(TOOL_GCC4MACHO_LD_SYSMOD) $(TOOL_GCC4MACHO_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
+	$(QUIET)$(APPEND) -n $(outbase).rsp $(objs)
+	$(QUIET)$(TOOL_GCC4MACHO_LD_SYSMOD) $(TOOL_GCC4MACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
+		-filelist $(outbase).rsp\
 		$(foreach p,$(libpath), -L$(p))\
-		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
-		$(call TOOL_GCC4MACHO_LD_SYSMOD_MAP,$(outbase).map)
-endef
-
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+endef
+
