MATLAB® has a very flexible approach to building and configuring build systems. If you have set up your model to use the ert (embedded real-time target) simulation, you can check in the model configuration parameter windows and see:
Ensure you tick Generate makefile. Copy the ert_lcc.tmf from: C:\Program Files\MATLAB\R2013b\rtw\c\ert
Switch into your build directory and build your model – you will see in the command window a line:
### Processing Template Makefile: C:\MATLAB\my_model\ert_lcc.tmf
And if you look in:
C:\MATLAB\my_model\my_model_ert_rtw
you will find the generated makefile:
C:\MATLAB\my_model\my_model_ert_rtw\my_model.mk
This has been generated by the
make_rtw
utility and is subsequently executed to create an executable.
You can now start modifying the build process. A full description of all the sections can be found in the Simulink® Coder->Customization->Target Development->Examples and How To section of the MATLAB documentation centre, but typical items are:
OPTS | User specific compile options |
USER_SRCS | Additional user sources, such as files needed by S-functions |
Other changes could be:
- Adding Folder Names to the Makefile Include Path;
- Adding Library Names to the Makefile.
Further down you can find the rules. You can add/modify these to include additional functionality as generating reports, checking version identities. For example, if you need a compiler/linker wrapper to provide additional build steps find the line:
include $(MATLAB_ROOT)\rtw\c\tools\lcctools.mak
Then you could insert something like:
ifeq ($(WRAPPER), 1) CC = C:\Wrapper\bin\lcc LD = C:\Wrappere\bin\lcclnk endif
At any time you can view the built makefile (.mk) to check that your rules are being generated correctly.
Many items above can be predefined and configured using System Target Files (STF) but the template makefiles (tmf) provides a rapid and convenient mechanism for setting up model builds.
MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks for a list of additional trademarks.