Use makecfg to Customize Generated Makefiles for S-Functions - MATLAB & Simulink (original) (raw)

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:

To customize the generated makefile:

  1. In the S-function MEX file folder that contains your S-function components, create a makecfg.m or_specificSFunction_makecfg.m file. If you create a makecfg.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.
  2. 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.
  3. 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 usesRTW.BuildInfo functions to specify filterV1.c for the build process.

function signalConvert_makecfg(objBuildInfo)

absolutePath = fullfile('$(START_DIR)', 'anotherFolder'); addSourceFiles(objBuildInfo, 'filterV1.c', absolutePath);

See Also

Topics