Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Template extension makefiles

A template extension makefile is a makefile which is integrated into the Symbian OS build system, such that it can be re-used by providing different input values as parameters. This facility allows extension makefiles to separate behaviour of the makefile from its input data. For example, you might want to copy files from one location to another using a template extension makefile which represents the required behaviour. The location from where these files have to be copied is represented by the input data, which can be specified in the bld.inf file using prj_extensions.

Note that it is recommended to follow GNU make syntax to define template extension makefiles. For more details on GNU make syntax, refer tohttp://www.gnu.org/software/make/manual/html_chapter/make_toc.html.

The template extension makefiles are invoked by the build system which defines a set of standard makefile variables. These variables can have well defined values and help the makefile writer to locate common directories, configurations and so on. The proper usage of these variables may result in achieving platform independence to a certain extent. It is highly recommended to use these variables wherever it is necessary.

The following is a list of the variables defined:

Variable name Description

$(EPOCROOT)

Location of the epoc32 tree.

$(PLATFORM)

The current platform which can be TOOLS, ARMV5, WINSCW etc.

$(CFG)

The current configuration either UREL or UDEB.

$(TO_ROOT)

Relative path to EPOCROOT.

$(TO_BLDINF)

The path to the top-level bld.inf.

$(EPOCBLD)

The project’s “working” build directory under \epoc32\build\….

$(EXTENSION_ROOT)

The path to the directory containing the bld.inf in which the extension makefile was called.

$/

Path element separator.

$;

PATH environment variable separator.

$(RMDIR)

Command for directory removal.

$(RM)

Command for file deletion.

$(ERASE)

Command for file deletion.

$(MKDIR)

Command for directory creation.

$(CP)

Command for file copying.

$(PLATFORM_PATH)

The current platform in lower case to be used as part of path names.

$(CFG_PATH)

The current configuration in lower case to be used as part of path names.

The extension makefiles integrated into the build system must support a number of phony targets which correspond to different phases of the Symbian OS build process. These phony targets are labels representing a set of commands to be executed to perform a task. For more information on these phony targets, refer to Extension makefile targets.

The commands for a phony target can be platform specific operations such as creating a directory, removing a directory, copying a file and so on. It is recommended to use the above listed variables to perform these platform specific operations, instead of invoking the command directly.

You must include the following statement in your template extension makefile to be able to use the variables listed in the table above:

include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk

This include statement includes a makefile that defines variables to store platform specific shell commands to support copying a file, deleting a file, removing a directory, and creating a directory. The value for these makefile variables is purely dependent on the shell being used. For example, the variable RM may have the value del on a Windows shell, whereas, on a Linux shell the value of the same variable is rm.

For example, the following will delete the files values.cpp and config.cpp for the target CLEAN.

CLEAN : 
  -$(ERASE) $(MDIR)$/values.cpp
  -$(ERASE) $(MDIR)$/config.cpp

A template extension makefile can be referenced in the bld.inf file using the prj_extensions keyword. For more information on how to reference a template extension makefile, see prj_extensions.

Each template extension makefile has an associated meta file which provides additional information such as the template makefile type, the platform for which the template can be applied and so on. It is mandatory to have a meta file with each template extension makefile. For information on meta file syntax, refer to Meta files.

[Top]


Notes

[Top]


Example

This example will copy the source files to a target path, build the component using the target copy of the source files, and finally delete the target copy of the source files.

# copy_default.mk
#

SOURCE_COPY=$(EPOCROOT)epoc32$/release$/$(PLATFORM_PATH)$/$(CFG_PATH)$/$(SOURCES)

TARGET_COPY=$(EPOCROOT)epoc32$/release$/$(PLATFORM_PATH)$/$(CFG_PATH)$/$(TARGET)

$(TARGET_COPY) : $(SOURCE_COPY)
    $(CP) "$?" "$@"

DO_NOTHING :
  @rem do nothing

MAKMAKE : 

BLD : $(TARGET_COPY)

SAVESPACE : BLD

FREEZE : DO_NOTHING

LIB : DO_NOTHING

CLEANLIB : DO_NOTHING

RESOURCE : DO_NOTHING

CLEAN : 
    -$(ERASE) $(TARGET_COPY)

RELEASABLES : 
    @echo $(TARGET_COPY)

FINAL : 

[Top]


See also

How to write an extension makefile template