blob: f0a6f9f0b51f0d4772797ef0df0e7cf8fe14eead [file] [log] [blame]
Guido van Rossumd8eb2111998-08-04 17:57:28 +00001#! /bin/sh
2#
3# linkmodule for Python
4# Chris Herborth (chrish@qnx.com)
5#
6# This is covered by the same copyright/licensing terms as the rest of
7# Python
8#
9# Shell script to build shared library versions of the modules; the
10# idea is to build an export list containing only the init*() function
11# for the module. We _could_ assume for foomodule.o it was initfoo, but
12# that's asking for trouble... this is a little less efficient but correct.
13#
14# This is called by the Modules/Makefile as $(LDSHARED):
15#
16# $(LDSHARED) foomodule.o -o foomodule$(SO)
17#
18# Could also be called as:
19#
20# $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \
21# -o readline$(SO)
22
23# Check to make sure we know what we're doing.
24system="`uname -m`"
25if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then
26 echo "Sorry, BeOS Python doesn't support x86 yet."
27 exit 1
28fi
29
30# Make sure we got reasonable arguments.
31TARGET=""
32ARGS=""
33
34while [ "$#" != "0" ]; do
35 case "$1" in
36 -o) TARGET="$2"; shift; shift;;
37 *) ARGS="$ARGS $1"; shift;;
38 esac
39done
40
41if [ "$TARGET" = "" ] ; then
42 echo "Usage:"
43 echo
44 echo " $0 [args] -o foomodule.so [args] foomodule.o [args]"
45 echo
46 echo "Where:"
47 echo
48 echo " [args] normal mwcc arguments"
49 exit 1
50fi
51
52EXPORTS=${TARGET%.so}.exp
53
54# The shared libraries and glue objects we need to link against; these
55# libs are overkill for most of the standard modules, but it makes life
56# in this shell script easier.
57LIBS="-L.. -lpython1.5 -lbe -lnet -lroot"
58GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"
59
60# Check to see if we've already got an exports file; we don't need to
61# update this once we've got it because we only ever want to export
62# one symbol.
63if [ ! -e $EXPORTS ] ; then
64 # The init*() function has to be related to the module's .so name
65 # for importdl to work.
66 echo init${TARGET%.so} | sed -e s/module// > $EXPORTS
67fi
68
69# Now link against the clean exports file.
70mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup