OSDN Git Service

Merge commit 'origin/master' into HEAD
[android-x86/external-mesa.git] / bin / mklib
index 90bf834..a25d5bf 100755 (executable)
--- a/bin/mklib
+++ b/bin/mklib
@@ -43,7 +43,7 @@ ARCH="auto"
 ARCHOPT=""
 NOPREFIX=0
 EXPORTS=""
-
+ID=""
 
 #
 # Parse arguments
@@ -61,7 +61,8 @@ do
            echo '  -minor N      specifies minor version number (default is 0)'
            echo '  -patch N      specifies patch version number (default is 0)'
            echo '  -lLIBRARY     specifies a dependency on LIBRARY'
-           echo '  -LDIR         search in DIR for library dependencies'
+           echo '  -LDIR         search in DIR for library dependencies at build time'
+           echo '  -RDIR         search in DIR for library dependencies at run time'
            echo '  -linker L     explicity specify the linker program to use (eg: gcc, g++)'
            echo '                Not observed on all systems at this time.'
            echo '  -ldflags OPT  specify any additional linker flags in OPT'
@@ -74,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
            ;;
@@ -107,6 +109,12 @@ do
        -L*)
            DEPS="$DEPS $1"
            ;;
+       -R*)
+           DEPS="$DEPS $1"
+           ;;
+       -Wl*)
+            DEPS="$DEPS $1"
+            ;;
        -pthread)
            # this is a special case (see bugzilla 10876)
            DEPS="$DEPS $1"
@@ -146,6 +154,10 @@ do
            shift 1;
            EXPORTS=$1
            ;;
+       '-id')
+           shift 1;
+           ID=$1
+           ;;
        -*)
            echo "mklib: Unknown option: " $1 ;
            exit 1
@@ -189,6 +201,7 @@ if [  ]  ; then
     echo PATCH is $PATCH
     echo DEPS are $DEPS
     echo "EXPORTS in" $EXPORTS
+    echo ID is $ID
     echo "-----------------"
 fi
 
@@ -198,7 +211,7 @@ fi
 #
 case $ARCH in
 
-    'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
+    'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*)
        # we assume gcc
 
        if [ "x$LINK" = "x" ] ; then
@@ -264,7 +277,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
@@ -333,7 +346,7 @@ case $ARCH in
                        # use g++
                        LINK="g++"
                    else
-                       echo "mklib: warning: can't find C++ comiler, trying CC."
+                       echo "mklib: warning: can't find C++ compiler, trying CC."
                        LINK="CC"
                    fi
                else
@@ -362,9 +375,11 @@ case $ARCH in
            # Check if objects are SPARC v9
            # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
            set ${OBJECTS}
-           SPARCV9=`file $1 | grep SPARCV9`
-           if [ "${SPARCV9}" ] ; then
-               OPTS="${OPTS} -xarch=v9"
+           if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
+               SPARCV9=`file $1 | grep SPARCV9`
+               if [ "${SPARCV9}" ] ; then
+                   OPTS="${OPTS} -xarch=v9"
+               fi
            fi
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
@@ -376,7 +391,7 @@ case $ARCH in
                ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            else
                rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
-               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
+               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
                ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
            fi
            FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
@@ -621,13 +636,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}"