Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc4966b

Browse files
committed
Changes for new BeOS port by Chris Herborth
1 parent 476e49f commit fc4966b

3 files changed

Lines changed: 74 additions & 149 deletions

File tree

BeOS/README

Lines changed: 31 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
Python 1.5.1 for BeOS
1+
Python 1.5.x (x > 1) for BeOS
22

33
This directory contains several useful things to help you build your own
44
version of Python for BeOS.
55

6-
At this time, Python only supports BeOS on the PowerPC platform; if you'd
7-
like to help me port it to the x86 platform, please let me know (I only
8-
have limited access to BeOS on an x86 system). If you'd like to lend
9-
me an x86 laptop running BeOS to do the port, _definitely_ let me know! :-)
10-
I'll even give it back when I'm done.
11-
126
What's Here?
137

14-
ar-1.1 - An "ar" command with a POSIX 1003.2 interface; you'll need
15-
this for building the Python libraries under BeOS
16-
(/bin/ar just won't cut it).
8+
ar-fake - A shell script used by the build process to emulate a "real"
9+
POSIX ar command; helps to build the Python shared library.
1710

1811
linkcc - A shell script used by the build process to build the Python
1912
shared library.
@@ -41,100 +34,59 @@ README.readline-2.2 - Instructions for compiling/installing GNU readline 2.2.
4134

4235
Compiling Your Own Version
4336

44-
To compile your own version of Python 1.5.1 for BeOS (with any luck,
45-
Python 1.6 will compile "out of the box" on BeOS), try this:
46-
47-
1) Get the Python 1.5.1 source code from ftp.python.org.
48-
49-
2) Get the Python 1.5.1 diffs from my web pages
50-
(http://www.qnx.com/~chrish/Be/software/); if you can't get them through
51-
a web browser, send me email and I'll mail them back to you. These
52-
diffs should also be available at ftp.python.org along with the BeOS
53-
binary archive.
54-
55-
Run autoconf. If you don't have autoconf, you can get a precompiled
56-
version from GeekGadgets (ftp://ftp.ninemoons.com/pub/geekgadgets/...).
37+
To compile your own version of Python 1.5.x for BeOS (with any luck,
38+
Python 1.5.2 and later will compile "out of the box" on BeOS), try this:
5739

58-
3) Compile and install the POSIX ar from the ar-1.1 directory; see the
59-
README in there for details.
40+
1) Get the latest Python source code from ftp.python.org.
6041

61-
4) Configure with:
42+
2) Configure with:
6243

63-
AR=ar-posix RANLIB=: ./configure --verbose --without-gcc \
44+
AR=$(pwd)/BeOS/ar-fake RANLIB=: ./configure --verbose --without-gcc \
6445
--prefix=/boot/home/config --with-thread
6546

66-
The only strange thing that happens during the configure is that
67-
we fail the "genuine getopt()" test; this is odd because we've got
68-
a real live GNU getopt() in the system libs. Other packages built
69-
using configure (such as all of the goodies in GeekGadgets) suffer
70-
the same fate though, so it's not a Python problem.
47+
3) Copy Modules/Setup.in to Modules/Setup.
7148

72-
5) Copy Modules/Setup.in to Modules/Setup.
49+
4) Edit Modules/Setup to turn on all the modules you want built.
7350

74-
6) Edit Modules/Setup to turn on all the modules you want built. I've
75-
personally built the following modules:
51+
Make sure you use _socket instead of socket for the name of the
52+
socketmodule on BeOS.
7653

77-
array, audioop, binascii, cPickle, cStringIO, cmath, crypt, curses,
78-
errno, fcntl, gdbm, grp, imageop, math, md5, new, operator, parser,
79-
pcre, posix, pwd, readline, regex, reop, rgbimg, rotor, select,
80-
signal, socket, soundex, strop, struct, syslog, termios, thread,
81-
time, timing, zlib
54+
If you want the modules to be built as shared libraries, instead of as
55+
part of the Python shared library, be sure to uncomment the #*shared*
56+
line.
8257

83-
Newly compiled/tested with 1.5.1:
84-
85-
_locale
58+
5) Make sure Modules/Makefile.pre has REALLIBRARY set to:
8659

