Use makecfg to Customize Generated Makefiles for S-Functions

With the toolchain and 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

  1. To customize the generated makefile:

    • For all S-functions in the build folder (Simulink Coder), create a makecfg.m file.

    • For a specific S-function in the build folder, create a specificSFunction_makecfg.m file.

  2. In the file that you create, use RTW.BuildInfo (Simulink Coder) 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 in the build folder.

After code generation, in the build folder, the code generator searches for makecfg.m and specificSFunction_makecfg.m files. If the files are present in the build folder, the code generator uses these files to customize the generated makefile,

For example, consider a build folder that contains signalConvert.mexa64 (S-function binary file) and signalConvert.tlc (inlined S-function implementation) after the TLC phase (Simulink Coder) 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)

absolute = fullfile('$(START_DIR)', 'anotherFolder');

addIncludePaths(objBuildInfo, absolute);
addSourcePaths(objBuildInfo, absolute);

Related Topics