The code generator includes a set of built-in template makefiles that build programs for specific system target files.
There are two types of template makefiles:
Compiler-specific template makefiles are for a particular compiler or development system.
By convention, compiler-specific template makefiles names correspond to
the system target file and compiler (or development system). For example,
grt_vcx64.tmf
is the template makefile for building a
generic real-time program under the Visual C++® compiler; ert_lcc.tmf
is the template
makefile for building an Embedded Coder® program under the lcc
compiler.
Default template makefiles make your model designs more portable, by choosing the compiler-specific makefile and compiler for your installation. Select and Configure C or C++ Compiler describes the operation of default template makefiles in detail.
Default template makefiles have names that follow the pattern
.
They are MATLAB® language files that, when run, select the TMF for the
specified system target file configuration. For example,
target
_default_tmfgrt_default_tmf
is the default template makefile for
building a generic real-time program; ert_default_tmf
is
the default template makefile for building an Embedded Coder program.
For details on the structure of template makefiles, see Customize Template Makefiles. This section describes compiler-specific template makefiles and common options you can use with each.
You can specify template makefile options through the Make
command configuration parameter. Append the options after
make_rtw
(or other make
command), as in
the following example:
make_rtw OPTS="-DMYDEFINE=1"
The syntax for make
command options differs slightly for
different compilers.
Note
To control compiler optimizations for a makefile build, use the Compiler optimization level configuration parameter, which provides:
System target file-independent values Optimizations on
(faster runs)
and Optimizations off
(faster builds)
, which easily allow you to toggle
compiler optimizations on and off during code development
The value Custom
for entering custom
compiler optimization flags at Simulink® GUI level (rather than at other levels of the build
process)
If you specify compiler options for your makefile build using
OPT_OPTS
, MEX_OPTS
(except
MEX_OPTS="-v"
), or MEX_OPT_FILE
, the
value of Compiler optimization level is ignored and a
warning is issued about the ignored parameter.
The template makefiles for UNIX® platforms are for the Free Software Foundation's GNU® Make. These makefiles conform to the guidelines specified in the IEEE®[1] Std 1003.2-1992 (POSIX) standard.
ert_unix.tmf
grt_unix.tmf
rsim_unix.tmf
rtwsfcn_unix.tmf
You can supply options to makefiles through the Make command
configuration parameter. Options specified in Make command are
passed to the command-line invocation of the make
utility,
which adds them to the overall flags passed to the compiler. The following options
can be used to modify the behavior of the build:
OPTS
— User-specific options, for
example,
OPTS="-DMYDEFINE=1"
OPT_OPTS
— Optimization options. Default is
-O
. To enable debugging, specify the option as
OPT_OPTS=-g
. Because of optimization problems in
IBM_RS, the default is to not optimize.
CPP_OPTS
— C++ compiler options.
USER_SRCS
— Additional user sources, such as
files used by S-functions.
USER_INCLUDES
— Additional include paths, for
example,
USER_INCLUDES="-Iwhere-ever -Iwhere-ever2"
DEBUG_BUILD
— Add debug information to generated
code, for example,
DEBUG_BUILD=1
These options are also documented in the comments at the head of the respective template makefiles.
To build an executable using the Visual C++ compiler within the build process, use one of the
template
makefiles:target
_vcx64.tmf
ert_vcx64.tmf
grt_vcx64.tmf
rsim_vcx64.tmf
rtwsfcn_vcx64.tmf
You can supply options to makefiles through the Make command
configuration parameter. Options specified in Make command
are passed to the command-line invocation of the make
utility, which adds them to the overall flags passed to the compiler. The
following options can be used to modify the behavior of the build:
OPT_OPTS
— Optimization option. Default is
-O2
. To enable debugging, specify the option as
OPT_OPTS=-Zi
.
OPTS
— User-specific options.
CPP_OPTS
— C++ compiler options.
USER_SRCS
— Additional user sources, such as
files used by S-functions.
USER_INCLUDES
— Additional include paths,
for example,
USER_INCLUDES="-Iwhere-ever -Iwhere-ever2"
DEBUG_BUILD
— Add debug information to
generated code, for example,
DEBUG_BUILD=1
These options are also documented in the comments at the head of the respective template makefiles.
To create a Visual C++ project makefile
(
) without building
an executable, use one of the
model
.mak
template
makefiles:target
_msvc.tmf
ert_msvc.tmf
grt_msvc.tmf
These template makefiles are for nmake
, which is bundled
with the Visual C++ compiler.
You can supply options to makefiles through the Make command
configuration parameter. Options specified in Make command
are passed to the command-line invocation of the make
utility, which adds them to the overall flags passed to the compiler. The
following options can be used to modify the behavior of the build:
OPTS
— User-specific options, for
example,
OPTS="/D MYDEFINE=1"
USER_SRCS
— Additional user sources, such as
files used by S-functions.
USER_INCLUDES
— Additional include paths,
for example,
USER_INCLUDES="-Iwhere-ever -Iwhere-ever2"
DEBUG_BUILD
— Add debug information to
generated code, for example,
DEBUG_BUILD=1
These options are also documented in the comments at the head of the respective template makefiles.
The code generator provides template makefiles to create an executable for the
Windows® platform using Lcc compiler Version 2.4 and GNU Make (gmake
).
ert_lcc.tmf
grt_lcc.tmf
rsim_lcc.tmf
rtwsfcn_lcc.tmf
You can supply options to makefiles by using the Make command
configuration parameter. Options specified in the Make command
field are passed to the command-line invocation of the make
utility, which adds them to the overall flags passed to the compiler. The following
options can be used to modify the behavior of the build:
OPTS
— User-specific options, for
example,
OPTS="-DMYDEFINE=1"
OPT_OPTS
— Optimization options. Default is to
not use options. To enable debugging, specify -g4
:
OPT_OPTS="-g4"
CPP_OPTS
— C++ compiler options.
USER_SRCS
— Additional user sources, such as
files used by S-functions.
USER_INCLUDES
— Additional include paths. For
example:
USER_INCLUDES="-Iwhere-ever -Iwhere-ever2"
For lcc
, use /
as file separator
before the file name instead of \
, for example,
d:\work\proj1/myfile.c
.
DEBUG_BUILD
— Add debug information to generated
code, for example,
DEBUG_BUILD=1
These options are also documented in the comments at the head of the respective template makefiles.
[1] IEEE is a registered trademark of The Institute of Electrical and Electronics Engineers, Inc.