Documentation Center

  • Trial Software
  • Product Updates

Makefile Generator Tutorial

This example shows how to use the XMakefile functionality of IDE Link component to generate and build code from a simple Simulink® model.

Supported IDE/tool chain:

  • Eclipse™ IDE

Supported processors:

Introduction

This application example shows how to use the XMakefile functionality to generate and build code from a simple model using a makefile.

Task 1 - Design and Simulate Algorithm

The following figure shows an algorithmic model that calculates the sum and difference of two random signal vectors containing 16 data points of int32 type.

1. Open the sumdiff_ecsumdiff_ec model.

2. In your model, click the "Run" button to run the simulation.

3. Stop the simulation by clicking the "Stop" button.

Task 2 - Configure Model for Code Generation

IDE Link also provides some configuration parameters as part of simulation configuration parameters of the model. For more information, please refer to product documentation.

In this step, we will modify one option for example purposes.

1. Open the Model Configuration Parameters dialog, set the "System target parameter" under "Code Generation" to either "idelink_ert.tlc" or "idelink_grt.tlc" and click "Apply".

2. Next, select "Coder Target" under "Code Generation". Click "Target Hardware Resources" and set the parameters to match your target hardware. Click "OK".

For more information on configuring the model for your target hardware see this sectionthis section in the IDE Link documentation.

  • Click "Tool Chain Automation" tab.

  • Choose "Makefile" from the "Build format" drop down menu.

  • Choose "Build" from the "Build action" drop down menu.

  • Click OK button.

Task 3 - Configure XMakefile Functionality

IDE Link also provides configuration parameters that allow for the creation and selection of tool chain configurations. For more information, please refer to the XMakefile documentationXMakefile documentation.

In this step, select the Linux® GCC or MinGW tool chain configuration depending on your desktop target OS. The following steps assume that you are configured to use a Linux® GCC tool chain and you configured the model for a host processor. Similar steps apply when you are using MinGW.

  • Choose "linux_gcc" from the "Configuration" drop-down menu.

  • Click OK button.

Task 4 - Build the Model

  • In your model, click the "Build Model" button to build the model.

  • Verify that a makefile was generated for the model.

Task 5 - Using the Generated Makefile

IDE Link software has generated the makefile and used it to build the model software. To rebuild the model software, invoke the makefile from either the MATLAB or system command line. Use the make utility that corresponds to the "Template" selection on the "XMakefile User Configuration".

For example, if you set "Template" to "gmake", invoke the gmake utility that ships with MATLAB. The gmake utility is located in the matlabroot/bin/$ARCH folder, where $ARCH is your system architecture (e.g., win32, glnx86).

The generated makefile in this case supports the "info" , "build" and "clean" targets and can be invoked with the command shown below from the model build directory. For example:

gmake -C sumdiff_ec_eclipseide -f sumdiff_ec.mk info clean build

If matlabroot/bin/$ARCH is not on the system path, then use the full path for gmake. For example:

/usr/local/MATLAB/bin/glnx86/gmake -C sumdiff_ec_eclipseide -f sumdiff_ec.mk info clean build

Summary

This example showed how to configure a model for generating and building a model with a makefile.

Was this topic helpful?