How to use Makefile of my own?
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Wed Feb 18, 2009 11:50 am
- Contact:
How to use Makefile of my own?
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!
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!
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to use Makefile of my own?
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
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
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Wed Feb 18, 2009 11:50 am
- Contact:
Re: How to use Makefile of my own?
Hi,
I have not made it work.
The build message is as follows.
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!
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
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!
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to use Makefile of my own?
Do u have any errors in the 'Trace' tab?
Eran
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Wed Feb 18, 2009 11:50 am
- Contact:
Re: How to use Makefile of my own?
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:
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!
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: 系统找不到指定的文件。)
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!
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to use Makefile of my own?
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 needsHalley wrote:I still have a question. When I tick on the "Enable custom build", do those configure in "Build Setting|Build Tool" still work?
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Wed Feb 18, 2009 11:50 am
- Contact:
Re: How to use Makefile of my own?
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!
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!
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to use Makefile of my own?
Yes. they are set in the environment before launching the build command (set them from settings -> environment variables)Halley wrote:1)How about the environment variae? Do they take effect when custom build is enabled?
I am not sure what are you referring to here, can please give an example?Halley wrote:2) The macro
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Wed Feb 18, 2009 11:50 am
- Contact:
Re: How to use Makefile of my own?
I set environment variable MAKE to C:\msys\1.0\bin\make.exe. And setting in project setting|custom builderanif wrote: Yes. they are set in the environment before launching the build command (set them from settings -> environment variables)Eran
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: 系统找不到指定的文件。)"
Those listed by clicking the "project setting|help button.eranif wrote: I am not sure what are you referring to here, can please give an example?
Eran
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to use Makefile of my own?
Ah, you found a 'gotcha' in codelite, MAKE is not allowed as environment variable.
Try settings it to something else and it will work
Here is code I wrote for this part:
Eran
Try settings it to something else 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{
Make sure you have read the HOW TO POST thread