87-
You can get precompiled gdbm, ncurses, and zlib libraries from the
88-
GeekGadgets repository (ftp://ftp.ninemoons.com/pub/geekgadgets/...).
89-
90-
Make sure you use _socket instead of socket for the name of the
91-
socketmodule on BeOS.
60+
REALLIBRARY=../libpython$(VERSION).so
9261

93-
7) Make:
62+
6) Make:
9463

95-
make
96-
97-
or, if you feel the need for speed:
98-
99-
make OPT="-O7 -opt schedule604"
64+
make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
65+
CCSHARED=-UUSE_DL_EXPORT
10066

101-
You can safely ignore any warnings you see during the build (and you'll
102-
see several if you use full warnings; I compiled the distribution with
103-
-w9 -ansi strict and cleaned up any errors...).
67+
7) Test:
10468

105-
8) Test:
106-
107-
make test
69+
make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
70+
CCSHARED=-UUSE_DL_EXPORT test
10871

10972
Expect the following errors:
11073

111-
test_builtin failed -- round(1000000000.0)
112-
test_fcntl skipped -- an optional feature could not be imported
11374
test_grp crashed -- exceptions.KeyError : getgrnam(): name not found
11475
test_pwd failed -- Writing: 'fakename', expected: 'caught e'
11576
test_socket crashed -- exceptions.AttributeError : SOCK_RAW
11677

11778
These are all due to either partial support for certain things (like
118-
sockets), or valid differences between systems (like the round()
119-
error; different CPUs represent floating point numbers differently,
120-
which can cause minor rounding errors).
121-
122-
9) Install:
123-
124-
make install
79+
sockets), or valid differences between systems.
12580

126-
10) Enjoy!
81+
NOTE: On R4/x86, the pause() function is broken; expect the signal
82+
module test to crash Python!
12783

128-
NOTE
84+
8) Install:
12985

130-
If you're going to build your own C/C++-based Python modules, link them
131-
against the libpython1.5.so shared library (in /boot/home/config/lib)
132-
instead of the libpython1.5.a (in /boot/home/config/lib/python1.5/config),
133-
unless you're building a statically-linked python interpreter (then you
134-
could try linking against _APP_ instead).
86+
make AR=$(pwd)/BeOS/ar-fake RANLIB=: OPT=-DUSE_DL_EXPORT \
87+
CCSHARED=-UUSE_DL_EXPORT install
13588

136-
Mixing modules linked against the shared library with a statically-linked
137-
interpreter is a bad idea (and it'll fail in _interesting_ ways).
89+
9) Enjoy!
13890

13991
- Chris Herborth ([email protected])
140-
April 25, 1998
92+
December 17, 1998

BeOS/linkcc

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,20 @@
2424
# For BeOS we should set $(LINKCC) to this in configure (similar to the
2525
# AIX situation):
2626
#
27-
# $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) -nodup $(OPT)
27+
# $(srcdir)../BeOS/linkcc $(LIBRARY) $(PURIFY) $(CC) $(OPT)
2828
#
2929
# -L.. -lpython$(VERSION) will automagically pick up the shared library.
30-
31-
# Check to make sure we know what we're doing.
32-
system="`uname -m`"
33-
if [ "$system" != "BeMac" ] && [ "$system" != "BeBox" ] ; then
34-
echo "Sorry, BeOS Python doesn't support x86 yet."
35-
exit 1
36-
fi
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.
3735

3836
LIBRARY="$1"; shift
3937

4038
# What we want to end up with.
41-
EXPORTS=${LIBRARY%.a}.exp
4239
DYNAMIC=${LIBRARY%.a}.so
43-
LINK_DYNAMIC="-l`echo ${DYNAMIC%.so} | sed -e s,\\\.\\\./,, -e s,lib,,`"
40+
LINK_DYNAMIC="-l$(basename ${DYNAMIC%.so} | sed -e s,lib,,)"
4441

4542
# Grab the rest of the args and build them into the command used to
4643
# link the python binary. Make sure we link against the shared lib
@@ -52,49 +49,20 @@ while [ "$#" != "0" ] ; do
5249
LINK_CMD="$LINK_CMD -L.. $LINK_DYNAMIC"
5350
shift
5451
;;
52+
5553
*)
5654
LINK_CMD="$LINK_CMD $1"
5755
shift
5856
;;
5957
esac
6058
done
6159

