#!/bin/sh

# Make a FreeBSD shared library
# contributed by Mark Diekhans <markd@grizzly.com>

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

# $Id: mklib.freebsd,v 1.7 1997/10/21 23:32:31 brianp Exp $

# $Log: mklib.freebsd,v $
# Revision 1.7  1997/10/21 23:32:31  brianp
# now takes major and minor version arguments
#

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

# Usage:  mklib libname major minor file.o ...
#
# First argument is name of output library (LIBRARY)
# Second arg is major version number (MAJOR)
# Third arg is minor version number (MINOR)
# Rest of arguments are object files (OBJECTS)

LIBRARY=$1
shift 1

MAJOR=$1
shift 1

MINOR=$1
shift 1

OBJECTS=$*

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

VERSION=$MAJOR.$MINOR

BASENAME=`echo ${LIBRARY} | sed "s/\.a//g"`
SHLIB=${BASENAME}.so.${VERSION}
STLIB=${BASENAME}.a

rm -f ${SHLIB} ${STLIB}

ar cq ${STLIB} ${OBJECTS}
ranlib ${STLIB}
ld -Bshareable -o ${SHLIB} ${OBJECTS}

mv ${SHLIB} ../lib
