[Top] [Prev] [TOC] [Next] [Bottom]

Porting the TargetRTS


The most common customization to the TargetRTS is porting it to a new platform. A platform is defined by the TargetRTS as the combination of the operating system, target hardware and the compiler/linker tool chain. A new operating system requires the most work since it often requires implementation changes. However, a new compiler may also require changes, in particular, to the configuration files.

The ports supported by ObjecTime Ltd. and shipped with the TargetRTS source are a good place to begin considering design alternatives for a new port. The root directory for the TargetRTS source will be referred to from this point forward using the environment variable RTS_HOME. It is usually a subdirectory of $OBJECTIME_HOME ($OBJECTIME_HOME/C++/TargetRTS or $OBJECTIME_HOME/C/TargetRTS). In the sections that follow, examples are extracted from this source.

Phases of a port

The major steps for implementing the port are as follows:

Choose a platform name

The first step in implementing a port is picking the name for the platform. This name and parts of it are used by the various loadbuild tools to find the files needed to build the TargetRTS for that platform. It is also used during compilation of the ObjecTime models. There are two parts to the name: target and libset. The resulting names for TargetRTS configurations are defined as combinations of the target and libset names in the following pattern:

<platform> ::= <target>.<libset>

Examples are given in Table 3
Example platform names used by the TargetRTS

Name


Description


SUN4S.sparc-gnu-2.7.1


SunOS 4.x SingleThreaded on a Sparc processor

using Free Software Foundation gnu version 2.7.1


SUN5T.sparc-gnu-2.7.1


Solaris 2.x MultiThreaded on a Sparc processor

using Free Software Foundation gnu version 2.7.1


SUN5S.sparc-SunC++-4.2


Solaris 2.x SingleThreaded on a Sparc processor

using Sun Microsystems SPARCUtils C++ version 4.2


HPUX09S.hppa-HPC++-3.76


HPUX 9.x SingleThreaded on an HPPA processor

using Hewlett Packard HPC++ version 3.76


PSOS2T.m68040-Green-1.8.7B


pSOS 2.x MultiThreaded on a Motorola 68040 processor

using GreenHills C++ version 1.8.7B

.

Target name

The target name presents the implementation-specific components of the TargetRTS. These components are generally specific to a given configuration, of a given version, of a given operating system. The target name is also used to name the configuration of the target, for example, single versus multi-threaded. The target name is defined as follows:

<target> ::= <OS name><OS version><RTS config>

For example: SUN5T. The components of <target> are defined as follows:

Libset name

Although the actual libset names can be chosen arbitrarily, by convention those defined by ObjecTime are defined as follows:

<libset> ::= <processor>-<compiler name>-<compiler version>

For example: sparc-gnu-2.7.1. The components of <libset> are defined as follows:

Create a setup script

The setup script is a file (setup.pl) containing Perl commands that set up the environment for the compilation of the TargetRTS to the platform. This file is contained in the $(RTS_HOME)/config/<target>.<libset> directory. If the target tool chain environment variables are part of a user's standard environment, then the variables in the setup.pl file may not be necessary. These environment variables defined in the setup.pl file are not available when using the toolset to build user models.

The commands in the setup.pl file are executed before any of the compilation tools are invoked. Typically, definitions for locations of files on the host platform are included in this file. This usually includes setting the shell environment variable PATH to point to the appropriate tools. Two variables must be defined for all targets, namely the preprocessor variable and the supported variable. The preprocessor variable defines the C++ preprocessor command appropriate for the compilation environment. The preprocessor command is used to automatically generate source code dependencies for the TargetRTS. The supported variable defines whether this target is supported by ObjecTime Limited. Valid values for supported are `Yes' and `No'. Another variable to note is target_base. This variable indicates that the implementation of the target-specific features of the TargetRTS are rooted in the same source directory as the target_base target. For example, for the VRTX4T target, the target_base is set to `VRTX3'. Therefore, VRTX4 specific implementations of TargetRTS classes are found in the same source directory as those of the VRTX3 target, that is, $(RTS_HOME)/src/target/VRTX3.

The example file, $(RTS_HOME)/config/VRTX4T.ppc603-Microtec-1.4/setup.pl, includes

