From 15b91a88152af5f9f0670ea30f0d2ae037303213 Mon Sep 17 00:00:00 2001
From: Alex Weiss <algrs@cacography.net>
Date: Sat, 27 Feb 2010 14:47:43 -0500
Subject: [PATCH] Fixed mklib to properly merge static libraries on darwin.

---
 bin/mklib |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/bin/mklib b/bin/mklib
index 7f22725..f28bfbb 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -743,12 +743,22 @@ case $ARCH in
         if [ $STATIC = 1 ] ; then
             LIBNAME="lib${LIBNAME}.a"
             echo "mklib: Making Darwin static library: " ${LIBNAME}
-            LINK="ar"
+            #LINK="ar"
             OPTS="-ruvs"
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
             fi
-            ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
+
+            # expand .a into .o files
+            NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
+
+            # make static lib
+            FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
+
+            # remove temporary extracted .o files
+            rm -rf ${LIBNAME}.obj
+
+            #${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
             FINAL_LIBS=${LIBNAME}
         else
             # On Darwin a .bundle is used for a library that you want to dlopen
-- 
1.7.0

