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 | 1f5c600 | 1995-02-18 15:02:22 +0000 | [diff] [blame] | 4 | Python can be built on the Mac using either THINK C 6.0 (or 7.0), or |
| 5 | CodeWarrior 5.0 (for 68K and PPC). In the past it has also been compiled |
| 6 | with earlier versions of Think, 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 |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 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 | |
Guido van Rossum | 1f5c600 | 1995-02-18 15:02:22 +0000 | [diff] [blame] | 11 | MPW is a special case -- it used to be possible to build Python as |
| 12 | an MPW tool using MPW 3.2, and this may still work, but I haven't |
| 13 | tried this lately. What I have tried, however, is building Python |
| 14 | as a shared library for CFM-68K, using the Symantec C compiler for MPW. |
| 15 | See subdirectory MPW and the README file there for more info. |
| 16 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 17 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 18 | 1. Using Think C 6.0 (or 7.0) |
| 19 | ============================= |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 20 | |
| 21 | 1.1 The directory structure |
| 22 | --------------------------- |
| 23 | |
| 24 | I duplicate the UNIX directory structure from the distribution. The |
| 25 | subdirectories needed to compile are: Mac, Include, Parser, Python, |
| 26 | Objects, Modules. (Don't bother with Grammar and the parser |
| 27 | generator, nor with the Doc subdirectory.) |
| 28 | |
| 29 | For running and testing, you also need Lib and its subdirectories test |
| 30 | and stdwin. You could also copy some things from the Demo/stdwin |
| 31 | directory (unfortunately most other demos are UNIX specific and even |
| 32 | many stdwin demos are). |
| 33 | |
| 34 | Make sure there is no config.c file in the Modules subdirectory (if |
| 35 | you copy from a directory where you have done a UNIX build this might |
| 36 | occur). Also don't use the config.h generated on UNIX. |
| 37 | |
| 38 | 1.2 The project file |
| 39 | -------------------- |
| 40 | |
| 41 | I put all source files in one project, which I place in the parent |
| 42 | directory of the source directories. |
| 43 | |
| 44 | 1.2.1 Project type |
| 45 | |
| 46 | (This is the Set Project Type... dialog in the Project menu.) |
| 47 | |
| 48 | Set the creator to PYTH; turn on "far data"; leave "far code" and |
| 49 | "separate strs" unchecked (they just serve to bloat the application). |
| 50 | A partition size of 1000K should be enough to run the standard test |
| 51 | suite (which requires a lot of memory because it stress tests the |
| 52 | parser quite a bit) and most demos or medium-size applications. The |
| 53 | interpreter will do basic things in as little at 500K but this may |
| 54 | prevent parsing larger modules. |
| 55 | |
| 56 | 1.2.2 Compiler options |
| 57 | |
| 58 | (This is the Options -> THINK C ... dialog in the Edit menu.) |
| 59 | |
| 60 | - Start with Factory Settings. |
| 61 | |
| 62 | - In the Prefix, remove #include <MacHeaders> and add |
| 63 | #define HAVE_CONFIG_H |
| 64 | |
| 65 | - Choose any optimizer and debugger settings you like. - You |
| 66 | can choose 4-byte ints if you want. This requires that you |
| 67 | rebuild the ANSI and unix libraries with 4-bytes ints as well |
| 68 | (better make copies with names like ANSI 32 bit). With 4-byte |
| 69 | ints the interpreter is marginally bigger and somewhat (~10%) |
| 70 | slower, but Python programs can use strings and lists with |
| 71 | more than 32000 items (with 2-byte ints these can cause |
| 72 | crashes). The range of Python integers is not affected (these |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 73 | are always represented as longs). In fact, nowadays I always |
| 74 | use 4-byte integers, since it is actually rather annoying that |
| 75 | strings >= 64K cause crashes. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 76 | |
| 77 | 1.2.3 Files to add |
| 78 | |
| 79 | (This is the Add Files... dialog in the Source menu.) |
| 80 | |
| 81 | The following source files must be added to the project. I use a |
| 82 | separate segment for each begin letter -- this avoids segment |
| 83 | overflow, except for 'c', where you have to put either ceval.c or |
| 84 | compile.c in a separate segment. You could also group them by |
| 85 | subdirectory or function, but you may still have to split segments |
| 86 | arbitrarily because of the 32000 bytes restriction. |
| 87 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 88 | - From Mac: all .c files. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 89 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 90 | - From Parser: acceler.c, grammar1.c, |
Guido van Rossum | bc0ba01 | 1994-09-16 11:09:18 +0000 | [diff] [blame] | 91 | myreadline.c, node.c, parser.c, parsetok.c, tokenizer.c. |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 92 | |
| 93 | - From Python: bltinmodule.c, ceval.c, cgensupport.c, |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 94 | compile.c, errors.c, getargs.c getopt.c, graminit.c, import.c, |
| 95 | importdl.c, marshal.c, modsupport.c, mystrtoul.c, |
| 96 | pythonmain.c, pythonrun.c, sigcheck.c, structmember.c, |
| 97 | sysmodule.c, traceback.c (i.e. all .c files except dup2.c, |
| 98 | fmod.c, frozenmain.c, getcwd.c, getmtime.c, memmove.c, |
| 99 | sigcheck.c, strerror.c, strtod.c, thread.c) |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 100 | |
| 101 | - From Objects: all .c files except xxobject.c. |
| 102 | |
| 103 | - From Modules: all the modules listed in config.c (in the Mac |
| 104 | subdirectory) in the initializer for inittab[], before |
| 105 | "ADDMODULE MARKER 2". Also add md5c.c if you add md5module.c, |
| 106 | and regexpr.c if you add regexmodule.c. (You'll find |
| 107 | macmodule.c in the Mac subdirectory, so it should already have |
| 108 | been added in a previous step.) Note that for most modules, |
| 109 | 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] | 110 | module names it is just <module>.c. Don't add stdwinmodule.c |
| 111 | yet, |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 112 | |
| 113 | The following THINK C libraries must be added: from Standard |
| 114 | Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each |
| 115 | library in a separate segment. Also see my earlier remark on 4-byte |
| 116 | ints. |
| 117 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 118 | 1.4 Adding STDWIN |
| 119 | ----------------- |
| 120 | |
| 121 | STDWIN is built in two separate projects: stdwin.pi contains the core |
| 122 | STDWIN implementation from Ports/mac, textedit.pi contains the files |
| 123 | from Packs/textedit. Use the same compiler options as for Python and |
| 124 | the same general source setup (in a sister directory of the toplevel |
| 125 | Python directory). Put all sources in the same segment. To |
| 126 | stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. |
| 127 | |
Guido van Rossum | e783444 | 1994-08-26 09:09:48 +0000 | [diff] [blame] | 128 | The two projects can now be added as libraries to the Python project. |
| 129 | You must also add stdwinmodule.c and add "#define USE_STDWIN" to the |
| 130 | Prefix in the compiler options dialog (this only affects macmain.c and |
| 131 | config.c). |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 132 | |
| 133 | Note that stdwinmodule.c contains an #include statement that |
| 134 | references "stdwin.h" by relative path name -- if the stdwin toplevel |
| 135 | directory is not a sibling of the python toplevel directory, you may |
| 136 | have to adjust the number of colons in the pathname. |
| 137 | |
| 138 | 1.5 Resources |
| 139 | ------------- |
| 140 | |
| 141 | Since I created them with ResEdit I have no text source of the |
| 142 | resources needed to give the application an icon etc... You can copy |
| 143 | the size, bundle, file reference and icon resources from the |
| 144 | distributed Python application with ResEdit. THINK C automatically |
| 145 | copies resources into the application file from a file |
| 146 | <projectname>.rsrc. |
| 147 | |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 148 | 1.6 Think C 5.0 |
| 149 | --------------- |
| 150 | |
| 151 | Tim Gilbert adds one note that will be helpful to future Think C 5.0 |
| 152 | users: When you have a really big project like python, and you want to |
| 153 | compile and run it, if you just hit Command-R, often Think C will |
| 154 | compile the remaining files, think for a moment, and then give you a |
| 155 | warning "internal error(ZREF)--please remove objects." Don't listen |
| 156 | to it. It is lying. What you should do instead is "Check Link..." |
| 157 | and _then_ hit Run. Why? Ask Symantec. |
| 158 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 159 | |
Guido van Rossum | 1f5c600 | 1995-02-18 15:02:22 +0000 | [diff] [blame] | 160 | 2. Using MicroWerks CodeWarrior 5.0 |
Guido van Rossum | b95ff40 | 1995-02-13 16:15:31 +0000 | [diff] [blame] | 161 | =================================== |
| 162 | |
| 163 | Essentially, follow the instructions for Think C. |
| 164 | |
| 165 | XXX Should at least list the project options. |
| 166 | |
| 167 | |
Guido van Rossum | d849a48 | 1994-08-20 21:55:48 +0000 | [diff] [blame] | 168 | --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> |
| 169 | <URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html> |