$os = $ENV{'OS'};
$os = 'default' unless defined( $os );
if( $os eq 'Windows_NT' )
{
$usr_mri = $ENV{'USR_MRI'};
$ENV{'PATH'} = "$usr_mri/bin;$ENV{'PATH'}";
}
else
{
$usr_mri =
"$ENV{'OS_HOME'}/spectra/solaris-ppc603-4.AB";
$ENV{'USR_MRI'} = "$usr_mri";
$ENV{'SPECTRA'} = "$usr_mri/spappc";
$ENV{'MRI_PPC_BIN'} = "$usr_mri/bin";
$ENV{'MRI_PPC_LIB'} = "$usr_mri/lib";
$ENV{'MRI_PPC_INC'} = "$usr_mri/include/mccppc";
$ENV{'PATH'} = "$usr_mri/bin:$ENV{'PATH'}";
}
$preprocessor = "cccppc -E >MANIFEST.i";
$include_opt = '-J';
$target_base = 'VRTX3';
$supported = 'Yes';

Note: The setup file is not used when compiling generated updates. The environment variables defined in the setup file must instead be defined in the user's environment before executing the ObjecTime toolset. In the given example, the setup file assumes that the user's environment has the variables USR_MRI and OS_HOME already defined. This is platform-specific.

TargetRTS makefiles

Two types of builds are supported by the makefiles for the TargetRTS: compilation of the TargetRTS libraries and compilation of the generated code. The platform-specific definitions are required by both and are thus placed in separate files. The sequencing of the makefiles for the two paths are shown in Figure 2, "Sequencing of Makefiles," on page 35.

Sequencing of Makefiles

As shown, there is a makefile for each of the following:

TargetRTS makefiles

The $RTS_HOME/src/Makefile contains a default target that invokes a Perl script called Build.pl. This script checks the dependencies for the TargetRTS source code and generates a makefile called depend.mk in the $(RTS_HOME)/build-<target>.<libset> directory. It then builds the TargetRTS from this directory.

Default makefile

The target, libset, and config makefiles are expected to override defaults defined in $RTS_HOME/libset/default.mk. The defaults are as follows:

CONFIG = $(TARGET).$(LIBRARY_SET)
# Defaults for macros which may be modified by
# libset/$(LIBRARY_SET)/libset.mk
# target/$(TARGET)/target.mk
# or config/$(CONFIG)/config.mk
FEEDBACK = $(PERL) "$(RTS_HOME)/tools/feedback.pl"
NOP = $(PERL) "$(RTS_HOME)/tools/nop.pl"
PERL = perl
PRELINK = ld -r -o
RM = $(PERL) "$(RTS_HOME)/tools/rm.pl"
RMF = $(RM) -f
TOUCH = $(PERL) "$(RTS_HOME)/tools/touch.pl"
# default pre-compile command, can be modified by libset.mk
PRECC = $(NOP)
# Macros used when creating an object file from a C++ source file
CC = $(FEEDBACK) -fail \
CC should be defined by libset.mk or generated makefile
DEBUG_TAG = -g
DEFINE_TAG = -D
INCLUDE_TAG = -I
LIBSETCCEXTRA =
LIBSETCCFLAGS =
OBJECT_OPT = -c
OBJOUT_OPT = -o
OBJOUT_TAG =
SHLIBCCFLAGS = -PIC
SOURCE_TAG =
TARGETCCFLAGS =
# Macros used when creating an object library from a set of object files
AR_CMD = $(PERL) "$(RTS_HOME)/tools/ar.pl"
LIBOUT_OPT =
LIBOUT_TAG =
RANLIB = $(NOP)
# Macros used when creating an shared library from a set of object files
SHLIB_CMD = $(FEEDBACK) -fail Shared libraries not supported.
SHLIBOUT_OPT = -o
SHLIBOUT_TAG =
# Macros used when creating an executable from a set of object files, libraries
LD = $(CC)
DIR_TAG = -L
LIBSETLDFLAGS =
LIB_TAG = -l
OT_LIB_TAG = -l
TARGETLDFLAGS =
TARGETLIBS =
EXEOUT_OPT = -o
EXEOUT_TAG =
# Macros used to construct names of various kinds of files
EXEC_EXT =
LIB_PFX = lib
LIB_EXT = .a
CPP_EXT = .cc
OBJ_EXT = .o
SHLIB_PFX = lib
SHLIB_EXT = .so
#
RTS_LIBRARY = $(RTS_HOME)/lib/$(CONFIG)
EXTERNAL_LIBS = $(DIR_TAG)"$(RTS_LIBRARY)" \
$(OT_LIB_TAG)ObjecTimeTransport \
$(OT_LIB_TAG)ObjecTimeTypes
SYSTEM_LIBS = $(DIR_TAG)"$(RTS_LIBRARY)" \
$(OT_LIB_TAG)ObjecTime \
$(OT_LIB_TAG)ObjecTimeTransport \
$(OT_LIB_TAG)ObjecTimeTypes
SYSTEM_DIRECTORY = $(LOCAL_DIRECTORY)/$(UPDATE)/C++/system
SYSTEM_DEPENDENCY = $(SYSTEM_DIRECTORY)/RTSystem.h \
$(SYSTEM_DIRECTORY)/initData.h
ALL_ACTORS_LIST = $(ALL_ACTORS)

