summaryrefslogtreecommitdiffstats
path: root/BeOS/linkmodule
blob: f0a6f9f0b51f0d4772797ef0df0e7cf8fe14eead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /bin/sh
#
# linkmodule for Python
# Chris Herborth (chrish@qnx.com)
#
# This is covered by the same copyright/licensing terms as the rest of
# Python
#
# Shell script to build shared library versions of the modules; the
# idea is to build an export list containing only the init*() function
# for the module.  We _could_ assume for foomodule.o it was initfoo, but
# that's asking for trouble... this is a little less efficient but correct.
#
# This is called by the Modules/Makefile as $(LDSHARED):
#
# $(LDSHARED) foomodule.o -o foomodule$(SO)
#
# Could also be called as:
#
# $(LDSHARED)  readline.o  -L/boot/home/config/lib -lreadline -ltermcap \
# -o readline$(SO)

# Check to make sure we know what we're doing.
system="`uname -m`"
if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then
	echo "Sorry, BeOS Python doesn't support x86 yet."
	exit 1
fi

# Make sure we got reasonable arguments.
TARGET=""
ARGS=""

while [ "$#" != "0" ]; do
	case "$1" in
		-o)	TARGET="$2"; shift; shift;;
		*)	ARGS="$ARGS $1"; shift;;
	esac
done

if [ "$TARGET" = "" ] ; then
	echo "Usage:"
	echo
	echo "	$0 [args] -o foomodule.so [args] foomodule.o [args]"
	echo
	echo "Where:"
	echo
	echo "	[args]	normal mwcc arguments"
	exit 1
fi

EXPORTS=${TARGET%.so}.exp

# The shared libraries and glue objects we need to link against; these
# libs are overkill for most of the standard modules, but it makes life
# in this shell script easier.
LIBS="-L.. -lpython1.5 -lbe -lnet -lroot"
GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"

# Check to see if we've already got an exports file; we don't need to
# update this once we've got it because we only ever want to export
# one symbol.
if [ ! -e $EXPORTS ] ; then
	# The init*() function has to be related to the module's .so name
	# for importdl to work.
	echo init${TARGET%.so} | sed -e s/module// > $EXPORTS
fi

# Now link against the clean exports file.
mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup