Makefiles for VxWorks applications are easy to create by exploiting the makefiles and make include files shipped with VxWorks BSPs. This section discusses how the VxWorks BSP makefiles are structured. An example of how to utilize this structure for application makefiles is in 8.8.2 Using Makefile Include Files for Application Modules.
In Tornado, a set of supporting files in installDir/target/h/make makes it possible for each BSP or application Makefile to be terse, specifying only the essential parameters that are unique to the object being built.
Example 8-1 shows the makefile from the installDir/target/config/mv147 directory; the makefile for any other BSP is similar. Two variables are defined at the start of the makefile: CPU, to specify the target architecture, and TOOL to identify what compilation tools to use. Based on the values of these variables and on the environment variables defined as part of your Tornado configuration, the makefile selects the appropriate set of definitions from installDir/target/h/make. After the standard definitions, several variables define properties specific to this BSP. Finally, the standard rules for building a BSP on your host are included.
# Makefile - makefile for target/config/mv147 # # Copyright 1984-1995 Wind River Systems, Inc. # # DESCRIPTION # This file contains rules for building VxWorks for the # Motorola MVME147. #*/ CPU = MC68020 TOOL = gnu include $(WIND_BASE)/target/h/make/defs.bsp include $(WIND_BASE)/target/h/make/make.$(CPU)$(TOOL) include $(WIND_BASE)/target/h/make/defs.$(WIND_HOST_TYPE) ## Only redefine make definitions below this point, or your definitions ## will be overwritten by the makefile stubs above. TARGET_DIR = mv147 VENDOR = Motorola BOARD = MVME147, MVME147S-1 # # The constants ROM_TEXT_ADRS, ROM_SIZE, and RAM_HIGH_ADRS are # defined in config.h as well as in this Makefile. # Both definitions of these constants must be identical. # ROM_TEXT_ADRS = ff800008 # ROM entry address ROM_SIZE = 00020000 # number of bytes of ROM space RAM_LOW_ADRS = 00001000 # RAM text/data address RAM_HIGH_ADRS = 00090000 # RAM text/data address HEX_FLAGS = -v -p $(ROM_TEXT_ADRS) -a 8 MACH_EXTRA = ## Only redefine make definitions above this point, or the expansion of ## makefile target dependencies may be incorrect. include $(WIND_BASE)/target/h/make/rules.bsp include $(WIND_BASE)/target/h/make/rules.$(WIND_HOST_TYPE)
There are two kinds of include files in installDir/target/h/make (as reflected by the two blocks of include statements in Example 8-1): variable definitions, and rule definitions. Just as for #include statements in the C preprocessor, include statements in makefiles accept the slash (/) character between directory segments of a file name. This feature of GNU make helps to write portable makefiles.
The following make include files define variables. These files are useful for application-module makefiles, as well as for BSP makefiles.
The following include files define make targets, and the rules to build them. These files are usually not required for building application modules in separate directories, because most of the rules they define are specific to the VxWorks run-time system and boot programs.
The variables defined in the make include files provide convenient defaults for most situations, and allow individual makefiles to specify only the definitions that are unique to each. This section describes the make variables most often used to specify properties of BSPs or applications. The following lists are not intended to be comprehensive; see the make include files for the complete set.
|
NOTE: Certain make variables are intended specifically for customization; see Variables for Customizing the Run-Time. Do not override other variables in BSP makefiles. They are described in the following sections for expository purposes.
|
||||||||||||||||||
The variables grouped in this section are useful for either BSP makefiles or application-module makefiles. They specify aspects of how to invoke the compiler.
The variables included in this section specify properties of a particular BSP, and are thus recorded in each BSP makefile. They are not normally used in application-module makefiles.
The variables listed in this section make it easy to control what facilities are statically linked into your run-time system. You can specify values for these variables either from the make command line, or from your own makefiles (when you take advantage of the predefined VxWorks make include files).
You can exploit the VxWorks makefile structure to put together your own application makefiles quickly and tersely. If you build your application directly in a BSP directory (or in a copy of one), you can use the Makefile in that BSP, by specifying variable definitions (Variables for Customizing the Run-Time) that include the components of your application.
You can also take advantage of the Tornado makefile structure if you develop application modules in separate directories. Example 8-2 illustrates the general scheme: include the makefile headers that specify variables, and list the object modules you want built as dependencies of a target. This simple scheme is usually sufficient, because the Tornado makefile variables are carefully designed to fit into the default rules that make knows about.1
|
NOTE: The target name exe is the Tornado convention for a default make target. You may either use that target name (as in Example 8-2), or define a different default rule in your makefiles. However, there must always be an exe target in makefiles based on the Tornado makefile headers (even if the associated rules do nothing).
|
||||||||||||||||||
# Makefile - makefile for ... # # Copyright ... # # DESCRIPTION # This file specifies how to build ... # ## It is often convenient to override the following with "make CPU=..." CPU = cputype TOOL = gnu include $(WIND_BASE)/target/h/make/defs.bsp include $(WIND_BASE)/target/h/make/make.$(CPU)$(TOOL) include $(WIND_BASE)/target/h/make/defs.$(WIND_HOST_TYPE) ## Only redefine make definitions below this point, or your definitions ## will be overwritten by the makefile stubs above. exe : myApp.o
The directory installDir/target/src/drv/sio/ contains source and templates for serial drivers that support both polled and asynchronous communications. The makefile for drivers in this directory is named Makefile.sio. Because this is not one of the names make can find automatically, you must specify the makefile with the -f option when you build a driver in this directory.
For example, to build the driver cd2400Sio.c and install it in the VxWorks archives, execute the following commands in this directory:
C:\tornado\target\src\drv\sio> make -f Makefile.sio CPU=cputype cd2400Sio.o C:\tornado\target\src\drv\sio> make -f Makefile.sio CPU=cputype default
% make -f Makefile.sio CPU=cputype cd2400Sio.o default
1: However, if you are working with C++, it may be also convenient to copy the .cpp.out rule from installDir/target/h/make/rules.bsp into your application's Makefile.