Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 1 | BUILDING PYTHON 1.2 FOR THE MACINTOSH |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 2 | ************************************* |
| 3 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 4 | Python can be built on the Mac using either THINK C 6.0 (or 7.0), MPW |
| 5 | 3.2, or CodeWarrior 5.0. In the past it has also been compiled with |
| 6 | earlier versions of Think and MPW, but no guarantees are made that the |
| 7 | source is still compatible with those versions. Think C 5.0 appears |
| 8 | to be OK. Likewise, new compiler versions may effectively change the |
| 9 | language accepted (or the library provided!) and thus cause problems. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 10 | |
| 11 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 12 | 1. Using Think C 6.0 (or 7.0) |
| 13 | ============================= |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 14 | |
| 15 | 1.1 The directory structure |
| 16 | --------------------------- |
| 17 | |
| 18 | I duplicate the UNIX directory structure from the distribution. The |
| 19 | subdirectories needed to compile are: Mac, Include, Parser, Python, |
| 20 | Objects, Modules. (Don't bother with Grammar and the parser |
| 21 | generator, nor with the Doc subdirectory.) |
| 22 | |
| 23 | For running and testing, you also need Lib and its subdirectories test |
| 24 | and stdwin. You could also copy some things from the Demo/stdwin |
| 25 | directory (unfortunately most other demos are UNIX specific and even |
| 26 | many stdwin demos are). |
| 27 | |
| 28 | Make sure there is no config.c file in the Modules subdirectory (if |
| 29 | you copy from a directory where you have done a UNIX build this might |
| 30 | occur). Also don't use the config.h generated on UNIX. |
| 31 | |
| 32 | 1.2 The project file |
| 33 | -------------------- |
| 34 | |
| 35 | I put all source files in one project, which I place in the parent |
| 36 | directory of the source directories. |
| 37 | |
| 38 | 1.2.1 Project type |
| 39 | |
| 40 | (This is the Set Project Type... dialog in the Project menu.) |
| 41 | |
| 42 | Set the creator to PYTH; turn on "far data"; leave "far code" and |
| 43 | "separate strs" unchecked (they just serve to bloat the application). |
| 44 | A partition size of 1000K should be enough to run the standard test |
| 45 | suite (which requires a lot of memory because it stress tests the |
| 46 | parser quite a bit) and most demos or medium-size applications. The |
| 47 | interpreter will do basic things in as little at 500K but this may |
| 48 | prevent parsing larger modules. |
| 49 | |
| 50 | 1.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 |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 67 | are always represented as longs). In fact, nowadays I always |
| 68 | use 4-byte integers, since it is actually rather annoying that |
| 69 | strings >= 64K cause crashes. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 70 | |
| 71 | 1.2.3 Files to add |
| 72 | |
| 73 | (This is the Add Files... dialog in the Source menu.) |
| 74 | |
| 75 | The following source files must be added to the project. I use a |
| 76 | separate segment for each begin letter -- this avoids segment |
| 77 | overflow, except for 'c', where you have to put either ceval.c or |
| 78 | compile.c in a separate segment. You could also group them by |
| 79 | subdirectory or function, but you may still have to split segments |
| 80 | arbitrarily because of the 32000 bytes restriction. |
| 81 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 82 | - From Mac: all .c files. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 83 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 84 | - From Parser: acceler.c, grammar1.c, |
Guido van Rossum | bc0ba01 | 1994-09-16 11:09:18 +0000 | [diff] [blame] | 85 | myreadline.c, node.c, parser.c, parsetok.c, tokenizer.c. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 86 | |
| 87 | - From Python: bltinmodule.c, ceval.c, cgensupport.c, |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 88 | compile.c, errors.c, getargs.c getopt.c, graminit.c, import.c, |
| 89 | importdl.c, marshal.c, modsupport.c, mystrtoul.c, |
| 90 | pythonmain.c, pythonrun.c, sigcheck.c, structmember.c, |
| 91 | sysmodule.c, traceback.c (i.e. all .c files except dup2.c, |
| 92 | fmod.c, frozenmain.c, getcwd.c, getmtime.c, memmove.c, |
| 93 | sigcheck.c, strerror.c, strtod.c, thread.c) |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 94 | |
| 95 | - From Objects: all .c files except xxobject.c. |
| 96 | |
| 97 | - From Modules: all the modules listed in config.c (in the Mac |
| 98 | subdirectory) in the initializer for inittab[], before |
| 99 | "ADDMODULE MARKER 2". Also add md5c.c if you add md5module.c, |
| 100 | and regexpr.c if you add regexmodule.c. (You'll find |
| 101 | macmodule.c in the Mac subdirectory, so it should already have |
| 102 | been added in a previous step.) Note that for most modules, |
| 103 | the source file is called <name>module.c, but for a few long |
Guido van Rossum | e783444 | 1994-08-26 09:09:48 +0000 | [diff] [blame] | 104 | module names it is just <module>.c. Don't add stdwinmodule.c |
| 105 | yet, |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 106 | |
| 107 | The following THINK C libraries must be added: from Standard |
| 108 | Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each |
| 109 | library in a separate segment. Also see my earlier remark on 4-byte |
| 110 | ints. |
| 111 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 112 | 1.4 Adding STDWIN |
| 113 | ----------------- |
| 114 | |
| 115 | STDWIN is built in two separate projects: stdwin.pi contains the core |
| 116 | STDWIN implementation from Ports/mac, textedit.pi contains the files |
| 117 | from Packs/textedit. Use the same compiler options as for Python and |
| 118 | the same general source setup (in a sister directory of the toplevel |
| 119 | Python directory). Put all sources in the same segment. To |
| 120 | stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. |
| 121 | |
Guido van Rossum | e783444 | 1994-08-26 09:09:48 +0000 | [diff] [blame] | 122 | The two projects can now be added as libraries to the Python project. |
| 123 | You must also add stdwinmodule.c and add "#define USE_STDWIN" to the |
| 124 | Prefix in the compiler options dialog (this only affects macmain.c and |
| 125 | config.c). |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 126 | |
| 127 | Note that stdwinmodule.c contains an #include statement that |
| 128 | references "stdwin.h" by relative path name -- if the stdwin toplevel |
| 129 | directory is not a sibling of the python toplevel directory, you may |
| 130 | have to adjust the number of colons in the pathname. |
| 131 | |
| 132 | 1.5 Resources |
| 133 | ------------- |
| 134 | |
| 135 | Since I created them with ResEdit I have no text source of the |
| 136 | resources needed to give the application an icon etc... You can copy |
| 137 | the size, bundle, file reference and icon resources from the |
| 138 | distributed Python application with ResEdit. THINK C automatically |
| 139 | copies resources into the application file from a file |
| 140 | <projectname>.rsrc. |
| 141 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 142 | 1.6 Think C 5.0 |
| 143 | --------------- |
| 144 | |
| 145 | Tim Gilbert adds one note that will be helpful to future Think C 5.0 |
| 146 | users: When you have a really big project like python, and you want to |
| 147 | compile and run it, if you just hit Command-R, often Think C will |
| 148 | compile the remaining files, think for a moment, and then give you a |
| 149 | warning "internal error(ZREF)--please remove objects." Don't listen |
| 150 | to it. It is lying. What you should do instead is "Check Link..." |
| 151 | and _then_ hit Run. Why? Ask Symantec. |
| 152 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 153 | |
Guido van Rossum | e783444 | 1994-08-26 09:09:48 +0000 | [diff] [blame] | 154 | 2. Using MPW 3.2 |
| 155 | ================ |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 156 | |
Guido van Rossum | e783444 | 1994-08-26 09:09:48 +0000 | [diff] [blame] | 157 | The subdirectory MPW contains a README.MPW file, a buildall script and |
Guido van Rossum | 8e1f8dd | 1994-08-29 09:14:14 +0000 | [diff] [blame] | 158 | several Makefiles, kindly contributed by Richard Walker of Island |
| 159 | Software. Move these files to the corresponding locations relative to |
| 160 | the Python root directory (where Mac-Makefile should become Makefile |
| 161 | in the Mac subdirectory, etc.), and run the buildall script. The |
| 162 | README.MPW file contains more instructions and caveats (I've added |
| 163 | some remarks of my own at the end). |
| 164 | |
| 165 | Some notes: |
| 166 | |
| 167 | - The MPW and THINK C ports share all source files, including config.c |
| 168 | and config.h -- all differentiation is done based on #ifdef THINK_C |
| 169 | or #ifdef MPW (#ifdef macintosh is used for code that should be seen |
| 170 | by all Mac compilers). |
| 171 | |
| 172 | - The dynload subdirectory contains an attempt to create dynamically |
| 173 | loadable modules from CODE segments. This was not very successful |
| 174 | due to the restrictions on CODE segments (no global variables, no |
| 175 | calls to external functions). Maybe Apple's new shared library |
| 176 | manager will be a better starting point. |
| 177 | |
| 178 | - I haven't tried building STDWIN with MPW recently. There is MPW |
| 179 | specific code all over the STDWIN source but it is for a much older |
| 180 | version of the compiler and library. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 181 | |
| 182 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame^] | 183 | 3. Using MicroWerks CodeWarrior 5.0 |
| 184 | =================================== |
| 185 | |
| 186 | Essentially, follow the instructions for Think C. |
| 187 | |
| 188 | XXX Should at least list the project options. |
| 189 | |
| 190 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 191 | --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> |
| 192 | <URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html> |