I want to write a makefile that has a build rule, a run rule and a clean (delete the exe file) rule . This is quite a simple task, but how can one incorporate some rule in the makefile such that the executable is only created if it doesn't already exist ?

  • 1
    Your question is quite broad you can probably accomplish this several ways [ -e file ] || make ... Post your file if you need help.
    – Panther
    Jan 26, 2015 at 17:47

1 Answer 1


If your build rule depends on the source needed to create the executable, then it will automatically only do the build process if the executable is not present (or any source files have modification time newer than the existing executable). So unless I'm missing something, you don't need anything special to make this happen.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .