Skip to Main Content Skip to Search
Product Documentation

Makefiles for Software Build Tool Chains

What is the XMakefile Feature

Overview

You can use makefiles instead of IDE projects during the automated software build process. This approach is described in Using Makefiles to Generate and Build Software.

The XMakefile feature lets you choose the configuration of a specific software build tool chain to use during the automated build process. The configuration contains paths and settings for your make utility, compiler, linker, archiver, pre-build, post-build, and execute tools.

You can choose one built-in configuration described in Supported Tool Chains in Embedded Coder and Available XMakefile Configurations.

You can also create a new configuration for a new tool chain, as described in Example: Creating a New XMakefile Configuration.

Your requirements for specific features may determine whether you choose makefiles or IDE projects. See Feature Support.

Supported Tool Chains in Embedded Coder

Embedded Coder includes support for the following IDEs and tool chains.

Tool ChainProcessor Family/Target Operating SystemHost Operating System
Analog Devices™ VisualDSP++®Blackfin™, SHARC™, and TigerSHARC™Windows
Green Hills® MULTI®ARM®, Analog Devices™ Blackfin®, PowerPC®, and NEC® v850Linux, Windows
GNU development toolsLinuxLinux
GNU development toolsARMMontaVista Linux
Texas Instruments Code Composer Studio 3.3 and 4Texas InstrumentsC2000™, C5500™, and C6000™Windows
Wind River Diab/GCCARM9, Host Simulator, VxWorks, RTP and RTP_SOWindows

Simulink Coder includes support for other IDEs and tool chains. See Supported Tool Chains in Simulink Coder.

Available XMakefile Configurations

The following list describes the configurations in the XMakefile dialog box that this product supports:

For more information about supported versions of third-party software, see Support for Third Party Products

Feature Support

With makefiles, you cannot use features that rely on direct communications between your MathWorks software and third-party IDEs.

You cannot use the following features with makefiles:

Using Makefiles to Generate and Build Software

In addition to this chapter, see the Makefile Generator Tutorial demo for more information about using makefiles to generate code.

Configuring Your Model to Use Makefiles

Update your model Configuration Parameters to use a makefile instead of an IDE when you build software from the model:

  1. Add a Target Preferences block to your model and configure it for your target processor. For more information, see Target Preferences.

  2. In your model window, select Simulation > Configuration Parameters.

  3. Under Code Generation, select IDE Link.

  4. Set Build format to Makefile. For more information, see Build format.

  5. Set Build action to Build_and_execute. For more information, see Build action.

Choosing an XMakefile Configuration

Configure how to generate makefiles:

  1. Enter xmakefilesetup on the MATLAB command line. The software opens an XMakefile User Configuration dialog box.

  2. Leave Template set to gmake.

  3. For Configuration, select the option that describes your software build toolchain and target platform. Click Apply.

Things to consider while setting Configuration:

Building Your Model

In your model, click the build button or enter Ctrl+B. This action creates a makefile and performs the other actions you specified in Build action.

By default, this process outputs files in the <builddir>/<buildconfiguration> folder. For example, in model_name/CustomMW.

 Green Hills MULTI Output Folder

Making an XMakefile Configuration Operational

When the XMakefile utility starts, it checks each configuration file to verify that the specified paths for the vendor tool chain are valid. If the paths are not valid, the configuration is non-operational. Typically, the cause of this problem is a difference between the path in the configuration and the actual path of the vendor toolchain.

To make a configuration operational:

  1. Clear Display operational configurations only to display non-operational configurations.

  2. Select the non-operational configuration from the Configuration options.

  3. When you click Apply, a new dialog box prompts you for the folder path of any missing resources the configuration requires.

    Use mapped network drives instead of UNC paths to specify directory locations. Using UNC paths with compilers that do not support them causes build errors.

Example: Creating a New XMakefile Configuration

Overview

This example shows you how to add support for a software development toolchain to the XMakefile utility. This example uses the Intel Compiler and Eclipse IDE, which provides an open framework and allows for otherwise unsupported toolchains.

Create a Configuration

When you click New, the new configuration inherits values and behavior from the current configuration. To create a configuration for the Intel Compiler, clone a configuration from any of these configurations: msvs_host, mingw_host, montavista_arm and gcc_target.

Open the XMakefile User Configuration UI by typing xmakefilesetup at the MATLAB prompt. This action displays the following dialog box.

Select an existing configuration, such as msvs_host, mingw_host, montavista_arm or gcc_target. Click the New button.

A pop-up dialog prompts you for the name of the new configuration. Enter intel_compiler and click OK.

The dialog box displays a new configuration called intel_compiler, based on the previous configuration.

Modify the Configuration

Adjust the compiler, linker, and archiver settings of the newly created configuration. This example assumes the location of the Intel compiler is C:\Program Files\Intel\Compiler\.

Make Utility.  You do not need to make any changes. This configuration uses the gmake tool that ships with MATLAB.

Compiler.  For Compiler, enter the location of icl.exe in the Intel installation.

Linker.  For Linker, enter the location of the linker executable, xilink.exe.

For Arguments, add the /LIBPATH path to the Intel libraries.

Archiver.  For Archiver, enter the location of the archiver, xilib.exe. Confirm that File extensions for library files includes .lib.