Target makefile

The $RTS_HOME/target/<target>/target.mk makefile provides definitions specific to the operating system and TargetRTS configuration. The definitions in this makefile override the defaults in $(RTS_HOME)/target/common.mk. An example target makefile template file, RTS_HOME/target/SUN5T/target.mk, is as follows:

# Define the _REENTRANT macro to enforce thread safety
TARGETCCFLAGS = $(DEFINE_TAG)_REENTRANT
# Add in the nsl and socket libraries and to pass on the RTS
# library directory to the run-time linker
TARGETLDFLAGS = $(LIB_TAG)nsl $(LIB_TAG)socket -R$(RTS_LIBRARY)
# Add in the posix4 and thread libraries
TARGETLIBS = $(LIB_TAG)posix4 $(LIB_TAG)thread

Libset makefile

The $RTS_HOME/libset/<libset>/libset.mk makefile provides definitions specific to the compiler. The definitions in this makefile override the defaults in $(RTS_HOME)/target/default.mk. An example libset makefile template file, $RTS_HOME/libset/sparc-gnu-2.7.1/libset.mk, is as follows:

# C++ compiler name and common arguments
CC = g++ -V2.7.1
# Command to make shared libraries
SHLIB_CMD = $(CC) -shared -z text -o
# Use pragmas to specify interface and implementation
LIBSETCCFLAGS = -DPRAGMA
# More c++ flags to turn on optimization, specify processor version
# and tune warnings
LIBSETCCEXTRA = -O4 -finline -finline-functions \
-mv8 -Wall -Winline -Wwrite-strings
# C compiler flags for building shared libraries
SHLIBCCFLAGS = -fPIC
# If SHLIBS is set to nothing,shared libraries will not be built
SHLIBS =

Config makefile

The $RTS_HOME/config/<target>.<libset>/config.mk makefile provides definitions specific to the combination of the operating system, TargetRTS configuration, and the compiler. This makefile is empty for most target/libset combinations. Usually this file will only be needed to work around problems that may not appear in either the target or libset alone. In the C++ TargetRTS, an example use of this file is as follows:

$RTS_HOME/config/VRTX4T.ppc603-Microtec-1.3C/config.mk:

EXEC_EXT = .x
TARGETLIBS = $(USR_MRI)/lib/cppcb.lib

Table 4 defines which make macros can be redefined and where they are set.


TARGET


Defined in RTUpdate.mk as "$(PLATFORM)$(THREADED)"


Redefinition not recommended.


CONFIG


Defined in default.mk as
"$(TARGET).$(LIBRARY)"


Redefinition not recommended.


OTCODEGEN_HOME


Defined in default.mk.


Redefinition not recommended.


VENDOR


Defined in default.mk as "generic" and intended to be overridden in libset.mk.


During porting, this may be left as "generic". However, you should provide an error-parser script eventually. Since error formats are typically vendor-specific (independent of the version of the compiler or of the compilation host-type), scripts are identified by the vendor's name in libset.mk.


OTCOMPILE


Defined in default.mk.


Redefinition not recommended.


OTLINK


Defined in default.mk.


Redefinition not recommended.


FEEDBACK


Defined in default.mk.


Redefinition not recommended.


MERGE


Defined in default.mk.


Redefinition not recommended.


NOP


Defined in default.mk.


Redefinition from Perl scripts to (faster) OS-dependent commands is possible.


PERL


Defined in default.mk as "perl"


Some compilation hosts may require an explicit path; if necessary, redefine in libset.mk or config.mk.


RM


Defined in default.mk.


Redefinition from Perl scripts to (faster) OS-dependent commands is possible.


RMF


Defined in default.mk.


Redefinition from Perl scripts to (faster) OS-dependent commands is possible.


TOUCH


Defined in default.mk.


Redefinition from Perl scripts to (faster) OS-dependent commands is possible.


PRECC


Defined in default.mk.



MAKEFILE


Defined in default.mk.



CC


Defined in default.mk to cause compile-time error, must be redefined in libset.mk.


Must be redefined in libset.mk before porting.


DEBUG_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


DEFINE_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


INCLUDE_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


LIBSETCCEXTRA


Default defined in default.mk.


Add compiler-specific compilation flags in libset.mk, if necessary.


LIBSETCCFLAGS


Default defined in default.mk.


Add compiler-specific compilation flags in libset.mk, if necessary.


OBJECT_OPT


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


OBJOUT_OPT


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


OBJOUT_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


SHLIBCCFLAGS


Default defined in default.mk.



SOURCE_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler.


TARGETCCFLAGS


Default defined in default.mk.


Add target-specific compilation flags in target.mk, if necessary.


AR_CMD


Default defined in default.mk.



LIBOUT_OPT


Default defined in default.mk.



LIBOUT_TAG


Default defined in default.mk.



RANLIB


Default defined in default.mk.



SHLIB_CMD


Default defined in default.mk.



SHLIBOUT_OPT


Default defined in default.mk.



SHLIBOUT_TAG


Default defined in default.mk.



LD


Default defined in default.mk.


Redefine in libset.mk if linker must be different from compiler (most compilers can invoke the linker anyhow), or if a preprocessing script is necessary.


DIR_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


LIBSETLDFLAGS


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


LIB_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


OT_LIB_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


TARGETLDFLAGS


Default defined in default.mk.



TARGETLIBS


Default defined in default.mk.



EXEOUT_OPT


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


EXEOUT_TAG


Default defined in default.mk.


Redefine in libset.mk if necessary for a linker.


EXEC_EXT


Default defined in default.mk.


Redefine in target.mk or libset.mk if necessary.


LIB_PFX


Default defined in default.mk.



LIB_EXT


Default defined in default.mk.



CPP_EXT


Default defined in default.mk.



OBJ_EXT


Default defined in default.mk.


Redefine in libset.mk if necessary for a compiler/linker.


SHLIB_PFX


Default defined in default.mk.



SHLIB_EXT


Default defined in default.mk.



RTSYSTEM_INCPATHS


Defined in default.mk.


Redefinition not recommended.


RTS_LIBRARY


Defined in default.mk.


Redefinition not recommended.


EXTERNAL_LIBS


Defined in default.mk.


Redefinition not recommended.


SYSTEM_LIBS


Defined in default.mk.


Redefinition not recommended.


OTLINK_CMD


Defined in default.mk.


Redefine to "" while Perl is not available on the compilation host.


LD_HEAD


Default defined in default.mk.


May be used to redefine link command if necessary.


ALL_OBJS_LIST


Default defined in default.mk as the concatenation of all object files in the update.


Redefine to "%$(ALL_OBJS_LISTFILE)" to pass list of object files to linker (or linker script), if line length limitations forbid passing list via shell.


LD_TAIL


Default defined in default.mk.


May be used to redefine link command if necessary.


OTCOMPILE_OPTS


Defined in default.mk.


Redefinition not recommended.


OTCOMPILE_CMD


Defined in default.mk.


Redefine to "" while Perl is not available on the compilation host.


CC_HEAD


Default defined in default.mk.


May be used to redefine compile command if necessary.


CC_TAIL


Default defined in default.mk.


May be used to redefine compile command if necessary.


MAKEDEPEND_CMD


Defined in default.mk.


Redefine to "echo makedepend" while Perl is not available on the compilation host.


MAKEDEPEND_HEAD


Defined in default.mk.


May be redefined to add RTSYSTEM_INCPATHS to updates' dependency discovery. It likely only makes sense to do this when porting requires changes to RTS include files.


USER_CC


From toolset, defined in RTUpdate_Compile.mk


Redefinition not recommended.

Make macro definitions


[Top] [Prev] [TOC] [Next] [Bottom]

support@objectime.com
Copyright © 1998, ObjecTime Limited. All rights reserved.