A.2   Building Applications

The Tornado 2.0 project facility is correctly preconfigured for building WRS BSPs. However, if you choose not to use the project facility or if you need to customize your build, you may need the information in the following sections. This includes a configuration constant, an environment variable, and compiler options that together specify the information the GNU toolkit requires to compile correctly for MC680x0 targets.

Defining the CPU Type

Setting the preprocessor variable CPU ensures that VxWorks and your applications build with the appropriate architecture-specific features enabled. Define this variable to one of the following values, to match the processor you are using:

For example, to define CPU for a MC68040 on the compiler command line, specify the following command-line option when you invoke the compiler:

-DCPU=MC68040

To provide the same information in a header or source file instead, include the following line in the file:

#define CPU MC68040

Configuring the GNU ToolKit Environment

Tornado includes the GNU compiler and associated tools. Tornado is configured to use these tools by default. No change is required to the execution path, because the compilation chain is installed in the same bin directory as the other Tornado executables.

Compiling C or C++ Modules

The following is an example of a compiler command line for MC680x0 cross-development. The file to be compiled in this example has a base name of applic.

% cc68k -DCPU=MC68040 -I $WIND_BASE/target/h -fno-builtin \ 
-O -nostdinc -c applic.language_id

The options shown in the example have the following meanings:1

-DCPU=MC68040
Required; defines the CPU type. If you are using another MC680x0 processor, specify the appropriate value (see Defining the CPU Type).

-I $WIND_BASE/target/h
Required; includes VxWorks header files. (Additional -I flags may be included to specify other header files.)

-fno-builtin
Required; uses library calls even for common library subroutines.

-O
Optional; performs standard optimization.

-nostdinc
Required; searches only the directory specified with the -I flag (see above) and the current directory for header files. Does not search host-system include files.

-c
Required; specifies that the module is to be compiled only, and not linked for execution under the host.

applic.language_id
Required; the file(s) to compile. For C compilation, specify a suffix of .c. For C++ compilation, specify a suffix of .cpp. The output is an unlinked object module in a.out format with the suffix .o; for the example, the output is applic.o.

During C++ compilation, the compiled object module (applic.o) is munched. Munching is the process of scanning an object module for non-local static objects, and generating data structures that VxWorks run-time support can use to call the objects' constructors and destructors. See the VxWorks Programmer's Guide: C++ Development for details.


*

CAUTION: Do not use -msoft-float on the MC68040 or MC68060. However, do use this flag for floating-point support on the MC68LC040. See Floating-Point Support.


1:  For more information on these and other compiler options, see the GNU ToolKit User's Guide. WRS supports compiler options used in building WRS software; a list of these options is included in the Guide. Other options are not supported, although they are available with the tools as shipped.