|
||
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 |
---|---|
|
Location of the |
|
The current platform which can be |
|
The current configuration either |
|
Relative path to |
|
The path to the top-level |
|
The project’s “working” build directory under
|
|
The path to the directory containing the |
|
Path element separator. |
|
|
|
Command for directory removal. |
|
Command for file deletion. |
|
Command for file deletion. |
|
Command for directory creation. |
|
Command for file copying. |
|
The current platform in lower case to be used as part of path names. |
|
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.
If a bld.inf
file #includes
another
bld.inf
, the $(TO_BLDINF)
variable contains the
directory of that top-level file. If you require the directory of the
bld.inf
which actually references the makefile, use
$(EXTENSION_ROOT)
instead.
Any path within a template extension makefile is recommended to use
the path separator variable $/
.
All the template extension makefiles along with their meta files
need to be located under the \epoc32\tools\makefile_templates\
folder.
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 :