Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 1 | #! /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. |
| 24 | system="`uname -m`" |
| 25 | if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then |
| 26 | echo "Sorry, BeOS Python doesn't support x86 yet." |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | # Make sure we got reasonable arguments. |
| 31 | TARGET="" |
| 32 | ARGS="" |
| 33 | |
| 34 | while [ "$#" != "0" ]; do |
| 35 | case "$1" in |
| 36 | -o) TARGET="$2"; shift; shift;; |
| 37 | *) ARGS="$ARGS $1"; shift;; |
| 38 | esac |
| 39 | done |
| 40 | |
| 41 | if [ "$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 |
| 50 | fi |
| 51 | |
| 52 | EXPORTS=${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. |
| 57 | LIBS="-L.. -lpython1.5 -lbe -lnet -lroot" |
| 58 | GLUE="/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. |
| 63 | if [ ! -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 |
| 67 | fi |
| 68 | |
| 69 | # Now link against the clean exports file. |
| 70 | mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup |