Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 1 | Python and MPW |
| 2 | ============== |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 3 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 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. |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 13 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 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. |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 19 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 20 | I use these feature test macros: |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 21 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 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 |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 29 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 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. |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 34 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 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. |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 38 | |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 39 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 40 | Applets |
| 41 | ======= |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 42 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 43 | (XXX This text file is on my Mac) |
Guido van Rossum | 8ce65b4 | 1994-08-29 08:58:39 +0000 | [diff] [blame] | 44 | |
Guido van Rossum | c0af2aa | 1994-09-09 12:10:21 +0000 | [diff] [blame] | 45 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 46 | Warning: Mixing Think C and MPW |
| 47 | =============================== |
Guido van Rossum | c0af2aa | 1994-09-09 12:10:21 +0000 | [diff] [blame] | 48 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 49 | (XXX Need to check what convention SC uses -- I hope it uses Think's.) |
Guido van Rossum | c0af2aa | 1994-09-09 12:10:21 +0000 | [diff] [blame] | 50 | |
Guido van Rossum | 1b2fe8e | 1995-02-17 14:49:28 +0000 | [diff] [blame^] | 51 | If you are mixing Think C and MPW, you may experience weird errors in |
Guido van Rossum | 31e7642 | 1994-09-16 11:08:31 +0000 | [diff] [blame] | 52 | previously correct modules. These disappear when you throw away the |
Guido van Rossum | c0af2aa | 1994-09-09 12:10:21 +0000 | [diff] [blame] | 53 | module's .pyc file. The errors usually have to do with string |
| 54 | literals containing '\n' or '\r'. The reason is an incompatibility |
| 55 | between their handling of '\n' and '\r' -- in MPW C, '\n' actually is |
| 56 | ASCII CR while '\r' is ASCII LF, which is the reverse situation from |
| 57 | any other ASCII based C implementation. This behaviour is inherited |
Guido van Rossum | 31e7642 | 1994-09-16 11:08:31 +0000 | [diff] [blame] | 58 | by Python compiled with MPW C. This is normally not a problem, but |
| 59 | *binary* files written by one system will be mis-interpreted by the |
| 60 | other, and this is what happens to the .pyc files. There is no easy |
| 61 | way to fix this in the source. (This is a real shame, since the |
| 62 | format of .pyc files was carefully designed to be independent of byte |
| 63 | order and integer size -- deviations in the ASCII character codes were |
| 64 | never anticipated.) |