The best way to generate code for concurrent execution models with posix threads, from a windows machine is to use IDELink. I recommend using the Eclipse IDE, as you can directly specify 'Linux' as the Board Operating System. With Wind River Diab, you only get the option for VxWorks, that happens to also use POSIX threads, but the code that you would eventually generate is not specific to a Linux Operating system, but is tailored to a VxWorks.
So, first specify the TLC to be used (in Configuration Parameters->Code Generation->System Target File), as idelink_ert.tlc. This should bring up the new 'Coder Target' leaf in the Configuration Parameters tree. On selecting this leaf you should find, on the right side, two tabs: Tool Chain Automation, and Target Hardware Resources.
Under Tool Chain Automation, make sure that the Build Format is set to "Make file". If you select 'Project' this will require you to be on a 32 bit system, and to have Ganymede Eclipse installed. Also using the 'Project' restricts you to use the MinGW toolchain which among other things does not support POSIX threading. By selcting 'Makefile', we can use our own toolchain and customize the make file that is generated (I will describe this later). Also, set the build action of the container model to "Create Make file".
Under Target Hardware Resources, select "Eclipse" as your IDE/Toolchain. Set your board to Custom (unless you have installed a support package provided by Mathworks that is specific to the board that you are using. You could install support packages by typing "targetinstaller" on your command window). Now make sure the operating system is set to Linux. Once you do this, a new tab should pop up next to board. The tab will be named "Linux".
If you want to add source files and include files specific to your board, the board tab is a good place to put them in.
Now let us go to the Linux tab. If you have a concurrent execution model that you are generating code for, an option may pop up saying - 'allow tasks to execute concurrently'.
Now, let us talk about customization of the Make file. You can do this using the 'xmakefilesetup' command. It may be be easier for you to read the following documentation for you to understand how to do this:
The documentation below describes what xmakefilesetup is:
As long as the "makefile" option is set as the build format, the templates and toolchain you specify in the 'xmakefilesetup' dialog will be used to create and build your make file for you.
When you select the 'Make file' to be your build format, Eclipse is completely bypassed. You can select whatever toolchain you want. Simply type:
1) Select the 'gmake' template
2) For Configurations, click on the 'New' Button on the right hand side, and name this 'my_toolchain'.
3) Now under the 'Make Utility' tab. You may not need to change anything. But just in case, change the make utility to:
C:\Program Files\MATLAB\R2013a\bin\win64\gmake.exe (or R2012b if you want to use that).
4) Under compiler, select the compiler of your choice. I am not sure what compiler that you like to use. I like to use Code Sourcery's G++ compiler:
-click on windows IA32 Windows installer
(one of the flags for this copiler is -enable-pthread, this should automatically be set when the 'Operating System' of the board is set to 'Linux'
-download and install.
-The location of the compiler should be:
C:\Program Files (x86)\CodeSourcery\Sourcery G++ Lite\bin\arm-none-linux-gnueabi-gcc.exe
5) Set the Linker to be what ever you want. If you are using Coder Sourcery's Tool Chain, this should be
C:\Program Files (x86)\CodeSourcery\Sourcery G++ Lite\bin\arm-none-linux-gnueabi-g++.exe
Add this arguement to the arguement list: '-lpthread'
6)Set the archiver to be whatever you want. If you are using the Code Sourcery Tool Chain, this should be
C:\Program Files (x86)\CodeSourcery\Sourcery G++ Lite\bin\arm-none-linux-gnueabi-ar.exe
7) Click Apply, and OK
You may ask yourself - Why is a '.a' file being created although I set the build action to 'Create_Makefile' and not 'Archive_Library'?
This is done automatically (take a look at the warning messages, then reopen the reference models and you will find that the build action has changed). Since there are model references being used, the container model's generated code uses the archived libraries to access those models.
Now that your toolchain is set to something that has the ability to deal with posix threads, the '.a' files that are generated should be correct.
You can also include libraries. You can do this in the configuration parameters, in the IDELink's "Board" tab that I talked about above... or you can make a custom rtwmakecfg.m file that is a more sophisticated way of including all necessary libraries, headers and source files.
The examples below should be a good starting point for writing your own rtwmakecfg.m file:
Please note that the above links are from Matlab Central which is a user group and we do not officially support files from MATLAB Central.