Page 1 of 1

How to use Makefile of my own?

Posted: Wed Feb 18, 2009 1:00 pm
by Halley
Hi,

I want to use Makefile that I write manually to build the project. CodeLite will use its own *.mk as the makefile. How to configurate in order to use my Makefile other than the one generated by CodeLite?

Thanks!

Re: How to use Makefile of my own?

Posted: Wed Feb 18, 2009 1:14 pm
by eranif
open the project settings (right click on the project settings, and select 'settings')

The dialog which opens is the project settings. select the 'Custom Build' tab and enable the 'Enabld Custom Build'

from this point on, codelite will no longer generate its own makefiles, but would use the on you supplied.

There are 4 default targets:
- Preprocess file - the command to run to just perform the pre-processing stage (you can leave this one empty)
- Compile Single File - this target is triggered when user attempts to build single file (Ctrl-F7 or right click on a file and select 'Compile') (you can leave this one empty if your makefile does not support this)
- Clean - this command will be used when user issues the clean command (right click on the project and select 'clean')
- Build - command to use for build.

Each target can be edited (just double click on the target) and new ones can be added.
There is another interesting field there: 'Working Directory' this is the directory where codelite will 'cd' before attempting to run your command - it is best to use the macros provided by codelite and not to set them hard coded (for example use $(ProjectPath) and not /home/eran/devl/myproject) this will make your project more "mobile"
To get full list of expandable macros, click on the 'Help' button at the bottom of the settings dialog.

In addition to this explanation, there is a detailed document here (you can easily find it from the main site home page, and select 'Documentation' from the side bar):
http://codelite.org/LiteEditor/CustomMakefiles


Eran

Re: How to use Makefile of my own?

Posted: Fri Feb 20, 2009 11:43 am
by Halley
Hi,

I have not made it work.

The build message is as follows.

Code: Select all

----------Build Started--------
C:\msys\1.0\make.exe
----------Building project:[ ctx1 - Debug ]----------
Failed to start build process, command: C:\msys\1.0\make.exe, process terminated with exit code: 0
My setting is as follows.
In the Project Setting dialog,
General tab:
Compiler: MinGW G++. (I have installed MinGW on my machine.)
Custom Build tab:
Work Directory: $(WorkspacePath) (It is set to the diretory where Makefile locates.)
Target Command
Build C:\msys\1.0\make.exe

Do I miss anything? Is there something I have not configured properly?
Thanks!

Re: How to use Makefile of my own?

Posted: Fri Feb 20, 2009 12:12 pm
by eranif
Do u have any errors in the 'Trace' tab?

Eran

Re: How to use Makefile of my own?

Posted: Fri Feb 20, 2009 12:49 pm
by Halley
Thanks for your guide. I figure out the cause.

I set the "Build Tool" in "Build Setting" pointing to "C:\msys\1.0\bin\make.exe". It can't find make when I issue build command.
The trace output:

Code: Select all

Error: Execution of command 'make' failed (error 2: 系统找不到指定的文件。)
CodeLite can't find make programme.

Then I set the target "build" bond to command "C:\msys\1.0\bin\make.exe" in "Custom Build".
This time it complains no target to build or no makefile. The Makefile locates in the source code diretory. I set variable WorkspacePath to that diretory too.

Finally, I set the target "build" bond to command "C:\msys\1.0\bin\make.exe -f /absolute/path/of/Makefile" in "Custom Build".
It works.

I still have a question. When I tick on the "Enable custom build", do those configure in "Build Setting|Build Tool" still work?
Thanks!

Re: How to use Makefile of my own?

Posted: Fri Feb 20, 2009 1:56 pm
by eranif
Halley wrote:I still have a question. When I tick on the "Enable custom build", do those configure in "Build Setting|Build Tool" still work?
No - when u choose to use a custom build - it means that codelite will not use its own settings, but the one defined in the 'custom build' tab and its up to your custom makefile to define all it needs


Eran

Re: How to use Makefile of my own?

Posted: Mon Feb 23, 2009 6:52 am
by Halley
1)How about the environment variae? Do they take effect when custom build is enabled?
Take a example, I would like to use different compiler for different build, and use varialbe $(CC) in the Makefile as the compiler. How to define/set such a environment variable for Makefile usage? Maybe I can choose compiler in project settting for this case. What I want is to use environment variable in Makefile.

2) The macro
There are some macroes. Can I define additional macro? How to?

Thanks a lot!

Re: How to use Makefile of my own?

Posted: Mon Feb 23, 2009 10:32 am
by eranif
Halley wrote:1)How about the environment variae? Do they take effect when custom build is enabled?
Yes. they are set in the environment before launching the build command (set them from settings -> environment variables)
Halley wrote:2) The macro
I am not sure what are you referring to here, can please give an example?

Eran

Re: How to use Makefile of my own?

Posted: Tue Feb 24, 2009 7:47 am
by Halley
eranif wrote: Yes. they are set in the environment before launching the build command (set them from settings -> environment variables)Eran
I set environment variable MAKE to C:\msys\1.0\bin\make.exe. And setting in project setting|custom build
Target Comand
build $(MAKE)

But it can not expand the variable to its value. As message is
"11:08:53: Error: Execution of command '$(MAKE) Clean' failed (error 2: 系统找不到指定的文件。)"
eranif wrote: I am not sure what are you referring to here, can please give an example?
Eran
Those listed by clicking the "project setting|help button.

Re: How to use Makefile of my own?

Posted: Tue Feb 24, 2009 3:40 pm
by eranif
Ah, you found a 'gotcha' in codelite, MAKE is not allowed as environment variable.
Try settings it to something else :D and it will work

Here is code I wrote for this part:

Code: Select all

if(varName == wxT("MAKE")) {
			//ignore this variable, since it is probably was passed here 
			//by the makefile generator
			replacement = wxT("___MAKE___");	
		}else{
Eran