62-
# The shared libraries and glue objects we need to link against.
60+
# The shared libraries and glue objects we need to link against; this is
61+
# a little overkill, but it'll be OK.
6362
LIBS="-lbe -lnet -lroot"
64-
GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"
65-
66-
# Unwanted symbols we need to eliminate; these are regular expressions
67-
# passed to egrep.
68-
SYMS="opterr optind optarg getopt __.* longjmp _.*_"
69-
70-
# Check to see if we've already got an exports file, and delete it if
71-
# it's older than the lib.
72-
if [ -e $EXPORTS ] && [ $LIBRARY -nt $EXPORTS ] ; then
73-
echo "Deleting old exports file for $DYNAMIC..."
74-
rm -f $EXPORTS
75-
fi
76-
77-
if [ ! -e $EXPORTS ] ; then
78-
# First link; create the exports file with the unwanted global symbols
79-
# in it. It's a pity we don't have "nm" or something like that...
80-
rm -f temp-exports.exp
81-
mwcc -xms -f temp-exports.exp -o $DYNAMIC $LIBRARY $GLUE $LIBS -nodup
82-
83-
# Now clean out those bad symbols.
84-
for sym in $SYMS ; do
85-
rm -f temp-exports.exp2
86-
egrep -v "^$sym$" < temp-exports.exp > temp-exports.exp2
87-
mv -f temp-exports.exp2 temp-exports.exp
88-
done
89-
90-
rm -f temp-exports.exp2
91-
mv -f temp-exports.exp $EXPORTS
92-
fi
93-
94-
# Now link against the clean exports file.
95-
mwcc -xms -f $EXPORTS -o $DYNAMIC $LIBRARY $GLUE $LIBS -nodup
9663

97-
# We'll need this or the python binary won't load libpython.so...
64+
# We'll need this or the python binary won't load libpython.so... handy
65+
# for testing.
9866
( cd .. ; ln -sf `pwd` lib )
9967

10068
# Now build the python binary.

BeOS/linkmodule

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
# Chris Herborth ([email protected])
55
#
66
# This is covered by the same copyright/licensing terms as the rest of
7-
# Python
7+
# Python.
88
#
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.
9+
# Shell script to build shared library versions of the modules; since
10+
# the change to the *ahem* "proper" import/export mechanism, this script
11+
# is much simpler. It handles PowerPC and x86, too.
1312
#
1413
# This is called by the Modules/Makefile as $(LDSHARED):
1514
#
@@ -19,13 +18,8 @@
1918
#
2019
# $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \
2120
# -o readline$(SO)
22-
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
28-
fi
21+
#
22+
# so we need to preserve the arguments, sort of.
2923

3024
# Make sure we got reasonable arguments.
3125
TARGET=""
@@ -45,26 +39,37 @@ if [ "$TARGET" = "" ] ; then
4539
echo
4640
echo "Where:"
4741
echo
48-
echo " [args] normal mwcc arguments"
42+
echo " [args] normal compiler arguments"
4943
exit 1
5044
fi
5145

52-
EXPORTS=${TARGET%.so}.exp
53-
5446
# The shared libraries and glue objects we need to link against; these
5547
# libs are overkill for most of the standard modules, but it makes life
5648
# in this shell script easier.
5749
LIBS="-L.. -lpython1.5 -lbe -lnet -lroot"
58-
GLUE="/boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o"
5950

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
67-
fi
51+
case $BE_HOST_CPU in
52+
ppc)
53+
# Boy, do we need a lot of crap...
54+
GLUE_LOC=/boot/develop/lib/ppc
55+
GLUE="${GLUE_LOC}/glue-noinit.a ${GLUE_LOC}/init_term_dyn.o"
56+
CC="mwcc -xms -export pragma -nodup"
57+
;;
58+
59+
x86)
60+
# We don't need as much crap here...
61+
GLUE=""
62+
CC="gcc -nostart -Wl,-soname=${TARGET}"
63+
;;
64+
65+
*)
66+
# What the?!?
67+
echo "$0 doesn't support $BE_HOST_CPU systems..."
68+
echo "You're on your own... I'd be surprised if this works."
69+
GLUE=""
70+
CC="cc"
71+
;;
72+
esac
6873

69-
# Now link against the clean exports file.
70-
mwcc -xms -f $EXPORTS -o $TARGET $ARGS $GLUE $LIBS -nodup
74+
# Now link that shared lib...
75+
$CC -o $TARGET $ARGS $GLUE $LIBS

0 commit comments

Comments
 (0)