Building the Library

Jump to: navigation, search
<< Compile Time Macros
Creating a Kernel Interface >>



Instead of using make files to build the Treck TCP/IP library, we have put together simple batch files for a DOS build environment. These are designed to be easy to understand and design for compilers that we do not support yet. The other feature of using batch files for DOS is that they can be easily converted to shell scripts for the UNIX environment. It is best to think of the batch files as a three-tiered system for building your project.

Note Note: Before running any batch files to build the system, you should run the batch file "SETUP.BAT" located in the `treckbin` directory to setup the proper path to the Treck directories.


Tier 1: Compiler Primitives and Library Utility Primitives
Tier 2: Compiling All of the Treck Code
Tier 3: Automated Build System


Let's look at each of these tiers individually.


Tier 1: Compiler Primitives and Library Utility Primitives

Here you simply create a batch file (.BAT) that contains the compiler command line. The first parameter (%1) is the file to compile (without the .C extension). The second parameter is optional but is typically used for a #define that is passed to the compiler when building the Treck code.

An example of this is as follows:

File <bcl86cc.bat>

@echo off
if "%2"=="" goto noopt
bcc -v -ml -1 -c -w9999 -I%trhome%\include -D%2 %1.c > %1.err
goto end
:noopt
bcc -v -ml -1 -c -w9999 -I%trhome%\include %1.c > %1.err
:end

This file could have been as simple as this:

bcc -v -ml -1 -c -w9999 -I%trhome%\include %1.c > %1.err

That is all there is to the compile batch file, but we still need a library batch file. We do the same thing for the library utility. Notice that the library utility does not use the second parameter (%2) and the first parameter is the same as in the compile command line.

An example of this is as follows:

File <bc86lib.bat>

@echo off
tlib treck +%1.obj

An important thing to note is that our command line only adds a single object to the library.

You should place both of these files into the `treckbin` directory.

Now that you have completed these two tasks, you can build the Treck Library.

Tier 2: Compiling All of the Treck Code

The batch files that are used for this tier are called BUILD.BAT, and BUILDLIB.BAT. You do not need to modify these files (unless you are removing protocols from the build). These files can be called directly from the DOS command line like this.

C:\>build bcl86cc
Warning Warning: Your current directory MUST be the `source` directory in order to build the Treck objects.

Once the build completes (and it should without warnings or errors if your paths are set correctly), you are ready to create your library like this.

C:\>buildlib bc86lib

If you have done everything correctly to this point, you should have a library. If you get any compile errors, please make sure that they are not due to any changes to the <trsystem.h> file. If you still have errors (or warnings), please contact Technical Support.

Tier 3: Automated Build System

There is one final batch file that you can add/modify. It is the automation that builds the "C" code into objects and inserts the objects into a library. As you can imagine, it is fairly simple. It calls BUILD.BAT to compile first, then BUILDLIB.BAT to put the objects into a library. In our Tier 3 batch files, we have them pass an extra #define into the build so we don't have to modify <trsystem.h>. We also delete the library before we build to make sure that it is always a clean library. Because we support more than one compiler, the tier 3 batch files are a little more complex than you would design for your system.

An example of one of our build batch files is as follows:

File <ucosx86l.bat>

@echo off
if "%1"=="" goto usage
del treck.lib
call build %1l86cc TM_KERNEL_UCOS_X86
call buildlib %186lib
goto end
:usage
echo %0 builds Treck TCP/IP for the Intel x86 Real Mode Processor
echo running under uC/OS v1.1 (LARGE MODEL)
echo .
echo Usage:
echo %0 compiler
echo .
echo Compilers supported:
echo Microsoft "C" 6.0: MC
echo Borland "C" 5.0: BC
echo .
echo Example: %0 MC
:end

Your build batch file does not need to be nearly this complex. It can be as simple as:

@echo off
del TRECK.LIB
call build bcl86cc
call buildlib bc86lib

You then use this file to build the TCP/IP library to link with your application, kernel, and device driver. This way you do not need to call `build` and `buildlib` from the DOS command prompt.


<< Compile Time Macros
Creating a Kernel Interface >>