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 |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 7 | # Python. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 8 | # |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 9 | # Shell script to build shared library versions of the modules; since |
| 10 | # the change to the *ahem* "proper" import/export mechanism, this script |
| 11 | # is much simpler. It handles PowerPC and x86, too. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 12 | # |
| 13 | # This is called by the Modules/Makefile as $(LDSHARED): |
| 14 | # |
| 15 | # $(LDSHARED) foomodule.o -o foomodule$(SO) |
| 16 | # |
| 17 | # Could also be called as: |
| 18 | # |
| 19 | # $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \ |
| 20 | # -o readline$(SO) |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 21 | # |
| 22 | # so we need to preserve the arguments, sort of. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 23 | |
| 24 | # Make sure we got reasonable arguments. |
| 25 | TARGET="" |
| 26 | ARGS="" |
| 27 | |
| 28 | while [ "$#" != "0" ]; do |
| 29 | case "$1" in |
| 30 | -o) TARGET="$2"; shift; shift;; |
| 31 | *) ARGS="$ARGS $1"; shift;; |
| 32 | esac |
| 33 | done |
| 34 | |
| 35 | if [ "$TARGET" = "" ] ; then |
| 36 | echo "Usage:" |
| 37 | echo |
| 38 | echo " $0 [args] -o foomodule.so [args] foomodule.o [args]" |
| 39 | echo |
| 40 | echo "Where:" |
| 41 | echo |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 42 | echo " [args] normal compiler arguments" |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 43 | exit 1 |
| 44 | fi |
| 45 | |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 46 | # The shared libraries and glue objects we need to link against; these |
| 47 | # libs are overkill for most of the standard modules, but it makes life |
| 48 | # in this shell script easier. |
| 49 | LIBS="-L.. -lpython1.5 -lbe -lnet -lroot" |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 50 | |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 51 | case $BE_HOST_CPU in |
| 52 | ppc) |
| 53 | # Boy, do we need a lot of crap... |
| 54 | GLUE_LOC=/boot/develop/lib/ppc |
| 55 | GLUE="${GLUE_LOC}/glue-noinit.a ${GLUE_LOC}/init_term_dyn.o" |
| 56 | CC="mwcc -xms -export pragma -nodup" |
| 57 | ;; |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 58 | |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 59 | x86) |
| 60 | # We don't need as much crap here... |
| 61 | GLUE="" |
| 62 | CC="gcc -nostart -Wl,-soname=${TARGET}" |
| 63 | ;; |
| 64 | |
| 65 | *) |
| 66 | # What the?!? |
| 67 | echo "$0 doesn't support $BE_HOST_CPU systems..." |
| 68 | echo "You're on your own... I'd be surprised if this works." |
| 69 | GLUE="" |
| 70 | CC="cc" |
| 71 | ;; |
| 72 | esac |
| 73 | |
| 74 | # Now link that shared lib... |
| 75 | $CC -o $TARGET $ARGS $GLUE $LIBS |