blob: 687c92ecd60b412c56cb1a0b3f8c562f16a9123a [file] [log] [blame]
Guido van Rossumd8eb2111998-08-04 17:57:28 +00001#! /bin/sh
2#
3# linkcc 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 the Python shared library properly; if we haven't
10# already built the export list, we'll need to link twice (argh...) so we
11# can eliminate some unwatnted global symbols from the system glue/init
12# objects.
13#
14# This is called by the Modules/Makefile as part of $(LINKCC):
15#
16# $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \
17# -L.. -lpython$(VERSION) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
18#
19# In 1.5.1 this changed to:
20#
21# $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \
22# $(LIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
23#
24# For BeOS we should set $(LINKCC) to this in configure (similar to the
25# AIX situation):
26#
Guido van Rossumfc4966b1998-12-17 18:00:33 +000027# $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) $(OPT)
Guido van Rossumd8eb2111998-08-04 17:57:28 +000028#
29# -L.. -lpython$(VERSION) will automagically pick up the shared library.
Guido van Rossumfc4966b1998-12-17 18:00:33 +000030#
31# As of Python 1.5.2, this isn't strictly necessary, but it makes me
32# feel safer. It makes sure we've got all the BeOS-specific libraries,
33# and it creates the "lib" symlink that we'll need for chance of running
34# "make test" successfully.
Guido van Rossumd8eb2111998-08-04 17:57:28 +000035
36LIBRARY="$1"; shift
37
38# What we want to end up with.
Guido van Rossume89d4501999-01-04 16:49:09 +000039DYNAMIC=${LIBRARY/.a/.so}
Guido van Rossumfc4966b1998-12-17 18:00:33 +000040LINK_DYNAMIC="-l$(basename ${DYNAMIC%.so} | sed -e s,lib,,)"
Guido van Rossumd8eb2111998-08-04 17:57:28 +000041
42# Grab the rest of the args and build them into the command used to
43# link the python binary. Make sure we link against the shared lib
44# and not the static lib.
45LINK_CMD=""
46while [ "$#" != "0" ] ; do
47 case "$1" in
48 $LIBRARY)
49 LINK_CMD="$LINK_CMD -L.. $LINK_DYNAMIC"
50 shift
51 ;;
Guido van Rossumfc4966b1998-12-17 18:00:33 +000052
Guido van Rossumd8eb2111998-08-04 17:57:28 +000053 *)
54 LINK_CMD="$LINK_CMD $1"
55 shift
56 ;;
57 esac
58done
59
Guido van Rossumfc4966b1998-12-17 18:00:33 +000060# The shared libraries and glue objects we need to link against; this is
61# a little overkill, but it'll be OK.
Guido van Rossumd8eb2111998-08-04 17:57:28 +000062LIBS="-lbe -lnet -lroot"
Guido van Rossumd8eb2111998-08-04 17:57:28 +000063
Guido van Rossume89d4501999-01-04 16:49:09 +000064case $BE_HOST_CPU in
65 ppc)
66 LIBS="-nodup $LIBS"
67 ;;
68esac
69
Guido van Rossumfc4966b1998-12-17 18:00:33 +000070# We'll need this or the python binary won't load libpython.so... handy
71# for testing.
Guido van Rossume89d4501999-01-04 16:49:09 +000072( cd .. ; ln -sf $(pwd) lib )
Guido van Rossumd8eb2111998-08-04 17:57:28 +000073
74# Now build the python binary.
Guido van Rossume89d4501999-01-04 16:49:09 +000075echo "Link command: $LINK_CMD $LIBS"
76$LINK_CMD $LIBS