#!/bin/sh

# Make a OpenBSD shared library
# contributed by thomas graichen (graichen@OpenBSD.org)

#--identification------------------------------------------------------

# $Id: mklib.openbsd,v 1.1 2001/02/22 20:55:36 philippe Exp $

# $Log: mklib.openbsd,v $
# Revision 1.1  2001/02/22 20:55:36  philippe
# xrml 0.5.0 initial commit
#
# Revision 1.2  1999/09/15 15:10:20  brianp
# added third, tiny version number to arguments
#
# Revision 1.1  1999/08/19 13:53:04  brianp
# initial check-in (post-crash)
#


#--common--------------------------------------------------------------

LIBRARY=$1
shift 1

MAJOR=$1
shift 1

MINOR=$1
shift 1

TINY=$1
shift 1

OBJECTS=$*

#--platform------------------------------------------------------------

set -x

LIBRARY=`basename $LIBRARY .so`

VERSION="${MAJOR}.${MINOR}"

echo "Building PIC library $LIBRARY"
rm -f ${LIBRARY}_pic.a ${LIBRARY}.so.${VERSION}
ar cq ${LIBRARY}_pic.a ${OBJECTS}
ranlib ${LIBRARY}_pic.a

ld -x -Bshareable -Bforcearchive -o ${LIBRARY}.so.${VERSION} ${LIBRARY}_pic.a

cp ${LIBRARY}_pic.a ${LIBRARY}.so.${VERSION} ../lib
ln -s ../lib/${LIBRARY}.so.${VERSION} ../lib/${LIBRARY}.so
