Page 1 of 1
Custom Makefile Steps Always Run
Posted: Sun Nov 07, 2010 4:29 am
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:
Rule action:
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.
Re: Custom Makefile Steps Always Run
Posted: Sun Nov 07, 2010 9:57 am
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:
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
Re: Custom Makefile Steps Always Run
Posted: Sun Nov 07, 2010 8:26 pm
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: 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?
Re: Custom Makefile Steps Always Run
Posted: Mon Nov 08, 2010 3:10 am
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:
Rule:
Code: Select all
Debug\test.ini: test.ini
cmd /c copy test.ini Debug\test.ini
and it will work
Eran
Re: Custom Makefile Steps Always Run
Posted: Mon Nov 08, 2010 5:50 am
by Cinolt
I see. It works now