blob: 406f478e4a5aa023cf1edee786f46658807ce3e1 [file] [log] [blame]
Jack Jansen8f2d8021996-08-05 15:34:45 +00001<HTML>
2<HEAD>
3<TITLE>Building Mac Python from source</TITLE>
4</HEAD>
5<BODY>
6<H1>Building Mac Python from source</H1>
7<HR>
Jack Jansen8f2d8021996-08-05 15:34:45 +00008
Jack Jansen4c1e56c1996-08-06 16:16:20 +00009This document explains how to build MacPython from source. This is
10necessary if you want to write extension modules for 68K Python, and
11currently also probably the easiest way to build PPC extension
12modules. Building Python is not something to be undertaken lightly,
13the process is not very streamlined so you need a reasonable working
14knowledge of the CodeWarrior development environment, a good net
15connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000016
Jack Jansen4c1e56c1996-08-06 16:16:20 +000017The information density in this file is high, so you should probably
18print it and read it at your leasure. Most things are explained only
19once (and probably in the wrong place:-). <p>
20
21I am very interested in feedback on this document, contact me at <A
22HREF="mailto:jack@cwi.nl">&lt;jack@cwi.nl&gt;</A> or send your
23comments to the <A
24HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
25Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000026
27<H2>What you need.</H2>
28
29The following things you definitely need:
30
31<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000032
Jack Jansen4c1e56c1996-08-06 16:16:20 +000033<LI> You need a MacPython source distribution, of course. You can
34obtain one from <A
35HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>,
36and possibly also from the standard <A
37HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
38site</A>. Everything you need is also included in the standard Python
39source distribution, but the organization is different. Look in
40directory <code>Mac/mwerks/projects</code> for the project files and
41related stuff.
Jack Jansen8f2d8021996-08-05 15:34:45 +000042
Jack Jansen4c1e56c1996-08-06 16:16:20 +000043<LI> You need MetroWerks CodeWarrior. The current distribution has
44been built with version 9 of CodeWarrior. Ordering information is
45available on the <A HREF="http://www.metrowerks.com/">MetroWerks
46homepage</A>. You might still be able to build Python with MPW or
47Think/Symantec C but you are basically on your own.
48
49<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen16e99c01996-09-07 17:11:26 +000050Neeracher. The current distribution has been built with a modified version of
51CWGUSI 1.7.2. CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000052obtainable from <A
53HREF="ftp://ftp.switch.ch/software/mac/src/mw_c">ftp://ftp.switch.ch/software/mac/src/mw_c</A>.
54It is possible to build a non-GUSI Python, see below.
55
Jack Jansen8f2d8021996-08-05 15:34:45 +000056</UL>
57
Jack Jansen4c1e56c1996-08-06 16:16:20 +000058<A NAME="optional">The MacPython project files are configured to
59include a plethora of optional modules</A>, and these modules need a
60number extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000061download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000062dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000063suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000064Python things are a bit more complicated: you have to edit the
65interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000066the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
67file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000068you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000069
70<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000071
Jack Jansen4c1e56c1996-08-06 16:16:20 +000072<LI> Tcl and Tk can be obtained from <A
73HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>.
74The current distributions, Tcl 7.5p1 and Tk 4.1p1 need a bit of work,
75see the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
76below. Get the "full source" distribution, which includes MoreFiles.
Jack Jansen8f2d8021996-08-05 15:34:45 +000077
Jack Jansen4c1e56c1996-08-06 16:16:20 +000078<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
79HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
80was built using version 1.2, which you can obtain from <A
81HREF="ftp://rhino.harvard.edu/pub/dan/WASTE">&lt;ftp://rhino.harvard.edu/pub/dan/WASTE&gt;</A>
82and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000083
Jack Jansen4c1e56c1996-08-06 16:16:20 +000084<LI> JPEG library by the Independent JPEG Group. Python is still built
85using an archaic version of the library, version 4. It can be obtained
86from the <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
87ftp://ftp.cwi.nl/pub/jack/python/mac</A> directory, complete with CW8
88projects. If someone manages to build Python with the version 6
89library I would be grateful if they sent me the changes needed. The
90most recent JPEG library can always be obtained from <A
91HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>.
92
93<LI> The netpbm/pbmplus and libtiff libraries. The netpbm distribution
94(which includes libtiff) is generally available on Internet ftp
95servers. For Python pbmplus, an older incarnation of netpbm, is
96functionally identical to netpbm, since Python only uses the library
97and not the complete applications. A distribution with correct
98projects and library source only is available from, you guessed it, <A
99HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>.
100
Jack Jansen8f2d8021996-08-05 15:34:45 +0000101</UL>
102
103<H2>Setting Up</H2>
104
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000105Now that you have collected everything you should start with building
106the various parts. Everything is independent, with the single
107exception that Tcl and Tk depend on CWGUSI. If you don't want to fix
108access paths try to set things up as follows:
109
Jack Jansen8f2d8021996-08-05 15:34:45 +0000110<PRE>
111Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000113 imglibs
114 libjpeg
115 pbmplus
116 libtiff
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000117 MoreFiles 1.4.2 (not needed by Python, only by tcl/tk)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000118 Python
119 Tcl 7.5
120 Tk 4.1
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000121 Waste 1.2 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000122</PRE>
123
Jack Jansen16e99c01996-09-07 17:11:26 +0000124First build GUSI. Move the files from the "CWGUSI-mods" to the right
125place in the CWGUSI distribution folder, and build the
Jack Jansen27b10ec1996-08-23 15:44:18 +0000126projects <code>GUSI.68K.µ</code>, <code>GUSI.CFM68K.µ</code>
Jack Jansen16e99c01996-09-07 17:11:26 +0000127and <code>GUSI.PPC.µ</code>. If you have a CWGUSI version more recent than
1281.7.2 it could be that the fixes are already included, check it. Alternatively,
129you can forget about the fixes and remove the one reference to GUSILoadPreferences
130in the Python sources. This will disable the "default file creator/type" and
131"Delay Sioux window" preferences in Python.
132
133Next, in
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000134<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>
135and<code>libtiff</code> you build all projects. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000136case, see below. Of course, if you are only interested in one of
137static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000138
139<H2><A NAME="tcltk">Building Tcl/Tk</H2>
140
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000141You need to make a minor organizational change to the Tcl/Tk
142distribution. The current instructions are for the
143<code>tcl7.5.1</code> and <code>tk4.1.1</code> distribution:
144
Jack Jansen8f2d8021996-08-05 15:34:45 +0000145<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000146
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000147<LI> Rename the <code>compat</code> folders to <code>(compat)</code>
148in both the Tcl and Tk folders.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000149
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000150<LI> In the Tcl folder, move <code>strncasecmp.c</code> and
151<code>tclErrno.h</code> from <code>(compat)</code> to the main Tcl
152folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000153
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000154<LI> Fix <code>dnr.c</code> as provided by MetroWerks by inserting
155<pre><code> #pragma ANSI_strict off </code></pre> at the
156beginning. The tcl library is built with strict ANSI on, and this file
157uses C++ style comments.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000158
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000159<LI> If you want to build <code>SimpleTcl</code> and
160<code>SimpleTk</code> you will probably have to remove the references
161to <code>libmoto</code> from the project.
162
163<LI> You are <EM>strongly</EM> advised to add a line
Jack Jansen8f2d8021996-08-05 15:34:45 +0000164<pre><code>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000165#define USE_TCLALLOC 1
Jack Jansen8f2d8021996-08-05 15:34:45 +0000166</code></pre>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000167somewhere at the beginning of <code>MW_TclHeader.pch</code>.
168As distributed, tcl and tk assume that malloc calls always succeed and
169use the resulting pointer without checking for <code>NULL</code>
170values. Needless to say, this wreaks havoc on a Macintosh.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000171
Jack Jansen27b10ec1996-08-23 15:44:18 +0000172<LI> If you want to build for CFM68K you have to modify <code>TclMacNotify.c</code>
173because there is an error in the Apple Universal headers (sic!). Read the
174comments at the beginning of <code>Mac:Python:macglue.c</code> and copy the
175code to <code>TclMacNotify.c</code>. If you get linker errors on <code>GetEvQHdr</code>
176you have not done this correctly.
177
Jack Jansen8f2d8021996-08-05 15:34:45 +0000178</UL>
179
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000180Build first the MoreFiles library, then the Tcl library, then
181SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
182then the Tk library, then SimpleTk (which can again be tested with
183<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000184building Python.
185
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000186<H2>Building Waste</H2>
187
188You do not need to build the Waste libraries, as Python includes the
189source modules themselves. You have to make one modification,
190though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC
191APIs</code>, add the following lines:
192
193<blockquote><pre><code>
194#include <Gestalt.h>
195#include <Errors.h>
196</code></pre></blockquote>
197
Jack Jansen8f2d8021996-08-05 15:34:45 +0000198<H2>The organization of the Python source tree</H2>
199
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000200Time for a short break, while we have a look at the organization of
201the Python source tree. At the top level, we find the following
202folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000203
204<DL>
205<DT> build.mac68k.stand
Jack Jansen27b10ec1996-08-23 15:44:18 +0000206<DD> This is where you will build static 68K interpreters.
207
208<DT> build.mac68k.shared
209<DD> This is where you build the CFM68K shared library, interpreter
210and applet framework.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000211
212<DT> build.macppc.shared
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000213<DD> This is where you build the PPC shared library, interpreter and
Jack Jansen27b10ec1996-08-23 15:44:18 +0000214applet framework. You can also build the fat applet framework here.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000215
216<DT> build.macppc.stand
217<DD> This is where you build a nonshared PPC interpreter (optional).
218
219<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000220<DD> Demo programs that are not Mac-specific. Some of these may not
221work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000222
223<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000224<DD> Extensions to the interpreter that are not Mac-specific. Contains
225only the <code>img</code> extension in this distribution. Extensions
226are <em>not</em> built here, as they are on Unix, but incorporated in
227the core interpreter or built as plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000228
229<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000230<DD> The Python grammar. Included for reference only, you cannot build
231the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000232
233<DT> Include
234<DD> Machine-independent header files.
235
236<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000237<DD> Machine-independent optional modules. Not all of these will work
238on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000239
240<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000241<DD> Machine-independent code for various objects. Most of these are
242not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000243
244<DT> Parser
245<DD> The Python parser (machine-independent).
246
247<DT> PlugIns
Jack Jansen27b10ec1996-08-23 15:44:18 +0000248<DD> This is where you build the PPC and CFM68K dynamically-loaded plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000249
250<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000251<DD> The core interpreter. Most files are machine-independent, some
252are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000253
254<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000255<DD> Tools for python developers. Contains <code>modulator</code>
256which builds skeleton C extension modules and <code>bgen</code> which
257generates complete interface modules from information in C header
258files. There are some readme files, but more documentation is sorely
259needed.
260
Jack Jansen8f2d8021996-08-05 15:34:45 +0000261</DL>
262
263All the mac-specific stuff lives in the <code>Mac</code> folder:
264<DL>
265
266<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000267<DD> Unix-compatability routines. Some of these are not used anymore,
268since CWGUSI provides a rather complete emulation, but you may need
269these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000270
271<DT> Demo
272<DD> Mac-specific demo programs, some of them annotated.
273
274<DT> Include
275<DD> Mac-specific but compiler-independent include files.
276
277<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000278<DD> Mac-specific standard modules. The <code>toolbox</code> folder
279contains modules specifically needed with various MacOS toolbox
280interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000281
282<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000283<DD> Mac-specific builtin modules. Theoretically these are all
284optional, but some are rather essential (like
285<code>macmodule</code>). A lot of these modules are generated with
286<code>bgen</code>, in which case the bgen input files are included so
287you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000288
289<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000290<DD> MPW-specific files. These have not been used or kept up-to-date
291for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000292
293<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000294<DD> Mwerks-specific sources and headers. Contains glue code for
295Pythons shared-library architecture, a replacement for
296<code>malloc</code> and a directory with various projects for building
297variations on the Python interpreter. The <code>mwerks_*.h</code>
298files here are the option-setting files for the various interpreters
299and such, comparable to the unix command-line <code>-D</code> options
300to the compiler. Each project uses the correct option file as its
301"prefix file" in the "C/C++ language" settings. Disabling optional
302modules (for the 68K interpreter), building non-GUSI interpreters and
303various other things are accomplished by modifying these files (and
304possibly changing the list of files included in the project window, of
305course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000306
307<DT> Python
308<DD> Mac-specific parts of the core interpreter.
309
310<DT> Resources
311<DD> Resource files needed to build the interpreter.
312
313<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000314<DD> A collection of various mac-specific Python scripts. Some are
315essential, some are useful but few are documented, so you will have to
316use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000317
318<DT> Unsupported
319<DD> Modules that are not supported any longer but may still work with a little effort.
320</DL>
321
322<H2>Building the 68K interpreter</H2>
323
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000324If you have all the optional libraries mentioned <A
325HREF="#optional">above</A> loaded buildin Python for 68K macs is a
326breeze: open the project in the folder <code>build.mac68k.stand</code>
327and build it. Do <em>not</em> run it yet, this will possibly result
328in a garbled preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000329
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000330First remove the <code>Python preferences</code> file from your
331preference folder, only if you had an older version of Python
332installed. (this is also what you do if you did not heed the last
333sentence of the preceeding paragraph). Next, move the interpreter to
334the main Python folder (up one level) and run it there. This will
335create a correct initial preferences file. You are now all set, and
336your tree should be completely compatible with a binary-only
337distribution. Read the release notes
338(<code>Relnotes-somethingorother</code>) and
339<code>ReadMeOrSuffer</code> in the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000340
Jack Jansen27b10ec1996-08-23 15:44:18 +0000341<H2>Building the CFM68K interpreter</H2>
342
343Building the CFM68K interpreter is as almost exactly the same as building
344the PPC interpreter, with the exception that you should read "CFM68K"
345for "PPC" every time. Continue reading with the next section.
346
Jack Jansen8f2d8021996-08-05 15:34:45 +0000347<H2>Building the PPC interpreter</H2>
348
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000349First you build the interpreter, core library and applet skeleton in
350folder <code>build.macppc.stand</code>. The order to build things is
351the following:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000352
353<DL>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000354<DT> MWRuntimeStaticLib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000355<DD> A modified version of the MetroWerks runtime library that is
356suitable for Pythons' shared library architecture. The sources all
357come from the MW distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000358
Jack Jansen27b10ec1996-08-23 15:44:18 +0000359<DT> PythonCorePPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000360<DD> The shared library that contains the bulk of the interpreter and
361its resources. It is a good idea to immedeately put an alias to this
362shared library in the <code>Extensions</code> folder of your system
363folder. Do exactly that: put an <em>alias</em> there, copying or
364moving the file will cause you grief later.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000365
366<DT> PythonPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000367<DD> The interpreter. This is basically a routine to call out to the
368shared library. Because of the organization of GUSI it also contains
369the Gusi settings resource (together with a ResEdit template, so you
370can change the gusi settings should you feel like doing so). Do
371<em>not</em> run it yet, this will possibly result in a garbled
372preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000373
374<DT> PythonApplet
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000375<DD> The applet skeleton application. Very similar to
376<code>PythonPPC</code>, but it calls to a different entrypoint in the
377core library. The <code>mkapplet</code> script will copy this complete
378file, and add a <code>'PYC '</code> with the module to generate an
379applet. <p>
380
Jack Jansen8f2d8021996-08-05 15:34:45 +0000381</DL>
382
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000383After creating the alias to <code>PythonCore</code> you should move
384<code>PythonPPC</code> to the main Python folder. Next you remove any
385old <code>Python Preferences</code> file from the
386<code>Preferences</code> folder (if you had python installed on your
387system before) and run the interpreter once to create the correct
388preferences file. You should also make an alias to
389<code>PythonApplet</code> in the main Python folder. (again: making an
390alias is preferrable to copying or moving the file, since this will
391cause the correct file to be used if you ever rebuild
392PythonApplet). <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000393
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000394Next, you have to build the extension modules in the
Jack Jansen27b10ec1996-08-23 15:44:18 +0000395<code>PlugIns</code> folder. Open each project with <code>.ppc</code> in the
396name and build it. After all
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000397the dynamically loaded modules are built you have to create a number
398of aliases: some modules live together in a single dynamic
Jack Jansen27b10ec1996-08-23 15:44:18 +0000399library. Run the <code>MkPluginAliases.py</code> script from
400<code>Mac:scripts</code> to create the aliases. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000401
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000402Finally, you must build the standard applets:
403<code>EditPythonPrefs</code>, <code>mkapplet</code>, etc. This is
404easiest done with the <code>fullbuild</code> script from
405<code>Mac:scripts</code>. Answer <em>no</em> to all questions except
406when it asks whether to build the applets. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000407
408<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000409Actually, the <code>fullbuild</code> script can be used to build
410everything, but you need a fully-functional interpreter before you can
411use it (and one that isn't rebuilt in the process: you cannot rebuild
412a running program). You could copy the 68K interpreter to a different
413place and use that to run fullbuild, or use the standalone PPC python
414for this. I tend to keep a standalone interpreter in a safe place for
415this use only.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000416</BLOCKQUOTE>
417
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000418You are all set now, and should read the release notes and
419<code>ReadMeOrSuffer</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000420
Jack Jansen27b10ec1996-08-23 15:44:18 +0000421<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
422
423Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
424file, a file that controls which symbols are exported by your PythonCore
425shared library. Rebuild it if you get unexpected undefined symbols when you
426are building a plugin module. <p>
427
428Rebuilding the .exp file is done by first removing the file and removing the
429reference to it in the project (in the "config" section). Next, build PythonCore.
430This will create a new .exp file. Edit this file to remove the references to
431the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
432<code>longjmp</code> and <code>__ptmf_null</code>. Next, add the .exp file to the project
433again and rebuild PythonCore. <p>
434
435This rather convoluted procedure is needed to ensure that plugin modules don't
436accidentally link with those entrypoints from PythonCore, which will not work because
437those routines have to be in the same code fragment as they are used from.
438
Jack Jansen8f2d8021996-08-05 15:34:45 +0000439<H2>Odds and ends</H2>
440
441Some remarks that I could not fit in elsewhere:
442
443<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000444
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000445<LI> It may be possible to use the <code>PythonCore</code> shared
446library to embed Python in another program, if your program can live
447with using GUSI for I/O. Use PythonCore in stead of your C library
448(or, at the very least, link it before the normal C library). Let me
449know whether this works.
450
451<LI> It is possible to build PPC extension modules without building a
452complete Python. Take the binary distribution, add folders
453<code>Include</code>, <code>Mac:Include</code> and
454<code>Mac:mwerks</code> from the source distribution and you should be
455all set. A template for a dynamic module can be found in
Jack Jansen27b10ec1996-08-23 15:44:18 +0000456<code>xx.ppc.µ</code> or <code>xx.CFM68K.µ</code>.
457
458<LI> The Python shared library architecture is a variant of the architecture
459described as "application with shared libraries and dropins" in the MetroWerks
460"Targeting MacOS" documentation. The Python Application and applet-template use
461the <code>AppRuntime.Lib</code> runtime library (with properly set CFM
462initialization and termination routines). PythonCore uses <code>ShlibRuntime.Lib</code>
463and <code>MWRuntimeStaticLib.Lib</code>, which is almost identical to the MW
464standard <code>MWRuntimeLib</code>, but not dynamically loaded. This library contains
465the part of the runtime that can (or must) be shared between all modules in the program.
466It is linked statically into PythonCore (and exported to the applications and plugins)
467so we do not have to distribute yet another shared library. Plugin modules use
468<code>ShlibRuntime.Lib</code> and obtain the rest from PythonCore. PythonCore uses a
469non-standard initialization entry point, <code>__initialize_with_resources</code>, to
470be able to obtain resources from the library file lateron. Plugins can do the same or
471use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000472
473
474<UL>
475</BODY>
476</HTML>