#!/bin/sh

# Make a Linux ELF shared library

# First argument is name of output library
# Rest of arguments are object files

LIBRARY=$1

shift 1
OBJECTS=$*

# the following provided by Thomas Hiller (Hiller@tu-harburg.d400.de)

LIBMAJOR=2
LIBMINOR=2
VERSION="${LIBMAJOR}.${LIBMINOR}"

LIBNAME=`basename $LIBRARY`
ARNAME=`basename $LIBNAME .so`.a
DIRNAME=`dirname $LIBRARY`

gcc -shared -Wl,-soname,${LIBNAME}.${LIBMAJOR} -o ${LIBRARY}.${VERSION} ${OBJECTS}
(cd $DIRNAME; ln -s ${LIBNAME}.${VERSION} ${LIBNAME}.${LIBMAJOR})

ln -s ${LIBNAME}.${LIBMAJOR} ${LIBRARY}


# also make regular .a files,
# provided by Danek Duvall (duvall@dhduvall.student.princeton.edu)

ar ruv ${DIRNAME}/${ARNAME} ${OBJECTS}
ranlib ${DIRNAME}/${ARNAME}


# Print a reminder about shared libs:
DIR=`cd .. ; pwd`
echo
echo "******Be sure to add" ${DIR}"/lib to your LD_LIBRARY_PATH variable"
echo
sleep 2



#### NOTES:
# One Mesa user reports having to run the "ldconfig -v" command to make
# Linux aware of the shared libs.
