blob: ea9eab3125443c0b0b001eb3aa12e944b7d9cc27 [file] [log] [blame]
Guido van Rossumd849a481994-08-20 21:55:48 +00001BUILDING PYTHON 1.1 FOR THE MACINTOSH
2*************************************
3
Guido van Rossumbc0ba011994-09-16 11:09:18 +00004Python can be built on the Mac using either THINK C 6.0 (or 7.0) or
5MPW 3.2. In the past it has been compiled with earlier versions of
6these compilers, but no guarantees are made that the source is still
Guido van Rossumd849a481994-08-20 21:55:48 +00007compatible with those versions. Likewise, new compiler versions may
Guido van Rossume7834441994-08-26 09:09:48 +00008effectively change the language accepted (or the library provided!)
9and thus cause problems.
Guido van Rossumd849a481994-08-20 21:55:48 +000010
11
121. Using Think C 6.0
13====================
14
151.1 The directory structure
16---------------------------
17
18I duplicate the UNIX directory structure from the distribution. The
19subdirectories needed to compile are: Mac, Include, Parser, Python,
20Objects, Modules. (Don't bother with Grammar and the parser
21generator, nor with the Doc subdirectory.)
22
23For running and testing, you also need Lib and its subdirectories test
24and stdwin. You could also copy some things from the Demo/stdwin
25directory (unfortunately most other demos are UNIX specific and even
26many stdwin demos are).
27
28Make sure there is no config.c file in the Modules subdirectory (if
29you copy from a directory where you have done a UNIX build this might
30occur). Also don't use the config.h generated on UNIX.
31
321.2 The project file
33--------------------
34
35I put all source files in one project, which I place in the parent
36directory of the source directories.
37
381.2.1 Project type
39
40(This is the Set Project Type... dialog in the Project menu.)
41
42Set the creator to PYTH; turn on "far data"; leave "far code" and
43"separate strs" unchecked (they just serve to bloat the application).
44A partition size of 1000K should be enough to run the standard test
45suite (which requires a lot of memory because it stress tests the
46parser quite a bit) and most demos or medium-size applications. The
47interpreter will do basic things in as little at 500K but this may
48prevent parsing larger modules.
49
501.2.2 Compiler options
51
52(This is the Options -> THINK C ... dialog in the Edit menu.)
53
54 - Start with Factory Settings.
55
56 - In the Prefix, remove #include <MacHeaders> and add
57 #define HAVE_CONFIG_H
58
59 - Choose any optimizer and debugger settings you like. - You
60 can choose 4-byte ints if you want. This requires that you
61 rebuild the ANSI and unix libraries with 4-bytes ints as well
62 (better make copies with names like ANSI 32 bit). With 4-byte
63 ints the interpreter is marginally bigger and somewhat (~10%)
64 slower, but Python programs can use strings and lists with
65 more than 32000 items (with 2-byte ints these can cause
66 crashes). The range of Python integers is not affected (these
67 are always represented as longs).
68
691.2.3 Files to add
70
71(This is the Add Files... dialog in the Source menu.)
72
73The following source files must be added to the project. I use a
74separate segment for each begin letter -- this avoids segment
75overflow, except for 'c', where you have to put either ceval.c or
76compile.c in a separate segment. You could also group them by
77subdirectory or function, but you may still have to split segments
78arbitrarily because of the 32000 bytes restriction.
79
80 - From Mac: all .c files except fopenRF.c [[which shouldn't even
81 be there]].
82
Guido van Rossumbc0ba011994-09-16 11:09:18 +000083 - From Parser: acceler.c, grammar1.c, intrcheck.c,
84 myreadline.c, node.c, parser.c, parsetok.c, tokenizer.c.
Guido van Rossumd849a481994-08-20 21:55:48 +000085
86 - From Python: bltinmodule.c, ceval.c, cgensupport.c,
87 compile.c, errors.c, getopt.c, graminit.c, import.c,
88 marshal.c, modsupport.c, mystrtoul.c, pythonmain.c,
Guido van Rossumbc0ba011994-09-16 11:09:18 +000089 pythonrun.c, sigcheck.c, structmember.c, sysmodule.c,
90 traceback.c (i.e. all .c files except dup2.c, fmod.c,
91 frozenmain.c, getcwd.c, getmtime.c, memmove.c, sigcheck.c,
92 strerror.c, strtod.c, thread.c)
Guido van Rossumd849a481994-08-20 21:55:48 +000093
94 - From Objects: all .c files except xxobject.c.
95
96 - From Modules: all the modules listed in config.c (in the Mac
97 subdirectory) in the initializer for inittab[], before
98 "ADDMODULE MARKER 2". Also add md5c.c if you add md5module.c,
99 and regexpr.c if you add regexmodule.c. (You'll find
100 macmodule.c in the Mac subdirectory, so it should already have
101 been added in a previous step.) Note that for most modules,
102 the source file is called <name>module.c, but for a few long
Guido van Rossume7834441994-08-26 09:09:48 +0000103 module names it is just <module>.c. Don't add stdwinmodule.c
104 yet,
Guido van Rossumd849a481994-08-20 21:55:48 +0000105
106The following THINK C libraries must be added: from Standard
107Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
108library in a separate segment. Also see my earlier remark on 4-byte
109ints.
110
Guido van Rossumd849a481994-08-20 21:55:48 +00001111.4 Adding STDWIN
112-----------------
113
114STDWIN is built in two separate projects: stdwin.pi contains the core
115STDWIN implementation from Ports/mac, textedit.pi contains the files
116from Packs/textedit. Use the same compiler options as for Python and
117the same general source setup (in a sister directory of the toplevel
118Python directory). Put all sources in the same segment. To
119stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
120
Guido van Rossume7834441994-08-26 09:09:48 +0000121The two projects can now be added as libraries to the Python project.
122You must also add stdwinmodule.c and add "#define USE_STDWIN" to the
123Prefix in the compiler options dialog (this only affects macmain.c and
124config.c).
Guido van Rossumd849a481994-08-20 21:55:48 +0000125
126Note that stdwinmodule.c contains an #include statement that
127references "stdwin.h" by relative path name -- if the stdwin toplevel
128directory is not a sibling of the python toplevel directory, you may
129have to adjust the number of colons in the pathname.
130
1311.5 Resources
132-------------
133
134Since I created them with ResEdit I have no text source of the
135resources needed to give the application an icon etc... You can copy
136the size, bundle, file reference and icon resources from the
137distributed Python application with ResEdit. THINK C automatically
138copies resources into the application file from a file
139<projectname>.rsrc.
140
141
Guido van Rossume7834441994-08-26 09:09:48 +00001422. Using MPW 3.2
143================
Guido van Rossumd849a481994-08-20 21:55:48 +0000144
Guido van Rossume7834441994-08-26 09:09:48 +0000145The subdirectory MPW contains a README.MPW file, a buildall script and
Guido van Rossum8e1f8dd1994-08-29 09:14:14 +0000146several Makefiles, kindly contributed by Richard Walker of Island
147Software. Move these files to the corresponding locations relative to
148the Python root directory (where Mac-Makefile should become Makefile
149in the Mac subdirectory, etc.), and run the buildall script. The
150README.MPW file contains more instructions and caveats (I've added
151some remarks of my own at the end).
152
153Some notes:
154
155- The MPW and THINK C ports share all source files, including config.c
156 and config.h -- all differentiation is done based on #ifdef THINK_C
157 or #ifdef MPW (#ifdef macintosh is used for code that should be seen
158 by all Mac compilers).
159
160- The dynload subdirectory contains an attempt to create dynamically
161 loadable modules from CODE segments. This was not very successful
162 due to the restrictions on CODE segments (no global variables, no
163 calls to external functions). Maybe Apple's new shared library
164 manager will be a better starting point.
165
166- I haven't tried building STDWIN with MPW recently. There is MPW
167 specific code all over the STDWIN source but it is for a much older
168 version of the compiler and library.
Guido van Rossumd849a481994-08-20 21:55:48 +0000169
170
171--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
172<URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>