|
1 | | -From: [email protected] (Richard Walker) |
2 | | -Date: Wed, 1 Jun 94 15:28:40 PDT |
| 1 | +Python and MPW |
| 2 | +============== |
3 | 3 |
|
4 | | -Compiling Python Under MPW C |
5 | | -============================ |
| 4 | +There is conditional code in Python for MPW. This has been used with |
| 5 | +different compilers at various points in time. Right now it is being |
| 6 | +used to turn the entire interpreter into a shared library on 68K Macs, |
| 7 | +so we can build "applets". I have used MPW 3.2 and the OpenDoc |
| 8 | +development environment from an OpenDoc CD released in 1984. This |
| 9 | +contains the Symantec C compiler for MPW, version 7.XXX, the |
| 10 | +Universal Headers version 2.0a1 (XXX), and early versions of CFM-68K |
| 11 | +(the Code Fragment Manager ported back to the 68K Mac) and |
| 12 | +MixedModeInit, which are required to use shared libraries. |
6 | 13 |
|
7 | | -This directory contains the Makefiles, source files and scripts |
8 | | -required to compile Python under MPW C. |
| 14 | +I've created a Makefile that does everything, plus a three-line Build |
| 15 | +script that calls Make and runs its output. The Makefile assumes that |
| 16 | +it lives in a 1-deep subdirectory of the root, so e.g. the Python |
| 17 | +Include directory can be referenced through "::Include". All object |
| 18 | +files are collected in the subsubdirectory Objcode. |
9 | 19 |
|
10 | | -Compiling: |
11 | | ----------- |
12 | | -the "buildall" file at the top level is an MPW script |
13 | | -which rebuilds the entire Python source. |
| 20 | +I use these feature test macros: |
14 | 21 |
|
15 | | -To build, start the MPW Shell and select the Worksheet window. |
16 | | -Go to top level directory of the Python source tree. |
17 | | -Type: buildall<ENTER> |
| 22 | +MPW for all MPW compilers (e.g. long double in <math.h>) |
| 23 | +__SC__ for things specific to the Symantec C compiler |
| 24 | + (e.g. doesn't like static forward) |
| 25 | +__CFM68K__ for things specific to CFM-68K |
| 26 | + (e.g. it requires the use of #pragma lib_export on|off) |
| 27 | +HAVE_UNIVERSAL_HEADERS for things not yet in Think's headers (e.g. UPPs) |
| 28 | +GENERATINGCFM for both PPC and 68K Code Fragment Manager |
18 | 29 |
|
19 | | -To rebuild: |
20 | | -Type: buildall clean<ENTER> |
21 | | -Type: buildall<ENTER> |
| 30 | +MPW is defined in config.h (if it finds that applec is defined); |
| 31 | +HAVE_UNIVERSAL_HEADERS is defined in macglue.h depending on whether it |
| 32 | +thinks we are using Universal Headers. The others are defined by the |
| 33 | +compiler or by the system headers. |
22 | 34 |
|
23 | | -Configuration: |
24 | | --------------- |
25 | | -The files "Makefile", "config.h", "Mac:config.c" and |
26 | | -"Modules:Makefile" are normally configured and/or generated |
27 | | -automagically under Unix. |
| 35 | +Compiler switches were a nightmare until I found I had to use -b. |
| 36 | +This wasn't mentioned in the CFM-68K docs that came on the OpenDoc |
| 37 | +CD-ROM. |
28 | 38 |
|
29 | | -Macintosh programmers will have to be content with editing |
30 | | -these files manually to reflect their desired configuration. |
31 | | -The files provided here are examples only; Modules which |
32 | | -made it into this version are those which required little or |
33 | | -no modification. |
34 | 39 |
|
35 | | -Running: |
36 | | --------- |
37 | | -The top-level Makefile compiles Python as an MPW Tool. |
38 | | -You can then run Python interactively from within |
39 | | -the MPW Worksheet. |
| 40 | +Applets |
| 41 | +======= |
40 | 42 |
|
41 | | -Diagnostics: |
42 | | ------------- |
43 | | -If Python fails to run by aborting in file "Parser:grammar1.c", |
44 | | -at the end of the function "finddfa", line 46, |
45 | | -try defining the preprocessor symbol "MPW_881_BUG" in |
46 | | -file "Parser:acceler.c", function "fixstate", line 107. |
| 43 | +(XXX This text file is on my Mac) |
47 | 44 |
|
48 | | ---------------------------------------------------------------- |
49 | 45 |
|
50 | | -Additional notes by Guido for Python 1.1: |
51 | | ------------------------------------------ |
| 46 | +Warning: Mixing Think C and MPW |
| 47 | +=============================== |
52 | 48 |
|
53 | | -I have tried this with MPW 3.2 and tweaked Richards Makefiles and |
54 | | -buildall script slightly to work with Python 1.1. The same configure |
55 | | -file now works for THINK C 6.0 (or 7.0) and MPW 3.2. It is essential |
56 | | -that 'MPW' is defined when compiling with MPW; for both compilers, |
57 | | -'HAVE_CONFIG_H' should also be defined. For MPW, the buildall script |
58 | | -takes care of this. |
| 49 | +(XXX Need to check what convention SC uses -- I hope it uses Think's.) |
59 | 50 |
|
60 | | -I moved some files around or renamed them and modified the Makefiles |
61 | | -accordingly. All Mac specific files are now in the Mac subdirectory, |
62 | | -especially config.c, config.h, macmodule.c, and (new) macmain.c. |
63 | | - |
64 | | -I wouldn't bother with the Grammar subdirectory or the Parser |
65 | | -generator (Pgen) -- the needed Pgen output files are part of the |
66 | | -distribution. |
67 | | - |
68 | | -If the buildall script stops at a compilation error you are usually |
69 | | -left in one of the subordinate directories. |
70 | | - |
71 | | -Instead of using the buildall script you can also once execute the Set |
72 | | -and Export commands listed at its top (which set compiler and linker |
73 | | -options) and in each of the directories Mac, Parser, Python, Objects, |
74 | | -Modules and finally the python rot directory, execute the two command |
75 | | - |
76 | | - make >makefile.out |
77 | | - makefile.out |
78 | | - |
79 | | -Or you could execute |
80 | | - |
81 | | - make |
82 | | - |
83 | | -have a look at its output and execute selected commands from it. |
84 | | - |
85 | | -The buildall script executes |
86 | | - |
87 | | - Directory {Python} |
88 | | - |
89 | | -which normally prints the current directory, because {Python} is not |
90 | | -defined. If it is set to the python root directory, you could place |
91 | | -buildall somewhere in your command search path and execute it from |
92 | | -anywhere. |
93 | | - |
94 | | -If you are mixing THINK C and MPW, you may experience weird errors in |
| 51 | +If you are mixing Think C and MPW, you may experience weird errors in |
95 | 52 | previously correct modules. These disappear when you throw away the |
96 | 53 | module's .pyc file. The errors usually have to do with string |
97 | 54 | literals containing '\n' or '\r'. The reason is an incompatibility |
|
0 commit comments