Is there any utility to monitor file changes and invoke GNU make?
Or, more generally, periodically invoke a command when some file changed? or Makefile contains the checking interval?
Is there any utility to monitor file changes and invoke GNU make?
Or, more generally, periodically invoke a command when some file changed? or Makefile contains the checking interval?
periodically invoke a command when some file changed
You can do that with incron. To prevent loops, build outside the source tree, check that the modified file is under source control, or use the IN_NO_LOOP option.
What platform? You can invoke the following line in Bourne shell or bash to run make every 60 seconds, for example. If your Makefile is designed correctly, it will exit without changing anything if no files have changed:
while true ; do make ; sleep 60; done
If you are trying to compile code as it is checked in, take a look at "Continuous Integration" by Paul Duvall, Addison Wesley. It outlines tools and techniques for this.
Yes, there are ways you could do this, but you didn't specify your platform.
If make and source is involved, then a Version Control System should be involved and modern VCS have "commit hooks" which can trigger a build based on certain VCS activities.
Randomly attempting a build based merely on "the source has changed" is a very easy way to produce builds that don't work.
added based on comment:
I'm guessing that you are coming from an IDE environment and brought some bad habits with you. You should spend much time thinking, a little time coding, and compile rarely. To do otherwise generates sloppy code which will be unhappy for you and the next guy so don't do it.
Also, there is nothing stopping you from using Git or Mercurial for your own local changes and pushing up to Subversion when you have something worthy for the central repository while being protected from your own bad changes.
However, I strongly recommend that you don't use your compiler as an error checker. You will be a worse programmer if you do.
auto make' into
auto commit'.
think-more' mode, but there's also some projects that should be programmed in
try-more-build-cycle' mode. And, for example, even think-more' projects have several stage, at the starting stage, it might be in
think-more' stage, and then it becomes a debug-more' stage, or sth else. So, while
think-more' is always good, strengthen my brain and expand my life, but for some tasks, WYSIWIG is more convenient. Isn't it?
You could set up some sort of cron task to do this at a specified interval.
Or, write a shell script that uses a polling loop to check if files were modified. Then either sleep or run make. You would run this as a daemon or in the background of your session.