Commit 6e30ee4d authored by Guido van Rossum's avatar Guido van Rossum

Changes for new BeOS port by Chris Herborth

parent 1f687f98
Python 1.5.1 for BeOS Python 1.5.x (x > 1) for BeOS
This directory contains several useful things to help you build your own This directory contains several useful things to help you build your own
version of Python for BeOS. version of Python for BeOS.
At this time, Python only supports BeOS on the PowerPC platform; if you'd
like to help me port it to the x86 platform, please let me know (I only
have limited access to BeOS on an x86 system). If you'd like to lend
me an x86 laptop running BeOS to do the port, _definitely_ let me know! :-)
I'll even give it back when I'm done.
What's Here? What's Here?
ar-1.1 - An "ar" command with a POSIX 1003.2 interface; you'll need ar-fake - A shell script used by the build process to emulate a "real"
this for building the Python libraries under BeOS POSIX ar command; helps to build the Python shared library.
(/bin/ar just won't cut it).
linkcc - A shell script used by the build process to build the Python linkcc - A shell script used by the build process to build the Python
shared library. shared library.
...@@ -41,100 +34,59 @@ README.readline-2.2 - Instructions for compiling/installing GNU readline 2.2. ...@@ -41,100 +34,59 @@ README.readline-2.2 - Instructions for compiling/installing GNU readline 2.2.
Compiling Your Own Version Compiling Your Own Version
To compile your own version of Python 1.5.1 for BeOS (with any luck, To compile your own version of Python 1.5.x for BeOS (with any luck,
Python 1.6 will compile "out of the box" on BeOS), try this: Python 1.5.2 and later will compile "out of the box" on BeOS), try this:
1) Get the Python 1.5.1 source code from ftp.python.org.
2) Get the Python 1.5.1 diffs from my web pages
(http://www.qnx.com/~chrish/Be/software/); if you can't get them through
a web browser, send me email and I'll mail them back to you. These
diffs should also be available at ftp.python.org along with the BeOS
binary archive.
Run autoconf. If you don't have autoconf, you can get a precompiled
version from GeekGadgets (ftp://ftp.ninemoons.com/pub/geekgadgets/...).
3) Compile and install the POSIX ar from the ar-1.1 directory; see the 1) Get the latest Python source code from ftp.python.org.
README in there for details.
4) Configure with: 2) Configure with:
AR=ar-posix RANLIB=: ./configure --verbose --without-gcc \ AR=$(pwd)/BeOS/ar-fake RANLIB=: ./configure --verbose --without-gcc \
--prefix=/boot/home/config --with-thread --prefix=/boot/home/config --with-thread
The only strange thing that happens during the configure is that 3) Copy Modules/Setup.in to Modules/Setup.
we fail the "genuine getopt()" test; this is odd because we've got
a real live GNU getopt() in the system libs. Other packages built
using configure (such as all of the goodies in GeekGadgets) suffer
the same fate though, so it's not a Python problem.
5) Copy Modules/Setup.in to Modules/Setup. 4) Edit Modules/Setup to turn on all the modules you want built.
6) Edit Modules/Setup to turn on all the modules you want built. I've Make sure you use _socket instead of socket for the name of the
personally built the following modules: socketmodule on BeOS.
array, audioop, binascii, cPickle, cStringIO, cmath, crypt, curses, If you want the modules to be built as shared libraries, instead of as
errno, fcntl, gdbm, grp, imageop, math, md5, new, operator, parser, part of the Python shared library, be sure to uncomment the #*shared*
pcre, posix, pwd, readline, regex, reop, rgbimg, rotor, select, line.
signal, socket, soundex, strop, struct, syslog, termios, thread,
time, timing, zlib
Newly compiled/tested with 1.5.1: 5) Make sure Modules/Makefile.pre has REALLIBRARY set to:
_locale
You can get precompiled gdbm, ncurses, and zlib libraries from the REALLIBRARY=../libpython$(VERSION).so
GeekGadgets repository (ftp://ftp.ninemoons.com/pub/geekgadgets/...).
Make sure you use _socket instead of socket for the name of the
socketmodule on BeOS.
7) Make: 6) Make:
make make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
CCSHARED=-UUSE_DL_EXPORT
or, if you feel the need for speed:
make OPT="-O7 -opt schedule604"
You can safely ignore any warnings you see during the build (and you'll 7) Test:
see several if you use full warnings; I compiled the distribution with
-w9 -ansi strict and cleaned up any errors...).
8) Test: make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
CCSHARED=-UUSE_DL_EXPORT test
make test
Expect the following errors: Expect the following errors:
test_builtin failed -- round(1000000000.0)
test_fcntl skipped -- an optional feature could not be imported
test_grp crashed -- exceptions.KeyError : getgrnam(): name not found test_grp crashed -- exceptions.KeyError : getgrnam(): name not found
test_pwd failed -- Writing: 'fakename', expected: 'caught e' test_pwd failed -- Writing: 'fakename', expected: 'caught e'
test_socket crashed -- exceptions.AttributeError : SOCK_RAW test_socket crashed -- exceptions.AttributeError : SOCK_RAW
These are all due to either partial support for certain things (like These are all due to either partial support for certain things (like
sockets), or valid differences between systems (like the round() sockets), or valid differences between systems.
error; different CPUs represent floating point numbers differently,
which can cause minor rounding errors).
9) Install:
make install
10) Enjoy! NOTE: On R4/x86, the pause() function is broken; expect the signal
module test to crash Python!
NOTE 8) Install:
If you're going to build your own C/C++-based Python modules, link them make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
against the libpython1.5.so shared library (in /boot/home/config/lib) CCSHARED=-UUSE_DL_EXPORT install
instead of the libpython1.5.a (in /boot/home/config/lib/python1.5/config),
unless you're building a statically-linked python interpreter (then you
could try linking against _APP_ instead).
Mixing modules linked against the shared library with a statically-linked 9) Enjoy!
interpreter is a bad idea (and it'll fail in _interesting_ ways).
- Chris Herborth (chrish@qnx.com) - Chris Herborth (chrish@qnx.com)
April 25, 1998 December 17, 1998
...@@ -24,23 +24,20 @@ ...@@ -24,23 +24,20 @@
# For BeOS we should set $(LINKCC) to this in configure (similar to the # For BeOS we should set $(LINKCC) to this in configure (similar to the
# AIX situation): # AIX situation):
# #
# $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) -nodup $(OPT) # $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) $(OPT)
# #
# -L.. -lpython$(VERSION) will automagically pick up the shared library. # -L.. -lpython$(VERSION) will automagically pick up the shared library.
#
# Check to make sure we know what we're doing. # As of Python 1.5.2, this isn't strictly necessary, but it makes me
system="`uname -m`" # feel safer. It makes sure we've got all the BeOS-specific libraries,
if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then # and it creates the "lib" symlink that we'll need for chance of running
echo "Sorry, BeOS Python doesn't support x86 yet." # "make test" successfully.
exit 1
fi
LIBRARY="$1"; shift LIBRARY="$1"; shift
# What we want to end up with. # What we want to end up with.
EXPORTS=${LIBRARY%.a}.exp
DYNAMIC=${LIBRARY%.a}.so DYNAMIC=${LIBRARY%.a}.so
LINK_DYNAMIC="-l`echo ${DYNAMIC%.so} | sed -e s,\\\.\\\./,, -e s,lib,,`" LINK_DYNAMIC="-l$(basename ${DYNAMIC%.so} | sed -e s,lib,,)"
# Grab the rest of the args and build them into the command used to # Grab the rest of the args and build them into the command used to
# link the python binary. Make sure we link against the shared lib # link the python binary. Make sure we link against the shared lib
...@@ -52,6 +49,7 @@ while [ "$#" != "0" ] ; do ...@@ -52,6 +49,7 @@ while [ "$#" != "0" ] ; do
LINK_CMD="$LINK_CMD -L.. $LINK_DYNAMIC" LINK_CMD="$LINK_CMD -L.. $LINK_DYNAMIC"
shift shift
;; ;;
*) *)
LINK_CMD="$LINK_CMD $1" LINK_CMD="$LINK_CMD $1"
shift shift
...@@ -59,42 +57,12 @@ while [ "$#" != "0" ] ; do ...@@ -59,42 +57,12 @@ while [ "$#" != "0" ] ; do
esac esac
done done
# The shared libraries and glue objects we need to link against. # The shared libraries and glue objects we need to link against; this is
# a little overkill, but it'll be OK.
LIBS="-lbe -lnet -lroot" LIBS="-lbe -lnet -lroot"
GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"
# Unwanted symbols we need to eliminate; these are regular expressions
# passed to egrep.
SYMS="opterr optind optarg getopt __.* longjmp _.*_"
# Check to see if we've already got an exports file, and delete it if
# it's older than the lib.
if [ -e $EXPORTS ] && [ $LIBRARY -nt $EXPORTS ] ; then
echo "Deleting old exports file for $DYNAMIC..."
rm -f $EXPORTS
fi
if [ ! -e $EXPORTS ] ; then
# First link; create the exports file with the unwanted global symbols
# in it. It's a pity we don't have "nm" or something like that...
rm -f temp-exports.exp
mwcc -xms -f temp-exports.exp -o $DYNAMIC $LIBRARY $GLUE $LIBS -nodup
# Now clean out those bad symbols.
for sym in $SYMS ; do
rm -f temp-exports.exp2
egrep -v "^$sym$" < temp-exports.exp > temp-exports.exp2
mv -f temp-exports.exp2 temp-exports.exp
done
rm -f temp-exports.exp2
mv -f temp-exports.exp $EXPORTS
fi
# Now link against the clean exports file.
mwcc -xms -f $EXPORTS -o $DYNAMIC $LIBRARY $GLUE $LIBS -nodup
# We'll need this or the python binary won't load libpython.so... # We'll need this or the python binary won't load libpython.so... handy
# for testing.
( cd .. ; ln -sf `pwd` lib ) ( cd .. ; ln -sf `pwd` lib )
# Now build the python binary. # Now build the python binary.
......
...@@ -4,12 +4,11 @@ ...@@ -4,12 +4,11 @@
# Chris Herborth (chrish@qnx.com) # Chris Herborth (chrish@qnx.com)
# #
# This is covered by the same copyright/licensing terms as the rest of # This is covered by the same copyright/licensing terms as the rest of
# Python # Python.
# #
# Shell script to build shared library versions of the modules; the # Shell script to build shared library versions of the modules; since
# idea is to build an export list containing only the init*() function # the change to the *ahem* "proper" import/export mechanism, this script
# for the module. We _could_ assume for foomodule.o it was initfoo, but # is much simpler. It handles PowerPC and x86, too.
# that's asking for trouble... this is a little less efficient but correct.
# #
# This is called by the Modules/Makefile as $(LDSHARED): # This is called by the Modules/Makefile as $(LDSHARED):
# #
...@@ -19,13 +18,8 @@ ...@@ -19,13 +18,8 @@
# #
# $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \ # $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \
# -o readline$(SO) # -o readline$(SO)
#
# Check to make sure we know what we're doing. # so we need to preserve the arguments, sort of.
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. # Make sure we got reasonable arguments.
TARGET="" TARGET=""
...@@ -45,26 +39,37 @@ if [ "$TARGET" = "" ] ; then ...@@ -45,26 +39,37 @@ if [ "$TARGET" = "" ] ; then
echo echo
echo "Where:" echo "Where:"
echo echo
echo " [args] normal mwcc arguments" echo " [args] normal compiler arguments"
exit 1 exit 1
fi fi
EXPORTS=${TARGET%.so}.exp
# The shared libraries and glue objects we need to link against; these # 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 # libs are overkill for most of the standard modules, but it makes life
# in this shell script easier. # in this shell script easier.
LIBS="-L.. -lpython1.5 -lbe -lnet -lroot" 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 case $BE_HOST_CPU in
# update this once we've got it because we only ever want to export ppc)
# one symbol. # Boy, do we need a lot of crap...
if [ ! -e $EXPORTS ] ; then GLUE_LOC=/boot/develop/lib/ppc
# The init*() function has to be related to the module's .so name GLUE="${GLUE_LOC}/glue-noinit.a ${GLUE_LOC}/init_term_dyn.o"
# for importdl to work. CC="mwcc -xms -export pragma -nodup"
echo init${TARGET%.so} | sed -e s/module// > $EXPORTS ;;
fi
x86)
# We don't need as much crap here...
GLUE=""
CC="gcc -nostart -Wl,-soname=${TARGET}"
;;
*)
# What the?!?
echo "$0 doesn't support $BE_HOST_CPU systems..."
echo "You're on your own... I'd be surprised if this works."
GLUE=""
CC="cc"
;;
esac
# Now link against the clean exports file. # Now link that shared lib...
mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup $CC -o $TARGET $ARGS $GLUE $LIBS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment