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.morspecificSFunction_makecfg.mfile. If you create amakecfg.mfile, it is active for any S-function in the S-function MEX file folder that the model uses. AspecificSFunction_makecfg.mfile is active only if the model uses the corresponding S-function.In the file that you create, use
RTW.BuildInfofunctions to specify additional items for the S-function build process. For example, you can use:addCompileFlagsto specify compiler options.addDefinesto 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);