Use makecfg to Customize Generated Makefiles for S-Functions
With the toolchain or template makefile approach for building code, you can customize generated makefiles for S-functions. Through the customization, you can specify additional items for the S-function build process:
Source files and folders
Include files and folders
Library names
Preprocessor macro definitions
Compiler flags
Link objects
To customize the generated makefile:
In the S-function MEX file folder that contains your S-function components, create a
makecfg.m
orspecificSFunction
_makecfg.m
file. If you create amakecfg.m
file, it is active for any S-function in the S-function MEX file folder that the model uses. AspecificSFunction
_makecfg.m
file is active only if the model uses the corresponding S-function.In the file that you create, use
RTW.BuildInfo
functions to specify additional items for the S-function build process. For example, you can use:addCompileFlags
to specify compiler options.addDefines
to specify preprocessor macro definitions.
Save the created file.
After code generation, in the S-function MEX file folder, the code generator searches
for makecfg.m
and
specificSFunction
_makecfg.m
files. If
the files are present, the code generator uses these files to customize the generated
makefile, model
.mk
.
For example, consider a folder that contains signalConvert.mexa64
(S-function binary file) and signalConvert.tlc
(inlined S-function
implementation) after the TLC phase of
the build process. The S-function requires an additional source code file,
filterV1.c
, which is located in anotherFolder
.
You can create a file, signalConvert_makecfg.m
, that uses
RTW.BuildInfo
functions to specify filterV1.c
for the build
process.
function signalConvert_makecfg(objBuildInfo) absolutePath = fullfile('$(START_DIR)', 'anotherFolder'); addSourceFiles(objBuildInfo, 'filterV1.c', absolutePath);