Other tabs.  For this example, ignore the remaining tabs. In other circumstances, you can use them to configure additional build actions. In a later step of this example, you will configure the software to automatically build and run the generated code.

Test the Configuration

Open the "sumdiff" model by entering sumdiff on the MATLAB prompt.

Use a Target Preferences block to configure the model for use with the Eclipse IDE. In the Simulink Library Browser, search for "Target Preferences". Drag and drop the Target Preferences block from the search results to the summdiff model.

Configure the Target Preferences block as follows: set IDE/Tool Chain to Eclipse, set Board to Custom, and set Processor to Intel x86/Pentium.

Open the Target Preferences block and set Operating System to None or select Windows. Click OK.

Open the Configuration Parameters for the summdiff model by pressing Ctrl+E. Set Build format to Makefile and Build action to Build_and_execute.

Save the model to a temporary location, such as C:\Temp\IntelTest\.

Set that location as a Current Folder by typing cd C:\temp\IntelTest\ at the MATLAB prompt.

Build the model by pressing Ctrl+B. The MATLAB Command Window displays something like:

### TLC code generation complete.
### Creating HTML report file sumdiff_codegen_rpt.html
### Creating project: c:\temp\IntelTest\sumdiff_eclipseide\sumdiff.mk
### Project creation done.
### Building project...
### Build done.
### Downloading program: c:\temp\IntelTest\sumdiff_eclipseide\sumdiff
### Download done.

A command window comes up showing the running model. Terminate the generated executable by pressing Ctrl+C.

XMakefile User Configuration Dialog Box

Active

Template.  Select the template that matches your toolchain and processor. The template defines the syntax rules for writing the contents of the makefile or buildfile. The default template is gmake, which works with the GNU make utility.

To add templates to this parameter, save them as .mkt files to the location specified by the User Templates parameter. For more information, see User Templates.

Configuration.  Select the configuration that best describes your toolchain and target processor.

You cannot edit or delete the configurations provided by MathWorks. You can, however, edit and delete the configurations that you create.

Use the New button to create an editable copy of the currently selected configuration.

Use the Delete button to delete a configuration you created.

Display operational configurations only.  When you open the XMakefile User Configuration dialog box, the software verifies that each configuration provided by MathWorks contains valid paths to the executable files it uses. If all of the paths are valid, the configuration is operational. If any of the paths are not valid, the configuration is not operational.

This setting only affects configurations provided by MathWorks, not configurations you create.

To display valid configurations, select Display operational configurations only.

To display all of the configurations, including non-operational configurations, clear Display operational configurations only.

For more information, see Making an XMakefile Configuration Operational.

User Templates.  Set the path of the folder to which you can add template files. Saving templates files with the .mkt extension to this folder adds them to the Templates options.

User Configurations.  Set the location of configuration files you create with the New button.

Make Utility

Make utility.  Set the path and filename of the make utility executable.

Arguments.  Define the command-line arguments to pass to the make utility. For more information, consult the third-party documentation for your make utility.

Optional include.  Set the path and file name of an optional makefile to include.

Compiler

Compiler.  Set the path and file name of the compiler executable.

Arguments.  Define the command-line arguments to pass to the compiler. For more information, consult the third-party documentation for your compiler.

Source.  Define the file name extension for the source files. Use commas to separate multiple file extensions.

Header.  Define the file name extension for the header files. Use commas to separate multiple file extensions.

Object.  Define the file name extension for the object files.

Linker

Linker.  Set the path and file name of the linker executable.

Arguments.  Define the command-line arguments to pass to the linker. For more information, consult the third-party documentation for your linker.

File extensions for library files.  Define the file name extension for the file library files. Use commas to separate multiple file extensions.

Generated output file extension.  Define the file name extension for the generated libraries or executables.

Archiver

Archiver.  Set the path and file name of the archiver executable.

Arguments.  Define the command-line arguments to pass to the archiver. For more information, consult the third-party documentation for your archiver.

Generated output file extension.  Define the file name extension for the generated libraries.

Pre-build

Enable Prebuild Step.  Select this check box to define a prebuild tool that runs before the compiler.

Prebuild tool.  Set the path and file name of the prebuild tool executable.

Arguments.  Define the command-line arguments to pass to the prebuild tool. For more information, consult the third-party documentation for your prebuild tool.

Post-build

Enable Postbuild Step.  Select this check box to define a postbuild tool that runs after the compiler or linker.

Postbuild tool.  Set the path and file name of the postbuild tool executable.

Arguments.  Define the command-line arguments to pass to the postbuild tool. For more information, consult the third-party documentation for your postbuild tool.

Execute

Use Default Execute Tool.  Select this check box to use the generated derivative as the execute tool when the build process is complete. Uncheck it to specify a different tool. The default value, echo, simply displays a message that the build process is complete.

Execute tool.  Set the path and file name of the execute tool executable or built-in command.

Arguments.  Define the command-line arguments to pass to the execute tool. For more information, consult the third-party documentation for your execute tool.

Tool Directories

Installation.  Use the Tool Directories tab to change the toolchain path of an operational configuration.

For example, if you installed two versions of a vendor build tool in separate folders, you can use the Installation path to change which one the configuration uses.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS