| 1 | <html> |
| 2 | |
| 3 | <title>Porting TADS 3</title> |
| 4 | |
| 5 | <h3>Porting TADS 3</h3> |
| 6 | |
| 7 | <p> |
| 8 | TADS 3 is designed for easy portability to a wide |
| 9 | variety of platforms. The source code is written in ANSI C++, and is |
| 10 | very conservative in its use of C++ languages features; the code does |
| 11 | not use templates, exceptions, or run-time type information, and limits |
| 12 | itself to the standard C run-time library. |
| 13 | |
| 14 | <h4>A Note on Newlines</h4> |
| 15 | |
| 16 | <p>Different operating systems have a tendency to disagree on the |
| 17 | most trivial details. One of these pointless variations that causes |
| 18 | a lot of trouble is "newline" conventions: each OS has its own way of |
| 19 | signaling the end of a line of text in files such as C source and |
| 20 | header files. In almost every case, the end of a line of text is |
| 21 | indicated by some combination of the special characters with ASCII |
| 22 | values 10 and 13, known respectively as "line feed" or "LF", and |
| 23 | "carriage return" or "CR". MS-DOS uses the sequence CR-LF; Unix uses |
| 24 | just LF; Macintosh uses just CR; and some system somewhere probably |
| 25 | uses LF-CR. |
| 26 | |
| 27 | <p>In many cases, systems are tolerant of "foreign" conventions, but |
| 28 | sometimes the wrong conventions will confuse compilers and other |
| 29 | tools. If you run into any mysterious compiler errors, or your text |
| 30 | editor or other tools have problems reading or displaying the TADS |
| 31 | source files, you might want to try converting the files to your |
| 32 | system's newline conventions. One of the easiest ways to do this is |
| 33 | usually to use your UNZIP tool's "auto-convert text files" option |
| 34 | when you unpack the TADS source archive - on command-line systems, |
| 35 | this is usually the "unzip -a" option. |
| 36 | |
| 37 | |
| 38 | <h4>Portable and OS Layer Code</h4> |
| 39 | |
| 40 | <p> The TADS 3 source code uses the same technique to separate code |
| 41 | into portable and OS layers that TADS 2 used. All of the code in the |
| 42 | TADS 3 source distribution is portable, except for the files in |
| 43 | system-specific subdirectories (such as "win32"). You should be able |
| 44 | to use all of the portable code without making any changes to it. |
| 45 | Any required changes in the portable code are porting exceptions; you |
| 46 | should report them back to me so that I can find a way to merge the |
| 47 | changes to correct the problem. There should be no platform-specific |
| 48 | #if's or #ifdef's in the portable code - the source in the portable |
| 49 | files should be 100% common to all platforms. |
| 50 | |
| 51 | <h4>OS Layer Implementation</h4> |
| 52 | |
| 53 | <p> TADS 3 uses the identical OS interface layer that TADS 2 used. |
| 54 | So, the first thing you need to do to port TADS 3 to a new platform |
| 55 | is to obtain the TADS 2 OS interface implementation for that |
| 56 | platform. TADS 2 has been widely ported, so there is a good chance |
| 57 | that you can use an existing OS layer implementation for your |
| 58 | platform. If you're porting to a platform that doesn't have a TADS 2 |
| 59 | port, you must create your own TADS 2 OS interface implementation for |
| 60 | the platform. Please obtain a copy of the TADS 2 source distribution |
| 61 | for full details on how to go about this. |
| 62 | |
| 63 | <p> TADS 3 is designed to share the same object files from the TADS 2 |
| 64 | OS layer, so you will not need to create a new copy of the OS files. |
| 65 | You should instead simply set up your new TADS 3 makefile so that it |
| 66 | includes headers from your TADS 2 OS include directory, and links in |
| 67 | the "osxxx" object files from your TADS 2 object file directory. |
| 68 | |
| 69 | <h4>Creating a Makefile</h4> |
| 70 | |
| 71 | <p> |
| 72 | Refer to win32/makefile.vc5 in the source distribution for an example |
| 73 | makefile. This makefile is set up for Microsoft Visual C++ on Windows |
| 74 | (it'll work on VC++ versions 5 and 6, at least). This is <i>not</i> |
| 75 | any kind of scary project file or other machine-generated monstronsity; |
| 76 | it's simply a makefile, similar to Unix-style makefiles. The "vc5" |
| 77 | extension, by the way, is just my own naming convention to indicate |
| 78 | that it's the Visual C++ version of the makefile. |
| 79 | |
| 80 | <p> The Windows makefile defines the groups of object files that make |
| 81 | up the various executables. In most cases, you will want to |
| 82 | configure your own executables in roughly the same way; the only |
| 83 | differences should be that you must substitute your OS layer |
| 84 | implementation files for the Windows versions - these are the files |
| 85 | whose names start with "os". |
| 86 | |
| 87 | <p> Makefiles are pretty nasty to read, so I'll provide some pointers on |
| 88 | what to look for. The first piece of information you want from the makefile |
| 89 | is simply the group of object files that make up each executable. This |
| 90 | much is pretty easy to read - look for names of executables followed |
| 91 | immediately by a colon - search for "t3make.exe:", for example, to find |
| 92 | the compiler executable's build rule. Following this is a long list of |
| 93 | object files. These are the object files that make up the executable. |
| 94 | All of the object files prefixed with "$(OBJDIR)" are portable |
| 95 | executables. The ones prefixed by "$(TADS2OBJDIR)" are the TADS 2 OS |
| 96 | layer object files - these are not part of the TADS 3 source distribution |
| 97 | because you can get them from the TADS 2 distribution. The object file |
| 98 | list ends at the line that starts with "$(LD) $(LDFLAGS)" - this line |
| 99 | starts the command specification for the "link" command that builds the |
| 100 | executable. |
| 101 | |
| 102 | <p>Many of the executables listed in the makefile are for testing |
| 103 | purposes only. You don't need to build these (but you certainly can |
| 104 | if you want to run some more in-depth testing on your port). |
| 105 | |
| 106 | <p>The source file dependencies are mostly straightforward - these |
| 107 | follow the executable rules. However, a few source files have special |
| 108 | compilation rules - look at the end of the source-to-object dependency |
| 109 | rules for the rules that have explicit "$(CC)" command lines listed |
| 110 | under the dependencies. For example, the object module "vmrun_d.obj" |
| 111 | is compiled from "vmrun.cpp" with a special compile command (the command |
| 112 | sets the #define symbol VM_DEBUGGER). |
| 113 | |
| 114 | |
| 115 | </html> |