45

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?

Lii
  • 11,553
  • 8
  • 64
  • 88
Stoiko
  • 451
  • 1
  • 4
  • 3

6 Answers6

43

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.

nates
  • 8,312
  • 5
  • 32
  • 28
20

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

jldupont
  • 93,734
  • 56
  • 203
  • 318
  • 1
    Does that let you edit your Makefile instead of having to do it Eclipse's way? – Peter Cordes Dec 11 '09 at 02:52
  • 1
    @Peter: you can edit your makefiles as you which and Eclipse doesn't touch it... at least that's how I have used it. Maybe there are esoteric options that I haven't touched yet :-) – jldupont Dec 11 '09 at 03:08
7

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

markovuksanovic
  • 15,676
  • 13
  • 46
  • 57
3

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
Issa Chanzi
  • 2,254
  • 2
  • 15
  • 21
3

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.

shrewmouse
  • 5,338
  • 3
  • 38
  • 43
1

Also, there might be a line that says "default: esh $(PLUGIN_SO)," or something along those lines depending on your project. I've found that changing the "default" to "all" will enable the project to compile too. This is a handy feature, eclipse :)

keaukraine
  • 5,315
  • 29
  • 54