RTEMS Logo

RTEMS 4.10.2 On-Line Library


Makefiles Makefiles Used During The BSP Building Process

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

3.1: Makefiles Used During The BSP Building Process

RTEMS uses the GNU automake and GNU autoconf automatic configuration package. Consequently, there are a number of automatically generated files in each directory in the RTEMS source tree. The bootstrap script found in the top level directory of the RTEMS source tree is executed to produce the automatically generated files. That script must be run from a directory with a configure.ac file in it. The bootstrap command is usually invoked in one of the following manners:

There is a file named Makefile.am in each directory of a BSP. This file is used by automake to produce the file named Makefile.in which is also found in each directory of a BSP. When modifying a Makefile.am, you can probably find examples of anything you need to do in one of the BSPs.

The configure process specializes the Makefile.in files at the time that RTEMS is configured for a specific development host and target. Makefiles are automatically generated from the Makefile.in files. It is necessary for the BSP developer to provide the Makefile.am files and generate the Makefile.in files. Most of the time, it is possible to copy the Makefile.am from another similar directory and edit it.

The Makefile files generated are processed when configuring and building RTEMS for a given BSP.

The BSP developer is responsible for generating Makefile.am files which properly build all the files associated with their BSP. Most BSPs will only have a single Makefile.am which details the set of source files to build to compose the BSP support library along with the set of include files that are to be installed.

This single Makefile.am at the top of the BSP tree specifies the set of header files to install. This fragment from the SPARC/ERC32 BSP results in four header files being installed.

include_HEADERS = include/bsp.h
include_HEADERS += include/tm27.h
include_HEADERS += include/erc32.h
include_HEADERS += include/coverhd.h

When adding new include files, you will be adding to the set of include_HEADERS. When you finish editing the Makefile.am file, do not forget to run bootstrap -p to regenerate the preinstall.am.

The Makefile.am also specifies which source files to build. By convention, logical components within the BSP each assign their source files to a unique variable. These variables which define the source files are collected into a single variable which instructs the GNU autotools that we are building libbsp.a. This fragment from the SPARC/ERC32 BSP shows how the startup related, miscellaneous support code, and the console device driver source is managed in the Makefile.am.

startup_SOURCES = ../../sparc/shared/bspclean.c ../../shared/bsplibc.c \
    ../../shared/bsppredriverhook.c \
    ../../shared/bsppost.c ../../sparc/shared/bspstart.c \
    ../../shared/bootcard.c ../../shared/sbrk.c startup/setvec.c \
    startup/spurious.c startup/erc32mec.c startup/boardinit.S
clock_SOURCES = clock/ckinit.c
...
noinst_LIBRARIES = libbsp.a
libbsp_a_SOURCES = $(startup_SOURCES) $(console_SOURCES) ...

When adding new files to an existing directory, do not forget to add the new files to the list of files to be built in the corresponding XXX_SOURCES variable in the Makefile.am and run bootstrap.

Some BSPs use code that is built in libcpu. If you BSP does this, then you will need to make sure the objects are pulled into your BSP library. The following from the SPARC/ERC32 BSP pulls in the cache, register window management and system call support code from the directory corresponding to its RTEMS_CPU model.

libbsp_a_LIBADD  = ../../../libcpu/@RTEMS_CPU@/cache.rel \
    ../../../libcpu/@RTEMS_CPU@/reg_win.rel \
    ../../../libcpu/@RTEMS_CPU@/syscall.rel

NOTE: The Makefile.am files are ONLY processed by bootstrap and the resulting Makefile.in files are only processed during the configure process of a RTEMS build. Therefore, when developing a BSP and adding a new file to a Makefile.am, the already generated Makefile will not automatically include the new references unless you configured RTEMS with the --enable-maintainer-mode option. Otherwise, the new file not being be taken into account!


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2008 OAR Corporation