Using custom Makefile with Eclipse/CDT [duplicate]

I have a project of multiple .c and .h files and I write my own makefile.

How can I configure Eclipse to use my makefile and my source files from their original locations?


You can create a custom Makefile and make sure it's in your project root. Then you need to disable the auto generated makefiles. You can do that by going here:

Project Properties (right click on project and select properties) -> C/C++ Build -> in that window uncheck "Generate Makefiles Automatically."

To use your own targets you can open the View called "Make Target":

Window -> Show View -> Make Target

In that view you can create a new target that will use the corresponding target in your custom Makefile.


There is an option to create a project from existing makefiles: use the "Project Wizard" and select "Makefile project".


You can disable "Generate makefiles automatically" in eclipse project properties -> c/c++ build (builder settings.)


In my latest attempt to compile a Cross ARM compile, I made a painful discovery on how to get this working.

First I created a "Makefile project with existing Code". I selected the Cross ARM tool chain. If I now open a console within Eclipse and make, it works.

Now to build within the GUI, I had to:

  1. Change properties to Internal Builder, with Generate Makefile checked.
  2. The settings option now offers Build Artifact tab. pick executable with ${Project}.
  3. Build. This will result in error in link stage.
  4. Switch the settings to External Builder, uncheck "Automatic Makefile generation"
  5. Clean
  6. Build

All that you have to do is tell gmake to use your makefile. The default command for Code Composer Studio is ${CCS_UTILS_DIR}/bin/gmake. Simply tell gmake to use your own makefile (e.g. sri.mk). We do this with the -f option. So the default command would become ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk

Note that Code Composer Studio is Eclipse based.

Here are the instructions:

  1. project->properties->C/C++ Build
  2. click on the 'Builder' tab
  3. Un-select 'Use default build command"
  4. Change the command to ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk

screen capture of gui settings

Note that the build is kicked off from the Debug directory. The Debug directory contains the makefiles that are generated by Eclipse. I put my makefile in the top level directory of the project so that's why I put ../ in -f ../sri.mk.