Custom Makefile Steps Always Run

General questions regarding the usage of CodeLite
Cinolt
CodeLite Curious
Posts: 3
Joined: Sun Nov 07, 2010 4:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Custom Makefile Steps Always Run

Post by Cinolt »

Hi, I want to utilize Custom makefile steps in my project to run certain commands only when a certain file has been modified. So, I go to my project settings and to the Custom makefile steps, and I enter this for the Dependencies:

Code: Select all

test
Rule action:

Code: Select all

test: main.c
	@echo hi
However, it is always displaying "hi" when I build my project, regardless of whether I modified main.c or not. What is the correct way to do what I want? Thanks for any help.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Custom Makefile Steps Always Run

Post by eranif »

Since 'test' probably does not exists, the 'custom makefile' will always run.
Try this:
Instead of 'test' try making it a real file.

Here is a real live example taken from codelite's project itself:

Depedencies:

Code: Select all

resources.cpp
Rule:

Code: Select all

resources.cpp: resources.xrc
	wxrc /c /v /o resources.cpp resources.xrc
This means:
the makefile adds another dependency on resources.cpp.
And the rule to make it is based on modifications on resources.xrc (which used for generating the resources.cpp)

This rule will only run if the file resources.xrc has been modified OR if resources.cpp does not exist (which in your example is always true)

Read this:

http://codelite.org/LiteEditor/ProjectSettingsSummary

Search for 'Custom Makefile Steps' at the end of the page, there is an example there of how to use this with yacc/lex.
Eran
Make sure you have read the HOW TO POST thread
Cinolt
CodeLite Curious
Posts: 3
Joined: Sun Nov 07, 2010 4:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Custom Makefile Steps Always Run

Post by Cinolt »

Thanks for the reply. I have already read the link you provided.

My real objective is to make my project copy an .ini file to the bin directory only when it is modified. So I tried this:

Code: Select all

test.ini

Code: Select all

test.ini: test.ini
	cmd /c copy test.ini $(ProjectPath)\Debug\test.ini
During build-time it produces this error:

Code: Select all

mingw32-make.exe[1]: Circular test.ini <- test.ini dependency dropped.
I also tried various other things to no avail. Could you please show how to get this to work?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Custom Makefile Steps Always Run

Post by eranif »

First an important comment:

Dont use the $(ProjectPath) since under Windows, it most likely contains a colon (as in: C:\path\to\project)) this will break the makefile
Instead, you can safely assume that the current working directory is already set to the project path


Now, to make what you want change your rule into:

Dependencies:

Code: Select all

Debug\test.ini
Rule:

Code: Select all

Debug\test.ini: test.ini
    cmd /c copy test.ini Debug\test.ini
and it will work

Eran
Make sure you have read the HOW TO POST thread
Cinolt
CodeLite Curious
Posts: 3
Joined: Sun Nov 07, 2010 4:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Custom Makefile Steps Always Run

Post by Cinolt »

I see. It works now :)
Post Reply