diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mklib | 154 |
1 files changed, 110 insertions, 44 deletions
diff --git a/bin/mklib b/bin/mklib index 06436ff388f..9bb179f19d1 100755 --- a/bin/mklib +++ b/bin/mklib @@ -1,36 +1,53 @@ #!/bin/sh # Make a shared library. -# Basically do a switch/case depending on the OS and make a shared (or static) -# library conforming to that OS. - - -# Usage: -# mklib [options] objects ... -# Options: -# -o LIBRARY specifies the name of resulting library -# ("-o GL" for example, might result in "libGL.so" being made) -# -major N specifies major version number (default is 1) -# -minor N specifies minor version number (default is 0) -# -patch N specifies patch version number (default is 0) -# -lLIBRARY specifies a dependency on LIBRARY -# -LDIR search in DIR for library dependencies -# -linker L explicity specify the linker program to use (ex: gcc, g++) -# Not observed on all systems at this time. -# -cplusplus link with C++ runtime -# -static make a static library (default is dynamic/shared) -# -install DIR pu resulting library file(s) in DIR -# -arch ARCH override using `uname` to determine architecture -# -archopt OPT specify an extra achitecture-specific option OPT -# -noprefix don't prefix library name with "lib" nor add any suffix -# -exports FILE only export the symbols listed in FILE +# This script should be useful for projects other than Mesa. +# Improvements/fixes are welcome. + + +# Copyright (C) 1999-2005 Brian Paul All Rights Reserved. # -# The library name should just be "GL" or "GLU", etc. The 'lib' prefix -# will be added here if needed, as well as the ".so" or ".a" suffix, -# etc (unless the -noprefix option is used). +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: # -# objects should be: foo.o bar.o etc.o +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +function usage() +{ + echo 'Usage: mklib [options] objects' + echo 'Create a shared library from object files.' + echo ' -o LIBRARY specifies the name of the resulting library, without' + echo ' the leading "lib" or any suffix.' + echo ' (eg: "-o GL" might result in "libGL.so" being made)' + echo ' -major N specifies major version number (default is 1)' + 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 ' -linker L explicity specify the linker program to use (eg: gcc, g++)' + echo ' Not observed on all systems at this time.' + echo ' -cplusplus link with C++ runtime' + echo ' -static make a static library (default is dynamic/shared)' + echo ' -install DIR put resulting library file(s) in DIR' + echo ' -arch ARCH override using `uname` to determine host system' + echo ' -archopt OPT specify an extra achitecture-specific option OPT' + echo " -noprefix don't prefix library name with 'lib' nor add any suffix" + echo ' -exports FILE only export the symbols listed in FILE' + echo ' -h, --help display this information and exit' +} # @@ -57,27 +74,74 @@ EXPORTS="" while true do case $1 in - '-o') shift 1; LIBNAME=$1;; - '-major') shift 1; MAJOR=$1;; - '-minor') shift 1; MINOR=$1;; - '-patch') shift 1; PATCH=$1;; - '-linker') shift 1; LINK=$1;; - -l*) DEPS="$DEPS $1";; - -L*) DEPS="$DEPS $1";; - '-cplusplus') CPLUSPLUS=1;; - '-static') STATIC=1;; - '-install') shift 1; INSTALLDIR=$1;; - '-arch') shift 1; ARCH=$1;; - '-archopt') shift 1; ARCHOPT=$1;; - '-noprefix') NOPREFIX=1;; - '-exports') shift 1; EXPORTS=$1;; - -*) echo "mklib: Unknown option: " $1 ; exit 1;; - *) break + '-h' | '--help') + usage; + exit 1 + ;; + '-o') + shift 1; + LIBNAME=$1 + ;; + '-major') + shift 1; + MAJOR=$1 + ;; + '-minor') + shift 1; + MINOR=$1 + ;; + '-patch') + shift 1; + PATCH=$1 + ;; + '-linker') + shift 1; + LINK=$1 + ;; + -l*) + DEPS="$DEPS $1" + ;; + -L*) + DEPS="$DEPS $1" + ;; + '-cplusplus') + CPLUSPLUS=1 + ;; + '-static') + STATIC=1 + ;; + '-install') + shift 1; + INSTALLDIR=$1 + ;; + '-arch') + shift 1; + ARCH=$1 + ;; + '-archopt') + shift 1; + ARCHOPT=$1 + ;; + '-noprefix') + NOPREFIX=1 + ;; + '-exports') + shift 1; + EXPORTS=$1 + ;; + -*) + echo "mklib: Unknown option: " $1 ; + exit 1 + ;; + *) + # This should be the first object file, stop parsing + break esac shift 1 done OBJECTS=$@ + if [ ${ARCH} = "auto" ] ; then ARCH=`uname` fi @@ -476,6 +540,8 @@ case $ARCH in 'icc') # Intel C compiler + # This should get merged into the Linux code, above, since this isn't + # really a different architecture. LIBNAME="lib${LIBNAME}" # prefix with "lib" if [ $STATIC = 1 ] ; then @@ -593,7 +659,7 @@ case $ARCH in ar rv ${LIBNAME} ${OBJECTS} FINAL_LIBS="${LIBNAME}" else - LIBNAME="lib${LIBNAME}.so" # prefix with "lib" + LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" echo "mklib: Making shared library for example arch: " ${LIBNAME} ld -o ${LIBNAME} ${OBJECTS} ${DEPS} FINAL_LIBS="${LIBNAME}" |