glx: kill old K&R syntax in XF86dri.c
[mesa.git] / bin / mklib
index 0dc3135d50f89270834b5b6a1d86be0c1e2c2f39..d7b740f8e34381dac588c819ed0364c360899233 100755 (executable)
--- a/bin/mklib
+++ b/bin/mklib
@@ -43,7 +43,7 @@ ARCH="auto"
 ARCHOPT=""
 NOPREFIX=0
 EXPORTS=""
-
+ID=""
 
 #
 # Parse arguments
@@ -75,6 +75,7 @@ do
            echo '  -altopts OPTS alternate options to override all others'
            echo "  -noprefix     don't prefix library name with 'lib' nor add any suffix"
            echo '  -exports FILE only export the symbols listed in FILE'
+           echo '  -id NAME      Sets the id of the dylib (Darwin)'
            echo '  -h, --help    display this information and exit'
            exit 1
            ;;
@@ -153,6 +154,10 @@ do
            shift 1;
            EXPORTS=$1
            ;;
+       '-id')
+           shift 1;
+           ID=$1
+           ;;
        -*)
            echo "mklib: Unknown option: " $1 ;
            exit 1
@@ -196,6 +201,7 @@ if [  ]  ; then
     echo PATCH is $PATCH
     echo DEPS are $DEPS
     echo "EXPORTS in" $EXPORTS
+    echo ID is $ID
     echo "-----------------"
 fi
 
@@ -254,9 +260,31 @@ case $ARCH in
                 OPTS=${ALTOPTS}
             fi
             rm -f ${LIBNAME}
+
+           # expand any .a objects into constituent .o files.
+           NEWOBJECTS=""
+           DELETIA=""
+           for OBJ in ${OBJECTS} ; do
+               if [ `expr match $OBJ '.*\.a'` -gt 0 ] ; then
+                   # extract the .o files from this .a archive
+                   FILES=`ar t $OBJ`
+                   ar x $OBJ
+                   NEWOBJECTS="$NEWOBJECTS $FILES"
+                   # keep track of temporary .o files and delete them below
+                   DELETIA="$DELETIA $FILES"
+               else
+                   # ordinary .o file
+                   NEWOBJECTS="$NEWOBJECTS $OBJ"
+               fi
+           done
+
             # make lib
-            ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
+            ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
             ranlib ${LIBNAME}
+
+           # remove temporary extracted .o files
+           rm -f ${DELETIA}
+
             # finish up
             FINAL_LIBS=${LIBNAME}
         else
@@ -271,7 +299,7 @@ case $ARCH in
            if [ $EXPORTS ] ; then
                #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
                # Make the 'exptmp' file for --version-script option
-               echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
+               echo "{" > exptmp
                echo "global:" >> exptmp
                sed 's/$/;/' ${EXPORTS} >> exptmp
                echo "local:" >> exptmp
@@ -630,13 +658,19 @@ case $ARCH in
                 LIBSUFFIX="bundle"
                 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
             else
-               LIBSUFFIX="dylib"
-                OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+                LIBSUFFIX="dylib"
+                if [ -z "$ID" ] ; then
+                    ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+                fi
+                OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
             fi
 
             if [ ${EXPORTS} ] ; then
+                if [ -f ${EXPORTS}".darwin" ] ; then
+                    EXPORTS=$EXPORTS".darwin"
+                fi
                 OPTS="${OPTS} -exported_symbols_list ${EXPORTS}"
-            fi 
+            fi
 
             LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
             LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}"