blob: ac20cd25ef3b0e2ecbd90dff4fdfa214f0aabfca [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
Guido van Rossumfc4966b1998-12-17 18:00:33 +00007# Python.
Guido van Rossumd8eb2111998-08-04 17:57:28 +00008#
Guido van Rossumfc4966b1998-12-17 18:00:33 +00009# 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 Rossumd8eb2111998-08-04 17:57:28 +000012#
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 Rossumfc4966b1998-12-17 18:00:33 +000021#
22# so we need to preserve the arguments, sort of.
Guido van Rossumd8eb2111998-08-04 17:57:28 +000023
24# Make sure we got reasonable arguments.
25TARGET=""
26ARGS=""
Fred Drakeb59c4602000-10-06 15:57:45 +000027VERSION=2.0
Guido van Rossumd8eb2111998-08-04 17:57:28 +000028
29while [ "$#" != "0" ]; do
30 case "$1" in
31 -o) TARGET="$2"; shift; shift;;
32 *) ARGS="$ARGS $1"; shift;;
33 esac
34done
35
36if [ "$TARGET" = "" ] ; then
37 echo "Usage:"
38 echo
39 echo " $0 [args] -o foomodule.so [args] foomodule.o [args]"
40 echo
41 echo "Where:"
42 echo
Guido van Rossumfc4966b1998-12-17 18:00:33 +000043 echo " [args] normal compiler arguments"
Guido van Rossumd8eb2111998-08-04 17:57:28 +000044 exit 1
45fi
46
Guido van Rossumd8eb2111998-08-04 17:57:28 +000047# The shared libraries and glue objects we need to link against; these
48# libs are overkill for most of the standard modules, but it makes life
49# in this shell script easier.
Fred Drake56221a72000-08-15 18:52:33 +000050LIBS="-L.. -lpython$VERSION -lbe -lnet -lroot"
Guido van Rossumd8eb2111998-08-04 17:57:28 +000051
Guido van Rossumfc4966b1998-12-17 18:00:33 +000052case $BE_HOST_CPU in
53 ppc)
54 # Boy, do we need a lot of crap...
55 GLUE_LOC=/boot/develop/lib/ppc
56 GLUE="${GLUE_LOC}/glue-noinit.a ${GLUE_LOC}/init_term_dyn.o"
Guido van Rossum6b9da451999-03-24 17:48:12 +000057 case $(uname -r) in
58 4.0*) CC="mwcc -xms -export pragma -nodup" ;;
59 *) CC="mwcc -shared -export pragma -nodup" ;;
60 esac
Guido van Rossumfc4966b1998-12-17 18:00:33 +000061 ;;
Guido van Rossumd8eb2111998-08-04 17:57:28 +000062
Guido van Rossumfc4966b1998-12-17 18:00:33 +000063 x86)
64 # We don't need as much crap here...
65 GLUE=""
66 CC="gcc -nostart -Wl,-soname=${TARGET}"
67 ;;
68
69 *)
70 # What the?!?
71 echo "$0 doesn't support $BE_HOST_CPU systems..."
72 echo "You're on your own... I'd be surprised if this works."
73 GLUE=""
74 CC="cc"
75 ;;
76esac
77
78# Now link that shared lib...
79$CC -o $TARGET $ARGS $GLUE $LIBS