cpython/BeOS/linkmodule

71 lines
1.9 KiB
Plaintext
Raw Normal View History

#! /bin/sh
#
# linkmodule for Python
# Chris Herborth (chrish@qnx.com)
#
# This is covered by the same copyright/licensing terms as the rest of
# Python
#
# Shell script to build shared library versions of the modules; the
# idea is to build an export list containing only the init*() function
# for the module. We _could_ assume for foomodule.o it was initfoo, but
# that's asking for trouble... this is a little less efficient but correct.
#
# This is called by the Modules/Makefile as $(LDSHARED):
#
# $(LDSHARED) foomodule.o -o foomodule$(SO)
#
# Could also be called as:
#
# $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \
# -o readline$(SO)
# Check to make sure we know what we're doing.
system="`uname -m`"
if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then
echo "Sorry, BeOS Python doesn't support x86 yet."
exit 1
fi
# Make sure we got reasonable arguments.
TARGET=""
ARGS=""
while [ "$#" != "0" ]; do
case "$1" in
-o) TARGET="$2"; shift; shift;;
*) ARGS="$ARGS $1"; shift;;
esac
done
if [ "$TARGET" = "" ] ; then
echo "Usage:"
echo
echo " $0 [args] -o foomodule.so [args] foomodule.o [args]"
echo
echo "Where:"
echo
echo " [args] normal mwcc arguments"
exit 1
fi
EXPORTS=${TARGET%.so}.exp
# The shared libraries and glue objects we need to link against; these
# libs are overkill for most of the standard modules, but it makes life
# in this shell script easier.
LIBS="-L.. -lpython1.5 -lbe -lnet -lroot"
GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"
# Check to see if we've already got an exports file; we don't need to
# update this once we've got it because we only ever want to export
# one symbol.
if [ ! -e $EXPORTS ] ; then
# The init*() function has to be related to the module's .so name
# for importdl to work.
echo init${TARGET%.so} | sed -e s/module// > $EXPORTS
fi
# Now link against the clean exports file.
mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup