Switch from archive libraries to partial linking

Before this commit, weak symbols were not overridden by non-weak symbols
found in archive libraries when linking with recent versions of
binutils.  As stated in the System V ABI, "the link editor does not
extract archive members to resolve undefined weak symbols".

This commit changes all Makefiles to use partial linking (ld -r) instead
of creating library archives, which forces all symbols to participate in
linking, allowing non-weak symbols to override weak symbols as intended.
This approach is also used by Linux, from which the gmake function
cmd_link_o_target (defined in config.mk and used in all Makefiles) is
inspired.

The name of each former library archive is preserved except for
extensions which change from ".a" to ".o".  This commit updates
references accordingly where needed, in particular in some linker
scripts.

This commit reveals board configurations that exclude some features but
include source files that depend these disabled features in the build,
resulting in undefined symbols.  Known such cases include:
- disabling CMD_NET but not CMD_NFS;
- enabling CONFIG_OF_LIBFDT but not CONFIG_QE.

Signed-off-by: Sebastien Carlier <sebastien.carlier@gmail.com>
diff --git a/fs/cramfs/Makefile b/fs/cramfs/Makefile
index 7b6cc0a..5f41932 100644
--- a/fs/cramfs/Makefile
+++ b/fs/cramfs/Makefile
@@ -23,7 +23,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libcramfs.a
+LIB	= $(obj)libcramfs.o
 
 AOBJS	=
 COBJS-$(CONFIG_CMD_CRAMFS) := cramfs.o
@@ -37,7 +37,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 
 #########################################################################
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index 712e348..3c65d25 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -27,7 +27,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libext2fs.a
+LIB	= $(obj)libext2fs.o
 
 AOBJS	=
 COBJS-$(CONFIG_CMD_EXT2) := ext2fs.o dev.o
@@ -40,7 +40,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 #########################################################################
 
diff --git a/fs/fat/Makefile b/fs/fat/Makefile
index b711460..bc45966 100644
--- a/fs/fat/Makefile
+++ b/fs/fat/Makefile
@@ -21,7 +21,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libfat.a
+LIB	= $(obj)libfat.o
 
 AOBJS	=
 COBJS-$(CONFIG_CMD_FAT)	:= fat.o file.o
@@ -32,7 +32,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 
 #########################################################################
diff --git a/fs/fdos/Makefile b/fs/fdos/Makefile
index fce2032..9cd4d91 100644
--- a/fs/fdos/Makefile
+++ b/fs/fdos/Makefile
@@ -28,7 +28,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libfdos.a
+LIB	= $(obj)libfdos.o
 
 AOBJS	=
 COBJS-$(CONFIG_CMD_FDOS) := fat.o vfat.o dev.o fdos.o fs.o subdir.o
@@ -41,7 +41,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 
 #########################################################################
diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile
index 7c9fb41..6db6145 100644
--- a/fs/jffs2/Makefile
+++ b/fs/jffs2/Makefile
@@ -23,7 +23,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libjffs2.a
+LIB	= $(obj)libjffs2.o
 
 AOBJS	=
 ifdef CONFIG_CMD_JFFS2
@@ -44,7 +44,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 
 #########################################################################
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
index 9cef8ee..495759c 100644
--- a/fs/reiserfs/Makefile
+++ b/fs/reiserfs/Makefile
@@ -27,7 +27,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libreiserfs.a
+LIB	= $(obj)libreiserfs.o
 
 AOBJS	=
 COBJS-$(CONFIG_CMD_REISER) := reiserfs.o dev.o mode_string.o
@@ -40,7 +40,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 #########################################################################
 
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 8328843..ccffe85 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -27,7 +27,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= $(obj)libubifs.a
+LIB	= $(obj)libubifs.o
 
 COBJS-$(CONFIG_CMD_UBIFS) := ubifs.o io.o super.o sb.o master.o lpt.o
 COBJS-$(CONFIG_CMD_UBIFS) += lpt_commit.o scan.o lprops.o
@@ -40,7 +40,7 @@
 all:	$(LIB) $(AOBJS)
 
 $(LIB):	$(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 #########################################################################
 
diff --git a/fs/yaffs2/Makefile b/fs/yaffs2/Makefile
index a2ef5e2..7753cfc 100644
--- a/fs/yaffs2/Makefile
+++ b/fs/yaffs2/Makefile
@@ -19,7 +19,7 @@
 #EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
 include $(TOPDIR)/config.mk
 
-LIB = $(obj)libyaffs2.a
+LIB = $(obj)libyaffs2.o
 
 COBJS-$(CONFIG_YAFFS2) := \
 	yaffscfg.o yaffs_ecc.o yaffsfs.o yaffs_guts.o yaffs_packedtags1.o \
@@ -36,7 +36,7 @@
 all:  $(LIB)
 
 $(LIB): $(obj).depend $(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
 
 .PHONY: clean distclean
 clean: