Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Makefile build configurations(How do I change build configuration for makefile build projects?)
Makefile build configurations [message #1839092] Sat, 13 March 2021 12:04 Go to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hello,

I shared a makefile build project with a colleague and on his machine the BUILD_MODE configuration is "run" and on my machine it is "debug". We cannot determine how to control this setting.

We cannot determine how to change the command line from "make -f ..\..\Makefile" to add a BUILD_MODE variable setting.

We shared a managed build project and can set the build configuration using project|right-click|Build Configurations|Set Active||Debug (or Release). For the makefile project this menu is greyed out. Probably because it does not use that mechanism?

Please advise me. Thanks, and have a great day.

-Lance
Re: Makefile build configurations [message #1839093 is a reply to message #1839092] Sat, 13 March 2021 12:06 Go to previous messageGo to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
I forgot to add, this is the part of the makefile we are trying to control:

ifeq ($(BUILD_MODE),debug)
CFLAGS += -O0 -g3 -Wall
else ifeq ($(BUILD_MODE),run)
CFLAGS += -O2
else
$(error Build mode $(BUILD_MODE) not supported by this Makefile)
endif

Cheers!
Re: Makefile build configurations [message #1839105 is a reply to message #1839093] Sun, 14 March 2021 03:01 Go to previous messageGo to next message
David VavraFriend
Messages: 1405
Registered: October 2012
Senior Member
In a managed build there is a makefile for each build configuration.
The build configuration is usually the name of the build folder within the project.
You can change this for each configuration (or all) with
Project --> Properties --> C/C++ Build --> Builder Settings tab --> Build Location
(though maybe not in a managed build).

When executing Project --> Build Project, CDT will set the current working directory to the
directory in Build Location then execute the build command found in
Project --> Properties --> C/C++ Build --> Builder Settings tab --> Build Command
The default is "make <target>" but you can change it by turning off Use default build command
AFAIK, you CANNOT stop the target from being appended to the command.

The command can

  • use Build Variables found in Project --> Properties --> C/C++ Build --> Build Variables
  • set environment variables when running make with Project --> Properties --> C/C++ Build --> Environment
In a Makefile Project you get to decide what the makefile does but the initial build actions are the same.

All of the items in Project --> Properties --> C/C++ Build (except for logging) can be modified according to build configuration.

https://help.eclipse.org/2020-09/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_build.htm
https://help.eclipse.org/2020-09/nav/10_4_7_0_3


[Updated on: Sun, 14 March 2021 03:18]

Report message to a moderator

Re: Makefile build configurations [message #1839128 is a reply to message #1839105] Mon, 15 March 2021 10:13 Go to previous messageGo to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hello David -

Thank you for the quick reply.

I have a Makefile Project, not a C++ Managed Build Project.

I created the project using the New C/C++ Project Wizard and selected the makefile project experimental template.

The Project --> Properties --> C/C++ Build property page does not exist. I do have Project --> Properties --> C/C++ General property page however.

I am using CDT Version: 9.5.5.201811180605.

I cannot figure out how to control BUILD_MODE, nor can I find a way to change the make command-line to add flags that could possibly control such variables.

The strangest part to me is why my colleague gets BUILD_MODE=run and I get BUILD_MODE=debug, yet we are sharing the same project and presumably machine setup. Must be a setting from left-field that is different in our setups.

Thanks again for the reply!

-Lance
Re: Makefile build configurations [message #1839129 is a reply to message #1839128] Mon, 15 March 2021 10:38 Go to previous messageGo to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hello -

I found a couple of stack overflow posts that seem to be similar to my issue: https://stackoverflow.com/questions/65430479/build-eclipse-makefile-project-from-command-line/65431232#65431232 and https://stackoverflow.com/questions/65428390/using-profile-in-makefile-project.

It seems I need to control this by adding a command-line parameter to the call to make, which is currently: make -f ..\..\Makefile. Is there a way to change or add to the make command?

Thanks again,

-Lance
Re: Makefile build configurations [message #1839141 is a reply to message #1839129] Mon, 15 March 2021 15:49 Go to previous messageGo to next message
David VavraFriend
Messages: 1405
Registered: October 2012
Senior Member
Quote:
I created the project using the New C/C++ Project Wizard and selected the makefile project experimental template.


I'm not sure what was intended with that particular Project Wizard but IMO it's broken.
I do note that it is marked experimental.
It seems to generate a project similar to a CMake project.

The way I generate Makefile Projects as I described them
is to import them with File --> Import --> C/C++ --> Existing Code as Makefile Project
I tried creating one with File --> New --> Makefile Project with Existing Code
Both seem to work the same.

Note: "existing code" is misleading.
You can create both in an empty directory.

If you want to try it on your current project,
I suggest deleting the.project and .cproject files first.
Doing so will lose whatever Eclipse settings you have already made, though.



[Updated on: Mon, 15 March 2021 15:53]

Report message to a moderator

Re: Makefile build configurations [message #1839187 is a reply to message #1839141] Wed, 17 March 2021 08:46 Go to previous messageGo to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hello - Thanks.

I tried the procedure you gave me, but on my side it created another Managed Build project instead of a Makefile Project. Perhaps my terminology is bad? My goal is to use the CDT IDE but provide and edit the makefile myself instead of it being automatically generated.

Everything is working except I cannot control the make command line, nor figure out how to control the BUILD_MODE variable.

Thanks again! I hope my explanation or lack of understanding of something did not waste your time.

-Lance
Re: Makefile build configurations [message #1839190 is a reply to message #1839187] Wed, 17 March 2021 09:52 Go to previous messageGo to next message
David VavraFriend
Messages: 1405
Registered: October 2012
Senior Member
I'm surprised. Works OK for me.
The major difference between a Managed Build Project and a Makefile Project is the generation of a makefile.
Another is mostly the project layout which should have been left untouched.
Turn off autogeneration with Project --> Properties --> C/C++ Build --> Builder Settings tab --> Generate Makefiles automatically
It will then be a Makefile Project where you maintain the makefile.

Quote:
I tried the procedure you gave me, but ... it created another Managed Build project instead of a Makefile Project. Everything is working except I cannot control the make command line, nor figure out how to control the BUILD_MODE variable.


What do you mean by "another Managed Build project"?
The first using the wizard that you described is a modified Makefile Project.
If you had actually made a Managed Build project then the controls for the makefile and setting variables would be there.
Sounds like you just used the experimental Makefile wizard again.

[Updated on: Wed, 17 March 2021 17:01]

Report message to a moderator

Re: Makefile build configurations [message #1839284 is a reply to message #1839190] Thu, 18 March 2021 17:19 Go to previous messageGo to next message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hello - Oh, that last post was very useful because it is good to learn a project can be either a Makefile Project or Managed Build. This reduces my experiment space a lot. The lack of C++ Build properties confused me (at least that is my excuse, heh heh).

By the way, I wanted to make sure I wasn't dealing with a CDT version so I grabbed the most recent 2021‑03 R to try these steps.

Now, I am trying to turn off autogeneration with Project --> Properties --> C/C++ Build --> Builder Settings tab --> Generate Makefiles automatically -- but the entire tab controls are greyed out disabled. I will keep poking but if there is a simple reason I cannot edit the properties please let me know.

Thanks again -- you are very nice to be responding so quickly. Appreciate it.
Re: Makefile build configurations [message #1839285 is a reply to message #1839284] Thu, 18 March 2021 17:36 Go to previous message
Lance Brooks is currently offline Lance BrooksFriend
Messages: 10
Registered: October 2016
Junior Member
Hi - SUCCESS!

Using this as a reference: http://rtorsten.blogspot.com/2012/05/eclipse-cdt-disabled-build-settings.html, I was able to enable the properties. I did have a slight difference and had to select C++ Build --> Tool Chain Editor --> Current builder: Gnu Make Builder. After that, I can edit Project --> Properties --> C/C++ Build --> Builder Settings tab --> Generate Makefiles automatically.

And it is working as you said :-).

This is now exactly what I want!! So, again, thanks! a ton for the great advice/help.
Previous Topic:Include Header files in Eclipse
Next Topic:Unhandled event loop exception occurs when trying to open file or folder in CDT
Goto Forum:
  


Current Time: Wed Dec 01 09:34:18 GMT 2021

Powered by FUDForum. Page generated in 0.02198 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top