home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
tvos200.zip
/
TOOLS
/
README
< prev
next >
Wrap
Text File
|
1995-04-25
|
13KB
|
350 lines
MKLIB and TCM
-------------
These tools are used to build libraries (MKLIB) and .EXE files (TCM) from
simple project files. Both use a config file SAWTOOLS.INI, which must contain
entries describing each set of compiler and options.
Before using:
-------------
To use these tools, you must have the following environment variables set:
SET TMP= (somewhere)
SET USER= (a max. 8-letter code; fi. your initials).
SET PRJ= (your project directory, see below).
Directory structure:
--------------------
TCM and MKLIB make some assumptions about directory structures used when
developing multiple projects. I use a single directory, called PRJ, which
contains subdirectories for every project I'm currently handling. Shared
libraries, such as TVISION, have a subdirectory there too; this subdirectory
contains all that's needed to build the library or the project.
The PRJ directory MUST be referred to by the SET PRJ= statement. On my PC
it is
SET PRJ=D:\PRJ
When a project needs stuff from a shared library, I use the include syntax
#include <tvision/tv.h>
The include files for shared libraries are in the project directory for that
library, i.e. d:\prj\tvision.
TCM
---
Stands for Tcc Make. This file reads .ppp files; each line therein contains one
module that's used to make the program. The suffix of the file mentioned on
the line will determine what compiler will be called for the file. Each
suffix has a corresponding entry describing the compiler in the sawtools.ini
file.
TCM recognises auto-dependency information as generated by the Borland and
WatCOM compilers when it's present in the OBJ file. Dependencies are checked
if this info is present in the object file. A new version of TCM will
check the dependencies for the IBM C Set/2 compiler also.
How to use
----------
When your SAWTOOLS.INI file is correct (which must be made OK only once) then
using TCM is very easy. To compile a project you must first generate a .PPP
file for the project. This can be done very easily by using DIR like this:
dir *.cpp /b >tv.ppp
which will generate a file containing all .CPP files on a single line.
Then, if you need any libraries, you'll add them to the .PPP file by hand.
When this is done use the command
TCM tv
to compile your program. For every source file, it will check if the object
file exists. If not, the source will be recompiled. If the object does exist
but the source file is newer then it will be recompiled also. If the source
file's date hasn't changed then the object is opened to see if dependency
information is present. If so the info is read and every header file's date
is checked against the dependency information. If any header has changed date
then the source will be recompiled.
When all compiles have succeeded then the linker will be started to link
all modules together. The result should be a working .EXE file.
Defaults:
---------
You can start TCM without arguments to compile the last program you've compiled
in the current subdirectory. TCM leaves a TCM.DEF file in the directory which
contains the last .PPP file it has built.
By default, TCM compiles for the compiler specified in the SAWTOOLS.INI file.
You can override the compiler settings by using the -c:<id> option, which
compiles for the compiler specified. Make sure your environment is OK for
that compiler too!
Other options for TCM can be found by using TCM -?.
How it finds files
------------------
TCM finds the files in the .PPP file as follows:
1. In the current directory. If necessary it tries to add a .CPP or a .C
extension to the name.
2. When not found, it takes the PRJ environment variable and adds the path
found therein to the path specified. So, if an entry in the PPP file
was 'tvision\tview.cpp' and a SET PRJ=D:\PRJ was done then it will try
to find 'd:\prj\tvision\tview.cpp'. To allow this step, the PPP line
cannot start with a drive specifier OR a backslash (\); both denote an
absolute path.
3. If a suffix was specified on the line we search all paths specified
for the suffix in the 'def-search' options in the SAWTOOLS.INI.
4. If the entry was a .LIB file we do some extra processing:
4a. We create a path for the library that's the same as the path that MKLIB
would use to store the library. That is, depending on the 'def-libpath'
in the SAWTOOLS.INI file a pathname for the library is made. This may
include a changed file NAME for the library! When found this library
is used, as it was made by MKLIB.
This mechanism ensures that the correct library will be found for the
current set of compiler & options used.
4b. Then we create a path for the library using the PRJ envvar. First we
add the contents PRJ before the library name. If it exists the library
will be used with a warning message, because it is independent of the
compiler and model used.
4c. Next we create a path by using PRJ, then adding the platform name (OS2 or
DOS), and at last the library name. This allows proper inclusion of the
appropriate OS2 or DOS library.
4d. We give up.
The SAWTOOLS.INI must reside in the current directory (bah) or somewhere in
the path (Yes!).
Suffixes
--------
The following suffixes are recognised and treated by TCM:
.C Calls the ".C" entry from the SAWTOOLS.INI file to compile.
.CPP Calls the ".CPP" entry,
.ASM Calls the .ASM entry,
.LIB Uses special stuff to find the file; causes a relink when the
lib is newer than the .EXE file; is added as a lib to the linker.
.OBJ Is not compiled, is added to the linker as a .OBJ.
.DEF Added as a response file to the linker.
Examples
--------
An example VQ.PPP is below:
vqwin
infsrch
vinf
infdict
inffile
infbase
inftoc
infart
tocview
artview
tlscrol
arttxt
dynarr
cms
// Turbo Vision applets
tvutil\ascii
tvutil\calc
tvutil\calendar
tvutil\gadgets
tvutil\mousedlg
tvutil\fileview
tvision\tv.lib
cpl\cpl.lib
As you can see the // is used as a comment. The upper sources are found in
the current directory and end in .CPP; the tvutil\... files are found
in d:\prj\tvutil\, and my library (for WatCOM) is at d:\lib\os2\w32ol\cpl.lib.
For an example SAWTOOLS.INI see below.
MKLIB
-----
MKLIB is a companion to TCM. Instead of making .exe files it makes .lib files.
It uses a .BLD file which must contain directives on how the lib is made for
the several platforms. It uses the SAWTOOLS.INI file to find out about
compilers and lib managers.
MKLIB will try to retrieve sources for the library from the RCS path by calling
a program CO.EXE. You can prevent this by not using the RCSpath, or by using
the -NCHK option to MKLIB.
To build a library, for instance the Turbo Vision library, you need tv.bld in
the TV directory and the PRJ environment variable set. Then issue the command
MKLIB TV -NCHK
to create the library for the current compiler & platform.
MKLIB does NO dependency checking, EXCEPT the check to compare object dates
with source dates. No header inclusion is checked.
The SAWTOOLS.INI file.
----------------------
Both MKLIB and TCM use the SAWTOOLS.INI file to retrieve info about their
current environment and compilers. The first sawtools section you'll need is:
[mklib]
def-model = l $ Default memory model,
def-libpath = `d:\lib\%j\%c%m\%l` $ Path = d:\LIB\DOS\OL\VISTA.LIB
def-listpath = `%s\%c%m%l`
def-objpath = `d:\_obj\%j\%c%m\%l` $ Paths for objects: %c-> compilerletter, %l=libname, %m=modelletter.
def-EXEobjpath = `c:\%jX\%c%m` $ .EXE objects: %c-> compilerletter, %l=libname, %m=modelletter.
def-exepath = `c:\%jx` $ C:\OS2X or C:\DOSX
def-search = .lib : "d:\prj", `d:\lib\%j\%c%m\%l`
[mklib-os2]
def-compiler = w32o $ Default compiler is BC++/2
[mklib-dos]
def-compiler = w32d $ Default compiler is WatCOM 32 DOS
The [mklib] section describes stuff that's shared between platforms; the
sections [mklib-os2] and [mklib-dos] are read only when MKLIB runs on one of
these platforms.
The first statement is def-model = l. It specifies that by default MKLIB and
TCM will use the LARGE memory model. Other values can be F (flat), H (huge),
S (small).
def-libpath:
Specifies the path & name of the library output file. It contains % entries
which are replaced by MKLIB and TCM. The replacement for each % entry is
specified below. You use these to make sure that a borland C 3.1 large
model DOS library gets another pathname as a watcom 10.0a OS/2 flat model
library.
def-listpath:
Specifies the path of the .LST file generated by MKLIB. This version places
the list in the current directory.
def-objpath:
Specifies the path where .OBJ files are to be placed. Again, use % stuff
to make sure that objects for different compilers go to different
directories.
def-exeobjpath:
Used by TCM only to place objects generated by TCM; i.e. objects that
are generated to make an .EXE file. Usually different from the def-objpath
so that you can periodically clean it out.
def-exepath:
The path where TCM will place the .EXE file it generates. This version
places DOS exe files in C:\DOSX and OS/2 exe files in C:\OS2X.
def-search:
Specifies search paths depending on the suffix. When TCM or MKLIB needs a
file it will search the paths defined for the suffix of the file.
def-compiler:
defines the name of the compiler to use if no compiler is explicitly
specified on the TCM or MKLIB command line..
Path expansion characters:
%m - replaced by MODEL letter, i.e. H, L, M, F ed. as defined on the
command line or the def-model option.
%s - Replaced with output file name if applicable
%j - replaced with DOS or OS2 depending on MKLIB platform.
%c - replaced with compiler ident string, as defined by the libsuffix=
SAWTOOLS command.
%l - Replaced with LIB name (from .BLD file) or EXE name (from .ppp).
The rest of the SAWTOOLS.INI file contains compiler set entries. Each set entry
describes a set of compilers and options for a given platform. So you can have
a set for the Borland C++ 3.1 compiler under DOS, another set for the WatCOM
C++ compiler under OS2 etc.
An example compiler set entry is:
[mklib-b2]
libsuffix = r $ 1st letter of lib name specifies compiler
compiler = .c, bcc, "-sm -D__JAL__ -D__32BITS__ -w-sig %d -v -o%o -Od -N -r -k %s"
compiler = .cpp, bcc, "-sm -D__32BITS__ -D__JAL__ -D__BCP__ -d -N -w-sig %d -v -o%o -N -k -Od -r -Vo- %s"
compiler = .asm, tasm, "%s,%o/s/z/t/ml/p -D__FLAT__ /d__%m__ %d /iP:\ "
librarian = tlib, "/c /P128 @%r", "%l &\n", "+%o &\n", ",\n\n\n"
linker = tlink, "/v /B:0x10000 /c /Toe /ap @%s", "%o %a+\n", "%x\n", "NUL\n", "%l %a+\n", "%d\n", "\n\n\n"
def-search = .lib : "d:\l\b2\lib" "d:\prj\nw\2"
def-search = .obj : "d:\l\b2\lib"
def-module = c02.obj, c2mt.lib, os2.lib
The name of this compiler set is 'b2'. This name can be found in the section
name, [mklib-b2]. The def-compiler option, the -FOR command line option of
MKLIB and the -C: option of TCM all specify this name. When MKLIB is invoked
it will first read the [mklib] and [mklib-os2] sections. Then it will parse
command line parameters. After this it will know the compiler set to use, so
it reads [mklib-<setname>].
The parameters etc in a set definition are:
libsuffix:
Provides an "indentification" for stuff generated with this template. It
is used in the output path descriptors so that stuff generated by this
template will get it's own directory somewhere.
The value must be a string of 1..8 characters. Because it's used to
generate a filename use only stuff that is valid in a file name.
compiler:
Defines a compiler for a given suffix. The suffix is specified 1st as .cpp,
then the name of the compiler executable is specified (bcc) and last a
command line template is specified.
The command line template is expanded by TCM and MKLIB and should
result in a valid command line for the compiler. It can contain % stuff
also; the meaning for these is specified below.
librarian:
Contains a librarian template. Used to start the librarian and to generate
the LIB response file.
linker:
Contains a linker template. Used to start the linker and to generate
the LINKER's response file.
def-search:
See the entry for [mklib] above.
def-module:
Used by TCM only, this specifies what .OBJ and .LIB files must always be
included in the EXE. All .OBJ files mentioned herein will be linked FIRST,
all .LIB files mentioned herein will be linked LAST. In this example,
this ensures that the Borland C++ startup code will be included, and it
ensures that the Borland C++ runtime library is properly linked.