Improved some error messages for command line processing.
[python/dscho.git] / BeOS / linkmodule
blobf0a6f9f0b51f0d4772797ef0df0e7cf8fe14eead
1 #! /bin/sh
3 # linkmodule for Python
4 # Chris Herborth (chrish@qnx.com)
6 # This is covered by the same copyright/licensing terms as the rest of
7 # Python
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.
14 # This is called by the Modules/Makefile as $(LDSHARED):
16 # $(LDSHARED) foomodule.o -o foomodule$(SO)
18 # Could also be called as:
20 # $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \
21 # -o readline$(SO)
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
30 # Make sure we got reasonable arguments.
31 TARGET=""
32 ARGS=""
34 while [ "$#" != "0" ]; do
35 case "$1" in
36 -o) TARGET="$2"; shift; shift;;
37 *) ARGS="$ARGS $1"; shift;;
38 esac
39 done
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
52 EXPORTS=${TARGET%.so}.exp
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"
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
69 # Now link against the clean exports file.
70 mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup