Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 1 | #! /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 Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 27 | # $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) $(OPT) |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 28 | # |
| 29 | # -L.. -lpython$(VERSION) will automagically pick up the shared library. |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 30 | # |
| 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 Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 35 | |
| 36 | LIBRARY="$1"; shift |
| 37 | |
| 38 | # What we want to end up with. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 39 | DYNAMIC=${LIBRARY%.a}.so |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 40 | LINK_DYNAMIC="-l$(basename ${DYNAMIC%.so} | sed -e s,lib,,)" |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 41 | |
| 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. |
| 45 | LINK_CMD="" |
| 46 | while [ "$#" != "0" ] ; do |
| 47 | case "$1" in |
| 48 | $LIBRARY) |
| 49 | LINK_CMD="$LINK_CMD -L.. $LINK_DYNAMIC" |
| 50 | shift |
| 51 | ;; |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 52 | |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 53 | *) |
| 54 | LINK_CMD="$LINK_CMD $1" |
| 55 | shift |
| 56 | ;; |
| 57 | esac |
| 58 | done |
| 59 | |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 60 | # The shared libraries and glue objects we need to link against; this is |
| 61 | # a little overkill, but it'll be OK. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 62 | LIBS="-lbe -lnet -lroot" |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 63 | |
Guido van Rossum | fc4966b | 1998-12-17 18:00:33 +0000 | [diff] [blame] | 64 | # We'll need this or the python binary won't load libpython.so... handy |
| 65 | # for testing. |
Guido van Rossum | d8eb211 | 1998-08-04 17:57:28 +0000 | [diff] [blame] | 66 | ( cd .. ; ln -sf `pwd` lib ) |
| 67 | |
| 68 | # Now build the python binary. |
| 69 | echo "Link command: $LINK_CMD" |
| 70 | $LINK_CMD |